@pie-element/multiple-choice 0.1.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 +269 -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 +34 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +167 -0
- package/dist/delivery/main.d.ts +30 -0
- package/dist/delivery/main.d.ts.map +1 -0
- package/dist/delivery/main.js +47 -0
- package/dist/delivery/multiple-choice.d.ts +61 -0
- package/dist/delivery/multiple-choice.d.ts.map +1 -0
- package/dist/delivery/multiple-choice.js +241 -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 +77 -0
- package/src/author/defaults.ts +168 -0
- package/src/author/index.ts +258 -0
- package/src/author/main.tsx +509 -0
- package/src/author/utils.ts +25 -0
- package/src/controller/defaults.ts +36 -0
- package/src/controller/index.ts +302 -0
- 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/src/delivery/index.ts +411 -0
- package/src/delivery/main.tsx +81 -0
- package/src/delivery/multiple-choice.tsx +466 -0
- package/src/delivery/session-updater.ts +41 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
- package/src/print/index.tsx +112 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import e from "./main.js";
|
|
2
|
+
import t from "../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js";
|
|
3
|
+
import { updateSessionMetadata as n, updateSessionValue as r } from "./session-updater.js";
|
|
4
|
+
import i from "react";
|
|
5
|
+
import * as a from "@pie-lib/render-ui";
|
|
6
|
+
import { EnableAudioAutoplayImage as o } from "@pie-lib/render-ui";
|
|
7
|
+
import { createRoot as s } from "react-dom/client";
|
|
8
|
+
import c from "debug";
|
|
9
|
+
import { ModelSetEvent as l, SessionChangedEvent as u } from "@pie-element/shared-player-events";
|
|
10
|
+
import { renderMath as d } from "@pie-element/shared-math-rendering-mathjax";
|
|
11
|
+
//#region src/delivery/index.ts
|
|
12
|
+
function f(e) {
|
|
13
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
14
|
+
}
|
|
15
|
+
function p(e, t) {
|
|
16
|
+
return !e || f(e) ? e : f(e.default) ? e.default : t && f(e[t]) ? e[t] : t && f(e[t]?.default) ? e[t].default : e;
|
|
17
|
+
}
|
|
18
|
+
var m = p(o, "EnableAudioAutoplayImage") || p(_.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), h = a, g = h.default, _ = g && typeof g == "object" ? g : h, v = c("pie-ui:multiple-choice"), y = (e, t, n, r) => {
|
|
19
|
+
let { autoplayAudioEnabled: i, completeAudioEnabled: a } = t || {};
|
|
20
|
+
if (i && a && !n && r) {
|
|
21
|
+
let e = r.querySelector("audio"), t = e && e.closest("#preview-prompt");
|
|
22
|
+
if (e && t) return !1;
|
|
23
|
+
}
|
|
24
|
+
if (!e || !e.value) return !1;
|
|
25
|
+
let { choiceMode: o, minSelections: s = 1, maxSelections: c } = t || {}, l = e.value.length || 0;
|
|
26
|
+
return o === "radio" ? !!l : !(l < s || l > c);
|
|
27
|
+
}, b = class extends HTMLElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(), this._model = null, this._session = null, this._options = null, this.audioComplete = !1, this._boundHandleKeyDown = this.handleKeyDown.bind(this), this._keyboardEventsEnabled = !1, this._audioInitialized = !1, this._root = null, this._mathObserver = null, this._mathRenderPending = !1, this._rerender = t(() => {
|
|
30
|
+
if (this._model && this._session) {
|
|
31
|
+
var t = i.createElement(e, {
|
|
32
|
+
model: this._model,
|
|
33
|
+
session: this._session,
|
|
34
|
+
options: this._options,
|
|
35
|
+
onChoiceChanged: this._onChange.bind(this),
|
|
36
|
+
onShowCorrectToggle: this.onShowCorrectToggle.bind(this)
|
|
37
|
+
});
|
|
38
|
+
this.setAttribute("aria-label", this._model.choiceMode === "radio" ? "Multiple Choice Question" : "Multiple Correct Answer Question"), this.setAttribute("role", "region"), this.setLangAttribute(), this._initMathObserver(), this._root ||= s(this), this._root.render(t), this._model.keyboardEventsEnabled === !0 && !this._keyboardEventsEnabled && this.enableKeyboardEvents();
|
|
39
|
+
} else v("skip");
|
|
40
|
+
}, 50, {
|
|
41
|
+
leading: !1,
|
|
42
|
+
trailing: !0
|
|
43
|
+
}), this._dispatchResponseChanged = t(() => {
|
|
44
|
+
this.dispatchEvent(new u(this.tagName.toLowerCase(), y(this._session, this._model, this.audioComplete, this)));
|
|
45
|
+
}), this._dispatchModelSet = t(() => {
|
|
46
|
+
this.dispatchEvent(new l(this.tagName.toLowerCase(), y(this._session, this._model, this.audioComplete, this), this._model !== void 0));
|
|
47
|
+
}, 50, {
|
|
48
|
+
leading: !1,
|
|
49
|
+
trailing: !0
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
_scheduleMathRender = () => {
|
|
53
|
+
this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
|
|
54
|
+
this._mathObserver && this._mathObserver.disconnect(), v("render complete - render math"), d(this), this._mathRenderPending = !1, setTimeout(() => {
|
|
55
|
+
this._mathObserver && this._mathObserver.observe(this, {
|
|
56
|
+
childList: !0,
|
|
57
|
+
subtree: !0
|
|
58
|
+
});
|
|
59
|
+
}, 50);
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
_initMathObserver() {
|
|
63
|
+
this._mathObserver || (this._mathObserver = new MutationObserver(this._scheduleMathRender), this._mathObserver.observe(this, {
|
|
64
|
+
childList: !0,
|
|
65
|
+
subtree: !0
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
_disconnectMathObserver() {
|
|
69
|
+
this._mathObserver &&= (this._mathObserver.disconnect(), null);
|
|
70
|
+
}
|
|
71
|
+
onShowCorrectToggle() {
|
|
72
|
+
d(this);
|
|
73
|
+
}
|
|
74
|
+
setLangAttribute() {
|
|
75
|
+
let e = this._model && typeof this._model.language ? this._model.language : "", t = e ? e.slice(0, 2) : "en";
|
|
76
|
+
this.setAttribute("lang", t);
|
|
77
|
+
}
|
|
78
|
+
set model(e) {
|
|
79
|
+
this._model = e, this._rerender(), this._audioInitialized = !1, this._dispatchModelSet();
|
|
80
|
+
}
|
|
81
|
+
get session() {
|
|
82
|
+
return this._session;
|
|
83
|
+
}
|
|
84
|
+
get options() {
|
|
85
|
+
return this._options;
|
|
86
|
+
}
|
|
87
|
+
set options(e) {
|
|
88
|
+
this._options = e, this._rerender();
|
|
89
|
+
}
|
|
90
|
+
set session(e) {
|
|
91
|
+
this._session = e, this._rerender(), this._dispatchResponseChanged();
|
|
92
|
+
}
|
|
93
|
+
_onChange(e) {
|
|
94
|
+
r(this._session, this._model.choiceMode, e), this._dispatchResponseChanged(), this._rerender();
|
|
95
|
+
}
|
|
96
|
+
_createAudioInfoToast() {
|
|
97
|
+
let e = document.createElement("div");
|
|
98
|
+
e.id = "play-audio-info", Object.assign(e.style, {
|
|
99
|
+
position: "absolute",
|
|
100
|
+
top: 0,
|
|
101
|
+
width: "100%",
|
|
102
|
+
height: "100%",
|
|
103
|
+
display: "flex",
|
|
104
|
+
justifyContent: "center",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
background: "white",
|
|
107
|
+
zIndex: "1000",
|
|
108
|
+
cursor: "pointer"
|
|
109
|
+
});
|
|
110
|
+
let t = document.createElement("img");
|
|
111
|
+
return t.src = m, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
|
|
112
|
+
}
|
|
113
|
+
connectedCallback() {
|
|
114
|
+
this._initMathObserver(), this._rerender(), new MutationObserver((e, t) => {
|
|
115
|
+
e.forEach((e) => {
|
|
116
|
+
if (e.type === "childList") {
|
|
117
|
+
if (this._audioInitialized) return;
|
|
118
|
+
let e = this.querySelector("audio"), r = e && e.closest("#preview-prompt");
|
|
119
|
+
if (!this._model || !this._model.autoplayAudioEnabled || e && !r || !e) return;
|
|
120
|
+
let i = this._createAudioInfoToast(), a = this.querySelector("#main-container"), o = () => {
|
|
121
|
+
this.querySelector("#play-audio-info") && (e.play(), a.removeChild(i)), document.removeEventListener("click", o);
|
|
122
|
+
};
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
e.paused && !this.querySelector("#play-audio-info") ? (a.appendChild(i), document.addEventListener("click", o)) : document.removeEventListener("click", o);
|
|
125
|
+
}, 500);
|
|
126
|
+
let s = () => {
|
|
127
|
+
n(this._session, { audioStartTime: (/* @__PURE__ */ new Date()).getTime() });
|
|
128
|
+
let t = this.querySelector("#play-audio-info");
|
|
129
|
+
t && a.removeChild(t), e.removeEventListener("playing", s);
|
|
130
|
+
};
|
|
131
|
+
e.addEventListener("playing", s);
|
|
132
|
+
let c = () => {
|
|
133
|
+
n(this._session, { audioEndTime: (/* @__PURE__ */ new Date()).getTime() }), this.audioComplete = !0, this._dispatchResponseChanged(), e.removeEventListener("ended", c);
|
|
134
|
+
};
|
|
135
|
+
e.addEventListener("ended", c), this._audio = e, this._handlePlaying = s, this._handleEnded = c, this._enableAudio = o, this._audioInitialized = !0, t.disconnect();
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}).observe(this, {
|
|
139
|
+
childList: !0,
|
|
140
|
+
subtree: !0
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
enableKeyboardEvents() {
|
|
144
|
+
this._keyboardEventsEnabled ||= (window.addEventListener("keydown", this._boundHandleKeyDown), !0);
|
|
145
|
+
}
|
|
146
|
+
disconnectedCallback() {
|
|
147
|
+
this._disconnectMathObserver(), this._keyboardEventsEnabled &&= (window.removeEventListener("keydown", this._boundHandleKeyDown), !1), document.removeEventListener("click", this._enableAudio), this._audio &&= (this._audio.removeEventListener("playing", this._handlePlaying), this._audio.removeEventListener("ended", this._handleEnded), null), this._root && this._root.unmount();
|
|
148
|
+
}
|
|
149
|
+
handleKeyDown(e) {
|
|
150
|
+
if (!this._model || !this._session) return;
|
|
151
|
+
let { mode: t } = this._model;
|
|
152
|
+
if (t !== "gather") return;
|
|
153
|
+
let n = ((e) => {
|
|
154
|
+
let t = e >= "1" && e <= "9" ? e - "1" : e === "0" ? 9 : -1, n = /^[a-jA-J]$/.test(e) ? e.toLowerCase().charCodeAt(0) - 97 : -1;
|
|
155
|
+
return t >= 0 ? t : n;
|
|
156
|
+
})(e.key);
|
|
157
|
+
if (n === void 0 || n <= -1 || n >= this._model.choices?.length) return;
|
|
158
|
+
let r = this._session.value || [], i = this._model.choices[n].value, a = {
|
|
159
|
+
value: i,
|
|
160
|
+
selected: !r.includes(i),
|
|
161
|
+
selector: "Keyboard"
|
|
162
|
+
};
|
|
163
|
+
this._onChange(a);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
//#endregion
|
|
167
|
+
export { b as default, y as isComplete };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/multiple-choice/src/main.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
declare class Main extends React.Component {
|
|
12
|
+
static propTypes: {
|
|
13
|
+
model: PropTypes.Requireable<object>;
|
|
14
|
+
session: PropTypes.Requireable<object>;
|
|
15
|
+
options: PropTypes.Requireable<object>;
|
|
16
|
+
onChoiceChanged: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
onShowCorrectToggle: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
extraCSSRules: PropTypes.Requireable<PropTypes.InferProps<{
|
|
19
|
+
names: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
20
|
+
rules: PropTypes.Requireable<string>;
|
|
21
|
+
}>>;
|
|
22
|
+
};
|
|
23
|
+
static defaultProps: {
|
|
24
|
+
model: {};
|
|
25
|
+
session: {};
|
|
26
|
+
};
|
|
27
|
+
render(): React.JSX.Element;
|
|
28
|
+
}
|
|
29
|
+
export default Main;
|
|
30
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/delivery/main.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAgCnC,cAAM,IAAK,SAAQ,KAAK,CAAC,SAAS;IAChC,MAAM,CAAC,SAAS;;;;;;;;;;MAUd;IAEF,MAAM,CAAC,YAAY;;;MAGjB;IAEF,MAAM;CAiBP;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import e from "./multiple-choice.js";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import n from "prop-types";
|
|
4
|
+
import * as r from "@pie-lib/render-ui";
|
|
5
|
+
import { PreviewLayout as i } from "@pie-lib/render-ui";
|
|
6
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/delivery/main.tsx
|
|
8
|
+
function o(e) {
|
|
9
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
10
|
+
}
|
|
11
|
+
function s(e, t) {
|
|
12
|
+
return !e || o(e) ? e : o(e.default) ? e.default : t && o(e[t]) ? e[t] : t && o(e[t]?.default) ? e[t].default : e;
|
|
13
|
+
}
|
|
14
|
+
var c = s(i, "PreviewLayout") || s(d.PreviewLayout, "PreviewLayout"), l = r, u = l.default, d = u && typeof u == "object" ? u : l, f = class extends t.Component {
|
|
15
|
+
static propTypes = {
|
|
16
|
+
model: n.object,
|
|
17
|
+
session: n.object,
|
|
18
|
+
options: n.object,
|
|
19
|
+
onChoiceChanged: n.func,
|
|
20
|
+
onShowCorrectToggle: n.func,
|
|
21
|
+
extraCSSRules: n.shape({
|
|
22
|
+
names: n.arrayOf(n.string),
|
|
23
|
+
rules: n.string
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
static defaultProps = {
|
|
27
|
+
model: {},
|
|
28
|
+
session: {}
|
|
29
|
+
};
|
|
30
|
+
render() {
|
|
31
|
+
let { model: t, onChoiceChanged: n, session: r, onShowCorrectToggle: i, options: o } = this.props, { extraCSSRules: s, fontSizeFactor: l } = t;
|
|
32
|
+
return /* @__PURE__ */ a(c, {
|
|
33
|
+
extraCSSRules: s,
|
|
34
|
+
fontSizeFactor: l,
|
|
35
|
+
classes: {},
|
|
36
|
+
children: /* @__PURE__ */ a(e, {
|
|
37
|
+
...t,
|
|
38
|
+
options: o,
|
|
39
|
+
session: r,
|
|
40
|
+
onChoiceChanged: n,
|
|
41
|
+
onShowCorrectToggle: i
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { f as default };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/multiple-choice/src/multiple-choice.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
export declare class MultipleChoice extends React.Component {
|
|
12
|
+
static propTypes: {
|
|
13
|
+
className: PropTypes.Requireable<string>;
|
|
14
|
+
mode: PropTypes.Requireable<string>;
|
|
15
|
+
choiceMode: PropTypes.Requireable<string>;
|
|
16
|
+
keyMode: PropTypes.Requireable<string>;
|
|
17
|
+
choices: PropTypes.Requireable<any[]>;
|
|
18
|
+
partLabel: PropTypes.Requireable<string>;
|
|
19
|
+
prompt: PropTypes.Requireable<string>;
|
|
20
|
+
teacherInstructions: PropTypes.Requireable<string>;
|
|
21
|
+
session: PropTypes.Requireable<object>;
|
|
22
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
23
|
+
onChoiceChanged: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
|
+
responseCorrect: PropTypes.Requireable<boolean>;
|
|
25
|
+
correctResponse: PropTypes.Requireable<any[]>;
|
|
26
|
+
choicesLayout: PropTypes.Requireable<string>;
|
|
27
|
+
gridColumns: PropTypes.Requireable<string>;
|
|
28
|
+
alwaysShowCorrect: PropTypes.Requireable<boolean>;
|
|
29
|
+
animationsDisabled: PropTypes.Requireable<boolean>;
|
|
30
|
+
language: PropTypes.Requireable<string>;
|
|
31
|
+
selectedAnswerBackgroundColor: PropTypes.Requireable<string>;
|
|
32
|
+
selectedAnswerStrokeColor: PropTypes.Requireable<string>;
|
|
33
|
+
selectedAnswerStrokeWidth: PropTypes.Requireable<string>;
|
|
34
|
+
hoverAnswerBackgroundColor: PropTypes.Requireable<string>;
|
|
35
|
+
hoverAnswerStrokeColor: PropTypes.Requireable<string>;
|
|
36
|
+
hoverAnswerStrokeWidth: PropTypes.Requireable<string>;
|
|
37
|
+
onShowCorrectToggle: PropTypes.Requireable<(...args: any[]) => any>;
|
|
38
|
+
isSelectionButtonBelow: PropTypes.Requireable<boolean>;
|
|
39
|
+
minSelections: PropTypes.Requireable<number>;
|
|
40
|
+
maxSelections: PropTypes.Requireable<number>;
|
|
41
|
+
autoplayAudioEnabled: PropTypes.Requireable<boolean>;
|
|
42
|
+
customAudioButton: {
|
|
43
|
+
playImage: PropTypes.Requireable<string>;
|
|
44
|
+
pauseImage: PropTypes.Requireable<string>;
|
|
45
|
+
};
|
|
46
|
+
options: PropTypes.Requireable<object>;
|
|
47
|
+
};
|
|
48
|
+
constructor(props: any);
|
|
49
|
+
isSelected(value: any): any;
|
|
50
|
+
handleChange: any;
|
|
51
|
+
onToggle: any;
|
|
52
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
53
|
+
indexToSymbol(index: any): string;
|
|
54
|
+
getCorrectness: any;
|
|
55
|
+
getChecked(choice: any): any;
|
|
56
|
+
renderHeading(): React.JSX.Element | null;
|
|
57
|
+
handleGroupFocus: any;
|
|
58
|
+
render(): React.JSX.Element;
|
|
59
|
+
}
|
|
60
|
+
export default MultipleChoice;
|
|
61
|
+
//# sourceMappingURL=multiple-choice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiple-choice.d.ts","sourceRoot":"","sources":["../../src/delivery/multiple-choice.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAqGnC,qBAAa,cAAe,SAAQ,KAAK,CAAC,SAAS;IACjD,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmCd;gBAEU,KAAK,KAAA;IAYjB,UAAU,CAAC,KAAK,KAAA;IAOhB,YAAY,EAAE,GAAG,CAef;IAEF,QAAQ,EAAE,GAAG,CAQX;IAEF,gCAAgC,CAAC,SAAS,KAAA;IAkB1C,aAAa,CAAC,KAAK,KAAA;IAYnB,cAAc,EAAE,GAAG,CAyBjB;IAEF,UAAU,CAAC,MAAM,KAAA;IAoBjB,aAAa;IAcb,gBAAgB,EAAE,GAAG,CAcnB;IAEF,MAAM;CA0JP;AAQD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import e from "./choice.js";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import n from "prop-types";
|
|
4
|
+
import * as r from "@pie-lib/render-ui";
|
|
5
|
+
import { Collapsible as i, PreviewPrompt as a, color as o } from "@pie-lib/render-ui";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
import l from "@pie-lib/correct-answer-toggle";
|
|
8
|
+
import u from "classnames";
|
|
9
|
+
import { styled as d } from "@mui/material/styles";
|
|
10
|
+
import f from "@mui/material/Box";
|
|
11
|
+
import p from "@pie-lib/translator";
|
|
12
|
+
//#region src/delivery/multiple-choice.tsx
|
|
13
|
+
function m(e) {
|
|
14
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
15
|
+
}
|
|
16
|
+
function h(e, t) {
|
|
17
|
+
return !e || m(e) ? e : m(e.default) ? e.default : t && m(e[t]) ? e[t] : t && m(e[t]?.default) ? e[t].default : e;
|
|
18
|
+
}
|
|
19
|
+
var g = h(a, "PreviewPrompt") || h(b.PreviewPrompt, "PreviewPrompt"), _ = h(i, "Collapsible") || h(b.Collapsible, "Collapsible"), v = r, y = v.default, b = y && typeof y == "object" ? y : v, { translator: x } = p, S = d(f)({
|
|
20
|
+
color: o.text(),
|
|
21
|
+
backgroundColor: o.background(),
|
|
22
|
+
"& *": { "-webkit-font-smoothing": "antialiased" },
|
|
23
|
+
position: "relative",
|
|
24
|
+
"& legend": { border: "none !important" }
|
|
25
|
+
}), C = d("h2")(({ theme: e }) => ({
|
|
26
|
+
display: "block",
|
|
27
|
+
fontSize: "inherit",
|
|
28
|
+
margin: "0",
|
|
29
|
+
fontWeight: "normal",
|
|
30
|
+
paddingBottom: e.spacing(2)
|
|
31
|
+
})), w = d(f)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), T = d(f)({
|
|
32
|
+
display: "flex",
|
|
33
|
+
flexDirection: "row",
|
|
34
|
+
flexWrap: "wrap"
|
|
35
|
+
}), E = d(f)({ display: "grid" }), D = d("fieldset")({
|
|
36
|
+
border: "0px",
|
|
37
|
+
padding: "0.01em 0 0 0",
|
|
38
|
+
margin: "0px",
|
|
39
|
+
minWidth: "0px",
|
|
40
|
+
"&:focus": { outline: "none" }
|
|
41
|
+
}), O = d("h3")({
|
|
42
|
+
position: "absolute",
|
|
43
|
+
left: "-10000px",
|
|
44
|
+
top: "auto",
|
|
45
|
+
width: "1px",
|
|
46
|
+
height: "1px",
|
|
47
|
+
overflow: "hidden"
|
|
48
|
+
}), k = d("div")(({ theme: e }) => ({
|
|
49
|
+
fontSize: e.typography.fontSize - 2,
|
|
50
|
+
color: e.palette.error.main,
|
|
51
|
+
paddingTop: e.spacing(1)
|
|
52
|
+
})), A = class extends t.Component {
|
|
53
|
+
static propTypes = {
|
|
54
|
+
className: n.string,
|
|
55
|
+
mode: n.oneOf([
|
|
56
|
+
"gather",
|
|
57
|
+
"view",
|
|
58
|
+
"evaluate"
|
|
59
|
+
]),
|
|
60
|
+
choiceMode: n.oneOf(["radio", "checkbox"]),
|
|
61
|
+
keyMode: n.oneOf([
|
|
62
|
+
"numbers",
|
|
63
|
+
"letters",
|
|
64
|
+
"none"
|
|
65
|
+
]),
|
|
66
|
+
choices: n.array,
|
|
67
|
+
partLabel: n.string,
|
|
68
|
+
prompt: n.string,
|
|
69
|
+
teacherInstructions: n.string,
|
|
70
|
+
session: n.object,
|
|
71
|
+
disabled: n.bool,
|
|
72
|
+
onChoiceChanged: n.func,
|
|
73
|
+
responseCorrect: n.bool,
|
|
74
|
+
correctResponse: n.array,
|
|
75
|
+
choicesLayout: n.oneOf([
|
|
76
|
+
"vertical",
|
|
77
|
+
"grid",
|
|
78
|
+
"horizontal"
|
|
79
|
+
]),
|
|
80
|
+
gridColumns: n.string,
|
|
81
|
+
alwaysShowCorrect: n.bool,
|
|
82
|
+
animationsDisabled: n.bool,
|
|
83
|
+
language: n.string,
|
|
84
|
+
selectedAnswerBackgroundColor: n.string,
|
|
85
|
+
selectedAnswerStrokeColor: n.string,
|
|
86
|
+
selectedAnswerStrokeWidth: n.string,
|
|
87
|
+
hoverAnswerBackgroundColor: n.string,
|
|
88
|
+
hoverAnswerStrokeColor: n.string,
|
|
89
|
+
hoverAnswerStrokeWidth: n.string,
|
|
90
|
+
onShowCorrectToggle: n.func,
|
|
91
|
+
isSelectionButtonBelow: n.bool,
|
|
92
|
+
minSelections: n.number,
|
|
93
|
+
maxSelections: n.number,
|
|
94
|
+
autoplayAudioEnabled: n.bool,
|
|
95
|
+
customAudioButton: {
|
|
96
|
+
playImage: n.string,
|
|
97
|
+
pauseImage: n.string
|
|
98
|
+
},
|
|
99
|
+
options: n.object
|
|
100
|
+
};
|
|
101
|
+
constructor(e) {
|
|
102
|
+
super(e), this.state = {
|
|
103
|
+
showCorrect: this.props.options && this.props.alwaysShowCorrect || !1,
|
|
104
|
+
maxSelectionsErrorState: !1
|
|
105
|
+
}, this.onToggle = this.onToggle.bind(this), this.firstInputRef = t.createRef();
|
|
106
|
+
}
|
|
107
|
+
isSelected(e) {
|
|
108
|
+
let t = this.props.session && this.props.session.value;
|
|
109
|
+
return t && t.indexOf && t.indexOf(e) >= 0;
|
|
110
|
+
}
|
|
111
|
+
handleChange = (e) => {
|
|
112
|
+
let { value: t, checked: n } = e.target, { maxSelections: r, onChoiceChanged: i, session: a } = this.props;
|
|
113
|
+
a.value && a.value.length >= r && (this.setState({ maxSelectionsErrorState: n }), n) || i({
|
|
114
|
+
value: t,
|
|
115
|
+
selected: n,
|
|
116
|
+
selector: "Mouse"
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
onToggle = () => {
|
|
120
|
+
this.props.mode === "evaluate" && this.setState({ showCorrect: !this.state.showCorrect }, () => {
|
|
121
|
+
this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
UNSAFE_componentWillReceiveProps(e) {
|
|
125
|
+
!e.correctResponse && this.state.showCorrect !== !1 && this.setState({ showCorrect: !1 }, () => {
|
|
126
|
+
this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
|
|
127
|
+
}), e.options && e.alwaysShowCorrect && this.state.showCorrect !== !0 && this.setState({ showCorrect: !0 }, () => {
|
|
128
|
+
this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
indexToSymbol(e) {
|
|
132
|
+
return this.props.keyMode === "numbers" ? `${e + 1}` : this.props.keyMode === "letters" ? String.fromCharCode(97 + e).toUpperCase() : "";
|
|
133
|
+
}
|
|
134
|
+
getCorrectness = (e = {}) => {
|
|
135
|
+
let t = e.correct, n = this.isSelected(e.value);
|
|
136
|
+
if (this.state.showCorrect) return t ? "correct" : void 0;
|
|
137
|
+
if (t) return n ? "correct" : "incorrect";
|
|
138
|
+
if (n) return "incorrect";
|
|
139
|
+
};
|
|
140
|
+
getChecked(e) {
|
|
141
|
+
return this.props.options && this.props.alwaysShowCorrect || this.state.showCorrect && this.props.mode === "evaluate" ? e.correct || !1 : this.isSelected(e.value);
|
|
142
|
+
}
|
|
143
|
+
renderHeading() {
|
|
144
|
+
let { mode: e, choiceMode: t } = this.props;
|
|
145
|
+
return e === "gather" ? t === "radio" ? /* @__PURE__ */ s(O, { children: "Multiple Choice Question" }) : /* @__PURE__ */ s(O, { children: "Multiple Select Question" }) : null;
|
|
146
|
+
}
|
|
147
|
+
handleGroupFocus = (e) => {
|
|
148
|
+
let t = e.currentTarget, n = document.activeElement;
|
|
149
|
+
t.contains(n) && n !== t || (!e.relatedTarget || t.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_PRECEDING) && this.firstInputRef?.current && this.firstInputRef.current.focus();
|
|
150
|
+
};
|
|
151
|
+
render() {
|
|
152
|
+
let { mode: t, disabled: n, className: r, choices: i = [], choiceMode: a, gridColumns: o, partLabel: d, prompt: p, responseCorrect: m, teacherInstructions: h, alwaysShowCorrect: v, animationsDisabled: y, language: b, isSelectionButtonBelow: O, minSelections: A, maxSelections: j, autoplayAudioEnabled: M, session: N, customAudioButton: P, options: F } = this.props, { showCorrect: I, maxSelectionsErrorState: L } = this.state, R = t === "evaluate", z = R && !m, B = o > 1 ? { gridTemplateColumns: `repeat(${o}, 1fr)` } : void 0, V = N.value && N.value.length || 0, H = /* @__PURE__ */ s(g, {
|
|
153
|
+
tagName: "div",
|
|
154
|
+
className: "prompt",
|
|
155
|
+
defaultClassName: "teacher-instructions",
|
|
156
|
+
prompt: h
|
|
157
|
+
}), U = () => A && j ? A === j ? x.t("translation:multipleChoice:minmaxSelections_equal", {
|
|
158
|
+
lng: b,
|
|
159
|
+
minSelections: A
|
|
160
|
+
}) : x.t("translation:multipleChoice:minmaxSelections_range", {
|
|
161
|
+
lng: b,
|
|
162
|
+
minSelections: A,
|
|
163
|
+
maxSelections: j
|
|
164
|
+
}) : A ? x.t("translation:multipleChoice:minSelections", {
|
|
165
|
+
lng: b,
|
|
166
|
+
minSelections: A
|
|
167
|
+
}) : "", W = this.props.choicesLayout === "grid" ? E : this.props.choicesLayout === "horizontal" ? T : f;
|
|
168
|
+
return /* @__PURE__ */ c(S, {
|
|
169
|
+
id: "main-container",
|
|
170
|
+
className: u(r, "multiple-choice"),
|
|
171
|
+
children: [
|
|
172
|
+
d && /* @__PURE__ */ s(C, { children: d }),
|
|
173
|
+
this.renderHeading(),
|
|
174
|
+
h && /* @__PURE__ */ s(w, { children: y ? H : /* @__PURE__ */ s(_, {
|
|
175
|
+
labels: {
|
|
176
|
+
hidden: "Show Teacher Instructions",
|
|
177
|
+
visible: "Hide Teacher Instructions"
|
|
178
|
+
},
|
|
179
|
+
children: H
|
|
180
|
+
}) }),
|
|
181
|
+
/* @__PURE__ */ c(D, {
|
|
182
|
+
tabIndex: 0,
|
|
183
|
+
onFocus: this.handleGroupFocus,
|
|
184
|
+
role: a === "radio" ? "radiogroup" : "group",
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ s(g, {
|
|
187
|
+
className: "prompt",
|
|
188
|
+
defaultClassName: "prompt",
|
|
189
|
+
prompt: p,
|
|
190
|
+
tagName: "legend",
|
|
191
|
+
autoplayAudioEnabled: M,
|
|
192
|
+
customAudioButton: P
|
|
193
|
+
}),
|
|
194
|
+
!(F && v) && /* @__PURE__ */ s(l, {
|
|
195
|
+
show: z,
|
|
196
|
+
toggled: I,
|
|
197
|
+
onToggle: this.onToggle.bind(this),
|
|
198
|
+
language: b
|
|
199
|
+
}),
|
|
200
|
+
/* @__PURE__ */ s(W, {
|
|
201
|
+
style: B,
|
|
202
|
+
children: i.map((t, r) => /* @__PURE__ */ s(e, {
|
|
203
|
+
autoFocusRef: r === 0 ? this.firstInputRef : null,
|
|
204
|
+
choicesLayout: this.props.choicesLayout,
|
|
205
|
+
selectedAnswerBackgroundColor: this.props.selectedAnswerBackgroundColor,
|
|
206
|
+
selectedAnswerStrokeColor: this.props.selectedAnswerStrokeColor,
|
|
207
|
+
selectedAnswerStrokeWidth: this.props.selectedAnswerStrokeWidth,
|
|
208
|
+
hoverAnswerBackgroundColor: this.props.hoverAnswerBackgroundColor,
|
|
209
|
+
hoverAnswerStrokeColor: this.props.hoverAnswerStrokeColor,
|
|
210
|
+
hoverAnswerStrokeWidth: this.props.hoverAnswerStrokeWidth,
|
|
211
|
+
gridColumns: o,
|
|
212
|
+
choice: t,
|
|
213
|
+
index: r,
|
|
214
|
+
choicesLength: i.length,
|
|
215
|
+
showCorrect: I,
|
|
216
|
+
isEvaluateMode: R,
|
|
217
|
+
choiceMode: a,
|
|
218
|
+
disabled: n,
|
|
219
|
+
tagName: d ? `group-${d}` : "group",
|
|
220
|
+
onChoiceChanged: this.handleChange,
|
|
221
|
+
hideTick: t.hideTick,
|
|
222
|
+
checked: this.getChecked(t),
|
|
223
|
+
correctness: R ? this.getCorrectness(t) : void 0,
|
|
224
|
+
displayKey: this.indexToSymbol(r),
|
|
225
|
+
isSelectionButtonBelow: O
|
|
226
|
+
}, `choice-${r}`))
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
}),
|
|
230
|
+
a === "checkbox" && V < A && /* @__PURE__ */ s(k, { children: U() }),
|
|
231
|
+
a === "checkbox" && L && /* @__PURE__ */ s(k, { children: x.t(`translation:multipleChoice:maxSelections_${j === 1 ? "one" : "other"}`, {
|
|
232
|
+
lng: b,
|
|
233
|
+
maxSelections: j
|
|
234
|
+
}) })
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
A.defaultProps = { session: { value: [] } };
|
|
240
|
+
//#endregion
|
|
241
|
+
export { A as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/multiple-choice/src/session-updater.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
export declare function updateSessionValue(session: any, choiceMode: any, data: any): void;
|
|
10
|
+
export declare function updateSessionMetadata(session: any, metadata: any): void;
|
|
11
|
+
//# sourceMappingURL=session-updater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-updater.d.ts","sourceRoot":"","sources":["../../src/delivery/session-updater.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,wBAAgB,kBAAkB,CAAC,OAAO,KAAA,EAAE,UAAU,KAAA,EAAE,IAAI,KAAA,QAoB3D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,KAAA,EAAE,QAAQ,KAAA,QAQtD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/delivery/session-updater.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
e.value = e.value || [], t === "checkbox" && (n.selected ? e.value = Array.from(new Set([...e.value, n.value])) : e.value = e.value.filter((e) => e !== n.value)), t === "radio" && (n.selected ? e.value = [n.value] : e.value = []), e.selector = n.selector;
|
|
4
|
+
}
|
|
5
|
+
function t(e, t) {
|
|
6
|
+
e.audioStartTime = e.audioStartTime || t.audioStartTime, e.audioEndTime = e.audioEndTime || t.audioEndTime, !e.waitTime && e.audioStartTime && e.audioEndTime && (e.waitTime = e.audioEndTime - e.audioStartTime);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as updateSessionMetadata, e as updateSessionValue };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import Element from './index.js';
|
|
8
|
+
export default Element;
|
|
9
|
+
//# sourceMappingURL=index.iife.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.iife.d.ts","sourceRoot":"","sources":["../src/index.iife.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,OAAO,MAAM,YAAY,CAAC;AAQjC,eAAe,OAAO,CAAC"}
|