@pie-element/match 4.6.0 → 4.6.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +508 -0
  2. package/configure/CHANGELOG.md +465 -0
  3. package/configure/lib/add-row.js +1 -1
  4. package/configure/lib/add-row.js.map +1 -1
  5. package/configure/lib/answer-config-block.js +151 -51
  6. package/configure/lib/answer-config-block.js.map +1 -1
  7. package/configure/lib/common.js +46 -0
  8. package/configure/lib/common.js.map +1 -0
  9. package/configure/lib/configure.js +98 -36
  10. package/configure/lib/configure.js.map +1 -1
  11. package/configure/lib/defaults.js +31 -2
  12. package/configure/lib/defaults.js.map +1 -1
  13. package/configure/lib/general-config-block.js +86 -33
  14. package/configure/lib/general-config-block.js.map +1 -1
  15. package/configure/lib/index.js +18 -4
  16. package/configure/lib/index.js.map +1 -1
  17. package/configure/lib/row.js +122 -34
  18. package/configure/lib/row.js.map +1 -1
  19. package/configure/package.json +7 -7
  20. package/configure/utils.js +12 -0
  21. package/controller/CHANGELOG.md +103 -0
  22. package/controller/lib/defaults.js.map +1 -1
  23. package/controller/lib/index.js +159 -16
  24. package/controller/lib/index.js.map +1 -1
  25. package/controller/package.json +3 -3
  26. package/docs/config-schema.json +153 -0
  27. package/docs/config-schema.json.md +117 -1
  28. package/docs/demo/config.js +2 -2
  29. package/docs/demo/generate.js +11 -9
  30. package/docs/pie-schema.json +48 -0
  31. package/docs/pie-schema.json.md +39 -0
  32. package/lib/answer-grid.js +12 -12
  33. package/lib/answer-grid.js.map +1 -1
  34. package/lib/index.js +7 -2
  35. package/lib/index.js.map +1 -1
  36. package/lib/main.js +16 -20
  37. package/lib/main.js.map +1 -1
  38. package/package.json +6 -5
@@ -98,6 +98,22 @@ Indicates if the item has to be displayed in the Settings Panel
98
98
 
99
99
  Indicates the label for the item that has to be displayed in the Settings Panel
100
100
 
101
+ # `settingsPanelDisabled` (boolean)
102
+
103
+ Indicates if the settings panel is not available
104
+
105
+ # `spellCheck` (object)
106
+
107
+ Properties of the `spellCheck` object:
108
+
109
+ ## `settings` (boolean)
110
+
111
+ Indicates if the item has to be displayed in the Settings Panel
112
+
113
+ ## `label` (string)
114
+
115
+ Indicates the label for the item that has to be displayed in the Settings Panel
116
+
101
117
  # `rationale` (object)
102
118
 
103
119
  Properties of the `rationale` object:
@@ -146,6 +162,86 @@ Indicates if the item has to be displayed in the Settings Panel
146
162
 
147
163
  Indicates the label for the item that has to be displayed in the Settings Panel
148
164
 
165
+ # `maxImageWidth` (object)
166
+
167
+ Properties of the `maxImageWidth` object:
168
+
169
+ ## `teacherInstructions` (number)
170
+
171
+ Indicates the max dimension for images in teacher instructions
172
+
173
+ ## `prompt` (number)
174
+
175
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
176
+
177
+ ## `rationale` (number)
178
+
179
+ Indicates the max dimension for images in rationale
180
+
181
+ ## `rowTitles` (number)
182
+
183
+ Indicates the max dimension for images in row labels
184
+
185
+ # `maxImageHeight` (object)
186
+
187
+ Properties of the `maxImageHeight` object:
188
+
189
+ ## `teacherInstructions` (number)
190
+
191
+ Indicates the max dimension for images in teacher instructions
192
+
193
+ ## `prompt` (number)
194
+
195
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
196
+
197
+ ## `rationale` (number)
198
+
199
+ Indicates the max dimension for images in rationale
200
+
201
+ ## `rowTitles` (number)
202
+
203
+ Indicates the max dimension for images in row labels
204
+
205
+ # `withRubric` (object)
206
+
207
+ Properties of the `withRubric` object:
208
+
209
+ ## `settings` (boolean)
210
+
211
+ Indicates if the item has to be displayed in the Settings Panel
212
+
213
+ ## `label` (string)
214
+
215
+ Indicates the label for the item that has to be displayed in the Settings Panel
216
+
217
+ # `minQuestions` (number)
218
+
219
+ Indicates the minimum number of question rows
220
+
221
+ # `maxQuestions` (number)
222
+
223
+ Indicates the maximum number of question rows
224
+
225
+ # `maxLengthQuestionsHeading` (number)
226
+
227
+ Indicates the maximum length of question rows headings
228
+
229
+ # `maxAnswers` (number)
230
+
231
+ Indicates the maximum number of answer columns
232
+
233
+ # `maxLengthAnswers` (number)
234
+
235
+ Indicates the maximum length of answer columns headings
236
+
237
+ # `maxLengthFirstColumnHeading` (number)
238
+
239
+ Indicates the maximum length of first column headings
240
+
241
+ # `width` (string, required)
242
+
243
+ How large (in px) should match be
244
+
149
245
  # `showPrompt` (boolean)
150
246
 
151
247
  Determines whether prompt field will be displayed or not
@@ -180,4 +276,24 @@ Indicates if the item has to be displayed in the Settings Panel
180
276
 
181
277
  ### `label` (string)
182
278
 
183
- Indicates the label for the item that has to be displayed in the Settings Panel
279
+ Indicates the label for the item that has to be displayed in the Settings Panel
280
+
281
+ ## `ConfigureMaxImageDimensionsProp` (object)
282
+
283
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
284
+
285
+ ### `teacherInstructions` (number)
286
+
287
+ Indicates the max dimension for images in teacher instructions
288
+
289
+ ### `prompt` (number)
290
+
291
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
292
+
293
+ ### `rationale` (number)
294
+
295
+ Indicates the max dimension for images in rationale
296
+
297
+ ### `rowTitles` (number)
298
+
299
+ Indicates the max dimension for images in row labels
@@ -2,7 +2,7 @@ const { model } = require('./generate');
2
2
 
3
3
  module.exports = {
4
4
  elements: {
5
- 'match-element': '../..'
5
+ 'match-element': '../..',
6
6
  },
7
- models: [model('1', 'match-element')]
7
+ models: [model('1', 'match-element')],
8
8
  };
@@ -5,16 +5,16 @@ exports.model = (id, element) => ({
5
5
  feedback: {
6
6
  correct: {
7
7
  type: 'none',
8
- default: 'Correct'
8
+ default: 'Correct',
9
9
  },
10
10
  partial: {
11
11
  type: 'none',
12
- default: 'Nearly'
12
+ default: 'Nearly',
13
13
  },
14
14
  incorrect: {
15
15
  type: 'none',
16
- default: 'Incorrect'
17
- }
16
+ default: 'Incorrect',
17
+ },
18
18
  },
19
19
  headers: ['Column 1', 'Column 2', 'Column 3'],
20
20
  layout: 3,
@@ -25,24 +25,26 @@ exports.model = (id, element) => ({
25
25
  {
26
26
  id: 1,
27
27
  title: 'Question Text 1',
28
- values: [false, false]
28
+ values: [false, false],
29
29
  },
30
30
  {
31
31
  id: 2,
32
32
  title: 'Question Text 2',
33
- values: [false, false]
33
+ values: [false, false],
34
34
  },
35
35
  {
36
36
  id: 3,
37
37
  title: 'Question Text 3',
38
- values: [false, false]
38
+ values: [false, false],
39
39
  },
40
40
  {
41
41
  id: 4,
42
42
  title: 'Question Text 4',
43
- values: [false, false]
44
- }
43
+ values: [false, false],
44
+ },
45
45
  ],
46
46
  promptEnabled: true,
47
47
  prompt: 'Select correct answers.',
48
+ toolbarEditorPosition: 'bottom',
49
+ rubricEnabled: false,
48
50
  });
@@ -288,6 +288,11 @@
288
288
  "type": "boolean",
289
289
  "title": "rationaleEnabled"
290
290
  },
291
+ "spellCheckEnabled": {
292
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
293
+ "type": "boolean",
294
+ "title": "spellCheckEnabled"
295
+ },
291
296
  "studentInstructionsEnabled": {
292
297
  "description": "Indicates if Student Instructions are enabled",
293
298
  "type": "boolean",
@@ -298,6 +303,21 @@
298
303
  "type": "boolean",
299
304
  "title": "teacherInstructionsEnabled"
300
305
  },
306
+ "toolbarEditorPosition": {
307
+ "description": "Indicates the editor's toolbar position which can be 'bottom' or 'top'",
308
+ "default": ": 'bottom'",
309
+ "enum": [
310
+ "bottom",
311
+ "top"
312
+ ],
313
+ "type": "string",
314
+ "title": "toolbarEditorPosition"
315
+ },
316
+ "rubricEnabled": {
317
+ "description": "Indicates if Rubric is enabled",
318
+ "type": "boolean",
319
+ "title": "rubricEnabled"
320
+ },
301
321
  "id": {
302
322
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
303
323
  "type": "string",
@@ -319,6 +339,8 @@
319
339
  "rationale",
320
340
  "rationaleEnabled",
321
341
  "rows",
342
+ "rubricEnabled",
343
+ "spellCheckEnabled",
322
344
  "studentInstructionsEnabled",
323
345
  "teacherInstructionsEnabled"
324
346
  ],
@@ -339,6 +361,32 @@
339
361
  }
340
362
  }
341
363
  },
364
+ "ConfigureMaxImageDimensionsProp": {
365
+ "title": "ConfigureMaxImageDimensionsProp",
366
+ "type": "object",
367
+ "properties": {
368
+ "teacherInstructions": {
369
+ "description": "Indicates the max dimension for images in teacher instructions",
370
+ "type": "number",
371
+ "title": "teacherInstructions"
372
+ },
373
+ "prompt": {
374
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
375
+ "type": "number",
376
+ "title": "prompt"
377
+ },
378
+ "rationale": {
379
+ "description": "Indicates the max dimension for images in rationale",
380
+ "type": "number",
381
+ "title": "rationale"
382
+ },
383
+ "rowTitles": {
384
+ "description": "Indicates the max dimension for images in row labels",
385
+ "type": "number",
386
+ "title": "rowTitles"
387
+ }
388
+ }
389
+ },
342
390
  "ComplexFeedbackType": {
343
391
  "title": "ComplexFeedbackType",
344
392
  "type": "object",
@@ -108,6 +108,10 @@ Indicates if Feedback is enabled
108
108
 
109
109
  Indicates if Rationale are enabled
110
110
 
111
+ # `spellCheckEnabled` (boolean, required)
112
+
113
+ Indicates if spellcheck is enabled for the author. Default value is true
114
+
111
115
  # `studentInstructionsEnabled` (boolean, required)
112
116
 
113
117
  Indicates if Student Instructions are enabled
@@ -116,6 +120,21 @@ Indicates if Student Instructions are enabled
116
120
 
117
121
  Indicates if Teacher Instructions are enabled
118
122
 
123
+ # `toolbarEditorPosition` (string, enum)
124
+
125
+ Indicates the editor's toolbar position which can be 'bottom' or 'top'
126
+
127
+ This element must be one of the following enum values:
128
+
129
+ * `bottom`
130
+ * `top`
131
+
132
+ Default: `": 'bottom'"`
133
+
134
+ # `rubricEnabled` (boolean, required)
135
+
136
+ Indicates if Rubric is enabled
137
+
119
138
  # `id` (string, required)
120
139
 
121
140
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -142,6 +161,26 @@ Indicates if the item has to be displayed in the Settings Panel
142
161
 
143
162
  Indicates the label for the item that has to be displayed in the Settings Panel
144
163
 
164
+ ## `ConfigureMaxImageDimensionsProp` (object)
165
+
166
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
167
+
168
+ ### `teacherInstructions` (number)
169
+
170
+ Indicates the max dimension for images in teacher instructions
171
+
172
+ ### `prompt` (number)
173
+
174
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
175
+
176
+ ### `rationale` (number)
177
+
178
+ Indicates the max dimension for images in rationale
179
+
180
+ ### `rowTitles` (number)
181
+
182
+ Indicates the max dimension for images in row labels
183
+
145
184
  ## `ComplexFeedbackType` (object)
146
185
 
147
186
  Properties of the `ComplexFeedbackType` object:
@@ -37,13 +37,13 @@ var _styles = require("@material-ui/core/styles");
37
37
 
38
38
  var _renderUi = require("@pie-lib/render-ui");
39
39
 
40
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
40
+ 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; }
41
41
 
42
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
42
+ 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; }
43
43
 
44
44
  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); }; }
45
45
 
46
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
46
+ 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; } }
47
47
 
48
48
  var AnswerGrid = /*#__PURE__*/function (_React$Component) {
49
49
  (0, _inherits2["default"])(AnswerGrid, _React$Component);
@@ -96,7 +96,6 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
96
96
  var _this2 = this;
97
97
 
98
98
  var _this$props2 = this.props,
99
- allowFeedback = _this$props2.allowFeedback,
100
99
  classes = _this$props2.classes,
101
100
  showCorrect = _this$props2.showCorrect,
102
101
  headers = _this$props2.headers,
@@ -106,6 +105,7 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
106
105
  disabled = _this$props2.disabled,
107
106
  view = _this$props2.view;
108
107
  var Tag = choiceMode === 'radio' ? _Radio["default"] : _Checkbox["default"];
108
+ var evaluate = disabled && !view;
109
109
 
110
110
  if (!rows || rows.length === 0) {
111
111
  return /*#__PURE__*/_react["default"].createElement("div", {
@@ -120,11 +120,11 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
120
120
  className: classes.controlsContainer
121
121
  }, /*#__PURE__*/_react["default"].createElement("table", {
122
122
  className: classes.table
123
- }, /*#__PURE__*/_react["default"].createElement("colgroup", null, headers.map(function (header, idx) {
123
+ }, /*#__PURE__*/_react["default"].createElement("colgroup", null, (headers || []).map(function (header, idx) {
124
124
  return /*#__PURE__*/_react["default"].createElement("col", {
125
125
  key: "col-".concat(idx)
126
126
  });
127
- })), /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, headers.map(function (header, idx) {
127
+ })), /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, (headers || []).map(function (header, idx) {
128
128
  return /*#__PURE__*/_react["default"].createElement("th", {
129
129
  className: classes.rowHeader,
130
130
  key: "th-".concat(idx),
@@ -136,7 +136,7 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
136
136
  __html: header
137
137
  }
138
138
  }));
139
- }))), rows.map(function (row, idx) {
139
+ }))), (rows || []).map(function (row, idx) {
140
140
  return /*#__PURE__*/_react["default"].createElement("tbody", {
141
141
  key: "row-".concat(idx),
142
142
  role: "group"
@@ -150,7 +150,7 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
150
150
  dangerouslySetInnerHTML: {
151
151
  __html: row.title
152
152
  }
153
- })), answers[row.id].map(function (rowItem, answerIndex) {
153
+ })), (answers[row.id] || []).map(function (rowItem, answerIndex) {
154
154
  var _cx2;
155
155
 
156
156
  return /*#__PURE__*/_react["default"].createElement("td", {
@@ -160,7 +160,7 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
160
160
  }, /*#__PURE__*/_react["default"].createElement("div", {
161
161
  className: classes.rowItem
162
162
  }, /*#__PURE__*/_react["default"].createElement(Tag, {
163
- className: (0, _classnames["default"])((_cx2 = {}, (0, _defineProperty2["default"])(_cx2, classes.correct, allowFeedback && (showCorrect && rowItem === true || disabled && !view && _this2.answerIsCorrect(row.id, rowItem, answerIndex))), (0, _defineProperty2["default"])(_cx2, classes.tag, true), (0, _defineProperty2["default"])(_cx2, classes.checked, rowItem === true), (0, _defineProperty2["default"])(_cx2, classes.tagDisabled, disabled), (0, _defineProperty2["default"])(_cx2, classes.incorrect, allowFeedback && disabled && !view && _this2.answerIsIncorrect(row.id, rowItem, answerIndex)), _cx2)),
163
+ className: (0, _classnames["default"])((_cx2 = {}, (0, _defineProperty2["default"])(_cx2, classes.correct, showCorrect && rowItem === true || evaluate && _this2.answerIsCorrect(row.id, rowItem, answerIndex)), (0, _defineProperty2["default"])(_cx2, classes.tag, true), (0, _defineProperty2["default"])(_cx2, classes.checked, rowItem === true && !evaluate), (0, _defineProperty2["default"])(_cx2, classes.tagDisabled, disabled), (0, _defineProperty2["default"])(_cx2, classes.incorrect, evaluate && _this2.answerIsIncorrect(row.id, rowItem, answerIndex)), _cx2)),
164
164
  disabled: disabled,
165
165
  onChange: _this2.onRowValueChange(row.id, answerIndex),
166
166
  checked: rowItem === true
@@ -174,7 +174,6 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
174
174
 
175
175
  exports.AnswerGrid = AnswerGrid;
176
176
  (0, _defineProperty2["default"])(AnswerGrid, "propTypes", {
177
- allowFeedback: _propTypes["default"].bool.isRequired,
178
177
  classes: _propTypes["default"].object.isRequired,
179
178
  correctAnswers: _propTypes["default"].object,
180
179
  view: _propTypes["default"].bool.isRequired,
@@ -196,7 +195,7 @@ var styles = function styles(theme) {
196
195
  marginBottom: theme.spacing.unit
197
196
  },
198
197
  column: {
199
- padding: '10px 20px 0'
198
+ padding: '5px 0'
200
199
  },
201
200
  correct: {
202
201
  color: "".concat(_renderUi.color.correct(), " !important")
@@ -215,7 +214,7 @@ var styles = function styles(theme) {
215
214
  padding: 0
216
215
  },
217
216
  rowItem: {
218
- padding: '6px 12px',
217
+ padding: '12px',
219
218
  textAlign: 'center'
220
219
  },
221
220
  separator: {
@@ -224,6 +223,7 @@ var styles = function styles(theme) {
224
223
  width: '100%'
225
224
  },
226
225
  tag: {
226
+ padding: '6px',
227
227
  color: _renderUi.color.text(),
228
228
  '&:hover': {
229
229
  color: _renderUi.color.primaryLight()
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/answer-grid.jsx"],"names":["AnswerGrid","rowId","answerIndex","event","props","onAnswerChange","choiceMode","answers","newAnswers","i","length","target","checked","rowValue","rowValueIndex","correctAnswers","allowFeedback","classes","showCorrect","headers","rows","disabled","view","Tag","Radio","Checkbox","controlsContainer","empty","table","map","header","idx","rowHeader","rowItem","questionText","__html","row","separator","title","id","column","correct","answerIsCorrect","tag","tagDisabled","incorrect","answerIsIncorrect","onRowValueChange","React","Component","PropTypes","bool","isRequired","object","func","string","array","styles","theme","marginLeft","marginRight","marginTop","spacing","unit","marginBottom","padding","color","margin","rowContainer","display","alignItems","textAlign","border","borderTop","primaryLight","width","text","primary","cursor","pointerEvents","opacity","backgroundColor","background","borderCollapse","borderSpacing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,U;;;;;;;;;;;;;;;yGAeQ,UAACC,KAAD,EAAQC,WAAR;AAAA,aAAwB,UAAAC,KAAK,EAAI;AAAA,0BACF,MAAKC,KADH;AAAA,YAC1CC,cAD0C,eAC1CA,cAD0C;AAAA,YAC1BC,UAD0B,eAC1BA,UAD0B;AAAA,YACdC,OADc,eACdA,OADc;;AAElD,YAAMC,UAAU,qBAAQD,OAAR,CAAhB;;AAEA,YAAID,UAAU,KAAK,OAAnB,EAA4B;AAC1B,eAAK,IAAIG,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,UAAU,CAACP,KAAD,CAAV,CAA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AAA,aAAa,EAAE,CAJV;AAKLpB,MAAAA,YAAY,EAAE;AALT,KArDgB;AA4DvB9B,IAAAA,YAAY,EAAE;AACZqC,MAAAA,SAAS,EAAE;AADC;AA5DS,GAAL;AAAA,CAApB;;eAiEe,wBAAWd,MAAX,EAAmBzD,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport Radio from '@material-ui/core/Radio';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport Typography from '@material-ui/core/Typography';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/render-ui';\n\nexport class AnswerGrid extends React.Component {\n static propTypes = {\n allowFeedback: PropTypes.bool.isRequired,\n classes: PropTypes.object.isRequired,\n correctAnswers: PropTypes.object,\n view: PropTypes.bool.isRequired,\n showCorrect: PropTypes.bool.isRequired,\n disabled: PropTypes.bool.isRequired,\n onAnswerChange: PropTypes.func.isRequired,\n choiceMode: PropTypes.string.isRequired,\n rows: PropTypes.array.isRequired,\n headers: PropTypes.array.isRequired,\n answers: PropTypes.object.isRequired\n };\n\n onRowValueChange = (rowId, answerIndex) => event => {\n const { onAnswerChange, choiceMode, answers } = this.props;\n const newAnswers = { ...answers };\n\n if (choiceMode === 'radio') {\n for (let i = 0; i < newAnswers[rowId].length; i++) {\n newAnswers[rowId][i] = false;\n }\n }\n\n newAnswers[rowId][answerIndex] = event.target.checked;\n\n onAnswerChange(newAnswers);\n };\n\n answerIsCorrect = (rowId, rowValue, rowValueIndex) => {\n const { correctAnswers } = this.props;\n\n return correctAnswers[rowId][rowValueIndex] === rowValue && rowValue === true;\n };\n\n // needs a separate method because what isn't correct isn't necessarily incorrect\n answerIsIncorrect = (rowId, rowValue, rowValueIndex) => {\n const { correctAnswers } = this.props;\n\n return correctAnswers[rowId][rowValueIndex] === true && rowValue === false\n || correctAnswers[rowId][rowValueIndex] === false && rowValue === true;\n };\n\n render() {\n const { allowFeedback, classes, showCorrect, headers, rows, choiceMode, answers, disabled, view } = this.props;\n const Tag = choiceMode === 'radio' ? Radio : Checkbox;\n\n if (!rows || rows.length === 0) {\n return (\n <div className={classes.controlsContainer}>\n <Typography className={classes.empty} component=\"div\">\n There are currently no questions to show.\n </Typography>\n </div>);\n }\n\n return (\n <div className={classes.controlsContainer}>\n <table className={classes.table}>\n <colgroup>\n {headers.map((header, idx) => (<col key={`col-${idx}`}/>))}\n </colgroup>\n\n <thead>\n <tr>\n {headers.map((header, idx) => (\n <th\n className={classes.rowHeader}\n key={`th-${idx}`}\n data-colno={`${idx}`}\n scope=\"row\"\n >\n <div\n className={cx(classes.rowItem, { [classes.questionText]: idx === 0 })}\n dangerouslySetInnerHTML={{ __html: header }}\n />\n </th>\n ))}\n </tr>\n </thead>\n\n {rows.map((row, idx) => (\n <tbody key={`row-${idx}`} role=\"group\">\n <tr className={classes.separator}>\n <td\n key={`td-title-${idx}`}\n data-colno={'0'}\n >\n <div\n className={cx(classes.rowItem, classes.questionText)}\n dangerouslySetInnerHTML={{ __html: row.title }}\n />\n </td>\n\n {answers[row.id].map((rowItem, answerIndex) => (\n <td\n key={`td-${idx}-${answerIndex}`}\n className={classes.column}\n data-colno={`${answerIndex + 1}`}\n >\n <div className={classes.rowItem}>\n <Tag\n className={cx({\n [classes.correct]: allowFeedback && (\n (showCorrect && rowItem === true) ||\n (disabled && !view && this.answerIsCorrect(row.id, rowItem, answerIndex))\n ),\n [classes.tag]: true,\n [classes.checked]: rowItem === true,\n [classes.tagDisabled]: disabled,\n [classes.incorrect]: allowFeedback && disabled && !view && this.answerIsIncorrect(row.id, rowItem, answerIndex)\n })}\n disabled={disabled}\n onChange={this.onRowValueChange(row.id, answerIndex)}\n checked={rowItem === true}\n />\n </div>\n </td>\n ))}\n </tr>\n </tbody>\n ))}\n </table>\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n controlsContainer: {\n marginLeft: 'auto',\n marginRight: 'auto',\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit\n },\n column: {\n padding: '10px 20px 0',\n },\n correct: {\n color: `${color.correct()} !important`\n },\n incorrect: {\n color: `${color.incorrect()} !important`\n },\n empty: {\n margin: theme.spacing.unit * 2\n },\n rowContainer: {\n display: 'flex',\n alignItems: 'center',\n },\n rowHeader: {\n padding: 0\n },\n rowItem: {\n padding: '6px 12px',\n textAlign: 'center'\n },\n separator: {\n border: 0,\n borderTop: `2.5px solid ${color.primaryLight()}`,\n width: '100%'\n },\n tag: {\n color: color.text(),\n '&:hover': {\n color: color.primaryLight()\n }\n },\n checked: {\n color: `${color.primary()} !important`\n },\n tagDisabled: {\n color: color.disabled(),\n cursor: 'not-allowed !important',\n pointerEvents: 'initial !important',\n opacity: 0.7,\n '&:hover': {\n color: color.disabled()\n }\n },\n table: {\n color: color.text(),\n backgroundColor: color.background(),\n borderCollapse: 'collapse',\n borderSpacing: 0,\n marginBottom: 0\n },\n questionText: {\n textAlign: 'left'\n },\n});\n\nexport default withStyles(styles)(AnswerGrid);\n"],"file":"answer-grid.js"}
1
+ {"version":3,"sources":["../src/answer-grid.jsx"],"names":["AnswerGrid","rowId","answerIndex","event","props","onAnswerChange","choiceMode","answers","newAnswers","i","length","target","checked","rowValue","rowValueIndex","correctAnswers","classes","showCorrect","headers","rows","disabled","view","Tag","Radio","Checkbox","evaluate","controlsContainer","empty","table","map","header","idx","rowHeader","rowItem","questionText","__html","row","separator","title","id","column","correct","answerIsCorrect","tag","tagDisabled","incorrect","answerIsIncorrect","onRowValueChange","React","Component","PropTypes","object","isRequired","bool","func","string","array","styles","theme","marginLeft","marginRight","marginTop","spacing","unit","marginBottom","padding","color","margin","rowContainer","display","alignItems","textAlign","border","borderTop","primaryLight","width","text","primary","cursor","pointerEvents","opacity","backgroundColor","background","borderCollapse","borderSpacing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,U;;;;;;;;;;;;;;;yGAcQ,UAACC,KAAD,EAA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C,IAAAA,WAAW,EAAE;AACXsB,MAAAA,KAAK,EAAEA,gBAAM9C,QAAN,EADI;AAEX0D,MAAAA,MAAM,EAAE,wBAFG;AAGXC,MAAAA,aAAa,EAAE,oBAHJ;AAIXC,MAAAA,OAAO,EAAE,GAJE;AAKX,iBAAW;AACTd,QAAAA,KAAK,EAAEA,gBAAM9C,QAAN;AADE;AALA,KA7CY;AAsDzBQ,IAAAA,KAAK,EAAE;AACLsC,MAAAA,KAAK,EAAEA,gBAAMU,IAAN,EADF;AAELK,MAAAA,eAAe,EAAEf,gBAAMgB,UAAN,EAFZ;AAGLC,MAAAA,cAAc,EAAE,UAHX;AAILC,MAAAA,aAAa,EAAE,CAJV;AAKLpB,MAAAA,YAAY,EAAE;AALT,KAtDkB;AA6DzB9B,IAAAA,YAAY,EAAE;AACZqC,MAAAA,SAAS,EAAE;AADC;AA7DW,GAAZ;AAAA,CAAf;;eAkEe,wBAAWd,MAAX,EAAmBzD,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport Radio from '@material-ui/core/Radio';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport Typography from '@material-ui/core/Typography';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/render-ui';\n\nexport class AnswerGrid extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n correctAnswers: PropTypes.object,\n view: PropTypes.bool.isRequired,\n showCorrect: PropTypes.bool.isRequired,\n disabled: PropTypes.bool.isRequired,\n onAnswerChange: PropTypes.func.isRequired,\n choiceMode: PropTypes.string.isRequired,\n rows: PropTypes.array.isRequired,\n headers: PropTypes.array.isRequired,\n answers: PropTypes.object.isRequired,\n };\n\n onRowValueChange = (rowId, answerIndex) => (event) => {\n const { onAnswerChange, choiceMode, answers } = this.props;\n const newAnswers = { ...answers };\n\n if (choiceMode === 'radio') {\n for (let i = 0; i < newAnswers[rowId].length; i++) {\n newAnswers[rowId][i] = false;\n }\n }\n\n newAnswers[rowId][answerIndex] = event.target.checked;\n\n onAnswerChange(newAnswers);\n };\n\n answerIsCorrect = (rowId, rowValue, rowValueIndex) => {\n const { correctAnswers } = this.props;\n\n return correctAnswers[rowId][rowValueIndex] === rowValue && rowValue === true;\n };\n\n // needs a separate method because what isn't correct isn't necessarily incorrect\n answerIsIncorrect = (rowId, rowValue, rowValueIndex) => {\n const { correctAnswers } = this.props;\n\n return (\n (correctAnswers[rowId][rowValueIndex] === true && rowValue === false) ||\n (correctAnswers[rowId][rowValueIndex] === false && rowValue === true)\n );\n };\n\n render() {\n const { classes, showCorrect, headers, rows, choiceMode, answers, disabled, view } = this.props;\n const Tag = choiceMode === 'radio' ? Radio : Checkbox;\n const evaluate = disabled && !view;\n\n if (!rows || rows.length === 0) {\n return (\n <div className={classes.controlsContainer}>\n <Typography className={classes.empty} component=\"div\">\n There are currently no questions to show.\n </Typography>\n </div>\n );\n }\n\n return (\n <div className={classes.controlsContainer}>\n <table className={classes.table}>\n <colgroup>\n {(headers || []).map((header, idx) => (\n <col key={`col-${idx}`} />\n ))}\n </colgroup>\n\n <thead>\n <tr>\n {(headers || []).map((header, idx) => (\n <th className={classes.rowHeader} key={`th-${idx}`} data-colno={`${idx}`} scope=\"row\">\n <div\n className={cx(classes.rowItem, { [classes.questionText]: idx === 0 })}\n dangerouslySetInnerHTML={{ __html: header }}\n />\n </th>\n ))}\n </tr>\n </thead>\n\n {(rows || []).map((row, idx) => (\n <tbody key={`row-${idx}`} role=\"group\">\n <tr className={classes.separator}>\n <td key={`td-title-${idx}`} data-colno={'0'}>\n <div\n className={cx(classes.rowItem, classes.questionText)}\n dangerouslySetInnerHTML={{ __html: row.title }}\n />\n </td>\n\n {(answers[row.id] || []).map((rowItem, answerIndex) => (\n <td key={`td-${idx}-${answerIndex}`} className={classes.column} data-colno={`${answerIndex + 1}`}>\n <div className={classes.rowItem}>\n <Tag\n className={cx({\n [classes.correct]:\n (showCorrect && rowItem === true) ||\n (evaluate && this.answerIsCorrect(row.id, rowItem, answerIndex)),\n [classes.tag]: true,\n [classes.checked]: rowItem === true && !evaluate,\n [classes.tagDisabled]: disabled,\n [classes.incorrect]: evaluate && this.answerIsIncorrect(row.id, rowItem, answerIndex),\n })}\n disabled={disabled}\n onChange={this.onRowValueChange(row.id, answerIndex)}\n checked={rowItem === true}\n />\n </div>\n </td>\n ))}\n </tr>\n </tbody>\n ))}\n </table>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n controlsContainer: {\n marginLeft: 'auto',\n marginRight: 'auto',\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit,\n },\n column: {\n padding: '5px 0',\n },\n correct: {\n color: `${color.correct()} !important`,\n },\n incorrect: {\n color: `${color.incorrect()} !important`,\n },\n empty: {\n margin: theme.spacing.unit * 2,\n },\n rowContainer: {\n display: 'flex',\n alignItems: 'center',\n },\n rowHeader: {\n padding: 0,\n },\n rowItem: {\n padding: '12px',\n textAlign: 'center',\n },\n separator: {\n border: 0,\n borderTop: `2.5px solid ${color.primaryLight()}`,\n width: '100%',\n },\n tag: {\n padding: '6px',\n color: color.text(),\n '&:hover': {\n color: color.primaryLight(),\n },\n },\n checked: {\n color: `${color.primary()} !important`,\n },\n tagDisabled: {\n color: color.disabled(),\n cursor: 'not-allowed !important',\n pointerEvents: 'initial !important',\n opacity: 0.7,\n '&:hover': {\n color: color.disabled(),\n },\n },\n table: {\n color: color.text(),\n backgroundColor: color.background(),\n borderCollapse: 'collapse',\n borderSpacing: 0,\n marginBottom: 0,\n },\n questionText: {\n textAlign: 'left',\n },\n});\n\nexport default withStyles(styles)(AnswerGrid);\n"],"file":"answer-grid.js"}
package/lib/index.js CHANGED
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "Component", {
11
11
  return _main["default"];
12
12
  }
13
13
  });
14
- exports["default"] = exports.isComplete = void 0;
14
+ exports.isComplete = exports["default"] = void 0;
15
15
 
16
16
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
17
 
@@ -39,7 +39,7 @@ var _get = _interopRequireDefault(require("lodash/get"));
39
39
 
40
40
  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); }; }
41
41
 
42
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
42
+ 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; } }
43
43
 
44
44
  var isComplete = function isComplete(session, model) {
45
45
  var rows = (0, _get["default"])(model, 'config.rows');
@@ -78,6 +78,9 @@ var Match = /*#__PURE__*/function (_HTMLElement) {
78
78
  }
79
79
  }, {
80
80
  key: "session",
81
+ get: function get() {
82
+ return this._session;
83
+ },
81
84
  set: function set(s) {
82
85
  this._session = s;
83
86
 
@@ -89,6 +92,8 @@ var Match = /*#__PURE__*/function (_HTMLElement) {
89
92
  this._session.answers = s.answers;
90
93
  var complete = isComplete(this._session, this._model);
91
94
  this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), complete));
95
+
96
+ this._render();
92
97
  }
93
98
  }, {
94
99
  key: "connectedCallback",
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["isComplete","session","model","rows","ids","map","r","id","reduce","acc","arr","answers","hasChoice","Array","isArray","includes","Match","m","_model","_render","s","_session","complete","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","el","React","createElement","Main","onSessionChange","sessionChanged","bind","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAIO,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD,EAAUC,KAAV,EAAoB;AAC5C,MAAMC,IAAI,GAAG,qBAAID,KAAJ,EAAW,aAAX,CAAb;AACA,MAAME,GAAG,GAAGD,IAAI,CAACE,GAAL,CAAS,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,EAAN;AAAA,GAAV,CAAZ;AACA,SAAOH,GAAG,CAACI,MAAJ,CAAW,UAACC,GAAD,EAAMF,EAAN,EAAa;AAC7B,QAAI,CAACE,GAAL,EAAU;AACR,aAAO,KAAP;AACD;;AACD,QAAMC,GAAG,GAAGT,OAAO,CAACU,OAAR,IAAmBV,OAAO,CAACU,OAAR,CAAgBJ,EAAhB,CAA/B;AACA,QAAMK,SAAS,GAAGC,KAAK,CAACC,OAAN,CAAcJ,GAAd,KAAsBA,GAAG,CAACK,QAAJ,CAAa,IAAb,CAAxC;AACA,WAAOH,SAAS,IAAIH,GAApB;AACD,GAPM,EAOJ,IAPI,CAAP;AAQD,CAXM;;;;IAacO,K;;;;;AACnB,mBAAc;AAAA;AAAA;AAEb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKC,MAAL,GAAcD,CAAd;;AACA,WAAKE,OAAL;AACD;;;SAED,aAAYC,CAAZ,EAAe;AACb,WAAKC,QAAL,GAAgBD,CAAhB;;AACA,WAAKD,OAAL;AACD;;;WAED,wBAAeC,CAAf,EAAkB;AAChB,WAAKC,QAAL,CAAcV,OAAd,GAAwBS,CAAC,CAACT,OAA1B;AACA,UAAMW,QAAQ,GAAGtB,UAAU,CAAC,KAAKqB,QAAN,EAAgB,KAAKH,MAArB,CAA3B;AACA,WAAKK,aAAL,CACE,IAAIC,oCAAJ,CAAwB,KAAKC,OAAL,CAAaC,WAAb,EAAxB,EAAoDJ,QAApD,CADF;AAGD;;;WAED,6BAAoB;AAClB,WAAKH,OAAL;AACD;;;WAED,mBAAU;AAAA;;AACR,UAAI,CAAC,KAAKD,MAAN,IAAgB,CAAC,KAAKG,QAA1B,EAAoC;AAClC;AACD;;AAED,UAAMM,EAAE,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnC5B,QAAAA,KAAK,EAAE,KAAKgB,MADuB;AAEnCjB,QAAAA,OAAO,EAAE,KAAKoB,QAFqB;AAGnCU,QAAAA,eAAe,EAAE,KAAKC,cAAL,CAAoBC,IAApB,CAAyB,IAAzB;AAHkB,OAA1B,CAAX;;AAMAC,2BAASC,MAAT,CAAgBR,EAAhB,EAAoB,IAApB,EAA0B,YAAM;AAC9B,uCAAW,KAAX;AACD,OAFD;AAGD;;;kDAzCgCS,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport Main from './main';\nimport { SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport get from 'lodash/get';\n\nexport { Main as Component };\n\nexport const isComplete = (session, model) => {\n const rows = get(model, 'config.rows');\n const ids = rows.map(r => r.id);\n return ids.reduce((acc, id) => {\n if (!acc) {\n return false;\n }\n const arr = session.answers && session.answers[id];\n const hasChoice = Array.isArray(arr) && arr.includes(true);\n return hasChoice && acc;\n }, true);\n};\n\nexport default class Match extends HTMLElement {\n constructor() {\n super();\n }\n\n set model(m) {\n this._model = m;\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n sessionChanged(s) {\n this._session.answers = s.answers;\n const complete = isComplete(this._session, this._model);\n this.dispatchEvent(\n new SessionChangedEvent(this.tagName.toLowerCase(), complete)\n );\n }\n\n connectedCallback() {\n this._render();\n }\n\n _render() {\n if (!this._model || !this._session) {\n return;\n }\n\n const el = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onSessionChange: this.sessionChanged.bind(this)\n });\n\n ReactDOM.render(el, this, () => {\n renderMath(this);\n });\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["isComplete","session","model","rows","ids","map","r","id","reduce","acc","arr","answers","hasChoice","Array","isArray","includes","Match","m","_model","_render","_session","s","complete","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","el","React","createElement","Main","onSessionChange","sessionChanged","bind","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAIO,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD,EAAUC,KAAV,EAAoB;AAC5C,MAAMC,IAAI,GAAG,qBAAID,KAAJ,EAAW,aAAX,CAAb;AACA,MAAME,GAAG,GAAGD,IAAI,CAACE,GAAL,CAAS,UAACC,CAAD;AAAA,WAAOA,CAAC,CAACC,EAAT;AAAA,GAAT,CAAZ;AACA,SAAOH,GAAG,CAACI,MAAJ,CAAW,UAACC,GAAD,EAAMF,EAAN,EAAa;AAC7B,QAAI,CAACE,GAAL,EAAU;AACR,aAAO,KAAP;AACD;;AACD,QAAMC,GAAG,GAAGT,OAAO,CAACU,OAAR,IAAmBV,OAAO,CAACU,OAAR,CAAgBJ,EAAhB,CAA/B;AACA,QAAMK,SAAS,GAAGC,KAAK,CAACC,OAAN,CAAcJ,GAAd,KAAsBA,GAAG,CAACK,QAAJ,CAAa,IAAb,CAAxC;AACA,WAAOH,SAAS,IAAIH,GAApB;AACD,GAPM,EAOJ,IAPI,CAAP;AAQD,CAXM;;;;IAacO,K;;;;;AACnB,mBAAc;AAAA;AAAA;AAEb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKC,MAAL,GAAcD,CAAd;;AACA,WAAKE,OAAL;AACD;;;SAOD,eAAc;AACZ,aAAO,KAAKC,QAAZ;AACD,K;SAPD,aAAYC,CAAZ,EAAe;AACb,WAAKD,QAAL,GAAgBC,CAAhB;;AACA,WAAKF,OAAL;AACD;;;WAMD,wBAAeE,CAAf,EAAkB;AAChB,WAAKD,QAAL,CAAcT,OAAd,GAAwBU,CAAC,CAACV,OAA1B;AACA,UAAMW,QAAQ,GAAGtB,UAAU,CAAC,KAAKoB,QAAN,EAAgB,KAAKF,MAArB,CAA3B;AAEA,WAAKK,aAAL,CAAmB,IAAIC,oCAAJ,CAAwB,KAAKC,OAAL,CAAaC,WAAb,EAAxB,EAAoDJ,QAApD,CAAnB;;AAEA,WAAKH,OAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;WAED,mBAAU;AAAA;;AACR,UAAI,CAAC,KAAKD,MAAN,IAAgB,CAAC,KAAKE,QAA1B,EAAoC;AAClC;AACD;;AAED,UAAMO,EAAE,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnC5B,QAAAA,KAAK,EAAE,KAAKgB,MADuB;AAEnCjB,QAAAA,OAAO,EAAE,KAAKmB,QAFqB;AAGnCW,QAAAA,eAAe,EAAE,KAAKC,cAAL,CAAoBC,IAApB,CAAyB,IAAzB;AAHkB,OAA1B,CAAX;;AAMAC,2BAASC,MAAT,CAAgBR,EAAhB,EAAoB,IAApB,EAA0B,YAAM;AAC9B,uCAAW,KAAX;AACD,OAFD;AAGD;;;kDA9CgCS,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport Main from './main';\nimport { SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport get from 'lodash/get';\n\nexport { Main as Component };\n\nexport const isComplete = (session, model) => {\n const rows = get(model, 'config.rows');\n const ids = rows.map((r) => r.id);\n return ids.reduce((acc, id) => {\n if (!acc) {\n return false;\n }\n const arr = session.answers && session.answers[id];\n const hasChoice = Array.isArray(arr) && arr.includes(true);\n return hasChoice && acc;\n }, true);\n};\n\nexport default class Match extends HTMLElement {\n constructor() {\n super();\n }\n\n set model(m) {\n this._model = m;\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n sessionChanged(s) {\n this._session.answers = s.answers;\n const complete = isComplete(this._session, this._model);\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), complete));\n\n this._render();\n }\n\n connectedCallback() {\n this._render();\n }\n\n _render() {\n if (!this._model || !this._session) {\n return;\n }\n\n const el = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onSessionChange: this.sessionChanged.bind(this),\n });\n\n ReactDOM.render(el, this, () => {\n renderMath(this);\n });\n }\n}\n"],"file":"index.js"}
package/lib/main.js CHANGED
@@ -33,13 +33,13 @@ var _answerGrid = _interopRequireDefault(require("./answer-grid"));
33
33
 
34
34
  var _styles = require("@material-ui/core/styles");
35
35
 
36
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
36
+ 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; }
37
37
 
38
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
38
+ 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; }
39
39
 
40
40
  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); }; }
41
41
 
42
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
42
+ 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; } }
43
43
 
44
44
  var Main = /*#__PURE__*/function (_React$Component) {
45
45
  (0, _inherits2["default"])(Main, _React$Component);
@@ -136,6 +136,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
136
136
  var _this$state = this.state,
137
137
  showCorrect = _this$state.showCorrect,
138
138
  session = _this$state.session;
139
+ var _model$correctness = model.correctness,
140
+ correctness = _model$correctness === void 0 ? {} : _model$correctness;
141
+ var showCorrectAnswerToggle = correctness.correctness && correctness.correctness !== 'correct';
139
142
  return /*#__PURE__*/_react["default"].createElement("div", {
140
143
  className: classes.mainContainer
141
144
  }, model.teacherInstructions && (0, _renderUi.hasText)(model.teacherInstructions) && /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
@@ -144,25 +147,20 @@ var Main = /*#__PURE__*/function (_React$Component) {
144
147
  visible: 'Hide Teacher Instructions'
145
148
  },
146
149
  className: classes.collapsible
147
- }, /*#__PURE__*/_react["default"].createElement("div", {
148
- dangerouslySetInnerHTML: {
149
- __html: model.teacherInstructions
150
- }
150
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
151
+ prompt: model.teacherInstructions
151
152
  })), model.prompt && /*#__PURE__*/_react["default"].createElement("div", {
152
- className: classes.prompt,
153
- dangerouslySetInnerHTML: {
154
- __html: model.prompt
155
- }
156
- }), /*#__PURE__*/_react["default"].createElement("div", {
153
+ className: classes.prompt
154
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
155
+ prompt: model.prompt
156
+ })), /*#__PURE__*/_react["default"].createElement("div", {
157
157
  className: classes.main
158
158
  }, /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
159
- className: classes.toggle,
160
- show: model.correctness && model.correctness.correctness && model.correctness.correctness !== 'correct',
159
+ show: showCorrectAnswerToggle,
161
160
  toggled: showCorrect,
162
161
  onToggle: this.toggleShowCorrect
163
- }), /*#__PURE__*/_react["default"].createElement(_answerGrid["default"], {
162
+ }), showCorrectAnswerToggle && /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_answerGrid["default"], {
164
163
  showCorrect: showCorrect,
165
- allowFeedback: model.allowFeedback,
166
164
  correctAnswers: model.correctResponse,
167
165
  disabled: model.disabled,
168
166
  view: model.view,
@@ -177,10 +175,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
177
175
  visible: 'Hide Rationale'
178
176
  },
179
177
  className: classes.collapsible
180
- }, /*#__PURE__*/_react["default"].createElement("div", {
181
- dangerouslySetInnerHTML: {
182
- __html: model.rationale
183
- }
178
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
179
+ prompt: model.rationale
184
180
  })), model.feedback && /*#__PURE__*/_react["default"].createElement(_renderUi.Feedback, {
185
181
  correctness: model.correctness.correctness,
186
182
  feedback: model.feedback