@pie-element/multiple-choice 8.0.0-beta → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -370,6 +370,82 @@
370
370
  }
371
371
  }
372
372
  },
373
+ "mathMlOptions": {
374
+ "title": "ConfigureMathMLProp",
375
+ "type": "object",
376
+ "properties": {
377
+ "mmlOutput": {
378
+ "description": "Indicates if model should have mathML output instead of latex",
379
+ "type": "number",
380
+ "title": "mmlOutput"
381
+ },
382
+ "mmlEditing": {
383
+ "description": "Indicates if mathML that's already in model should be editable",
384
+ "type": "number",
385
+ "title": "mmlEditing"
386
+ }
387
+ }
388
+ },
389
+ "language": {
390
+ "title": "ConfigurePropWithEnabled",
391
+ "type": "object",
392
+ "properties": {
393
+ "settings": {
394
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
395
+ "type": "boolean",
396
+ "title": "settings"
397
+ },
398
+ "label": {
399
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
400
+ "type": "string",
401
+ "title": "label"
402
+ },
403
+ "enabled": {
404
+ "description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
405
+ "type": "boolean",
406
+ "title": "enabled"
407
+ }
408
+ }
409
+ },
410
+ "languageChoices": {
411
+ "description": "Language choices configuration\nOnly available if language is enabled",
412
+ "type": "object",
413
+ "properties": {
414
+ "label": {
415
+ "type": "string",
416
+ "title": "label"
417
+ },
418
+ "options": {
419
+ "type": "array",
420
+ "items": {
421
+ "title": "ConfigureLanguageOptionsProp",
422
+ "type": "object",
423
+ "properties": {
424
+ "value": {
425
+ "description": "Value of the language option",
426
+ "type": "string",
427
+ "title": "value"
428
+ },
429
+ "label": {
430
+ "description": "Label of the language option",
431
+ "type": "string",
432
+ "title": "label"
433
+ }
434
+ },
435
+ "required": [
436
+ "label",
437
+ "value"
438
+ ]
439
+ },
440
+ "title": "options"
441
+ }
442
+ },
443
+ "required": [
444
+ "label",
445
+ "options"
446
+ ],
447
+ "title": "languageChoices"
448
+ },
373
449
  "showPrompt": {
374
450
  "description": "Determines whether prompt field will be displayed or not",
375
451
  "default": true,
@@ -381,6 +457,56 @@
381
457
  "default": "Item Stemm",
382
458
  "type": "string",
383
459
  "title": "promptLabel"
460
+ },
461
+ "contentDimensions": {
462
+ "description": "Indicates the dimensions configuration for the authoring container\nNote: Some items have a default minimum width because of their content, but if\nthe minWidth is lower than this, the overflow behavior will take care of that",
463
+ "default": ": {}",
464
+ "type": "object",
465
+ "properties": {
466
+ "maxHeight": {
467
+ "description": "Indicates the max height of the authoring container",
468
+ "default": "undefined",
469
+ "type": [
470
+ "string",
471
+ "number"
472
+ ],
473
+ "title": "maxHeight"
474
+ },
475
+ "maxWidth": {
476
+ "description": "Indicates the max width of the authoring container",
477
+ "default": "undefined",
478
+ "type": [
479
+ "string",
480
+ "number"
481
+ ],
482
+ "title": "maxWidth"
483
+ },
484
+ "minHeight": {
485
+ "description": "Indicates the min height of the authoring container",
486
+ "default": "undefined",
487
+ "type": [
488
+ "string",
489
+ "number"
490
+ ],
491
+ "title": "minHeight"
492
+ },
493
+ "minWidth": {
494
+ "description": "Indicates the min width of the authoring container",
495
+ "default": "undefined",
496
+ "type": [
497
+ "string",
498
+ "number"
499
+ ],
500
+ "title": "minWidth"
501
+ }
502
+ },
503
+ "title": "contentDimensions"
504
+ },
505
+ "settingsPartialScoring": {
506
+ "description": "Indicates whether the settings panel wil allow the author to modify settings for partial scoring",
507
+ "default": true,
508
+ "type": "boolean",
509
+ "title": "settingsPartialScoring"
384
510
  }
385
511
  },
386
512
  "definitions": {
@@ -446,6 +572,42 @@
446
572
  "title": "choices"
447
573
  }
448
574
  }
575
+ },
576
+ "ConfigureMathMLProp": {
577
+ "title": "ConfigureMathMLProp",
578
+ "type": "object",
579
+ "properties": {
580
+ "mmlOutput": {
581
+ "description": "Indicates if model should have mathML output instead of latex",
582
+ "type": "number",
583
+ "title": "mmlOutput"
584
+ },
585
+ "mmlEditing": {
586
+ "description": "Indicates if mathML that's already in model should be editable",
587
+ "type": "number",
588
+ "title": "mmlEditing"
589
+ }
590
+ }
591
+ },
592
+ "ConfigureLanguageOptionsProp": {
593
+ "title": "ConfigureLanguageOptionsProp",
594
+ "type": "object",
595
+ "properties": {
596
+ "value": {
597
+ "description": "Value of the language option",
598
+ "type": "string",
599
+ "title": "value"
600
+ },
601
+ "label": {
602
+ "description": "Label of the language option",
603
+ "type": "string",
604
+ "title": "label"
605
+ }
606
+ },
607
+ "required": [
608
+ "label",
609
+ "value"
610
+ ]
449
611
  }
450
612
  },
451
613
  "$schema": "http://json-schema.org/draft-07/schema#"
@@ -285,6 +285,58 @@ Indicates if the item has to be displayed in the Settings Panel
285
285
 
286
286
  Indicates the label for the item that has to be displayed in the Settings Panel
287
287
 
288
+ # `mathMlOptions` (object)
289
+
290
+ Properties of the `mathMlOptions` object:
291
+
292
+ ## `mmlOutput` (number)
293
+
294
+ Indicates if model should have mathML output instead of latex
295
+
296
+ ## `mmlEditing` (number)
297
+
298
+ Indicates if mathML that's already in model should be editable
299
+
300
+ # `language` (object)
301
+
302
+ Properties of the `language` object:
303
+
304
+ ## `settings` (boolean)
305
+
306
+ Indicates if the item has to be displayed in the Settings Panel
307
+
308
+ ## `label` (string)
309
+
310
+ Indicates the label for the item that has to be displayed in the Settings Panel
311
+
312
+ ## `enabled` (boolean)
313
+
314
+ Indicates the value of the item if it affects config-ui
315
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
316
+
317
+ # `languageChoices` (object)
318
+
319
+ Language choices configuration
320
+ Only available if language is enabled
321
+
322
+ Properties of the `languageChoices` object:
323
+
324
+ ## `label` (string, required)
325
+
326
+ ## `options` (array, required)
327
+
328
+ The object is an array with all elements of the type `object`.
329
+
330
+ The array object has the following properties:
331
+
332
+ ### `value` (string, required)
333
+
334
+ Value of the language option
335
+
336
+ ### `label` (string, required)
337
+
338
+ Label of the language option
339
+
288
340
  # `showPrompt` (boolean)
289
341
 
290
342
  Determines whether prompt field will be displayed or not
@@ -297,6 +349,46 @@ The label for the item stem/prompt field
297
349
 
298
350
  Default: `"Item Stemm"`
299
351
 
352
+ # `contentDimensions` (object)
353
+
354
+ Indicates the dimensions configuration for the authoring container
355
+ Note: Some items have a default minimum width because of their content, but if
356
+ the minWidth is lower than this, the overflow behavior will take care of that
357
+
358
+ Properties of the `contentDimensions` object:
359
+
360
+ ## `maxHeight` (string,number)
361
+
362
+ Indicates the max height of the authoring container
363
+
364
+ Default: `"undefined"`
365
+
366
+ ## `maxWidth` (string,number)
367
+
368
+ Indicates the max width of the authoring container
369
+
370
+ Default: `"undefined"`
371
+
372
+ ## `minHeight` (string,number)
373
+
374
+ Indicates the min height of the authoring container
375
+
376
+ Default: `"undefined"`
377
+
378
+ ## `minWidth` (string,number)
379
+
380
+ Indicates the min width of the authoring container
381
+
382
+ Default: `"undefined"`
383
+
384
+ Default: `": {}"`
385
+
386
+ # `settingsPartialScoring` (boolean)
387
+
388
+ Indicates whether the settings panel wil allow the author to modify settings for partial scoring
389
+
390
+ Default: `true`
391
+
300
392
  ---
301
393
 
302
394
  # Sub Schemas
@@ -350,4 +442,28 @@ Indicates the max dimension for images in rationale
350
442
 
351
443
  ### `choices` (number)
352
444
 
353
- Indicates the max dimension for images in choices
445
+ Indicates the max dimension for images in choices
446
+
447
+ ## `ConfigureMathMLProp` (object)
448
+
449
+ Properties of the `ConfigureMathMLProp` object:
450
+
451
+ ### `mmlOutput` (number)
452
+
453
+ Indicates if model should have mathML output instead of latex
454
+
455
+ ### `mmlEditing` (number)
456
+
457
+ Indicates if mathML that's already in model should be editable
458
+
459
+ ## `ConfigureLanguageOptionsProp` (object)
460
+
461
+ Properties of the `ConfigureLanguageOptionsProp` object:
462
+
463
+ ### `value` (string, required)
464
+
465
+ Value of the language option
466
+
467
+ ### `label` (string, required)
468
+
469
+ Label of the language option
@@ -46,8 +46,7 @@ exports.model = (id, element) => ({
46
46
  accessibility: 'finland',
47
47
  },
48
48
  ],
49
- prompt:
50
- 'Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>',
49
+ prompt: "",
51
50
  promptEnabled: true,
52
51
  toolbarEditorPosition: 'bottom',
53
52
  rubricEnabled: false,
@@ -188,6 +188,11 @@
188
188
  "type": "boolean",
189
189
  "title": "rubricEnabled"
190
190
  },
191
+ "language": {
192
+ "description": "Indicates the language of the component\nSupported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX",
193
+ "type": "string",
194
+ "title": "language"
195
+ },
191
196
  "id": {
192
197
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
193
198
  "type": "string",
@@ -275,6 +280,42 @@
275
280
  }
276
281
  }
277
282
  },
283
+ "ConfigureMathMLProp": {
284
+ "title": "ConfigureMathMLProp",
285
+ "type": "object",
286
+ "properties": {
287
+ "mmlOutput": {
288
+ "description": "Indicates if model should have mathML output instead of latex",
289
+ "type": "number",
290
+ "title": "mmlOutput"
291
+ },
292
+ "mmlEditing": {
293
+ "description": "Indicates if mathML that's already in model should be editable",
294
+ "type": "number",
295
+ "title": "mmlEditing"
296
+ }
297
+ }
298
+ },
299
+ "ConfigureLanguageOptionsProp": {
300
+ "title": "ConfigureLanguageOptionsProp",
301
+ "type": "object",
302
+ "properties": {
303
+ "value": {
304
+ "description": "Value of the language option",
305
+ "type": "string",
306
+ "title": "value"
307
+ },
308
+ "label": {
309
+ "description": "Label of the language option",
310
+ "type": "string",
311
+ "title": "label"
312
+ }
313
+ },
314
+ "required": [
315
+ "label",
316
+ "value"
317
+ ]
318
+ },
278
319
  "Choice": {
279
320
  "title": "Choice",
280
321
  "type": "object",
@@ -162,6 +162,11 @@ Indicates if Accessibility Labels are enabled
162
162
 
163
163
  Indicates if Rubric is enabled
164
164
 
165
+ # `language` (string)
166
+
167
+ Indicates the language of the component
168
+ Supported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX
169
+
165
170
  # `id` (string, required)
166
171
 
167
172
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -225,6 +230,30 @@ Indicates the max dimension for images in rationale
225
230
 
226
231
  Indicates the max dimension for images in choices
227
232
 
233
+ ## `ConfigureMathMLProp` (object)
234
+
235
+ Properties of the `ConfigureMathMLProp` object:
236
+
237
+ ### `mmlOutput` (number)
238
+
239
+ Indicates if model should have mathML output instead of latex
240
+
241
+ ### `mmlEditing` (number)
242
+
243
+ Indicates if mathML that's already in model should be editable
244
+
245
+ ## `ConfigureLanguageOptionsProp` (object)
246
+
247
+ Properties of the `ConfigureLanguageOptionsProp` object:
248
+
249
+ ### `value` (string, required)
250
+
251
+ Value of the language option
252
+
253
+ ### `label` (string, required)
254
+
255
+ Label of the language option
256
+
228
257
  ## `Choice` (object)
229
258
 
230
259
  Properties of the `Choice` object:
@@ -33,7 +33,7 @@ var _styles = require("@material-ui/core/styles");
33
33
 
34
34
  var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
35
35
 
36
- var _renderUi = require("@pie-lib/render-ui");
36
+ var _renderUi = require("@pie-lib/pie-toolbox/render-ui");
37
37
 
38
38
  var _feedbackTick = _interopRequireDefault(require("./feedback-tick"));
39
39
 
@@ -51,7 +51,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
51
51
 
52
52
  var CLASS_NAME = 'multiple-choice-component';
53
53
 
54
- var styleSheet = function styleSheet() {
54
+ var styleSheet = function styleSheet(theme) {
55
55
  return {
56
56
  row: {
57
57
  display: 'flex',
@@ -64,11 +64,14 @@ var styleSheet = function styleSheet() {
64
64
  backgroundColor: _renderUi.color.background(),
65
65
  flex: 1,
66
66
  '& label': {
67
- color: _renderUi.color.text()
67
+ color: _renderUi.color.text(),
68
+ '& > span': {
69
+ fontSize: 'inherit'
70
+ }
68
71
  }
69
72
  },
70
73
  horizontalLayout: (0, _defineProperty2["default"])({}, "& .".concat(CLASS_NAME), {
71
- paddingRight: '8px'
74
+ paddingRight: theme.spacing.unit
72
75
  })
73
76
  };
74
77
  };
@@ -125,7 +128,9 @@ var StyledCheckbox = (0, _styles.withStyles)(inputStyles)(function (props) {
125
128
  checked = props.checked,
126
129
  onChange = props.onChange,
127
130
  disabled = props.disabled,
128
- accessibility = props.accessibility;
131
+ accessibility = props.accessibility,
132
+ value = props.value,
133
+ id = props.id;
129
134
 
130
135
  var key = function key(k) {
131
136
  return correctness ? "".concat(correctness, "-").concat(k) : k;
@@ -139,10 +144,13 @@ var StyledCheckbox = (0, _styles.withStyles)(inputStyles)(function (props) {
139
144
  var miniProps = {
140
145
  checked: checked,
141
146
  onChange: onChange,
142
- disabled: disabled
147
+ disabled: disabled,
148
+ value: value
143
149
  };
144
150
  return /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], (0, _extends2["default"])({
145
- "aria-label": accessibility
151
+ id: id,
152
+ "aria-label": accessibility,
153
+ "aria-checked": checked
146
154
  }, miniProps, {
147
155
  className: CLASS_NAME,
148
156
  classes: {
@@ -159,7 +167,9 @@ var StyledRadio = (0, _styles.withStyles)(inputStyles)(function (props) {
159
167
  checked = props.checked,
160
168
  onChange = props.onChange,
161
169
  disabled = props.disabled,
162
- accessibility = props.accessibility;
170
+ accessibility = props.accessibility,
171
+ value = props.value,
172
+ id = props.id;
163
173
 
164
174
  var key = function key(k) {
165
175
  return correctness ? "".concat(correctness, "-").concat(k) : k;
@@ -173,10 +183,13 @@ var StyledRadio = (0, _styles.withStyles)(inputStyles)(function (props) {
173
183
  var miniProps = {
174
184
  checked: checked,
175
185
  onChange: onChange,
176
- disabled: disabled
186
+ disabled: disabled,
187
+ value: value
177
188
  };
178
189
  return /*#__PURE__*/_react["default"].createElement(_Radio["default"], (0, _extends2["default"])({
179
- "aria-label": accessibility
190
+ id: id,
191
+ "aria-label": accessibility,
192
+ "aria-checked": checked
180
193
  }, miniProps, {
181
194
  className: CLASS_NAME,
182
195
  classes: {
@@ -199,17 +212,24 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
199
212
  (0, _classCallCheck2["default"])(this, ChoiceInput);
200
213
  _this = _super.call(this, props);
201
214
  _this.onToggleChoice = _this.onToggleChoice.bind((0, _assertThisInitialized2["default"])(_this));
215
+ _this.choiceId = _this.generateChoiceId();
202
216
  return _this;
203
217
  }
204
218
 
205
219
  (0, _createClass2["default"])(ChoiceInput, [{
206
220
  key: "onToggleChoice",
207
- value: function onToggleChoice() {
208
- this.props.onChange({
221
+ value: function onToggleChoice(event) {
222
+ this.props.onChange(event);
223
+ this.props.updateSession({
209
224
  value: this.props.value,
210
225
  selected: !this.props.checked
211
226
  });
212
227
  }
228
+ }, {
229
+ key: "generateChoiceId",
230
+ value: function generateChoiceId() {
231
+ return 'choice-' + (Math.random() * 10000).toFixed();
232
+ }
213
233
  }, {
214
234
  key: "render",
215
235
  value: function render() {
@@ -219,7 +239,6 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
219
239
  displayKey = _this$props.displayKey,
220
240
  feedback = _this$props.feedback,
221
241
  label = _this$props.label,
222
- checked = _this$props.checked,
223
242
  correctness = _this$props.correctness,
224
243
  classes = _this$props.classes,
225
244
  className = _this$props.className,
@@ -227,10 +246,25 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
227
246
  accessibility = _this$props.accessibility,
228
247
  hideTick = _this$props.hideTick,
229
248
  isEvaluateMode = _this$props.isEvaluateMode,
230
- choicesLayout = _this$props.choicesLayout;
249
+ choicesLayout = _this$props.choicesLayout,
250
+ value = _this$props.value,
251
+ checked = _this$props.checked;
231
252
  var Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
232
253
  var classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';
233
254
  var holderClassNames = (0, _classnames["default"])(classes.checkboxHolder, (0, _defineProperty2["default"])({}, classes.horizontalLayout, choicesLayout === 'horizontal'));
255
+
256
+ var choicelabel = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, displayKey ? /*#__PURE__*/_react["default"].createElement("span", {
257
+ className: classes.row
258
+ }, displayKey, ".", "\xA0", /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
259
+ className: "label",
260
+ prompt: label,
261
+ tagName: "span"
262
+ })) : /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
263
+ className: "label",
264
+ prompt: label,
265
+ tagName: "span"
266
+ }));
267
+
234
268
  return /*#__PURE__*/_react["default"].createElement("div", {
235
269
  className: (0, _classnames["default"])(className, 'corespring-' + classSuffix, 'choice-input')
236
270
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -240,19 +274,18 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
240
274
  }), /*#__PURE__*/_react["default"].createElement("div", {
241
275
  className: (0, _classnames["default"])(holderClassNames, 'checkbox-holder')
242
276
  }, /*#__PURE__*/_react["default"].createElement(StyledFormControlLabel, {
243
- disabled: disabled,
244
- label: displayKey ? displayKey + '. ' : '',
277
+ label: choicelabel,
278
+ value: value,
279
+ htmlFor: this.choiceId,
245
280
  control: /*#__PURE__*/_react["default"].createElement(Tag, {
246
281
  accessibility: accessibility,
282
+ disabled: disabled,
247
283
  checked: checked,
248
284
  correctness: correctness,
285
+ value: value,
286
+ id: this.choiceId,
249
287
  onChange: this.onToggleChoice
250
288
  })
251
- }), /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
252
- className: "label",
253
- onClick: this.onToggleChoice,
254
- prompt: label,
255
- tagName: "span"
256
289
  }))), rationale && /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
257
290
  className: "rationale",
258
291
  defaultClassName: "rationale",
@@ -283,7 +316,8 @@ exports.ChoiceInput = ChoiceInput;
283
316
  className: _propTypes["default"].string,
284
317
  hideTick: _propTypes["default"].bool,
285
318
  isEvaluateMode: _propTypes["default"].bool,
286
- choicesLayout: _propTypes["default"].oneOf(['vertical', 'grid', 'horizontal'])
319
+ choicesLayout: _propTypes["default"].oneOf(['vertical', 'grid', 'horizontal']),
320
+ updateSession: _propTypes["default"].func
287
321
  });
288
322
  (0, _defineProperty2["default"])(ChoiceInput, "defaultProps", {
289
323
  rationale: null,