@pie-element/explicit-constructed-response 6.7.1-next.0 → 6.7.1-next.33

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.
@@ -82,7 +82,8 @@ var _default = {
82
82
  image: {
83
83
  disabled: false
84
84
  }
85
- }
85
+ },
86
+ required: false
86
87
  },
87
88
  partialScoring: {
88
89
  settings: false,
@@ -101,7 +102,8 @@ var _default = {
101
102
  image: {
102
103
  disabled: false
103
104
  }
104
- }
105
+ },
106
+ required: false
105
107
  },
106
108
  settingsPanelDisabled: false,
107
109
  spellCheck: {
@@ -132,7 +134,8 @@ var _default = {
132
134
  image: {
133
135
  disabled: false
134
136
  }
135
- }
137
+ },
138
+ required: false
136
139
  },
137
140
  template: {
138
141
  inputConfiguration: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.js"],"names":["model","disabled","mode","prompt","shuffle","markup","toolbarEditorPosition","displayType","spellCheckEnabled","playerSpellCheckEnabled","choices","label","value","correct","maxLengthPerChoiceEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","configuration","baseInputConfiguration","html","audio","video","image","settings","inputConfiguration","partialScoring","rationale","settingsPanelDisabled","spellCheck","enabled","editSource","playerSpellCheck","teacherInstructions","template","maxLengthPerChoice","maxResponseAreas","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,QAAQ,EAAE,KADL;AAELC,IAAAA,IAAI,EAAE,QAFD;AAGLC,IAAAA,MAAM,EAAE,yCAHH;AAILC,IAAAA,OAAO,EAAE,IAJJ;AAKLC,IAAAA,MAAM,EAAE,yCALH;AAMLC,IAAAA,qBAAqB,EAAE,QANlB;AAOLC,IAAAA,WAAW,EAAE,OAPR;AAQLC,IAAAA,iBAAiB,EAAE,IARd;AASLC,IAAAA,uBAAuB,EAAE,IATpB;A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MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,UAAU,EAAE;AAFC,KAhFF;AAoFbC,IAAAA,QAAQ,EAAE;AACRnB,MAAAA,QAAQ,EAAE,KADF;AAERd,MAAAA,KAAK,EAAE,kBAFC;AAGRoB,MAAAA,OAAO,EAAE;AAHD,KApFG;AAyFbc,IAAAA,eAAe,EAAE;AACflC,MAAAA,KAAK,EAAE,kBADQ;AAEfmC,MAAAA,OAAO,EAAE;AAFM;AAzFJ;AA9DF,C","sourcesContent":["export default {\n model: {\n disabled: false,\n mode: 'gather',\n prompt: 'Use the inputs to complete the sentence',\n shuffle: true,\n markup: '<p>The {{0}} jumped {{1}} the {{2}}</p>',\n toolbarEditorPosition: 'bottom',\n displayType: 'block',\n spellCheckEnabled: true,\n playerSpellCheckEnabled: true,\n choices: {\n 0: [\n {\n label: 'cow',\n value: '0',\n },\n {\n label: 'cattle',\n value: '1',\n },\n {\n label: 'calf',\n value: '2',\n correct: false,\n },\n ],\n 1: [\n {\n label: 'over',\n value: '0',\n },\n {\n label: 'past',\n value: '1',\n },\n {\n label: 'beyond',\n value: '2',\n },\n ],\n 2: [\n {\n label: 'moon',\n value: '0',\n },\n {\n label: 'satellite',\n value: '2',\n },\n {\n label: 'house ',\n value: '3',\n },\n ],\n },\n maxLengthPerChoiceEnabled: true,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n },\n configuration: {\n baseInputConfiguration: {\n html: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n settingsPanelDisabled: false,\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n editSource: {\n label: 'Edit Source',\n settings: false,\n enabled: false,\n },\n playerSpellCheck: {\n label: 'Student Spellcheck',\n settings: true,\n enabled: true,\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n template: {\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n maxLengthPerChoice: {\n settings: true,\n label: 'Maximum Length Per Choice',\n },\n maxResponseAreas: 10,\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n },\n};\n"],"file":"defaults.js"}
1
+ {"version":3,"sources":["../src/defaults.js"],"names":["model","disabled","mode","prompt","shuffle","markup","toolbarEditorPosition","displayType","spellCheckEnabled","playerSpellCheckEnabled","choices","label","value","correct","maxLengthPerChoiceEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","configuration","baseInputConfiguration","html","audio","video","image","settings","inputConfiguration","required","partialScoring","rationale","settingsPanelDisabled","spellCheck","enabled","editSource","playerSpellCheck","teacherInstructions","template","maxLengthPerChoice","maxResponseAreas","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,QAAQ,EAAE,KADL;AAELC,IAAAA,IAAI,EAAE,QAFD;AAGLC,IAAAA,MAAM,EAAE,yCAHH;AAILC,IAAAA,OAAO,EAAE,IAJJ;AAKLC,IAAAA,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Ac,EAAE;AACdL,MAAAA,mBAAmB,EAAE,GADP;AAEdhC,MAAAA,MAAM,EAAE,GAFM;AAGd0B,MAAAA,SAAS,EAAE;AAHG,KA1EH;AA+EbY,IAAAA,UAAU,EAAE;AACVhB,MAAAA,QAAQ,EAAE,KADA;AAEVd,MAAAA,KAAK,EAAE;AAFG,KA/EC;AAmFb+B,IAAAA,aAAa,EAAE;AACbC,MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,UAAU,EAAE;AAFC,KAnFF;AAuFbC,IAAAA,QAAQ,EAAE;AACRpB,MAAAA,QAAQ,EAAE,KADF;AAERd,MAAAA,KAAK,EAAE,kBAFC;AAGRqB,MAAAA,OAAO,EAAE;AAHD,KAvFG;AA4Fbc,IAAAA,eAAe,EAAE;AACfnC,MAAAA,KAAK,EAAE,kBADQ;AAEfoC,MAAAA,OAAO,EAAE;AAFM;AA5FJ;AA9DF,C","sourcesContent":["export default {\n model: {\n disabled: false,\n mode: 'gather',\n prompt: 'Use the inputs to complete the sentence',\n shuffle: true,\n markup: '<p>The {{0}} jumped {{1}} the {{2}}</p>',\n toolbarEditorPosition: 'bottom',\n displayType: 'block',\n spellCheckEnabled: true,\n playerSpellCheckEnabled: true,\n choices: {\n 0: [\n {\n label: 'cow',\n value: '0',\n },\n {\n label: 'cattle',\n value: '1',\n },\n {\n label: 'calf',\n value: '2',\n correct: false,\n },\n ],\n 1: [\n {\n label: 'over',\n value: '0',\n },\n {\n label: 'past',\n value: '1',\n },\n {\n label: 'beyond',\n value: '2',\n },\n ],\n 2: [\n {\n label: 'moon',\n value: '0',\n },\n {\n label: 'satellite',\n value: '2',\n },\n {\n label: 'house ',\n value: '3',\n },\n ],\n },\n maxLengthPerChoiceEnabled: true,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n },\n configuration: {\n baseInputConfiguration: {\n html: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n settingsPanelDisabled: false,\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n editSource: {\n label: 'Edit Source',\n settings: false,\n enabled: false,\n },\n playerSpellCheck: {\n label: 'Student Spellcheck',\n settings: true,\n enabled: true,\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n template: {\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n maxLengthPerChoice: {\n settings: true,\n label: 'Maximum Length Per Choice',\n },\n maxResponseAreas: 10,\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n },\n};\n"],"file":"defaults.js"}
@@ -383,9 +383,12 @@ var Main = /*#__PURE__*/function (_React$Component) {
383
383
  toolbarEditorPosition = _ref2.toolbarEditorPosition;
384
384
 
385
385
  var _ref3 = errors || {},
386
- _ref3$choicesErrors = _ref3.choicesErrors,
387
- choicesErrors = _ref3$choicesErrors === void 0 ? {} : _ref3$choicesErrors,
388
- responseAreasError = _ref3.responseAreasError;
386
+ _ref3$choices = _ref3.choices,
387
+ choicesErrors = _ref3$choices === void 0 ? {} : _ref3$choices,
388
+ promptError = _ref3.prompt,
389
+ rationaleError = _ref3.rationale,
390
+ responseAreasError = _ref3.responseAreas,
391
+ teacherInstructionsError = _ref3.teacherInstructions;
389
392
 
390
393
  var validationMessage = (0, _utils.generateValidationMessage)(configuration);
391
394
  var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
@@ -440,6 +443,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
440
443
  onChange: this.onTeacherInstructionsChanged,
441
444
  imageSupport: imageSupport,
442
445
  nonEmpty: false,
446
+ error: teacherInstructionsError,
443
447
  toolbarOpts: toolbarOpts,
444
448
  pluginProps: getPluginProps(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration),
445
449
  spellCheck: spellCheckEnabled,
@@ -452,7 +456,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
452
456
  language: 'special'
453
457
  }],
454
458
  mathMlOptions: mathMlOptions
455
- })), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
459
+ }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
460
+ className: classes.errorText
461
+ }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
456
462
  label: prompt.label,
457
463
  className: classes.promptHolder
458
464
  }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
@@ -462,6 +468,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
462
468
  imageSupport: imageSupport,
463
469
  nonEmpty: false,
464
470
  disableUnderline: true,
471
+ error: promptError,
465
472
  toolbarOpts: toolbarOpts,
466
473
  pluginProps: getPluginProps(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration),
467
474
  spellCheck: spellCheckEnabled,
@@ -474,7 +481,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
474
481
  language: 'special'
475
482
  }],
476
483
  mathMlOptions: mathMlOptions
477
- })), /*#__PURE__*/_react["default"].createElement("div", {
484
+ }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
485
+ className: classes.errorText
486
+ }, promptError)), /*#__PURE__*/_react["default"].createElement("div", {
478
487
  className: classes.flexContainer
479
488
  }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
480
489
  className: classes.text
@@ -561,6 +570,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
561
570
  markup: model.rationale || '',
562
571
  onChange: this.onRationaleChanged,
563
572
  imageSupport: imageSupport,
573
+ error: rationaleError,
564
574
  toolbarOpts: toolbarOpts,
565
575
  pluginProps: getPluginProps(rationale === null || rationale === void 0 ? void 0 : rationale.inputConfiguration),
566
576
  spellCheck: spellCheckEnabled,
@@ -573,7 +583,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
573
583
  language: 'special'
574
584
  }],
575
585
  mathMlOptions: mathMlOptions
576
- })));
586
+ }), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
587
+ className: classes.errorText
588
+ }, rationaleError)));
577
589
  }
578
590
  }]);
579
591
  return Main;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","dropdown","styles","theme","promptHolder","width","paddingTop","spacing","unit","marginBottom","markup","minHeight","choiceConfiguration","paddingBottom","switchElement","justifyContent","margin","addButton","text","fontSize","typography","tooltip","whiteSpace","maxWidth","errorText","color","palette","error","main","flexContainer","display","alignItems","responseHeader","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","get","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","template","settingsPanelDisabled","spellCheck","editSource","withRubric","mathMlOptions","language","languageChoices","errors","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","responseAreasError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","enabled","options","panelProperties","playerSpellCheckEnabled","rubricEnabled","getPluginProps","onModelChange","Settings","Properties","onTeacherInstructionsChanged","inputConfiguration","onPromptChanged","marginLeft","ALL_PLUGINS","type","duplicates","respAreaToolbar","onToolbarDone","correctChoice","onChangeResponse","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,MAAR,GAAoCC,kBAApC,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAAoCD,kBAApC,CAAgBC,KAAhB;AAAA,IAAuBC,QAAvB,GAAoCF,kBAApC,CAAuBE,QAAvB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,UAAU,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFrB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADW;AAMzBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,SAAS,EAAE,OADL;AAENL,MAAAA,UAAU,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAFpB;AAGNH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,UADf;AAEjBjH,EAAAA,KAAK,EAAE+G,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjBpH,EAAAA,cAAc,EAAEgH,sBAAUK,IAAV,CAAeH,UAJd;AAKjB/D,EAAAA,sBAAsB,EAAE6D,sBAAUK,IAAV,CAAeH,UALtB;AAMjBjE,EAAAA,OAAO,EAAE+D,sBAAUC,MAAV,CAAiBC,UANT;AAOjB9D,EAAAA,YAAY,EAAE4D,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CAPG;AAWjB7D,EAAAA,kBAAkB,EAAE2D,sBAAUC;AAXb,C;AAgZrB,IAAMO,MAAM,GAAG,wBAAWlK,MAAX,EAAmBuC,IAAnB,CAAf;eAEe2H,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport { EditableHtml, ALL_PLUGINS } from '@pie-lib/pie-toolbox/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\nimport classnames from 'classnames';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n },\n choiceConfiguration: {\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 text: {\n fontSize: theme.typography.fontSize + 2,\n },\n tooltip: {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'end',\n },\n responseHeader: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit,\n },\n});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: 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 uploadSoundSupport: PropTypes.object,\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = [] },\n onModelChanged,\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({ ...this.props.model, maxLengthPerChoice });\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({ ...this.props.model, prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({ ...this.props.model, rationale });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({ ...this.props.model, slateMarkup });\n };\n\n onResponsesChanged = (choices) => {\n this.props.onModelChanged({ ...this.props.model, choices });\n };\n\n onLengthChanged = (maxLengthPerChoice) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, maxLengthPerChoice });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged } = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = (newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1)];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice &&\n (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({ ...model, choices, maxLengthPerChoice });\n };\n\n onChange = (markup) => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged,\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]');\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0',\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () =>\n onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice,\n });\n\n this.setState({ cachedChoices: undefined }, callback);\n };\n\n onHandleAreaChange = throttle(\n (nodes) => {\n const {\n model: { choices },\n onModelChanged,\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.get('index');\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({ ...this.props.model, choices: newChoices });\n\n this.setState({ cachedChoices: newCachedChoices }, callback);\n },\n 500,\n { trailing: false, leading: true },\n );\n\n render() {\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n maxImageWidth = {},\n maxImageHeight = {},\n maxLengthPerChoice = {},\n maxResponseAreas,\n partialScoring = {},\n playerSpellCheck = {},\n prompt = {},\n rationale = {},\n template = {},\n settingsPanelDisabled,\n spellCheck = {},\n editSource = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n errors,\n maxLengthPerChoiceEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const { choicesErrors = {}, responseAreasError } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n 'editSource.enabled': editSource?.settings && toggle(editSource.label, true),\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n\n return (\n <layout.ConfigLayout\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\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={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n\n <div className={classes.flexContainer}>\n <Typography className={classes.text}>Define Template, Choices, and Correct Responses</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'} style={{ marginLeft: '8px' }} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n pluginProps={getPluginProps(template?.inputConfiguration)}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.data.get('index')] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.data.get('index'), newVal)}\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n {!isEmpty(model.choices) && (\n <Typography className={classnames(classes.text, classes.responseHeader)}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n />\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n </layout.ConfigLayout>\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":["toggle","settings","Panel","dropdown","styles","theme","promptHolder","width","paddingTop","spacing","unit","marginBottom","markup","minHeight","choiceConfiguration","paddingBottom","switchElement","justifyContent","margin","addButton","text","fontSize","typography","tooltip","whiteSpace","maxWidth","errorText","color","palette","error","main","flexContainer","display","alignItems","responseHeader","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","get","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","template","settingsPanelDisabled","spellCheck","editSource","withRubric","mathMlOptions","language","languageChoices","errors","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","promptError","rationaleError","responseAreasError","responseAreas","teacherInstructionsError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","enabled","options","panelProperties","playerSpellCheckEnabled","rubricEnabled","getPluginProps","onModelChange","Settings","Properties","onTeacherInstructionsChanged","inputConfiguration","onPromptChanged","marginLeft","ALL_PLUGINS","type","duplicates","respAreaToolbar","onToolbarDone","correctChoice","onChangeResponse","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;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UAJd;AAKjBnE,EAAAA,sBAAsB,EAAEiE,sBAAUK,IAAV,CAAeH,UALtB;AAMjBrE,EAAAA,OAAO,EAAEmE,sBAAUC,MAAV,CAAiBC,UANT;AAOjBlE,EAAAA,YAAY,EAAEgE,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CAPG;AAWjBjE,EAAAA,kBAAkB,EAAE+D,sBAAUC;AAXb,C;AA4ZrB,IAAMO,MAAM,GAAG,wBAAWtK,MAAX,EAAmBuC,IAAnB,CAAf;eAEe+H,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport { EditableHtml, ALL_PLUGINS } from '@pie-lib/pie-toolbox/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\nimport classnames from 'classnames';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n },\n choiceConfiguration: {\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 text: {\n fontSize: theme.typography.fontSize + 2,\n },\n tooltip: {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'end',\n },\n responseHeader: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit,\n },\n});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: 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 uploadSoundSupport: PropTypes.object,\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = [] },\n onModelChanged,\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({ ...this.props.model, maxLengthPerChoice });\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({ ...this.props.model, prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({ ...this.props.model, rationale });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({ ...this.props.model, slateMarkup });\n };\n\n onResponsesChanged = (choices) => {\n this.props.onModelChanged({ ...this.props.model, choices });\n };\n\n onLengthChanged = (maxLengthPerChoice) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, maxLengthPerChoice });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged } = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = (newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1)];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice &&\n (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({ ...model, choices, maxLengthPerChoice });\n };\n\n onChange = (markup) => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged,\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]');\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0',\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () =>\n onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice,\n });\n\n this.setState({ cachedChoices: undefined }, callback);\n };\n\n onHandleAreaChange = throttle(\n (nodes) => {\n const {\n model: { choices },\n onModelChanged,\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.get('index');\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({ ...this.props.model, choices: newChoices });\n\n this.setState({ cachedChoices: newCachedChoices }, callback);\n },\n 500,\n { trailing: false, leading: true },\n );\n\n render() {\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n maxImageWidth = {},\n maxImageHeight = {},\n maxLengthPerChoice = {},\n maxResponseAreas,\n partialScoring = {},\n playerSpellCheck = {},\n prompt = {},\n rationale = {},\n template = {},\n settingsPanelDisabled,\n spellCheck = {},\n editSource = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n errors,\n maxLengthPerChoiceEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const {\n choices: choicesErrors = {},\n prompt: promptError,\n rationale: rationaleError,\n responseAreas: responseAreasError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n 'editSource.enabled': editSource?.settings && toggle(editSource.label, true),\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n\n return (\n <layout.ConfigLayout\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n error={teacherInstructionsError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {teacherInstructionsError && <div className={classes.errorText}>{teacherInstructionsError}</div>}\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={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n error={promptError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {promptError && <div className={classes.errorText}>{promptError}</div>}\n </InputContainer>\n )}\n\n <div className={classes.flexContainer}>\n <Typography className={classes.text}>Define Template, Choices, and Correct Responses</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'} style={{ marginLeft: '8px' }} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n pluginProps={getPluginProps(template?.inputConfiguration)}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.data.get('index')] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.data.get('index'), newVal)}\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n {!isEmpty(model.choices) && (\n <Typography className={classnames(classes.text, classes.responseHeader)}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n />\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n error={rationaleError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {rationaleError && <div className={classes.errorText}>{rationaleError}</div>}\n </InputContainer>\n )}\n </layout.ConfigLayout>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
@@ -8,7 +8,7 @@
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@material-ui/icons": "^3.0.1",
10
10
  "@pie-framework/pie-configure-events": "^1.3.0",
11
- "@pie-lib/pie-toolbox": "1.12.1",
11
+ "@pie-lib/pie-toolbox": "1.12.2",
12
12
  "classnames": "^2.2.6",
13
13
  "debug": "^3.1.0",
14
14
  "lodash": "^4.17.15",
@@ -311,10 +311,20 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
311
311
  resolve(null);
312
312
  }
313
313
  });
314
- };
314
+ }; // remove all html tags
315
+
315
316
 
316
317
  exports.createCorrectResponseSession = createCorrectResponseSession;
317
318
 
319
+ var getInnerText = function getInnerText(html) {
320
+ return (html || '').replaceAll(/<[^>]*>/g, '');
321
+ }; // remove all html tags except img and iframe
322
+
323
+
324
+ var getContent = function getContent(html) {
325
+ return (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
326
+ };
327
+
318
328
  var validate = function validate() {
319
329
  var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
320
330
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -322,6 +332,14 @@ var validate = function validate() {
322
332
  markup = model.markup;
323
333
  var maxResponseAreas = config.maxResponseAreas;
324
334
  var allChoicesErrors = {};
335
+ var errors = {};
336
+ ['teacherInstructions', 'prompt', 'rationale'].forEach(function (field) {
337
+ var _config$field;
338
+
339
+ if ((_config$field = config[field]) !== null && _config$field !== void 0 && _config$field.required && !getContent(model[field])) {
340
+ errors[field] = 'This field is required.';
341
+ }
342
+ });
325
343
  Object.entries(choices || {}).forEach(function (_ref4) {
326
344
  var _ref5 = (0, _slicedToArray2["default"])(_ref4, 2),
327
345
  key = _ref5[0],
@@ -350,17 +368,16 @@ var validate = function validate() {
350
368
  allChoicesErrors[key] = choicesErrors;
351
369
  }
352
370
  });
353
- var errors = {};
354
371
  var nbOfResponseAreas = (markup.match(/\{\{(\d+)\}\}/g) || []).length;
355
372
 
356
373
  if (nbOfResponseAreas > maxResponseAreas) {
357
- errors.responseAreasError = "No more than ".concat(maxResponseAreas, " response areas should be defined.");
374
+ errors.responseAreas = "No more than ".concat(maxResponseAreas, " response areas should be defined.");
358
375
  } else if (nbOfResponseAreas < 1) {
359
- errors.responseAreasError = 'There should be at least 1 response area defined.';
376
+ errors.responseAreas = 'There should be at least 1 response area defined.';
360
377
  }
361
378
 
362
379
  if (!(0, _isEmpty["default"])(allChoicesErrors)) {
363
- errors.choicesErrors = allChoicesErrors;
380
+ errors.choices = allChoicesErrors;
364
381
  }
365
382
 
366
383
  return errors;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["translator","Translator","log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","getAdjustedLength","length","normalize","question","defaults","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","preparChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","showNote","values","note","t","lng","language","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","Math","max","disabled","prompt","markup","displayType","playerSpellCheckEnabled","responseCorrect","getScore","undefined","role","rationale","teacherInstructions","getTextFromHTML","html","replace","trim","config","responseAreas","match","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","validate","maxResponseAreas","allChoicesErrors","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","some","errors","nbOfResponseAreas","responseAreasError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA,IAAME,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,a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hB,CAAsBjE,KAAK,GAAG,CAA9B,EAAiCkE,IAAjC,CAAsC,UAACxD,CAAD;AAAA,iBAAOA,CAAC,CAACtC,KAAF,KAAYA,KAAnB;AAAA,SAAtC,CAAxB;;AAEA,YAAI4F,eAAJ,EAAqB;AACnBD,UAAAA,aAAa,CAAC1F,KAAD,CAAb,GAAuB,2BAAvB;AACD;AACF;AACF,KAZD;;AAcA,QAAI,CAAC,yBAAQ0F,aAAR,CAAL,EAA6B;AAC3BJ,MAAAA,gBAAgB,CAAC9D,GAAD,CAAhB,GAAwBkE,aAAxB;AACD;AACF,GArBD;AAuBA,MAAMI,MAAM,GAAG,EAAf;AACA,MAAMC,iBAAiB,GAAG,CAAC1C,MAAM,CAACe,KAAP,CAAa,gBAAb,KAAkC,EAAnC,EAAuC7D,MAAjE;;AAEA,MAAIwF,iBAAiB,GAAGV,gBAAxB,EAA0C;AACxCS,IAAAA,MAAM,CAACE,kBAAP,0BAA4CX,gBAA5C;AACD,GAFD,MAEO,IAAIU,iBAAiB,GAAG,CAAxB,EAA2B;AAChCD,IAAAA,MAAM,CAACE,kBAAP,GAA4B,mDAA5B;AACD;;AAED,MAAI,CAAC,yBAAQV,gBAAR,CAAL,EAAgC;AAC9BQ,IAAAA,MAAM,CAACJ,aAAP,GAAuBJ,gBAAvB;AACD;;AAED,SAAOQ,MAAP;AACD,CA1CM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport debug from 'debug';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport defaults from './defaults';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n\nexport const normalize = (question) => ({\n ...defaults,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async (resolve) => {\n // this was added to treat an exception, when the model has choices without the \"value\" property\n // like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n const { value = {} } = session || {};\n\n const preparChoiceFn = prepareChoice(env.mode, defaultFeedback);\n\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, preparChoiceFn);\n\n return obj;\n },\n {},\n );\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n feedback = reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val = !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n );\n }\n\n let showNote = false;\n // check if a choice has an alternate\n Object.values(choices).forEach((choice) => {\n if (choice && choice.length > 1) {\n showNote = true;\n }\n });\n\n let { note } = normalizedQuestion;\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n }\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n env,\n note,\n showNote,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n displayType: normalizedQuestion.displayType,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n language: normalizedQuestion.language\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n}\n\nconst getTextFromHTML = (html) => {\n return (html || '').replace(/<\\/?[^>]+(>|$)/g, '');\n};\n\nexport const prepareVal = (html) => {\n const value = getTextFromHTML(html);\n\n return value.trim();\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\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 =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\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;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\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 if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const errors = {};\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choicesErrors = allChoicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["translator","Translator","log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","getAdjustedLength","length","normalize","question","defaults","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","preparChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","showNote","values","note","t","lng","language","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","Math","max","disabled","prompt","markup","displayType","playerSpellCheckEnabled","responseCorrect","getScore","undefined","role","rationale","teacherInstructions","getTextFromHTML","html","replace","trim","config","responseAreas","match","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","getInnerText","replaceAll","getContent","validate","maxResponseAreas","allChoicesErrors","errors","field","required","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","some","nbOfResponseAreas"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA,IAAME,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,aAAa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,iBAAiB,GAAG,CAAxB,EAA2B;AAChCV,IAAAA,MAAM,CAACvB,aAAP,GAAuB,mDAAvB;AACD;;AAED,MAAI,CAAC,yBAAQsB,gBAAR,CAAL,EAAgC;AAC9BC,IAAAA,MAAM,CAACtE,OAAP,GAAiBqE,gBAAjB;AACD;;AAED,SAAOC,MAAP;AACD,CAhDM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport debug from 'debug';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport defaults from './defaults';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n\nexport const normalize = (question) => ({\n ...defaults,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async (resolve) => {\n // this was added to treat an exception, when the model has choices without the \"value\" property\n // like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n const { value = {} } = session || {};\n\n const preparChoiceFn = prepareChoice(env.mode, defaultFeedback);\n\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, preparChoiceFn);\n\n return obj;\n },\n {},\n );\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n feedback = reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val = !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n );\n }\n\n let showNote = false;\n // check if a choice has an alternate\n Object.values(choices).forEach((choice) => {\n if (choice && choice.length > 1) {\n showNote = true;\n }\n });\n\n let { note } = normalizedQuestion;\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n }\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n env,\n note,\n showNote,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n displayType: normalizedQuestion.displayType,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n language: normalizedQuestion.language,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n}\n\nconst getTextFromHTML = (html) => {\n return (html || '').replace(/<\\/?[^>]+(>|$)/g, '');\n};\n\nexport const prepareVal = (html) => {\n const value = getTextFromHTML(html);\n\n return value.trim();\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\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 =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\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;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img and iframe\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\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 if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreas = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreas = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choices = allChoicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -8,7 +8,7 @@
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
- "@pie-lib/pie-toolbox": "1.12.1",
11
+ "@pie-lib/pie-toolbox": "1.12.2",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15",
14
14
  "type-of": "^2.0.1"
@@ -70,7 +70,7 @@
70
70
  }
71
71
  },
72
72
  "prompt": {
73
- "title": "EditableHtmlPluginConfigure",
73
+ "title": "EditableHtmlPluginConfigureRequired",
74
74
  "type": "object",
75
75
  "properties": {
76
76
  "inputConfiguration": {
@@ -123,6 +123,11 @@
123
123
  }
124
124
  }
125
125
  },
126
+ "required": {
127
+ "description": "Indicates if the item is required and the value cannot be empty",
128
+ "type": "boolean",
129
+ "title": "required"
130
+ },
126
131
  "settings": {
127
132
  "description": "Indicates if the item has to be displayed in the Settings Panel",
128
133
  "type": "boolean",
@@ -136,7 +141,7 @@
136
141
  }
137
142
  },
138
143
  "rationale": {
139
- "title": "EditableHtmlPluginConfigure",
144
+ "title": "EditableHtmlPluginConfigureRequired",
140
145
  "type": "object",
141
146
  "properties": {
142
147
  "inputConfiguration": {
@@ -189,6 +194,11 @@
189
194
  }
190
195
  }
191
196
  },
197
+ "required": {
198
+ "description": "Indicates if the item is required and the value cannot be empty",
199
+ "type": "boolean",
200
+ "title": "required"
201
+ },
192
202
  "settings": {
193
203
  "description": "Indicates if the item has to be displayed in the Settings Panel",
194
204
  "type": "boolean",
@@ -271,7 +281,7 @@
271
281
  }
272
282
  },
273
283
  "teacherInstructions": {
274
- "title": "EditableHtmlPluginConfigure",
284
+ "title": "EditableHtmlPluginConfigureRequired",
275
285
  "type": "object",
276
286
  "properties": {
277
287
  "inputConfiguration": {
@@ -324,6 +334,11 @@
324
334
  }
325
335
  }
326
336
  },
337
+ "required": {
338
+ "description": "Indicates if the item is required and the value cannot be empty",
339
+ "type": "boolean",
340
+ "title": "required"
341
+ },
327
342
  "settings": {
328
343
  "description": "Indicates if the item has to be displayed in the Settings Panel",
329
344
  "type": "boolean",
@@ -730,6 +745,77 @@
730
745
  }
731
746
  }
732
747
  },
748
+ "EditableHtmlPluginConfigureRequired": {
749
+ "title": "EditableHtmlPluginConfigureRequired",
750
+ "type": "object",
751
+ "properties": {
752
+ "inputConfiguration": {
753
+ "title": "EditableHtmlConfigureProp",
754
+ "type": "object",
755
+ "properties": {
756
+ "math": {
757
+ "title": "EditableHtmlButtonConfigure",
758
+ "type": "object",
759
+ "properties": {
760
+ "disabled": {
761
+ "description": "Indicates if the plugin is disabled or not",
762
+ "type": "boolean",
763
+ "title": "disabled"
764
+ }
765
+ }
766
+ },
767
+ "audio": {
768
+ "title": "EditableHtmlButtonConfigure",
769
+ "type": "object",
770
+ "properties": {
771
+ "disabled": {
772
+ "description": "Indicates if the plugin is disabled or not",
773
+ "type": "boolean",
774
+ "title": "disabled"
775
+ }
776
+ }
777
+ },
778
+ "video": {
779
+ "title": "EditableHtmlButtonConfigure",
780
+ "type": "object",
781
+ "properties": {
782
+ "disabled": {
783
+ "description": "Indicates if the plugin is disabled or not",
784
+ "type": "boolean",
785
+ "title": "disabled"
786
+ }
787
+ }
788
+ },
789
+ "image": {
790
+ "title": "EditableHtmlButtonConfigure",
791
+ "type": "object",
792
+ "properties": {
793
+ "disabled": {
794
+ "description": "Indicates if the plugin is disabled or not",
795
+ "type": "boolean",
796
+ "title": "disabled"
797
+ }
798
+ }
799
+ }
800
+ }
801
+ },
802
+ "required": {
803
+ "description": "Indicates if the item is required and the value cannot be empty",
804
+ "type": "boolean",
805
+ "title": "required"
806
+ },
807
+ "settings": {
808
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
809
+ "type": "boolean",
810
+ "title": "settings"
811
+ },
812
+ "label": {
813
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
814
+ "type": "string",
815
+ "title": "label"
816
+ }
817
+ }
818
+ },
733
819
  "EditableHtmlPluginConfigure": {
734
820
  "title": "EditableHtmlPluginConfigure",
735
821
  "type": "object",
@@ -90,6 +90,10 @@ Properties of the `image` object:
90
90
 
91
91
  Indicates if the plugin is disabled or not
92
92
 
93
+ ## `required` (boolean)
94
+
95
+ Indicates if the item is required and the value cannot be empty
96
+
93
97
  ## `settings` (boolean)
94
98
 
95
99
  Indicates if the item has to be displayed in the Settings Panel
@@ -138,6 +142,10 @@ Properties of the `image` object:
138
142
 
139
143
  Indicates if the plugin is disabled or not
140
144
 
145
+ ## `required` (boolean)
146
+
147
+ Indicates if the item is required and the value cannot be empty
148
+
141
149
  ## `settings` (boolean)
142
150
 
143
151
  Indicates if the item has to be displayed in the Settings Panel
@@ -238,6 +246,10 @@ Properties of the `image` object:
238
246
 
239
247
  Indicates if the plugin is disabled or not
240
248
 
249
+ ## `required` (boolean)
250
+
251
+ Indicates if the item is required and the value cannot be empty
252
+
241
253
  ## `settings` (boolean)
242
254
 
243
255
  Indicates if the item has to be displayed in the Settings Panel
@@ -544,6 +556,58 @@ Indicates if the item has to be displayed in the Settings Panel
544
556
 
545
557
  Indicates the label for the item that has to be displayed in the Settings Panel
546
558
 
559
+ ## `EditableHtmlPluginConfigureRequired` (object)
560
+
561
+ Properties of the `EditableHtmlPluginConfigureRequired` object:
562
+
563
+ ### `inputConfiguration` (object)
564
+
565
+ Properties of the `inputConfiguration` object:
566
+
567
+ #### `math` (object)
568
+
569
+ Properties of the `math` object:
570
+
571
+ ##### `disabled` (boolean)
572
+
573
+ Indicates if the plugin is disabled or not
574
+
575
+ #### `audio` (object)
576
+
577
+ Properties of the `audio` object:
578
+
579
+ ##### `disabled` (boolean)
580
+
581
+ Indicates if the plugin is disabled or not
582
+
583
+ #### `video` (object)
584
+
585
+ Properties of the `video` object:
586
+
587
+ ##### `disabled` (boolean)
588
+
589
+ Indicates if the plugin is disabled or not
590
+
591
+ #### `image` (object)
592
+
593
+ Properties of the `image` object:
594
+
595
+ ##### `disabled` (boolean)
596
+
597
+ Indicates if the plugin is disabled or not
598
+
599
+ ### `required` (boolean)
600
+
601
+ Indicates if the item is required and the value cannot be empty
602
+
603
+ ### `settings` (boolean)
604
+
605
+ Indicates if the item has to be displayed in the Settings Panel
606
+
607
+ ### `label` (string)
608
+
609
+ Indicates the label for the item that has to be displayed in the Settings Panel
610
+
547
611
  ## `EditableHtmlPluginConfigure` (object)
548
612
 
549
613
  Properties of the `EditableHtmlPluginConfigure` object:
@@ -246,6 +246,77 @@
246
246
  }
247
247
  }
248
248
  },
249
+ "EditableHtmlPluginConfigureRequired": {
250
+ "title": "EditableHtmlPluginConfigureRequired",
251
+ "type": "object",
252
+ "properties": {
253
+ "inputConfiguration": {
254
+ "title": "EditableHtmlConfigureProp",
255
+ "type": "object",
256
+ "properties": {
257
+ "math": {
258
+ "title": "EditableHtmlButtonConfigure",
259
+ "type": "object",
260
+ "properties": {
261
+ "disabled": {
262
+ "description": "Indicates if the plugin is disabled or not",
263
+ "type": "boolean",
264
+ "title": "disabled"
265
+ }
266
+ }
267
+ },
268
+ "audio": {
269
+ "title": "EditableHtmlButtonConfigure",
270
+ "type": "object",
271
+ "properties": {
272
+ "disabled": {
273
+ "description": "Indicates if the plugin is disabled or not",
274
+ "type": "boolean",
275
+ "title": "disabled"
276
+ }
277
+ }
278
+ },
279
+ "video": {
280
+ "title": "EditableHtmlButtonConfigure",
281
+ "type": "object",
282
+ "properties": {
283
+ "disabled": {
284
+ "description": "Indicates if the plugin is disabled or not",
285
+ "type": "boolean",
286
+ "title": "disabled"
287
+ }
288
+ }
289
+ },
290
+ "image": {
291
+ "title": "EditableHtmlButtonConfigure",
292
+ "type": "object",
293
+ "properties": {
294
+ "disabled": {
295
+ "description": "Indicates if the plugin is disabled or not",
296
+ "type": "boolean",
297
+ "title": "disabled"
298
+ }
299
+ }
300
+ }
301
+ }
302
+ },
303
+ "required": {
304
+ "description": "Indicates if the item is required and the value cannot be empty",
305
+ "type": "boolean",
306
+ "title": "required"
307
+ },
308
+ "settings": {
309
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
310
+ "type": "boolean",
311
+ "title": "settings"
312
+ },
313
+ "label": {
314
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
315
+ "type": "string",
316
+ "title": "label"
317
+ }
318
+ }
319
+ },
249
320
  "EditableHtmlPluginConfigure": {
250
321
  "title": "EditableHtmlPluginConfigure",
251
322
  "type": "object",
@@ -168,6 +168,58 @@ Indicates if the item has to be displayed in the Settings Panel
168
168
 
169
169
  Indicates the label for the item that has to be displayed in the Settings Panel
170
170
 
171
+ ## `EditableHtmlPluginConfigureRequired` (object)
172
+
173
+ Properties of the `EditableHtmlPluginConfigureRequired` object:
174
+
175
+ ### `inputConfiguration` (object)
176
+
177
+ Properties of the `inputConfiguration` object:
178
+
179
+ #### `math` (object)
180
+
181
+ Properties of the `math` object:
182
+
183
+ ##### `disabled` (boolean)
184
+
185
+ Indicates if the plugin is disabled or not
186
+
187
+ #### `audio` (object)
188
+
189
+ Properties of the `audio` object:
190
+
191
+ ##### `disabled` (boolean)
192
+
193
+ Indicates if the plugin is disabled or not
194
+
195
+ #### `video` (object)
196
+
197
+ Properties of the `video` object:
198
+
199
+ ##### `disabled` (boolean)
200
+
201
+ Indicates if the plugin is disabled or not
202
+
203
+ #### `image` (object)
204
+
205
+ Properties of the `image` object:
206
+
207
+ ##### `disabled` (boolean)
208
+
209
+ Indicates if the plugin is disabled or not
210
+
211
+ ### `required` (boolean)
212
+
213
+ Indicates if the item is required and the value cannot be empty
214
+
215
+ ### `settings` (boolean)
216
+
217
+ Indicates if the item has to be displayed in the Settings Panel
218
+
219
+ ### `label` (string)
220
+
221
+ Indicates the label for the item that has to be displayed in the Settings Panel
222
+
171
223
  ## `EditableHtmlPluginConfigure` (object)
172
224
 
173
225
  Properties of the `EditableHtmlPluginConfigure` object:
@@ -1,4 +1,4 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.0/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.1/module/index.js";
2
2
  import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@4.0.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
@@ -16513,7 +16513,7 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
16513
16513
  var _this$props7 = this.props, classes = _this$props7.classes, model = _this$props7.model, configuration = _this$props7.configuration, onConfigurationChanged = _this$props7.onConfigurationChanged, imageSupport = _this$props7.imageSupport, uploadSoundSupport = _this$props7.uploadSoundSupport;
16514
16514
  var _ref = configuration || ({}), _ref$baseInputConfigu = _ref.baseInputConfiguration, baseInputConfiguration = _ref$baseInputConfigu === void 0 ? {} : _ref$baseInputConfigu, _ref$contentDimension = _ref.contentDimensions, contentDimensions = _ref$contentDimension === void 0 ? {} : _ref$contentDimension, _ref$maxImageWidth = _ref.maxImageWidth, maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth, _ref$maxImageHeight = _ref.maxImageHeight, maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight, _ref$maxLengthPerChoi = _ref.maxLengthPerChoice, maxLengthPerChoice = _ref$maxLengthPerChoi === void 0 ? {} : _ref$maxLengthPerChoi, maxResponseAreas = _ref.maxResponseAreas, _ref$partialScoring = _ref.partialScoring, partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring, _ref$playerSpellCheck = _ref.playerSpellCheck, playerSpellCheck = _ref$playerSpellCheck === void 0 ? {} : _ref$playerSpellCheck, _ref$prompt = _ref.prompt, prompt = _ref$prompt === void 0 ? {} : _ref$prompt, _ref$rationale = _ref.rationale, rationale = _ref$rationale === void 0 ? {} : _ref$rationale, _ref$template = _ref.template, template = _ref$template === void 0 ? {} : _ref$template, settingsPanelDisabled = _ref.settingsPanelDisabled, _ref$spellCheck = _ref.spellCheck, spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck, _ref$editSource = _ref.editSource, editSource = _ref$editSource === void 0 ? {} : _ref$editSource, _ref$teacherInstructi = _ref.teacherInstructions, teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi, _ref$withRubric = _ref.withRubric, withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric, _ref$mathMlOptions = _ref.mathMlOptions, mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions, _ref$language = _ref.language, language = _ref$language === void 0 ? {} : _ref$language, _ref$languageChoices = _ref.languageChoices, languageChoices = _ref$languageChoices === void 0 ? {} : _ref$languageChoices;
16515
16515
  var _ref2 = model || ({}), errors = _ref2.errors, maxLengthPerChoiceEnabled = _ref2.maxLengthPerChoiceEnabled, promptEnabled = _ref2.promptEnabled, rationaleEnabled = _ref2.rationaleEnabled, spellCheckEnabled = _ref2.spellCheckEnabled, teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled, toolbarEditorPosition = _ref2.toolbarEditorPosition;
16516
- var _ref3 = errors || ({}), _ref3$choicesErrors = _ref3.choicesErrors, choicesErrors = _ref3$choicesErrors === void 0 ? {} : _ref3$choicesErrors, responseAreasError = _ref3.responseAreasError;
16516
+ var _ref3 = errors || ({}), _ref3$choices = _ref3.choices, choicesErrors = _ref3$choices === void 0 ? {} : _ref3$choices, promptError = _ref3.prompt, rationaleError = _ref3.rationale, responseAreasError = _ref3.responseAreas, teacherInstructionsError = _ref3.teacherInstructions;
16517
16517
  var validationMessage = (0, _utils.generateValidationMessage)(configuration);
16518
16518
  var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
16519
16519
  var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
@@ -16565,6 +16565,7 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
16565
16565
  onChange: this.onTeacherInstructionsChanged,
16566
16566
  imageSupport: imageSupport,
16567
16567
  nonEmpty: false,
16568
+ error: teacherInstructionsError,
16568
16569
  toolbarOpts: toolbarOpts,
16569
16570
  pluginProps: getPluginProps(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration),
16570
16571
  spellCheck: spellCheckEnabled,
@@ -16577,7 +16578,9 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
16577
16578
  language: 'special'
16578
16579
  }],
16579
16580
  mathMlOptions: mathMlOptions
16580
- })), promptEnabled && _react["default"].createElement(_configUi.InputContainer, {
16581
+ }), teacherInstructionsError && _react["default"].createElement("div", {
16582
+ className: classes.errorText
16583
+ }, teacherInstructionsError)), promptEnabled && _react["default"].createElement(_configUi.InputContainer, {
16581
16584
  label: prompt.label,
16582
16585
  className: classes.promptHolder
16583
16586
  }, _react["default"].createElement(_editableHtml.EditableHtml, {
@@ -16587,6 +16590,7 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
16587
16590
  imageSupport: imageSupport,
16588
16591
  nonEmpty: false,
16589
16592
  disableUnderline: true,
16593
+ error: promptError,
16590
16594
  toolbarOpts: toolbarOpts,
16591
16595
  pluginProps: getPluginProps(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration),
16592
16596
  spellCheck: spellCheckEnabled,
@@ -16599,7 +16603,9 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
16599
16603
  language: 'special'
16600
16604
  }],
16601
16605
  mathMlOptions: mathMlOptions
16602
- })), _react["default"].createElement("div", {
16606
+ }), promptError && _react["default"].createElement("div", {
16607
+ className: classes.errorText
16608
+ }, promptError)), _react["default"].createElement("div", {
16603
16609
  className: classes.flexContainer
16604
16610
  }, _react["default"].createElement(_Typography["default"], {
16605
16611
  className: classes.text
@@ -16686,6 +16692,7 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
16686
16692
  markup: model.rationale || '',
16687
16693
  onChange: this.onRationaleChanged,
16688
16694
  imageSupport: imageSupport,
16695
+ error: rationaleError,
16689
16696
  toolbarOpts: toolbarOpts,
16690
16697
  pluginProps: getPluginProps(rationale === null || rationale === void 0 ? void 0 : rationale.inputConfiguration),
16691
16698
  spellCheck: spellCheckEnabled,
@@ -16698,7 +16705,9 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
16698
16705
  language: 'special'
16699
16706
  }],
16700
16707
  mathMlOptions: mathMlOptions
16701
- })));
16708
+ }), rationaleError && _react["default"].createElement("div", {
16709
+ className: classes.errorText
16710
+ }, rationaleError)));
16702
16711
  }
16703
16712
  }]);
16704
16713
  return Main;
@@ -16806,7 +16815,8 @@ var defaults = {};
16806
16815
  image: {
16807
16816
  disabled: false
16808
16817
  }
16809
- }
16818
+ },
16819
+ required: false
16810
16820
  },
16811
16821
  partialScoring: {
16812
16822
  settings: false,
@@ -16825,7 +16835,8 @@ var defaults = {};
16825
16835
  image: {
16826
16836
  disabled: false
16827
16837
  }
16828
- }
16838
+ },
16839
+ required: false
16829
16840
  },
16830
16841
  settingsPanelDisabled: false,
16831
16842
  spellCheck: {
@@ -16856,7 +16867,8 @@ var defaults = {};
16856
16867
  image: {
16857
16868
  disabled: false
16858
16869
  }
16859
- }
16870
+ },
16871
+ required: false
16860
16872
  },
16861
16873
  template: {
16862
16874
  inputConfiguration: {
@@ -24803,7 +24803,7 @@ function model(question, session, env) {
24803
24803
  displayType: normalizedQuestion.displayType,
24804
24804
  playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,
24805
24805
  responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,
24806
- language: normalizedQuestion.language
24806
+ language: normalizedQuestion.language,
24807
24807
  };
24808
24808
 
24809
24809
  if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
@@ -24899,10 +24899,20 @@ const createCorrectResponseSession = (question, env) => {
24899
24899
  });
24900
24900
  };
24901
24901
 
24902
+ // remove all html tags except img and iframe
24903
+ const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
24904
+
24902
24905
  const validate = (model = {}, config = {}) => {
24903
24906
  const { choices, markup } = model;
24904
24907
  const { maxResponseAreas } = config;
24905
24908
  const allChoicesErrors = {};
24909
+ const errors = {};
24910
+
24911
+ ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {
24912
+ if (config[field]?.required && !getContent(model[field])) {
24913
+ errors[field] = 'This field is required.';
24914
+ }
24915
+ });
24906
24916
 
24907
24917
  Object.entries(choices || {}).forEach(([key, values]) => {
24908
24918
  const reversedChoices = [...(values || [])].reverse();
@@ -24927,17 +24937,16 @@ const validate = (model = {}, config = {}) => {
24927
24937
  }
24928
24938
  });
24929
24939
 
24930
- const errors = {};
24931
24940
  const nbOfResponseAreas = (markup.match(/\{\{(\d+)\}\}/g) || []).length;
24932
24941
 
24933
24942
  if (nbOfResponseAreas > maxResponseAreas) {
24934
- errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;
24943
+ errors.responseAreas = `No more than ${maxResponseAreas} response areas should be defined.`;
24935
24944
  } else if (nbOfResponseAreas < 1) {
24936
- errors.responseAreasError = 'There should be at least 1 response area defined.';
24945
+ errors.responseAreas = 'There should be at least 1 response area defined.';
24937
24946
  }
24938
24947
 
24939
24948
  if (!isEmpty_1(allChoicesErrors)) {
24940
- errors.choicesErrors = allChoicesErrors;
24949
+ errors.choices = allChoicesErrors;
24941
24950
  }
24942
24951
 
24943
24952
  return errors;
package/module/element.js CHANGED
@@ -1,4 +1,4 @@
1
- import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.0/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.1/module/index.js";
2
2
  import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.0.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
@@ -4,7 +4,7 @@
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
7
- "version": "1.5.0"
7
+ "version": "1.5.1"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
package/module/print.js CHANGED
@@ -1,4 +1,4 @@
1
- import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.0/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.1/module/index.js";
2
2
  import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.0.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "6.7.1-next.0+18816ef1d",
7
+ "version": "6.7.1-next.33+8fc82ab19",
8
8
  "description": "",
9
9
  "scripts": {
10
10
  "postpublish": "../../scripts/postpublish"
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@material-ui/core": "^3.9.2",
14
14
  "@pie-framework/pie-player-events": "^0.1.0",
15
- "@pie-lib/pie-toolbox": "1.12.1",
15
+ "@pie-lib/pie-toolbox": "1.12.2",
16
16
  "classnames": "^2.2.5",
17
17
  "lodash": "^4.17.10",
18
18
  "prop-types": "^15.6.1",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "author": "",
23
23
  "license": "ISC",
24
- "gitHead": "18816ef1de94386135b7da95e4e932fbd20cc75a",
24
+ "gitHead": "8fc82ab19baf45aecb40e4b364a7c307a9840130",
25
25
  "main": "lib/index.js",
26
26
  "module": "src/index.js",
27
27
  "exports": {