@pie-element/multiple-choice 13.1.0 → 13.1.1-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/dist/author/defaults.d.ts +206 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +151 -0
- package/dist/author/index.d.ts +27 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +116 -0
- package/dist/author/main.d.ts +35 -0
- package/dist/author/main.d.ts.map +1 -0
- package/dist/author/main.js +290 -0
- package/dist/author/utils.d.ts +10 -0
- package/dist/author/utils.d.ts.map +1 -0
- package/dist/author/utils.js +7 -0
- package/dist/controller/defaults.d.ts +36 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +29 -0
- package/dist/controller/index.d.ts +66 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +124 -0
- package/dist/controller/utils.d.ts +11 -0
- package/dist/controller/utils.d.ts.map +1 -0
- package/dist/controller/utils.js +8 -0
- package/dist/delivery/choice-input.d.ts +45 -0
- package/dist/delivery/choice-input.d.ts.map +1 -0
- package/dist/delivery/choice-input.js +274 -0
- package/dist/delivery/choice.d.ts +21 -0
- package/dist/delivery/choice.d.ts.map +1 -0
- package/dist/delivery/choice.js +109 -0
- package/dist/delivery/feedback-tick.d.ts +21 -0
- package/dist/delivery/feedback-tick.d.ts.map +1 -0
- package/dist/delivery/feedback-tick.js +104 -0
- package/dist/delivery/index.d.ts +38 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +217 -0
- package/dist/delivery/main.d.ts +32 -0
- package/dist/delivery/main.d.ts.map +1 -0
- package/dist/delivery/main.js +51 -0
- package/dist/delivery/multiple-choice.d.ts +63 -0
- package/dist/delivery/multiple-choice.d.ts.map +1 -0
- package/dist/delivery/multiple-choice.js +252 -0
- package/dist/delivery/session-updater.d.ts +11 -0
- package/dist/delivery/session-updater.d.ts.map +1 -0
- package/dist/delivery/session-updater.js +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.d.ts +9 -0
- package/dist/index.iife.d.ts.map +1 -0
- package/dist/index.iife.js +148 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +30 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMerge.js +19 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMergeDeep.js +31 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTrim.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createAssigner.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +32 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIterateeCall.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js +50 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/defaults.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/merge.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +19 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js +8 -0
- package/dist/print/index.d.ts +16 -0
- package/dist/print/index.d.ts.map +1 -0
- package/dist/print/index.js +44 -0
- package/package.json +58 -26
- package/{configure/lib/defaults.js → src/author/defaults.ts} +55 -90
- package/{configure/lib/index.js → src/author/index.ts} +98 -51
- package/src/author/main.tsx +509 -0
- package/src/author/utils.ts +25 -0
- package/{controller/lib/defaults.js → src/controller/defaults.ts} +11 -8
- package/{controller/lib/index.js → src/controller/index.ts} +123 -109
- package/src/controller/utils.ts +22 -0
- package/src/delivery/choice-input.tsx +413 -0
- package/src/delivery/choice.tsx +203 -0
- package/src/delivery/feedback-tick.tsx +156 -0
- package/{lib/index.js → src/delivery/index.ts} +211 -129
- package/src/delivery/main.tsx +85 -0
- package/src/delivery/multiple-choice.tsx +485 -0
- package/{lib/session-updater.js → src/delivery/session-updater.ts} +17 -13
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
- package/src/print/index.tsx +112 -0
- package/CHANGELOG.json +0 -1972
- package/CHANGELOG.md +0 -2696
- package/LICENSE.md +0 -5
- package/PRINT.md +0 -35
- package/README.md +0 -56
- package/choice.png +0 -0
- package/configure/CHANGELOG.json +0 -1387
- package/configure/CHANGELOG.md +0 -2046
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -477
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/utils.js +0 -18
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -22
- package/controller/CHANGELOG.json +0 -527
- package/controller/CHANGELOG.md +0 -1388
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -15
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -15
- package/docs/config-schema.json +0 -2993
- package/docs/config-schema.json.md +0 -2217
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -61
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -7
- package/docs/pie-schema.json +0 -1332
- package/docs/pie-schema.json.md +0 -1015
- package/lib/choice-input.js +0 -380
- package/lib/choice-input.js.map +0 -1
- package/lib/choice.js +0 -197
- package/lib/choice.js.map +0 -1
- package/lib/feedback-tick.js +0 -134
- package/lib/feedback-tick.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -63
- package/lib/main.js.map +0 -1
- package/lib/multiple-choice.js +0 -412
- package/lib/multiple-choice.js.map +0 -1
- package/lib/print.js +0 -94
- package/lib/print.js.map +0 -1
- package/lib/session-updater.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -3045
- package/module/demo.js +0 -86
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -124
- package/module/print.html +0 -18
- package/module/print.js +0 -1
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/multiple-choice/src/multiple-choice.jsx
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import { styled } from '@mui/material/styles';
|
|
16
|
+
import Box from '@mui/material/Box';
|
|
17
|
+
import { color, Collapsible as CollapsibleImport, PreviewPrompt as PreviewPromptImport, transformDataHeadings } from '@pie-lib/render-ui';
|
|
18
|
+
|
|
19
|
+
function isRenderableReactInteropType(value: any) {
|
|
20
|
+
return (
|
|
21
|
+
typeof value === 'function' ||
|
|
22
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
27
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
28
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
29
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
30
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
31
|
+
return maybeSymbol[namedExport];
|
|
32
|
+
}
|
|
33
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
34
|
+
return maybeSymbol[namedExport].default;
|
|
35
|
+
}
|
|
36
|
+
return maybeSymbol;
|
|
37
|
+
}
|
|
38
|
+
const PreviewPrompt = unwrapReactInteropSymbol(PreviewPromptImport, 'PreviewPrompt') || unwrapReactInteropSymbol(renderUi.PreviewPrompt, 'PreviewPrompt');
|
|
39
|
+
const Collapsible = unwrapReactInteropSymbol(CollapsibleImport, 'Collapsible') || unwrapReactInteropSymbol(renderUi.Collapsible, 'Collapsible');
|
|
40
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
41
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
42
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
43
|
+
const renderUi =
|
|
44
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
45
|
+
? renderUiDefaultMaybe
|
|
46
|
+
: renderUiNamespaceAny;
|
|
47
|
+
import Translator from '@pie-lib/translator';
|
|
48
|
+
|
|
49
|
+
import Choice from './choice.js';
|
|
50
|
+
|
|
51
|
+
const { translator } = Translator;
|
|
52
|
+
|
|
53
|
+
const MainContainer: any = styled(Box)({
|
|
54
|
+
color: color.text(),
|
|
55
|
+
backgroundColor: color.background(),
|
|
56
|
+
'& *': {
|
|
57
|
+
'-webkit-font-smoothing': 'antialiased',
|
|
58
|
+
},
|
|
59
|
+
position: 'relative',
|
|
60
|
+
// remove border from legend tags inside main to override the OT default styles
|
|
61
|
+
'& legend': {
|
|
62
|
+
border: 'none !important',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const PartLabel: any = styled('h2')(({ theme }) => ({
|
|
67
|
+
display: 'block',
|
|
68
|
+
fontSize: 'inherit',
|
|
69
|
+
margin: '0',
|
|
70
|
+
fontWeight: 'normal',
|
|
71
|
+
paddingBottom: theme.spacing(2),
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
const TeacherInstructions: any = styled(Box)(({ theme }) => ({
|
|
75
|
+
marginBottom: theme.spacing(2),
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
const HorizontalLayout: any = styled(Box)({
|
|
79
|
+
display: 'flex',
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
flexWrap: 'wrap',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const GridLayout: any = styled(Box)({
|
|
85
|
+
display: 'grid',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const StyledFieldset: any = styled('fieldset')({
|
|
89
|
+
border: '0px',
|
|
90
|
+
padding: '0.01em 0 0 0',
|
|
91
|
+
margin: '0px',
|
|
92
|
+
minWidth: '0px',
|
|
93
|
+
'&:focus': {
|
|
94
|
+
outline: 'none',
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const SrOnly: any = styled('h3')({
|
|
99
|
+
position: 'absolute',
|
|
100
|
+
left: '-10000px',
|
|
101
|
+
top: 'auto',
|
|
102
|
+
width: '1px',
|
|
103
|
+
height: '1px',
|
|
104
|
+
overflow: 'hidden',
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const ErrorText: any = styled('div')(({ theme }) => ({
|
|
108
|
+
fontSize: theme.typography.fontSize - 2,
|
|
109
|
+
color: theme.palette.error.main,
|
|
110
|
+
paddingTop: theme.spacing(1),
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
export class MultipleChoice extends React.Component {
|
|
114
|
+
static propTypes = {
|
|
115
|
+
className: PropTypes.string,
|
|
116
|
+
mode: PropTypes.oneOf(['gather', 'view', 'evaluate']),
|
|
117
|
+
choiceMode: PropTypes.oneOf(['radio', 'checkbox']),
|
|
118
|
+
keyMode: PropTypes.oneOf(['numbers', 'letters', 'none']),
|
|
119
|
+
choices: PropTypes.array,
|
|
120
|
+
partLabel: PropTypes.string,
|
|
121
|
+
prompt: PropTypes.string,
|
|
122
|
+
teacherInstructions: PropTypes.string,
|
|
123
|
+
session: PropTypes.object,
|
|
124
|
+
disabled: PropTypes.bool,
|
|
125
|
+
onChoiceChanged: PropTypes.func,
|
|
126
|
+
responseCorrect: PropTypes.bool,
|
|
127
|
+
correctResponse: PropTypes.array,
|
|
128
|
+
choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),
|
|
129
|
+
gridColumns: PropTypes.string,
|
|
130
|
+
alwaysShowCorrect: PropTypes.bool,
|
|
131
|
+
animationsDisabled: PropTypes.bool,
|
|
132
|
+
language: PropTypes.string,
|
|
133
|
+
selectedAnswerBackgroundColor: PropTypes.string,
|
|
134
|
+
selectedAnswerStrokeColor: PropTypes.string,
|
|
135
|
+
selectedAnswerStrokeWidth: PropTypes.string,
|
|
136
|
+
hoverAnswerBackgroundColor: PropTypes.string,
|
|
137
|
+
hoverAnswerStrokeColor: PropTypes.string,
|
|
138
|
+
hoverAnswerStrokeWidth: PropTypes.string,
|
|
139
|
+
onShowCorrectToggle: PropTypes.func,
|
|
140
|
+
isSelectionButtonBelow: PropTypes.bool,
|
|
141
|
+
minSelections: PropTypes.number,
|
|
142
|
+
maxSelections: PropTypes.number,
|
|
143
|
+
autoplayAudioEnabled: PropTypes.bool,
|
|
144
|
+
customAudioButton: {
|
|
145
|
+
playImage: PropTypes.string,
|
|
146
|
+
pauseImage: PropTypes.string,
|
|
147
|
+
},
|
|
148
|
+
options: PropTypes.object,
|
|
149
|
+
baseHeadingLevel: PropTypes.number,
|
|
150
|
+
includeSrHeading: PropTypes.bool,
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
constructor(props) {
|
|
154
|
+
super(props);
|
|
155
|
+
|
|
156
|
+
this.state = {
|
|
157
|
+
showCorrect: (this.props.options && this.props.alwaysShowCorrect) || false,
|
|
158
|
+
maxSelectionsErrorState: false,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
this.onToggle = this.onToggle.bind(this);
|
|
162
|
+
this.firstInputRef = React.createRef();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
isSelected(value) {
|
|
166
|
+
const sessionValue = this.props.session && this.props.session.value;
|
|
167
|
+
|
|
168
|
+
return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// handleChange was added for accessibility. Please see comments and videos from PD-2441.
|
|
172
|
+
handleChange: any = (event) => {
|
|
173
|
+
const { value, checked } = event.target;
|
|
174
|
+
const { maxSelections, onChoiceChanged, session } = this.props;
|
|
175
|
+
|
|
176
|
+
if (session.value && session.value.length >= maxSelections) {
|
|
177
|
+
// show/hide max selections error when user select/deselect an answer
|
|
178
|
+
this.setState({ maxSelectionsErrorState: checked });
|
|
179
|
+
|
|
180
|
+
if (checked) {
|
|
181
|
+
// prevent selecting more answers
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
onChoiceChanged({ value, selected: checked, selector: 'Mouse' });
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
onToggle: any = () => {
|
|
190
|
+
if (this.props.mode === 'evaluate') {
|
|
191
|
+
this.setState({ showCorrect: !this.state.showCorrect }, () => {
|
|
192
|
+
if (this.props.onShowCorrectToggle) {
|
|
193
|
+
this.props.onShowCorrectToggle();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
200
|
+
if (!nextProps.correctResponse && this.state.showCorrect !== false) {
|
|
201
|
+
this.setState({ showCorrect: false }, () => {
|
|
202
|
+
if (this.props.onShowCorrectToggle) {
|
|
203
|
+
this.props.onShowCorrectToggle();
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (nextProps.options && nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
|
|
209
|
+
this.setState({ showCorrect: true }, () => {
|
|
210
|
+
if (this.props.onShowCorrectToggle) {
|
|
211
|
+
this.props.onShowCorrectToggle();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
indexToSymbol(index) {
|
|
218
|
+
if (this.props.keyMode === 'numbers') {
|
|
219
|
+
return `${index + 1}`;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (this.props.keyMode === 'letters') {
|
|
223
|
+
return String.fromCharCode(97 + index).toUpperCase();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return '';
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
getCorrectness: any = (choice = {}) => {
|
|
230
|
+
const isCorrect = choice.correct;
|
|
231
|
+
const isChecked = this.isSelected(choice.value);
|
|
232
|
+
|
|
233
|
+
if (this.state.showCorrect) {
|
|
234
|
+
return isCorrect ? 'correct' : undefined;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (isCorrect) {
|
|
238
|
+
if (isChecked) {
|
|
239
|
+
// A correct answer is selected: marked with a green checkmark
|
|
240
|
+
return 'correct';
|
|
241
|
+
} else {
|
|
242
|
+
// A correct answer is NOT selected: marked with an orange X
|
|
243
|
+
return 'incorrect';
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
if (isChecked) {
|
|
247
|
+
// An incorrect answer is selected: marked with an orange X
|
|
248
|
+
return 'incorrect';
|
|
249
|
+
} else {
|
|
250
|
+
// An incorrect answer is NOT selected: not marked
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
getChecked(choice) {
|
|
257
|
+
// check for print context: options prop is passed from print.js and alwaysShowCorrect is true
|
|
258
|
+
const isPrintMode = this.props.options && this.props.alwaysShowCorrect;
|
|
259
|
+
|
|
260
|
+
if (isPrintMode) {
|
|
261
|
+
return choice.correct || false;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// evaluate mode with show correct toggled
|
|
265
|
+
const isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';
|
|
266
|
+
|
|
267
|
+
if (isEvaluateMode) {
|
|
268
|
+
return choice.correct || false;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// default behavior: show what the user has selected
|
|
272
|
+
return this.isSelected(choice.value);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// renderHeading function was added for accessibility.
|
|
276
|
+
renderHeading() {
|
|
277
|
+
const { mode, choiceMode, includeSrHeading, baseHeadingLevel, partLabel } = this.props;
|
|
278
|
+
|
|
279
|
+
// When a part label is present the item is an EBSR part — the SR heading
|
|
280
|
+
// is provided by the EBSR element, not here.
|
|
281
|
+
const shouldRenderSrHeading = !partLabel && includeSrHeading !== false;
|
|
282
|
+
|
|
283
|
+
if (!shouldRenderSrHeading || mode !== 'gather') {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const clampedLevel = baseHeadingLevel ? Math.min(6, baseHeadingLevel) : 2;
|
|
288
|
+
const HeadingTag = SrOnly.withComponent(`h${clampedLevel}`);
|
|
289
|
+
const label = choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Select Question';
|
|
290
|
+
|
|
291
|
+
return <HeadingTag>{label}</HeadingTag>;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
handleGroupFocus: any = (e) => {
|
|
295
|
+
const fieldset = e.currentTarget;
|
|
296
|
+
const activeEl = document.activeElement;
|
|
297
|
+
|
|
298
|
+
if (fieldset.contains(activeEl) && activeEl !== fieldset) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Only focus the first input if user is tabbing forward
|
|
303
|
+
if (!e.relatedTarget || fieldset.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
304
|
+
if (this.firstInputRef?.current) {
|
|
305
|
+
this.firstInputRef.current.focus();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
render() {
|
|
311
|
+
const {
|
|
312
|
+
mode,
|
|
313
|
+
disabled,
|
|
314
|
+
className,
|
|
315
|
+
choices = [],
|
|
316
|
+
choiceMode,
|
|
317
|
+
gridColumns,
|
|
318
|
+
partLabel,
|
|
319
|
+
prompt,
|
|
320
|
+
responseCorrect,
|
|
321
|
+
teacherInstructions,
|
|
322
|
+
alwaysShowCorrect,
|
|
323
|
+
animationsDisabled,
|
|
324
|
+
language,
|
|
325
|
+
isSelectionButtonBelow,
|
|
326
|
+
minSelections,
|
|
327
|
+
maxSelections,
|
|
328
|
+
autoplayAudioEnabled,
|
|
329
|
+
session,
|
|
330
|
+
customAudioButton,
|
|
331
|
+
options,
|
|
332
|
+
baseHeadingLevel,
|
|
333
|
+
} = this.props;
|
|
334
|
+
const { showCorrect, maxSelectionsErrorState } = this.state;
|
|
335
|
+
const isEvaluateMode = mode === 'evaluate';
|
|
336
|
+
const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
|
|
337
|
+
const columnsStyle = gridColumns > 1 ? { gridTemplateColumns: `repeat(${gridColumns}, 1fr)` } : undefined;
|
|
338
|
+
const selections = (session.value && session.value.length) || 0;
|
|
339
|
+
|
|
340
|
+
// Heading levels are optional and only applied when baseHeadingLevel is provided.
|
|
341
|
+
const getContentHeadingLevel = () => {
|
|
342
|
+
if (!baseHeadingLevel) return undefined;
|
|
343
|
+
// SR heading (rendered or external) sits at baseHeadingLevel.
|
|
344
|
+
// Content is always one below that; part label (EBSR) sits between them.
|
|
345
|
+
let offset = 1; // content default: baseHeadingLevel + 1
|
|
346
|
+
if (partLabel) offset += 1; // part label at base + 1, content pushed to base + 2
|
|
347
|
+
return Math.min(6, baseHeadingLevel + offset);
|
|
348
|
+
};
|
|
349
|
+
const contentHeadingLevel = getContentHeadingLevel();
|
|
350
|
+
const transformPrompt = (html) => (html && contentHeadingLevel) ? transformDataHeadings(html, contentHeadingLevel) : html;
|
|
351
|
+
|
|
352
|
+
const teacherInstructionsDiv = (
|
|
353
|
+
<PreviewPrompt
|
|
354
|
+
tagName="div"
|
|
355
|
+
className="prompt"
|
|
356
|
+
defaultClassName="teacher-instructions"
|
|
357
|
+
prompt={teacherInstructions}
|
|
358
|
+
/>
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
const getMultipleChoiceMinSelectionErrorMessage = () => {
|
|
362
|
+
if (minSelections && maxSelections) {
|
|
363
|
+
return minSelections === maxSelections
|
|
364
|
+
? translator.t('translation:multipleChoice:minmaxSelections_equal', { lng: language, minSelections })
|
|
365
|
+
: translator.t('translation:multipleChoice:minmaxSelections_range', {
|
|
366
|
+
lng: language,
|
|
367
|
+
minSelections,
|
|
368
|
+
maxSelections,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (minSelections) {
|
|
373
|
+
return translator.t('translation:multipleChoice:minSelections', { lng: language, minSelections });
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return '';
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const LayoutComponent = this.props.choicesLayout === 'grid'
|
|
380
|
+
? GridLayout
|
|
381
|
+
: this.props.choicesLayout === 'horizontal'
|
|
382
|
+
? HorizontalLayout
|
|
383
|
+
: Box;
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<MainContainer id={'main-container'} className={classNames(className, 'multiple-choice')}>
|
|
387
|
+
{partLabel && <PartLabel as={baseHeadingLevel ? `h${Math.min(6, baseHeadingLevel + 1)}` : 'h2'}>{partLabel}</PartLabel>}
|
|
388
|
+
|
|
389
|
+
{this.renderHeading()}
|
|
390
|
+
|
|
391
|
+
{teacherInstructions && (
|
|
392
|
+
<TeacherInstructions>
|
|
393
|
+
{!animationsDisabled ? (
|
|
394
|
+
<Collapsible
|
|
395
|
+
labels={{
|
|
396
|
+
hidden: 'Show Teacher Instructions',
|
|
397
|
+
visible: 'Hide Teacher Instructions',
|
|
398
|
+
}}
|
|
399
|
+
>
|
|
400
|
+
{teacherInstructionsDiv}
|
|
401
|
+
</Collapsible>
|
|
402
|
+
) : (
|
|
403
|
+
teacherInstructionsDiv
|
|
404
|
+
)}
|
|
405
|
+
</TeacherInstructions>
|
|
406
|
+
)}
|
|
407
|
+
|
|
408
|
+
<StyledFieldset
|
|
409
|
+
tabIndex={0}
|
|
410
|
+
onFocus={this.handleGroupFocus}
|
|
411
|
+
role={choiceMode === 'radio' ? 'radiogroup' : 'group'}
|
|
412
|
+
>
|
|
413
|
+
<PreviewPrompt
|
|
414
|
+
className="prompt"
|
|
415
|
+
defaultClassName="prompt"
|
|
416
|
+
prompt={transformPrompt(prompt)}
|
|
417
|
+
tagName={'legend'}
|
|
418
|
+
autoplayAudioEnabled={autoplayAudioEnabled}
|
|
419
|
+
customAudioButton={customAudioButton}
|
|
420
|
+
/>
|
|
421
|
+
|
|
422
|
+
{!(options && alwaysShowCorrect) && (
|
|
423
|
+
<CorrectAnswerToggle
|
|
424
|
+
show={showCorrectAnswerToggle}
|
|
425
|
+
toggled={showCorrect}
|
|
426
|
+
onToggle={this.onToggle.bind(this)}
|
|
427
|
+
language={language}
|
|
428
|
+
/>
|
|
429
|
+
)}
|
|
430
|
+
|
|
431
|
+
<LayoutComponent style={columnsStyle}>
|
|
432
|
+
{choices.map((choice, index) => (
|
|
433
|
+
<Choice
|
|
434
|
+
autoFocusRef={index === 0 ? this.firstInputRef : null}
|
|
435
|
+
choicesLayout={this.props.choicesLayout}
|
|
436
|
+
selectedAnswerBackgroundColor={this.props.selectedAnswerBackgroundColor}
|
|
437
|
+
selectedAnswerStrokeColor={this.props.selectedAnswerStrokeColor}
|
|
438
|
+
selectedAnswerStrokeWidth={this.props.selectedAnswerStrokeWidth}
|
|
439
|
+
hoverAnswerBackgroundColor={this.props.hoverAnswerBackgroundColor}
|
|
440
|
+
hoverAnswerStrokeColor={this.props.hoverAnswerStrokeColor}
|
|
441
|
+
hoverAnswerStrokeWidth={this.props.hoverAnswerStrokeWidth}
|
|
442
|
+
gridColumns={gridColumns}
|
|
443
|
+
key={`choice-${index}`}
|
|
444
|
+
choice={choice}
|
|
445
|
+
index={index}
|
|
446
|
+
choicesLength={choices.length}
|
|
447
|
+
showCorrect={showCorrect}
|
|
448
|
+
isEvaluateMode={isEvaluateMode}
|
|
449
|
+
choiceMode={choiceMode}
|
|
450
|
+
disabled={disabled}
|
|
451
|
+
tagName={partLabel ? `group-${partLabel}` : 'group'}
|
|
452
|
+
onChoiceChanged={this.handleChange}
|
|
453
|
+
hideTick={choice.hideTick}
|
|
454
|
+
checked={this.getChecked(choice)}
|
|
455
|
+
correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}
|
|
456
|
+
displayKey={this.indexToSymbol(index)}
|
|
457
|
+
isSelectionButtonBelow={isSelectionButtonBelow}
|
|
458
|
+
/>
|
|
459
|
+
))}
|
|
460
|
+
</LayoutComponent>
|
|
461
|
+
</StyledFieldset>
|
|
462
|
+
|
|
463
|
+
{choiceMode === 'checkbox' && selections < minSelections && (
|
|
464
|
+
<ErrorText>{getMultipleChoiceMinSelectionErrorMessage()}</ErrorText>
|
|
465
|
+
)}
|
|
466
|
+
{choiceMode === 'checkbox' && maxSelectionsErrorState && (
|
|
467
|
+
<ErrorText>
|
|
468
|
+
{translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
|
|
469
|
+
lng: language,
|
|
470
|
+
maxSelections,
|
|
471
|
+
})}
|
|
472
|
+
</ErrorText>
|
|
473
|
+
)}
|
|
474
|
+
</MainContainer>
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
MultipleChoice.defaultProps = {
|
|
480
|
+
session: {
|
|
481
|
+
value: [],
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
export default MultipleChoice;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/multiple-choice/src/session-updater.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
|
+
*/
|
|
2
10
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.updateSessionMetadata = updateSessionMetadata;
|
|
7
|
-
exports.updateSessionValue = updateSessionValue;
|
|
8
|
-
function updateSessionValue(session, choiceMode, data) {
|
|
11
|
+
export function updateSessionValue(session, choiceMode, data) {
|
|
9
12
|
session.value = session.value || [];
|
|
10
13
|
if (choiceMode === 'checkbox') {
|
|
11
14
|
if (data.selected) {
|
|
@@ -14,6 +17,7 @@ function updateSessionValue(session, choiceMode, data) {
|
|
|
14
17
|
session.value = session.value.filter(v => v !== data.value);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
20
|
+
|
|
17
21
|
if (choiceMode === 'radio') {
|
|
18
22
|
if (data.selected) {
|
|
19
23
|
session.value = [data.value];
|
|
@@ -21,17 +25,17 @@ function updateSessionValue(session, choiceMode, data) {
|
|
|
21
25
|
session.value = [];
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
|
-
|
|
28
|
+
|
|
25
29
|
//update session value metadata
|
|
26
30
|
session.selector = data.selector; //the input method used to select the choice (e.g. mouse, keyboard)
|
|
27
31
|
}
|
|
28
|
-
|
|
32
|
+
|
|
33
|
+
export function updateSessionMetadata(session, metadata) {
|
|
29
34
|
session.audioStartTime = session.audioStartTime || metadata.audioStartTime; //timestamp when auto-played audio started playing
|
|
30
35
|
session.audioEndTime = session.audioEndTime || metadata.audioEndTime; //timestamp when auto-played audio completed playing
|
|
31
|
-
|
|
32
|
-
if
|
|
36
|
+
|
|
37
|
+
if(!session.waitTime && session.audioStartTime && session.audioEndTime) {
|
|
33
38
|
// waitTime is elapsed time the user waited for auto-played audio to finish
|
|
34
|
-
session.waitTime = session.audioEndTime - session.audioStartTime;
|
|
39
|
+
session.waitTime = (session.audioEndTime - session.audioStartTime);
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
|
-
//# sourceMappingURL=session-updater.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IIFE entry point for multiple-choice element
|
|
3
|
+
* This file is only used for IIFE builds and includes auto-registration
|
|
4
|
+
*
|
|
5
|
+
* @sync-generated - Auto-generated during sync from pie-elements
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Element from './index.js';
|
|
9
|
+
|
|
10
|
+
// Auto-register the custom element for IIFE mode
|
|
11
|
+
if (typeof window !== 'undefined' && !customElements.get('multiple-choice-element')) {
|
|
12
|
+
customElements.define('multiple-choice-element', Element);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Export for IIFE global
|
|
16
|
+
export default Element;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './delivery/index.js';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/multiple-choice/src/print.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
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { createRoot } from 'react-dom/client';
|
|
13
|
+
import { cloneDeep, debounce } from 'lodash-es';
|
|
14
|
+
import Main from '../delivery/main.js';
|
|
15
|
+
import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
|
|
16
|
+
import debug from 'debug';
|
|
17
|
+
|
|
18
|
+
const log = debug('pie-element:multiple-choice:print');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Live in same package as main element - so we can access some of the shared comps!
|
|
22
|
+
*
|
|
23
|
+
* - update pslb to build print if src/print.js is there
|
|
24
|
+
* - update demo el
|
|
25
|
+
* - get configure/controller building
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const preparePrintModel = (model, opts) => {
|
|
29
|
+
const instr = opts.role === 'instructor';
|
|
30
|
+
|
|
31
|
+
model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
|
|
32
|
+
model.teacherInstructions =
|
|
33
|
+
instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
|
|
34
|
+
model.showTeacherInstructions = instr;
|
|
35
|
+
model.alwaysShowCorrect = instr;
|
|
36
|
+
model.mode = instr ? 'evaluate' : model.mode;
|
|
37
|
+
|
|
38
|
+
model.disabled = true;
|
|
39
|
+
model.animationsDisabled = true;
|
|
40
|
+
model.lockChoiceOrder = true;
|
|
41
|
+
model.choicesLayout = model.choicesLayout || 'vertical';
|
|
42
|
+
|
|
43
|
+
const choices = cloneDeep(model.choices);
|
|
44
|
+
|
|
45
|
+
model.choices = choices.map((c) => {
|
|
46
|
+
c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
|
|
47
|
+
c.hideTick = instr;
|
|
48
|
+
c.feedback = undefined;
|
|
49
|
+
return c;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
model.keyMode = model.choicePrefix || 'letters';
|
|
53
|
+
|
|
54
|
+
return model;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default class MultipleChoicePrint extends HTMLElement {
|
|
58
|
+
constructor() {
|
|
59
|
+
super();
|
|
60
|
+
this._options = null;
|
|
61
|
+
this._model = null;
|
|
62
|
+
this._session = [];
|
|
63
|
+
this._root = null;
|
|
64
|
+
this._rerender = debounce(
|
|
65
|
+
() => {
|
|
66
|
+
if (this._model && this._session) {
|
|
67
|
+
const printModel = preparePrintModel(this._model, this._options);
|
|
68
|
+
|
|
69
|
+
const element =
|
|
70
|
+
this._options &&
|
|
71
|
+
React.createElement(Main, {
|
|
72
|
+
model: printModel,
|
|
73
|
+
session: {},
|
|
74
|
+
options: this._options,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (!this._root) {
|
|
78
|
+
this._root = createRoot(this);
|
|
79
|
+
}
|
|
80
|
+
this._root.render(element);
|
|
81
|
+
// Use double requestAnimationFrame so React has committed to the DOM before we render math
|
|
82
|
+
requestAnimationFrame(() => {
|
|
83
|
+
requestAnimationFrame(() => {
|
|
84
|
+
log('render complete - render math');
|
|
85
|
+
renderMath(this);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
log('skip');
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
50,
|
|
93
|
+
{ leading: false, trailing: true },
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
set options(o) {
|
|
97
|
+
this._options = o;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
set model(s) {
|
|
101
|
+
this._model = s;
|
|
102
|
+
this._rerender();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
connectedCallback() {}
|
|
106
|
+
|
|
107
|
+
disconnectedCallback() {
|
|
108
|
+
if (this._root) {
|
|
109
|
+
this._root.unmount();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|