@pie-element/ebsr 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 +67 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +161 -0
- package/dist/author/index.d.ts +35 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +78 -0
- package/dist/author/main.d.ts +23 -0
- package/dist/author/main.d.ts.map +1 -0
- package/dist/author/main.js +121 -0
- package/dist/controller/defaults.d.ts +16 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +26 -0
- package/dist/controller/index.d.ts +43 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +186 -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/index.d.ts +25 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +95 -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 +165 -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/_arrayMap.js +7 -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/_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/_baseGet.js +10 -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/_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/_baseToString.js +15 -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/_castPath.js +10 -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/_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/_isKey.js +11 -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/_memoizeCapped.js +11 -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/_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/_stringToPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toKey.js +10 -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/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/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/get.js +8 -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/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/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/memoize.js +16 -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/toString.js +7 -0
- package/dist/print/index.d.ts +25 -0
- package/dist/print/index.d.ts.map +1 -0
- package/dist/print/index.js +104 -0
- package/package.json +70 -0
- package/src/author/defaults.ts +183 -0
- package/src/author/index.ts +184 -0
- package/src/author/main.tsx +245 -0
- package/src/controller/defaults.ts +35 -0
- package/src/controller/index.ts +452 -0
- package/src/controller/utils.ts +28 -0
- package/src/delivery/index.tsx +167 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
- package/src/print/index.tsx +213 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/ebsr/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 { cloneDeep, get } from 'lodash-es';
|
|
12
|
+
import MultipleChoice from '@pie-element/multiple-choice';
|
|
13
|
+
import debug from 'debug';
|
|
14
|
+
import { SessionChangedEvent } from '@pie-element/shared-player-events';
|
|
15
|
+
const MC_TAG_NAME = 'ebsr-multiple-choice';
|
|
16
|
+
const SESSION_CHANGED = SessionChangedEvent.TYPE;
|
|
17
|
+
import Translator from '@pie-lib/translator';
|
|
18
|
+
|
|
19
|
+
const { translator } = Translator;
|
|
20
|
+
|
|
21
|
+
const log = debug('pie-element:ebsr:print');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Live in same package as main element - so we can access some of the shared comps!
|
|
25
|
+
*
|
|
26
|
+
* - update pslb to build print if src/print.js is there
|
|
27
|
+
* - update demo el
|
|
28
|
+
* - get configure/controller building
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const preparePrintModel = (model, opts) => {
|
|
32
|
+
const instr = opts.role === 'instructor';
|
|
33
|
+
|
|
34
|
+
model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
|
|
35
|
+
model.teacherInstructions =
|
|
36
|
+
instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
|
|
37
|
+
model.showTeacherInstructions = instr;
|
|
38
|
+
model.alwaysShowCorrect = instr;
|
|
39
|
+
model.mode = instr ? 'evaluate' : 'gather';
|
|
40
|
+
|
|
41
|
+
model.disabled = true;
|
|
42
|
+
model.animationsDisabled = true;
|
|
43
|
+
model.lockChoiceOrder = true;
|
|
44
|
+
model.choicesLayout = model.choicesLayout || 'vertical';
|
|
45
|
+
|
|
46
|
+
const choices = cloneDeep(model.choices);
|
|
47
|
+
|
|
48
|
+
model.choices = choices.map((c) => {
|
|
49
|
+
c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
|
|
50
|
+
c.hideTick = instr;
|
|
51
|
+
c.feedback = undefined;
|
|
52
|
+
return c;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
model.keyMode = model.choicePrefix || 'letters';
|
|
56
|
+
|
|
57
|
+
return model;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
class EbsrMC extends MultipleChoice {}
|
|
61
|
+
|
|
62
|
+
const defineMultipleChoice = () => {
|
|
63
|
+
if (!customElements.get(MC_TAG_NAME)) {
|
|
64
|
+
customElements.define(MC_TAG_NAME, EbsrMC);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
defineMultipleChoice();
|
|
69
|
+
|
|
70
|
+
const isNonEmptyArray = (a) => Array.isArray(a) && a.length > 0;
|
|
71
|
+
|
|
72
|
+
export const isSessionComplete = (session) => {
|
|
73
|
+
const a = get(session, 'value.partA.value');
|
|
74
|
+
const b = get(session, 'value.partB.value');
|
|
75
|
+
|
|
76
|
+
return isNonEmptyArray(a) && isNonEmptyArray(b);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default class Ebsr extends HTMLElement {
|
|
80
|
+
constructor() {
|
|
81
|
+
super();
|
|
82
|
+
this._model = {};
|
|
83
|
+
this._session = {};
|
|
84
|
+
this._options = null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
onSessionUpdated: any = (e) => {
|
|
88
|
+
if (e.target === this) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
e.stopImmediatePropagation();
|
|
94
|
+
|
|
95
|
+
const id = e.target.getAttribute('id');
|
|
96
|
+
|
|
97
|
+
if (id) {
|
|
98
|
+
const key = `part${id.toUpperCase()}`;
|
|
99
|
+
|
|
100
|
+
if (e.update) {
|
|
101
|
+
this._model[key] = e.update;
|
|
102
|
+
}
|
|
103
|
+
//TODO: accessing a private property here. The session event should contain the update in future to prevent this.
|
|
104
|
+
this.dispatchSessionChanged(e.srcElement._session, key);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
set model(m) {
|
|
109
|
+
this._model = m;
|
|
110
|
+
|
|
111
|
+
customElements.whenDefined(MC_TAG_NAME).then(() => {
|
|
112
|
+
this.setPartModel(this.partA, 'partA');
|
|
113
|
+
this.setPartModel(this.partB, 'partB');
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
set session(s) {
|
|
118
|
+
this._session = s;
|
|
119
|
+
|
|
120
|
+
customElements.whenDefined(MC_TAG_NAME).then(() => {
|
|
121
|
+
this.setPartSession(this.partA, 'partA');
|
|
122
|
+
this.setPartSession(this.partB, 'partB');
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setPartModel(part, key) {
|
|
127
|
+
if (this._model && this._model[key] && part) {
|
|
128
|
+
let labels = {
|
|
129
|
+
partA: undefined,
|
|
130
|
+
partB: undefined,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
if (this._model.partLabels) {
|
|
134
|
+
const language = this._model.language;
|
|
135
|
+
|
|
136
|
+
labels = {
|
|
137
|
+
partA: translator.t('ebsr.part', {
|
|
138
|
+
lng: language,
|
|
139
|
+
index: this._model.partLabelType === 'Letters' ? 'A' : '1',
|
|
140
|
+
}),
|
|
141
|
+
partB: translator.t('ebsr.part', {
|
|
142
|
+
lng: language,
|
|
143
|
+
index: this._model.partLabelType === 'Letters' ? 'B' : '2',
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
part.model = {
|
|
149
|
+
...preparePrintModel(this._model[key], this._options),
|
|
150
|
+
keyMode: this._model[key].choicePrefix,
|
|
151
|
+
partLabel: labels[key],
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// pass options to enable print mode detection in multiple-choice component
|
|
155
|
+
part.options = this._options;
|
|
156
|
+
|
|
157
|
+
if (!part._session) {
|
|
158
|
+
// for print, "set session" is not called,
|
|
159
|
+
// but ebsr needs sessions in order to render the elements,
|
|
160
|
+
// so we set it here it was not set already
|
|
161
|
+
part.session = {};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
set options(o) {
|
|
167
|
+
this._options = o;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
setPartSession(part, key) {
|
|
171
|
+
if (this._session && this._model && part) {
|
|
172
|
+
const { value } = this._session;
|
|
173
|
+
part.session = value && value[key] ? value[key] : { id: key };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
dispatchSessionChanged(partSession, key) {
|
|
178
|
+
this._session.value = {
|
|
179
|
+
...this._session.value,
|
|
180
|
+
[key]: partSession,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
log('[onSessionChanged] session: ', this._session);
|
|
184
|
+
const complete = isSessionComplete(this._session);
|
|
185
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), complete));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
get partA() {
|
|
189
|
+
return this.querySelector(`${MC_TAG_NAME}#a`);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
get partB() {
|
|
193
|
+
return this.querySelector(`${MC_TAG_NAME}#b`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
connectedCallback() {
|
|
197
|
+
this._render();
|
|
198
|
+
this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
disconnectedCallback() {
|
|
202
|
+
this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
_render() {
|
|
206
|
+
this.innerHTML = `
|
|
207
|
+
<div>
|
|
208
|
+
<${MC_TAG_NAME} id="a"></${MC_TAG_NAME}>
|
|
209
|
+
<${MC_TAG_NAME} id="b"></${MC_TAG_NAME}>
|
|
210
|
+
</div>
|
|
211
|
+
`;
|
|
212
|
+
}
|
|
213
|
+
}
|