@pie-element/ebsr 6.5.0 → 6.5.1-beta.587
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +463 -0
- package/configure/CHANGELOG.md +447 -0
- package/configure/lib/defaults.js +34 -11
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +30 -23
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +109 -72
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +3 -3
- package/configure/src/__tests__/__snapshots__/index.test.js.snap +12 -2
- package/configure/src/__tests__/index.test.js +164 -211
- package/configure/src/defaults.js +49 -27
- package/configure/src/index.js +19 -39
- package/configure/src/main.jsx +165 -149
- package/controller/CHANGELOG.md +67 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +123 -29
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +2 -2
- package/controller/src/__tests__/index.test.js +113 -141
- package/controller/src/__tests__/utils.test.js +6 -9
- package/controller/src/defaults.js +1 -1
- package/controller/src/index.js +109 -70
- package/controller/src/utils.js +6 -4
- package/docs/config-schema.json +376 -0
- package/docs/config-schema.json.md +289 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +3 -3
- package/docs/pie-schema.json +177 -0
- package/docs/pie-schema.json.md +138 -0
- package/lib/index.js +12 -9
- package/lib/index.js.map +1 -1
- package/lib/print.js +243 -0
- package/lib/print.js.map +1 -0
- package/package.json +8 -4
- package/src/__tests__/index.test.js +2 -7
- package/src/index.js +7 -5
- package/src/print.js +179 -0
package/docs/pie-schema.json.md
CHANGED
|
@@ -68,6 +68,10 @@ Indicates if Feedback is enabled
|
|
|
68
68
|
|
|
69
69
|
Indicates if Rationale are enabled
|
|
70
70
|
|
|
71
|
+
## `spellCheckEnabled` (boolean, required)
|
|
72
|
+
|
|
73
|
+
Indicates if spellcheck is enabled for the author. Default value is true
|
|
74
|
+
|
|
71
75
|
## `studentInstructionsEnabled` (boolean, required)
|
|
72
76
|
|
|
73
77
|
Indicates if Student Instructions are enabled
|
|
@@ -76,6 +80,12 @@ Indicates if Student Instructions are enabled
|
|
|
76
80
|
|
|
77
81
|
Indicates if Teacher Instructions are enabled
|
|
78
82
|
|
|
83
|
+
## `verticalMode` (boolean)
|
|
84
|
+
|
|
85
|
+
Indicates the layout of choices for player
|
|
86
|
+
|
|
87
|
+
Default: `": true"`
|
|
88
|
+
|
|
79
89
|
# `partB` (object, required)
|
|
80
90
|
|
|
81
91
|
Properties of the `partB` object:
|
|
@@ -142,6 +152,10 @@ Indicates if Feedback is enabled
|
|
|
142
152
|
|
|
143
153
|
Indicates if Rationale are enabled
|
|
144
154
|
|
|
155
|
+
## `spellCheckEnabled` (boolean, required)
|
|
156
|
+
|
|
157
|
+
Indicates if spellcheck is enabled for the author. Default value is true
|
|
158
|
+
|
|
145
159
|
## `studentInstructionsEnabled` (boolean, required)
|
|
146
160
|
|
|
147
161
|
Indicates if Student Instructions are enabled
|
|
@@ -150,6 +164,12 @@ Indicates if Student Instructions are enabled
|
|
|
150
164
|
|
|
151
165
|
Indicates if Teacher Instructions are enabled
|
|
152
166
|
|
|
167
|
+
## `verticalMode` (boolean)
|
|
168
|
+
|
|
169
|
+
Indicates the layout of choices for player
|
|
170
|
+
|
|
171
|
+
Default: `": true"`
|
|
172
|
+
|
|
153
173
|
# `partLabels` (boolean, required)
|
|
154
174
|
|
|
155
175
|
Indicates if part labels should be displayed
|
|
@@ -278,6 +298,22 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
278
298
|
|
|
279
299
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
280
300
|
|
|
301
|
+
### `settingsPanelDisabled` (boolean)
|
|
302
|
+
|
|
303
|
+
Indicates if the settings panel is not available
|
|
304
|
+
|
|
305
|
+
### `spellCheck` (object)
|
|
306
|
+
|
|
307
|
+
Properties of the `spellCheck` object:
|
|
308
|
+
|
|
309
|
+
#### `settings` (boolean)
|
|
310
|
+
|
|
311
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
312
|
+
|
|
313
|
+
#### `label` (string)
|
|
314
|
+
|
|
315
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
316
|
+
|
|
281
317
|
### `rationale` (object)
|
|
282
318
|
|
|
283
319
|
Properties of the `rationale` object:
|
|
@@ -314,6 +350,78 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
314
350
|
|
|
315
351
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
316
352
|
|
|
353
|
+
### `choicesLayout` (object)
|
|
354
|
+
|
|
355
|
+
Properties of the `choicesLayout` object:
|
|
356
|
+
|
|
357
|
+
#### `settings` (boolean)
|
|
358
|
+
|
|
359
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
360
|
+
|
|
361
|
+
#### `label` (string)
|
|
362
|
+
|
|
363
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
364
|
+
|
|
365
|
+
### `gridColumns` (object)
|
|
366
|
+
|
|
367
|
+
Properties of the `gridColumns` object:
|
|
368
|
+
|
|
369
|
+
#### `settings` (boolean)
|
|
370
|
+
|
|
371
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
372
|
+
|
|
373
|
+
#### `label` (string)
|
|
374
|
+
|
|
375
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
376
|
+
|
|
377
|
+
### `minAnswerChoices` (number)
|
|
378
|
+
|
|
379
|
+
Minimum number of answer choices
|
|
380
|
+
|
|
381
|
+
### `maxAnswerChoices` (number)
|
|
382
|
+
|
|
383
|
+
Maximum number of answer choices
|
|
384
|
+
|
|
385
|
+
### `maxImageWidth` (object)
|
|
386
|
+
|
|
387
|
+
Properties of the `maxImageWidth` object:
|
|
388
|
+
|
|
389
|
+
#### `teacherInstructions` (number)
|
|
390
|
+
|
|
391
|
+
Indicates the max dimension for images in teacher instructions
|
|
392
|
+
|
|
393
|
+
#### `prompt` (number)
|
|
394
|
+
|
|
395
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
396
|
+
|
|
397
|
+
#### `rationale` (number)
|
|
398
|
+
|
|
399
|
+
Indicates the max dimension for images in rationale
|
|
400
|
+
|
|
401
|
+
#### `choices` (number)
|
|
402
|
+
|
|
403
|
+
Indicates the max dimension for images in choices
|
|
404
|
+
|
|
405
|
+
### `maxImageHeight` (object)
|
|
406
|
+
|
|
407
|
+
Properties of the `maxImageHeight` object:
|
|
408
|
+
|
|
409
|
+
#### `teacherInstructions` (number)
|
|
410
|
+
|
|
411
|
+
Indicates the max dimension for images in teacher instructions
|
|
412
|
+
|
|
413
|
+
#### `prompt` (number)
|
|
414
|
+
|
|
415
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
416
|
+
|
|
417
|
+
#### `rationale` (number)
|
|
418
|
+
|
|
419
|
+
Indicates the max dimension for images in rationale
|
|
420
|
+
|
|
421
|
+
#### `choices` (number)
|
|
422
|
+
|
|
423
|
+
Indicates the max dimension for images in choices
|
|
424
|
+
|
|
317
425
|
## `ConfigureProp` (object)
|
|
318
426
|
|
|
319
427
|
Properties of the `ConfigureProp` object:
|
|
@@ -326,6 +434,26 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
326
434
|
|
|
327
435
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
328
436
|
|
|
437
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
438
|
+
|
|
439
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
440
|
+
|
|
441
|
+
### `teacherInstructions` (number)
|
|
442
|
+
|
|
443
|
+
Indicates the max dimension for images in teacher instructions
|
|
444
|
+
|
|
445
|
+
### `prompt` (number)
|
|
446
|
+
|
|
447
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
448
|
+
|
|
449
|
+
### `rationale` (number)
|
|
450
|
+
|
|
451
|
+
Indicates the max dimension for images in rationale
|
|
452
|
+
|
|
453
|
+
### `choices` (number)
|
|
454
|
+
|
|
455
|
+
Indicates the max dimension for images in choices
|
|
456
|
+
|
|
329
457
|
## `Part` (object)
|
|
330
458
|
|
|
331
459
|
Properties of the `Part` object:
|
|
@@ -392,6 +520,10 @@ Indicates if Feedback is enabled
|
|
|
392
520
|
|
|
393
521
|
Indicates if Rationale are enabled
|
|
394
522
|
|
|
523
|
+
### `spellCheckEnabled` (boolean, required)
|
|
524
|
+
|
|
525
|
+
Indicates if spellcheck is enabled for the author. Default value is true
|
|
526
|
+
|
|
395
527
|
### `studentInstructionsEnabled` (boolean, required)
|
|
396
528
|
|
|
397
529
|
Indicates if Student Instructions are enabled
|
|
@@ -400,6 +532,12 @@ Indicates if Student Instructions are enabled
|
|
|
400
532
|
|
|
401
533
|
Indicates if Teacher Instructions are enabled
|
|
402
534
|
|
|
535
|
+
### `verticalMode` (boolean)
|
|
536
|
+
|
|
537
|
+
Indicates the layout of choices for player
|
|
538
|
+
|
|
539
|
+
Default: `": true"`
|
|
540
|
+
|
|
403
541
|
## `Choice` (object)
|
|
404
542
|
|
|
405
543
|
Properties of the `Choice` object:
|
package/lib/index.js
CHANGED
|
@@ -5,9 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] =
|
|
9
|
-
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
exports.isSessionComplete = exports["default"] = void 0;
|
|
11
9
|
|
|
12
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
11
|
|
|
@@ -15,6 +13,8 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
|
|
|
15
13
|
|
|
16
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
15
|
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
19
|
|
|
20
20
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
@@ -31,13 +31,13 @@ var _get = _interopRequireDefault(require("lodash/get"));
|
|
|
31
31
|
|
|
32
32
|
var _debug = _interopRequireDefault(require("debug"));
|
|
33
33
|
|
|
34
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
34
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
35
|
|
|
36
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
37
|
|
|
38
38
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
39
39
|
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
40
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
41
|
|
|
42
42
|
var SESSION_CHANGED = _piePlayerEvents.SessionChangedEvent.TYPE;
|
|
43
43
|
var MC_TAG_NAME = 'ebsr-multiple-choice';
|
|
@@ -53,7 +53,7 @@ var EbsrMC = /*#__PURE__*/function (_MultipleChoice) {
|
|
|
53
53
|
return _super.apply(this, arguments);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
return EbsrMC;
|
|
56
|
+
return (0, _createClass2["default"])(EbsrMC);
|
|
57
57
|
}(_multipleChoice["default"]);
|
|
58
58
|
|
|
59
59
|
var defineMultipleChoice = function defineMultipleChoice() {
|
|
@@ -125,6 +125,9 @@ var Ebsr = /*#__PURE__*/function (_HTMLElement) {
|
|
|
125
125
|
}
|
|
126
126
|
}, {
|
|
127
127
|
key: "session",
|
|
128
|
+
get: function get() {
|
|
129
|
+
return this._session;
|
|
130
|
+
},
|
|
128
131
|
set: function set(s) {
|
|
129
132
|
var _this3 = this;
|
|
130
133
|
|
|
@@ -138,7 +141,7 @@ var Ebsr = /*#__PURE__*/function (_HTMLElement) {
|
|
|
138
141
|
}, {
|
|
139
142
|
key: "setPartModel",
|
|
140
143
|
value: function setPartModel(part, key) {
|
|
141
|
-
if (this._model && this._model[key]) {
|
|
144
|
+
if (this._model && this._model[key] && part) {
|
|
142
145
|
var mode = this._model.mode;
|
|
143
146
|
part.model = _objectSpread(_objectSpread({}, this._model[key]), {}, {
|
|
144
147
|
mode: mode,
|
|
@@ -149,7 +152,7 @@ var Ebsr = /*#__PURE__*/function (_HTMLElement) {
|
|
|
149
152
|
}, {
|
|
150
153
|
key: "setPartSession",
|
|
151
154
|
value: function setPartSession(part, key) {
|
|
152
|
-
if (this._session && this._model) {
|
|
155
|
+
if (this._session && this._model && part) {
|
|
153
156
|
var value = this._session.value;
|
|
154
157
|
part.session = value && value[key] ? value[key] : {
|
|
155
158
|
id: key
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["SESSION_CHANGED","SessionChangedEvent","TYPE","MC_TAG_NAME","log","EbsrMC","MultipleChoice","defineMultipleChoice","customElements","get","define","isNonEmptyArray","a","Array","isArray","length","isSessionComplete","session","b","Ebsr","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","key","toUpperCase","update","_model","dispatchSessionChanged","srcElement","_session","m","whenDefined","then","setPartModel","partA","partB","s","setPartSession","part","mode","model","keyMode","choicePrefix","value","partSession","complete","dispatchEvent","tagName","toLowerCase","querySelector","_render","addEventListener","onSessionUpdated","removeEventListener","innerHTML","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AACA,IAAMA,eAAe,GAAGC,qCAAoBC,IAA5C;AACA,IAAMC,WAAW,GAAG,sBAApB;AACA,IAAMC,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEMC,M;;;;;;;;;;;EAAeC,0B;;AAErB,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,GAAM;AACjC,MAAI,CAACC,cAAc,CAACC,GAAf,CAAmBN,WAAnB,CAAL,EAAsC;AACpCK,IAAAA,cAAc,CAACE,MAAf,CAAsBP,WAAtB,EAAmCE,MAAnC;AACD;AACF,CAJD;;AAMAE,oBAAoB;;AAEpB,IAAMI,eAAe,GAAG,SAAlBA,eAAkB,CAACC,CAAD;AAAA,SAAOC,KAAK,CAACC,OAAN,CAAcF,CAAd,KAAoBA,CAAC,CAACG,MAAF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AA9B;AACD,OAHD;AAID;;;
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["SESSION_CHANGED","SessionChangedEvent","TYPE","MC_TAG_NAME","log","EbsrMC","MultipleChoice","defineMultipleChoice","customElements","get","define","isNonEmptyArray","a","Array","isArray","length","isSessionComplete","session","b","Ebsr","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","key","toUpperCase","update","_model","dispatchSessionChanged","srcElement","_session","m","whenDefined","then","setPartModel","partA","partB","s","setPartSession","part","mode","model","keyMode","choicePrefix","value","partSession","complete","dispatchEvent","tagName","toLowerCase","querySelector","_render","addEventListener","onSessionUpdated","removeEventListener","innerHTML","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AACA,IAAMA,eAAe,GAAGC,qCAAoBC,IAA5C;AACA,IAAMC,WAAW,GAAG,sBAApB;AACA,IAAMC,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEMC,M;;;;;;;;;;;EAAeC,0B;;AAErB,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,GAAM;AACjC,MAAI,CAACC,cAAc,CAACC,GAAf,CAAmBN,WAAnB,CAAL,EAAsC;AACpCK,IAAAA,cAAc,CAACE,MAAf,CAAsBP,WAAtB,EAAmCE,MAAnC;AACD;AACF,CAJD;;AAMAE,oBAAoB;;AAEpB,IAAMI,eAAe,GAAG,SAAlBA,eAAkB,CAACC,CAAD;AAAA,SAAOC,KAAK,CAACC,OAAN,CAAcF,CAAd,KAAoBA,CAAC,CAACG,MAAF,GAAW,CAAtC;AAAA,CAAxB;;AAEO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,OAAD,EAAa;AAC5C,MAAML,CAAC,GAAG,qBAAIK,OAAJ,EAAa,mBAAb,CAAV;AACA,MAAMC,CAAC,GAAG,qBAAID,OAAJ,EAAa,mBAAb,CAAV;AAEA,SAAON,eAAe,CAACC,CAAD,CAAf,IAAsBD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,eAAY;AACV,aAAO,KAAKI,aAAL,WAAsBjD,WAAtB,QAAP;AACD;;;SAED,eAAY;AACV,aAAO,KAAKiD,aAAL,WAAsBjD,WAAtB,QAAP;AACD;;;WAED,6BAAoB;AAClB,WAAKkD,OAAL;;AACA,WAAKC,gBAAL,CAAsBtD,eAAtB,EAAuC,KAAKuD,gBAA5C;AACD;;;WAED,gCAAuB;AACrB,WAAKC,mBAAL,CAAyBxD,eAAzB,EAA0C,KAAKuD,gBAA/C;AACD;;;WAED,mBAAU;AACR,WAAKE,SAAL,qCAEOtD,WAFP,yBAE+BA,WAF/B,yBAGOA,WAHP,yBAG+BA,WAH/B;AAMD;;;kDAxG+BuD,W","sourcesContent":["import { SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport MultipleChoice from '@pie-element/multiple-choice';\nimport get from 'lodash/get';\nimport debug from 'debug';\nconst SESSION_CHANGED = SessionChangedEvent.TYPE;\nconst MC_TAG_NAME = 'ebsr-multiple-choice';\nconst log = debug('pie-elements:ebsr');\n\nclass EbsrMC extends MultipleChoice {}\n\nconst defineMultipleChoice = () => {\n if (!customElements.get(MC_TAG_NAME)) {\n customElements.define(MC_TAG_NAME, EbsrMC);\n }\n};\n\ndefineMultipleChoice();\n\nconst isNonEmptyArray = (a) => Array.isArray(a) && a.length > 0;\n\nexport const isSessionComplete = (session) => {\n const a = get(session, 'value.partA.value');\n const b = get(session, 'value.partB.value');\n\n return isNonEmptyArray(a) && isNonEmptyArray(b);\n};\n\nexport default class Ebsr extends HTMLElement {\n constructor() {\n super();\n this._model = {};\n this._session = {};\n }\n\n onSessionUpdated = (e) => {\n if (e.target === this) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n\n const id = e.target.getAttribute('id');\n\n if (id) {\n const key = `part${id.toUpperCase()}`;\n\n if (e.update) {\n this._model[key] = e.update;\n }\n //TODO: accessing a private property here. The session event should contain the update in future to prevent this.\n this.dispatchSessionChanged(e.srcElement._session, key);\n }\n };\n\n set model(m) {\n this._model = m;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartModel(this.partA, 'partA');\n this.setPartModel(this.partB, 'partB');\n });\n }\n\n set session(s) {\n this._session = s;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartSession(this.partA, 'partA');\n this.setPartSession(this.partB, 'partB');\n });\n }\n\n get session() {\n return this._session;\n }\n\n setPartModel(part, key) {\n if (this._model && this._model[key] && part) {\n const { mode } = this._model;\n\n part.model = {\n ...this._model[key],\n mode,\n keyMode: this._model[key].choicePrefix,\n };\n }\n }\n\n setPartSession(part, key) {\n if (this._session && this._model && part) {\n const { value } = this._session;\n part.session = value && value[key] ? value[key] : { id: key };\n }\n }\n\n dispatchSessionChanged(partSession, key) {\n this._session.value = {\n ...this._session.value,\n [key]: partSession,\n };\n\n log('[onSessionChanged] session: ', this._session);\n const complete = isSessionComplete(this._session);\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), complete));\n }\n\n get partA() {\n return this.querySelector(`${MC_TAG_NAME}#a`);\n }\n\n get partB() {\n return this.querySelector(`${MC_TAG_NAME}#b`);\n }\n\n connectedCallback() {\n this._render();\n this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n disconnectedCallback() {\n this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n _render() {\n this.innerHTML = `\n <div>\n <${MC_TAG_NAME} id=\"a\"></${MC_TAG_NAME}>\n <${MC_TAG_NAME} id=\"b\"></${MC_TAG_NAME}>\n </div>\n `;\n }\n}\n"],"file":"index.js"}
|
package/lib/print.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.isSessionComplete = exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
|
|
12
|
+
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
|
+
|
|
28
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
29
|
+
|
|
30
|
+
var _multipleChoice = _interopRequireDefault(require("@pie-element/multiple-choice"));
|
|
31
|
+
|
|
32
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
33
|
+
|
|
34
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
35
|
+
|
|
36
|
+
var _piePlayerEvents = require("@pie-framework/pie-player-events");
|
|
37
|
+
|
|
38
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
|
+
|
|
40
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
|
+
|
|
42
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
43
|
+
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
|
+
|
|
46
|
+
var MC_TAG_NAME = 'ebsr-multiple-choice';
|
|
47
|
+
var SESSION_CHANGED = _piePlayerEvents.SessionChangedEvent.TYPE;
|
|
48
|
+
var log = (0, _debug["default"])('pie-element:ebsr:print');
|
|
49
|
+
/**
|
|
50
|
+
* Live in same package as main element - so we can access some of the shared comps!
|
|
51
|
+
*
|
|
52
|
+
* - update pslb to build print if src/print.js is there
|
|
53
|
+
* - update demo el
|
|
54
|
+
* - get configure/controller building
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
var preparePrintModel = function preparePrintModel(model, opts) {
|
|
58
|
+
var instr = opts.role === 'instructor';
|
|
59
|
+
model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
|
|
60
|
+
model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
|
|
61
|
+
model.showTeacherInstructions = instr;
|
|
62
|
+
model.alwaysShowCorrect = instr;
|
|
63
|
+
model.mode = instr ? 'evaluate' : 'gather';
|
|
64
|
+
model.disabled = true;
|
|
65
|
+
model.animationsDisabled = true;
|
|
66
|
+
model.lockChoiceOrder = true;
|
|
67
|
+
model.choicesLayout = model.choicesLayout || 'vertical';
|
|
68
|
+
var choices = (0, _cloneDeep["default"])(model.choices);
|
|
69
|
+
model.choices = choices.map(function (c) {
|
|
70
|
+
c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
|
|
71
|
+
c.hideTick = instr;
|
|
72
|
+
c.feedback = undefined;
|
|
73
|
+
return c;
|
|
74
|
+
});
|
|
75
|
+
model.keyMode = model.choicePrefix || 'letters';
|
|
76
|
+
return model;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
var EbsrMC = /*#__PURE__*/function (_MultipleChoice) {
|
|
80
|
+
(0, _inherits2["default"])(EbsrMC, _MultipleChoice);
|
|
81
|
+
|
|
82
|
+
var _super = _createSuper(EbsrMC);
|
|
83
|
+
|
|
84
|
+
function EbsrMC() {
|
|
85
|
+
(0, _classCallCheck2["default"])(this, EbsrMC);
|
|
86
|
+
return _super.apply(this, arguments);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (0, _createClass2["default"])(EbsrMC);
|
|
90
|
+
}(_multipleChoice["default"]);
|
|
91
|
+
|
|
92
|
+
var defineMultipleChoice = function defineMultipleChoice() {
|
|
93
|
+
if (!customElements.get(MC_TAG_NAME)) {
|
|
94
|
+
customElements.define(MC_TAG_NAME, EbsrMC);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
defineMultipleChoice();
|
|
99
|
+
|
|
100
|
+
var isNonEmptyArray = function isNonEmptyArray(a) {
|
|
101
|
+
return Array.isArray(a) && a.length > 0;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
var isSessionComplete = function isSessionComplete(session) {
|
|
105
|
+
var a = (0, _get["default"])(session, 'value.partA.value');
|
|
106
|
+
var b = (0, _get["default"])(session, 'value.partB.value');
|
|
107
|
+
return isNonEmptyArray(a) && isNonEmptyArray(b);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
exports.isSessionComplete = isSessionComplete;
|
|
111
|
+
|
|
112
|
+
var Ebsr = /*#__PURE__*/function (_HTMLElement) {
|
|
113
|
+
(0, _inherits2["default"])(Ebsr, _HTMLElement);
|
|
114
|
+
|
|
115
|
+
var _super2 = _createSuper(Ebsr);
|
|
116
|
+
|
|
117
|
+
function Ebsr() {
|
|
118
|
+
var _this;
|
|
119
|
+
|
|
120
|
+
(0, _classCallCheck2["default"])(this, Ebsr);
|
|
121
|
+
_this = _super2.call(this);
|
|
122
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSessionUpdated", function (e) {
|
|
123
|
+
if (e.target === (0, _assertThisInitialized2["default"])(_this)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
e.stopImmediatePropagation();
|
|
129
|
+
var id = e.target.getAttribute('id');
|
|
130
|
+
|
|
131
|
+
if (id) {
|
|
132
|
+
var key = "part".concat(id.toUpperCase());
|
|
133
|
+
|
|
134
|
+
if (e.update) {
|
|
135
|
+
_this._model[key] = e.update;
|
|
136
|
+
} //TODO: accessing a private property here. The session event should contain the update in future to prevent this.
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
_this.dispatchSessionChanged(e.srcElement._session, key);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
_this._model = {};
|
|
143
|
+
_this._session = {};
|
|
144
|
+
_this._options = null;
|
|
145
|
+
return _this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
(0, _createClass2["default"])(Ebsr, [{
|
|
149
|
+
key: "model",
|
|
150
|
+
set: function set(m) {
|
|
151
|
+
var _this2 = this;
|
|
152
|
+
|
|
153
|
+
this._model = m;
|
|
154
|
+
customElements.whenDefined(MC_TAG_NAME).then(function () {
|
|
155
|
+
_this2.setPartModel(_this2.partA, 'partA');
|
|
156
|
+
|
|
157
|
+
_this2.setPartModel(_this2.partB, 'partB');
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "session",
|
|
162
|
+
set: function set(s) {
|
|
163
|
+
var _this3 = this;
|
|
164
|
+
|
|
165
|
+
this._session = s;
|
|
166
|
+
customElements.whenDefined(MC_TAG_NAME).then(function () {
|
|
167
|
+
_this3.setPartSession(_this3.partA, 'partA');
|
|
168
|
+
|
|
169
|
+
_this3.setPartSession(_this3.partB, 'partB');
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "setPartModel",
|
|
174
|
+
value: function setPartModel(part, key) {
|
|
175
|
+
if (this._model && this._model[key] && part) {
|
|
176
|
+
part.model = _objectSpread(_objectSpread({}, preparePrintModel(this._model[key], this._options)), {}, {
|
|
177
|
+
keyMode: this._model[key].choicePrefix
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (!part._session) {
|
|
181
|
+
// for print, "set session" is not called,
|
|
182
|
+
// but ebsr needs sessions in order to render the elements,
|
|
183
|
+
// so we set it here it was not set already
|
|
184
|
+
part.session = {};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "options",
|
|
190
|
+
set: function set(o) {
|
|
191
|
+
this._options = o;
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "setPartSession",
|
|
195
|
+
value: function setPartSession(part, key) {
|
|
196
|
+
if (this._session && this._model && part) {
|
|
197
|
+
var value = this._session.value;
|
|
198
|
+
part.session = value && value[key] ? value[key] : {
|
|
199
|
+
id: key
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "dispatchSessionChanged",
|
|
205
|
+
value: function dispatchSessionChanged(partSession, key) {
|
|
206
|
+
this._session.value = _objectSpread(_objectSpread({}, this._session.value), {}, (0, _defineProperty2["default"])({}, key, partSession));
|
|
207
|
+
log('[onSessionChanged] session: ', this._session);
|
|
208
|
+
var complete = isSessionComplete(this._session);
|
|
209
|
+
this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), complete));
|
|
210
|
+
}
|
|
211
|
+
}, {
|
|
212
|
+
key: "partA",
|
|
213
|
+
get: function get() {
|
|
214
|
+
return this.querySelector("".concat(MC_TAG_NAME, "#a"));
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "partB",
|
|
218
|
+
get: function get() {
|
|
219
|
+
return this.querySelector("".concat(MC_TAG_NAME, "#b"));
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "connectedCallback",
|
|
223
|
+
value: function connectedCallback() {
|
|
224
|
+
this._render();
|
|
225
|
+
|
|
226
|
+
this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);
|
|
227
|
+
}
|
|
228
|
+
}, {
|
|
229
|
+
key: "disconnectedCallback",
|
|
230
|
+
value: function disconnectedCallback() {
|
|
231
|
+
this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);
|
|
232
|
+
}
|
|
233
|
+
}, {
|
|
234
|
+
key: "_render",
|
|
235
|
+
value: function _render() {
|
|
236
|
+
this.innerHTML = "\n <div>\n <".concat(MC_TAG_NAME, " id=\"a\"></").concat(MC_TAG_NAME, ">\n <").concat(MC_TAG_NAME, " id=\"b\"></").concat(MC_TAG_NAME, ">\n </div>\n ");
|
|
237
|
+
}
|
|
238
|
+
}]);
|
|
239
|
+
return Ebsr;
|
|
240
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
|
|
241
|
+
|
|
242
|
+
exports["default"] = Ebsr;
|
|
243
|
+
//# sourceMappingURL=print.js.map
|
package/lib/print.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/print.js"],"names":["MC_TAG_NAME","SESSION_CHANGED","SessionChangedEvent","TYPE","log","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","alwaysShowCorrect","mode","disabled","animationsDisabled","lockChoiceOrder","choicesLayout","choices","map","c","rationale","rationaleEnabled","hideTick","feedback","keyMode","choicePrefix","EbsrMC","MultipleChoice","defineMultipleChoice","customElements","get","define","isNonEmptyArray","a","Array","isArray","length","isSessionComplete","session","b","Ebsr","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","key","toUpperCase","update","_model","dispatchSessionChanged","srcElement","_session","_options","m","whenDefined","then","setPartModel","partA","partB","s","setPartSession","part","o","value","partSession","complete","dispatchEvent","tagName","toLowerCase","querySelector","_render","addEventListener","onSessionUpdated","removeEventListener","innerHTML","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AACA,IAAMA,WAAW,GAAG,sBAApB;AACA,IAAMC,eAAe,GAAGC,qCAAoBC,IAA5C;AAEA,IAAMC,GAAG,GAAG,uBAAM,wBAAN,CAAZ;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAL,KAAc,YAA5B;AAEAH,EAAAA,KAAK,CAACI,MAAN,GAAeJ,KAAK,CAACK,aAAN,KAAwB,KAAxB,GAAgCL,KAAK,CAACI,MAAtC,GAA+CE,SAA9D;AACAN,EAAAA,KAAK,CAACO,mBAAN,GACEL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SADpF;AAEAN,EAAAA,KAAK,CAACS,uBAAN,GAAgCP,KAAhC;AACAF,EAAAA,KAAK,CAACU,iBAAN,GAA0BR,KAA1B;AACAF,EAAAA,K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d,mCACK,KAAKZ,QAAL,CAAcY,KADnB,4CAEGlB,GAFH,EAESmB,WAFT;AAKAnE,MAAAA,GAAG,CAAC,8BAAD,EAAiC,KAAKsD,QAAtC,CAAH;AACA,UAAMc,QAAQ,GAAG9B,iBAAiB,CAAC,KAAKgB,QAAN,CAAlC;AACA,WAAKe,aAAL,CAAmB,IAAIvE,oCAAJ,CAAwB,KAAKwE,OAAL,CAAaC,WAAb,EAAxB,EAAoDH,QAApD,CAAnB;AACD;;;SAED,eAAY;AACV,aAAO,KAAKI,aAAL,WAAsB5E,WAAtB,QAAP;AACD;;;SAED,eAAY;AACV,aAAO,KAAK4E,aAAL,WAAsB5E,WAAtB,QAAP;AACD;;;WAED,6BAAoB;AAClB,WAAK6E,OAAL;;AACA,WAAKC,gBAAL,CAAsB7E,eAAtB,EAAuC,KAAK8E,gBAA5C;AACD;;;WAED,gCAAuB;AACrB,WAAKC,mBAAL,CAAyB/E,eAAzB,EAA0C,KAAK8E,gBAA/C;AACD;;;WAED,mBAAU;AACR,WAAKE,SAAL,qCAEOjF,WAFP,yBAE+BA,WAF/B,yBAGOA,WAHP,yBAG+BA,WAH/B;AAMD;;;kDA7G+BkF,W","sourcesContent":["import React from 'react';\nimport cloneDeep from 'lodash/cloneDeep';\nimport MultipleChoice from '@pie-element/multiple-choice';\nimport debug from 'debug';\nimport get from 'lodash/get';\n\nimport { SessionChangedEvent } from '@pie-framework/pie-player-events';\nconst MC_TAG_NAME = 'ebsr-multiple-choice';\nconst SESSION_CHANGED = SessionChangedEvent.TYPE;\n\nconst log = debug('pie-element:ebsr:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.alwaysShowCorrect = instr;\n model.mode = instr ? 'evaluate' : 'gather';\n\n model.disabled = true;\n model.animationsDisabled = true;\n model.lockChoiceOrder = true;\n model.choicesLayout = model.choicesLayout || 'vertical';\n\n const choices = cloneDeep(model.choices);\n\n model.choices = choices.map((c) => {\n c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;\n c.hideTick = instr;\n c.feedback = undefined;\n return c;\n });\n\n model.keyMode = model.choicePrefix || 'letters';\n\n return model;\n};\n\nclass EbsrMC extends MultipleChoice {}\n\nconst defineMultipleChoice = () => {\n if (!customElements.get(MC_TAG_NAME)) {\n customElements.define(MC_TAG_NAME, EbsrMC);\n }\n};\n\ndefineMultipleChoice();\n\nconst isNonEmptyArray = (a) => Array.isArray(a) && a.length > 0;\n\nexport const isSessionComplete = (session) => {\n const a = get(session, 'value.partA.value');\n const b = get(session, 'value.partB.value');\n\n return isNonEmptyArray(a) && isNonEmptyArray(b);\n};\n\nexport default class Ebsr extends HTMLElement {\n constructor() {\n super();\n this._model = {};\n this._session = {};\n this._options = null;\n }\n\n onSessionUpdated = (e) => {\n if (e.target === this) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n\n const id = e.target.getAttribute('id');\n\n if (id) {\n const key = `part${id.toUpperCase()}`;\n\n if (e.update) {\n this._model[key] = e.update;\n }\n //TODO: accessing a private property here. The session event should contain the update in future to prevent this.\n this.dispatchSessionChanged(e.srcElement._session, key);\n }\n };\n\n set model(m) {\n this._model = m;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartModel(this.partA, 'partA');\n this.setPartModel(this.partB, 'partB');\n });\n }\n\n set session(s) {\n this._session = s;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartSession(this.partA, 'partA');\n this.setPartSession(this.partB, 'partB');\n });\n }\n\n setPartModel(part, key) {\n if (this._model && this._model[key] && part) {\n part.model = {\n ...preparePrintModel(this._model[key], this._options),\n keyMode: this._model[key].choicePrefix,\n };\n\n if (!part._session) {\n // for print, \"set session\" is not called,\n // but ebsr needs sessions in order to render the elements,\n // so we set it here it was not set already\n part.session = {};\n }\n }\n }\n\n set options(o) {\n this._options = o;\n }\n\n setPartSession(part, key) {\n if (this._session && this._model && part) {\n const { value } = this._session;\n part.session = value && value[key] ? value[key] : { id: key };\n }\n }\n\n dispatchSessionChanged(partSession, key) {\n this._session.value = {\n ...this._session.value,\n [key]: partSession,\n };\n\n log('[onSessionChanged] session: ', this._session);\n const complete = isSessionComplete(this._session);\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), complete));\n }\n\n get partA() {\n return this.querySelector(`${MC_TAG_NAME}#a`);\n }\n\n get partB() {\n return this.querySelector(`${MC_TAG_NAME}#b`);\n }\n\n connectedCallback() {\n this._render();\n this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n disconnectedCallback() {\n this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n _render() {\n this.innerHTML = `\n <div>\n <${MC_TAG_NAME} id=\"a\"></${MC_TAG_NAME}>\n <${MC_TAG_NAME} id=\"b\"></${MC_TAG_NAME}>\n </div>\n `;\n }\n}\n"],"file":"print.js"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.1-beta.587+40df32c2f",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@pie-element/multiple-choice": "^5.8.
|
|
10
|
+
"@pie-element/multiple-choice": "^5.8.1-beta.587+40df32c2f",
|
|
11
11
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"debug": "^4.1.1",
|
|
@@ -15,10 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"author": "pie framework developers",
|
|
17
17
|
"license": "ISC",
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "40df32c2f78966706cb168843567c9df174f1d88",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"postpublish": "../../scripts/postpublish"
|
|
21
21
|
},
|
|
22
22
|
"main": "lib/index.js",
|
|
23
|
-
"module": "src/index.js"
|
|
23
|
+
"module": "src/index.js",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./src/index.js",
|
|
26
|
+
"./print": "./src/print.js"
|
|
27
|
+
}
|
|
24
28
|
}
|
|
@@ -75,9 +75,7 @@ describe('ebsr', () => {
|
|
|
75
75
|
const session = { id: key, value };
|
|
76
76
|
el.dispatchSessionChanged(session, key);
|
|
77
77
|
|
|
78
|
-
expect(el.dispatchEvent).toBeCalledWith(
|
|
79
|
-
new SessionChangedEvent('ebsr-element', false)
|
|
80
|
-
);
|
|
78
|
+
expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('ebsr-element', false));
|
|
81
79
|
expect(el._session.value[key]).toEqual(session);
|
|
82
80
|
});
|
|
83
81
|
};
|
|
@@ -114,8 +112,5 @@ describe('isSessionComplete', () => {
|
|
|
114
112
|
};
|
|
115
113
|
|
|
116
114
|
assertComplete({}, false);
|
|
117
|
-
assertComplete(
|
|
118
|
-
{ value: { partA: { value: [1] }, partB: { value: [2] } } },
|
|
119
|
-
true
|
|
120
|
-
);
|
|
115
|
+
assertComplete({ value: { partA: { value: [1] }, partB: { value: [2] } } }, true);
|
|
121
116
|
});
|
package/src/index.js
CHANGED
|
@@ -71,8 +71,12 @@ export default class Ebsr extends HTMLElement {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
get session() {
|
|
75
|
+
return this._session;
|
|
76
|
+
}
|
|
77
|
+
|
|
74
78
|
setPartModel(part, key) {
|
|
75
|
-
if (this._model && this._model[key]) {
|
|
79
|
+
if (this._model && this._model[key] && part) {
|
|
76
80
|
const { mode } = this._model;
|
|
77
81
|
|
|
78
82
|
part.model = {
|
|
@@ -84,7 +88,7 @@ export default class Ebsr extends HTMLElement {
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
setPartSession(part, key) {
|
|
87
|
-
if (this._session && this._model) {
|
|
91
|
+
if (this._session && this._model && part) {
|
|
88
92
|
const { value } = this._session;
|
|
89
93
|
part.session = value && value[key] ? value[key] : { id: key };
|
|
90
94
|
}
|
|
@@ -98,9 +102,7 @@ export default class Ebsr extends HTMLElement {
|
|
|
98
102
|
|
|
99
103
|
log('[onSessionChanged] session: ', this._session);
|
|
100
104
|
const complete = isSessionComplete(this._session);
|
|
101
|
-
this.dispatchEvent(
|
|
102
|
-
new SessionChangedEvent(this.tagName.toLowerCase(), complete)
|
|
103
|
-
);
|
|
105
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), complete));
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
get partA() {
|