@pie-element/multiple-choice 6.2.0 → 6.2.1-beta.1443

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 (49) hide show
  1. package/CHANGELOG.md +346 -0
  2. package/README.md +1 -1
  3. package/configure/CHANGELOG.md +321 -0
  4. package/configure/lib/defaults.js +22 -1
  5. package/configure/lib/defaults.js.map +1 -1
  6. package/configure/lib/index.js +16 -2
  7. package/configure/lib/index.js.map +1 -1
  8. package/configure/lib/main.js +204 -159
  9. package/configure/lib/main.js.map +1 -1
  10. package/configure/lib/utils.js +18 -0
  11. package/configure/lib/utils.js.map +1 -0
  12. package/configure/package.json +5 -5
  13. package/controller/CHANGELOG.md +35 -0
  14. package/controller/lib/defaults.js.map +1 -1
  15. package/controller/lib/index.js +61 -3
  16. package/controller/lib/index.js.map +1 -1
  17. package/controller/lib/utils.js.map +1 -1
  18. package/controller/package.json +2 -2
  19. package/docs/config-schema.json +115 -0
  20. package/docs/config-schema.json.md +89 -1
  21. package/docs/demo/config.js +2 -2
  22. package/docs/demo/generate.js +13 -11
  23. package/docs/demo/index.html +1 -1
  24. package/docs/demo/session.js +1 -1
  25. package/docs/pie-schema.json +38 -0
  26. package/docs/pie-schema.json.md +28 -0
  27. package/lib/choice-input.js +17 -10
  28. package/lib/choice-input.js.map +1 -1
  29. package/lib/choice.js +14 -3
  30. package/lib/choice.js.map +1 -1
  31. package/lib/index.js +1 -1
  32. package/lib/index.js.map +1 -1
  33. package/lib/main.js +4 -1
  34. package/lib/main.js.map +1 -1
  35. package/lib/multiple-choice.js +12 -3
  36. package/lib/multiple-choice.js.map +1 -1
  37. package/lib/print.js +2 -0
  38. package/lib/print.js.map +1 -1
  39. package/lib/session-updater.js.map +1 -1
  40. package/package.json +6 -6
  41. package/module/configure.js +0 -771
  42. package/module/controller.js +0 -20641
  43. package/module/demo.js +0 -77
  44. package/module/element.js +0 -2004
  45. package/module/index.html +0 -21
  46. package/module/manifest.json +0 -14
  47. package/module/print-demo.js +0 -115
  48. package/module/print.html +0 -18
  49. package/module/print.js +0 -1966
@@ -84,6 +84,18 @@ Indicates if the item has to be displayed in the Settings Panel
84
84
 
85
85
  Indicates the label for the item that has to be displayed in the Settings Panel
86
86
 
87
+ # `spellCheck` (object)
88
+
89
+ Properties of the `spellCheck` object:
90
+
91
+ ## `settings` (boolean)
92
+
93
+ Indicates if the item has to be displayed in the Settings Panel
94
+
95
+ ## `label` (string)
96
+
97
+ Indicates the label for the item that has to be displayed in the Settings Panel
98
+
87
99
  # `choicesLayout` (object)
88
100
 
89
101
  Properties of the `choicesLayout` object:
@@ -156,6 +168,10 @@ Indicates if the item has to be displayed in the Settings Panel
156
168
 
157
169
  Indicates the label for the item that has to be displayed in the Settings Panel
158
170
 
171
+ # `settingsPanelDisabled` (boolean)
172
+
173
+ Indicates if the settings panel is not available
174
+
159
175
  # `studentInstructions` (object)
160
176
 
161
177
  Properties of the `studentInstructions` object:
@@ -217,6 +233,58 @@ Minimum number of answer choices
217
233
 
218
234
  Maximum number of answer choices
219
235
 
236
+ # `maxImageWidth` (object)
237
+
238
+ Properties of the `maxImageWidth` object:
239
+
240
+ ## `teacherInstructions` (number)
241
+
242
+ Indicates the max dimension for images in teacher instructions
243
+
244
+ ## `prompt` (number)
245
+
246
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
247
+
248
+ ## `rationale` (number)
249
+
250
+ Indicates the max dimension for images in rationale
251
+
252
+ ## `choices` (number)
253
+
254
+ Indicates the max dimension for images in choices
255
+
256
+ # `maxImageHeight` (object)
257
+
258
+ Properties of the `maxImageHeight` object:
259
+
260
+ ## `teacherInstructions` (number)
261
+
262
+ Indicates the max dimension for images in teacher instructions
263
+
264
+ ## `prompt` (number)
265
+
266
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
267
+
268
+ ## `rationale` (number)
269
+
270
+ Indicates the max dimension for images in rationale
271
+
272
+ ## `choices` (number)
273
+
274
+ Indicates the max dimension for images in choices
275
+
276
+ # `withRubric` (object)
277
+
278
+ Properties of the `withRubric` object:
279
+
280
+ ## `settings` (boolean)
281
+
282
+ Indicates if the item has to be displayed in the Settings Panel
283
+
284
+ ## `label` (string)
285
+
286
+ Indicates the label for the item that has to be displayed in the Settings Panel
287
+
220
288
  # `showPrompt` (boolean)
221
289
 
222
290
  Determines whether prompt field will be displayed or not
@@ -262,4 +330,24 @@ Indicates the label for the item that has to be displayed in the Settings Panel
262
330
  ### `enabled` (boolean)
263
331
 
264
332
  Indicates the value of the item if it affects config-ui
265
- (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
333
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
334
+
335
+ ## `ConfigureMaxImageDimensionsProp` (object)
336
+
337
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
338
+
339
+ ### `teacherInstructions` (number)
340
+
341
+ Indicates the max dimension for images in teacher instructions
342
+
343
+ ### `prompt` (number)
344
+
345
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
346
+
347
+ ### `rationale` (number)
348
+
349
+ Indicates the max dimension for images in rationale
350
+
351
+ ### `choices` (number)
352
+
353
+ Indicates the max dimension for images in choices
@@ -2,7 +2,7 @@ const { model } = require('./generate');
2
2
 
3
3
  module.exports = {
4
4
  elements: {
5
- 'multiple-choice': '../..'
5
+ 'multiple-choice': '../..',
6
6
  },
7
- models: [model('1', 'multiple-choice')]
7
+ models: [model('1', 'multiple-choice')],
8
8
  };
@@ -10,29 +10,29 @@ exports.model = (id, element) => ({
10
10
  label: 'Sweden',
11
11
  feedback: {
12
12
  type: 'none',
13
- value: ''
13
+ value: '',
14
14
  },
15
- accessibility: 'sweden'
15
+ accessibility: 'sweden',
16
16
  },
17
17
  {
18
18
  value: 'iceland',
19
19
  label: 'Iceland',
20
20
  feedback: {
21
21
  type: 'none',
22
- value: ''
22
+ value: '',
23
23
  },
24
24
  rationale: 'Rationale for Iceland',
25
- accessibility: 'iceland'
25
+ accessibility: 'iceland',
26
26
  },
27
27
  {
28
28
  value: 'norway',
29
29
  label: 'Norway',
30
30
  feedback: {
31
31
  type: 'none',
32
- value: ''
32
+ value: '',
33
33
  },
34
34
  rationale: 'Rationale for Norway',
35
- accessibility: 'norway'
35
+ accessibility: 'norway',
36
36
  },
37
37
  {
38
38
  correct: true,
@@ -40,13 +40,15 @@ exports.model = (id, element) => ({
40
40
  label: 'Finland',
41
41
  feedback: {
42
42
  type: 'none',
43
- value: ''
43
+ value: '',
44
44
  },
45
45
  rationale: 'Rationale for Finland',
46
- accessibility: 'finland'
47
- }
46
+ accessibility: 'finland',
47
+ },
48
48
  ],
49
- prompt: 'Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>',
49
+ prompt:
50
+ 'Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>',
50
51
  promptEnabled: true,
51
- toolbarEditorPosition: 'bottom'
52
+ toolbarEditorPosition: 'bottom',
53
+ rubricEnabled: false,
52
54
  });
@@ -1 +1 @@
1
- <multiple-choice pie-id="1"> </multiple-choice>
1
+ <multiple-choice pie-id="1"> </multiple-choice>
@@ -3,5 +3,5 @@ module.exports = [
3
3
  id: '1',
4
4
  element: 'multiple-choice',
5
5
  // value: ['iceland', 'norway']
6
- }
6
+ },
7
7
  ];
@@ -163,6 +163,11 @@
163
163
  "type": "boolean",
164
164
  "title": "rationaleEnabled"
165
165
  },
166
+ "spellCheckEnabled": {
167
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
168
+ "type": "boolean",
169
+ "title": "spellCheckEnabled"
170
+ },
166
171
  "studentInstructionsEnabled": {
167
172
  "description": "Indicates if Student Instructions are enabled",
168
173
  "type": "boolean",
@@ -178,6 +183,11 @@
178
183
  "type": "boolean",
179
184
  "title": "accessibilityLabelsEnabled"
180
185
  },
186
+ "rubricEnabled": {
187
+ "description": "Indicates if Rubric is enabled",
188
+ "type": "boolean",
189
+ "title": "rubricEnabled"
190
+ },
181
191
  "id": {
182
192
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
183
193
  "type": "string",
@@ -196,6 +206,8 @@
196
206
  "feedbackEnabled",
197
207
  "id",
198
208
  "rationaleEnabled",
209
+ "rubricEnabled",
210
+ "spellCheckEnabled",
199
211
  "studentInstructionsEnabled",
200
212
  "teacherInstructionsEnabled"
201
213
  ],
@@ -237,6 +249,32 @@
237
249
  }
238
250
  }
239
251
  },
252
+ "ConfigureMaxImageDimensionsProp": {
253
+ "title": "ConfigureMaxImageDimensionsProp",
254
+ "type": "object",
255
+ "properties": {
256
+ "teacherInstructions": {
257
+ "description": "Indicates the max dimension for images in teacher instructions",
258
+ "type": "number",
259
+ "title": "teacherInstructions"
260
+ },
261
+ "prompt": {
262
+ "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",
263
+ "type": "number",
264
+ "title": "prompt"
265
+ },
266
+ "rationale": {
267
+ "description": "Indicates the max dimension for images in rationale",
268
+ "type": "number",
269
+ "title": "rationale"
270
+ },
271
+ "choices": {
272
+ "description": "Indicates the max dimension for images in choices",
273
+ "type": "number",
274
+ "title": "choices"
275
+ }
276
+ }
277
+ },
240
278
  "Choice": {
241
279
  "title": "Choice",
242
280
  "type": "object",
@@ -142,6 +142,10 @@ Indicates if feedback is enabled
142
142
 
143
143
  Indicates if Rationale are enabled
144
144
 
145
+ # `spellCheckEnabled` (boolean, required)
146
+
147
+ Indicates if spellcheck is enabled for the author. Default value is true
148
+
145
149
  # `studentInstructionsEnabled` (boolean, required)
146
150
 
147
151
  Indicates if Student Instructions are enabled
@@ -154,6 +158,10 @@ Indicates if Teacher Instructions are enabled
154
158
 
155
159
  Indicates if Accessibility Labels are enabled
156
160
 
161
+ # `rubricEnabled` (boolean, required)
162
+
163
+ Indicates if Rubric is enabled
164
+
157
165
  # `id` (string, required)
158
166
 
159
167
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -197,6 +205,26 @@ Indicates the label for the item that has to be displayed in the Settings Panel
197
205
  Indicates the value of the item if it affects config-ui
198
206
  (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
199
207
 
208
+ ## `ConfigureMaxImageDimensionsProp` (object)
209
+
210
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
211
+
212
+ ### `teacherInstructions` (number)
213
+
214
+ Indicates the max dimension for images in teacher instructions
215
+
216
+ ### `prompt` (number)
217
+
218
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
219
+
220
+ ### `rationale` (number)
221
+
222
+ Indicates the max dimension for images in rationale
223
+
224
+ ### `choices` (number)
225
+
226
+ Indicates the max dimension for images in choices
227
+
200
228
  ## `Choice` (object)
201
229
 
202
230
  Properties of the `Choice` object:
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.ChoiceInput = exports.StyledRadio = exports.StyledCheckbox = exports.StyledFormControlLabel = void 0;
8
+ exports["default"] = exports.StyledRadio = exports.StyledFormControlLabel = exports.StyledCheckbox = exports.ChoiceInput = void 0;
9
9
 
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
 
@@ -19,10 +19,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
19
19
 
20
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
21
 
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
22
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
25
23
 
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
26
  var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
27
27
 
28
28
  var _react = _interopRequireDefault(require("react"));
@@ -45,9 +45,11 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
45
45
 
46
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
- 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; }
48
+ 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; }
49
49
 
50
- 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; }
50
+ 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; }
51
+
52
+ var CLASS_NAME = 'multiple-choice-component';
51
53
 
52
54
  var styleSheet = function styleSheet() {
53
55
  return {
@@ -64,7 +66,10 @@ var styleSheet = function styleSheet() {
64
66
  '& label': {
65
67
  color: _renderUi.color.text()
66
68
  }
67
- }
69
+ },
70
+ horizontalLayout: (0, _defineProperty2["default"])({}, "& .".concat(CLASS_NAME), {
71
+ paddingRight: '8px'
72
+ })
68
73
  };
69
74
  };
70
75
 
@@ -85,7 +90,6 @@ var StyledFormControlLabel = (0, _styles.withStyles)(formStyleSheet, {
85
90
  }));
86
91
  });
87
92
  exports.StyledFormControlLabel = StyledFormControlLabel;
88
- var CLASS_NAME = 'multiple-choice-component';
89
93
 
90
94
  var colorStyle = function colorStyle(varName, fallback) {
91
95
  return (0, _defineProperty2["default"])({}, "&.".concat(CLASS_NAME), {
@@ -222,9 +226,11 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
222
226
  rationale = _this$props.rationale,
223
227
  accessibility = _this$props.accessibility,
224
228
  hideTick = _this$props.hideTick,
225
- isEvaluateMode = _this$props.isEvaluateMode;
229
+ isEvaluateMode = _this$props.isEvaluateMode,
230
+ choicesLayout = _this$props.choicesLayout;
226
231
  var Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
227
232
  var classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';
233
+ var holderClassNames = (0, _classnames["default"])(classes.checkboxHolder, (0, _defineProperty2["default"])({}, classes.horizontalLayout, choicesLayout === 'horizontal'));
228
234
  return /*#__PURE__*/_react["default"].createElement("div", {
229
235
  className: (0, _classnames["default"])(className, 'corespring-' + classSuffix, 'choice-input')
230
236
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -232,7 +238,7 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
232
238
  }, !hideTick && isEvaluateMode && /*#__PURE__*/_react["default"].createElement(_feedbackTick["default"], {
233
239
  correctness: correctness
234
240
  }), /*#__PURE__*/_react["default"].createElement("div", {
235
- className: (0, _classnames["default"])(classes.checkboxHolder, 'checkbox-holder')
241
+ className: (0, _classnames["default"])(holderClassNames, 'checkbox-holder')
236
242
  }, /*#__PURE__*/_react["default"].createElement(StyledFormControlLabel, {
237
243
  disabled: disabled,
238
244
  label: displayKey ? displayKey + '. ' : '',
@@ -276,7 +282,8 @@ exports.ChoiceInput = ChoiceInput;
276
282
  classes: _propTypes["default"].object,
277
283
  className: _propTypes["default"].string,
278
284
  hideTick: _propTypes["default"].bool,
279
- isEvaluateMode: _propTypes["default"].bool
285
+ isEvaluateMode: _propTypes["default"].bool,
286
+ choicesLayout: _propTypes["default"].oneOf(['vertical', 'grid', 'horizontal'])
280
287
  });
281
288
  (0, _defineProperty2["default"])(ChoiceInput, "defaultProps", {
282
289
  rationale: null,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/choice-input.jsx"],"names":["styleSheet","row","display","alignItems","backgroundColor","color","background","checkboxHolder","flex","text","formStyleSheet","label","StyledFormControlLabel","name","props","classes","CLASS_NAME","colorStyle","varName","fallback","inputStyles","correct","disabled","incorrect","root","primaryLight","checked","primary","opacity","cursor","pointerEvents","StyledCheckbox","correctness","onChange","accessibility","key","k","resolved","miniProps","StyledRadio","ChoiceInput","onToggleChoice","bind","value","selected","choiceMode","displayKey","feedback","className","rationale","hideTick","isEvaluateMode","Tag","classSuffix","React","Component","PropTypes","oneOf","string","isRequired","bool","func","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa;AAAA,SAAO;AACxBC,IAAAA,GAAG,EAAE;AACHC,MAAAA,OAAO,EAAE,MADN;AAEHC,MAAAA,UAAU,EAAE,QAFT;AAGHC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN;AAHd,KADmB;AAMxBC,IAAAA,cAAc,EAAE;AACdL,MAAAA,OAAO,EAAE,MADK;AAEdC,MAAAA,UAAU,EAAE,QAFE;AAGdC,MAAAA,eAAe,E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AEW,sBAAUC,KAAV,CAAgB,CAAC,OAAD,EAAU,UAAV,CAAhB,CADK;AAEjBX,EAAAA,UAAU,EAAEU,sBAAUE,MAAV,CAAiBC,UAFZ;AAGjBjC,EAAAA,OAAO,EAAE8B,sBAAUI,IAAV,CAAeD,UAHP;AAIjB3B,EAAAA,WAAW,EAAEwB,sBAAUE,MAJN;AAKjBpC,EAAAA,QAAQ,EAAEkC,sBAAUI,IAAV,CAAeD,UALR;AAMjBZ,EAAAA,QAAQ,EAAES,sBAAUE,MANH;AAOjB/C,EAAAA,KAAK,EAAE6C,sBAAUE,MAAV,CAAiBC,UAPP;AAQjBV,EAAAA,SAAS,EAAEO,sBAAUE,MARJ;AASjBxB,EAAAA,aAAa,EAAEsB,sBAAUE,MATR;AAUjBzB,EAAAA,QAAQ,EAAEuB,sBAAUK,IAAV,CAAeF,UAVR;AAWjBhB,EAAAA,KAAK,EAAEa,sBAAUE,MAAV,CAAiBC,UAXP;AAYjB5C,EAAAA,OAAO,EAAEyC,sBAAUM,MAZF;AAajBd,EAAAA,SAAS,EAAEQ,sBAAUE,MAbJ;AAcjBR,EAAAA,QAAQ,EAAEM,sBAAUI,IAdH;AAejBT,EAAAA,cAAc,EAAEK,sBAAUI;AAfT,C;iCADRpB,W,kBAmBW;AACpBS,EAAAA,SAAS,EAAE,IADS;AAEpBf,EAAAA,aAAa,EAAE,IAFK;AAGpBR,EAAAA,OAAO,EAAE,KAHW;AAIpByB,EAAAA,cAAc,EAAE;AAJI,C;;eAyET,wBAAWnD,UAAX,EAAuBwC,WAAvB,C","sourcesContent":["import FormControlLabel from '@material-ui/core/FormControlLabel';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Checkbox from '@material-ui/core/Checkbox';\nimport { Feedback, color, PreviewPrompt } from '@pie-lib/render-ui';\nimport FeedbackTick from './feedback-tick';\nimport Radio from '@material-ui/core/Radio';\nimport classNames from 'classnames';\n\nconst styleSheet = () => ({\n row: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n },\n checkboxHolder: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n flex: 1,\n '& label': {\n color: color.text(),\n },\n },\n});\n\nconst formStyleSheet = {\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)'\n backgroundColor: color.background(),\n },\n};\n\nexport const StyledFormControlLabel = withStyles(formStyleSheet, {\n name: 'FormControlLabel',\n})((props) => (\n <FormControlLabel {...props} classes={{ label: props.classes.label }} />\n));\n\nconst CLASS_NAME = 'multiple-choice-component';\n\nconst colorStyle = (varName, fallback) => ({\n [`&.${CLASS_NAME}`]: {\n color: `var(--choice-input-${varName}, ${fallback}) !important`,\n },\n});\n\nconst inputStyles = {\n 'correct-root': colorStyle('correct-color', color.text()),\n 'correct-checked': colorStyle('correct-selected-color', color.correct()), //green[500]),\n 'correct-disabled': colorStyle('correct-disabled-color', color.disabled()), //'grey'),\n 'incorrect-root': colorStyle('incorrect-color', color.incorrect()),\n 'incorrect-checked': colorStyle('incorrect-checked', color.incorrect()), //orange[500]),\n 'incorrect-disabled': colorStyle(\n 'incorrect-disabled-color',\n color.disabled()\n ),\n root: {\n ...colorStyle('color', color.text()),\n '&:hover': { color: `${color.primaryLight()} !important` },\n },\n checked: colorStyle('selected-color', color.primary()),\n disabled: {\n ...colorStyle('disabled-color', color.text()),\n opacity: 0.6,\n cursor: 'not-allowed !important',\n pointerEvents: 'initial !important',\n },\n};\n\nexport const StyledCheckbox = withStyles(inputStyles)((props) => {\n const {\n correctness,\n classes,\n checked,\n onChange,\n disabled,\n accessibility,\n } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled };\n return (\n <Checkbox\n aria-label={accessibility}\n {...miniProps}\n className={CLASS_NAME}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport const StyledRadio = withStyles(inputStyles)((props) => {\n const {\n correctness,\n classes,\n checked,\n onChange,\n disabled,\n accessibility,\n } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled };\n\n return (\n <Radio\n aria-label={accessibility}\n {...miniProps}\n className={CLASS_NAME}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport class ChoiceInput extends React.Component {\n static propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n displayKey: PropTypes.string.isRequired,\n checked: PropTypes.bool.isRequired,\n correctness: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n feedback: PropTypes.string,\n label: PropTypes.string.isRequired,\n rationale: PropTypes.string,\n accessibility: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n value: PropTypes.string.isRequired,\n classes: PropTypes.object,\n className: PropTypes.string,\n hideTick: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n };\n\n static defaultProps = {\n rationale: null,\n accessibility: null,\n checked: false,\n isEvaluateMode: false,\n };\n\n constructor(props) {\n super(props);\n this.onToggleChoice = this.onToggleChoice.bind(this);\n }\n\n onToggleChoice() {\n this.props.onChange({\n value: this.props.value,\n selected: !this.props.checked,\n });\n }\n\n render() {\n const {\n choiceMode,\n disabled,\n displayKey,\n feedback,\n label,\n checked,\n correctness,\n classes,\n className,\n rationale,\n accessibility,\n hideTick,\n isEvaluateMode,\n } = this.props;\n\n const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;\n const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';\n\n return (\n <div className={classNames(className, 'corespring-' + classSuffix, 'choice-input')}>\n <div className={classes.row}>\n {(!hideTick && isEvaluateMode) && <FeedbackTick correctness={correctness} />}\n <div className={classNames(classes.checkboxHolder, 'checkbox-holder')}>\n <StyledFormControlLabel\n disabled={disabled}\n label={displayKey ? displayKey + '. ' : ''}\n control={\n <Tag\n accessibility={accessibility}\n checked={checked}\n correctness={correctness}\n onChange={this.onToggleChoice}\n />\n }\n />\n <PreviewPrompt\n className=\"label\"\n onClick={this.onToggleChoice}\n prompt={label}\n tagName=\"span\"\n />\n </div>\n </div>\n {rationale && (\n <PreviewPrompt className=\"rationale\" defaultClassName=\"rationale\" prompt={rationale} />\n )}\n <Feedback feedback={feedback} correctness={correctness} />\n </div>\n );\n }\n}\n\nexport default withStyles(styleSheet)(ChoiceInput);\n"],"file":"choice-input.js"}
1
+ {"version":3,"sources":["../src/choice-input.jsx"],"names":["CLASS_NAME","styleSheet","row","display","alignItems","backgroundColor","color","background","checkboxHolder","flex","text","horizontalLayout","paddingRight","formStyleSheet","label","StyledFormControlLabel","name","props","classes","colorStyle","varName","fallback","inputStyles","correct","disabled","incorrect","root","primaryLight","checked","primary","opacity","cursor","pointerEvents","StyledCheckbox","correctness","onChange","accessibility","key","k","resolved","miniProps","StyledRadio","ChoiceInput","onToggleChoice","bind","value","selected","choiceMode","displayKey","feedback","className","rationale","hideTick","isEvaluateMode","choicesLayout","Tag","classSuffix","holderClassNames","React","Component","PropTypes","oneOf","string","isRequired","bool","func","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,2BAAnB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,SAAO;AACxBC,IAAAA,GAAG,EAAE;AACHC,MAAAA,OAAO,EAAE,MADN;AAEHC,MAAAA,UAAU,EAAE,QAFT;AAGHC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN;AAHd,KADmB;AAMxBC,IAAAA,cAAc,EAAE;AACdL,MAAAA,OAAO,EAA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EAAAA,SAAS,EAAE,IADS;AAEpBf,EAAAA,aAAa,EAAE,IAFK;AAGpBR,EAAAA,OAAO,EAAE,KAHW;AAIpByB,EAAAA,cAAc,EAAE;AAJI,C;;eAuET,wBAAWpD,UAAX,EAAuByC,WAAvB,C","sourcesContent":["import FormControlLabel from '@material-ui/core/FormControlLabel';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Checkbox from '@material-ui/core/Checkbox';\nimport { Feedback, color, PreviewPrompt } from '@pie-lib/render-ui';\nimport FeedbackTick from './feedback-tick';\nimport Radio from '@material-ui/core/Radio';\nimport classNames from 'classnames';\n\nconst CLASS_NAME = 'multiple-choice-component';\n\nconst styleSheet = () => ({\n row: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n },\n checkboxHolder: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n flex: 1,\n '& label': {\n color: color.text(),\n },\n },\n horizontalLayout: {\n [`& .${CLASS_NAME}`]: {\n paddingRight: '8px',\n },\n },\n});\n\nconst formStyleSheet = {\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)'\n backgroundColor: color.background(),\n },\n};\n\nexport const StyledFormControlLabel = withStyles(formStyleSheet, {\n name: 'FormControlLabel',\n})((props) => <FormControlLabel {...props} classes={{ label: props.classes.label }} />);\n\nconst colorStyle = (varName, fallback) => ({\n [`&.${CLASS_NAME}`]: {\n color: `var(--choice-input-${varName}, ${fallback}) !important`,\n },\n});\n\nconst inputStyles = {\n 'correct-root': colorStyle('correct-color', color.text()),\n 'correct-checked': colorStyle('correct-selected-color', color.correct()), //green[500]),\n 'correct-disabled': colorStyle('correct-disabled-color', color.disabled()), //'grey'),\n 'incorrect-root': colorStyle('incorrect-color', color.incorrect()),\n 'incorrect-checked': colorStyle('incorrect-checked', color.incorrect()), //orange[500]),\n 'incorrect-disabled': colorStyle('incorrect-disabled-color', color.disabled()),\n root: {\n ...colorStyle('color', color.text()),\n '&:hover': { color: `${color.primaryLight()} !important` },\n },\n checked: colorStyle('selected-color', color.primary()),\n disabled: {\n ...colorStyle('disabled-color', color.text()),\n opacity: 0.6,\n cursor: 'not-allowed !important',\n pointerEvents: 'initial !important',\n },\n};\n\nexport const StyledCheckbox = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, accessibility } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled };\n return (\n <Checkbox\n aria-label={accessibility}\n {...miniProps}\n className={CLASS_NAME}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport const StyledRadio = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, accessibility } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled };\n\n return (\n <Radio\n aria-label={accessibility}\n {...miniProps}\n className={CLASS_NAME}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport class ChoiceInput extends React.Component {\n static propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n displayKey: PropTypes.string.isRequired,\n checked: PropTypes.bool.isRequired,\n correctness: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n feedback: PropTypes.string,\n label: PropTypes.string.isRequired,\n rationale: PropTypes.string,\n accessibility: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n value: PropTypes.string.isRequired,\n classes: PropTypes.object,\n className: PropTypes.string,\n hideTick: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n };\n\n static defaultProps = {\n rationale: null,\n accessibility: null,\n checked: false,\n isEvaluateMode: false,\n };\n\n constructor(props) {\n super(props);\n this.onToggleChoice = this.onToggleChoice.bind(this);\n }\n\n onToggleChoice() {\n this.props.onChange({\n value: this.props.value,\n selected: !this.props.checked,\n });\n }\n\n render() {\n const {\n choiceMode,\n disabled,\n displayKey,\n feedback,\n label,\n checked,\n correctness,\n classes,\n className,\n rationale,\n accessibility,\n hideTick,\n isEvaluateMode,\n choicesLayout,\n } = this.props;\n\n const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;\n const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';\n\n const holderClassNames = classNames(classes.checkboxHolder, {\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n });\n\n return (\n <div className={classNames(className, 'corespring-' + classSuffix, 'choice-input')}>\n <div className={classes.row}>\n {!hideTick && isEvaluateMode && <FeedbackTick correctness={correctness} />}\n <div className={classNames(holderClassNames, 'checkbox-holder')}>\n <StyledFormControlLabel\n disabled={disabled}\n label={displayKey ? displayKey + '. ' : ''}\n control={\n <Tag\n accessibility={accessibility}\n checked={checked}\n correctness={correctness}\n onChange={this.onToggleChoice}\n />\n }\n />\n <PreviewPrompt className=\"label\" onClick={this.onToggleChoice} prompt={label} tagName=\"span\" />\n </div>\n </div>\n {rationale && <PreviewPrompt className=\"rationale\" defaultClassName=\"rationale\" prompt={rationale} />}\n <Feedback feedback={feedback} correctness={correctness} />\n </div>\n );\n }\n}\n\nexport default withStyles(styleSheet)(ChoiceInput);\n"],"file":"choice-input.js"}
package/lib/choice.js CHANGED
@@ -33,9 +33,9 @@ var _classnames = _interopRequireDefault(require("classnames"));
33
33
 
34
34
  var _choiceInput = _interopRequireDefault(require("./choice-input"));
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
 
@@ -71,6 +71,8 @@ var Choice = /*#__PURE__*/function (_React$Component) {
71
71
  (0, _createClass2["default"])(Choice, [{
72
72
  key: "render",
73
73
  value: function render() {
74
+ var _classNames;
75
+
74
76
  var _this$props2 = this.props,
75
77
  choice = _this$props2.choice,
76
78
  index = _this$props2.index,
@@ -101,7 +103,7 @@ var Choice = /*#__PURE__*/function (_React$Component) {
101
103
  isEvaluateMode: isEvaluateMode
102
104
  });
103
105
 
104
- var names = (0, _classnames["default"])(classes.choice, (0, _defineProperty2["default"])({}, classes.noBorder, index === choicesLength - 1 || choicesLayout !== 'vertical'));
106
+ var names = (0, _classnames["default"])(classes.choice, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.noBorder, index === choicesLength - 1 || choicesLayout !== 'vertical'), (0, _defineProperty2["default"])(_classNames, classes.horizontalLayout, choicesLayout === 'horizontal'), _classNames));
105
107
  return /*#__PURE__*/_react["default"].createElement("div", {
106
108
  className: choiceClass,
107
109
  key: index
@@ -139,6 +141,15 @@ var _default = (0, _styles.withStyles)({
139
141
  },
140
142
  noBorder: {
141
143
  borderBottom: 'none'
144
+ },
145
+ horizontalLayout: {
146
+ paddingRight: '20px',
147
+ '& label': {
148
+ marginRight: '8px' // '& span:first-child': {
149
+ // paddingRight: 0
150
+ // }
151
+
152
+ }
142
153
  }
143
154
  })(Choice);
144
155
 
package/lib/choice.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/choice.jsx"],"names":["Choice","choice","props","disabled","onChoiceChanged","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","checked","correctness","displayKey","classes","choicesLayout","gridColumns","choiceClass","feedback","choiceProps","onChange","names","noBorder","React","Component","propTypes","PropTypes","oneOf","object","bool","isRequired","func","number","string","paddingTop","paddingBottom","borderBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,M;;;;;;;;;;;;;;;iGACA,UAACC,MAAD,EAAY;AACrB,wBAAsC,MAAKC,KAA3C;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,eAAlB,eAAkBA,eAAlB;;AAEA,UAAI,CAACD,QAAL,EAAe;AACbC,QAAAA,eAAe,CAACH,MAAD,CAAf;AAC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Styles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport ChoiceInput from './choice-input';\n\nexport class Choice extends React.Component {\n onChange = (choice) => {\n const { disabled, onChoiceChanged } = this.props;\n\n if (!disabled) {\n onChoiceChanged(choice);\n }\n };\n\n render() {\n const {\n choice,\n index,\n choicesLength,\n showCorrect,\n isEvaluateMode,\n choiceMode,\n disabled,\n checked,\n correctness,\n displayKey,\n classes,\n choicesLayout,\n gridColumns,\n } = this.props;\n const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');\n\n const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;\n\n const choiceProps = {\n ...choice,\n checked,\n choiceMode,\n disabled,\n feedback,\n correctness,\n displayKey,\n choicesLayout,\n gridColumns,\n onChange: this.onChange,\n isEvaluateMode,\n };\n\n const names = classNames(classes.choice, {\n [classes.noBorder]:\n index === choicesLength - 1 || choicesLayout !== 'vertical',\n });\n\n return (\n <div className={choiceClass} key={index}>\n <ChoiceInput {...choiceProps} className={names} />\n </div>\n );\n }\n}\n\nChoice.propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n choice: PropTypes.object,\n disabled: PropTypes.bool.isRequired,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n index: PropTypes.number,\n choicesLength: PropTypes.number,\n showCorrect: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n checked: PropTypes.bool,\n correctness: PropTypes.string,\n displayKey: PropTypes.string,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n};\n\nexport default withStyles({\n choice: {\n paddingTop: '20px',\n paddingBottom: '10px',\n borderBottom: '1px solid #E0DEE0',\n },\n noBorder: {\n borderBottom: 'none',\n },\n})(Choice);\n"],"file":"choice.js"}
1
+ {"version":3,"sources":["../src/choice.jsx"],"names":["Choice","choice","props","disabled","onChoiceChanged","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","checked","correctness","displayKey","classes","choicesLayout","gridColumns","choiceClass","feedback","choiceProps","onChange","names","noBorder","horizontalLayout","React","Component","propTypes","PropTypes","oneOf","object","bool","isRequired","func","number","string","paddingTop","paddingBottom","borderBottom","paddingRight","marginRight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,M;;;;;;;;;;;;;;;iGACA,UAACC,MAAD,EAAY;AACrB,wBAAsC,MAAKC,KAA3C;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,eAAlB,eAAkBA,eAAlB;;AAEA,UAAI,CAACD,QAAL,EAAe;AACbC,QAAAA,eAAe,CAACH,MAAD,CAAf;AACD;AACF,K;;;;;;WAED,kBAAS;AAAA;;AACP,yBAcI,KAAKC,KAdT;AAAA,UACED,MADF,gBACEA,MADF;AAAA,UAEEI,KAFF,gBAEEA,KAFF;AAAA,UAGEC,aAHF,gBAGEA,aAHF;AAAA,UAIEC,WAJF,gBAIEA,WAJF;AAAA,UAKEC,cALF,gBAKEA,cALF;AAAA,UAMEC,UANF,gBAMEA,UANF;AAAA,UAOEN,QAPF,gBAOEA,QAPF;AAAA,UAQEO,OARF,gBAQEA,OARF;AAAA,UASEC,WATF,gBASEA,WATF;AAAA,UAUEC,UAVF,gBAUEA,UAVF;AAAA,UAWEC,OAXF,gBAWEA,OAXF;AAAA,UAYEC,aAZF,gBAYEA,aAZF;AAAA,UAaEC,WAbF,gBAaEA,WAbF;AAeA,UAAMC,WAAW,GAAG,YAAYX,KAAK,KAAKC,aAAa,GAAG,CAA1B,GAA8B,OAA9B,GAAwC,EAApD,CAApB;AAEA,UAAMW,QAAQ,GAAG,CAACT,cAAD,IAAmBD,WAAnB,GAAiC,EAAjC,GAAsCN,MAAM,CAACgB,QAA9D;;AAEA,UAAMC,WAAW,mCACZjB,MADY;AAEfS,QAAAA,OAAO,EAAPA,OAFe;AAGfD,QAAAA,UAAU,EAAVA,UAHe;AAIfN,QAAAA,QAAQ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,WAAW,EAAEe,sBAAUO,MAXN;AAYjBrB,EAAAA,UAAU,EAAEc,sBAAUO,MAZL;AAajBnB,EAAAA,aAAa,EAAEY,sBAAUC,KAAV,CAAgB,CAAC,UAAD,EAAa,MAAb,EAAqB,YAArB,CAAhB,CAbE;AAcjBZ,EAAAA,WAAW,EAAEW,sBAAUO;AAdN,CAAnB;;eAiBe,wBAAW;AACxBhC,EAAAA,MAAM,EAAE;AACNiC,IAAAA,UAAU,EAAE,MADN;AAENC,IAAAA,aAAa,EAAE,MAFT;AAGNC,IAAAA,YAAY,EAAE;AAHR,GADgB;AAMxBf,EAAAA,QAAQ,EAAE;AACRe,IAAAA,YAAY,EAAE;AADN,GANc;AASxBd,EAAAA,gBAAgB,EAAE;AAChBe,IAAAA,YAAY,EAAE,MADE;AAEhB,eAAW;AACTC,MAAAA,WAAW,EAAE,KADJ,CAET;AACA;AACA;;AAJS;AAFK;AATM,CAAX,EAkBZtC,MAlBY,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport ChoiceInput from './choice-input';\n\nexport class Choice extends React.Component {\n onChange = (choice) => {\n const { disabled, onChoiceChanged } = this.props;\n\n if (!disabled) {\n onChoiceChanged(choice);\n }\n };\n\n render() {\n const {\n choice,\n index,\n choicesLength,\n showCorrect,\n isEvaluateMode,\n choiceMode,\n disabled,\n checked,\n correctness,\n displayKey,\n classes,\n choicesLayout,\n gridColumns,\n } = this.props;\n const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');\n\n const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;\n\n const choiceProps = {\n ...choice,\n checked,\n choiceMode,\n disabled,\n feedback,\n correctness,\n displayKey,\n choicesLayout,\n gridColumns,\n onChange: this.onChange,\n isEvaluateMode,\n };\n\n const names = classNames(classes.choice, {\n [classes.noBorder]: index === choicesLength - 1 || choicesLayout !== 'vertical',\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n });\n\n return (\n <div className={choiceClass} key={index}>\n <ChoiceInput {...choiceProps} className={names} />\n </div>\n );\n }\n}\n\nChoice.propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n choice: PropTypes.object,\n disabled: PropTypes.bool.isRequired,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n index: PropTypes.number,\n choicesLength: PropTypes.number,\n showCorrect: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n checked: PropTypes.bool,\n correctness: PropTypes.string,\n displayKey: PropTypes.string,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n};\n\nexport default withStyles({\n choice: {\n paddingTop: '20px',\n paddingBottom: '10px',\n borderBottom: '1px solid #E0DEE0',\n },\n noBorder: {\n borderBottom: 'none',\n },\n horizontalLayout: {\n paddingRight: '20px',\n '& label': {\n marginRight: '8px',\n // '& span:first-child': {\n // paddingRight: 0\n // }\n },\n },\n})(Choice);\n"],"file":"choice.js"}
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.isComplete = void 0;
8
+ exports.isComplete = exports["default"] = void 0;
9
9
 
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
 
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","value","length","MultipleChoice","_model","_session","_rerender","element","React","createElement","Main","model","onChoiceChanged","_onChange","bind","ReactDOM","render","leading","trailing","_dispatchResponseChanged","event","CustomEvent","bubbles","composed","detail","complete","component","tagName","toLowerCase","dispatchEvent","_dispatchModelSet","hasModel","undefined","s","data","choiceMode","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;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AS,EAAE,MAAKC,OAAL,CAAaC,WAAb;AAFL;AAHqC,OAAnC,CAAZ;;AASA,YAAKC,aAAL,CAAmBT,KAAnB;AACD,KAX+B,CAAhC;AAaA,UAAKU,iBAAL,GAAyB,0BACvB,YAAM;AACJ,YAAKD,aAAL,CACE,IAAIR,WAAJ,CAAgB,WAAhB,EAA6B;AAC3BC,QAAAA,OAAO,EAAE,IADkB;AAE3BC,QAAAA,QAAQ,EAAE,IAFiB;AAG3BC,QAAAA,MAAM,EAAE;AACNC,UAAAA,QAAQ,EAAE1B,UAAU,CAAC,MAAKM,QAAN,CADd;AAENqB,UAAAA,SAAS,EAAE,MAAKC,OAAL,CAAaC,WAAb,EAFL;AAGNG,UAAAA,QAAQ,EAAE,MAAK3B,MAAL,KAAgB4B;AAHpB;AAHmB,OAA7B,CADF;AAWD,KAbsB,EAcvB,EAduB,EAevB;AAAEf,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KAfuB,CAAzB;AAtCY;AAuDb;;;;SAED,aAAUe,CAAV,EAAa;AACX,WAAK7B,MAAL,GAAc6B,CAAd;;AACA,WAAK3B,SAAL;;AACA,WAAKwB,iBAAL;AACD;;;SAED,eAAc;AACZ,aAAO,KAAKzB,QAAZ;AACD,K;SAED,aAAY4B,CAAZ,EAAe;AACb,WAAK5B,QAAL,GAAgB4B,CAAhB;;AACA,WAAK3B,SAAL,GAFa,CAGb;;;AACA,WAAKa,wBAAL;AACD;;;WAED,mBAAUe,IAAV,EAAgB;AACd,8CAAmB,KAAK7B,QAAxB,EAAkC,KAAKD,MAAL,CAAY+B,UAA9C,EAA0DD,IAA1D;;AACA,WAAKf,wBAAL;;AACA,WAAKb,SAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,SAAL;AACD;;;kDAnFyC8B,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { updateSessionValue } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = session => !!(session && session.value && session.value.length);\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChoiceChanged: this._onChange.bind(this)\n });\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true }\n );\n\n this._dispatchResponseChanged = debounce(() => {\n var event = new CustomEvent('session-changed', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase()\n }\n });\n\n this.dispatchEvent(event);\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new CustomEvent('model-set', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n hasModel: this._model !== undefined\n }\n })\n );\n },\n 50,\n { leading: false, trailing: true }\n );\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n connectedCallback() {\n this._rerender();\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","value","length","MultipleChoice","_model","_session","_rerender","element","React","createElement","Main","model","onChoiceChanged","_onChange","bind","ReactDOM","render","leading","trailing","_dispatchResponseChanged","event","CustomEvent","bubbles","composed","detail","complete","component","tagName","toLowerCase","dispatchEvent","_dispatchModelSet","hasModel","undefined","s","data","choiceMode","HTMLElement"],"mappings":";;;;;;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ounce from 'lodash/debounce';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { updateSessionValue } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session) => !!(session && session.value && session.value.length);\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChoiceChanged: this._onChange.bind(this),\n });\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n\n this._dispatchResponseChanged = debounce(() => {\n var event = new CustomEvent('session-changed', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n },\n });\n\n this.dispatchEvent(event);\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new CustomEvent('model-set', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n hasModel: this._model !== undefined,\n },\n }),\n );\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n connectedCallback() {\n this._rerender();\n }\n}\n"],"file":"index.js"}
package/lib/main.js CHANGED
@@ -56,7 +56,10 @@ var Main = /*#__PURE__*/function (_React$Component) {
56
56
  session = _this$props.session,
57
57
  classes = _this$props.classes; // model.partLabel is a property used for ebsr
58
58
 
59
- return /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewLayout, null, model.partLabel && /*#__PURE__*/_react["default"].createElement("p", null, model.partLabel), /*#__PURE__*/_react["default"].createElement("div", {
59
+ return /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewLayout, {
60
+ ariaLabel: model.choiceMode == 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',
61
+ role: "region"
62
+ }, model.partLabel && /*#__PURE__*/_react["default"].createElement("p", null, model.partLabel), /*#__PURE__*/_react["default"].createElement("div", {
60
63
  className: (0, _classnames["default"])(classes.root, classes[model.className])
61
64
  }, /*#__PURE__*/_react["default"].createElement(_multipleChoice["default"], (0, _extends2["default"])({}, model, {
62
65
  session: session,
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["Main","props","model","onChoiceChanged","session","classes","partLabel","root","className","React","Component","PropTypes","object","func","isRequired","Styled","name","theme","typography","useNextVariants","Root"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;IAEMA,I;;;;;AAYJ,gBAAYC,KAAZ,EAAmB;AAAA;AAAA,6BACXA,KADW;AAElB;;;;WAED,kBAAS;AACP,wBAAqD,KAAKA,KAA1D;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,eAAf,eAAeA,eAAf;AAAA,UAAgCC,OAAhC,eAAgCA,OAAhC;AAAA,UAAyCC,OAAzC,eAAyCA,OAAzC,CADO,CAGP;;AACA,0BACE,gCAAC,uBAAD,QACGH,KAAK,CAACI,SAAN,iBAAmB,2CAAIJ,KAAK,CAACI,SAAV,CADtB,eAEE;AAAK,QAAA,SAAS,EAAE,4BAAWD,OAAO,CAACE,IAAnB,EAAyBF,OAAO,CAACH,KAAK,CAACM,SAAP,CAAhC;AAAhB,sBACE,gCAAC,0BAAD,gCACMN,KADN;AAEE,QAAA,OAAO,EAAEE,OAFX;AAGE,QAAA,eAAe,EAAED;AAHnB,SADF,CAFF,CADF;AAYD;;;EAhCgBM,kBAAMC,S;;iCAAnBV,I,eACe;AACjBE,EAAAA,KAAK,EAAES,sBAAUC,MADA;AAEjBR,EAAAA,OAAO,EAAEO,sBAAUC,MAFF;AAGjBT,EAAAA,eAAe,EAAEQ,sBAAUE,IAHV;AAIjBR,EAAAA,OAAO,EAAEM,sBAAUC,MAAV,CAAiBE;AAJT,C;iCADfd,I,kBAQkB;AACpBE,EAAAA,KAAK,EAAE,EADa;AAEpBE,EAAAA,OAAO,EAAE;AAFW,C;AA2BxB,IAAMW,MAAM,GAAG,wBAAW,EAAX,EAAe;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAAf,EAAiChB,IAAjC,CAAf;AAEA,IAAMiB,KAAK,GAAG,4BAAe;AAC3BC,EAAAA,UAAU,EAAE;AACVC,IAAAA,eAAe,EAAE;AADP;AADe,CAAf,CAAd;;AAMA,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAACnB,KAAD;AAAA,sBACX,gCAAC,wBAAD;AAAkB,IAAA,KAAK,EAAEgB;AAAzB,kBACE,gCAAC,MAAD,EAAYhB,KAAZ,CADF,CADW;AAAA,CAAb;;eAMemB,I","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { PreviewLayout } from '@pie-lib/render-ui';\nimport MultipleChoice from './multiple-choice';\n\nclass Main extends React.Component {\n static propTypes = {\n model: PropTypes.object,\n session: PropTypes.object,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n };\n\n static defaultProps = {\n model: {},\n session: {},\n };\n constructor(props) {\n super(props);\n }\n\n render() {\n const { model, onChoiceChanged, session, classes } = this.props;\n\n // model.partLabel is a property used for ebsr\n return (\n <PreviewLayout>\n {model.partLabel && <p>{model.partLabel}</p>}\n <div className={classNames(classes.root, classes[model.className])}>\n <MultipleChoice\n {...model}\n session={session}\n onChoiceChanged={onChoiceChanged}\n />\n </div>\n </PreviewLayout>\n );\n }\n}\n\nconst Styled = withStyles({}, { name: 'Main' })(Main);\n\nconst theme = createMuiTheme({\n typography: {\n useNextVariants: true,\n },\n});\n\nconst Root = (props) => (\n <MuiThemeProvider theme={theme}>\n <Styled {...props} />\n </MuiThemeProvider>\n);\n\nexport default Root;\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["Main","props","model","onChoiceChanged","session","classes","choiceMode","partLabel","root","className","React","Component","PropTypes","object","func","isRequired","Styled","name","theme","typography","useNextVariants","Root"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;IAEMA,I;;;;;AAYJ,gBAAYC,KAAZ,EAAmB;AAAA;AAAA,6BACXA,KADW;AAElB;;;;WAED,kBAAS;AACP,wBAAqD,KAAKA,KAA1D;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,eAAf,eAAeA,eAAf;AAAA,UAAgCC,OAAhC,eAAgCA,OAAhC;AAAA,UAAyCC,OAAzC,eAAyCA,OAAzC,CADO,CAGP;;AACA,0BACE,gCAAC,uBAAD;AACE,QAAA,SAAS,EAAGH,KAAK,CAACI,UAAN,IAAoB,OAApB,GAA8B,0BAA9B,GAA2D,kCADzE;AAEE,QAAA,IAAI,EAAC;AAFP,SAIGJ,KAAK,CAACK,SAAN,iBAAmB,2CAAIL,KAAK,CAACK,SAAV,CAJtB,eAKE;AAAK,QAAA,SAAS,EAAE,4BAAWF,OAAO,CAACG,IAAnB,EAAyBH,OAAO,CAACH,KAAK,CAACO,SAAP,CAAhC;AAAhB,sBACE,gCAAC,0BAAD,gCAAoBP,KAApB;AAA2B,QAAA,OAAO,EAAEE,OAApC;AAA6C,QAAA,eAAe,EAAED;AAA9D,SADF,CALF,CADF;AAWD;;;EA/BgBO,kBAAMC,S;;iCAAnBX,I,eACe;AACjBE,EAAAA,KAAK,EAAEU,sBAAUC,MADA;AAEjBT,EAAAA,OAAO,EAAEQ,sBAAUC,MAFF;AAGjBV,EAAAA,eAAe,EAAES,sBAAUE,IAHV;AAIjBT,EAAAA,OAAO,EAAEO,sBAAUC,MAAV,CAAiBE;AAJT,C;iCADff,I,kBAQkB;AACpBE,EAAAA,KAAK,EAAE,EADa;AAEpBE,EAAAA,OAAO,EAAE;AAFW,C;AA0BxB,IAAMY,MAAM,GAAG,wBAAW,EAAX,EAAe;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAAf,EAAiCjB,IAAjC,CAAf;AAEA,IAAMkB,KAAK,GAAG,4BAAe;AAC3BC,EAAAA,UAAU,EAAE;AACVC,IAAAA,eAAe,EAAE;AADP;AADe,CAAf,CAAd;;AAMA,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAACpB,KAAD;AAAA,sBACX,gCAAC,wBAAD;AAAkB,IAAA,KAAK,EAAEiB;AAAzB,kBACE,gCAAC,MAAD,EAAYjB,KAAZ,CADF,CADW;AAAA,CAAb;;eAMeoB,I","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { PreviewLayout } from '@pie-lib/render-ui';\nimport MultipleChoice from './multiple-choice';\n\nclass Main extends React.Component {\n static propTypes = {\n model: PropTypes.object,\n session: PropTypes.object,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n };\n\n static defaultProps = {\n model: {},\n session: {},\n };\n constructor(props) {\n super(props);\n }\n\n render() {\n const { model, onChoiceChanged, session, classes } = this.props;\n\n // model.partLabel is a property used for ebsr\n return (\n <PreviewLayout\n ariaLabel={(model.choiceMode == 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question')}\n role=\"region\"\n > \n {model.partLabel && <p>{model.partLabel}</p>}\n <div className={classNames(classes.root, classes[model.className])}>\n <MultipleChoice {...model} session={session} onChoiceChanged={onChoiceChanged} />\n </div>\n </PreviewLayout>\n );\n }\n}\n\nconst Styled = withStyles({}, { name: 'Main' })(Main);\n\nconst theme = createMuiTheme({\n typography: {\n useNextVariants: true,\n },\n});\n\nconst Root = (props) => (\n <MuiThemeProvider theme={theme}>\n <Styled {...props} />\n </MuiThemeProvider>\n);\n\nexport default Root;\n"],"file":"main.js"}