@pie-element/multiple-choice 5.9.3-next.747 → 5.9.3-next.760

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.
@@ -47,6 +47,10 @@ 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
+
50
54
  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
55
 
52
56
  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 +118,28 @@ var styles = function styles(theme) {
114
118
  '&:focus': {
115
119
  backgroundColor: _renderUi.color.disabled()
116
120
  }
121
+ },
122
+ flexContainer: {
123
+ display: 'flex',
124
+ alignItems: 'center'
125
+ },
126
+ titleText: {
127
+ fontFamily: 'Cerebri Sans',
128
+ fontSize: '18px',
129
+ lineHeight: '19px',
130
+ color: '#495B8F',
131
+ marginRight: '5px',
132
+ marginBottom: '5px'
133
+ },
134
+ tooltip: {
135
+ fontSize: '12px',
136
+ whiteSpace: 'pre',
137
+ maxWidth: '500px'
138
+ },
139
+ errorText: {
140
+ fontSize: '12px',
141
+ color: 'red',
142
+ paddingTop: '5px'
117
143
  }
118
144
  };
119
145
  };
@@ -177,7 +203,13 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
177
203
  feedbackEnabled = _ref3.feedbackEnabled,
178
204
  promptEnabled = _ref3.promptEnabled,
179
205
  spellCheckEnabled = _ref3.spellCheckEnabled,
180
- choices = _ref3.choices;
206
+ choices = _ref3.choices,
207
+ errors = _ref3.errors;
208
+
209
+ var _ref4 = errors || {},
210
+ choicesErrors = _ref4.choicesErrors,
211
+ correctResponseError = _ref4.correctResponseError,
212
+ answerChoicesError = _ref4.answerChoicesError;
181
213
 
182
214
  var nrOfColumnsAvailable = choices && choices.length ? Array.from({
183
215
  length: choices.length
@@ -232,7 +264,26 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
232
264
  disableUnderline: true,
233
265
  toolbarOpts: toolbarOpts,
234
266
  spellCheck: spellCheckEnabled
235
- })), model.choices.map(function (choice, index) {
267
+ })), /*#__PURE__*/_react["default"].createElement("div", {
268
+ className: classes.flexContainer
269
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
270
+ className: classes.titleText
271
+ }, "Choices"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
272
+ classes: {
273
+ tooltip: classes.tooltip
274
+ },
275
+ disableFocusListener: true,
276
+ disableTouchListener: true,
277
+ placement: 'right',
278
+ title: 'Validation requirements:\nThere should at least two answer choices, non-blank and unique.\nA correct answer must be defined.'
279
+ }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
280
+ fontSize: 'small',
281
+ color: 'primary'
282
+ }))), correctResponseError && /*#__PURE__*/_react["default"].createElement("div", {
283
+ className: classes.errorText
284
+ }, correctResponseError), answerChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
285
+ className: classes.errorText
286
+ }, answerChoicesError), choices.map(function (choice, index) {
236
287
  return /*#__PURE__*/_react["default"].createElement("div", {
237
288
  key: "choice-".concat(index),
238
289
  className: classes.choiceConfigurationHolder
@@ -255,7 +306,9 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
255
306
  allowDelete: deleteChoice.settings,
256
307
  noLabels: true,
257
308
  toolbarOpts: toolbarOpts,
258
- spellCheck: spellCheckEnabled
309
+ spellCheck: spellCheckEnabled,
310
+ error: choicesErrors && choicesErrors[choice.value] ? choicesErrors[choice.value] : null,
311
+ noCorrectAnswerError: correctResponseError
259
312
  }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
260
313
  key: "rationale-".concat(index),
261
314
  label: rationale.label,
@@ -337,11 +390,11 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
337
390
  }, Content));
338
391
  });
339
392
 
340
- var InfoDialog = function InfoDialog(_ref4) {
341
- var open = _ref4.open,
342
- onCancel = _ref4.onCancel,
343
- onOk = _ref4.onOk,
344
- title = _ref4.title;
393
+ var InfoDialog = function InfoDialog(_ref5) {
394
+ var open = _ref5.open,
395
+ onCancel = _ref5.onCancel,
396
+ onOk = _ref5.onOk,
397
+ title = _ref5.title;
345
398
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
346
399
  open: open
347
400
  }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, onOk && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
@@ -385,8 +438,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
385
438
  model = _this$props.model,
386
439
  configuration = _this$props.configuration;
387
440
 
388
- var _ref5 = configuration || {},
389
- minAnswerChoices = _ref5.minAnswerChoices;
441
+ var _ref6 = configuration || {},
442
+ minAnswerChoices = _ref6.minAnswerChoices;
390
443
 
391
444
  if (minAnswerChoices && model.choices.length === minAnswerChoices) {
392
445
  _this.setState({
@@ -420,11 +473,11 @@ var Main = /*#__PURE__*/function (_React$Component) {
420
473
  model = _this$props2.model,
421
474
  configuration = _this$props2.configuration;
422
475
 
423
- var _ref6 = configuration || {},
424
- maxAnswerChoices = _ref6.maxAnswerChoices;
476
+ var _ref7 = configuration || {},
477
+ maxAnswerChoices = _ref7.maxAnswerChoices;
425
478
 
426
- var _ref7 = model || {},
427
- limitChoicesNumber = _ref7.limitChoicesNumber; // if old property is used, set maxAnswerChoices to 9
479
+ var _ref8 = model || {},
480
+ limitChoicesNumber = _ref8.limitChoicesNumber; // if old property is used, set maxAnswerChoices to 9
428
481
 
429
482
 
430
483
  if (limitChoicesNumber) {
@@ -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,kBAA3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Types 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 />\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"}
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","Content","label","map","choice","index","c","value","root","undefined","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;;;;;;;;;;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,C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A,QAAQ,EAAEH,MAAM,CAACT,QAHnB;AAIE,QAAA,IAAI,EAAES,MAAM,CAACR;AAJf,QADF,eAOE,gCAAC,MAAD,gCACM,KAAKpE,KADX;AAEE,QAAA,aAAa,EAAE,KAAKiF,cAFtB;AAGE,QAAA,cAAc,EAAE,KAAK3E,cAHvB;AAIE,QAAA,eAAe,EAAE,KAAKD,eAJxB;AAKE,QAAA,WAAW,EAAE,KAAKE,WALpB;AAME,QAAA,eAAe,EAAE,KAAKH,eANxB;AAOE,QAAA,4BAA4B,EAAE,KAAKO;AAPrC,SAPF,CADF;AAmBD;;;EAhLuB+E,kBAAMC,S;;;iCAAnBhB,I,eACQ;AACjBzE,EAAAA,KAAK,EAAEqE,sBAAUqB,MAAV,CAAiBC,UADP;AAEjB1F,EAAAA,aAAa,EAAEoE,sBAAUqB,MAAV,CAAiBC,UAFf;AAGjBC,EAAAA,gBAAgB,EAAEvB,sBAAUC,IAHX;AAIjBS,EAAAA,cAAc,EAAEV,sBAAUE,IAAV,CAAeoB,UAJd;AAKjBnF,EAAAA,sBAAsB,EAAE6D,sBAAUE,IAAV,CAAeoB,UALtB;AAMjB5F,EAAAA,OAAO,EAAEsE,sBAAUqB,MAAV,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;AAkLrB,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';\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 },\n titleText: {\n fontFamily: 'Cerebri Sans',\n fontSize: '18px',\n lineHeight: '19px',\n color: '#495B8F',\n marginRight: '5px',\n marginBottom: '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 =\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 <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={'Validation requirements:\\nThere should at least two answer choices, non-blank and unique.\\nA correct answer must be defined.'}\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={{\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 />\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"}
@@ -8,8 +8,8 @@
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",
11
+ "@pie-lib/config-ui": "10.10.4-next.217",
12
+ "@pie-lib/editable-html": "7.17.4-next.217",
13
13
  "@pie-lib/scoring-config": "^3.5.153",
14
14
  "debug": "^3.1.0",
15
15
  "lodash": "^4.17.15",
@@ -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 = "Should be defined at least ".concat(minAnswerChoices, " choices.");
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":";;;;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P;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,C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;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 = `Should be defined at least ${minAnswerChoices} choices.`;\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,4 +1,4 @@
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";
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.9/module/index.js";
2
2
  import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.0.32/module/index.js";
3
3
  import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.2.8/module/index.js";
4
4
  var lib = {};
@@ -55,7 +55,9 @@ const {Tooltip: Tooltip} = _dll_material_ui__core;
55
55
  const {Dialog: Dialog} = _dll_material_ui__core;
56
56
  const {DialogTitle: DialogTitle} = _dll_material_ui__core;
57
57
  const {DialogActions: DialogActions} = _dll_material_ui__core;
58
+ const {Typography: Typography} = _dll_material_ui__core;
58
59
  const {merge: merge} = _dll_lodash;
60
+ const {Info: Info} = _dll_material_ui__icons;
59
61
  const EditableHtml = _dll_pie_lib__editable_html;
60
62
  const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
61
63
  const {ChoiceConfiguration: ChoiceConfiguration} = _dll_pie_lib__config_ui;
@@ -117,13 +119,36 @@ const styles = theme => ({
117
119
  '&:focus': {
118
120
  backgroundColor: color.disabled()
119
121
  }
122
+ },
123
+ flexContainer: {
124
+ display: 'flex',
125
+ alignItems: 'center'
126
+ },
127
+ titleText: {
128
+ fontFamily: 'Cerebri Sans',
129
+ fontSize: '18px',
130
+ lineHeight: '19px',
131
+ color: '#495B8F',
132
+ marginRight: '5px',
133
+ marginBottom: '5px'
134
+ },
135
+ tooltip: {
136
+ fontSize: '12px',
137
+ whiteSpace: 'pre',
138
+ maxWidth: '500px'
139
+ },
140
+ errorText: {
141
+ fontSize: '12px',
142
+ color: 'red',
143
+ paddingTop: '5px'
120
144
  }
121
145
  });
122
146
  const Design = withStyles(styles)(props => {
123
147
  const {classes, model, configuration, onPromptChanged, onChoiceChanged, onRemoveChoice, onAddChoice, imageSupport, onChangeModel, onConfigurationChanged, onTeacherInstructionsChanged} = props;
124
148
  const {prompt = {}, addChoiceButton = {}, feedback = {}, deleteChoice = {}, choiceMode = {}, choicePrefix = {}, partialScoring = {}, lockChoiceOrder = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, accessibility = {}, scoringType = {}, sequentialChoiceLabels = {}, settingsPanelDisabled, choicesLayout, spellCheck = {}, gridColumns} = configuration || ({});
125
149
  let {maxAnswerChoices} = configuration || ({});
126
- const {limitChoicesNumber, teacherInstructionsEnabled, rationaleEnabled, accessibilityLabelsEnabled, feedbackEnabled, promptEnabled, spellCheckEnabled, choices} = model || ({});
150
+ const {limitChoicesNumber, teacherInstructionsEnabled, rationaleEnabled, accessibilityLabelsEnabled, feedbackEnabled, promptEnabled, spellCheckEnabled, choices, errors} = model || ({});
151
+ const {choicesErrors, correctResponseError, answerChoicesError} = errors || ({});
127
152
  const nrOfColumnsAvailable = choices && choices.length ? Array.from({
128
153
  length: choices.length
129
154
  }, (_, i) => `${i + 1}`) : [];
@@ -151,7 +176,7 @@ const Design = withStyles(styles)(props => {
151
176
  __self: undefined,
152
177
  __source: {
153
178
  fileName: _jsxFileName,
154
- lineNumber: 152
179
+ lineNumber: 178
155
180
  }
156
181
  }, teacherInstructionsEnabled && React$1.createElement(InputContainer, {
157
182
  label: teacherInstructions.label,
@@ -159,7 +184,7 @@ const Design = withStyles(styles)(props => {
159
184
  __self: undefined,
160
185
  __source: {
161
186
  fileName: _jsxFileName,
162
- lineNumber: 154
187
+ lineNumber: 180
163
188
  }
164
189
  }, React$1.createElement(EditableHtml, {
165
190
  className: classes.prompt,
@@ -172,7 +197,7 @@ const Design = withStyles(styles)(props => {
172
197
  __self: undefined,
173
198
  __source: {
174
199
  fileName: _jsxFileName,
175
- lineNumber: 158
200
+ lineNumber: 184
176
201
  }
177
202
  })), promptEnabled && React$1.createElement(InputContainer, {
178
203
  label: prompt.label,
@@ -180,7 +205,7 @@ const Design = withStyles(styles)(props => {
180
205
  __self: undefined,
181
206
  __source: {
182
207
  fileName: _jsxFileName,
183
- lineNumber: 171
208
+ lineNumber: 197
184
209
  }
185
210
  }, React$1.createElement(EditableHtml, {
186
211
  className: classes.prompt,
@@ -194,15 +219,64 @@ const Design = withStyles(styles)(props => {
194
219
  __self: undefined,
195
220
  __source: {
196
221
  fileName: _jsxFileName,
197
- lineNumber: 172
222
+ lineNumber: 198
223
+ }
224
+ })), React$1.createElement('div', {
225
+ className: classes.flexContainer,
226
+ __self: undefined,
227
+ __source: {
228
+ fileName: _jsxFileName,
229
+ lineNumber: 210
198
230
  }
199
- })), model.choices.map((choice, index) => React$1.createElement('div', {
231
+ }, React$1.createElement(Typography, {
232
+ className: classes.titleText,
233
+ __self: undefined,
234
+ __source: {
235
+ fileName: _jsxFileName,
236
+ lineNumber: 211
237
+ }
238
+ }, "Choices"), React$1.createElement(Tooltip, {
239
+ classes: {
240
+ tooltip: classes.tooltip
241
+ },
242
+ disableFocusListener: true,
243
+ disableTouchListener: true,
244
+ placement: 'right',
245
+ title: 'Validation requirements:\nThere should at least two answer choices, non-blank and unique.\nA correct answer must be defined.',
246
+ __self: undefined,
247
+ __source: {
248
+ fileName: _jsxFileName,
249
+ lineNumber: 212
250
+ }
251
+ }, React$1.createElement(Info, {
252
+ fontSize: 'small',
253
+ color: 'primary',
254
+ __self: undefined,
255
+ __source: {
256
+ fileName: _jsxFileName,
257
+ lineNumber: 219
258
+ }
259
+ }))), correctResponseError && React$1.createElement('div', {
260
+ className: classes.errorText,
261
+ __self: undefined,
262
+ __source: {
263
+ fileName: _jsxFileName,
264
+ lineNumber: 222
265
+ }
266
+ }, correctResponseError), answerChoicesError && React$1.createElement('div', {
267
+ className: classes.errorText,
268
+ __self: undefined,
269
+ __source: {
270
+ fileName: _jsxFileName,
271
+ lineNumber: 223
272
+ }
273
+ }, answerChoicesError), choices.map((choice, index) => React$1.createElement('div', {
200
274
  key: `choice-${index}`,
201
275
  className: classes.choiceConfigurationHolder,
202
276
  __self: undefined,
203
277
  __source: {
204
278
  fileName: _jsxFileName,
205
- lineNumber: 185
279
+ lineNumber: 225
206
280
  }
207
281
  }, React$1.createElement(ChoiceConfiguration, {
208
282
  key: index,
@@ -220,10 +294,12 @@ const Design = withStyles(styles)(props => {
220
294
  noLabels: true,
221
295
  toolbarOpts: toolbarOpts,
222
296
  spellCheck: spellCheckEnabled,
297
+ error: choicesErrors && choicesErrors[choice.value] ? choicesErrors[choice.value] : null,
298
+ noCorrectAnswerError: correctResponseError,
223
299
  __self: undefined,
224
300
  __source: {
225
301
  fileName: _jsxFileName,
226
- lineNumber: 189
302
+ lineNumber: 229
227
303
  }
228
304
  }), rationaleEnabled && React$1.createElement(InputContainer, {
229
305
  key: `rationale-${index}`,
@@ -232,7 +308,7 @@ const Design = withStyles(styles)(props => {
232
308
  __self: undefined,
233
309
  __source: {
234
310
  fileName: _jsxFileName,
235
- lineNumber: 207
311
+ lineNumber: 249
236
312
  }
237
313
  }, React$1.createElement(EditableHtml, {
238
314
  className: classes.rationale,
@@ -248,7 +324,7 @@ const Design = withStyles(styles)(props => {
248
324
  __self: undefined,
249
325
  __source: {
250
326
  fileName: _jsxFileName,
251
- lineNumber: 212
327
+ lineNumber: 254
252
328
  }
253
329
  })), accessibilityLabelsEnabled && React$1.createElement(InputContainer, {
254
330
  key: `accessibility-${index}`,
@@ -257,7 +333,7 @@ const Design = withStyles(styles)(props => {
257
333
  __self: undefined,
258
334
  __source: {
259
335
  fileName: _jsxFileName,
260
- lineNumber: 229
336
+ lineNumber: 271
261
337
  }
262
338
  }, React$1.createElement(EditableHtml, {
263
339
  className: classes.accessibility,
@@ -272,13 +348,13 @@ const Design = withStyles(styles)(props => {
272
348
  __self: undefined,
273
349
  __source: {
274
350
  fileName: _jsxFileName,
275
- lineNumber: 234
351
+ lineNumber: 276
276
352
  }
277
353
  })))), React$1.createElement('br', {
278
354
  __self: undefined,
279
355
  __source: {
280
356
  fileName: _jsxFileName,
281
- lineNumber: 251
357
+ lineNumber: 293
282
358
  }
283
359
  }), addChoiceButton.settings && React$1.createElement(Tooltip, {
284
360
  title: maxAnswerChoices && model.choices.length >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '',
@@ -288,7 +364,7 @@ const Design = withStyles(styles)(props => {
288
364
  __self: undefined,
289
365
  __source: {
290
366
  fileName: _jsxFileName,
291
- lineNumber: 253
367
+ lineNumber: 295
292
368
  }
293
369
  }, React$1.createElement(Button, {
294
370
  classes: {
@@ -301,7 +377,7 @@ const Design = withStyles(styles)(props => {
301
377
  __self: undefined,
302
378
  __source: {
303
379
  fileName: _jsxFileName,
304
- lineNumber: 261
380
+ lineNumber: 303
305
381
  }
306
382
  }, addChoiceButton.label)));
307
383
  const settingsInPanel = {
@@ -319,7 +395,7 @@ const Design = withStyles(styles)(props => {
319
395
  __self: undefined,
320
396
  __source: {
321
397
  fileName: _jsxFileName,
322
- lineNumber: 303
398
+ lineNumber: 345
323
399
  }
324
400
  }, settingsPanelDisabled ? Content : React$1.createElement(layout.ConfigLayout, {
325
401
  settings: React$1.createElement(Panel, {
@@ -342,13 +418,13 @@ const Design = withStyles(styles)(props => {
342
418
  __self: undefined,
343
419
  __source: {
344
420
  fileName: _jsxFileName,
345
- lineNumber: 309
421
+ lineNumber: 351
346
422
  }
347
423
  }),
348
424
  __self: undefined,
349
425
  __source: {
350
426
  fileName: _jsxFileName,
351
- lineNumber: 307
427
+ lineNumber: 349
352
428
  }
353
429
  }, Content));
354
430
  });
@@ -357,19 +433,19 @@ const InfoDialog = ({open, onCancel, onOk, title}) => React$1.createElement(Dial
357
433
  __self: undefined,
358
434
  __source: {
359
435
  fileName: _jsxFileName,
360
- lineNumber: 346
436
+ lineNumber: 388
361
437
  }
362
438
  }, React$1.createElement(DialogTitle, {
363
439
  __self: undefined,
364
440
  __source: {
365
441
  fileName: _jsxFileName,
366
- lineNumber: 347
442
+ lineNumber: 389
367
443
  }
368
444
  }, title), React$1.createElement(DialogActions, {
369
445
  __self: undefined,
370
446
  __source: {
371
447
  fileName: _jsxFileName,
372
- lineNumber: 348
448
+ lineNumber: 390
373
449
  }
374
450
  }, onOk && React$1.createElement(Button, {
375
451
  onClick: onOk,
@@ -377,7 +453,7 @@ const InfoDialog = ({open, onCancel, onOk, title}) => React$1.createElement(Dial
377
453
  __self: undefined,
378
454
  __source: {
379
455
  fileName: _jsxFileName,
380
- lineNumber: 350
456
+ lineNumber: 392
381
457
  }
382
458
  }, "OK"), onCancel && React$1.createElement(Button, {
383
459
  onClick: onCancel,
@@ -385,7 +461,7 @@ const InfoDialog = ({open, onCancel, onOk, title}) => React$1.createElement(Dial
385
461
  __self: undefined,
386
462
  __source: {
387
463
  fileName: _jsxFileName,
388
- lineNumber: 355
464
+ lineNumber: 397
389
465
  }
390
466
  }, "Cancel")));
391
467
  InfoDialog.propTypes = {
@@ -563,7 +639,7 @@ class Main extends React$1.Component {
563
639
  __self: this,
564
640
  __source: {
565
641
  fileName: _jsxFileName,
566
- lineNumber: 529
642
+ lineNumber: 571
567
643
  }
568
644
  }), React$1.createElement(Design, {
569
645
  ...this.props,
@@ -576,7 +652,7 @@ class Main extends React$1.Component {
576
652
  __self: this,
577
653
  __source: {
578
654
  fileName: _jsxFileName,
579
- lineNumber: 535
655
+ lineNumber: 577
580
656
  }
581
657
  }));
582
658
  }
@@ -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 = `Should be defined at least ${minAnswerChoices} choices.`;
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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "5.9.3-next.747+6350e113a",
4
+ "version": "5.9.3-next.760+7600567d9",
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",
10
+ "@pie-lib/config-ui": "10.10.4-next.217",
11
11
  "@pie-lib/correct-answer-toggle": "^2.3.35",
12
12
  "@pie-lib/math-rendering": "^2.3.13",
13
13
  "@pie-lib/render-ui": "^4.12.5",
@@ -21,7 +21,7 @@
21
21
  "react-test-renderer": "^16.3.2",
22
22
  "react-transition-group": "^2.3.1"
23
23
  },
24
- "gitHead": "6350e113a803025917943cb137b04698031b07e3",
24
+ "gitHead": "7600567d98665ed5d9f43005c465cac78d69b143",
25
25
  "scripts": {
26
26
  "postpublish": "../../scripts/postpublish"
27
27
  },