@pie-element/ebsr 13.2.0-next.9 → 14.0.1

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/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@pie-element/ebsr",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "13.2.0-next.9",
4
+ "version": "14.0.1",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "dependencies": {
10
- "@pie-element/multiple-choice": "^12.2.0-next.9",
10
+ "@pie-element/multiple-choice": "^13.0.1",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
- "@pie-lib/translator": "3.2.0-next.3",
12
+ "@pie-lib/translator": "4.0.0",
13
13
  "classnames": "^2.2.5",
14
14
  "debug": "^4.1.1",
15
15
  "lodash-es": "^4.17.23"
16
16
  },
17
17
  "author": "pie framework developers",
18
18
  "license": "ISC",
19
- "gitHead": "8c88ef381fb968e335518ffdc7f37790859ee415",
19
+ "gitHead": "70b44575d7ea20d6e4640d9c51c1593a23232be3",
20
20
  "scripts": {
21
21
  "postpublish": "../../scripts/postpublish"
22
22
  },
package/src/print.js CHANGED
@@ -20,31 +20,30 @@ const log = debug('pie-element:ebsr:print');
20
20
 
21
21
  const preparePrintModel = (model, opts) => {
22
22
  const instr = opts.role === 'instructor';
23
-
24
- model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
25
- model.teacherInstructions =
26
- instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
27
- model.showTeacherInstructions = instr;
28
- model.alwaysShowCorrect = instr;
29
- model.mode = instr ? 'evaluate' : 'gather';
30
-
31
- model.disabled = true;
32
- model.animationsDisabled = true;
33
- model.lockChoiceOrder = true;
34
- model.choicesLayout = model.choicesLayout || 'vertical';
35
-
36
- const choices = cloneDeep(model.choices);
37
-
38
- model.choices = choices.map((c) => {
39
- c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
23
+ const printModel = cloneDeep(model);
24
+
25
+ printModel.prompt = printModel.promptEnabled !== false ? printModel.prompt : undefined;
26
+ printModel.teacherInstructions =
27
+ instr && printModel.teacherInstructionsEnabled !== false ? printModel.teacherInstructions : undefined;
28
+ printModel.showTeacherInstructions = instr;
29
+ printModel.alwaysShowCorrect = instr;
30
+ printModel.mode = instr ? 'evaluate' : 'gather';
31
+
32
+ printModel.disabled = true;
33
+ printModel.animationsDisabled = true;
34
+ printModel.lockChoiceOrder = true;
35
+ printModel.choicesLayout = printModel.choicesLayout || 'vertical';
36
+
37
+ printModel.choices = (printModel.choices || []).map((c) => {
38
+ c.rationale = instr && printModel.rationaleEnabled !== false ? c.rationale : undefined;
40
39
  c.hideTick = instr;
41
40
  c.feedback = undefined;
42
41
  return c;
43
42
  });
44
43
 
45
- model.keyMode = model.choicePrefix || 'letters';
44
+ printModel.keyMode = printModel.choicePrefix || 'letters';
46
45
 
47
- return model;
46
+ return printModel;
48
47
  };
49
48
 
50
49
  class EbsrMC extends MultipleChoice {}
@@ -97,11 +96,7 @@ export default class Ebsr extends HTMLElement {
97
96
 
98
97
  set model(m) {
99
98
  this._model = m;
100
-
101
- customElements.whenDefined(MC_TAG_NAME).then(() => {
102
- this.setPartModel(this.partA, 'partA');
103
- this.setPartModel(this.partB, 'partB');
104
- });
99
+ this._updateParts();
105
100
  }
106
101
 
107
102
  set session(s) {
@@ -113,8 +108,15 @@ export default class Ebsr extends HTMLElement {
113
108
  });
114
109
  }
115
110
 
111
+ _updateParts() {
112
+ customElements.whenDefined(MC_TAG_NAME).then(() => {
113
+ this.setPartModel(this.partA, 'partA');
114
+ this.setPartModel(this.partB, 'partB');
115
+ });
116
+ }
117
+
116
118
  setPartModel(part, key) {
117
- if (this._model && this._model[key] && part) {
119
+ if (this._model && this._model[key] && part && this._options) {
118
120
  let labels = {
119
121
  partA: undefined,
120
122
  partB: undefined,
@@ -155,6 +157,8 @@ export default class Ebsr extends HTMLElement {
155
157
 
156
158
  set options(o) {
157
159
  this._options = o;
160
+ // re-render parts so role changes (student/instructor) propagate to each part
161
+ this._updateParts();
158
162
  }
159
163
 
160
164
  setPartSession(part, key) {