@pie-element/match 4.7.2 → 4.7.3-next.1016

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 (42) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/configure/CHANGELOG.md +170 -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 -35
  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 +49 -10
  10. package/configure/lib/configure.js.map +1 -1
  11. package/configure/lib/defaults.js +19 -1
  12. package/configure/lib/defaults.js.map +1 -1
  13. package/configure/lib/general-config-block.js +81 -31
  14. package/configure/lib/general-config-block.js.map +1 -1
  15. package/configure/lib/index.js +4 -4
  16. package/configure/lib/index.js.map +1 -1
  17. package/configure/lib/row.js +109 -21
  18. package/configure/lib/row.js.map +1 -1
  19. package/configure/package.json +4 -4
  20. package/configure/utils.js +11 -0
  21. package/controller/CHANGELOG.md +16 -0
  22. package/controller/lib/index.js +37 -3
  23. package/controller/lib/index.js.map +1 -1
  24. package/controller/package.json +1 -1
  25. package/docs/config-schema.json +94 -0
  26. package/docs/config-schema.json.md +73 -1
  27. package/docs/demo/generate.js +1 -0
  28. package/docs/pie-schema.json +42 -0
  29. package/docs/pie-schema.json.md +35 -0
  30. package/lib/answer-grid.js +9 -10
  31. package/lib/answer-grid.js.map +1 -1
  32. package/lib/index.js +7 -2
  33. package/lib/index.js.map +1 -1
  34. package/lib/main.js +11 -17
  35. package/lib/main.js.map +1 -1
  36. package/package.json +5 -5
  37. package/module/configure.js +0 -1776
  38. package/module/controller.js +0 -21219
  39. package/module/demo.js +0 -75
  40. package/module/element.js +0 -591
  41. package/module/index.html +0 -16
  42. package/module/manifest.json +0 -10
@@ -131,6 +131,22 @@
131
131
  }
132
132
  }
133
133
  },
134
+ "spellCheck": {
135
+ "title": "ConfigureProp",
136
+ "type": "object",
137
+ "properties": {
138
+ "settings": {
139
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
140
+ "type": "boolean",
141
+ "title": "settings"
142
+ },
143
+ "label": {
144
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
145
+ "type": "string",
146
+ "title": "label"
147
+ }
148
+ }
149
+ },
134
150
  "rationale": {
135
151
  "title": "ConfigureProp",
136
152
  "type": "object",
@@ -195,6 +211,58 @@
195
211
  }
196
212
  }
197
213
  },
214
+ "maxImageWidth": {
215
+ "title": "ConfigureMaxImageDimensionsProp",
216
+ "type": "object",
217
+ "properties": {
218
+ "teacherInstructions": {
219
+ "description": "Indicates the max dimension for images in teacher instructions",
220
+ "type": "number",
221
+ "title": "teacherInstructions"
222
+ },
223
+ "prompt": {
224
+ "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",
225
+ "type": "number",
226
+ "title": "prompt"
227
+ },
228
+ "rationale": {
229
+ "description": "Indicates the max dimension for images in rationale",
230
+ "type": "number",
231
+ "title": "rationale"
232
+ },
233
+ "rowTitles": {
234
+ "description": "Indicates the max dimension for images in row labels",
235
+ "type": "number",
236
+ "title": "rowTitles"
237
+ }
238
+ }
239
+ },
240
+ "maxImageHeight": {
241
+ "title": "ConfigureMaxImageDimensionsProp",
242
+ "type": "object",
243
+ "properties": {
244
+ "teacherInstructions": {
245
+ "description": "Indicates the max dimension for images in teacher instructions",
246
+ "type": "number",
247
+ "title": "teacherInstructions"
248
+ },
249
+ "prompt": {
250
+ "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",
251
+ "type": "number",
252
+ "title": "prompt"
253
+ },
254
+ "rationale": {
255
+ "description": "Indicates the max dimension for images in rationale",
256
+ "type": "number",
257
+ "title": "rationale"
258
+ },
259
+ "rowTitles": {
260
+ "description": "Indicates the max dimension for images in row labels",
261
+ "type": "number",
262
+ "title": "rowTitles"
263
+ }
264
+ }
265
+ },
198
266
  "showPrompt": {
199
267
  "description": "Determines whether prompt field will be displayed or not",
200
268
  "default": true,
@@ -230,6 +298,32 @@
230
298
  "title": "label"
231
299
  }
232
300
  }
301
+ },
302
+ "ConfigureMaxImageDimensionsProp": {
303
+ "title": "ConfigureMaxImageDimensionsProp",
304
+ "type": "object",
305
+ "properties": {
306
+ "teacherInstructions": {
307
+ "description": "Indicates the max dimension for images in teacher instructions",
308
+ "type": "number",
309
+ "title": "teacherInstructions"
310
+ },
311
+ "prompt": {
312
+ "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",
313
+ "type": "number",
314
+ "title": "prompt"
315
+ },
316
+ "rationale": {
317
+ "description": "Indicates the max dimension for images in rationale",
318
+ "type": "number",
319
+ "title": "rationale"
320
+ },
321
+ "rowTitles": {
322
+ "description": "Indicates the max dimension for images in row labels",
323
+ "type": "number",
324
+ "title": "rowTitles"
325
+ }
326
+ }
233
327
  }
234
328
  },
235
329
  "$schema": "http://json-schema.org/draft-07/schema#"
@@ -98,6 +98,18 @@ 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
+ # `spellCheck` (object)
102
+
103
+ Properties of the `spellCheck` object:
104
+
105
+ ## `settings` (boolean)
106
+
107
+ Indicates if the item has to be displayed in the Settings Panel
108
+
109
+ ## `label` (string)
110
+
111
+ Indicates the label for the item that has to be displayed in the Settings Panel
112
+
101
113
  # `rationale` (object)
102
114
 
103
115
  Properties of the `rationale` object:
@@ -146,6 +158,46 @@ Indicates if the item has to be displayed in the Settings Panel
146
158
 
147
159
  Indicates the label for the item that has to be displayed in the Settings Panel
148
160
 
161
+ # `maxImageWidth` (object)
162
+
163
+ Properties of the `maxImageWidth` object:
164
+
165
+ ## `teacherInstructions` (number)
166
+
167
+ Indicates the max dimension for images in teacher instructions
168
+
169
+ ## `prompt` (number)
170
+
171
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
172
+
173
+ ## `rationale` (number)
174
+
175
+ Indicates the max dimension for images in rationale
176
+
177
+ ## `rowTitles` (number)
178
+
179
+ Indicates the max dimension for images in row labels
180
+
181
+ # `maxImageHeight` (object)
182
+
183
+ Properties of the `maxImageHeight` object:
184
+
185
+ ## `teacherInstructions` (number)
186
+
187
+ Indicates the max dimension for images in teacher instructions
188
+
189
+ ## `prompt` (number)
190
+
191
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
192
+
193
+ ## `rationale` (number)
194
+
195
+ Indicates the max dimension for images in rationale
196
+
197
+ ## `rowTitles` (number)
198
+
199
+ Indicates the max dimension for images in row labels
200
+
149
201
  # `showPrompt` (boolean)
150
202
 
151
203
  Determines whether prompt field will be displayed or not
@@ -180,4 +232,24 @@ Indicates if the item has to be displayed in the Settings Panel
180
232
 
181
233
  ### `label` (string)
182
234
 
183
- Indicates the label for the item that has to be displayed in the Settings Panel
235
+ Indicates the label for the item that has to be displayed in the Settings Panel
236
+
237
+ ## `ConfigureMaxImageDimensionsProp` (object)
238
+
239
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
240
+
241
+ ### `teacherInstructions` (number)
242
+
243
+ Indicates the max dimension for images in teacher instructions
244
+
245
+ ### `prompt` (number)
246
+
247
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
248
+
249
+ ### `rationale` (number)
250
+
251
+ Indicates the max dimension for images in rationale
252
+
253
+ ### `rowTitles` (number)
254
+
255
+ Indicates the max dimension for images in row labels
@@ -45,4 +45,5 @@ exports.model = (id, element) => ({
45
45
  ],
46
46
  promptEnabled: true,
47
47
  prompt: 'Select correct answers.',
48
+ toolbarEditorPosition: 'bottom'
48
49
  });
@@ -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,16 @@
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
+ },
301
316
  "id": {
302
317
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
303
318
  "type": "string",
@@ -319,6 +334,7 @@
319
334
  "rationale",
320
335
  "rationaleEnabled",
321
336
  "rows",
337
+ "spellCheckEnabled",
322
338
  "studentInstructionsEnabled",
323
339
  "teacherInstructionsEnabled"
324
340
  ],
@@ -339,6 +355,32 @@
339
355
  }
340
356
  }
341
357
  },
358
+ "ConfigureMaxImageDimensionsProp": {
359
+ "title": "ConfigureMaxImageDimensionsProp",
360
+ "type": "object",
361
+ "properties": {
362
+ "teacherInstructions": {
363
+ "description": "Indicates the max dimension for images in teacher instructions",
364
+ "type": "number",
365
+ "title": "teacherInstructions"
366
+ },
367
+ "prompt": {
368
+ "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",
369
+ "type": "number",
370
+ "title": "prompt"
371
+ },
372
+ "rationale": {
373
+ "description": "Indicates the max dimension for images in rationale",
374
+ "type": "number",
375
+ "title": "rationale"
376
+ },
377
+ "rowTitles": {
378
+ "description": "Indicates the max dimension for images in row labels",
379
+ "type": "number",
380
+ "title": "rowTitles"
381
+ }
382
+ }
383
+ },
342
384
  "ComplexFeedbackType": {
343
385
  "title": "ComplexFeedbackType",
344
386
  "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,17 @@ 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
+
119
134
  # `id` (string, required)
120
135
 
121
136
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -142,6 +157,26 @@ Indicates if the item has to be displayed in the Settings Panel
142
157
 
143
158
  Indicates the label for the item that has to be displayed in the Settings Panel
144
159
 
160
+ ## `ConfigureMaxImageDimensionsProp` (object)
161
+
162
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
163
+
164
+ ### `teacherInstructions` (number)
165
+
166
+ Indicates the max dimension for images in teacher instructions
167
+
168
+ ### `prompt` (number)
169
+
170
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
171
+
172
+ ### `rationale` (number)
173
+
174
+ Indicates the max dimension for images in rationale
175
+
176
+ ### `rowTitles` (number)
177
+
178
+ Indicates the max dimension for images in row labels
179
+
145
180
  ## `ComplexFeedbackType` (object)
146
181
 
147
182
  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,
@@ -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,CAAkBS,MAAtC,EAA8CD,CAAC,EAA/C,EAAmD;AACjDD,YAAAA,UAAU,CA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,MAAAA,YAAY,EAAE;AALT,KAtDgB;AA6DvB9B,IAAAA,YAAY,EAAE;AACZqC,MAAAA,SAAS,EAAE;AADC;AA7DS,GAAL;AAAA,CAApB;;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 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: '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"}
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,EAAQC,WAAR;AAAA,aAAwB,UA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,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,KA7CU;AAsDvBQ,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,KAtDgB;AA6DvB9B,IAAAA,YAAY,EAAE;AACZqC,MAAAA,SAAS,EAAE;AADC;AA7DS,GAAL;AAAA,CAApB;;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 correctAnswers[rowId][rowValueIndex] === true && rowValue === false\n || correctAnswers[rowId][rowValueIndex] === false && rowValue === true;\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 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]: (\n (showCorrect && rowItem === true) ||\n (evaluate && this.answerIsCorrect(row.id, rowItem, answerIndex))\n ),\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","onSessionCh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ApD,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,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;;;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,CACE,IAAIC,oCAAJ,CAAwB,KAAKC,OAAL,CAAaC,WAAb,EAAxB,EAAoDJ,QAApD,CADF;;AAIA,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;;;kDAhDgCS,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(\n new SessionChangedEvent(this.tagName.toLowerCase(), complete)\n );\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);
@@ -147,16 +147,13 @@ var Main = /*#__PURE__*/function (_React$Component) {
147
147
  visible: 'Hide Teacher Instructions'
148
148
  },
149
149
  className: classes.collapsible
150
- }, /*#__PURE__*/_react["default"].createElement("div", {
151
- dangerouslySetInnerHTML: {
152
- __html: model.teacherInstructions
153
- }
150
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
151
+ prompt: model.teacherInstructions
154
152
  })), model.prompt && /*#__PURE__*/_react["default"].createElement("div", {
155
- className: classes.prompt,
156
- dangerouslySetInnerHTML: {
157
- __html: model.prompt
158
- }
159
- }), /*#__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", {
160
157
  className: classes.main
161
158
  }, /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
162
159
  show: showCorrectAnswerToggle,
@@ -164,7 +161,6 @@ var Main = /*#__PURE__*/function (_React$Component) {
164
161
  onToggle: this.toggleShowCorrect
165
162
  }), showCorrectAnswerToggle && /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_answerGrid["default"], {
166
163
  showCorrect: showCorrect,
167
- allowFeedback: model.allowFeedback,
168
164
  correctAnswers: model.correctResponse,
169
165
  disabled: model.disabled,
170
166
  view: model.view,
@@ -179,10 +175,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
179
175
  visible: 'Hide Rationale'
180
176
  },
181
177
  className: classes.collapsible
182
- }, /*#__PURE__*/_react["default"].createElement("div", {
183
- dangerouslySetInnerHTML: {
184
- __html: model.rationale
185
- }
178
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
179
+ prompt: model.rationale
186
180
  })), model.feedback && /*#__PURE__*/_react["default"].createElement(_renderUi.Feedback, {
187
181
  correctness: model.correctness.correctness,
188
182
  feedback: model.feedback