@pie-element/multiple-choice 6.2.6 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.3.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@6.3.0...@pie-element/multiple-choice@6.3.1) (2022-05-09)
7
+
8
+ **Note:** Version bump only for package @pie-element/multiple-choice
9
+
10
+
11
+
12
+
13
+
14
+ # [6.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@6.2.7...@pie-element/multiple-choice@6.3.0) (2022-05-03)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * build ([7b3a278](https://github.com/pie-framework/pie-elements/commit/7b3a278f2c83562cbe848bd08c38a20d6cd2b8a0))
20
+ * fix crash ([0b5ab48](https://github.com/pie-framework/pie-elements/commit/0b5ab48ecf0468ac7fb724a152a5640dc25fea62))
21
+ * **multiple-choice:** comment validation ui/ux ([89e731c](https://github.com/pie-framework/pie-elements/commit/89e731c549a3da60f4dcbdb2e131d53a4587b5ea))
22
+ * added getters for the session PD-1668 ([de8a754](https://github.com/pie-framework/pie-elements/commit/de8a754f4580370b127257c435e43db405b4bdc4))
23
+ * **multiple-choice:** set choices layout for print PD-1623 ([ed90d57](https://github.com/pie-framework/pie-elements/commit/ed90d578da7d8db040082e93e718357a60dd8881))
24
+ * **multiple-choice:** set lockChoiceOrder to true for print ([5de2c75](https://github.com/pie-framework/pie-elements/commit/5de2c751b7a6cc63d54d4c8a1bbfb7adab4d2c00))
25
+
26
+
27
+ ### Features
28
+
29
+ * **multiple-choice:** PD-1697 ui/ux for validation ([9a088a3](https://github.com/pie-framework/pie-elements/commit/9a088a3d4af75586d6b8e302078c8629a3e7d718))
30
+ * **multiple-choice:** updated validation behaviors PD-1696 PD-1697 ([ab009c4](https://github.com/pie-framework/pie-elements/commit/ab009c4832572dab96c5b4130a5088dea17222e6))
31
+ * added configurable validation ([1e3a0d6](https://github.com/pie-framework/pie-elements/commit/1e3a0d6da3c790e68a7fd401df2c832917d62480))
32
+ * added configurable validation + refactoring PD-1696 ([31f6354](https://github.com/pie-framework/pie-elements/commit/31f6354b256fef876fa6c48e79a3f82486b5fce7))
33
+ * added configurable validation + refactoring PD-1696 ([08d9b70](https://github.com/pie-framework/pie-elements/commit/08d9b70991f159707ef7fd5b3e533a0addda1d90))
34
+ * added configurable validation + refactoring PD-1696 ([07c42c2](https://github.com/pie-framework/pie-elements/commit/07c42c2811349d1e829d367993541157fbbe2dfc))
35
+ * start working on multiple-choice validation ([722037b](https://github.com/pie-framework/pie-elements/commit/722037bc0fddd2e090ec1506e85a91949ad86c91))
36
+
37
+
38
+
39
+
40
+
41
+ ## [6.2.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@6.2.6...@pie-element/multiple-choice@6.2.7) (2022-04-12)
42
+
43
+ **Note:** Version bump only for package @pie-element/multiple-choice
44
+
45
+
46
+
47
+
48
+
6
49
  ## [6.2.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@6.2.5...@pie-element/multiple-choice@6.2.6) (2022-03-28)
7
50
 
8
51
  **Note:** Version bump only for package @pie-element/multiple-choice
@@ -3,6 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@4.2.0...@pie-element/multiple-choice-configure@4.2.1) (2022-05-09)
7
+
8
+ **Note:** Version bump only for package @pie-element/multiple-choice-configure
9
+
10
+
11
+
12
+
13
+
14
+ # [4.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@4.1.7...@pie-element/multiple-choice-configure@4.2.0) (2022-05-03)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * build ([7b3a278](https://github.com/pie-framework/pie-elements/commit/7b3a278f2c83562cbe848bd08c38a20d6cd2b8a0))
20
+ * fix crash ([0b5ab48](https://github.com/pie-framework/pie-elements/commit/0b5ab48ecf0468ac7fb724a152a5640dc25fea62))
21
+ * **multiple-choice:** comment validation ui/ux ([89e731c](https://github.com/pie-framework/pie-elements/commit/89e731c549a3da60f4dcbdb2e131d53a4587b5ea))
22
+
23
+
24
+ ### Features
25
+
26
+ * **multiple-choice:** PD-1697 ui/ux for validation ([9a088a3](https://github.com/pie-framework/pie-elements/commit/9a088a3d4af75586d6b8e302078c8629a3e7d718))
27
+ * **multiple-choice:** updated validation behaviors PD-1696 PD-1697 ([ab009c4](https://github.com/pie-framework/pie-elements/commit/ab009c4832572dab96c5b4130a5088dea17222e6))
28
+
29
+
30
+
31
+
32
+
33
+ ## [4.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@4.1.6...@pie-element/multiple-choice-configure@4.1.7) (2022-04-12)
34
+
35
+ **Note:** Version bump only for package @pie-element/multiple-choice-configure
36
+
37
+
38
+
39
+
40
+
6
41
  ## [4.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@4.1.5...@pie-element/multiple-choice-configure@4.1.6) (2022-03-28)
7
42
 
8
43
  **Note:** Version bump only for package @pie-element/multiple-choice-configure
@@ -47,6 +47,12 @@ var _DialogTitle = _interopRequireDefault(require("@material-ui/core/DialogTitle
47
47
 
48
48
  var _DialogActions = _interopRequireDefault(require("@material-ui/core/DialogActions"));
49
49
 
50
+ var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
51
+
52
+ var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
53
+
54
+ var _utils = require("./utils");
55
+
50
56
  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); }; }
51
57
 
52
58
  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; } }
@@ -114,6 +120,28 @@ var styles = function styles(theme) {
114
120
  '&:focus': {
115
121
  backgroundColor: _renderUi.color.disabled()
116
122
  }
123
+ },
124
+ flexContainer: {
125
+ display: 'flex',
126
+ alignItems: 'center',
127
+ marginBottom: '5px'
128
+ },
129
+ titleText: {
130
+ fontFamily: 'Cerebri Sans',
131
+ fontSize: '18px',
132
+ lineHeight: '19px',
133
+ color: '#495B8F',
134
+ marginRight: '5px'
135
+ },
136
+ tooltip: {
137
+ fontSize: '12px',
138
+ whiteSpace: 'pre',
139
+ maxWidth: '500px'
140
+ },
141
+ errorText: {
142
+ fontSize: '12px',
143
+ color: 'red',
144
+ paddingTop: '5px'
117
145
  }
118
146
  };
119
147
  };
@@ -177,7 +205,13 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
177
205
  feedbackEnabled = _ref3.feedbackEnabled,
178
206
  promptEnabled = _ref3.promptEnabled,
179
207
  spellCheckEnabled = _ref3.spellCheckEnabled,
180
- choices = _ref3.choices;
208
+ choices = _ref3.choices,
209
+ errors = _ref3.errors;
210
+
211
+ var _ref4 = errors || {},
212
+ choicesErrors = _ref4.choicesErrors,
213
+ correctResponseError = _ref4.correctResponseError,
214
+ answerChoicesError = _ref4.answerChoicesError;
181
215
 
182
216
  var nrOfColumnsAvailable = choices && choices.length ? Array.from({
183
217
  length: choices.length
@@ -209,6 +243,8 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
209
243
  maxAnswerChoices = MAX_CHOICES;
210
244
  }
211
245
 
246
+ var validationMessage = (0, _utils.generateValidationMessage)(configuration);
247
+
212
248
  var Content = /*#__PURE__*/_react["default"].createElement("div", null, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
213
249
  label: teacherInstructions.label,
214
250
  className: classes.promptHolder
@@ -232,7 +268,26 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
232
268
  disableUnderline: true,
233
269
  toolbarOpts: toolbarOpts,
234
270
  spellCheck: spellCheckEnabled
235
- })), model.choices.map(function (choice, index) {
271
+ })), /*#__PURE__*/_react["default"].createElement("div", {
272
+ className: classes.flexContainer
273
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
274
+ className: classes.titleText
275
+ }, "Choices"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
276
+ classes: {
277
+ tooltip: classes.tooltip
278
+ },
279
+ disableFocusListener: true,
280
+ disableTouchListener: true,
281
+ placement: 'right',
282
+ title: validationMessage
283
+ }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
284
+ fontSize: 'small',
285
+ color: 'primary'
286
+ }))), correctResponseError && /*#__PURE__*/_react["default"].createElement("div", {
287
+ className: classes.errorText
288
+ }, correctResponseError), answerChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
289
+ className: classes.errorText
290
+ }, answerChoicesError), choices.map(function (choice, index) {
236
291
  return /*#__PURE__*/_react["default"].createElement("div", {
237
292
  key: "choice-".concat(index),
238
293
  className: classes.choiceConfigurationHolder
@@ -255,7 +310,9 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
255
310
  allowDelete: deleteChoice.settings,
256
311
  noLabels: true,
257
312
  toolbarOpts: toolbarOpts,
258
- spellCheck: spellCheckEnabled
313
+ spellCheck: spellCheckEnabled,
314
+ error: choicesErrors && choicesErrors[choice.value] ? choicesErrors[choice.value] : null,
315
+ noCorrectAnswerError: correctResponseError
259
316
  }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
260
317
  key: "rationale-".concat(index),
261
318
  label: rationale.label,
@@ -295,7 +352,7 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
295
352
  }
296
353
  }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
297
354
  classes: {
298
- root: maxAnswerChoices && model.choices.length >= maxAnswerChoices ? classes.disableButton : undefined
355
+ root: maxAnswerChoices && model.choices.length >= maxAnswerChoices && classes.disableButton
299
356
  },
300
357
  className: classes.addButton,
301
358
  variant: "contained",
@@ -337,11 +394,11 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
337
394
  }, Content));
338
395
  });
339
396
 
340
- var InfoDialog = function InfoDialog(_ref4) {
341
- var open = _ref4.open,
342
- onCancel = _ref4.onCancel,
343
- onOk = _ref4.onOk,
344
- title = _ref4.title;
397
+ var InfoDialog = function InfoDialog(_ref5) {
398
+ var open = _ref5.open,
399
+ onCancel = _ref5.onCancel,
400
+ onOk = _ref5.onOk,
401
+ title = _ref5.title;
345
402
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
346
403
  open: open
347
404
  }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, onOk && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
@@ -385,8 +442,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
385
442
  model = _this$props.model,
386
443
  configuration = _this$props.configuration;
387
444
 
388
- var _ref5 = configuration || {},
389
- minAnswerChoices = _ref5.minAnswerChoices;
445
+ var _ref6 = configuration || {},
446
+ minAnswerChoices = _ref6.minAnswerChoices;
390
447
 
391
448
  if (minAnswerChoices && model.choices.length === minAnswerChoices) {
392
449
  _this.setState({
@@ -399,13 +456,6 @@ var Main = /*#__PURE__*/function (_React$Component) {
399
456
  open: false
400
457
  }
401
458
  });
402
- },
403
- onCancel: function onCancel() {
404
- return _this.setState({
405
- dialog: {
406
- open: false
407
- }
408
- });
409
459
  }
410
460
  }
411
461
  });
@@ -420,51 +470,32 @@ var Main = /*#__PURE__*/function (_React$Component) {
420
470
  model = _this$props2.model,
421
471
  configuration = _this$props2.configuration;
422
472
 
423
- var _ref6 = configuration || {},
424
- maxAnswerChoices = _ref6.maxAnswerChoices;
473
+ var _ref7 = configuration || {},
474
+ maxAnswerChoices = _ref7.maxAnswerChoices;
425
475
 
426
- var _ref7 = model || {},
427
- limitChoicesNumber = _ref7.limitChoicesNumber; // if old property is used, set maxAnswerChoices to 9
476
+ var _ref8 = model || {},
477
+ limitChoicesNumber = _ref8.limitChoicesNumber; // if old property is used, set maxAnswerChoices to 9
428
478
 
429
479
 
430
480
  if (limitChoicesNumber) {
431
481
  maxAnswerChoices = MAX_CHOICES;
432
482
  }
433
483
 
434
- if (maxAnswerChoices && model.choices.length === maxAnswerChoices) {
435
- _this.setState({
436
- dialog: {
437
- open: true,
438
- message: "There can't be more than ".concat(maxAnswerChoices, " choices."),
439
- onOk: function onOk() {
440
- _this.setState({
441
- dialog: {
442
- open: false
443
- }
444
- });
445
- },
446
- onCancel: function onCancel() {
447
- return _this.setState({
448
- dialog: {
449
- open: false
450
- }
451
- });
452
- }
453
- }
454
- });
455
- } else {
456
- model.choices.push({
457
- label: '',
458
- value: _configUi.choiceUtils.firstAvailableIndex(model.choices.map(function (c) {
459
- return c.value;
460
- }), 0),
461
- feedback: {
462
- type: 'none'
463
- }
464
- });
465
-
466
- _this.props.onModelChanged(model);
484
+ if (maxAnswerChoices && model.choices.length >= maxAnswerChoices) {
485
+ return;
467
486
  }
487
+
488
+ model.choices.push({
489
+ label: '',
490
+ value: _configUi.choiceUtils.firstAvailableIndex(model.choices.map(function (c) {
491
+ return c.value;
492
+ }), 0),
493
+ feedback: {
494
+ type: 'none'
495
+ }
496
+ });
497
+
498
+ _this.props.onModelChanged(model);
468
499
  });
469
500
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (index, choice) {
470
501
  var model = _this.props.model;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["Panel","settings","toggle","radio","dropdown","MAX_CHOICES","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","rationaleHolder","accessibilityHolder","rationale","accessibility","design","choiceConfigurationHolder","display","flexDirection","alignItems","choiceConfiguration","switchElement","justifyContent","margin","addButton","disableButton","cursor","pointerEvents","backgroundColor","color","disabled","Design","props","classes","model","configuration","onPromptChanged","onChoiceChanged","onRemoveChoice","onAddChoice","imageSupport","onChangeModel","onConfigurationChanged","onTeacherInstructionsChanged","addChoiceButton","feedback","deleteChoice","choiceMode","choicePrefix","partialScoring","lockChoiceOrder","teacherInstructions","studentInstructions","scoringType","sequentialChoiceLabels","settingsPanelDisabled","choicesLayout","spellCheck","gridColumns","maxAnswerChoices","limitChoicesNumber","teacherInstructionsEnabled","rationaleEnabled","accessibilityLabelsEnabled","feedbackEnabled","promptEnabled","spellCheckEnabled","choices","nrOfColumnsAvailable","length","Array","from","_","i","labelPlugins","audio","video","toolbarOpts","toolbarEditorPosition","position","Content","label","map","choice","index","c","tooltip","root","undefined","settingsInPanel","Settings","Properties","studentInstructionsEnabled","InfoDialog","open","onCancel","onOk","title","propTypes","PropTypes","bool","func","string","Main","dialog","minAnswerChoices","setState","message","splice","onModelChanged","push","value","utils","firstAvailableIndex","type","correct","key","correctFound","state","React","Component","object","isRequired","disableSidePanel","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,KAAR,GAA2CC,kBAA3C,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA2CD,kBAA3C,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAA2CF,kBAA3C,CAAuBE,KAAvB;AAAA,IAA8BC,QAA9B,GAA2CH,kBAA3C,CAA8BG,QAA9B;AAEA,IAAMC,WAAW,GAAG,CAApB;;AAEA,IAAMC,MAAM,GAA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;AAII,QAAA,IAAI,EAAES,MAAM,CAACR;AAJjB,QADA,eAMI,gCAAC,MAAD,gCACI,KAAKhE,KADT;AAEA,QAAA,aAAa,EAAE,KAAK6E,cAFpB;AAGA,QAAA,cAAc,EAAE,KAAKvE,cAHrB;AAIA,QAAA,eAAe,EAAE,KAAKD,eAJtB;AAKA,QAAA,WAAW,EAAE,KAAKE,WALlB;AAMA,QAAA,eAAe,EAAE,KAAKH,eANtB;AAOA,QAAA,4BAA4B,EAAE,KAAKO;AAPnC,SANJ,CADF;AAiBD;;;EA9KuB4E,kBAAMC,S;;;iCAAnBjB,I,eACQ;AACjBrE,EAAAA,KAAK,EAAEiE,sBAAUsB,MAAV,CAAiBC,UADP;AAEjBvF,EAAAA,aAAa,EAAEgE,sBAAUsB,MAAV,CAAiBC,UAFf;AAGjBC,EAAAA,gBAAgB,EAAExB,sBAAUC,IAHX;AAIjBS,EAAAA,cAAc,EAAEV,sBAAUE,IAAV,CAAeqB,UAJd;AAKjBhF,EAAAA,sBAAsB,EAAEyD,sBAAUE,IAAV,CAAeqB,UALtB;AAMjBzF,EAAAA,OAAO,EAAEkE,sBAAUsB,MAAV,CAAiBC,UANT;AAOjBlF,EAAAA,YAAY,EAAE2D,sBAAUyB,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAE1B,sBAAUE,IAAV,CAAeqB,UADQ;AAE5B,cAAQvB,sBAAUE,IAAV,CAAeqB;AAFK,GAAhB;AAPG,C;AAgLrB,IAAMI,MAAM,GAAG,wBAAW7H,MAAX,EAAmBsG,IAAnB,CAAf;eAEeuB,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport {\n InputContainer,\n ChoiceConfiguration,\n settings,\n layout,\n choiceUtils as utils,\n} from '@pie-lib/config-ui';\nimport { color } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Button from '@material-ui/core/Button';\nimport merge from 'lodash/merge';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport DialogActions from '@material-ui/core/DialogActions';\n\nconst { Panel, toggle, radio, dropdown } = settings;\n\nconst MAX_CHOICES = 9;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n },\n rationaleHolder: {\n width: '70%',\n },\n accessibilityHolder: {\n width: '70%',\n },\n rationale: {\n paddingTop: theme.spacing.unit * 2,\n },\n accessibility: {\n paddingTop: theme.spacing.unit * 2,\n },\n design: {\n paddingTop: theme.spacing.unit * 3,\n },\n choiceConfigurationHolder: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n },\n choiceConfiguration: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0,\n },\n addButton: {\n float: 'right',\n },\n disableButton: {\n cursor: 'not-allowed',\n pointerEvents: 'all',\n backgroundColor: color.disabled(),\n '&:hover': {\n backgroundColor: color.disabled(),\n },\n '&:focus': {\n backgroundColor: color.disabled(),\n },\n },\n});\n\nconst Design = withStyles(styles)((props) => {\n const {\n classes,\n model,\n configuration,\n onPromptChanged,\n onChoiceChanged,\n onRemoveChoice,\n onAddChoice,\n imageSupport,\n onChangeModel,\n onConfigurationChanged,\n onTeacherInstructionsChanged,\n } = props;\n const {\n prompt = {},\n addChoiceButton = {},\n feedback = {},\n deleteChoice = {},\n choiceMode = {},\n choicePrefix = {},\n partialScoring = {},\n lockChoiceOrder = {},\n teacherInstructions = {},\n studentInstructions = {},\n rationale = {},\n accessibility = {},\n scoringType = {},\n sequentialChoiceLabels = {},\n settingsPanelDisabled,\n choicesLayout,\n spellCheck = {},\n gridColumns,\n } = configuration || {};\n let { maxAnswerChoices } = configuration || {};\n const {\n limitChoicesNumber,\n teacherInstructionsEnabled,\n rationaleEnabled,\n accessibilityLabelsEnabled,\n feedbackEnabled,\n promptEnabled,\n spellCheckEnabled,\n choices,\n } = model || {};\n\n const nrOfColumnsAvailable =\n choices && choices.length\n ? Array.from({ length: choices.length }, (_, i) => `${i + 1}`)\n : [];\n\n const labelPlugins = {\n audio: { disabled: true },\n video: { disabled: true },\n };\n\n const toolbarOpts = {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n // if old property is used, set maxAnswerChoices to 9\n if (limitChoicesNumber) {\n maxAnswerChoices = MAX_CHOICES;\n }\n\n const Content = (\n <div>\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n {model.choices.map((choice, index) => (\n <div\n key={`choice-${index}`}\n className={classes.choiceConfigurationHolder}\n >\n <ChoiceConfiguration\n key={index}\n index={index + 1}\n useLetterOrdering={model.choicePrefix === 'letters'}\n className={classes.choiceConfiguration}\n mode={model.choiceMode}\n data={choice}\n defaultFeedback={{}}\n imageSupport={imageSupport}\n onDelete={() => onRemoveChoice(index)}\n onChange={(c) => onChoiceChanged(index, c)}\n allowFeedBack={feedbackEnabled}\n allowDelete={deleteChoice.settings}\n noLabels\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n {rationaleEnabled && (\n <InputContainer\n key={`rationale-${index}`}\n label={rationale.label}\n className={classes.rationaleHolder}\n >\n <EditableHtml\n className={classes.rationale}\n markup={choice.rationale || ''}\n onChange={(c) =>\n onChoiceChanged(index, {\n ...choice,\n rationale: c,\n })\n }\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n pluginProps={labelPlugins}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n {accessibilityLabelsEnabled && (\n <InputContainer\n key={`accessibility-${index}`}\n label={accessibility.label}\n className={classes.accessibilityHolder}\n >\n <EditableHtml\n className={classes.accessibility}\n markup={choice.accessibility || ''}\n onChange={(c) =>\n onChoiceChanged(index, {\n ...choice,\n accessibility: c,\n })\n }\n imageSupport={imageSupport}\n pluginProps={labelPlugins}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n </div>\n ))}\n <br />\n {addChoiceButton.settings && (\n <Tooltip\n title={\n maxAnswerChoices && model.choices.length >= maxAnswerChoices\n ? `Only ${maxAnswerChoices} allowed maximum`\n : ''\n }\n classes={{ tooltip: classes.tooltip }}\n >\n <Button\n classes={{\n root:\n maxAnswerChoices && model.choices.length >= maxAnswerChoices\n ? classes.disableButton\n : undefined,\n }}\n className={classes.addButton}\n variant=\"contained\"\n color=\"primary\"\n onClick={onAddChoice}\n >\n {addChoiceButton.label}\n </Button>\n </Tooltip>\n )}\n </div>\n );\n\n const settingsInPanel = {\n choiceMode:\n choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),\n 'sequentialChoiceLabels.enabled':\n sequentialChoiceLabels.settings &&\n toggle(sequentialChoiceLabels.label, true),\n choicePrefix:\n choicePrefix.settings &&\n radio(choicePrefix.label, ['numbers', 'letters']),\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n feedbackEnabled: feedback.settings && toggle(feedback.label),\n choicesLayout:\n choicesLayout.settings &&\n dropdown(choicesLayout.label, ['vertical', 'grid', 'horizontal']),\n gridColumns:\n choicesLayout.settings &&\n model.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.length > 0 &&\n dropdown(gridColumns.label, nrOfColumnsAvailable),\n };\n\n return (\n <div className={classes.design}>\n {settingsPanelDisabled ? (\n Content\n ) : (\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onChangeModel}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: settingsInPanel,\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n accessibilityLabelsEnabled:\n accessibility.settings && toggle(accessibility.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, ['auto', 'rubric']),\n },\n }}\n />\n }\n >\n {Content}\n </layout.ConfigLayout>\n )}\n </div>\n );\n});\n\nconst InfoDialog = ({ open, onCancel, onOk, title }) => (\n <Dialog open={open}>\n <DialogTitle>{title}</DialogTitle>\n <DialogActions>\n {onOk && (\n <Button onClick={onOk} color=\"primary\">\n OK\n </Button>\n )}\n {onCancel && (\n <Button onClick={onCancel} color=\"primary\">\n Cancel\n </Button>\n )}\n </DialogActions>\n </Dialog>\n);\n\nInfoDialog.propTypes = {\n open: PropTypes.bool,\n onCancel: PropTypes.func,\n onOk: PropTypes.func,\n title: PropTypes.string,\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n state = {\n dialog: {\n open: false,\n },\n };\n\n onRemoveChoice = (index) => {\n const { model, configuration } = this.props;\n const { minAnswerChoices } = configuration || {};\n\n if (minAnswerChoices && model.choices.length === minAnswerChoices) {\n this.setState({\n dialog: {\n open: true,\n message: `There can't be less than ${minAnswerChoices} choices.`,\n onOk: () => {\n this.setState({\n dialog: {\n open: false,\n },\n });\n },\n onCancel: () =>\n this.setState({\n dialog: {\n open: false,\n },\n }),\n },\n });\n } else {\n model.choices.splice(index, 1);\n this.props.onModelChanged(model);\n }\n };\n\n onAddChoice = () => {\n const { model, configuration } = this.props;\n let { maxAnswerChoices } = configuration || {};\n const { limitChoicesNumber } = model || {};\n\n // if old property is used, set maxAnswerChoices to 9\n if (limitChoicesNumber) {\n maxAnswerChoices = MAX_CHOICES;\n }\n\n if (maxAnswerChoices && model.choices.length === maxAnswerChoices) {\n this.setState({\n dialog: {\n open: true,\n message: `There can't be more than ${maxAnswerChoices} choices.`,\n onOk: () => {\n this.setState({\n dialog: {\n open: false,\n },\n });\n },\n onCancel: () =>\n this.setState({\n dialog: {\n open: false,\n },\n }),\n },\n });\n } else {\n model.choices.push({\n label: '',\n value: utils.firstAvailableIndex(\n model.choices.map((c) => c.value),\n 0\n ),\n feedback: {\n type: 'none',\n },\n });\n\n this.props.onModelChanged(model);\n }\n };\n\n onChoiceChanged = (index, choice) => {\n const { model } = this.props;\n\n if (choice.correct && model.choiceMode === 'radio') {\n model.choices = model.choices.map((c) => {\n return merge({}, c, { correct: false });\n });\n }\n\n model.choices.splice(index, 1, choice);\n this.props.onModelChanged(model);\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({\n ...this.props.model,\n prompt,\n });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.props.onModelChanged({\n ...this.props.model,\n teacherInstructions,\n });\n };\n\n onModelChanged = (model, key) => {\n const { onModelChanged } = this.props;\n\n switch (key) {\n case 'choiceMode': {\n let value = model.choiceMode;\n\n if (value === 'radio') {\n let correctFound = false;\n\n model.choices = model.choices.map((c) => {\n if (correctFound) {\n c.correct = false;\n return c;\n }\n\n if (c.correct) {\n correctFound = true;\n }\n return c;\n });\n }\n onModelChanged(model, true);\n break;\n }\n default:\n onModelChanged(model);\n break;\n }\n };\n\n render() {\n const { dialog } = this.state;\n\n return (\n <>\n <InfoDialog\n open={dialog.open}\n title={dialog.message}\n onCancel={dialog.onCancel}\n onOk={dialog.onOk}\n /><Design\n {...this.props}\n onChangeModel={this.onModelChanged}\n onRemoveChoice={this.onRemoveChoice}\n onChoiceChanged={this.onChoiceChanged}\n onAddChoice={this.onAddChoice}\n onPromptChanged={this.onPromptChanged}\n onTeacherInstructionsChanged={this.onTeacherInstructionsChanged}\n /></>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["Panel","settings","toggle","radio","dropdown","MAX_CHOICES","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","rationaleHolder","accessibilityHolder","rationale","accessibility","design","choiceConfigurationHolder","display","flexDirection","alignItems","choiceConfiguration","switchElement","justifyContent","margin","addButton","disableButton","cursor","pointerEvents","backgroundColor","color","disabled","flexContainer","titleText","fontFamily","fontSize","lineHeight","marginRight","tooltip","whiteSpace","maxWidth","errorText","Design","props","classes","model","configuration","onPromptChanged","onChoiceChanged","onRemoveChoice","onAddChoice","imageSupport","onChangeModel","onConfigurationChanged","onTeacherInstructionsChanged","addChoiceButton","feedback","deleteChoice","choiceMode","choicePrefix","partialScoring","lockChoiceOrder","teacherInstructions","studentInstructions","scoringType","sequentialChoiceLabels","settingsPanelDisabled","choicesLayout","spellCheck","gridColumns","maxAnswerChoices","limitChoicesNumber","teacherInstructionsEnabled","rationaleEnabled","accessibilityLabelsEnabled","feedbackEnabled","promptEnabled","spellCheckEnabled","choices","errors","choicesErrors","correctResponseError","answerChoicesError","nrOfColumnsAvailable","length","Array","from","_","i","labelPlugins","audio","video","toolbarOpts","toolbarEditorPosition","position","validationMessage","Content","label","map","choice","index","c","value","root","settingsInPanel","Settings","Properties","studentInstructionsEnabled","InfoDialog","open","onCancel","onOk","title","propTypes","PropTypes","bool","func","string","Main","dialog","minAnswerChoices","setState","message","splice","onModelChanged","push","utils","firstAvailableIndex","type","correct","key","correctFound","state","React","Component","object","isRequired","disableSidePanel","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,KAAR,GAA2CC,kBAA3C,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA2CD,kBAA3C,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAA2CF,kBAA3C,CAAuBE,KAAvB;AAAA,IAA8BC,QAA9B,GAA2CH,kBAA3C,CAA8BG,QAA9B;AAEA,IAAMC,WAAW,GAAG,CAApB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,aAAa,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADW;AAMzBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENH,MAAAA,KAAK,EAAE;AAFD,KANiB;AAUzBO,IAAAA,eAAe,EAAE;AACfP,MAAAA,KAAK,EAAE;AADQ,KAVQ;AAazBQ,IAAAA,mBAAmB,EAAE;AACnBR,MAAAA,KAAK,EAAE;AADY,KAbI;AAgBzBS,IAAAA,SAAS,EA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AAV,CAAiBC,UANT;AAOjBrF,EAAAA,YAAY,EAAE+D,sBAAUwB,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEzB,sBAAUE,IAAV,CAAeoB,UADQ;AAE5B,cAAQtB,sBAAUE,IAAV,CAAeoB;AAFK,GAAhB;AAPG,C;AAwJrB,IAAMI,MAAM,GAAG,wBAAW1I,MAAX,EAAmBoH,IAAnB,CAAf;eAEesB,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport {\n InputContainer,\n ChoiceConfiguration,\n settings,\n layout,\n choiceUtils as utils,\n} from '@pie-lib/config-ui';\nimport { color } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Button from '@material-ui/core/Button';\nimport merge from 'lodash/merge';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport { generateValidationMessage } from './utils';\n\nconst { Panel, toggle, radio, dropdown } = settings;\n\nconst MAX_CHOICES = 9;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n },\n rationaleHolder: {\n width: '70%',\n },\n accessibilityHolder: {\n width: '70%',\n },\n rationale: {\n paddingTop: theme.spacing.unit * 2,\n },\n accessibility: {\n paddingTop: theme.spacing.unit * 2,\n },\n design: {\n paddingTop: theme.spacing.unit * 3,\n },\n choiceConfigurationHolder: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n },\n choiceConfiguration: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0,\n },\n addButton: {\n float: 'right',\n },\n disableButton: {\n cursor: 'not-allowed',\n pointerEvents: 'all',\n backgroundColor: color.disabled(),\n '&:hover': {\n backgroundColor: color.disabled(),\n },\n '&:focus': {\n backgroundColor: color.disabled(),\n },\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\n marginBottom: '5px'\n },\n titleText: {\n fontFamily: 'Cerebri Sans',\n fontSize: '18px',\n lineHeight: '19px',\n color: '#495B8F',\n marginRight: '5px'\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px'\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n paddingTop: '5px'\n }\n});\n\nconst Design = withStyles(styles)((props) => {\n const {\n classes,\n model,\n configuration,\n onPromptChanged,\n onChoiceChanged,\n onRemoveChoice,\n onAddChoice,\n imageSupport,\n onChangeModel,\n onConfigurationChanged,\n onTeacherInstructionsChanged,\n } = props;\n const {\n prompt = {},\n addChoiceButton = {},\n feedback = {},\n deleteChoice = {},\n choiceMode = {},\n choicePrefix = {},\n partialScoring = {},\n lockChoiceOrder = {},\n teacherInstructions = {},\n studentInstructions = {},\n rationale = {},\n accessibility = {},\n scoringType = {},\n sequentialChoiceLabels = {},\n settingsPanelDisabled,\n choicesLayout,\n spellCheck = {},\n gridColumns\n } = configuration || {};\n let { maxAnswerChoices } = configuration || {};\n const {\n limitChoicesNumber,\n teacherInstructionsEnabled,\n rationaleEnabled,\n accessibilityLabelsEnabled,\n feedbackEnabled,\n promptEnabled,\n spellCheckEnabled,\n choices,\n errors\n } = model || {};\n\n const { choicesErrors, correctResponseError, answerChoicesError } = errors || {};\n const nrOfColumnsAvailable = choices && choices.length\n ? Array.from({ length: choices.length }, (_, i) => `${i + 1}`)\n : [];\n\n const labelPlugins = {\n audio: { disabled: true },\n video: { disabled: true },\n };\n\n const toolbarOpts = {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n // if old property is used, set maxAnswerChoices to 9\n if (limitChoicesNumber) {\n maxAnswerChoices = MAX_CHOICES;\n }\n\n const validationMessage = generateValidationMessage(configuration);\n\n const Content = (\n <div>\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n <div className={classes.flexContainer}>\n <Typography className={classes.titleText}>Choices</Typography>\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'}/>\n </Tooltip>\n </div>\n {correctResponseError && <div className={classes.errorText}>{correctResponseError}</div>}\n {answerChoicesError && <div className={classes.errorText}>{answerChoicesError}</div>}\n {choices.map((choice, index) => (\n <div\n key={`choice-${index}`}\n className={classes.choiceConfigurationHolder}\n >\n <ChoiceConfiguration\n key={index}\n index={index + 1}\n useLetterOrdering={model.choicePrefix === 'letters'}\n className={classes.choiceConfiguration}\n mode={model.choiceMode}\n data={choice}\n defaultFeedback={{}}\n imageSupport={imageSupport}\n onDelete={() => onRemoveChoice(index)}\n onChange={(c) => onChoiceChanged(index, c)}\n allowFeedBack={feedbackEnabled}\n allowDelete={deleteChoice.settings}\n noLabels\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n error={choicesErrors && choicesErrors[choice.value] ? choicesErrors[choice.value] : null}\n noCorrectAnswerError={correctResponseError}\n />\n {rationaleEnabled && (\n <InputContainer\n key={`rationale-${index}`}\n label={rationale.label}\n className={classes.rationaleHolder}\n >\n <EditableHtml\n className={classes.rationale}\n markup={choice.rationale || ''}\n onChange={(c) =>\n onChoiceChanged(index, {\n ...choice,\n rationale: c,\n })\n }\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n pluginProps={labelPlugins}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n {accessibilityLabelsEnabled && (\n <InputContainer\n key={`accessibility-${index}`}\n label={accessibility.label}\n className={classes.accessibilityHolder}\n >\n <EditableHtml\n className={classes.accessibility}\n markup={choice.accessibility || ''}\n onChange={(c) =>\n onChoiceChanged(index, {\n ...choice,\n accessibility: c,\n })\n }\n imageSupport={imageSupport}\n pluginProps={labelPlugins}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n </div>\n ))}\n <br/>\n {addChoiceButton.settings && (\n <Tooltip\n title={\n maxAnswerChoices && model.choices.length >= maxAnswerChoices\n ? `Only ${maxAnswerChoices} allowed maximum`\n : ''\n }\n classes={{ tooltip: classes.tooltip }}\n >\n <Button\n classes={{ root: maxAnswerChoices && model.choices.length >= maxAnswerChoices && classes.disableButton }}\n className={classes.addButton}\n variant=\"contained\"\n color=\"primary\"\n onClick={onAddChoice}\n >\n {addChoiceButton.label}\n </Button>\n </Tooltip>\n )}\n </div>\n );\n\n const settingsInPanel = {\n choiceMode:\n choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),\n 'sequentialChoiceLabels.enabled':\n sequentialChoiceLabels.settings &&\n toggle(sequentialChoiceLabels.label, true),\n choicePrefix:\n choicePrefix.settings &&\n radio(choicePrefix.label, ['numbers', 'letters']),\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n feedbackEnabled: feedback.settings && toggle(feedback.label),\n choicesLayout:\n choicesLayout.settings &&\n dropdown(choicesLayout.label, ['vertical', 'grid', 'horizontal']),\n gridColumns:\n choicesLayout.settings &&\n model.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.length > 0 &&\n dropdown(gridColumns.label, nrOfColumnsAvailable),\n };\n\n return (\n <div className={classes.design}>\n {settingsPanelDisabled ? (\n Content\n ) : (\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onChangeModel}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: settingsInPanel,\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n accessibilityLabelsEnabled:\n accessibility.settings && toggle(accessibility.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, ['auto', 'rubric']),\n },\n }}\n />\n }\n >\n {Content}\n </layout.ConfigLayout>\n )}\n </div>\n );\n});\n\nconst InfoDialog = ({ open, onCancel, onOk, title }) => (\n <Dialog open={open}>\n <DialogTitle>{title}</DialogTitle>\n <DialogActions>\n {onOk && (\n <Button onClick={onOk} color=\"primary\">\n OK\n </Button>\n )}\n {onCancel && (\n <Button onClick={onCancel} color=\"primary\">\n Cancel\n </Button>\n )}\n </DialogActions>\n </Dialog>\n);\n\nInfoDialog.propTypes = {\n open: PropTypes.bool,\n onCancel: PropTypes.func,\n onOk: PropTypes.func,\n title: PropTypes.string,\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n state = {\n dialog: {\n open: false,\n },\n };\n\n onRemoveChoice = (index) => {\n const { model, configuration } = this.props;\n const { minAnswerChoices } = configuration || {};\n\n if (minAnswerChoices && model.choices.length === minAnswerChoices) {\n this.setState({\n dialog: {\n open: true,\n message: `There can't be less than ${minAnswerChoices} choices.`,\n onOk: () => {\n this.setState({\n dialog: {\n open: false,\n },\n });\n }\n }\n });\n } else {\n model.choices.splice(index, 1);\n this.props.onModelChanged(model);\n }\n };\n\n onAddChoice = () => {\n const { model, configuration } = this.props;\n let { maxAnswerChoices } = configuration || {};\n const { limitChoicesNumber } = model || {};\n\n // if old property is used, set maxAnswerChoices to 9\n if (limitChoicesNumber) {\n maxAnswerChoices = MAX_CHOICES;\n }\n\n if (maxAnswerChoices && model.choices.length >= maxAnswerChoices) {\n return;\n }\n\n model.choices.push({\n label: '',\n value: utils.firstAvailableIndex(model.choices.map((c) => c.value), 0),\n feedback: { type: 'none' }\n });\n\n this.props.onModelChanged(model);\n };\n\n onChoiceChanged = (index, choice) => {\n const { model } = this.props;\n\n if (choice.correct && model.choiceMode === 'radio') {\n model.choices = model.choices.map((c) => {\n return merge({}, c, { correct: false });\n });\n }\n\n model.choices.splice(index, 1, choice);\n this.props.onModelChanged(model);\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({\n ...this.props.model,\n prompt,\n });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.props.onModelChanged({\n ...this.props.model,\n teacherInstructions,\n });\n };\n\n onModelChanged = (model, key) => {\n const { onModelChanged } = this.props;\n\n switch (key) {\n case 'choiceMode': {\n let value = model.choiceMode;\n\n if (value === 'radio') {\n let correctFound = false;\n\n model.choices = model.choices.map((c) => {\n if (correctFound) {\n c.correct = false;\n\n return c;\n }\n\n if (c.correct) {\n correctFound = true;\n }\n\n return c;\n });\n }\n\n onModelChanged(model, true);\n break;\n }\n default:\n onModelChanged(model);\n break;\n }\n };\n\n render() {\n const { dialog } = this.state;\n\n return (\n <>\n <InfoDialog\n open={dialog.open}\n title={dialog.message}\n onCancel={dialog.onCancel}\n onOk={dialog.onOk}\n />\n <Design\n {...this.props}\n onChangeModel={this.onModelChanged}\n onRemoveChoice={this.onRemoveChoice}\n onChoiceChanged={this.onChoiceChanged}\n onAddChoice={this.onAddChoice}\n onPromptChanged={this.onPromptChanged}\n onTeacherInstructionsChanged={this.onTeacherInstructionsChanged}\n />\n </>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.generateValidationMessage = void 0;
7
+
8
+ var generateValidationMessage = function generateValidationMessage(config) {
9
+ var minAnswerChoices = config.minAnswerChoices,
10
+ maxAnswerChoices = config.maxAnswerChoices;
11
+ var answerChoicesMessage = "\nThere should be at least ".concat(minAnswerChoices, " ") + (maxAnswerChoices ? "and at most ".concat(maxAnswerChoices, " ") : '') + 'answer choices defined.' + '\nEvery answer choice should be non-blank and unique.';
12
+ var correctAnswerMessage = '\nA correct answer must be defined.';
13
+ var message = 'Validation requirements:' + answerChoicesMessage + correctAnswerMessage;
14
+ return message;
15
+ };
16
+
17
+ exports.generateValidationMessage = generateValidationMessage;
18
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils.js"],"names":["generateValidationMessage","config","minAnswerChoices","maxAnswerChoices","answerChoicesMessage","correctAnswerMessage","message"],"mappings":";;;;;;;AAAO,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,CAAAC,MAAM,EAAI;AACjD,MAAQC,gBAAR,GAA+CD,MAA/C,CAAQC,gBAAR;AAAA,MAA0BC,gBAA1B,GAA+CF,MAA/C,CAA0BE,gBAA1B;AAEA,MAAMC,oBAAoB,GAAG,qCAA8BF,gBAA9B,UAC1BC,gBAAgB,yBAAkBA,gBAAlB,SAAwC,EAD9B,IACoC,yBADpC,GAE3B,uDAFF;AAIA,MAAME,oBAAoB,GAAG,qCAA7B;AAEA,MAAMC,OAAO,GAAG,6BAA6BF,oBAA7B,GAAoDC,oBAApE;AAEA,SAAOC,OAAP;AACD,CAZM","sourcesContent":["export const generateValidationMessage = config => {\n const { minAnswerChoices, maxAnswerChoices } = config;\n\n const answerChoicesMessage = `\\nThere should be at least ${minAnswerChoices} ` +\n (maxAnswerChoices ? `and at most ${maxAnswerChoices} ` : '') + 'answer choices defined.' +\n '\\nEvery answer choice should be non-blank and unique.';\n\n const correctAnswerMessage = '\\nA correct answer must be defined.';\n\n const message = 'Validation requirements:' + answerChoicesMessage + correctAnswerMessage;\n\n return message;\n};\n"],"file":"utils.js"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-configure",
3
- "version": "4.1.6",
3
+ "version": "4.2.1",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -8,9 +8,9 @@
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@material-ui/icons": "^3.0.1",
10
10
  "@pie-framework/pie-configure-events": "^1.2.0",
11
- "@pie-lib/config-ui": "^10.10.24",
12
- "@pie-lib/editable-html": "^7.19.3",
13
- "@pie-lib/scoring-config": "^3.5.153",
11
+ "@pie-lib/config-ui": "^10.12.2",
12
+ "@pie-lib/editable-html": "^7.22.2",
13
+ "@pie-lib/scoring-config": "^3.5.158",
14
14
  "debug": "^3.1.0",
15
15
  "lodash": "^4.17.15",
16
16
  "prop-types": "^15.6.2",
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.6.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.5.5...@pie-element/multiple-choice-controller@3.6.0) (2022-05-03)
7
+
8
+
9
+ ### Features
10
+
11
+ * **multiple-choice:** updated validation behaviors PD-1696 PD-1697 ([ab009c4](https://github.com/pie-framework/pie-elements/commit/ab009c4832572dab96c5b4130a5088dea17222e6))
12
+ * added configurable validation ([1e3a0d6](https://github.com/pie-framework/pie-elements/commit/1e3a0d6da3c790e68a7fd401df2c832917d62480))
13
+ * added configurable validation + refactoring PD-1696 ([31f6354](https://github.com/pie-framework/pie-elements/commit/31f6354b256fef876fa6c48e79a3f82486b5fce7))
14
+ * added configurable validation + refactoring PD-1696 ([08d9b70](https://github.com/pie-framework/pie-elements/commit/08d9b70991f159707ef7fd5b3e533a0addda1d90))
15
+ * added configurable validation + refactoring PD-1696 ([07c42c2](https://github.com/pie-framework/pie-elements/commit/07c42c2811349d1e829d367993541157fbbe2dfc))
16
+ * start working on multiple-choice validation ([722037b](https://github.com/pie-framework/pie-elements/commit/722037bc0fddd2e090ec1506e85a91949ad86c91))
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.5.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.5.4...@pie-element/multiple-choice-controller@3.5.5) (2022-04-12)
23
+
24
+ **Note:** Version bump only for package @pie-element/multiple-choice-controller
25
+
26
+
27
+
28
+
29
+
6
30
  ## [3.5.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.4.1...@pie-element/multiple-choice-controller@3.5.1) (2021-11-11)
7
31
 
8
32
  **Note:** Version bump only for package @pie-element/multiple-choice-controller
@@ -11,9 +11,12 @@ exports.getScore = void 0;
11
11
  exports.model = model;
12
12
  exports.normalize = void 0;
13
13
  exports.outcome = outcome;
14
+ exports.validate = void 0;
14
15
 
15
16
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
16
17
 
18
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
+
17
20
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
18
21
 
19
22
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
@@ -246,4 +249,57 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
246
249
  };
247
250
 
248
251
  exports.createCorrectResponseSession = createCorrectResponseSession;
252
+
253
+ var validate = function validate() {
254
+ var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
255
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
256
+ var choices = model.choices;
257
+ var _config$minAnswerChoi = config.minAnswerChoices,
258
+ minAnswerChoices = _config$minAnswerChoi === void 0 ? 2 : _config$minAnswerChoi,
259
+ maxAnswerChoices = config.maxAnswerChoices;
260
+ var reversedChoices = (0, _toConsumableArray2["default"])(choices || []).reverse();
261
+ var choicesErrors = {};
262
+ var hasCorrectResponse = false;
263
+ reversedChoices.forEach(function (choice, index) {
264
+ var correct = choice.correct,
265
+ value = choice.value,
266
+ label = choice.label;
267
+
268
+ if (correct) {
269
+ hasCorrectResponse = true;
270
+ }
271
+
272
+ if (label === '' || label === '<div></div>') {
273
+ choicesErrors[value] = 'Content should not be empty.';
274
+ } else {
275
+ var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
276
+ return c.label === label;
277
+ });
278
+
279
+ if (identicalAnswer) {
280
+ choicesErrors[value] = 'Content should be unique.';
281
+ }
282
+ }
283
+ });
284
+ var errors = {};
285
+ var nbOfChoices = (choices || []).length;
286
+
287
+ if (nbOfChoices < minAnswerChoices) {
288
+ errors.answerChoicesError = "There should be at least ".concat(minAnswerChoices, " choices defined.");
289
+ } else if (nbOfChoices > maxAnswerChoices) {
290
+ errors.answerChoicesError = "No more than ".concat(maxAnswerChoices, " choices should be defined.");
291
+ }
292
+
293
+ if (!hasCorrectResponse) {
294
+ errors.correctResponseError = 'No correct response defined.';
295
+ }
296
+
297
+ if (!(0, _isEmpty["default"])(choicesErrors)) {
298
+ errors.choicesErrors = choicesErrors;
299
+ }
300
+
301
+ return errors;
302
+ };
303
+
304
+ exports.validate = validate;
249
305
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["prepareChoice","model","env","defaultFeedback","choice","role","mode","out","label","value","accessibilityLabelsEnabled","accessibility","textContent","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","createDefaultModel","Promise","resolve","defaults","normalize","question","verticalMode","choicesLayout","questionProps","session","updateSession","normalizedQuestion","Object","assign","incorrect","choices","map","lockChoiceOrder","disabled","prompt","promptEnabled","gridColumns","choiceMode","keyMode","choicePrefix","responseCorrect","undefined","teacherInstructions","teacherInstructionsEnabled","getScore","config","selectedChoices","correctChoices","filter","ch","score","reduce","acc","selectedChoice","find","length","str","parseFloat","toFixed","outcome","empty","partialScoringEnabled","partialScoring","enabled","createCorrectResponseSession","id","c"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAAAC,MAAM,EAAI;AAC/D,eAAuBF,GAAG,IAAI,EAA9B;AAAA,QAAQG,IAAR,QAAQA,IAAR;AAAA,QAAcC,IAAd,QAAcA,IAAd;;AACA,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEJ,MAAM,CAACI,KADJ;AAEVC,MAAAA,KAAK,EAAEL,MAAM,CAACK;AAFJ,KAAZ;;AAKA,QAAIR,KAAK,CAACS,0BAAV,EAAsC;AACpCH,MAAAA,GAAG,CAACI,aAAJ,GAAoB,sBAAUP,MAAM,CAACO,aAAjB,EAAgCC,WAAhC,IAA+CR,MAAM,CAACK,KAA1E;AACD;;AAED,QAAIJ,IAAI,KAAK,YAAT,KAA0BC,IAAI,KAAK,MAAT,IAAmBA,IAAI,KAAK,UAAtD,CAAJ,EAAuE;AACrEC,MAAAA,GAAG,CAACM,SAAJ,GAAgBZ,KAAK,CAACa,gBAAN,GAAyBV,MAAM,CAACS,SAAhC,GAA4C,IAA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,EAAI;AAC5B,QAAIpB,GAAG,CAACI,IAAJ,KAAa,UAAb,IAA2BJ,GAAG,CAACG,IAAJ,KAAa,YAA5C,EAA0D;AACxD,kBAAoBoB,QAAQ,IAAI;AAAEU,QAAAA,OAAO,EAAE;AAAX,OAAhC;AAAA,UAAQA,OAAR,SAAQA,OAAR;;AAEAb,MAAAA,OAAO,CAAC;AACNgD,QAAAA,EAAE,EAAE,GADE;AAEN7D,QAAAA,KAAK,EAAE0B,OAAO,CAACkB,MAAR,CAAe,UAAAkB,CAAC;AAAA,iBAAIA,CAAC,CAACxD,OAAN;AAAA,SAAhB,EAA+BqB,GAA/B,CAAmC,UAAAmC,CAAC;AAAA,iBAAIA,CAAC,CAAC9D,KAAN;AAAA,SAApC;AAFD,OAAD,CAAP;AAID,KAPD,MAOO;AACLa,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAXM,CAAP;AAYD,CAbM","sourcesContent":["/* eslint-disable no-console */\nimport isEmpty from 'lodash/isEmpty';\nimport { isResponseCorrect, parseHTML } from './utils';\nimport defaults from './defaults';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-lib/controller-utils';\n\nconst prepareChoice = (model, env, defaultFeedback) => choice => {\n const { role, mode } = env || {};\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (model.accessibilityLabelsEnabled) {\n out.accessibility = parseHTML(choice.accessibility).textContent || choice.value;\n }\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = question => {\n const { verticalMode, choicesLayout, ...questionProps } = question || {};\n\n return {\n ...defaults,\n ...questionProps,\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel\n choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout\n };\n};\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback\n );\n\n let choices = normalizedQuestion.choices.map(\n prepareChoice(normalizedQuestion, env, defaultFeedback)\n );\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(\n choices,\n session,\n updateSession,\n 'value'\n );\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect:\n env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\n\nexport const getScore = (config, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session.value || [];\n const correctChoices = (config.choices || []).filter(ch => ch.correct);\n\n let score = selectedChoices.reduce((acc, selectedChoice) =>\n acc + (correctChoices.find(ch => ch.value === selectedChoice) ? 1 : 0), 0);\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise(resolve => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n } else {\n const partialScoringEnabled =\n partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter(c => c.correct).map(c => c.value)\n });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["prepareChoice","model","env","defaultFeedback","choice","role","mode","out","label","value","accessibilityLabelsEnabled","accessibility","textContent","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","createDefaultModel","Promise","resolve","defaults","normalize","question","verticalMode","choicesLayout","questionProps","session","updateSession","normalizedQuestion","Object","assign","incorrect","choices","map","lockChoiceOrder","disabled","prompt","promptEnabled","gridColumns","choiceMode","keyMode","choicePrefix","responseCorrect","undefined","teacherInstructions","teacherInstructionsEnabled","getScore","config","selectedChoices","correctChoices","filter","ch","score","reduce","acc","selectedChoice","find","length","str","parseFloat","toFixed","outcome","empty","partialScoringEnabled","partialScoring","enabled","createCorrectResponseSession","id","c","validate","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","choicesErrors","hasCorrectResponse","forEach","index","identicalAnswer","slice","some","errors","nbOfChoices","answerChoicesError","correctResponseError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAAAC,MAAM,EAAI;AAC/D,eAAuBF,GAAG,IAAI,EAA9B;AAAA,QAAQG,IAAR,QAAQA,IAAR;AAAA,QAAcC,IAAd,QAAcA,IAAd;;AACA,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEJ,MAAM,CAACI,KADJ;AAEVC,MAAAA,KAAK,EAAEL,MAAM,CAACK;AAFJ,KAAZ;;AAKA,QAAIR,KAAK,CAACS,0BAAV,EAAsC;AACpCH,MAAAA,GAAG,CAACI,aAAJ,GAAoB,sBAAUP,MAAM,CAACO,aAAjB,EAAgCC,WAAhC,IAA+CR,MAAM,CAACK,KAA1E;AACD;;AAED,QAAIJ,IAAI,KAAK,YAAT,KAA0BC,IAAI,KAAK,MAAT,IAAmBA,IAAI,KAAK,UAAtD,CAAJ,EAAuE;AACrEC,MAAAA,GAAG,CAACM,SAAJ,GAAgBZ,KAAK,CAACa,gBAAN,GAAyBV,MAAM,CAACS,SAAhC,GAA4C,IAA5D;AACD,KAFD,MAEO;AACLN,MAAAA,GAAG,CAACM,SAAJ,GAAgB,IAAhB;AACD;;AAED,QAAIP,IAAI,KAAK,UAAb,EAAyB;AACvBC,MAAAA,GAAG,CAACQ,OAAJ,GAAc,CAAC,CAACX,MAAM,CAACW,OAAvB;;AAEA,UAAId,KAAK,CAACe,eAAV,EAA2B;AACzB,YAAMC,YAAY,GAAIb,MAAM,CAACc,QAAP,IAAmBd,MAAM,CAACc,QAAP,CAAgBC,IAApC,IAA6C,MAAlE;;AAEA,YAAIF,YAAY,KAAK,SAArB,EAAgC;AAC9BV,U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,KAAYA,KAAhB;AAAA,OAAvC,CAAxB;;AAEA,UAAIyE,eAAJ,EAAqB;AACnBJ,QAAAA,aAAa,CAACpE,KAAD,CAAb,GAAuB,2BAAvB;AACD;AACF;AACF,GAhBD;AAkBA,MAAM2E,MAAM,GAAG,EAAf;AACA,MAAMC,WAAW,GAAG,CAAClD,OAAO,IAAI,EAAZ,EAAgByB,MAApC;;AAEA,MAAIyB,WAAW,GAAGZ,gBAAlB,EAAoC;AAClCW,IAAAA,MAAM,CAACE,kBAAP,sCAAwDb,gBAAxD;AACD,GAFD,MAEO,IAAIY,WAAW,GAAGX,gBAAlB,EAAoC;AACzCU,IAAAA,MAAM,CAACE,kBAAP,0BAA4CZ,gBAA5C;AACD;;AAED,MAAI,CAACI,kBAAL,EAAyB;AACvBM,IAAAA,MAAM,CAACG,oBAAP,GAA8B,8BAA9B;AACD;;AAED,MAAI,CAAC,yBAAQV,aAAR,CAAL,EAA6B;AAC3BO,IAAAA,MAAM,CAACP,aAAP,GAAuBA,aAAvB;AACD;;AAED,SAAOO,MAAP;AACD,CA3CM","sourcesContent":["/* eslint-disable no-console */\nimport isEmpty from 'lodash/isEmpty';\nimport { isResponseCorrect, parseHTML } from './utils';\nimport defaults from './defaults';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-lib/controller-utils';\n\nconst prepareChoice = (model, env, defaultFeedback) => choice => {\n const { role, mode } = env || {};\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (model.accessibilityLabelsEnabled) {\n out.accessibility = parseHTML(choice.accessibility).textContent || choice.value;\n }\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = question => {\n const { verticalMode, choicesLayout, ...questionProps } = question || {};\n\n return {\n ...defaults,\n ...questionProps,\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel\n choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout\n };\n};\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback\n );\n\n let choices = normalizedQuestion.choices.map(\n prepareChoice(normalizedQuestion, env, defaultFeedback)\n );\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(\n choices,\n session,\n updateSession,\n 'value'\n );\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect:\n env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\n\nexport const getScore = (config, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session.value || [];\n const correctChoices = (config.choices || []).filter(ch => ch.correct);\n\n let score = selectedChoices.reduce((acc, selectedChoice) =>\n acc + (correctChoices.find(ch => ch.value === selectedChoice) ? 1 : 0), 0);\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise(resolve => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n } else {\n const partialScoringEnabled =\n partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter(c => c.correct).map(c => c.value)\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...choices || []].reverse();\n const choicesErrors = {};\n let hasCorrectResponse = false;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n const errors = {};\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponseError = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-controller",
3
3
  "private": true,
4
- "version": "3.5.4",
4
+ "version": "3.6.0",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
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;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;;AAEO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,OAAO;AAAA,SAAI,CAAC,EAAEA,OAAO,IAAIA,OAAO,CAACC,KAAnB,IAA4BD,OAAO,CAACC,KAAR,CAAcC,MAA5C,CAAL;AAAA,CAA1B;;;;IAEcC,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAEA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;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A,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":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;;AAEO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,OAAO;AAAA,SAAI,CAAC,EAAEA,OAAO,IAAIA,OAAO,CAACC,KAAnB,IAA4BD,OAAO,CAACC,KAAR,CAAcC,MAA5C,CAAL;AAAA,CAA1B;;;;IAEcC,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAEA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UA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,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;AAvCY;AAwDb;;;;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;;;kDApFyC8B,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\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,6 +1,6 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_material_ui__core, _dll_lodash, _dll_pie_lib__render_ui, _dll_debug, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.9/module/index.js";
2
- import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.0.32/module/index.js";
3
- import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.2.8/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_material_ui__core, _dll_lodash, _dll_material_ui__icons, _dll_pie_lib__render_ui, _dll_debug, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.15/module/index.js";
2
+ import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.2.2/module/index.js";
3
+ import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.5.2/module/index.js";
4
4
  var lib = {};
5
5
  Object.defineProperty(lib, "__esModule", {
6
6
  value: true
@@ -46,6 +46,13 @@ class InsertImageEvent extends CustomEvent {
46
46
  }
47
47
  InsertImageEvent.TYPE = 'insert.image';
48
48
  var InsertImageEvent_1 = lib.InsertImageEvent = InsertImageEvent;
49
+ const generateValidationMessage = config => {
50
+ const {minAnswerChoices, maxAnswerChoices} = config;
51
+ const answerChoicesMessage = `\nThere should be at least ${minAnswerChoices} ` + (maxAnswerChoices ? `and at most ${maxAnswerChoices} ` : '') + 'answer choices defined.' + '\nEvery answer choice should be non-blank and unique.';
52
+ const correctAnswerMessage = '\nA correct answer must be defined.';
53
+ const message = 'Validation requirements:' + answerChoicesMessage + correctAnswerMessage;
54
+ return message;
55
+ };
49
56
  const React$1 = _dll_react;
50
57
  const PropTypes = _dll_prop_types;
51
58
  const {color: color} = _dll_pie_lib__render_ui;
@@ -55,7 +62,9 @@ const {Tooltip: Tooltip} = _dll_material_ui__core;
55
62
  const {Dialog: Dialog} = _dll_material_ui__core;
56
63
  const {DialogTitle: DialogTitle} = _dll_material_ui__core;
57
64
  const {DialogActions: DialogActions} = _dll_material_ui__core;
65
+ const {Typography: Typography} = _dll_material_ui__core;
58
66
  const {merge: merge} = _dll_lodash;
67
+ const {Info: Info} = _dll_material_ui__icons;
59
68
  const EditableHtml = _dll_pie_lib__editable_html;
60
69
  const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
61
70
  const {ChoiceConfiguration: ChoiceConfiguration} = _dll_pie_lib__config_ui;
@@ -117,13 +126,36 @@ const styles = theme => ({
117
126
  '&:focus': {
118
127
  backgroundColor: color.disabled()
119
128
  }
129
+ },
130
+ flexContainer: {
131
+ display: 'flex',
132
+ alignItems: 'center',
133
+ marginBottom: '5px'
134
+ },
135
+ titleText: {
136
+ fontFamily: 'Cerebri Sans',
137
+ fontSize: '18px',
138
+ lineHeight: '19px',
139
+ color: '#495B8F',
140
+ marginRight: '5px'
141
+ },
142
+ tooltip: {
143
+ fontSize: '12px',
144
+ whiteSpace: 'pre',
145
+ maxWidth: '500px'
146
+ },
147
+ errorText: {
148
+ fontSize: '12px',
149
+ color: 'red',
150
+ paddingTop: '5px'
120
151
  }
121
152
  });
122
153
  const Design = withStyles(styles)(props => {
123
154
  const {classes, model, configuration, onPromptChanged, onChoiceChanged, onRemoveChoice, onAddChoice, imageSupport, onChangeModel, onConfigurationChanged, onTeacherInstructionsChanged} = props;
124
155
  const {prompt = {}, addChoiceButton = {}, feedback = {}, deleteChoice = {}, choiceMode = {}, choicePrefix = {}, partialScoring = {}, lockChoiceOrder = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, accessibility = {}, scoringType = {}, sequentialChoiceLabels = {}, settingsPanelDisabled, choicesLayout, spellCheck = {}, gridColumns} = configuration || ({});
125
156
  let {maxAnswerChoices} = configuration || ({});
126
- const {limitChoicesNumber, teacherInstructionsEnabled, rationaleEnabled, accessibilityLabelsEnabled, feedbackEnabled, promptEnabled, spellCheckEnabled, choices} = model || ({});
157
+ const {limitChoicesNumber, teacherInstructionsEnabled, rationaleEnabled, accessibilityLabelsEnabled, feedbackEnabled, promptEnabled, spellCheckEnabled, choices, errors} = model || ({});
158
+ const {choicesErrors, correctResponseError, answerChoicesError} = errors || ({});
127
159
  const nrOfColumnsAvailable = choices && choices.length ? Array.from({
128
160
  length: choices.length
129
161
  }, (_, i) => `${i + 1}`) : [];
@@ -147,11 +179,12 @@ const Design = withStyles(styles)(props => {
147
179
  if (limitChoicesNumber) {
148
180
  maxAnswerChoices = MAX_CHOICES;
149
181
  }
182
+ const validationMessage = generateValidationMessage(configuration);
150
183
  const Content = React$1.createElement('div', {
151
184
  __self: undefined,
152
185
  __source: {
153
186
  fileName: _jsxFileName,
154
- lineNumber: 152
187
+ lineNumber: 180
155
188
  }
156
189
  }, teacherInstructionsEnabled && React$1.createElement(InputContainer, {
157
190
  label: teacherInstructions.label,
@@ -159,7 +192,7 @@ const Design = withStyles(styles)(props => {
159
192
  __self: undefined,
160
193
  __source: {
161
194
  fileName: _jsxFileName,
162
- lineNumber: 154
195
+ lineNumber: 182
163
196
  }
164
197
  }, React$1.createElement(EditableHtml, {
165
198
  className: classes.prompt,
@@ -172,7 +205,7 @@ const Design = withStyles(styles)(props => {
172
205
  __self: undefined,
173
206
  __source: {
174
207
  fileName: _jsxFileName,
175
- lineNumber: 158
208
+ lineNumber: 186
176
209
  }
177
210
  })), promptEnabled && React$1.createElement(InputContainer, {
178
211
  label: prompt.label,
@@ -180,7 +213,7 @@ const Design = withStyles(styles)(props => {
180
213
  __self: undefined,
181
214
  __source: {
182
215
  fileName: _jsxFileName,
183
- lineNumber: 171
216
+ lineNumber: 199
184
217
  }
185
218
  }, React$1.createElement(EditableHtml, {
186
219
  className: classes.prompt,
@@ -194,15 +227,64 @@ const Design = withStyles(styles)(props => {
194
227
  __self: undefined,
195
228
  __source: {
196
229
  fileName: _jsxFileName,
197
- lineNumber: 172
230
+ lineNumber: 200
231
+ }
232
+ })), React$1.createElement('div', {
233
+ className: classes.flexContainer,
234
+ __self: undefined,
235
+ __source: {
236
+ fileName: _jsxFileName,
237
+ lineNumber: 212
238
+ }
239
+ }, React$1.createElement(Typography, {
240
+ className: classes.titleText,
241
+ __self: undefined,
242
+ __source: {
243
+ fileName: _jsxFileName,
244
+ lineNumber: 213
245
+ }
246
+ }, "Choices"), React$1.createElement(Tooltip, {
247
+ classes: {
248
+ tooltip: classes.tooltip
249
+ },
250
+ disableFocusListener: true,
251
+ disableTouchListener: true,
252
+ placement: 'right',
253
+ title: validationMessage,
254
+ __self: undefined,
255
+ __source: {
256
+ fileName: _jsxFileName,
257
+ lineNumber: 214
258
+ }
259
+ }, React$1.createElement(Info, {
260
+ fontSize: 'small',
261
+ color: 'primary',
262
+ __self: undefined,
263
+ __source: {
264
+ fileName: _jsxFileName,
265
+ lineNumber: 221
266
+ }
267
+ }))), correctResponseError && React$1.createElement('div', {
268
+ className: classes.errorText,
269
+ __self: undefined,
270
+ __source: {
271
+ fileName: _jsxFileName,
272
+ lineNumber: 224
273
+ }
274
+ }, correctResponseError), answerChoicesError && React$1.createElement('div', {
275
+ className: classes.errorText,
276
+ __self: undefined,
277
+ __source: {
278
+ fileName: _jsxFileName,
279
+ lineNumber: 225
198
280
  }
199
- })), model.choices.map((choice, index) => React$1.createElement('div', {
281
+ }, answerChoicesError), choices.map((choice, index) => React$1.createElement('div', {
200
282
  key: `choice-${index}`,
201
283
  className: classes.choiceConfigurationHolder,
202
284
  __self: undefined,
203
285
  __source: {
204
286
  fileName: _jsxFileName,
205
- lineNumber: 185
287
+ lineNumber: 227
206
288
  }
207
289
  }, React$1.createElement(ChoiceConfiguration, {
208
290
  key: index,
@@ -220,10 +302,12 @@ const Design = withStyles(styles)(props => {
220
302
  noLabels: true,
221
303
  toolbarOpts: toolbarOpts,
222
304
  spellCheck: spellCheckEnabled,
305
+ error: choicesErrors && choicesErrors[choice.value] ? choicesErrors[choice.value] : null,
306
+ noCorrectAnswerError: correctResponseError,
223
307
  __self: undefined,
224
308
  __source: {
225
309
  fileName: _jsxFileName,
226
- lineNumber: 189
310
+ lineNumber: 231
227
311
  }
228
312
  }), rationaleEnabled && React$1.createElement(InputContainer, {
229
313
  key: `rationale-${index}`,
@@ -232,7 +316,7 @@ const Design = withStyles(styles)(props => {
232
316
  __self: undefined,
233
317
  __source: {
234
318
  fileName: _jsxFileName,
235
- lineNumber: 207
319
+ lineNumber: 251
236
320
  }
237
321
  }, React$1.createElement(EditableHtml, {
238
322
  className: classes.rationale,
@@ -248,7 +332,7 @@ const Design = withStyles(styles)(props => {
248
332
  __self: undefined,
249
333
  __source: {
250
334
  fileName: _jsxFileName,
251
- lineNumber: 212
335
+ lineNumber: 256
252
336
  }
253
337
  })), accessibilityLabelsEnabled && React$1.createElement(InputContainer, {
254
338
  key: `accessibility-${index}`,
@@ -257,7 +341,7 @@ const Design = withStyles(styles)(props => {
257
341
  __self: undefined,
258
342
  __source: {
259
343
  fileName: _jsxFileName,
260
- lineNumber: 229
344
+ lineNumber: 273
261
345
  }
262
346
  }, React$1.createElement(EditableHtml, {
263
347
  className: classes.accessibility,
@@ -272,13 +356,13 @@ const Design = withStyles(styles)(props => {
272
356
  __self: undefined,
273
357
  __source: {
274
358
  fileName: _jsxFileName,
275
- lineNumber: 234
359
+ lineNumber: 278
276
360
  }
277
361
  })))), React$1.createElement('br', {
278
362
  __self: undefined,
279
363
  __source: {
280
364
  fileName: _jsxFileName,
281
- lineNumber: 251
365
+ lineNumber: 295
282
366
  }
283
367
  }), addChoiceButton.settings && React$1.createElement(Tooltip, {
284
368
  title: maxAnswerChoices && model.choices.length >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '',
@@ -288,11 +372,11 @@ const Design = withStyles(styles)(props => {
288
372
  __self: undefined,
289
373
  __source: {
290
374
  fileName: _jsxFileName,
291
- lineNumber: 253
375
+ lineNumber: 297
292
376
  }
293
377
  }, React$1.createElement(Button, {
294
378
  classes: {
295
- root: maxAnswerChoices && model.choices.length >= maxAnswerChoices ? classes.disableButton : undefined
379
+ root: maxAnswerChoices && model.choices.length >= maxAnswerChoices && classes.disableButton
296
380
  },
297
381
  className: classes.addButton,
298
382
  variant: "contained",
@@ -301,7 +385,7 @@ const Design = withStyles(styles)(props => {
301
385
  __self: undefined,
302
386
  __source: {
303
387
  fileName: _jsxFileName,
304
- lineNumber: 261
388
+ lineNumber: 305
305
389
  }
306
390
  }, addChoiceButton.label)));
307
391
  const settingsInPanel = {
@@ -319,7 +403,7 @@ const Design = withStyles(styles)(props => {
319
403
  __self: undefined,
320
404
  __source: {
321
405
  fileName: _jsxFileName,
322
- lineNumber: 303
406
+ lineNumber: 342
323
407
  }
324
408
  }, settingsPanelDisabled ? Content : React$1.createElement(layout.ConfigLayout, {
325
409
  settings: React$1.createElement(Panel, {
@@ -342,13 +426,13 @@ const Design = withStyles(styles)(props => {
342
426
  __self: undefined,
343
427
  __source: {
344
428
  fileName: _jsxFileName,
345
- lineNumber: 309
429
+ lineNumber: 348
346
430
  }
347
431
  }),
348
432
  __self: undefined,
349
433
  __source: {
350
434
  fileName: _jsxFileName,
351
- lineNumber: 307
435
+ lineNumber: 346
352
436
  }
353
437
  }, Content));
354
438
  });
@@ -357,19 +441,19 @@ const InfoDialog = ({open, onCancel, onOk, title}) => React$1.createElement(Dial
357
441
  __self: undefined,
358
442
  __source: {
359
443
  fileName: _jsxFileName,
360
- lineNumber: 346
444
+ lineNumber: 385
361
445
  }
362
446
  }, React$1.createElement(DialogTitle, {
363
447
  __self: undefined,
364
448
  __source: {
365
449
  fileName: _jsxFileName,
366
- lineNumber: 347
450
+ lineNumber: 386
367
451
  }
368
452
  }, title), React$1.createElement(DialogActions, {
369
453
  __self: undefined,
370
454
  __source: {
371
455
  fileName: _jsxFileName,
372
- lineNumber: 348
456
+ lineNumber: 387
373
457
  }
374
458
  }, onOk && React$1.createElement(Button, {
375
459
  onClick: onOk,
@@ -377,7 +461,7 @@ const InfoDialog = ({open, onCancel, onOk, title}) => React$1.createElement(Dial
377
461
  __self: undefined,
378
462
  __source: {
379
463
  fileName: _jsxFileName,
380
- lineNumber: 350
464
+ lineNumber: 389
381
465
  }
382
466
  }, "OK"), onCancel && React$1.createElement(Button, {
383
467
  onClick: onCancel,
@@ -385,7 +469,7 @@ const InfoDialog = ({open, onCancel, onOk, title}) => React$1.createElement(Dial
385
469
  __self: undefined,
386
470
  __source: {
387
471
  fileName: _jsxFileName,
388
- lineNumber: 355
472
+ lineNumber: 394
389
473
  }
390
474
  }, "Cancel")));
391
475
  InfoDialog.propTypes = {
@@ -441,12 +525,7 @@ class Main extends React$1.Component {
441
525
  open: false
442
526
  }
443
527
  });
444
- },
445
- onCancel: () => this.setState({
446
- dialog: {
447
- open: false
448
- }
449
- })
528
+ }
450
529
  }
451
530
  });
452
531
  } else {
@@ -463,35 +542,17 @@ class Main extends React$1.Component {
463
542
  if (limitChoicesNumber) {
464
543
  maxAnswerChoices = MAX_CHOICES;
465
544
  }
466
- if (maxAnswerChoices && model.choices.length === maxAnswerChoices) {
467
- this.setState({
468
- dialog: {
469
- open: true,
470
- message: `There can't be more than ${maxAnswerChoices} choices.`,
471
- onOk: () => {
472
- this.setState({
473
- dialog: {
474
- open: false
475
- }
476
- });
477
- },
478
- onCancel: () => this.setState({
479
- dialog: {
480
- open: false
481
- }
482
- })
483
- }
484
- });
485
- } else {
486
- model.choices.push({
487
- label: '',
488
- value: utils$1.firstAvailableIndex(model.choices.map(c => c.value), 0),
489
- feedback: {
490
- type: 'none'
491
- }
492
- });
493
- this.props.onModelChanged(model);
545
+ if (maxAnswerChoices && model.choices.length >= maxAnswerChoices) {
546
+ return;
494
547
  }
548
+ model.choices.push({
549
+ label: '',
550
+ value: utils$1.firstAvailableIndex(model.choices.map(c => c.value), 0),
551
+ feedback: {
552
+ type: 'none'
553
+ }
554
+ });
555
+ this.props.onModelChanged(model);
495
556
  };
496
557
  }
497
558
  __init4() {
@@ -563,7 +624,7 @@ class Main extends React$1.Component {
563
624
  __self: this,
564
625
  __source: {
565
626
  fileName: _jsxFileName,
566
- lineNumber: 529
627
+ lineNumber: 542
567
628
  }
568
629
  }), React$1.createElement(Design, {
569
630
  ...this.props,
@@ -576,7 +637,7 @@ class Main extends React$1.Component {
576
637
  __self: this,
577
638
  __source: {
578
639
  fileName: _jsxFileName,
579
- lineNumber: 534
640
+ lineNumber: 548
580
641
  }
581
642
  }));
582
643
  }
@@ -20638,4 +20638,49 @@ const createCorrectResponseSession = (question, env) => {
20638
20638
  });
20639
20639
  };
20640
20640
 
20641
- export { createCorrectResponseSession, createDefaultModel, getScore, model, normalize, outcome };
20641
+ const validate = (model = {}, config = {}) => {
20642
+ const { choices } = model;
20643
+ const { minAnswerChoices = 2, maxAnswerChoices } = config;
20644
+ const reversedChoices = [...choices || []].reverse();
20645
+ const choicesErrors = {};
20646
+ let hasCorrectResponse = false;
20647
+
20648
+ reversedChoices.forEach((choice, index) => {
20649
+ const { correct, value, label } = choice;
20650
+
20651
+ if (correct) {
20652
+ hasCorrectResponse = true;
20653
+ }
20654
+
20655
+ if (label === '' || label === '<div></div>') {
20656
+ choicesErrors[value] = 'Content should not be empty.';
20657
+ } else {
20658
+ const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);
20659
+
20660
+ if (identicalAnswer) {
20661
+ choicesErrors[value] = 'Content should be unique.';
20662
+ }
20663
+ }
20664
+ });
20665
+
20666
+ const errors = {};
20667
+ const nbOfChoices = (choices || []).length;
20668
+
20669
+ if (nbOfChoices < minAnswerChoices) {
20670
+ errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;
20671
+ } else if (nbOfChoices > maxAnswerChoices) {
20672
+ errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;
20673
+ }
20674
+
20675
+ if (!hasCorrectResponse) {
20676
+ errors.correctResponseError = 'No correct response defined.';
20677
+ }
20678
+
20679
+ if (!isEmpty_1(choicesErrors)) {
20680
+ errors.choicesErrors = choicesErrors;
20681
+ }
20682
+
20683
+ return errors;
20684
+ };
20685
+
20686
+ export { createCorrectResponseSession, createDefaultModel, getScore, model, normalize, outcome, validate };
package/module/element.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.9/module/index.js";
2
- import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.0.34/module/index.js";
1
+ import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.15/module/index.js";
2
+ import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.3/module/index.js";
3
3
  function getDefaultExportFromCjs(x) {
4
4
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
5
  }
package/module/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/multiple-choice@6.2.5</title>
5
+ <title>@pie-element/multiple-choice@6.3.0</title>
6
6
  <script
7
7
  type="module"
8
8
  src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
- "version": "6.2.5",
3
+ "version": "6.3.0",
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/shared-module",
7
- "version": "^1.4.9"
7
+ "version": "^1.4.15"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/math-rendering-module",
11
- "version": "^1.0.34"
11
+ "version": "^1.1.3"
12
12
  }
13
13
  ]
14
14
  }
package/module/print.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/multiple-choice@6.2.5</title>
5
+ <title>@pie-element/multiple-choice@6.3.0</title>
6
6
  <link
7
7
  href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
8
  rel="stylesheet"
package/module/print.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.9/module/index.js";
2
- import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.0.34/module/index.js";
1
+ import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.15/module/index.js";
2
+ import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.3/module/index.js";
3
3
  function getDefaultExportFromCjs(x) {
4
4
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
5
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "6.2.6",
4
+ "version": "6.3.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "dependencies": {
9
9
  "@material-ui/core": "^3.9.2",
10
- "@pie-lib/config-ui": "^10.10.24",
11
- "@pie-lib/correct-answer-toggle": "^2.3.35",
12
- "@pie-lib/math-rendering": "^2.3.13",
13
- "@pie-lib/render-ui": "^4.12.5",
10
+ "@pie-lib/config-ui": "^10.12.2",
11
+ "@pie-lib/correct-answer-toggle": "^2.3.36",
12
+ "@pie-lib/math-rendering": "^2.4.0",
13
+ "@pie-lib/render-ui": "^4.12.6",
14
14
  "classnames": "^2.2.5",
15
15
  "debug": "^4.1.1",
16
16
  "enzyme-to-json": "^3.3.3",
@@ -21,7 +21,7 @@
21
21
  "react-test-renderer": "^16.3.2",
22
22
  "react-transition-group": "^2.3.1"
23
23
  },
24
- "gitHead": "92cd24e6736b2eed8f82ac44ba775ad4f2080ade",
24
+ "gitHead": "43f534de577f1eb49e63c8dc43d5519754d4df93",
25
25
  "scripts": {
26
26
  "postpublish": "../../scripts/postpublish"
27
27
  },