@pie-element/multiple-choice 13.1.1-next.0 → 13.2.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +1972 -0
- package/CHANGELOG.md +2696 -0
- package/LICENSE.md +5 -0
- package/PRINT.md +35 -0
- package/README.md +56 -0
- package/choice.png +0 -0
- package/configure/CHANGELOG.json +1387 -0
- package/configure/CHANGELOG.md +2046 -0
- package/{src/author/defaults.ts → configure/lib/defaults.js} +90 -55
- package/configure/lib/defaults.js.map +1 -0
- package/{src/author/index.ts → configure/lib/index.js} +51 -98
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +477 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/utils.js +18 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +22 -0
- package/controller/CHANGELOG.json +527 -0
- package/controller/CHANGELOG.md +1388 -0
- package/{src/controller/defaults.ts → controller/lib/defaults.js} +8 -11
- package/controller/lib/defaults.js.map +1 -0
- package/{src/controller/index.ts → controller/lib/index.js} +109 -123
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +15 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +15 -0
- package/docs/config-schema.json +2993 -0
- package/docs/config-schema.json.md +2217 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +61 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +7 -0
- package/docs/pie-schema.json +1332 -0
- package/docs/pie-schema.json.md +1015 -0
- package/lib/choice-input.js +380 -0
- package/lib/choice-input.js.map +1 -0
- package/lib/choice.js +197 -0
- package/lib/choice.js.map +1 -0
- package/lib/feedback-tick.js +134 -0
- package/lib/feedback-tick.js.map +1 -0
- package/{src/delivery/index.ts → lib/index.js} +129 -211
- package/lib/index.js.map +1 -0
- package/lib/main.js +63 -0
- package/lib/main.js.map +1 -0
- package/lib/multiple-choice.js +412 -0
- package/lib/multiple-choice.js.map +1 -0
- package/lib/print.js +94 -0
- package/lib/print.js.map +1 -0
- package/{src/delivery/session-updater.ts → lib/session-updater.js} +13 -17
- package/lib/session-updater.js.map +1 -0
- package/module/configure.js +1 -0
- package/module/controller.js +3045 -0
- package/module/demo.js +86 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +10 -0
- package/module/print-demo.js +124 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +26 -58
- package/dist/author/defaults.d.ts +0 -206
- package/dist/author/defaults.d.ts.map +0 -1
- package/dist/author/defaults.js +0 -151
- package/dist/author/index.d.ts +0 -27
- package/dist/author/index.d.ts.map +0 -1
- package/dist/author/index.js +0 -116
- package/dist/author/main.d.ts +0 -35
- package/dist/author/main.d.ts.map +0 -1
- package/dist/author/main.js +0 -290
- package/dist/author/utils.d.ts +0 -10
- package/dist/author/utils.d.ts.map +0 -1
- package/dist/author/utils.js +0 -7
- package/dist/controller/defaults.d.ts +0 -36
- package/dist/controller/defaults.d.ts.map +0 -1
- package/dist/controller/defaults.js +0 -29
- package/dist/controller/index.d.ts +0 -66
- package/dist/controller/index.d.ts.map +0 -1
- package/dist/controller/index.js +0 -124
- package/dist/controller/utils.d.ts +0 -11
- package/dist/controller/utils.d.ts.map +0 -1
- package/dist/controller/utils.js +0 -8
- package/dist/delivery/choice-input.d.ts +0 -45
- package/dist/delivery/choice-input.d.ts.map +0 -1
- package/dist/delivery/choice-input.js +0 -274
- package/dist/delivery/choice.d.ts +0 -21
- package/dist/delivery/choice.d.ts.map +0 -1
- package/dist/delivery/choice.js +0 -109
- package/dist/delivery/feedback-tick.d.ts +0 -21
- package/dist/delivery/feedback-tick.d.ts.map +0 -1
- package/dist/delivery/feedback-tick.js +0 -104
- package/dist/delivery/index.d.ts +0 -38
- package/dist/delivery/index.d.ts.map +0 -1
- package/dist/delivery/index.js +0 -217
- package/dist/delivery/main.d.ts +0 -32
- package/dist/delivery/main.d.ts.map +0 -1
- package/dist/delivery/main.js +0 -51
- package/dist/delivery/multiple-choice.d.ts +0 -63
- package/dist/delivery/multiple-choice.d.ts.map +0 -1
- package/dist/delivery/multiple-choice.js +0 -252
- package/dist/delivery/session-updater.d.ts +0 -11
- package/dist/delivery/session-updater.d.ts.map +0 -1
- package/dist/delivery/session-updater.js +0 -9
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.iife.d.ts +0 -9
- package/dist/index.iife.d.ts.map +0 -1
- package/dist/index.iife.js +0 -148
- package/dist/index.js +0 -2
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +0 -57
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +0 -30
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMerge.js +0 -19
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMergeDeep.js +0 -31
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTrim.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createAssigner.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +0 -32
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +0 -23
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +0 -33
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIterateeCall.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_trimmedEndIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js +0 -50
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/defaults.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +0 -21
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/merge.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +0 -19
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js +0 -8
- package/dist/print/index.d.ts +0 -16
- package/dist/print/index.d.ts.map +0 -1
- package/dist/print/index.js +0 -44
- package/src/author/main.tsx +0 -509
- package/src/author/utils.ts +0 -25
- package/src/controller/utils.ts +0 -22
- package/src/delivery/choice-input.tsx +0 -413
- package/src/delivery/choice.tsx +0 -203
- package/src/delivery/feedback-tick.tsx +0 -156
- package/src/delivery/main.tsx +0 -85
- package/src/delivery/multiple-choice.tsx +0 -485
- package/src/index.iife.ts +0 -16
- package/src/index.ts +0 -1
- package/src/print/index.tsx +0 -112
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @synced-from pie-elements/packages/multiple-choice/controller/src/defaults.js
|
|
4
|
-
* @auto-generated
|
|
5
|
-
*
|
|
6
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
-
* Manual edits will be overwritten on next sync.
|
|
8
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
-
*/
|
|
1
|
+
"use strict";
|
|
10
2
|
|
|
11
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
12
8
|
choiceMode: 'checkbox',
|
|
13
9
|
choicePrefix: 'letters',
|
|
14
10
|
choices: [],
|
|
@@ -32,5 +28,6 @@ export default {
|
|
|
32
28
|
hoverAnswerBackgroundColor: 'initial',
|
|
33
29
|
hoverAnswerStrokeColor: 'initial',
|
|
34
30
|
hoverAnswerStrokeWidth: 'initial',
|
|
35
|
-
keyboardEventsEnabled: false
|
|
31
|
+
keyboardEventsEnabled: false
|
|
36
32
|
};
|
|
33
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["choiceMode","choicePrefix","choices","choicesLayout","feedbackEnabled","gridColumns","lockChoiceOrder","partialScoring","prompt","promptEnabled","rationale","rationaleEnabled","scoringType","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","keyboardEventsEnabled"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n choiceMode: 'checkbox',\n choicePrefix: 'letters',\n choices: [],\n choicesLayout: 'vertical',\n feedbackEnabled: false,\n gridColumns: 2,\n lockChoiceOrder: true,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n selectedAnswerBackgroundColor: 'initial',\n selectedAnswerStrokeColor: 'initial',\n selectedAnswerStrokeWidth: 'initial',\n hoverAnswerBackgroundColor: 'initial',\n hoverAnswerStrokeColor: 'initial',\n hoverAnswerStrokeWidth: 'initial',\n keyboardEventsEnabled: false,\n};\n"],"mappings":";;;;;;iCAAe;EACbA,UAAU,EAAE,UAAU;EACtBC,YAAY,EAAE,SAAS;EACvBC,OAAO,EAAE,EAAE;EACXC,aAAa,EAAE,UAAU;EACzBC,eAAe,EAAE,KAAK;EACtBC,WAAW,EAAE,CAAC;EACdC,eAAe,EAAE,IAAI;EACrBC,cAAc,EAAE,IAAI;EACpBC,MAAM,EAAE,EAAE;EACVC,aAAa,EAAE,IAAI;EACnBC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,IAAI;EACtBC,WAAW,EAAE,MAAM;EACnBC,0BAA0B,EAAE,IAAI;EAChCC,mBAAmB,EAAE,EAAE;EACvBC,0BAA0B,EAAE,IAAI;EAChCC,qBAAqB,EAAE,QAAQ;EAC/BC,6BAA6B,EAAE,SAAS;EACxCC,yBAAyB,EAAE,SAAS;EACpCC,yBAAyB,EAAE,SAAS;EACpCC,0BAA0B,EAAE,SAAS;EACrCC,sBAAsB,EAAE,SAAS;EACjCC,sBAAsB,EAAE,SAAS;EACjCC,qBAAqB,EAAE;AACzB,CAAC","ignoreList":[]}
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createCorrectResponseSession = void 0;
|
|
8
|
+
exports.createDefaultModel = createDefaultModel;
|
|
9
|
+
exports.getScore = exports.getLogTrace = void 0;
|
|
10
|
+
exports.model = model;
|
|
11
|
+
exports.normalize = void 0;
|
|
12
|
+
exports.outcome = outcome;
|
|
13
|
+
exports.validate = void 0;
|
|
14
|
+
var _lodashEs = require("lodash-es");
|
|
15
|
+
var _utils = require("./utils");
|
|
16
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
17
|
+
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
11
18
|
/* eslint-disable no-console */
|
|
12
|
-
import { isEmpty } from 'lodash-es';
|
|
13
|
-
import { isResponseCorrect } from './utils.js';
|
|
14
|
-
import defaults from './defaults.js';
|
|
15
|
-
import { lockChoices, partialScoring, getShuffledChoices } from '@pie-element/shared-controller-utils';
|
|
16
19
|
|
|
17
|
-
const prepareChoice = (model, env, defaultFeedback) =>
|
|
18
|
-
const {
|
|
20
|
+
const prepareChoice = (model, env, defaultFeedback) => choice => {
|
|
21
|
+
const {
|
|
22
|
+
role,
|
|
23
|
+
mode
|
|
24
|
+
} = env || {};
|
|
19
25
|
const out = {
|
|
20
26
|
label: choice.label,
|
|
21
|
-
value: choice.value
|
|
27
|
+
value: choice.value
|
|
22
28
|
};
|
|
23
|
-
|
|
24
29
|
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
25
30
|
out.rationale = model.rationaleEnabled ? choice.rationale : null;
|
|
26
31
|
} else {
|
|
27
32
|
out.rationale = null;
|
|
28
33
|
}
|
|
29
|
-
|
|
30
34
|
if (mode === 'evaluate') {
|
|
31
35
|
out.correct = !!choice.correct;
|
|
32
|
-
|
|
33
36
|
if (model.feedbackEnabled) {
|
|
34
|
-
const feedbackType =
|
|
35
|
-
|
|
37
|
+
const feedbackType = choice.feedback && choice.feedback.type || 'none';
|
|
36
38
|
if (feedbackType === 'default') {
|
|
37
39
|
out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];
|
|
38
40
|
} else if (feedbackType === 'custom') {
|
|
@@ -40,23 +42,26 @@ const prepareChoice = (model, env, defaultFeedback) => (choice) => {
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
|
-
|
|
44
45
|
return out;
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
function createDefaultModel(model = {}) {
|
|
48
|
+
return new Promise(resolve => resolve({
|
|
49
|
+
..._defaults.default,
|
|
50
|
+
...model
|
|
51
|
+
}));
|
|
49
52
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
const normalize = question => {
|
|
54
|
+
const {
|
|
55
|
+
verticalMode,
|
|
56
|
+
choicesLayout,
|
|
57
|
+
...questionProps
|
|
58
|
+
} = question || {};
|
|
54
59
|
return {
|
|
55
|
-
...
|
|
60
|
+
..._defaults.default,
|
|
56
61
|
...questionProps,
|
|
57
62
|
// This is used for offering support for old models which have the property verticalMode
|
|
58
63
|
// Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel
|
|
59
|
-
choicesLayout: choicesLayout ||
|
|
64
|
+
choicesLayout: choicesLayout || verticalMode === false && 'horizontal' || _defaults.default.choicesLayout
|
|
60
65
|
};
|
|
61
66
|
};
|
|
62
67
|
|
|
@@ -67,22 +72,18 @@ export const normalize = (question) => {
|
|
|
67
72
|
* @param {*} env
|
|
68
73
|
* @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
|
|
69
74
|
*/
|
|
70
|
-
|
|
75
|
+
exports.normalize = normalize;
|
|
76
|
+
async function model(question, session, env, updateSession) {
|
|
71
77
|
const normalizedQuestion = normalize(question);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
+
const defaultFeedback = Object.assign({
|
|
79
|
+
correct: 'Correct',
|
|
80
|
+
incorrect: 'Incorrect'
|
|
81
|
+
}, normalizedQuestion.defaultFeedback);
|
|
78
82
|
let choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));
|
|
79
|
-
|
|
80
|
-
const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);
|
|
81
|
-
|
|
83
|
+
const lockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion, session, env);
|
|
82
84
|
if (!lockChoiceOrder) {
|
|
83
|
-
choices = await getShuffledChoices(choices, session, updateSession, 'value');
|
|
85
|
+
choices = await (0, _controllerUtils.getShuffledChoices)(choices, session, updateSession, 'value');
|
|
84
86
|
}
|
|
85
|
-
|
|
86
87
|
const out = {
|
|
87
88
|
disabled: env.mode !== 'gather',
|
|
88
89
|
mode: env.mode,
|
|
@@ -92,7 +93,7 @@ export async function model(question, session, env, updateSession) {
|
|
|
92
93
|
choiceMode: normalizedQuestion.choiceMode,
|
|
93
94
|
keyMode: normalizedQuestion.choicePrefix,
|
|
94
95
|
choices,
|
|
95
|
-
responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,
|
|
96
|
+
responseCorrect: env.mode === 'evaluate' ? (0, _utils.isResponseCorrect)(normalizedQuestion, session) : undefined,
|
|
96
97
|
language: normalizedQuestion.language,
|
|
97
98
|
extraCSSRules: normalizedQuestion.extraCSSRules,
|
|
98
99
|
fontSizeFactor: normalizedQuestion.fontSizeFactor,
|
|
@@ -108,45 +109,33 @@ export async function model(question, session, env, updateSession) {
|
|
|
108
109
|
keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,
|
|
109
110
|
autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,
|
|
110
111
|
completeAudioEnabled: normalizedQuestion.completeAudioEnabled,
|
|
111
|
-
customAudioButton: normalizedQuestion.customAudioButton
|
|
112
|
+
customAudioButton: normalizedQuestion.customAudioButton
|
|
112
113
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const {
|
|
115
|
+
role,
|
|
116
|
+
mode
|
|
117
|
+
} = env || {};
|
|
116
118
|
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
117
|
-
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled
|
|
118
|
-
? normalizedQuestion.teacherInstructions
|
|
119
|
-
: null;
|
|
119
|
+
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
120
120
|
} else {
|
|
121
121
|
out.teacherInstructions = null;
|
|
122
122
|
}
|
|
123
|
-
|
|
124
123
|
return out;
|
|
125
124
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (!session || isEmpty(session)) {
|
|
125
|
+
const getScore = (config, session) => {
|
|
126
|
+
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
129
127
|
return 0;
|
|
130
128
|
}
|
|
131
|
-
|
|
132
129
|
const selectedChoices = session.value || [];
|
|
133
|
-
const correctChoices = (config.choices || []).filter(
|
|
134
|
-
|
|
135
|
-
let score = selectedChoices.reduce(
|
|
136
|
-
(acc, selectedChoice) => acc + (correctChoices.find((ch) => ch.value === selectedChoice) ? 1 : 0),
|
|
137
|
-
0,
|
|
138
|
-
);
|
|
139
|
-
|
|
130
|
+
const correctChoices = (config.choices || []).filter(ch => ch.correct);
|
|
131
|
+
let score = selectedChoices.reduce((acc, selectedChoice) => acc + (correctChoices.find(ch => ch.value === selectedChoice) ? 1 : 0), 0);
|
|
140
132
|
if (correctChoices.length < selectedChoices.length) {
|
|
141
133
|
score -= selectedChoices.length - correctChoices.length;
|
|
142
|
-
|
|
143
134
|
if (score < 0) {
|
|
144
135
|
score = 0;
|
|
145
136
|
}
|
|
146
137
|
}
|
|
147
|
-
|
|
148
138
|
const str = correctChoices.length ? score / correctChoices.length : 0;
|
|
149
|
-
|
|
150
139
|
return parseFloat(str.toFixed(2));
|
|
151
140
|
};
|
|
152
141
|
|
|
@@ -157,38 +146,30 @@ export const getScore = (config, session) => {
|
|
|
157
146
|
* @param {Object} env - the environment
|
|
158
147
|
* @returns {Array} traceLog - array of trace messages
|
|
159
148
|
*/
|
|
160
|
-
|
|
149
|
+
exports.getScore = getScore;
|
|
150
|
+
const getLogTrace = (model, session, env) => {
|
|
161
151
|
const traceLog = [];
|
|
162
152
|
const selected = session?.value || [];
|
|
163
|
-
|
|
164
153
|
const questionType = model.choiceMode === 'radio' ? 'multiple-choice (radio)' : 'multiple-select (checkbox)';
|
|
165
154
|
traceLog.push(`Question type: ${questionType}.`);
|
|
166
|
-
|
|
167
155
|
if (selected.length) {
|
|
168
156
|
traceLog.push(`Student selected ${selected.length} answer(s): ${selected.join(', ')}.`);
|
|
169
157
|
} else {
|
|
170
158
|
traceLog.push('Student did not select any answers.');
|
|
171
159
|
}
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
const correctValues = correctChoices.map((c) => c.value);
|
|
160
|
+
const correctChoices = (model.choices || []).filter(c => c.correct);
|
|
161
|
+
const correctValues = correctChoices.map(c => c.value);
|
|
175
162
|
traceLog.push(`${correctChoices.length} correct answer(s) are defined for this question.`);
|
|
176
|
-
|
|
177
163
|
if (selected.length) {
|
|
178
|
-
const correctSelected = selected.filter(
|
|
179
|
-
const incorrectSelected = selected.filter(
|
|
180
|
-
traceLog.push(
|
|
181
|
-
`Student selected ${correctSelected.length} correct and ${incorrectSelected.length} incorrect answer(s).`
|
|
182
|
-
);
|
|
164
|
+
const correctSelected = selected.filter(v => correctValues.includes(v));
|
|
165
|
+
const incorrectSelected = selected.filter(v => !correctValues.includes(v));
|
|
166
|
+
traceLog.push(`Student selected ${correctSelected.length} correct and ${incorrectSelected.length} incorrect answer(s).`);
|
|
183
167
|
}
|
|
184
|
-
|
|
185
|
-
const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
|
|
168
|
+
const partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
|
|
186
169
|
const scoringMethod = partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring';
|
|
187
170
|
traceLog.push(`Score calculated using ${scoringMethod}.`);
|
|
188
|
-
|
|
189
171
|
const score = getScore(model, session);
|
|
190
172
|
traceLog.push(`Final score: ${score}.`);
|
|
191
|
-
|
|
192
173
|
return traceLog;
|
|
193
174
|
};
|
|
194
175
|
|
|
@@ -201,32 +182,38 @@ export const getLogTrace = (model, session, env) => {
|
|
|
201
182
|
* @param {*} session
|
|
202
183
|
* @param {Object} env
|
|
203
184
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
185
|
+
exports.getLogTrace = getLogTrace;
|
|
186
|
+
function outcome(model, session, env) {
|
|
187
|
+
return new Promise(resolve => {
|
|
188
|
+
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
189
|
+
resolve({
|
|
190
|
+
score: 0,
|
|
191
|
+
empty: true,
|
|
192
|
+
traceLog: ['Student did not select any answers. Score is 0.']
|
|
193
|
+
});
|
|
208
194
|
} else {
|
|
209
195
|
const traceLog = getLogTrace(model, session, env);
|
|
210
196
|
const score = getScore(model, session);
|
|
211
|
-
const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
traceLog
|
|
197
|
+
const partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
|
|
198
|
+
resolve({
|
|
199
|
+
score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
|
|
200
|
+
empty: false,
|
|
201
|
+
traceLog
|
|
217
202
|
});
|
|
218
203
|
}
|
|
219
204
|
});
|
|
220
205
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return new Promise((resolve) => {
|
|
206
|
+
const createCorrectResponseSession = (question, env) => {
|
|
207
|
+
return new Promise(resolve => {
|
|
224
208
|
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
225
|
-
const {
|
|
226
|
-
|
|
209
|
+
const {
|
|
210
|
+
choices
|
|
211
|
+
} = question || {
|
|
212
|
+
choices: []
|
|
213
|
+
};
|
|
227
214
|
resolve({
|
|
228
215
|
id: '1',
|
|
229
|
-
value: choices.filter(
|
|
216
|
+
value: choices.filter(c => c.correct).map(c => c.value)
|
|
230
217
|
});
|
|
231
218
|
} else {
|
|
232
219
|
resolve(null);
|
|
@@ -235,68 +222,67 @@ export const createCorrectResponseSession = (question, env) => {
|
|
|
235
222
|
};
|
|
236
223
|
|
|
237
224
|
// remove all html tags
|
|
238
|
-
|
|
225
|
+
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
226
|
+
const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
239
227
|
|
|
240
228
|
// remove all html tags except img, iframe and source tag for audio
|
|
241
|
-
const getContent =
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
229
|
+
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
230
|
+
const validate = (model = {}, config = {}) => {
|
|
231
|
+
const {
|
|
232
|
+
choices
|
|
233
|
+
} = model;
|
|
234
|
+
const {
|
|
235
|
+
minAnswerChoices = 2,
|
|
236
|
+
maxAnswerChoices
|
|
237
|
+
} = config;
|
|
246
238
|
const reversedChoices = [...(choices || [])].reverse();
|
|
247
239
|
const choicesErrors = {};
|
|
248
240
|
const rationaleErrors = {};
|
|
249
241
|
const errors = {};
|
|
250
|
-
|
|
251
|
-
['teacherInstructions', 'prompt'].forEach((field) => {
|
|
242
|
+
['teacherInstructions', 'prompt'].forEach(field => {
|
|
252
243
|
if (config[field]?.required && !getContent(model[field])) {
|
|
253
244
|
errors[field] = 'This field is required.';
|
|
254
245
|
}
|
|
255
246
|
});
|
|
256
|
-
|
|
257
247
|
let hasCorrectResponse = false;
|
|
258
|
-
|
|
259
248
|
reversedChoices.forEach((choice, index) => {
|
|
260
|
-
const {
|
|
261
|
-
|
|
249
|
+
const {
|
|
250
|
+
correct,
|
|
251
|
+
value,
|
|
252
|
+
label,
|
|
253
|
+
rationale
|
|
254
|
+
} = choice;
|
|
262
255
|
if (correct) {
|
|
263
256
|
hasCorrectResponse = true;
|
|
264
257
|
}
|
|
265
|
-
|
|
266
258
|
if (!getContent(label)) {
|
|
267
259
|
choicesErrors[value] = 'Content should not be empty.';
|
|
268
260
|
} else {
|
|
269
|
-
const identicalAnswer = reversedChoices.slice(index + 1).some(
|
|
270
|
-
|
|
261
|
+
const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);
|
|
271
262
|
if (identicalAnswer) {
|
|
272
263
|
choicesErrors[value] = 'Content should be unique.';
|
|
273
264
|
}
|
|
274
265
|
}
|
|
275
|
-
|
|
276
266
|
if (config.rationale?.required && !getContent(rationale)) {
|
|
277
267
|
rationaleErrors[value] = 'This field is required.';
|
|
278
268
|
}
|
|
279
269
|
});
|
|
280
|
-
|
|
281
270
|
const nbOfChoices = (choices || []).length;
|
|
282
|
-
|
|
283
271
|
if (nbOfChoices < minAnswerChoices) {
|
|
284
272
|
errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;
|
|
285
273
|
} else if (nbOfChoices > maxAnswerChoices) {
|
|
286
274
|
errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;
|
|
287
275
|
}
|
|
288
|
-
|
|
289
276
|
if (!hasCorrectResponse) {
|
|
290
277
|
errors.correctResponse = 'No correct response defined.';
|
|
291
278
|
}
|
|
292
|
-
|
|
293
|
-
if (!isEmpty(choicesErrors)) {
|
|
279
|
+
if (!(0, _lodashEs.isEmpty)(choicesErrors)) {
|
|
294
280
|
errors.choices = choicesErrors;
|
|
295
281
|
}
|
|
296
|
-
|
|
297
|
-
if (!isEmpty(rationaleErrors)) {
|
|
282
|
+
if (!(0, _lodashEs.isEmpty)(rationaleErrors)) {
|
|
298
283
|
errors.rationale = rationaleErrors;
|
|
299
284
|
}
|
|
300
|
-
|
|
301
285
|
return errors;
|
|
302
286
|
};
|
|
287
|
+
exports.validate = validate;
|
|
288
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_lodashEs","require","_utils","_defaults","_interopRequireDefault","_controllerUtils","prepareChoice","model","env","defaultFeedback","choice","role","mode","out","label","value","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","createDefaultModel","Promise","resolve","defaults","normalize","question","verticalMode","choicesLayout","questionProps","exports","session","updateSession","normalizedQuestion","Object","assign","incorrect","choices","map","lockChoiceOrder","lockChoices","getShuffledChoices","disabled","prompt","promptEnabled","gridColumns","choiceMode","keyMode","choicePrefix","responseCorrect","isResponseCorrect","undefined","language","extraCSSRules","fontSizeFactor","isSelectionButtonBelow","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","minSelections","maxSelections","keyboardEventsEnabled","autoplayAudioEnabled","completeAudioEnabled","customAudioButton","teacherInstructions","teacherInstructionsEnabled","getScore","config","isEmpty","selectedChoices","correctChoices","filter","ch","score","reduce","acc","selectedChoice","find","length","str","parseFloat","toFixed","getLogTrace","traceLog","selected","questionType","push","join","c","correctValues","correctSelected","v","includes","incorrectSelected","partialScoringEnabled","partialScoring","enabled","scoringMethod","outcome","empty","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","choicesErrors","rationaleErrors","errors","forEach","field","required","hasCorrectResponse","index","identicalAnswer","slice","some","nbOfChoices","answerChoices","correctResponse"],"sources":["../src/index.js"],"sourcesContent":["/* eslint-disable no-console */\nimport { isEmpty } from 'lodash-es';\nimport { isResponseCorrect } from './utils';\nimport defaults from './defaults';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-lib/controller-utils';\n\nconst prepareChoice = (model, env, defaultFeedback) => (choice) => {\n const { role, mode } = env || {};\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = (question) => {\n const { verticalMode, choicesLayout, ...questionProps } = question || {};\n\n return {\n ...defaults,\n ...questionProps,\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel\n choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout,\n };\n};\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n let choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'value');\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n fontSizeFactor: normalizedQuestion.fontSizeFactor,\n isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,\n selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',\n selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',\n selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',\n hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',\n hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',\n hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',\n minSelections: normalizedQuestion.minSelections,\n maxSelections: normalizedQuestion.maxSelections,\n keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,\n autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,\n completeAudioEnabled: normalizedQuestion.completeAudioEnabled,\n customAudioButton: normalizedQuestion.customAudioButton,\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport const getScore = (config, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session.value || [];\n const correctChoices = (config.choices || []).filter((ch) => ch.correct);\n\n let score = selectedChoices.reduce(\n (acc, selectedChoice) => acc + (correctChoices.find((ch) => ch.value === selectedChoice) ? 1 : 0),\n 0,\n );\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\n};\n\n/**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (model, session, env) => {\n const traceLog = [];\n const selected = session?.value || [];\n \n const questionType = model.choiceMode === 'radio' ? 'multiple-choice (radio)' : 'multiple-select (checkbox)';\n traceLog.push(`Question type: ${questionType}.`);\n \n if (selected.length) {\n traceLog.push(`Student selected ${selected.length} answer(s): ${selected.join(', ')}.`);\n } else {\n traceLog.push('Student did not select any answers.');\n }\n\n const correctChoices = (model.choices || []).filter((c) => c.correct);\n const correctValues = correctChoices.map((c) => c.value);\n traceLog.push(`${correctChoices.length} correct answer(s) are defined for this question.`);\n \n if (selected.length) {\n const correctSelected = selected.filter((v) => correctValues.includes(v));\n const incorrectSelected = selected.filter((v) => !correctValues.includes(v));\n traceLog.push(\n `Student selected ${correctSelected.length} correct and ${incorrectSelected.length} incorrect answer(s).`\n );\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const scoringMethod = partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring';\n traceLog.push(`Score calculated using ${scoringMethod}.`);\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true, traceLog: ['Student did not select any answers. Score is 0.'] });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n\n resolve({ \n score: partialScoringEnabled ? score : score === 1 ? 1 : 0, \n empty: false, \n traceLog \n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter((c) => c.correct).map((c) => c.value),\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const choicesErrors = {};\n const rationaleErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n let hasCorrectResponse = false;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label, rationale } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\n\n if (!getContent(label)) {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n\n if (config.rationale?.required && !getContent(rationale)) {\n rationaleErrors[value] = 'This field is required.';\n }\n });\n\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponse = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choices = choicesErrors;\n }\n\n if (!isEmpty(rationaleErrors)) {\n errors.rationale = rationaleErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAJA;;AAMA,MAAMK,aAAa,GAAGA,CAACC,KAAK,EAAEC,GAAG,EAAEC,eAAe,KAAMC,MAAM,IAAK;EACjE,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAC,GAAGJ,GAAG,IAAI,CAAC,CAAC;EAChC,MAAMK,GAAG,GAAG;IACVC,KAAK,EAAEJ,MAAM,CAACI,KAAK;IACnBC,KAAK,EAAEL,MAAM,CAACK;EAChB,CAAC;EAED,IAAIJ,IAAI,KAAK,YAAY,KAAKC,IAAI,KAAK,MAAM,IAAIA,IAAI,KAAK,UAAU,CAAC,EAAE;IACrEC,GAAG,CAACG,SAAS,GAAGT,KAAK,CAACU,gBAAgB,GAAGP,MAAM,CAACM,SAAS,GAAG,IAAI;EAClE,CAAC,MAAM;IACLH,GAAG,CAACG,SAAS,GAAG,IAAI;EACtB;EAEA,IAAIJ,IAAI,KAAK,UAAU,EAAE;IACvBC,GAAG,CAACK,OAAO,GAAG,CAAC,CAACR,MAAM,CAACQ,OAAO;IAE9B,IAAIX,KAAK,CAACY,eAAe,EAAE;MACzB,MAAMC,YAAY,GAAIV,MAAM,CAACW,QAAQ,IAAIX,MAAM,CAACW,QAAQ,CAACC,IAAI,IAAK,MAAM;MAExE,IAAIF,YAAY,KAAK,SAAS,EAAE;QAC9BP,GAAG,CAACQ,QAAQ,GAAGZ,eAAe,CAACC,MAAM,CAACQ,OAAO,GAAG,SAAS,GAA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GAAG,CAAC,CAAC,CAACG,IAAI,CAAElC,CAAC,IAAKA,CAAC,CAAChF,KAAK,KAAKA,KAAK,CAAC;MAEvF,IAAIgH,eAAe,EAAE;QACnBR,aAAa,CAACvG,KAAK,CAAC,GAAG,2BAA2B;MACpD;IACF;IAEA,IAAI0D,MAAM,CAACzD,SAAS,EAAE2G,QAAQ,IAAI,CAACZ,UAAU,CAAC/F,SAAS,CAAC,EAAE;MACxDuG,eAAe,CAACxG,KAAK,CAAC,GAAG,yBAAyB;IACpD;EACF,CAAC,CAAC;EAEF,MAAMkH,WAAW,GAAG,CAAC1F,OAAO,IAAI,EAAE,EAAE6C,MAAM;EAE1C,IAAI6C,WAAW,GAAGf,gBAAgB,EAAE;IAClCM,MAAM,CAACU,aAAa,GAAG,4BAA4BhB,gBAAgB,mBAAmB;EACxF,CAAC,MAAM,IAAIe,WAAW,GAAGd,gBAAgB,EAAE;IACzCK,MAAM,CAACU,aAAa,GAAG,gBAAgBf,gBAAgB,6BAA6B;EACtF;EAEA,IAAI,CAACS,kBAAkB,EAAE;IACvBJ,MAAM,CAACW,eAAe,GAAG,8BAA8B;EACzD;EAEA,IAAI,CAAC,IAAAzD,iBAAO,EAAC4C,aAAa,CAAC,EAAE;IAC3BE,MAAM,CAACjF,OAAO,GAAG+E,aAAa;EAChC;EAEA,IAAI,CAAC,IAAA5C,iBAAO,EAAC6C,eAAe,CAAC,EAAE;IAC7BC,MAAM,CAACxG,SAAS,GAAGuG,eAAe;EACpC;EAEA,OAAOC,MAAM;AACf,CAAC;AAACxF,OAAA,CAAAiF,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isResponseCorrect = exports.getCorrectResponse = void 0;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
const getCorrectResponse = choices => choices.filter(c => c.correct).map(c => c.value).sort();
|
|
9
|
+
exports.getCorrectResponse = getCorrectResponse;
|
|
10
|
+
const isResponseCorrect = (question, session) => {
|
|
11
|
+
let correctResponse = getCorrectResponse(question.choices);
|
|
12
|
+
return session && (0, _lodashEs.isEqual)((session.value || []).sort(), correctResponse);
|
|
13
|
+
};
|
|
14
|
+
exports.isResponseCorrect = isResponseCorrect;
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_lodashEs","require","getCorrectResponse","choices","filter","c","correct","map","value","sort","exports","isResponseCorrect","question","session","correctResponse","isEqual"],"sources":["../src/utils.js"],"sourcesContent":["import { isEqual } from 'lodash-es';\n\nexport const getCorrectResponse = (choices) =>\n choices\n .filter((c) => c.correct)\n .map((c) => c.value)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n let correctResponse = getCorrectResponse(question.choices);\n return session && isEqual((session.value || []).sort(), correctResponse);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAIC,OAAO,IACxCA,OAAO,CACJC,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,CAAC,CACxBC,GAAG,CAAEF,CAAC,IAAKA,CAAC,CAACG,KAAK,CAAC,CACnBC,IAAI,CAAC,CAAC;AAACC,OAAA,CAAAR,kBAAA,GAAAA,kBAAA;AAEL,MAAMS,iBAAiB,GAAGA,CAACC,QAAQ,EAAEC,OAAO,KAAK;EACtD,IAAIC,eAAe,GAAGZ,kBAAkB,CAACU,QAAQ,CAACT,OAAO,CAAC;EAC1D,OAAOU,OAAO,IAAI,IAAAE,iBAAO,EAAC,CAACF,OAAO,CAACL,KAAK,IAAI,EAAE,EAAEC,IAAI,CAAC,CAAC,EAAEK,eAAe,CAAC;AAC1E,CAAC;AAACJ,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-element/multiple-choice-controller",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "8.1.0-next.0",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "src/index.js",
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@pie-lib/controller-utils": "2.0.0",
|
|
12
|
+
"debug": "^4.1.1",
|
|
13
|
+
"lodash-es": "^4.17.23"
|
|
14
|
+
}
|
|
15
|
+
}
|