@pie-element/ebsr 12.3.4-next.0 → 13.0.0-beta.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.
Files changed (92) hide show
  1. package/configure/lib/defaults.js +23 -36
  2. package/configure/lib/defaults.js.map +1 -1
  3. package/configure/lib/index.js +114 -202
  4. package/configure/lib/index.js.map +1 -1
  5. package/configure/lib/main.js +188 -271
  6. package/configure/lib/main.js.map +1 -1
  7. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
  8. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +4213 -0
  9. package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
  10. package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
  11. package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
  12. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
  13. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +3351 -0
  14. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/__tests__/root.test.js +248 -0
  15. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +200 -0
  16. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
  17. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +211 -0
  18. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
  19. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +477 -0
  20. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
  21. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
  22. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
  23. package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +22 -0
  24. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
  25. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +2316 -0
  26. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/__tests__/index.test.js +520 -0
  27. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/__tests__/utils.test.js +8 -0
  28. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +33 -0
  29. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
  30. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +251 -0
  31. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
  32. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +16 -0
  33. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
  34. package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
  35. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +2993 -0
  36. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +2217 -0
  37. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
  38. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +61 -0
  39. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
  40. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/pie.manifest.json +11 -0
  41. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
  42. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +1332 -0
  43. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +1015 -0
  44. package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/choice-input-test.js +117 -0
  45. package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/index-test.js +151 -0
  46. package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/key-events-test.js +95 -0
  47. package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/multiple-choice-test.js +223 -0
  48. package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/session-updater-test.js +70 -0
  49. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +370 -0
  50. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
  51. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +197 -0
  52. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
  53. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +130 -0
  54. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
  55. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +292 -0
  56. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
  57. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +54 -0
  58. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
  59. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +386 -0
  60. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
  61. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +92 -0
  62. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
  63. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +37 -0
  64. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
  65. package/configure/node_modules/@pie-element/multiple-choice/package.json +39 -0
  66. package/configure/package.json +9 -6
  67. package/configure/src/__tests__/index.test.js +99 -108
  68. package/configure/src/index.js +13 -6
  69. package/configure/src/main.jsx +14 -18
  70. package/controller/lib/defaults.js +20 -32
  71. package/controller/lib/defaults.js.map +1 -1
  72. package/controller/lib/index.js +224 -349
  73. package/controller/lib/index.js.map +1 -1
  74. package/controller/lib/utils.js +4 -18
  75. package/controller/lib/utils.js.map +1 -1
  76. package/controller/package.json +3 -3
  77. package/lib/index.js +113 -181
  78. package/lib/index.js.map +1 -1
  79. package/lib/print.js +120 -204
  80. package/lib/print.js.map +1 -1
  81. package/package.json +5 -9
  82. package/src/__tests__/index.test.js +18 -5
  83. package/configure/src/__tests__/__snapshots__/index.test.js.snap +0 -83
  84. package/module/configure.js +0 -1
  85. package/module/controller.js +0 -6469
  86. package/module/demo.js +0 -77
  87. package/module/element.js +0 -1
  88. package/module/index.html +0 -21
  89. package/module/manifest.json +0 -14
  90. package/module/print-demo.js +0 -115
  91. package/module/print.html +0 -18
  92. package/module/print.js +0 -1
package/lib/print.js CHANGED
@@ -1,52 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
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
-
7
+ exports.isSessionComplete = exports.default = void 0;
14
8
  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
9
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
27
-
28
10
  var _multipleChoice = _interopRequireDefault(require("@pie-element/multiple-choice"));
29
-
30
11
  var _debug = _interopRequireDefault(require("debug"));
31
-
32
12
  var _get = _interopRequireDefault(require("lodash/get"));
33
-
34
13
  var _piePlayerEvents = require("@pie-framework/pie-player-events");
35
-
36
14
  var _translator = _interopRequireDefault(require("@pie-lib/translator"));
15
+ const MC_TAG_NAME = 'ebsr-multiple-choice';
16
+ const SESSION_CHANGED = _piePlayerEvents.SessionChangedEvent.TYPE;
17
+ const {
18
+ translator
19
+ } = _translator.default;
20
+ const log = (0, _debug.default)('pie-element:ebsr:print');
37
21
 
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 translator = _translator["default"].translator;
49
- var log = (0, _debug["default"])('pie-element:ebsr:print');
50
22
  /**
51
23
  * Live in same package as main element - so we can access some of the shared comps!
52
24
  *
@@ -55,8 +27,8 @@ var log = (0, _debug["default"])('pie-element:ebsr:print');
55
27
  * - get configure/controller building
56
28
  */
57
29
 
58
- var preparePrintModel = function preparePrintModel(model, opts) {
59
- var instr = opts.role === 'instructor';
30
+ const preparePrintModel = (model, opts) => {
31
+ const instr = opts.role === 'instructor';
60
32
  model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
61
33
  model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
62
34
  model.showTeacherInstructions = instr;
@@ -66,8 +38,8 @@ var preparePrintModel = function preparePrintModel(model, opts) {
66
38
  model.animationsDisabled = true;
67
39
  model.lockChoiceOrder = true;
68
40
  model.choicesLayout = model.choicesLayout || 'vertical';
69
- var choices = (0, _cloneDeep["default"])(model.choices);
70
- model.choices = choices.map(function (c) {
41
+ const choices = (0, _cloneDeep.default)(model.choices);
42
+ model.choices = choices.map(c => {
71
43
  c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
72
44
  c.hideTick = instr;
73
45
  c.feedback = undefined;
@@ -76,191 +48,135 @@ var preparePrintModel = function preparePrintModel(model, opts) {
76
48
  model.keyMode = model.choicePrefix || 'letters';
77
49
  return model;
78
50
  };
79
-
80
- var EbsrMC = /*#__PURE__*/function (_MultipleChoice) {
81
- (0, _inherits2["default"])(EbsrMC, _MultipleChoice);
82
-
83
- var _super = _createSuper(EbsrMC);
84
-
85
- function EbsrMC() {
86
- (0, _classCallCheck2["default"])(this, EbsrMC);
87
- return _super.apply(this, arguments);
88
- }
89
-
90
- return (0, _createClass2["default"])(EbsrMC);
91
- }(_multipleChoice["default"]);
92
-
93
- var defineMultipleChoice = function defineMultipleChoice() {
51
+ class EbsrMC extends _multipleChoice.default {}
52
+ const defineMultipleChoice = () => {
94
53
  if (!customElements.get(MC_TAG_NAME)) {
95
54
  customElements.define(MC_TAG_NAME, EbsrMC);
96
55
  }
97
56
  };
98
-
99
57
  defineMultipleChoice();
100
-
101
- var isNonEmptyArray = function isNonEmptyArray(a) {
102
- return Array.isArray(a) && a.length > 0;
103
- };
104
-
105
- var isSessionComplete = function isSessionComplete(session) {
106
- var a = (0, _get["default"])(session, 'value.partA.value');
107
- var b = (0, _get["default"])(session, 'value.partB.value');
58
+ const isNonEmptyArray = a => Array.isArray(a) && a.length > 0;
59
+ const isSessionComplete = session => {
60
+ const a = (0, _get.default)(session, 'value.partA.value');
61
+ const b = (0, _get.default)(session, 'value.partB.value');
108
62
  return isNonEmptyArray(a) && isNonEmptyArray(b);
109
63
  };
110
-
111
64
  exports.isSessionComplete = isSessionComplete;
112
-
113
- var Ebsr = /*#__PURE__*/function (_HTMLElement) {
114
- (0, _inherits2["default"])(Ebsr, _HTMLElement);
115
-
116
- var _super2 = _createSuper(Ebsr);
117
-
118
- function Ebsr() {
119
- var _this;
120
-
121
- (0, _classCallCheck2["default"])(this, Ebsr);
122
- _this = _super2.call(this);
123
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSessionUpdated", function (e) {
124
- if (e.target === (0, _assertThisInitialized2["default"])(_this)) {
65
+ class Ebsr extends HTMLElement {
66
+ constructor() {
67
+ super();
68
+ (0, _defineProperty2.default)(this, "onSessionUpdated", e => {
69
+ if (e.target === this) {
125
70
  return;
126
71
  }
127
-
128
72
  e.preventDefault();
129
73
  e.stopImmediatePropagation();
130
- var id = e.target.getAttribute('id');
131
-
74
+ const id = e.target.getAttribute('id');
132
75
  if (id) {
133
- var key = "part".concat(id.toUpperCase());
134
-
76
+ const key = `part${id.toUpperCase()}`;
135
77
  if (e.update) {
136
- _this._model[key] = e.update;
137
- } //TODO: accessing a private property here. The session event should contain the update in future to prevent this.
138
-
139
-
140
- _this.dispatchSessionChanged(e.srcElement._session, key);
78
+ this._model[key] = e.update;
79
+ }
80
+ //TODO: accessing a private property here. The session event should contain the update in future to prevent this.
81
+ this.dispatchSessionChanged(e.srcElement._session, key);
141
82
  }
142
83
  });
143
- _this._model = {};
144
- _this._session = {};
145
- _this._options = null;
146
- return _this;
84
+ this._model = {};
85
+ this._session = {};
86
+ this._options = null;
147
87
  }
148
-
149
- (0, _createClass2["default"])(Ebsr, [{
150
- key: "model",
151
- set: function set(m) {
152
- var _this2 = this;
153
-
154
- this._model = m;
155
- customElements.whenDefined(MC_TAG_NAME).then(function () {
156
- _this2.setPartModel(_this2.partA, 'partA');
157
-
158
- _this2.setPartModel(_this2.partB, 'partB');
159
- });
160
- }
161
- }, {
162
- key: "session",
163
- set: function set(s) {
164
- var _this3 = this;
165
-
166
- this._session = s;
167
- customElements.whenDefined(MC_TAG_NAME).then(function () {
168
- _this3.setPartSession(_this3.partA, 'partA');
169
-
170
- _this3.setPartSession(_this3.partB, 'partB');
171
- });
172
- }
173
- }, {
174
- key: "setPartModel",
175
- value: function setPartModel(part, key) {
176
- if (this._model && this._model[key] && part) {
177
- var labels = {
178
- 'partA': undefined,
179
- 'partB': undefined
88
+ set model(m) {
89
+ this._model = m;
90
+ customElements.whenDefined(MC_TAG_NAME).then(() => {
91
+ this.setPartModel(this.partA, 'partA');
92
+ this.setPartModel(this.partB, 'partB');
93
+ });
94
+ }
95
+ set session(s) {
96
+ this._session = s;
97
+ customElements.whenDefined(MC_TAG_NAME).then(() => {
98
+ this.setPartSession(this.partA, 'partA');
99
+ this.setPartSession(this.partB, 'partB');
100
+ });
101
+ }
102
+ setPartModel(part, key) {
103
+ if (this._model && this._model[key] && part) {
104
+ let labels = {
105
+ 'partA': undefined,
106
+ 'partB': undefined
107
+ };
108
+ if (this._model.partLabels) {
109
+ const language = this._model.language;
110
+ labels = {
111
+ 'partA': translator.t('ebsr.part', {
112
+ lng: language,
113
+ index: this._model.partLabelType === 'Letters' ? 'A' : '1'
114
+ }),
115
+ 'partB': translator.t('ebsr.part', {
116
+ lng: language,
117
+ index: this._model.partLabelType === 'Letters' ? 'B' : '2'
118
+ })
180
119
  };
181
-
182
- if (this._model.partLabels) {
183
- var language = this._model.language;
184
- labels = {
185
- 'partA': translator.t('ebsr.part', {
186
- lng: language,
187
- index: this._model.partLabelType === 'Letters' ? 'A' : '1'
188
- }),
189
- 'partB': translator.t('ebsr.part', {
190
- lng: language,
191
- index: this._model.partLabelType === 'Letters' ? 'B' : '2'
192
- })
193
- };
194
- }
195
-
196
- part.model = _objectSpread(_objectSpread({}, preparePrintModel(this._model[key], this._options)), {}, {
197
- keyMode: this._model[key].choicePrefix,
198
- partLabel: labels[key]
199
- }); // pass options to enable print mode detection in multiple-choice component
200
-
201
- part.options = this._options;
202
-
203
- if (!part._session) {
204
- // for print, "set session" is not called,
205
- // but ebsr needs sessions in order to render the elements,
206
- // so we set it here it was not set already
207
- part.session = {};
208
- }
209
120
  }
210
- }
211
- }, {
212
- key: "options",
213
- set: function set(o) {
214
- this._options = o;
215
- }
216
- }, {
217
- key: "setPartSession",
218
- value: function setPartSession(part, key) {
219
- if (this._session && this._model && part) {
220
- var value = this._session.value;
221
- part.session = value && value[key] ? value[key] : {
222
- id: key
223
- };
121
+ part.model = {
122
+ ...preparePrintModel(this._model[key], this._options),
123
+ keyMode: this._model[key].choicePrefix,
124
+ partLabel: labels[key]
125
+ };
126
+
127
+ // pass options to enable print mode detection in multiple-choice component
128
+ part.options = this._options;
129
+ if (!part._session) {
130
+ // for print, "set session" is not called,
131
+ // but ebsr needs sessions in order to render the elements,
132
+ // so we set it here it was not set already
133
+ part.session = {};
224
134
  }
225
135
  }
226
- }, {
227
- key: "dispatchSessionChanged",
228
- value: function dispatchSessionChanged(partSession, key) {
229
- this._session.value = _objectSpread(_objectSpread({}, this._session.value), {}, (0, _defineProperty2["default"])({}, key, partSession));
230
- log('[onSessionChanged] session: ', this._session);
231
- var complete = isSessionComplete(this._session);
232
- this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), complete));
233
- }
234
- }, {
235
- key: "partA",
236
- get: function get() {
237
- return this.querySelector("".concat(MC_TAG_NAME, "#a"));
238
- }
239
- }, {
240
- key: "partB",
241
- get: function get() {
242
- return this.querySelector("".concat(MC_TAG_NAME, "#b"));
243
- }
244
- }, {
245
- key: "connectedCallback",
246
- value: function connectedCallback() {
247
- this._render();
248
-
249
- this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);
250
- }
251
- }, {
252
- key: "disconnectedCallback",
253
- value: function disconnectedCallback() {
254
- this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);
255
- }
256
- }, {
257
- key: "_render",
258
- value: function _render() {
259
- 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 ");
136
+ }
137
+ set options(o) {
138
+ this._options = o;
139
+ }
140
+ setPartSession(part, key) {
141
+ if (this._session && this._model && part) {
142
+ const {
143
+ value
144
+ } = this._session;
145
+ part.session = value && value[key] ? value[key] : {
146
+ id: key
147
+ };
260
148
  }
261
- }]);
262
- return Ebsr;
263
- }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
264
-
265
- exports["default"] = Ebsr;
149
+ }
150
+ dispatchSessionChanged(partSession, key) {
151
+ this._session.value = {
152
+ ...this._session.value,
153
+ [key]: partSession
154
+ };
155
+ log('[onSessionChanged] session: ', this._session);
156
+ const complete = isSessionComplete(this._session);
157
+ this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), complete));
158
+ }
159
+ get partA() {
160
+ return this.querySelector(`${MC_TAG_NAME}#a`);
161
+ }
162
+ get partB() {
163
+ return this.querySelector(`${MC_TAG_NAME}#b`);
164
+ }
165
+ connectedCallback() {
166
+ this._render();
167
+ this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);
168
+ }
169
+ disconnectedCallback() {
170
+ this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);
171
+ }
172
+ _render() {
173
+ this.innerHTML = `
174
+ <div>
175
+ <${MC_TAG_NAME} id="a"></${MC_TAG_NAME}>
176
+ <${MC_TAG_NAME} id="b"></${MC_TAG_NAME}>
177
+ </div>
178
+ `;
179
+ }
180
+ }
181
+ exports.default = Ebsr;
266
182
  //# sourceMappingURL=print.js.map
package/lib/print.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/print.js"],"names":["MC_TAG_NAME","SESSION_CHANGED","SessionChangedEvent","TYPE","translator","Translator","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","labels","partLabels","language","t","lng","index","partLabelType","partLabel","options","o","value","partSession","complete","dispatchEvent","tagName","toLowerCase","querySelector","_render","addEventListener","onSessionUpdated","removeEventListener","innerHTML","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAGA;;;;;;;;;;AAFA,IAAMA,WAAW,GAAG,sBAApB;AACA,IAAMC,eAAe,GAAGC,qCAAoBC,IAA5C;AAGA,IAAQC,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA,IAAME,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,KA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AACA,WAAKwB,aAAL,CAAmB,IAAIlF,oCAAJ,CAAwB,KAAKmF,OAAL,CAAaC,WAAb,EAAxB,EAAoDH,QAApD,CAAnB;AACD;;;SAED,eAAY;AACV,aAAO,KAAKI,aAAL,WAAsBvF,WAAtB,QAAP;AACD;;;SAED,eAAY;AACV,aAAO,KAAKuF,aAAL,WAAsBvF,WAAtB,QAAP;AACD;;;WAED,6BAAoB;AAClB,WAAKwF,OAAL;;AACA,WAAKC,gBAAL,CAAsBxF,eAAtB,EAAuC,KAAKyF,gBAA5C;AACD;;;WAED,gCAAuB;AACrB,WAAKC,mBAAL,CAAyB1F,eAAzB,EAA0C,KAAKyF,gBAA/C;AACD;;;WAED,mBAAU;AACR,WAAKE,SAAL,qCAEO5F,WAFP,yBAE+BA,WAF/B,yBAGOA,WAHP,yBAG+BA,WAH/B;AAMD;;;kDArI+B6F,W","sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\nimport MultipleChoice from '@pie-element/multiple-choice';\nimport debug from 'debug';\nimport get from 'lodash/get';\nimport { SessionChangedEvent } from '@pie-framework/pie-player-events';\nconst MC_TAG_NAME = 'ebsr-multiple-choice';\nconst SESSION_CHANGED = SessionChangedEvent.TYPE;\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\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 let labels = {\n 'partA': undefined,\n 'partB': undefined\n };\n\n if (this._model.partLabels) {\n const language = this._model.language;\n\n labels = {\n 'partA': translator.t('ebsr.part', {\n lng: language,\n index: this._model.partLabelType === 'Letters' ? 'A' : '1'\n }),\n 'partB': translator.t('ebsr.part', {\n lng: language,\n index: this._model.partLabelType === 'Letters' ? 'B' : '2'\n })\n };\n }\n\n part.model = {\n ...preparePrintModel(this._model[key], this._options),\n keyMode: this._model[key].choicePrefix,\n partLabel: labels[key]\n };\n\n // pass options to enable print mode detection in multiple-choice component\n part.options = this._options;\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"}
1
+ {"version":3,"file":"print.js","names":["_cloneDeep","_interopRequireDefault","require","_multipleChoice","_debug","_get","_piePlayerEvents","_translator","MC_TAG_NAME","SESSION_CHANGED","SessionChangedEvent","TYPE","translator","Translator","log","debug","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","alwaysShowCorrect","mode","disabled","animationsDisabled","lockChoiceOrder","choicesLayout","choices","cloneDeep","map","c","rationale","rationaleEnabled","hideTick","feedback","keyMode","choicePrefix","EbsrMC","MultipleChoice","defineMultipleChoice","customElements","get","define","isNonEmptyArray","a","Array","isArray","length","isSessionComplete","session","b","exports","Ebsr","HTMLElement","constructor","_defineProperty2","default","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","key","toUpperCase","update","_model","dispatchSessionChanged","srcElement","_session","_options","m","whenDefined","then","setPartModel","partA","partB","s","setPartSession","part","labels","partLabels","language","t","lng","index","partLabelType","partLabel","options","o","value","partSession","complete","dispatchEvent","tagName","toLowerCase","querySelector","connectedCallback","_render","addEventListener","onSessionUpdated","disconnectedCallback","removeEventListener","innerHTML"],"sources":["../src/print.js"],"sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\nimport MultipleChoice from '@pie-element/multiple-choice';\nimport debug from 'debug';\nimport get from 'lodash/get';\nimport { SessionChangedEvent } from '@pie-framework/pie-player-events';\nconst MC_TAG_NAME = 'ebsr-multiple-choice';\nconst SESSION_CHANGED = SessionChangedEvent.TYPE;\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\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 let labels = {\n 'partA': undefined,\n 'partB': undefined\n };\n\n if (this._model.partLabels) {\n const language = this._model.language;\n\n labels = {\n 'partA': translator.t('ebsr.part', {\n lng: language,\n index: this._model.partLabelType === 'Letters' ? 'A' : '1'\n }),\n 'partB': translator.t('ebsr.part', {\n lng: language,\n index: this._model.partLabelType === 'Letters' ? 'B' : '2'\n })\n };\n }\n\n part.model = {\n ...preparePrintModel(this._model[key], this._options),\n keyMode: this._model[key].choicePrefix,\n partLabel: labels[key]\n };\n\n // pass options to enable print mode detection in multiple-choice component\n part.options = this._options;\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"],"mappings":";;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAGA,IAAAK,WAAA,GAAAN,sBAAA,CAAAC,OAAA;AAFA,MAAMM,WAAW,GAAG,sBAAsB;AAC1C,MAAMC,eAAe,GAAGC,oCAAmB,CAACC,IAAI;AAGhD,MAAM;EAAEC;AAAW,CAAC,GAAGC,mBAAU;AAEjC,MAAMC,GAAG,GAAG,IAAAC,cAAK,EAAC,wBAAwB,CAAC;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,iBAAiB,GAAGA,CAACC,KAAK,EAAEC,IA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AC3B,GAAG,GAAG4B;IACT,CAAC;IAEDnF,GAAG,CAAC,8BAA8B,EAAE,IAAI,CAAC6D,QAAQ,CAAC;IAClD,MAAMuB,QAAQ,GAAG5C,iBAAiB,CAAC,IAAI,CAACqB,QAAQ,CAAC;IACjD,IAAI,CAACwB,aAAa,CAAC,IAAIzF,oCAAmB,CAAC,IAAI,CAAC0F,OAAO,CAACC,WAAW,CAAC,CAAC,EAAEH,QAAQ,CAAC,CAAC;EACnF;EAEA,IAAIjB,KAAKA,CAAA,EAAG;IACV,OAAO,IAAI,CAACqB,aAAa,CAAC,GAAG9F,WAAW,IAAI,CAAC;EAC/C;EAEA,IAAI0E,KAAKA,CAAA,EAAG;IACV,OAAO,IAAI,CAACoB,aAAa,CAAC,GAAG9F,WAAW,IAAI,CAAC;EAC/C;EAEA+F,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAACC,OAAO,CAAC,CAAC;IACd,IAAI,CAACC,gBAAgB,CAAChG,eAAe,EAAE,IAAI,CAACiG,gBAAgB,CAAC;EAC/D;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAACC,mBAAmB,CAACnG,eAAe,EAAE,IAAI,CAACiG,gBAAgB,CAAC;EAClE;EAEAF,OAAOA,CAAA,EAAG;IACR,IAAI,CAACK,SAAS,GAAG;AACrB;AACA,WAAWrG,WAAW,aAAaA,WAAW;AAC9C,WAAWA,WAAW,aAAaA,WAAW;AAC9C;AACA,KAAK;EACH;AACF;AAACiD,OAAA,CAAAK,OAAA,GAAAJ,IAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,29 +1,25 @@
1
1
  {
2
2
  "name": "@pie-element/ebsr",
3
- "version": "12.3.4-next.0+bb17c7e0a",
3
+ "version": "13.0.0-beta.0",
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": "^11.4.4-next.0+bb17c7e0a",
10
+ "@pie-element/multiple-choice": "12.0.0-beta.0",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
- "@pie-lib/translator": "2.23.1",
12
+ "@pie-lib/translator": "2.23.3-next.0",
13
13
  "classnames": "^2.2.5",
14
14
  "debug": "^4.1.1",
15
15
  "lodash": "^4.17.11"
16
16
  },
17
17
  "author": "pie framework developers",
18
18
  "license": "ISC",
19
- "gitHead": "bb17c7e0a54b6b5ff139075cccf1e341cc6f859f",
19
+ "gitHead": "7879a67078db250e4b7e8fdc869638024600411d",
20
20
  "scripts": {
21
21
  "postpublish": "../../scripts/postpublish"
22
22
  },
23
23
  "main": "lib/index.js",
24
- "module": "src/index.js",
25
- "exports": {
26
- ".": "./src/index.js",
27
- "./print": "./src/print.js"
28
- }
24
+ "module": "src/index.js"
29
25
  }
@@ -42,14 +42,20 @@ describe('ebsr', () => {
42
42
 
43
43
  beforeAll(() => {
44
44
  Def = require('../index').default;
45
+
46
+ // Register the custom element if not already registered
47
+ if (!customElements.get('ebsr-element')) {
48
+ customElements.define('ebsr-element', Def);
49
+ }
45
50
  });
46
51
 
47
52
  beforeEach(() => {
48
- el = new Def();
49
- el.connectedCallback();
53
+ el = document.createElement('ebsr-element');
54
+
55
+ // Mock createElement for part elements
50
56
  ebsr = {
51
- partA: new HTMLElement(),
52
- partB: new HTMLElement(),
57
+ partA: document.createElement('div'),
58
+ partB: document.createElement('div'),
53
59
  };
54
60
  el.querySelector = jest.fn((s) => {
55
61
  if (s === '#part-a') {
@@ -58,7 +64,14 @@ describe('ebsr', () => {
58
64
  return ebsr.partB;
59
65
  }
60
66
  });
61
- el.tagName = 'ebsr-element';
67
+
68
+ // Mock _render to avoid innerHTML issues with custom elements
69
+ el._render = jest.fn();
70
+
71
+ // Mock dispatchEvent for testing
72
+ el.dispatchEvent = jest.fn();
73
+
74
+ el.connectedCallback();
62
75
  el.model = defaultModel;
63
76
  el.session = defaultSession;
64
77
  });
@@ -1,83 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`index createDefaultModel default-snapshot 1`] = `
4
- Object {
5
- "partA": Object {
6
- "choiceMode": "radio",
7
- "choicePrefix": "letters",
8
- "choices": Array [],
9
- "choicesLayout": "vertical",
10
- "feedbackEnabled": false,
11
- "gridColumns": 2,
12
- "prompt": "",
13
- "promptEnabled": true,
14
- "rationale": "",
15
- "rationaleEnabled": true,
16
- "spellCheckEnabled": true,
17
- "studentInstructionsEnabled": true,
18
- "teacherInstructions": "",
19
- "teacherInstructionsEnabled": true,
20
- "toolbarEditorPosition": "bottom",
21
- },
22
- "partB": Object {
23
- "choiceMode": "radio",
24
- "choicePrefix": "letters",
25
- "choices": Array [],
26
- "choicesLayout": "vertical",
27
- "feedbackEnabled": false,
28
- "gridColumns": 2,
29
- "prompt": "",
30
- "promptEnabled": true,
31
- "rationale": "",
32
- "rationaleEnabled": true,
33
- "spellCheckEnabled": true,
34
- "studentInstructionsEnabled": true,
35
- "teacherInstructions": "",
36
- "teacherInstructionsEnabled": true,
37
- "toolbarEditorPosition": "bottom",
38
- },
39
- "partLabelType": "Letters",
40
- "partLabels": true,
41
- }
42
- `;
43
-
44
- exports[`index createDefaultModel with-overrides-snapshot 1`] = `
45
- Object {
46
- "partA": Object {
47
- "choiceMode": "radio",
48
- "choicePrefix": "letters",
49
- "choices": Array [],
50
- "choicesLayout": "vertical",
51
- "feedbackEnabled": false,
52
- "gridColumns": 2,
53
- "prompt": "",
54
- "promptEnabled": true,
55
- "rationale": "foo",
56
- "rationaleEnabled": true,
57
- "spellCheckEnabled": true,
58
- "studentInstructionsEnabled": true,
59
- "teacherInstructions": "ti",
60
- "teacherInstructionsEnabled": true,
61
- "toolbarEditorPosition": "bottom",
62
- },
63
- "partB": Object {
64
- "choiceMode": "radio",
65
- "choicePrefix": "letters",
66
- "choices": Array [],
67
- "choicesLayout": "vertical",
68
- "feedbackEnabled": false,
69
- "gridColumns": 2,
70
- "prompt": "",
71
- "promptEnabled": true,
72
- "rationale": "",
73
- "rationaleEnabled": true,
74
- "spellCheckEnabled": true,
75
- "studentInstructionsEnabled": true,
76
- "teacherInstructions": "",
77
- "teacherInstructionsEnabled": true,
78
- "toolbarEditorPosition": "bottom",
79
- },
80
- "partLabelType": "Letters",
81
- "partLabels": true,
82
- }
83
- `;
@@ -1 +0,0 @@
1
- import{_dll_react as e,_dll_prop_types as t,_dll_material_ui__core_styles as i,_dll_lodash as a,_dll_react_dom as s}from"../../../@pie-lib/shared-module@^1.17.5/module/index.js";import o from"@pie-element/multiple-choice/configure/lib";import{_dll_pie_lib__config_ui as n}from"../../../@pie-lib/config-module@^2.23.3/module/index.js";var l={};Object.defineProperty(l,"__esModule",{value:!0});class r extends CustomEvent{constructor(e,t=!1){super(r.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}r.TYPE="model.updated";var c=l.ModelUpdatedEvent=r;class d extends CustomEvent{constructor(e,t){super(d.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}d.TYPE="delete.image",l.DeleteImageEvent=d;class h extends CustomEvent{constructor(e){super(h.TYPE,{bubbles:!0,detail:e}),this.handler=e}}h.TYPE="insert.image",l.InsertImageEvent=h;class p extends CustomEvent{constructor(e,t){super(p.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}p.TYPE="delete.sound",l.DeleteSoundEvent=p;class g extends CustomEvent{constructor(e){super(g.TYPE,{bubbles:!0,detail:e}),this.handler=e}}g.TYPE="insert.sound",l.InsertSoundEvent=g;const u=e,b=t,{withStyles:m}=i,{settings:_}=n,{layout:f}=n,{Panel:C,toggle:E,radio:A,dropdown:v}=_;class L extends u.Component{constructor(...e){super(...e),L.prototype.__init.call(this),L.prototype.__init2.call(this)}static __initStatic(){this.propTypes={classes:b.object,configuration:b.object,model:b.object,onModelChanged:b.func,onConfigurationChanged:b.func}}__init(){this.removeExtraChoices=e=>{let t=!1;return(e||[]).map((e=>t?(e.correct=!1,e):(e.correct&&(t=!0),e)))}}__init2(){this.onModelChanged=(e,t)=>{const{onModelChanged:i}=this.props;return"partA.choiceMode"===t&&"radio"===e.partA.choiceMode?(e.partA.choices=this.removeExtraChoices(e.partA.choices),i(e,!0)):"partB.choiceMode"===t&&"radio"===e.partB.choiceMode?(e.partB.choices=this.removeExtraChoices(e.partB.choices),i(e,!0)):i(e)}}render(){const{classes:e,model:t,configuration:i,onConfigurationChanged:a}=this.props,{partLabelType:s,partA:o,partB:n,extraCSSRules:l}=t,{contentDimensions:r={},partA:c={},partB:d={},partialScoring:h={},settingsPanelDisabled:p,scoringType:g={},language:b={},languageChoices:m={},..._}=i,{feedback:L={},choiceMode:y={},choicePrefix:B={},lockChoiceOrder:P={},prompt:M={},teacherInstructions:x={},studentInstructions:k={},choicesLayout:I={},gridColumns:S={},rationale:T={},spellCheck:D={}}=c||{},{feedback:Y={},choiceMode:O={},choicePrefix:w={},lockChoiceOrder:$={},prompt:j={},teacherInstructions:N={},studentInstructions:U={},choicesLayout:z={},gridColumns:R={},rationale:q={},spellCheck:H={}}=d||{},F="Numbers"===(s||"Numbers"),G="Part "+(F?"1":"A"),W="Part "+(F?"2":"B"),J={partA:o.choices&&o.choices.length?Array.from({length:o.choices.length},((e,t)=>`${t+1}`)):[],partB:n.choices&&n.choices.length?Array.from({length:n.choices.length},((e,t)=>`${t+1}`)):[]},K={partLabels:_.partLabels.settings&&E(_.partLabels.label),partLabelType:t.partLabels&&v("",["Numbers","Letters"]),partialScoring:h.settings&&E(h.label),scoringType:g.settings&&A(g.label,["auto","rubric"]),"language.enabled":b.settings&&E(b.label,!0),language:b.settings&&b.enabled&&v(m.label,m.options)},Q={"partA.choiceMode":y.settings&&A(y.label,["checkbox","radio"]),"partA.choicePrefix":B.settings&&A(B.label,["numbers","letters"]),"partA.lockChoiceOrder":P.settings&&E(P.label),"partA.choicesLayout":I.settings&&v(I.label,["vertical","grid","horizontal"]),"partA.gridColumns":I.settings&&"grid"===o.choicesLayout&&J.partA.length>0&&v(S.label,J.partA)},V={"partA.feedbackEnabled":L.settings&&E(L.label),"partA.promptEnabled":M.settings&&E(M.label),"partA.teacherInstructionsEnabled":x.settings&&E(x.label),"partA.studentInstructionsEnabled":k.settings&&E(k.label),"partA.rationaleEnabled":T.settings&&E(T.label),"partA.spellCheckEnabled":D.settings&&E(D.label)},X={"partB.choiceMode":O.settings&&A(O.label,["checkbox","radio"]),"partB.choicePrefix":w.settings&&A(w.label,["numbers","letters"]),"partB.lockChoiceOrder":$.settings&&E($.label),"partB.choicesLayout":z.settings&&v(z.label,["vertical","grid","horizontal"]),"partB.gridColumns":z.settings&&"grid"===n.choicesLayout&&J.partB.length>0&&v(R.label,J.partB)},Z={"partB.feedbackEnabled":Y.settings&&E(Y.label),"partB.promptEnabled":j.settings&&E(j.label),"partB.teacherInstructionsEnabled":N.settings&&E(N.label),"partB.studentInstructionsEnabled":U.settings&&E(U.label),"partB.rationaleEnabled":q.settings&&E(q.label),"partB.spellCheckEnabled":H.settings&&E(H.label)};return u.createElement(f.ConfigLayout,{extraCSSRules:l,dimensions:r,hideSettings:p,settings:u.createElement(C,{model:t,onChangeModel:this.onModelChanged,configuration:i,onChangeConfiguration:a,groups:{"Settings for both":K,[`Settings ${G}`]:Q,[`Properties ${G}`]:V,[`Settings ${W}`]:X,[`Properties ${W}`]:Z}})},t.partLabels&&u.createElement("div",{className:e.partLabel},G),u.createElement("ebsr-multiple-choice-configure",{id:"A",key:"partA",ref:e=>{e&&(this.partA=e,this.partA._model={...this.props.model.partA,errors:this.props.model.errors&&this.props.model.errors.partA||{}},this.partA.configuration={...c,..._})}}),u.createElement("div",{className:e.divider}),t.partLabels&&u.createElement("div",{className:e.partLabel},W),u.createElement("ebsr-multiple-choice-configure",{id:"B",key:"partB",ref:e=>{e&&(this.partB=e,this.partB._model={...this.props.model.partB,errors:this.props.model.errors&&this.props.model.errors.partB||{}},this.partB.configuration={...d,..._})}}))}}L.__initStatic();const y=m((e=>({partLabel:{paddingBottom:2*e.spacing.unit},divider:{flex:1,height:2.5*e.spacing.unit}})))(L),{cloneDeep:B}=a,P={addChoiceButton:{settings:!0,label:"Add a Choice"},choiceMode:{settings:!0,label:"Response Type"},choicePrefix:{settings:!0,label:"Choice Labels"},deleteChoice:{settings:!0},feedback:{settings:!0,label:"Feedback"},lockChoiceOrder:{settings:!0,label:"Lock Choice Order"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},rationale:{settings:!0,label:"Rationale",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},settingsPanelDisabled:!0,studentInstructions:{settings:!1,label:"Student Instructions"},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},choicesLayout:{settings:!1,label:"Choices Layout"},gridColumns:{label:"Grid columns"},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},maxImageWidth:{teacherInstructions:300,prompt:300,rationale:636,choices:636},maxImageHeight:{teacherInstructions:300,prompt:300,rationale:300,choices:300},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},choices:{inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}}},baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}}},M=e=>({choiceMode:"radio",choicePrefix:"letters",choices:[],choicesLayout:"vertical",feedbackEnabled:!1,gridColumns:2,prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,spellCheckEnabled:!0,studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom",...e});var x={model:{partLabels:!0,partLabelType:"Letters",partA:M(),partB:M()},configuration:{baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},partialScoring:{label:"Allow Partial Scoring",settings:!1},scoringType:{settings:!1,label:"Scoring Type"},partA:B(P),partB:B(P),partLabels:{settings:!0,label:"Part Labels"},settingsPanelDisabled:!1,language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]}}};const k=e,I=s,{defaults:S}=a;function T(e){let t,i=e[0],a=1;for(;a<e.length;){const s=e[a],o=e[a+1];if(a+=2,("optionalAccess"===s||"optionalCall"===s)&&null==i)return;"access"===s||"optionalAccess"===s?(t=i,i=o(i)):"call"!==s&&"optionalCall"!==s||(i=o(((...e)=>i.call(t,...e))),t=void 0)}return i}const D=c.TYPE;customElements.get("ebsr-multiple-choice-configure")||customElements.define("ebsr-multiple-choice-configure",class extends o{});const Y=(e,t)=>({configuration:S(e,x.configuration),model:t}),{model:O}=x||{};class w extends HTMLElement{static __initStatic(){this.createDefaultModel=({partA:e={},partB:t={},...i}={},a=O)=>({...a,...i,partA:{...a.partA,...e,choicesLayout:e.choicesLayout||!1===e.verticalMode&&"horizontal"||a.partA.choicesLayout},partB:{...a.partB,...t,choicesLayout:t.choicesLayout||!1===t.verticalMode&&"horizontal"||a.partB.choicesLayout}})}constructor(){super(),w.prototype.__init.call(this),w.prototype.__init2.call(this),this._model=w.createDefaultModel(),this._configuration=x.configuration,this.onConfigurationChanged=this.onConfigurationChanged.bind(this)}set model(e){this._model=w.createDefaultModel(e,this._model),this._render()}dispatchModelUpdated(e){const t=!!e;this.dispatchEvent(new c(this._model,t))}__init(){this.onModelChanged=(e,t)=>{this._model=w.createDefaultModel(e,this._model),this.dispatchModelUpdated(t),this._render()}}set configuration(e){const t=Y(e,this._model),i={...x.configuration,...t.configuration};this._configuration=i,T([i,"optionalAccess",e=>e.language,"optionalAccess",e=>e.enabled])?T([i,"optionalAccess",e=>e.languageChoices,"optionalAccess",e=>e.options,"optionalAccess",e=>e.length])&&(this._model.language=T([i,"optionalAccess",e=>e.languageChoices,"access",e=>e.options,"access",e=>e[0],"access",e=>e.value])):i.language.settings&&this._model.language?(this._configuration.language.enabled=!0,this._configuration.languageChoices.options&&this._configuration.languageChoices.options.length||(this._configuration.languageChoices.options=[]),this._configuration.languageChoices.options.find((e=>e.value===this._model.language))||this._configuration.languageChoices.options.push({value:this._model.language,label:this._model.language})):delete this._model.language,this._render()}onConfigurationChanged(e){this._configuration=Y(e,this._model).configuration,this._model&&this.onModelChanged(this._model),this._render()}__init2(){this.onModelUpdated=e=>{if(e.target===this)return;e.preventDefault(),e.stopImmediatePropagation();const t=e.target&&e.target.getAttribute("id");t&&(e.update&&(this._model[`part${t}`]=e.update),this.dispatchEvent(new c(this._model)))}}connectedCallback(){this.addEventListener(D,this.onModelUpdated),this._render()}disconnectedCallback(){this.removeEventListener(D,this.onModelUpdated)}_render(){let e=k.createElement(y,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged,onConfigurationChanged:this.onConfigurationChanged});I.render(e,this)}}w.__initStatic();export{w as default};