@pie-element/inline-dropdown 5.0.4-next.0 → 5.0.4-next.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/defaults.js +6 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/main.js +23 -7
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +1 -1
- package/controller/lib/index.js +11 -0
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +49 -13
- package/docs/config-schema.json.md +38 -10
- package/docs/pie-schema.json +26 -5
- package/docs/pie-schema.json.md +21 -5
- package/package.json +3 -3
|
@@ -24,7 +24,8 @@ var _default = {
|
|
|
24
24
|
configuration: {
|
|
25
25
|
prompt: {
|
|
26
26
|
settings: true,
|
|
27
|
-
label: 'Prompt'
|
|
27
|
+
label: 'Prompt',
|
|
28
|
+
required: false
|
|
28
29
|
},
|
|
29
30
|
settingsPanelDisabled: false,
|
|
30
31
|
spellCheck: {
|
|
@@ -42,11 +43,13 @@ var _default = {
|
|
|
42
43
|
},
|
|
43
44
|
rationale: {
|
|
44
45
|
settings: true,
|
|
45
|
-
label: 'Rationale'
|
|
46
|
+
label: 'Rationale',
|
|
47
|
+
required: false
|
|
46
48
|
},
|
|
47
49
|
teacherInstructions: {
|
|
48
50
|
settings: true,
|
|
49
|
-
label: 'Teacher Instructions'
|
|
51
|
+
label: 'Teacher Instructions',
|
|
52
|
+
required: false
|
|
50
53
|
},
|
|
51
54
|
choiceRationale: {
|
|
52
55
|
settings: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","disabled","mode","prompt","shuffle","markup","choices","alternateResponse","promptEnabled","rationaleEnabled","choiceRationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","toolbarEditorPosition","displayType","configuration","settings","label","settingsPanelDisabled","spellCheck","enabled","lockChoiceOrder","partialScoring","rationale","teacherInstructions","choiceRationale","maxResponseAreas","maxResponseAreaChoices","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,4CAHH;AAILC,IAAAA,OAAO,EAAE,IAJJ;AAKLC,IAAAA,MAAM,EAAE,EALH;AAMLC,IAAAA,OAAO,EAAE,EANJ;AAOLC,IAAAA,iBAAiB,EAAE,EAPd;AAQLC,IAAAA,aAAa,EAAE,IARV;AASLC,IAAAA,gBAAgB,EAAE,IATb;AAULC,IAAAA,sBAAsB,EAAE,IAVnB;AAWLC,IAAAA,0BAA0B,EAAE,IAXvB;AAYLC,IAAAA,0BAA0B,EAAE,IAZvB;AAaLC,IAAAA,qBAAqB,EAAE,QAblB;AAcLC,IAAAA,WAAW,EAAE;AAdR,GADM;AAiBbC,EAAAA,aAAa,EAAE;AACbZ,IAAAA,MAAM,EAAE;AACNa,MAAAA,QAAQ,EAAE,IADJ;AAENC,MAAAA,KAAK,EAAE;
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","disabled","mode","prompt","shuffle","markup","choices","alternateResponse","promptEnabled","rationaleEnabled","choiceRationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","toolbarEditorPosition","displayType","configuration","settings","label","required","settingsPanelDisabled","spellCheck","enabled","lockChoiceOrder","partialScoring","rationale","teacherInstructions","choiceRationale","maxResponseAreas","maxResponseAreaChoices","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,4CAHH;AAILC,IAAAA,OAAO,EAAE,IAJJ;AAKLC,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IAAAA,qBAAqB,EAAE;AACrBG,MAAAA,QAAQ,EAAE,KADW;AAErBC,MAAAA,KAAK,EAAE;AAFc,KAlCV;AAsCbU,IAAAA,gBAAgB,EAAE,EAtCL;AAuCbC,IAAAA,sBAAsB,EAAE,EAvCX;AAwCbC,IAAAA,aAAa,EAAE;AACbJ,MAAAA,mBAAmB,EAAE,GADR;AAEbtB,MAAAA,MAAM,EAAE,GAFK;AAGbqB,MAAAA,SAAS,EAAE;AAHE,KAxCF;AA6CbM,IAAAA,cAAc,EAAE;AACdL,MAAAA,mBAAmB,EAAE,GADP;AAEdtB,MAAAA,MAAM,EAAE,GAFM;AAGdqB,MAAAA,SAAS,EAAE;AAHG,KA7CH;AAkDbO,IAAAA,UAAU,EAAE;AACVf,MAAAA,QAAQ,EAAE,KADA;AAEVC,MAAAA,KAAK,EAAE;AAFG,KAlDC;AAsDbe,IAAAA,aAAa,EAAE;AACbC,MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,UAAU,EAAE;AAFC,KAtDF;AA0DbC,IAAAA,QAAQ,EAAE;AACRnB,MAAAA,QAAQ,EAAE,KADF;AAERC,MAAAA,KAAK,EAAE,kBAFC;AAGRI,MAAAA,OAAO,EAAE;AAHD,KA1DG;AA+Dbe,IAAAA,eAAe,EAAE;AACfnB,MAAAA,KAAK,EAAE,kBADQ;AAEfoB,MAAAA,OAAO,EAAE;AAFM;AA/DJ;AAjBF,C","sourcesContent":["export default {\n model: {\n disabled: false,\n mode: 'gather',\n prompt: 'Use the dropdowns to complete the sentence',\n shuffle: true,\n markup: '',\n choices: {},\n alternateResponse: {},\n promptEnabled: true,\n rationaleEnabled: true,\n choiceRationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n displayType: 'block',\n },\n configuration: {\n prompt: {\n settings: true,\n label: 'Prompt',\n required: false,\n },\n settingsPanelDisabled: false,\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n lockChoiceOrder: {\n settings: true,\n label: 'Lock Choice Order',\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n required: false,\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n required: false,\n },\n choiceRationale: {\n settings: true,\n label: 'Choice Rationale',\n },\n toolbarEditorPosition: {\n settings: false,\n label: 'Toolbar Editor Position',\n },\n maxResponseAreas: 10,\n maxResponseAreaChoices: 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"}
|
package/configure/lib/main.js
CHANGED
|
@@ -92,7 +92,6 @@ var styles = function styles(theme) {
|
|
|
92
92
|
},
|
|
93
93
|
markup: {
|
|
94
94
|
minHeight: '100px',
|
|
95
|
-
paddingBottom: theme.spacing.unit * 2.5,
|
|
96
95
|
width: '100%',
|
|
97
96
|
'& [data-slate-editor="true"]': {
|
|
98
97
|
minHeight: '100px'
|
|
@@ -113,6 +112,9 @@ var styles = function styles(theme) {
|
|
|
113
112
|
rationaleChoices: {
|
|
114
113
|
marginBottom: theme.spacing.unit * 2.5
|
|
115
114
|
},
|
|
115
|
+
responseArea: {
|
|
116
|
+
paddingBottom: theme.spacing.unit * 2.5
|
|
117
|
+
},
|
|
116
118
|
panelDetails: {
|
|
117
119
|
display: 'block',
|
|
118
120
|
paddingTop: 0,
|
|
@@ -468,8 +470,11 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
468
470
|
toolbarEditorPosition = _ref2.toolbarEditorPosition;
|
|
469
471
|
|
|
470
472
|
var _ref3 = errors || {},
|
|
473
|
+
promptError = _ref3.prompt,
|
|
474
|
+
rationaleError = _ref3.rationale,
|
|
471
475
|
responseAreasError = _ref3.responseAreasError,
|
|
472
|
-
responseAreaChoicesError = _ref3.responseAreaChoicesError
|
|
476
|
+
responseAreaChoicesError = _ref3.responseAreaChoicesError,
|
|
477
|
+
teacherInstructionsError = _ref3.teacherInstructions;
|
|
473
478
|
|
|
474
479
|
var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
475
480
|
var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
@@ -558,6 +563,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
558
563
|
onChange: this.onTeacherInstructionsChanged,
|
|
559
564
|
imageSupport: imageSupport,
|
|
560
565
|
nonEmpty: false,
|
|
566
|
+
error: teacherInstructionsError,
|
|
561
567
|
toolbarOpts: toolbarOpts,
|
|
562
568
|
spellCheck: spellCheckEnabled,
|
|
563
569
|
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
@@ -569,7 +575,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
569
575
|
language: 'special'
|
|
570
576
|
}],
|
|
571
577
|
mathMlOptions: mathMlOptions
|
|
572
|
-
})
|
|
578
|
+
}), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
579
|
+
className: classes.errorText
|
|
580
|
+
}, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
573
581
|
label: prompt.label,
|
|
574
582
|
className: classes.promptHolder
|
|
575
583
|
}, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
@@ -579,6 +587,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
579
587
|
imageSupport: imageSupport,
|
|
580
588
|
nonEmpty: false,
|
|
581
589
|
disableUnderline: true,
|
|
590
|
+
error: promptError,
|
|
582
591
|
toolbarOpts: toolbarOpts,
|
|
583
592
|
spellCheck: spellCheckEnabled,
|
|
584
593
|
maxImageWidth: defaultImageMaxWidth,
|
|
@@ -590,7 +599,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
590
599
|
language: 'special'
|
|
591
600
|
}],
|
|
592
601
|
mathMlOptions: mathMlOptions
|
|
593
|
-
})
|
|
602
|
+
}), promptError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
603
|
+
className: classes.errorText
|
|
604
|
+
}, promptError)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
594
605
|
className: classes.flexContainer
|
|
595
606
|
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
596
607
|
className: classes.text
|
|
@@ -605,7 +616,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
605
616
|
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
606
617
|
fontSize: 'small',
|
|
607
618
|
color: 'primary'
|
|
608
|
-
}))), /*#__PURE__*/_react["default"].createElement(
|
|
619
|
+
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
620
|
+
className: classes.responseArea
|
|
621
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
609
622
|
activePlugins: _editableHtml.ALL_PLUGINS,
|
|
610
623
|
toolbarOpts: {
|
|
611
624
|
position: 'top'
|
|
@@ -659,7 +672,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
659
672
|
className: classes.errorText
|
|
660
673
|
}, responseAreasError), responseAreaChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
661
674
|
className: classes.errorText
|
|
662
|
-
}, responseAreaChoicesError), choiceRationaleEnabled && renderChoiceRationale(), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
675
|
+
}, responseAreaChoicesError)), choiceRationaleEnabled && renderChoiceRationale(), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
663
676
|
label: rationale.label,
|
|
664
677
|
className: classes.promptHolder
|
|
665
678
|
}, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
@@ -667,6 +680,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
667
680
|
markup: model.rationale || '',
|
|
668
681
|
onChange: this.onRationaleChanged,
|
|
669
682
|
imageSupport: imageSupport,
|
|
683
|
+
error: rationaleError,
|
|
670
684
|
toolbarOpts: toolbarOpts,
|
|
671
685
|
spellCheck: spellCheckEnabled,
|
|
672
686
|
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
@@ -678,7 +692,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
678
692
|
language: 'special'
|
|
679
693
|
}],
|
|
680
694
|
mathMlOptions: mathMlOptions
|
|
681
|
-
})
|
|
695
|
+
}), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
696
|
+
className: classes.errorText
|
|
697
|
+
}, rationaleError)), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
682
698
|
open: warning.open,
|
|
683
699
|
title: "Warning",
|
|
684
700
|
text: warning.text,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","dropdown","styles","theme","promptHolder","width","paddingTop","spacing","unit","marginBottom","markup","minHeight","paddingBottom","choiceConfiguration","text","fontSize","typography","marginRight","rationaleLabel","display","whiteSpace","rationaleChoices","panelDetails","flexContainer","alignItems","tooltip","maxWidth","errorText","color","palette","error","main","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","prepareVal","html","tmp","value","textContent","innerText","Main","warning","open","newVal","props","onModelChanged","model","prompt","onModelChange","rationale","index","choice","indexOfChoice","choices","findIndex","elem","label","splice","teacherInstructions","slateMarkup","callback","setState","onClose","onConfirm","respAreaChoices","state","domMarkup","allRespAreas","querySelectorAll","allChoices","forEach","el","dataset","existingRespAreaChoices","obj","key","newRespAreaChoices","shouldWarn","newChoices","length","find","c","correct","remove","choiceIndex","maxResponseAreaChoices","configuration","undefined","r","map","parseInt","filter","val","isNaN","push","respIndex","selectedIndex","nProps","newState","domNode","ReactDOM","findDOMNode","classes","onConfigurationChanged","imageSupport","uploadSoundSupport","choiceRationale","contentDimensions","lockChoiceOrder","maxResponseAreas","maxImageWidth","maxImageHeight","partialScoring","settingsPanelDisabled","spellCheck","withRubric","mathMlOptions","language","languageChoices","choiceRationaleEnabled","errors","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","responseAreasError","responseAreaChoicesError","defaultImageMaxWidth","defaultImageMaxHeight","renderChoiceRationale","Object","keys","__html","onChoiceRationaleChanged","toolbarOpts","position","validationMessage","panelSettings","enabled","options","panelProperties","rubricEnabled","Settings","Properties","onTeacherInstructionsChanged","onPromptChanged","ALL_PLUGINS","type","duplicates","respAreaToolbar","node","onToolbarDone","onAddChoice","onCheck","onRemoveChoice","data","get","onSelectChoice","onChange","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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;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,C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AO,CAACqB,OAJnB;AAKE,QAAA,SAAS,EAAErB,OAAO,CAACsB;AALrB,QArIF,CADF;AA+ID;;;EAheuBkG,kBAAMC,S;;;iCAAnB1H,I,eACQ;AACjB8C,EAAAA,aAAa,EAAE6E,sBAAUC,MAAV,CAAiBC,UADf;AAEjBvH,EAAAA,KAAK,EAAEqH,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjB1H,EAAAA,cAAc,EAAEsH,sBAAUK,IAAV,CAAeH,UAJd;AAKjB9D,EAAAA,sBAAsB,EAAE4D,sBAAUK,IAAV,CAAeH,UALtB;AAMjB/D,EAAAA,OAAO,EAAE6D,sBAAUC,MAAV,CAAiBC,UANT;AAOjB7D,EAAAA,YAAY,EAAE2D,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CAPG;AAWjB5D,EAAAA,kBAAkB,EAAE0D,sBAAUM,KAAV,CAAgB;AAClCC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADc;AAElC,cAAQF,sBAAUK,IAAV,CAAeH;AAFW,GAAhB;AAXH,C;AAkerB,IAAMM,MAAM,GAAG,wBAAW9K,MAAX,EAAmB2C,IAAnB,CAAf;eAEemI,M","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/pie-toolbox/editable-html';\nimport { AlertDialog, InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEqual from 'lodash/isEqual';\nimport isUndefined from 'lodash/isUndefined';\nimport isEmpty from 'lodash/isEmpty';\nimport reduce from 'lodash/reduce';\nimport max from 'lodash/max';\nimport { withStyles } from '@material-ui/core/styles';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport ExpansionPanel from '@material-ui/core/ExpansionPanel';\nimport ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';\nimport ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Info from '@material-ui/icons/Info';\nimport InlineDropdownToolbar from './inline-dropdown-toolbar';\nimport { generateValidationMessage } from './utils';\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 paddingBottom: theme.spacing.unit * 2.5,\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 text: {\n fontSize: theme.typography.fontSize + 2,\n marginRight: theme.spacing.unit,\n },\n rationaleLabel: {\n display: 'flex',\n whiteSpace: 'break-spaces',\n },\n rationaleChoices: {\n marginBottom: theme.spacing.unit * 2.5,\n },\n panelDetails: {\n display: 'block',\n paddingTop: 0,\n paddingBottom: 0,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\n marginBottom: theme.spacing.unit,\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});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n\n div.innerHTML = (htmlString || '').trim();\n\n return div;\n};\n\nconst prepareVal = (html) => {\n const tmp = document.createElement('DIV');\n\n tmp.innerHTML = html;\n\n const value = tmp.textContent || tmp.innerText || '';\n\n return value.trim();\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.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n state = {\n warning: { open: false },\n };\n\n componentDidMount() {\n const {\n model: { choices },\n } = this.props;\n\n this.setState({ respAreaChoices: cloneDeep(choices) });\n }\n\n UNSAFE_componentWillReceiveProps(nProps) {\n const newState = {};\n\n if (\n !isEqual(nProps.model.choices, this.props.model.choices) ||\n !isEqual(nProps.model.choices, this.state.respAreaChoices)\n ) {\n newState.respAreaChoices = cloneDeep(nProps.model.choices);\n }\n\n if (!isEmpty(newState)) {\n this.setState(newState);\n }\n }\n\n componentDidUpdate() {\n //eslint-disable-next-line\n const domNode = ReactDOM.findDOMNode(this);\n\n renderMath(domNode);\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.onModelChange({ prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.onModelChange({ rationale });\n };\n\n onChoiceRationaleChanged = (index, choice) => {\n const { model } = this.props;\n const indexOfChoice =\n model.choices &&\n model.choices[index] &&\n model.choices[index].findIndex((elem) => elem.label === choice.label && elem.value === choice.value);\n\n model.choices[index] && model.choices[index].splice(indexOfChoice, 1, choice);\n\n this.onModelChange(model);\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.onModelChange({ teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.onModelChange({ slateMarkup });\n };\n\n onCheck = (callback) => {\n this.setState({\n warning: {\n open: true,\n text: 'Response areas with under 2 options or with no correct answers will be discarded.',\n onClose: () => {\n this.setState({ warning: { open: false } });\n },\n onConfirm: () => {\n this.setState({ warning: { open: false } }, callback);\n },\n },\n });\n };\n\n onChange = (markup) => {\n const { respAreaChoices } = this.state;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"inline_dropdown\"]');\n const allChoices = {};\n\n allRespAreas.forEach((el) => {\n allChoices[el.dataset.index] = el.dataset.value || '';\n });\n\n const existingRespAreaChoices = reduce(\n respAreaChoices,\n (obj, choices, key) => {\n if (!isUndefined(allChoices[key])) {\n obj[key] = respAreaChoices[key];\n }\n\n return obj;\n },\n {},\n );\n\n const newRespAreaChoices = {};\n let shouldWarn = false;\n\n allRespAreas.forEach((el, index) => {\n const newChoices = existingRespAreaChoices[el.dataset.index] || [];\n\n if (newChoices.length < 2 || !newChoices.find((c) => c.correct)) {\n el.remove();\n shouldWarn = true;\n } else {\n newRespAreaChoices[index] = existingRespAreaChoices[el.dataset.index] || [];\n el.dataset.index = index;\n }\n });\n\n if (shouldWarn) {\n this.setState({\n warning: {\n open: true,\n text: 'Response areas with under 2 options or with no correct answers will be discarded.',\n onClose: () => {\n this.setState({ warning: { open: false } });\n },\n onConfirm: () => {\n this.setState({ warning: { open: false } }, () =>\n this.onModelChange({\n choices: cloneDeep(newRespAreaChoices),\n slateMarkup: domMarkup.innerHTML,\n }),\n );\n },\n },\n });\n } else {\n this.onModelChange({\n choices: cloneDeep(newRespAreaChoices),\n slateMarkup: domMarkup.innerHTML,\n });\n }\n };\n\n onAddChoice = (index, label, choiceIndex) => {\n const { respAreaChoices } = this.state;\n const { maxResponseAreaChoices } = this.props.configuration;\n\n if (respAreaChoices[index] && respAreaChoices[index].length >= maxResponseAreaChoices) {\n this.setState({\n warning: {\n open: true,\n text: `There are only ${maxResponseAreaChoices} answers allowed per choice.`,\n onClose: undefined,\n onConfirm: () => {\n this.setState({ warning: { open: false } });\n },\n },\n });\n\n return;\n }\n\n if (!respAreaChoices[index]) {\n respAreaChoices[index] = [];\n }\n\n if ((respAreaChoices[index] || []).find((r) => prepareVal(r.label) === prepareVal(label))) {\n // show warning for duplicated answers\n this.setState({\n warning: {\n open: true,\n text: 'Duplicate answers are not allowed.',\n onClose: undefined,\n onConfirm: () => {\n this.setState({ warning: { open: false } });\n },\n },\n });\n\n return;\n }\n\n if (choiceIndex >= 0 && respAreaChoices[index]?.[choiceIndex]) {\n // we need to update the choice label with the new value\n respAreaChoices[index][choiceIndex].label = label;\n } else {\n // add a new choice\n const value =\n (respAreaChoices[index] &&\n max(respAreaChoices[index].map((c) => parseInt(c.value)).filter((val) => !isNaN(val)))) ||\n 0;\n\n respAreaChoices[index].push({\n label,\n value: `${value + 1}`,\n correct: false,\n });\n }\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n onRemoveChoice = (respIndex, index) => {\n const { respAreaChoices } = this.state;\n\n respAreaChoices[respIndex].splice(index, 1);\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n onSelectChoice = (respIndex, selectedIndex) => {\n const { respAreaChoices } = this.state;\n\n respAreaChoices[respIndex] = respAreaChoices[respIndex].map((choice, index) => ({\n ...choice,\n correct: index === selectedIndex,\n }));\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n render() {\n const { warning } = this.state;\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n choiceRationale = {},\n contentDimensions = {},\n lockChoiceOrder = {},\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n partialScoring = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n choiceRationaleEnabled,\n choices,\n errors,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n const { responseAreasError, responseAreaChoicesError } = errors || {};\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const renderChoiceRationale = () =>\n (Object.keys(choices) || []).map((key, index) => (\n <div key={key} className={classes.rationaleChoices}>\n <ExpansionPanel>\n <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>\n <Typography className={classes.text}>{`Rationale for response area #${index + 1}`}</Typography>\n </ExpansionPanelSummary>\n\n <ExpansionPanelDetails className={classes.panelDetails}>\n {(choices[key] || []).map((choice) => (\n <InputContainer\n key={choice.label}\n label={\n <span\n className={classes.rationaleLabel}\n dangerouslySetInnerHTML={{\n __html: `${rationale.label} for ${choice.label} (${choice.correct ? 'correct' : 'incorrect'})`,\n }}\n />\n }\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={choice.rationale || ''}\n spellCheck={spellCheckEnabled}\n onChange={(c) => this.onChoiceRationaleChanged(key, { ...choice, rationale: c })}\n imageSupport={imageSupport}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n ))}\n </ExpansionPanelDetails>\n </ExpansionPanel>\n </div>\n ));\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const validationMessage = generateValidationMessage(configuration);\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.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 choiceRationaleEnabled: choiceRationale.settings && toggle(choiceRationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\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 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 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'} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n responseAreaProps={{\n type: 'inline-dropdown',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { respAreaChoices } = this.state;\n\n return () => (\n <InlineDropdownToolbar\n onAddChoice={this.onAddChoice}\n onCheck={this.onCheck}\n onRemoveChoice={(index) => this.onRemoveChoice(node.data.get('index'), index)}\n onSelectChoice={(index) => this.onSelectChoice(node.data.get('index'), index)}\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n choices={respAreaChoices[node.data.get('index')]}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n />\n );\n },\n }}\n spellCheck={spellCheckEnabled}\n className={classes.markup}\n markup={model.slateMarkup || ''}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\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 {responseAreaChoicesError && <div className={classes.errorText}>{responseAreaChoicesError}</div>}\n\n {choiceRationaleEnabled && renderChoiceRationale()}\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 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\n <AlertDialog\n open={warning.open}\n title=\"Warning\"\n text={warning.text}\n onClose={warning.onClose}\n onConfirm={warning.onConfirm}\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","text","fontSize","typography","marginRight","rationaleLabel","display","whiteSpace","rationaleChoices","responseArea","panelDetails","flexContainer","alignItems","tooltip","maxWidth","errorText","color","palette","error","main","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","prepareVal","html","tmp","value","textContent","innerText","Main","warning","open","newVal","props","onModelChanged","model","prompt","onModelChange","rationale","index","choice","indexOfChoice","choices","findIndex","elem","label","splice","teacherInstructions","slateMarkup","callback","setState","onClose","onConfirm","respAreaChoices","state","domMarkup","allRespAreas","querySelectorAll","allChoices","forEach","el","dataset","existingRespAreaChoices","obj","key","newRespAreaChoices","shouldWarn","newChoices","length","find","c","correct","remove","choiceIndex","maxResponseAreaChoices","configuration","undefined","r","map","parseInt","filter","val","isNaN","push","respIndex","selectedIndex","nProps","newState","domNode","ReactDOM","findDOMNode","classes","onConfigurationChanged","imageSupport","uploadSoundSupport","choiceRationale","contentDimensions","lockChoiceOrder","maxResponseAreas","maxImageWidth","maxImageHeight","partialScoring","settingsPanelDisabled","spellCheck","withRubric","mathMlOptions","language","languageChoices","choiceRationaleEnabled","errors","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","promptError","rationaleError","responseAreasError","responseAreaChoicesError","teacherInstructionsError","defaultImageMaxWidth","defaultImageMaxHeight","renderChoiceRationale","Object","keys","__html","onChoiceRationaleChanged","toolbarOpts","position","validationMessage","panelSettings","enabled","options","panelProperties","rubricEnabled","Settings","Properties","onTeacherInstructionsChanged","onPromptChanged","ALL_PLUGINS","type","duplicates","respAreaToolbar","node","onToolbarDone","onAddChoice","onCheck","onRemoveChoice","data","get","onSelectChoice","onChange","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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;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;AAENN,MAAAA,KAAK,EAAE,MAFD;AAGN,sCAAgC;AAC9BM,QAAAA,SAAS,EAAE;AADmB;AAH1B,KANiB;AAazBC,IAAAA,mBAAmB,EAAE;AACnBN,MAAAA,UAAU,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CADd;AAEnBK,MAAAA,aAAa,EAAEV,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAFjB,KAbI;AAiBzBM,IAAAA,IAAI,EAAE;AACJC,MAAAA,QAAQ,EAAEZ,KAAK,CAACa,UAAN,CAAiB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OAAO,CAACC,IADhB;AAEE,QAAA,KAAK,EAAC,SAFR;AAGE,QAAA,IAAI,EAAED,OAAO,CAACjC,IAHhB;AAIE,QAAA,OAAO,EAAEiC,OAAO,CAACqB,OAJnB;AAKE,QAAA,SAAS,EAAErB,OAAO,CAACsB;AALrB,QA7IF,CADF;AAuJD;;;EA9euBqG,kBAAMC,S;;;iCAAnB7H,I,eACQ;AACjB8C,EAAAA,aAAa,EAAEgF,sBAAUC,MAAV,CAAiBC,UADf;AAEjB1H,EAAAA,KAAK,EAAEwH,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjB7H,EAAAA,cAAc,EAAEyH,sBAAUK,IAAV,CAAeH,UAJd;AAKjBjE,EAAAA,sBAAsB,EAAE+D,sBAAUK,IAAV,CAAeH,UALtB;AAMjBlE,EAAAA,OAAO,EAAEgE,sBAAUC,MAAV,CAAiBC,UANT;AAOjBhE,EAAAA,YAAY,EAAE8D,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CAPG;AAWjB/D,EAAAA,kBAAkB,EAAE6D,sBAAUM,KAAV,CAAgB;AAClCC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADc;AAElC,cAAQF,sBAAUK,IAAV,CAAeH;AAFW,GAAhB;AAXH,C;AAgfrB,IAAMM,MAAM,GAAG,wBAAWlL,MAAX,EAAmB4C,IAAnB,CAAf;eAEesI,M","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/pie-toolbox/editable-html';\nimport { AlertDialog, InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEqual from 'lodash/isEqual';\nimport isUndefined from 'lodash/isUndefined';\nimport isEmpty from 'lodash/isEmpty';\nimport reduce from 'lodash/reduce';\nimport max from 'lodash/max';\nimport { withStyles } from '@material-ui/core/styles';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport ExpansionPanel from '@material-ui/core/ExpansionPanel';\nimport ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';\nimport ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Info from '@material-ui/icons/Info';\nimport InlineDropdownToolbar from './inline-dropdown-toolbar';\nimport { generateValidationMessage } from './utils';\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 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 text: {\n fontSize: theme.typography.fontSize + 2,\n marginRight: theme.spacing.unit,\n },\n rationaleLabel: {\n display: 'flex',\n whiteSpace: 'break-spaces',\n },\n rationaleChoices: {\n marginBottom: theme.spacing.unit * 2.5,\n },\n responseArea: {\n paddingBottom: theme.spacing.unit * 2.5,\n },\n panelDetails: {\n display: 'block',\n paddingTop: 0,\n paddingBottom: 0,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\n marginBottom: theme.spacing.unit,\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});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n\n div.innerHTML = (htmlString || '').trim();\n\n return div;\n};\n\nconst prepareVal = (html) => {\n const tmp = document.createElement('DIV');\n\n tmp.innerHTML = html;\n\n const value = tmp.textContent || tmp.innerText || '';\n\n return value.trim();\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.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n state = {\n warning: { open: false },\n };\n\n componentDidMount() {\n const {\n model: { choices },\n } = this.props;\n\n this.setState({ respAreaChoices: cloneDeep(choices) });\n }\n\n UNSAFE_componentWillReceiveProps(nProps) {\n const newState = {};\n\n if (\n !isEqual(nProps.model.choices, this.props.model.choices) ||\n !isEqual(nProps.model.choices, this.state.respAreaChoices)\n ) {\n newState.respAreaChoices = cloneDeep(nProps.model.choices);\n }\n\n if (!isEmpty(newState)) {\n this.setState(newState);\n }\n }\n\n componentDidUpdate() {\n //eslint-disable-next-line\n const domNode = ReactDOM.findDOMNode(this);\n\n renderMath(domNode);\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.onModelChange({ prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.onModelChange({ rationale });\n };\n\n onChoiceRationaleChanged = (index, choice) => {\n const { model } = this.props;\n const indexOfChoice =\n model.choices &&\n model.choices[index] &&\n model.choices[index].findIndex((elem) => elem.label === choice.label && elem.value === choice.value);\n\n model.choices[index] && model.choices[index].splice(indexOfChoice, 1, choice);\n\n this.onModelChange(model);\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.onModelChange({ teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.onModelChange({ slateMarkup });\n };\n\n onCheck = (callback) => {\n this.setState({\n warning: {\n open: true,\n text: 'Response areas with under 2 options or with no correct answers will be discarded.',\n onClose: () => {\n this.setState({ warning: { open: false } });\n },\n onConfirm: () => {\n this.setState({ warning: { open: false } }, callback);\n },\n },\n });\n };\n\n onChange = (markup) => {\n const { respAreaChoices } = this.state;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"inline_dropdown\"]');\n const allChoices = {};\n\n allRespAreas.forEach((el) => {\n allChoices[el.dataset.index] = el.dataset.value || '';\n });\n\n const existingRespAreaChoices = reduce(\n respAreaChoices,\n (obj, choices, key) => {\n if (!isUndefined(allChoices[key])) {\n obj[key] = respAreaChoices[key];\n }\n\n return obj;\n },\n {},\n );\n\n const newRespAreaChoices = {};\n let shouldWarn = false;\n\n allRespAreas.forEach((el, index) => {\n const newChoices = existingRespAreaChoices[el.dataset.index] || [];\n\n if (newChoices.length < 2 || !newChoices.find((c) => c.correct)) {\n el.remove();\n shouldWarn = true;\n } else {\n newRespAreaChoices[index] = existingRespAreaChoices[el.dataset.index] || [];\n el.dataset.index = index;\n }\n });\n\n if (shouldWarn) {\n this.setState({\n warning: {\n open: true,\n text: 'Response areas with under 2 options or with no correct answers will be discarded.',\n onClose: () => {\n this.setState({ warning: { open: false } });\n },\n onConfirm: () => {\n this.setState({ warning: { open: false } }, () =>\n this.onModelChange({\n choices: cloneDeep(newRespAreaChoices),\n slateMarkup: domMarkup.innerHTML,\n }),\n );\n },\n },\n });\n } else {\n this.onModelChange({\n choices: cloneDeep(newRespAreaChoices),\n slateMarkup: domMarkup.innerHTML,\n });\n }\n };\n\n onAddChoice = (index, label, choiceIndex) => {\n const { respAreaChoices } = this.state;\n const { maxResponseAreaChoices } = this.props.configuration;\n\n if (respAreaChoices[index] && respAreaChoices[index].length >= maxResponseAreaChoices) {\n this.setState({\n warning: {\n open: true,\n text: `There are only ${maxResponseAreaChoices} answers allowed per choice.`,\n onClose: undefined,\n onConfirm: () => {\n this.setState({ warning: { open: false } });\n },\n },\n });\n\n return;\n }\n\n if (!respAreaChoices[index]) {\n respAreaChoices[index] = [];\n }\n\n if ((respAreaChoices[index] || []).find((r) => prepareVal(r.label) === prepareVal(label))) {\n // show warning for duplicated answers\n this.setState({\n warning: {\n open: true,\n text: 'Duplicate answers are not allowed.',\n onClose: undefined,\n onConfirm: () => {\n this.setState({ warning: { open: false } });\n },\n },\n });\n\n return;\n }\n\n if (choiceIndex >= 0 && respAreaChoices[index]?.[choiceIndex]) {\n // we need to update the choice label with the new value\n respAreaChoices[index][choiceIndex].label = label;\n } else {\n // add a new choice\n const value =\n (respAreaChoices[index] &&\n max(respAreaChoices[index].map((c) => parseInt(c.value)).filter((val) => !isNaN(val)))) ||\n 0;\n\n respAreaChoices[index].push({\n label,\n value: `${value + 1}`,\n correct: false,\n });\n }\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n onRemoveChoice = (respIndex, index) => {\n const { respAreaChoices } = this.state;\n\n respAreaChoices[respIndex].splice(index, 1);\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n onSelectChoice = (respIndex, selectedIndex) => {\n const { respAreaChoices } = this.state;\n\n respAreaChoices[respIndex] = respAreaChoices[respIndex].map((choice, index) => ({\n ...choice,\n correct: index === selectedIndex,\n }));\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n render() {\n const { warning } = this.state;\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n choiceRationale = {},\n contentDimensions = {},\n lockChoiceOrder = {},\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n partialScoring = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n choiceRationaleEnabled,\n choices,\n errors,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n const {\n prompt: promptError,\n rationale: rationaleError,\n responseAreasError,\n responseAreaChoicesError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const renderChoiceRationale = () =>\n (Object.keys(choices) || []).map((key, index) => (\n <div key={key} className={classes.rationaleChoices}>\n <ExpansionPanel>\n <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>\n <Typography className={classes.text}>{`Rationale for response area #${index + 1}`}</Typography>\n </ExpansionPanelSummary>\n\n <ExpansionPanelDetails className={classes.panelDetails}>\n {(choices[key] || []).map((choice) => (\n <InputContainer\n key={choice.label}\n label={\n <span\n className={classes.rationaleLabel}\n dangerouslySetInnerHTML={{\n __html: `${rationale.label} for ${choice.label} (${choice.correct ? 'correct' : 'incorrect'})`,\n }}\n />\n }\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={choice.rationale || ''}\n spellCheck={spellCheckEnabled}\n onChange={(c) => this.onChoiceRationaleChanged(key, { ...choice, rationale: c })}\n imageSupport={imageSupport}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n ))}\n </ExpansionPanelDetails>\n </ExpansionPanel>\n </div>\n ));\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const validationMessage = generateValidationMessage(configuration);\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.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 choiceRationaleEnabled: choiceRationale.settings && toggle(choiceRationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\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 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 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'} />\n </Tooltip>\n </div>\n\n <div className={classes.responseArea}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n responseAreaProps={{\n type: 'inline-dropdown',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { respAreaChoices } = this.state;\n\n return () => (\n <InlineDropdownToolbar\n onAddChoice={this.onAddChoice}\n onCheck={this.onCheck}\n onRemoveChoice={(index) => this.onRemoveChoice(node.data.get('index'), index)}\n onSelectChoice={(index) => this.onSelectChoice(node.data.get('index'), index)}\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n choices={respAreaChoices[node.data.get('index')]}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n />\n );\n },\n }}\n spellCheck={spellCheckEnabled}\n className={classes.markup}\n markup={model.slateMarkup || ''}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\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 {responseAreaChoicesError && <div className={classes.errorText}>{responseAreaChoicesError}</div>}\n </div>\n\n {choiceRationaleEnabled && renderChoiceRationale()}\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 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\n <AlertDialog\n open={warning.open}\n title=\"Warning\"\n text={warning.text}\n onClose={warning.onClose}\n onConfirm={warning.onConfirm}\n />\n </layout.ConfigLayout>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
package/configure/package.json
CHANGED
|
@@ -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.
|
|
11
|
+
"@pie-lib/pie-toolbox": "1.2.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"debug": "^3.1.0",
|
|
14
14
|
"lodash": "^4.17.15",
|
package/controller/lib/index.js
CHANGED
|
@@ -318,6 +318,10 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
318
318
|
|
|
319
319
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
320
320
|
|
|
321
|
+
var getInnerText = function getInnerText(html) {
|
|
322
|
+
return (html || '').replaceAll(/<[^>]*>/g, '');
|
|
323
|
+
};
|
|
324
|
+
|
|
321
325
|
var validate = function validate() {
|
|
322
326
|
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
323
327
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -326,6 +330,13 @@ var validate = function validate() {
|
|
|
326
330
|
var maxResponseAreas = config.maxResponseAreas,
|
|
327
331
|
maxResponseAreaChoices = config.maxResponseAreaChoices;
|
|
328
332
|
var errors = {};
|
|
333
|
+
['teacherInstructions', 'prompt', 'rationale'].forEach(function (field) {
|
|
334
|
+
var _config$field;
|
|
335
|
+
|
|
336
|
+
if ((_config$field = config[field]) !== null && _config$field !== void 0 && _config$field.required && !getInnerText(model[field])) {
|
|
337
|
+
errors[field] = 'This field is required';
|
|
338
|
+
}
|
|
339
|
+
});
|
|
329
340
|
var nbOfResponseAreas = ((markup || '').match(/\{\{(\d+)\}\}/g) || []).length;
|
|
330
341
|
|
|
331
342
|
if (nbOfResponseAreas > maxResponseAreas) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["getFeedback","correct","normalize","question","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","choiceRationaleEnabled","model","session","env","updateSession","Promise","resolve","normalizedQuestion","value","choices","obj","area","key","choice","feedback","mode","allCorrectResponses","respAreaLength","Object","keys","length","correctResponses","i","result","answer","correctChoice","isCorrect","lockChoiceOrder","teacherInstructions","rationale","choicesWillNullRationales","reduce","acc","currentValue","map","role","out","disabled","prompt","displayType","markup","responseCorrect","getScore","undefined","language","config","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","score","empty","partialScoringEnabled","partialScoring","enabled","Math","floor","createCorrectResponseSession","forEach","correctChoices","filter","c","id","validate","maxResponseAreas","maxResponseAreaChoices","errors","nbOfResponseAreas","match","responseAreasError","choiceKey","responseAreaChoicesError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,OAAD,EAAa;A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AAMA,SAAOC,MAAP;AACD,CApBM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport isEmpty from 'lodash/isEmpty';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\n\nimport { getAllCorrectResponses } from './utils';\n\nconst getFeedback = (correct) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question) => ({\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n choiceRationaleEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport function model(question, session, env, updateSession) {\n return new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n const keys = Object.keys(choices);\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n choices[key] = await getShuffledChoices(choices[key], session, updateSession, 'value');\n }\n }\n\n let teacherInstructions = null;\n let rationale = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language\n };\n\n resolve(out);\n });\n}\n\nexport const getScore = (config, session) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\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 if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\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 { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors = {};\n\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 defined at least 1 response area.';\n }\n\n (Object.keys(choices) || []).forEach((choiceKey) => {\n if (choices[choiceKey] && choices[choiceKey].length > maxResponseAreaChoices) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["getFeedback","correct","normalize","question","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","choiceRationaleEnabled","model","session","env","updateSession","Promise","resolve","normalizedQuestion","value","choices","obj","area","key","choice","feedback","mode","allCorrectResponses","respAreaLength","Object","keys","length","correctResponses","i","result","answer","correctChoice","isCorrect","lockChoiceOrder","teacherInstructions","rationale","choicesWillNullRationales","reduce","acc","currentValue","map","role","out","disabled","prompt","displayType","markup","responseCorrect","getScore","undefined","language","config","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","score","empty","partialScoringEnabled","partialScoring","enabled","Math","floor","createCorrectResponseSession","forEach","correctChoices","filter","c","id","getInnerText","html","replaceAll","validate","maxResponseAreas","maxResponseAreaChoices","errors","field","required","nbOfResponseAreas","match","responseAreasError","choiceKey","responseAreaChoicesError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,OAAD,EAAa;AAC/B,MAAIA,OAAJ,EAAa;AACX,WAAO,SAAP;AACD;;AAED,SAAO,WAAP;AACD,CAND;;AAQO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,QAAD;AAAA;AACvBC,IAAAA,aAAa,EAAE,IADQ;AAEvBC,IAAAA,gBAAgB,EAAE,IAFK;AAGvBC,IAAAA,0BAA0B,EAAE,IAHL;AAIvBC,IAAAA,0BAA0B,EAAE,IAJL;AAKvBC,IAAAA,sBAAsB,EAAE;AALD,KAMpBL,QANoB;AAAA,CAAlB;AASP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASM,KAAT,CAAeN,QAAf,EAAyBO,OAAzB,EAAkCC,GAAlC,EAAuCC,aAAvC,EAAsD;AAC3D,SAAO,IAAIC,OAAJ;AAAA,6FAAY,iBAAOC,OAAP;AAAA;;AAAA;AAAA;AAAA;AAAA;AACXC,cAAAA,kBADW,GACUb,SAAS,CAACC,QAAD,CADnB;AAAA,sBAEMO,OAAO,IAAI,EAFjB,sBAETM,KAFS,EAETA,KAFS,4BAED,EAFC;AAGbC,cAAAA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AAA,MAA0BC,sBAA1B,GAAqD1B,MAArD,CAA0B0B,sBAA1B;AACA,MAAMC,MAAM,GAAG,EAAf;AAEA,GAAC,qBAAD,EAAwB,QAAxB,EAAkC,WAAlC,EAA+CX,OAA/C,CAAuD,UAACY,KAAD,EAAW;AAAA;;AAChE,QAAI,iBAAA5B,MAAM,CAAC4B,KAAD,CAAN,wDAAeC,QAAf,IAA2B,CAACR,YAAY,CAACjE,KAAK,CAACwE,KAAD,CAAN,CAA5C,EAA4D;AAC1DD,MAAAA,MAAM,CAACC,KAAD,CAAN,GAAgB,wBAAhB;AACD;AACF,GAJD;AAMA,MAAME,iBAAiB,GAAG,CAAC,CAACnC,MAAM,IAAI,EAAX,EAAeoC,KAAf,CAAqB,gBAArB,KAA0C,EAA3C,EAA+CxD,MAAzE;;AAEA,MAAIuD,iBAAiB,GAAGL,gBAAxB,EAA0C;AACxCE,IAAAA,MAAM,CAACK,kBAAP,0BAA4CP,gBAA5C;AACD,GAFD,MAEO,IAAIK,iBAAiB,GAAG,CAAxB,EAA2B;AAChCH,IAAAA,MAAM,CAACK,kBAAP,GAA4B,mDAA5B;AACD;;AAED,GAAC3D,MAAM,CAACC,IAAP,CAAYV,OAAZ,KAAwB,EAAzB,EAA6BoD,OAA7B,CAAqC,UAACiB,SAAD,EAAe;AAClD,QAAIrE,OAAO,CAACqE,SAAD,CAAP,IAAsBrE,OAAO,CAACqE,SAAD,CAAP,CAAmB1D,MAAnB,GAA4BmD,sBAAtD,EAA8E;AAC5EC,MAAAA,MAAM,CAACO,wBAAP,0BAAkDR,sBAAlD;AACD;AACF,GAJD;AAMA,SAAOC,MAAP;AACD,CA1BM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport isEmpty from 'lodash/isEmpty';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\n\nimport { getAllCorrectResponses } from './utils';\n\nconst getFeedback = (correct) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question) => ({\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n choiceRationaleEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport function model(question, session, env, updateSession) {\n return new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n const keys = Object.keys(choices);\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n choices[key] = await getShuffledChoices(choices[key], session, updateSession, 'value');\n }\n }\n\n let teacherInstructions = null;\n let rationale = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language,\n };\n\n resolve(out);\n });\n}\n\nexport const getScore = (config, session) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\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 if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getInnerText(model[field])) {\n errors[field] = 'This field is required';\n }\n });\n\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 defined at least 1 response area.';\n }\n\n (Object.keys(choices) || []).forEach((choiceKey) => {\n if (choices[choiceKey] && choices[choiceKey].length > maxResponseAreaChoices) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/docs/config-schema.json
CHANGED
|
@@ -20,9 +20,14 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"prompt": {
|
|
23
|
-
"title": "
|
|
23
|
+
"title": "ConfigureRequiredProp",
|
|
24
24
|
"type": "object",
|
|
25
25
|
"properties": {
|
|
26
|
+
"required": {
|
|
27
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"title": "required"
|
|
30
|
+
},
|
|
26
31
|
"settings": {
|
|
27
32
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
28
33
|
"type": "boolean",
|
|
@@ -68,9 +73,14 @@
|
|
|
68
73
|
}
|
|
69
74
|
},
|
|
70
75
|
"rationale": {
|
|
71
|
-
"title": "
|
|
76
|
+
"title": "ConfigureRequiredProp",
|
|
72
77
|
"type": "object",
|
|
73
78
|
"properties": {
|
|
79
|
+
"required": {
|
|
80
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"title": "required"
|
|
83
|
+
},
|
|
74
84
|
"settings": {
|
|
75
85
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
76
86
|
"type": "boolean",
|
|
@@ -153,9 +163,14 @@
|
|
|
153
163
|
}
|
|
154
164
|
},
|
|
155
165
|
"teacherInstructions": {
|
|
156
|
-
"title": "
|
|
166
|
+
"title": "ConfigureRequiredProp",
|
|
157
167
|
"type": "object",
|
|
158
168
|
"properties": {
|
|
169
|
+
"required": {
|
|
170
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
171
|
+
"type": "boolean",
|
|
172
|
+
"title": "required"
|
|
173
|
+
},
|
|
159
174
|
"settings": {
|
|
160
175
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
161
176
|
"type": "boolean",
|
|
@@ -256,6 +271,11 @@
|
|
|
256
271
|
"title": "ConfigurePropWithEnabled",
|
|
257
272
|
"type": "object",
|
|
258
273
|
"properties": {
|
|
274
|
+
"enabled": {
|
|
275
|
+
"description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
|
|
276
|
+
"type": "boolean",
|
|
277
|
+
"title": "enabled"
|
|
278
|
+
},
|
|
259
279
|
"settings": {
|
|
260
280
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
261
281
|
"type": "boolean",
|
|
@@ -265,11 +285,6 @@
|
|
|
265
285
|
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
266
286
|
"type": "string",
|
|
267
287
|
"title": "label"
|
|
268
|
-
},
|
|
269
|
-
"enabled": {
|
|
270
|
-
"description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
|
|
271
|
-
"type": "boolean",
|
|
272
|
-
"title": "enabled"
|
|
273
288
|
}
|
|
274
289
|
}
|
|
275
290
|
},
|
|
@@ -392,6 +407,27 @@
|
|
|
392
407
|
}
|
|
393
408
|
}
|
|
394
409
|
},
|
|
410
|
+
"ConfigureRequiredProp": {
|
|
411
|
+
"title": "ConfigureRequiredProp",
|
|
412
|
+
"type": "object",
|
|
413
|
+
"properties": {
|
|
414
|
+
"required": {
|
|
415
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
416
|
+
"type": "boolean",
|
|
417
|
+
"title": "required"
|
|
418
|
+
},
|
|
419
|
+
"settings": {
|
|
420
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
421
|
+
"type": "boolean",
|
|
422
|
+
"title": "settings"
|
|
423
|
+
},
|
|
424
|
+
"label": {
|
|
425
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
426
|
+
"type": "string",
|
|
427
|
+
"title": "label"
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
395
431
|
"ConfigureMaxImageDimensionsProp": {
|
|
396
432
|
"title": "ConfigureMaxImageDimensionsProp",
|
|
397
433
|
"type": "object",
|
|
@@ -433,6 +469,11 @@
|
|
|
433
469
|
"title": "ConfigurePropWithEnabled",
|
|
434
470
|
"type": "object",
|
|
435
471
|
"properties": {
|
|
472
|
+
"enabled": {
|
|
473
|
+
"description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
|
|
474
|
+
"type": "boolean",
|
|
475
|
+
"title": "enabled"
|
|
476
|
+
},
|
|
436
477
|
"settings": {
|
|
437
478
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
438
479
|
"type": "boolean",
|
|
@@ -442,11 +483,6 @@
|
|
|
442
483
|
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
443
484
|
"type": "string",
|
|
444
485
|
"title": "label"
|
|
445
|
-
},
|
|
446
|
-
"enabled": {
|
|
447
|
-
"description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
|
|
448
|
-
"type": "boolean",
|
|
449
|
-
"title": "enabled"
|
|
450
486
|
}
|
|
451
487
|
}
|
|
452
488
|
},
|
|
@@ -18,6 +18,10 @@ Indicates the label for the item that has to be displayed in the Settings Panel
|
|
|
18
18
|
|
|
19
19
|
Properties of the `prompt` object:
|
|
20
20
|
|
|
21
|
+
## `required` (boolean)
|
|
22
|
+
|
|
23
|
+
Indicates if the item is required and the value cannot be empty
|
|
24
|
+
|
|
21
25
|
## `settings` (boolean)
|
|
22
26
|
|
|
23
27
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -54,6 +58,10 @@ Indicates the label for the item that has to be displayed in the Settings Panel
|
|
|
54
58
|
|
|
55
59
|
Properties of the `rationale` object:
|
|
56
60
|
|
|
61
|
+
## `required` (boolean)
|
|
62
|
+
|
|
63
|
+
Indicates if the item is required and the value cannot be empty
|
|
64
|
+
|
|
57
65
|
## `settings` (boolean)
|
|
58
66
|
|
|
59
67
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -118,6 +126,10 @@ Indicates the label for the item that has to be displayed in the Settings Panel
|
|
|
118
126
|
|
|
119
127
|
Properties of the `teacherInstructions` object:
|
|
120
128
|
|
|
129
|
+
## `required` (boolean)
|
|
130
|
+
|
|
131
|
+
Indicates if the item is required and the value cannot be empty
|
|
132
|
+
|
|
121
133
|
## `settings` (boolean)
|
|
122
134
|
|
|
123
135
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -194,6 +206,11 @@ Indicates if mathML that's already in model should be editable
|
|
|
194
206
|
|
|
195
207
|
Properties of the `language` object:
|
|
196
208
|
|
|
209
|
+
## `enabled` (boolean)
|
|
210
|
+
|
|
211
|
+
Indicates the value of the item if it affects config-ui
|
|
212
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
213
|
+
|
|
197
214
|
## `settings` (boolean)
|
|
198
215
|
|
|
199
216
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -202,11 +219,6 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
202
219
|
|
|
203
220
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
204
221
|
|
|
205
|
-
## `enabled` (boolean)
|
|
206
|
-
|
|
207
|
-
Indicates the value of the item if it affects config-ui
|
|
208
|
-
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
209
|
-
|
|
210
222
|
# `languageChoices` (object)
|
|
211
223
|
|
|
212
224
|
Language choices configuration
|
|
@@ -300,6 +312,22 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
300
312
|
|
|
301
313
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
302
314
|
|
|
315
|
+
## `ConfigureRequiredProp` (object)
|
|
316
|
+
|
|
317
|
+
Properties of the `ConfigureRequiredProp` object:
|
|
318
|
+
|
|
319
|
+
### `required` (boolean)
|
|
320
|
+
|
|
321
|
+
Indicates if the item is required and the value cannot be empty
|
|
322
|
+
|
|
323
|
+
### `settings` (boolean)
|
|
324
|
+
|
|
325
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
326
|
+
|
|
327
|
+
### `label` (string)
|
|
328
|
+
|
|
329
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
330
|
+
|
|
303
331
|
## `ConfigureMaxImageDimensionsProp` (object)
|
|
304
332
|
|
|
305
333
|
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
@@ -332,6 +360,11 @@ Indicates if mathML that's already in model should be editable
|
|
|
332
360
|
|
|
333
361
|
Properties of the `ConfigurePropWithEnabled` object:
|
|
334
362
|
|
|
363
|
+
### `enabled` (boolean)
|
|
364
|
+
|
|
365
|
+
Indicates the value of the item if it affects config-ui
|
|
366
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
367
|
+
|
|
335
368
|
### `settings` (boolean)
|
|
336
369
|
|
|
337
370
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -340,11 +373,6 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
340
373
|
|
|
341
374
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
342
375
|
|
|
343
|
-
### `enabled` (boolean)
|
|
344
|
-
|
|
345
|
-
Indicates the value of the item if it affects config-ui
|
|
346
|
-
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
347
|
-
|
|
348
376
|
## `ConfigureLanguageOptionsProp` (object)
|
|
349
377
|
|
|
350
378
|
Properties of the `ConfigureLanguageOptionsProp` object:
|
package/docs/pie-schema.json
CHANGED
|
@@ -203,6 +203,27 @@
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
},
|
|
206
|
+
"ConfigureRequiredProp": {
|
|
207
|
+
"title": "ConfigureRequiredProp",
|
|
208
|
+
"type": "object",
|
|
209
|
+
"properties": {
|
|
210
|
+
"required": {
|
|
211
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
212
|
+
"type": "boolean",
|
|
213
|
+
"title": "required"
|
|
214
|
+
},
|
|
215
|
+
"settings": {
|
|
216
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
217
|
+
"type": "boolean",
|
|
218
|
+
"title": "settings"
|
|
219
|
+
},
|
|
220
|
+
"label": {
|
|
221
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
222
|
+
"type": "string",
|
|
223
|
+
"title": "label"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
},
|
|
206
227
|
"ConfigureMaxImageDimensionsProp": {
|
|
207
228
|
"title": "ConfigureMaxImageDimensionsProp",
|
|
208
229
|
"type": "object",
|
|
@@ -244,6 +265,11 @@
|
|
|
244
265
|
"title": "ConfigurePropWithEnabled",
|
|
245
266
|
"type": "object",
|
|
246
267
|
"properties": {
|
|
268
|
+
"enabled": {
|
|
269
|
+
"description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
|
|
270
|
+
"type": "boolean",
|
|
271
|
+
"title": "enabled"
|
|
272
|
+
},
|
|
247
273
|
"settings": {
|
|
248
274
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
249
275
|
"type": "boolean",
|
|
@@ -253,11 +279,6 @@
|
|
|
253
279
|
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
254
280
|
"type": "string",
|
|
255
281
|
"title": "label"
|
|
256
|
-
},
|
|
257
|
-
"enabled": {
|
|
258
|
-
"description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
|
|
259
|
-
"type": "boolean",
|
|
260
|
-
"title": "enabled"
|
|
261
282
|
}
|
|
262
283
|
}
|
|
263
284
|
},
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -122,6 +122,22 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
122
122
|
|
|
123
123
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
124
124
|
|
|
125
|
+
## `ConfigureRequiredProp` (object)
|
|
126
|
+
|
|
127
|
+
Properties of the `ConfigureRequiredProp` object:
|
|
128
|
+
|
|
129
|
+
### `required` (boolean)
|
|
130
|
+
|
|
131
|
+
Indicates if the item is required and the value cannot be empty
|
|
132
|
+
|
|
133
|
+
### `settings` (boolean)
|
|
134
|
+
|
|
135
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
136
|
+
|
|
137
|
+
### `label` (string)
|
|
138
|
+
|
|
139
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
140
|
+
|
|
125
141
|
## `ConfigureMaxImageDimensionsProp` (object)
|
|
126
142
|
|
|
127
143
|
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
@@ -154,6 +170,11 @@ Indicates if mathML that's already in model should be editable
|
|
|
154
170
|
|
|
155
171
|
Properties of the `ConfigurePropWithEnabled` object:
|
|
156
172
|
|
|
173
|
+
### `enabled` (boolean)
|
|
174
|
+
|
|
175
|
+
Indicates the value of the item if it affects config-ui
|
|
176
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
177
|
+
|
|
157
178
|
### `settings` (boolean)
|
|
158
179
|
|
|
159
180
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -162,11 +183,6 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
162
183
|
|
|
163
184
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
164
185
|
|
|
165
|
-
### `enabled` (boolean)
|
|
166
|
-
|
|
167
|
-
Indicates the value of the item if it affects config-ui
|
|
168
|
-
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
169
|
-
|
|
170
186
|
## `ConfigureLanguageOptionsProp` (object)
|
|
171
187
|
|
|
172
188
|
Properties of the `ConfigureLanguageOptionsProp` object:
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"repository": "pie-framework/pie-elements",
|
|
7
|
-
"version": "5.0.4-next.
|
|
7
|
+
"version": "5.0.4-next.16+1d20148ed",
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@material-ui/core": "^3.9.2",
|
|
15
15
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
16
|
-
"@pie-lib/pie-toolbox": "1.
|
|
16
|
+
"@pie-lib/pie-toolbox": "1.2.0",
|
|
17
17
|
"classnames": "^2.2.5",
|
|
18
18
|
"lodash": "^4.17.10",
|
|
19
19
|
"prop-types": "^15.6.1",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "1d20148ed6abb750252b3cf604080abe71af5194",
|
|
26
26
|
"main": "lib/index.js",
|
|
27
27
|
"module": "src/index.js"
|
|
28
28
|
}
|