@pie-element/hotspot 6.12.1-next.2 → 6.12.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.
- package/configure/lib/defaults.js +6 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/root.js +17 -5
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +1 -1
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +3 -0
- package/configure/src/defaults.js +3 -0
- package/configure/src/root.jsx +13 -1
- package/controller/lib/index.js +22 -5
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/index.js +16 -4
- package/docs/config-schema.json +25 -5
- package/docs/config-schema.json.md +18 -2
- package/docs/pie-schema.json +7 -2
- package/docs/pie-schema.json.md +6 -2
- package/package.json +3 -3
|
@@ -63,7 +63,8 @@ var _default = {
|
|
|
63
63
|
image: {
|
|
64
64
|
disabled: false
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
|
+
required: false
|
|
67
68
|
},
|
|
68
69
|
prompt: {
|
|
69
70
|
settings: true,
|
|
@@ -78,7 +79,8 @@ var _default = {
|
|
|
78
79
|
image: {
|
|
79
80
|
disabled: false
|
|
80
81
|
}
|
|
81
|
-
}
|
|
82
|
+
},
|
|
83
|
+
required: false
|
|
82
84
|
},
|
|
83
85
|
settingsPanelDisabled: false,
|
|
84
86
|
spellCheck: {
|
|
@@ -99,7 +101,8 @@ var _default = {
|
|
|
99
101
|
image: {
|
|
100
102
|
disabled: false
|
|
101
103
|
}
|
|
102
|
-
}
|
|
104
|
+
},
|
|
105
|
+
required: false
|
|
103
106
|
},
|
|
104
107
|
preserveAspectRatio: {
|
|
105
108
|
settings: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","imageUrl","shapes","rectangles","polygons","circles","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","baseInputConfiguration","audio","disabled","video","image","settings","label","rationale","inputConfiguration","settingsPanelDisabled","spellCheck","enabled","teacherInstructions","preserveAspectRatio","minShapes","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,MAAM,EAAE,EADH;AAELC,IAAAA,qBAAqB,EAAE,QAFlB;AAGLC,IAAAA,QAAQ,EAAE,EAHL;AAILC,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAE,EADN;AAENC,MAAAA,QAAQ,EAAE,EAFJ;AAGNC,MAAAA,OAAO,EAAE;AAHH,KAJH;AASLC,IAAAA,eAAe,EAAE,IATZ;AAULC,IAAAA,cAAc,EAAE,KAVX;AAWLC,IAAAA,UAAU,EAAE;AACVC,MAAAA,MAAM,EAAE,CADE;AAEVC,MAAAA,KAAK,EAAE;AAFG,KAXP;AAeLC,IAAAA,YAAY,EAAE,2BAfT;AAgBLC,IAAAA,WAAW,EAAE,CAAC,2BAAD,CAhBR;AAiBLC,IAAAA,YAAY,EAAE,MAjBT;AAkBLC,IAAAA,WAAW,EAAE,CAAC,MAAD,CAlBR;AAmBLC,IAAAA,aAAa,EAAE,IAnBV;AAoBLC,IAAAA,gBAAgB,EAAE,IApBb;AAqBLC,IAAAA,0BAA0B,EAAE,IArBvB;AAsBLC,IAAAA,0BAA0B,EAAE,IAtBvB;AAuBLC,IAAAA,WAAW,EAAE;AAvBR,GADM;AA0BbC,EAAAA,aAAa,EAAE;AACbC,IAAAA,sBAAsB,EAAE;AACtBC,MAAAA,KAAK,EAAE;AAAEC,QAAAA,QAAQ,EAAE;AAAZ,OADe;AAEtBC,MAAAA,KAAK,EAAE;AAAED,QAAAA,QAAQ,EAAE;AAAZ,OAFe;AAGtBE,MAAAA,KAAK,EAAE;AAAEF,QAAAA,QAAQ,EAAE;AAAZ;AAHe,KADX;AAMbjB,IAAAA,eAAe,EAAE;AACfoB,MAAAA,QAAQ,EAAE,IADK;AAEfC,MAAAA,KAAK,EAAE;AAFQ,KANJ;AAUbpB,IAAAA,cAAc,EAAE;AACdmB,MAAAA,QAAQ,EAAE,KADI;AAEdC,MAAAA,KAAK,EAAE;AAFO,KAVH;AAcbC,IAAAA,SAAS,EAAE;AACTF,MAAAA,QAAQ,EAAE,IADD;AAETC,MAAAA,KAAK,EAAE,WAFE;AAGTE,MAAAA,kBAAkB,EAAE;AAClBP,QAAAA,KAAK,EAAE;AAAEC,UAAAA,QAAQ,EAAE;AAAZ,SADW;AAElBC,QAAAA,KAAK,EAAE;AAAED,UAAAA,QAAQ,EAAE;AAAZ,SAFW;AAGlBE,QAAAA,KAAK,EAAE;AAAEF,UAAAA,QAAQ,EAAE;AAAZ;AAHW;
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","imageUrl","shapes","rectangles","polygons","circles","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","baseInputConfiguration","audio","disabled","video","image","settings","label","rationale","inputConfiguration","required","settingsPanelDisabled","spellCheck","enabled","teacherInstructions","preserveAspectRatio","minShapes","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,MAAM,EAAE,EADH;AAELC,IAAAA,qBAAqB,EAAE,QAFlB;AAGLC,IAAAA,QAAQ,EAAE,EAHL;AAILC,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAE,EADN;AAENC,MAAAA,QAAQ,EAAE,EAFJ;AAGNC,MAAAA,OAAO,EAAE;AAHH,KAJH;AASLC,IAAAA,eAA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EbnC,MAAAA,MAAM,EAAE,GAFK;AAGb6B,MAAAA,SAAS,EAAE;AAHE,KAxDF;AA6DbU,IAAAA,cAAc,EAAE;AACdJ,MAAAA,mBAAmB,EAAE,GADP;AAEdnC,MAAAA,MAAM,EAAE,GAFM;AAGd6B,MAAAA,SAAS,EAAE;AAHG,KA7DH;AAkEbW,IAAAA,UAAU,EAAE;AACVb,MAAAA,QAAQ,EAAE,KADA;AAEVC,MAAAA,KAAK,EAAE;AAFG,KAlEC;AAsEba,IAAAA,aAAa,EAAE;AACbC,MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,UAAU,EAAE;AAFC,KAtEF;AA0EbC,IAAAA,QAAQ,EAAE;AACRjB,MAAAA,QAAQ,EAAE,KADF;AAERC,MAAAA,KAAK,EAAE,kBAFC;AAGRM,MAAAA,OAAO,EAAE;AAHD,KA1EG;AA+EbW,IAAAA,eAAe,EAAE;AACfjB,MAAAA,KAAK,EAAE,kBADQ;AAEfkB,MAAAA,OAAO,EAAE;AAFM;AA/EJ;AA1BF,C","sourcesContent":["export default {\n model: {\n prompt: '',\n toolbarEditorPosition: 'bottom',\n imageUrl: '',\n shapes: {\n rectangles: [],\n polygons: [],\n circles: [],\n },\n multipleCorrect: true,\n partialScoring: false,\n dimensions: {\n height: 0,\n width: 0,\n },\n hotspotColor: 'rgba(137, 183, 244, 0.25)',\n hotspotList: ['rgba(137, 183, 244, 0.25)'],\n outlineColor: 'blue',\n outlineList: ['blue'],\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n strokeWidth: 5,\n },\n configuration: {\n baseInputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n multipleCorrect: {\n settings: true,\n label: 'Multiple Correct Responses',\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 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 settingsPanelDisabled: false,\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\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 preserveAspectRatio: {\n settings: false,\n enabled: true,\n label: 'Preserve aspect ratio',\n },\n minShapes: 2,\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/root.js
CHANGED
|
@@ -162,8 +162,11 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
162
162
|
toolbarEditorPosition = _ref2.toolbarEditorPosition;
|
|
163
163
|
|
|
164
164
|
var _ref3 = errors || {},
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
promptError = _ref3.prompt,
|
|
166
|
+
rationaleError = _ref3.rationale,
|
|
167
|
+
shapesError = _ref3.shapes,
|
|
168
|
+
selectionsError = _ref3.selections,
|
|
169
|
+
teacherInstructionsError = _ref3.teacherInstructions;
|
|
167
170
|
|
|
168
171
|
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
169
172
|
var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
@@ -211,6 +214,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
211
214
|
onChange: onTeacherInstructionsChanged,
|
|
212
215
|
imageSupport: imageSupport,
|
|
213
216
|
nonEmpty: false,
|
|
217
|
+
error: teacherInstructionsError,
|
|
214
218
|
toolbarOpts: toolbarOpts,
|
|
215
219
|
pluginProps: getPluginProps(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration),
|
|
216
220
|
spellCheck: spellCheckEnabled,
|
|
@@ -223,7 +227,9 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
223
227
|
language: 'special'
|
|
224
228
|
}],
|
|
225
229
|
mathMlOptions: mathMlOptions
|
|
226
|
-
})
|
|
230
|
+
}), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
231
|
+
className: classes.errorText
|
|
232
|
+
}, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
227
233
|
label: prompt.label,
|
|
228
234
|
className: classes.promptContainer
|
|
229
235
|
}, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
|
|
@@ -231,6 +237,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
231
237
|
onChange: onPromptChanged,
|
|
232
238
|
imageSupport: imageSupport,
|
|
233
239
|
nonEmpty: false,
|
|
240
|
+
error: promptError,
|
|
234
241
|
toolbarOpts: toolbarOpts,
|
|
235
242
|
pluginProps: getPluginProps(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration),
|
|
236
243
|
spellCheck: spellCheckEnabled,
|
|
@@ -243,7 +250,9 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
243
250
|
language: 'special'
|
|
244
251
|
}],
|
|
245
252
|
mathMlOptions: mathMlOptions
|
|
246
|
-
})
|
|
253
|
+
}), promptError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
254
|
+
className: classes.errorText
|
|
255
|
+
}, promptError)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
247
256
|
className: classes.flexContainer
|
|
248
257
|
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
249
258
|
className: classes.subheading,
|
|
@@ -322,6 +331,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
322
331
|
markup: model.rationale || '',
|
|
323
332
|
onChange: onRationaleChanged,
|
|
324
333
|
imageSupport: imageSupport,
|
|
334
|
+
error: rationaleError,
|
|
325
335
|
toolbarOpts: toolbarOpts,
|
|
326
336
|
pluginProps: getPluginProps(rationale === null || rationale === void 0 ? void 0 : rationale.inputConfiguration),
|
|
327
337
|
spellCheck: spellCheckEnabled,
|
|
@@ -334,7 +344,9 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
334
344
|
language: 'special'
|
|
335
345
|
}],
|
|
336
346
|
mathMlOptions: mathMlOptions
|
|
337
|
-
})
|
|
347
|
+
}), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
348
|
+
className: classes.errorText
|
|
349
|
+
}, rationaleError)));
|
|
338
350
|
}
|
|
339
351
|
}]);
|
|
340
352
|
return Root;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/root.jsx"],"names":["Panel","settings","toggle","dropdown","Root","fieldType","color","onColorChanged","props","cType","value","resizeType","model","dimensions","shapes","configuration","preserveAspectRatio","onUpdateImageDimension","onUpdateShapes","nextImageDimensions","updatedDimensions","enabled","shapesArray","updatedShapes","classes","imageSupport","uploadSoundSupport","onConfigurationChanged","onImageUpload","onModelChangedByConfig","onPromptChanged","onRationaleChanged","onTeacherInstructionsChanged","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","multipleCorrect","partialScoring","prompt","rationale","settingsPanelDisabled","spellCheck","teacherInstructions","withRubric","mathMlOptions","language","languageChoices","errors","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","shapesError","selectionsError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","label","options","panelProperties","rubricEnabled","getPluginProps","Settings","Properties","promptContainer","inputConfiguration","flexContainer","subheading","tooltip","hotspotColor","hotspotList","outlineColor","outlineList","handleColorChange","imageUrl","strokeWidth","add","errorText","width","e","handleOnUpdateImageDimensions","field","height","React","Component","styles","theme","display","marginBottom","spacing","unit","flex","paddingTop","marginRight","alignItems","fontSize","typography","whiteSpace","maxWidth","palette","error","main","propTypes","PropTypes","object","isRequired","shape","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,KAAR,GAAoCC,kBAApC,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAAoCD,kBAApC,CAAeC,MAAf;AAAA,IAAuBC,QAAvB,GAAoCF,kBAApC,CAAuBE,QAAvB;;IAEaC,I;;;;;;;;;;;;;;;0GACS,UAACC,SAAD,EAAYC,KAAZ,EAAsB;AACxC,UAAQC,cAAR,GAA2B,MAAKC,KAAhC,CAAQD,cAAR;AACA,UAAME,KAAK,aAAMJ,SAAN,UAAX;AAEAE,MAAAA,cAAc,CAACE,KAAD,EAAQH,KAAR,CAAd;AACD,K;sHAE+B,UAACI,KAAD,EAAQC,UAAR,EAAuB;AACrD,wBAKI,MAAKH,KALT;AAAA,0CACEI,KADF;AAAA,UACWC,UADX,qBACWA,UADX;AAAA,UACuBC,MADvB,qBACuBA,MADvB;AAAA,8CAEEC,aAFF,CAEmBC,mBAFnB;AAAA,UAEmBA,mBAFnB,sCAEyC,EAFzC;AAAA,UAGEC,sBAHF,eAGEA,sBAHF;AAAA,UAIEC,cAJF,eAIEA,cAJF;;AAOA,UAAMC,mBAAmB,mCAAQN,UAAR,4CAAqBF,UAArB,EAAkCD,KAAlC,EAAzB,CARqD,CAUrD;;;AACA,UAAMU,iBAAiB,GAAG,kCACxBP,UADwB,EAExBM,mBAFwB,EAGxBH,mBAAmB,CAACK,OAHI,EAIxBV,UAJwB,CAA1B,CAXqD,CAiBrD;;AACA,UAAMW,WAAW,GAAG,yBAAaR,MAAb,CAApB,C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,EAAEiF,sBAAUI,IAAV,CAAeF,UAnBxB;AAoBf9E,EAAAA,4BAA4B,EAAE4E,sBAAUI,IAAV,CAAeF;AApB9B,CAAjB;;eAuBe,wBAAWpB,MAAX,EAAmBtF,IAAnB,C","sourcesContent":["import React from 'react';\nimport { settings, layout, InputContainer, NumberTextField } from '@pie-lib/pie-toolbox/config-ui';\nimport PropTypes from 'prop-types';\nimport { EditableHtml } from '@pie-lib/pie-toolbox/editable-html';\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';\nimport HotspotPalette from './hotspot-palette';\nimport HotspotContainer from './hotspot-container';\nimport { updateImageDimensions, generateValidationMessage, getUpdatedShapes, getAllShapes, groupShapes } from './utils';\n\nconst { Panel, toggle, dropdown } = settings;\n\nexport class Root extends React.Component {\n handleColorChange = (fieldType, color) => {\n const { onColorChanged } = this.props;\n const cType = `${fieldType}Color`;\n\n onColorChanged(cType, color);\n };\n\n handleOnUpdateImageDimensions = (value, resizeType) => {\n const {\n model: { dimensions, shapes },\n configuration: { preserveAspectRatio = {} },\n onUpdateImageDimension,\n onUpdateShapes,\n } = this.props;\n\n const nextImageDimensions = { ...dimensions, [resizeType]: value };\n\n // if preserveAspectRatio.enabled, updateImageDimensions function makes sure aspect ratio is kept\n const updatedDimensions = updateImageDimensions(\n dimensions,\n nextImageDimensions,\n preserveAspectRatio.enabled,\n resizeType,\n );\n // transform shapes map into shapes array\n const shapesArray = getAllShapes(shapes);\n // transform all the shapes to fit the re-sized image\n const updatedShapes = getUpdatedShapes(dimensions, updatedDimensions, shapesArray);\n // transform shapes array back into shapes map\n\n onUpdateShapes(groupShapes(updatedShapes));\n onUpdateImageDimension(updatedDimensions);\n };\n\n render() {\n const {\n classes,\n configuration,\n model,\n imageSupport,\n uploadSoundSupport,\n onConfigurationChanged,\n onImageUpload,\n onModelChangedByConfig,\n onPromptChanged,\n onRationaleChanged,\n onUpdateImageDimension,\n onTeacherInstructionsChanged,\n onUpdateShapes,\n } = this.props;\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n maxImageWidth = {},\n maxImageHeight = {},\n multipleCorrect = {},\n partialScoring = {},\n preserveAspectRatio = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n errors,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n const { shapesError, selectionsError } = 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 multipleCorrect: multipleCorrect.settings && toggle(multipleCorrect.label),\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n promptEnabled: prompt.settings && toggle(prompt.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 spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\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 onChangeModel={onModelChangedByConfig}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptContainer}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={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.promptContainer}>\n <EditableHtml\n markup={model.prompt || ''}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\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.subheading} variant=\"subheading\">\n Define Hotspot\n </Typography>\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'left'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ float: 'right' }} />\n </Tooltip>\n </div>\n\n <HotspotPalette\n hotspotColor={model.hotspotColor}\n hotspotList={model.hotspotList}\n outlineColor={model.outlineColor}\n outlineList={model.outlineList}\n onHotspotColorChange={(color) => this.handleColorChange('hotspot', color)}\n onOutlineColorChange={(color) => this.handleColorChange('outline', color)}\n />\n\n <HotspotContainer\n dimensions={model.dimensions}\n imageUrl={model.imageUrl}\n multipleCorrect={model.multipleCorrect}\n hasErrors={!!shapesError || !!selectionsError}\n hotspotColor={model.hotspotColor}\n outlineColor={model.outlineColor}\n onUpdateImageDimension={onUpdateImageDimension}\n onUpdateShapes={onUpdateShapes}\n onImageUpload={onImageUpload}\n shapes={model.shapes}\n strokeWidth={model.strokeWidth}\n preserveAspectRatioEnabled={preserveAspectRatio.enabled}\n insertImage={imageSupport && imageSupport.add}\n />\n {shapesError && <div className={classes.errorText}>{shapesError}</div>}\n {selectionsError && <div className={classes.errorText}>{selectionsError}</div>}\n\n {model.imageUrl && (\n <React.Fragment>\n <Typography variant=\"subheading\">Image Dimensions</Typography>\n\n <div className={classes.dimensions}>\n <NumberTextField\n key=\"hotspot-manual-width\"\n label=\"Width\"\n value={model.dimensions.width}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'width')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n\n <NumberTextField\n key=\"hotspot-manual-height\"\n label=\"Height\"\n value={model.dimensions.height}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'height')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n </div>\n </React.Fragment>\n )}\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptContainer}>\n <EditableHtml\n markup={model.rationale || ''}\n onChange={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 styles = (theme) => ({\n dimensions: {\n display: 'flex',\n marginBottom: theme.spacing.unit * 1.5,\n },\n field: {\n flex: 1,\n width: '90%',\n },\n promptContainer: {\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n width: '100%',\n },\n subheading: {\n marginRight: theme.spacing.unit,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\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\nRoot.propTypes = {\n classes: PropTypes.object.isRequired,\n configuration: PropTypes.object,\n model: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func,\n delete: PropTypes.func,\n }),\n uploadSoundSupport: PropTypes.shape({\n add: PropTypes.func,\n delete: PropTypes.func,\n }),\n onImageUpload: PropTypes.func.isRequired,\n onColorChanged: PropTypes.func.isRequired,\n onPromptChanged: PropTypes.func.isRequired,\n onUpdateImageDimension: PropTypes.func.isRequired,\n onUpdateShapes: PropTypes.func.isRequired,\n onModelChangedByConfig: PropTypes.func.isRequired,\n onRationaleChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n onTeacherInstructionsChanged: PropTypes.func.isRequired,\n};\n\nexport default withStyles(styles)(Root);\n"],"file":"root.js"}
|
|
1
|
+
{"version":3,"sources":["../src/root.jsx"],"names":["Panel","settings","toggle","dropdown","Root","fieldType","color","onColorChanged","props","cType","value","resizeType","model","dimensions","shapes","configuration","preserveAspectRatio","onUpdateImageDimension","onUpdateShapes","nextImageDimensions","updatedDimensions","enabled","shapesArray","updatedShapes","classes","imageSupport","uploadSoundSupport","onConfigurationChanged","onImageUpload","onModelChangedByConfig","onPromptChanged","onRationaleChanged","onTeacherInstructionsChanged","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","multipleCorrect","partialScoring","prompt","rationale","settingsPanelDisabled","spellCheck","teacherInstructions","withRubric","mathMlOptions","language","languageChoices","errors","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","promptError","rationaleError","shapesError","selectionsError","selections","teacherInstructionsError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","label","options","panelProperties","rubricEnabled","getPluginProps","Settings","Properties","promptContainer","inputConfiguration","errorText","flexContainer","subheading","tooltip","hotspotColor","hotspotList","outlineColor","outlineList","handleColorChange","imageUrl","strokeWidth","add","width","e","handleOnUpdateImageDimensions","field","height","React","Component","styles","theme","display","marginBottom","spacing","unit","flex","paddingTop","marginRight","alignItems","fontSize","typography","whiteSpace","maxWidth","palette","error","main","propTypes","PropTypes","object","isRequired","shape","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,KAAR,GAAoCC,kBAApC,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAAoCD,kBAApC,CAAeC,MAAf;AAAA,IAAuBC,QAAvB,GAAoCF,kBAApC,CAAuBE,QAAvB;;IAEaC,I;;;;;;;;;;;;;;;0GACS,UAACC,SAAD,EAAYC,KAAZ,EAAsB;AACxC,UAAQC,cAAR,GAA2B,MAAKC,KAAhC,CAAQD,cAAR;AACA,UAAME,KAAK,aAAMJ,SAAN,UAAX;AAEAE,MAAAA,cAAc,CAACE,KAAD,EAAQH,KAAR,CAAd;AACD,K;sHAE+B,UAACI,KAAD,EAAQC,UAAR,EAAuB;AACrD,wBAKI,MAAKH,KALT;AAAA,0CACEI,KADF;AAAA,UACWC,UADX,qBACWA,UADX;AAAA,UACuBC,MADvB,qBACuBA,MADvB;AAAA,8CAEEC,aAFF,CAEmBC,mBAFnB;AAAA,UAEmBA,mBAFnB,sCAEyC,EAFzC;AAAA,UAGEC,sBAHF,eAGEA,sBAHF;AAAA,UAIEC,cAJF,eAIEA,cAJF;;AAOA,UAAMC,mBAAmB,mCAAQN,UAAR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F,sBAAUG,KAAV,CAAgB;AAC5B7B,IAAAA,GAAG,EAAE0B,sBAAUI,IADa;AAE5B,cAAQJ,sBAAUI;AAFU,GAAhB,CAJC;AAQf1F,EAAAA,kBAAkB,EAAEsF,sBAAUG,KAAV,CAAgB;AAClC7B,IAAAA,GAAG,EAAE0B,sBAAUI,IADmB;AAElC,cAAQJ,sBAAUI;AAFgB,GAAhB,CARL;AAYfxF,EAAAA,aAAa,EAAEoF,sBAAUI,IAAV,CAAeF,UAZf;AAaf3G,EAAAA,cAAc,EAAEyG,sBAAUI,IAAV,CAAeF,UAbhB;AAcfpF,EAAAA,eAAe,EAAEkF,sBAAUI,IAAV,CAAeF,UAdjB;AAefjG,EAAAA,sBAAsB,EAAE+F,sBAAUI,IAAV,CAAeF,UAfxB;AAgBfhG,EAAAA,cAAc,EAAE8F,sBAAUI,IAAV,CAAeF,UAhBhB;AAiBfrF,EAAAA,sBAAsB,EAAEmF,sBAAUI,IAAV,CAAeF,UAjBxB;AAkBfnF,EAAAA,kBAAkB,EAAEiF,sBAAUI,IAAV,CAAeF,UAlBpB;AAmBfvF,EAAAA,sBAAsB,EAAEqF,sBAAUI,IAAV,CAAeF,UAnBxB;AAoBflF,EAAAA,4BAA4B,EAAEgF,sBAAUI,IAAV,CAAeF;AApB9B,CAAjB;;eAuBe,wBAAWpB,MAAX,EAAmB1F,IAAnB,C","sourcesContent":["import React from 'react';\nimport { settings, layout, InputContainer, NumberTextField } from '@pie-lib/pie-toolbox/config-ui';\nimport PropTypes from 'prop-types';\nimport { EditableHtml } from '@pie-lib/pie-toolbox/editable-html';\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';\nimport HotspotPalette from './hotspot-palette';\nimport HotspotContainer from './hotspot-container';\nimport { updateImageDimensions, generateValidationMessage, getUpdatedShapes, getAllShapes, groupShapes } from './utils';\n\nconst { Panel, toggle, dropdown } = settings;\n\nexport class Root extends React.Component {\n handleColorChange = (fieldType, color) => {\n const { onColorChanged } = this.props;\n const cType = `${fieldType}Color`;\n\n onColorChanged(cType, color);\n };\n\n handleOnUpdateImageDimensions = (value, resizeType) => {\n const {\n model: { dimensions, shapes },\n configuration: { preserveAspectRatio = {} },\n onUpdateImageDimension,\n onUpdateShapes,\n } = this.props;\n\n const nextImageDimensions = { ...dimensions, [resizeType]: value };\n\n // if preserveAspectRatio.enabled, updateImageDimensions function makes sure aspect ratio is kept\n const updatedDimensions = updateImageDimensions(\n dimensions,\n nextImageDimensions,\n preserveAspectRatio.enabled,\n resizeType,\n );\n // transform shapes map into shapes array\n const shapesArray = getAllShapes(shapes);\n // transform all the shapes to fit the re-sized image\n const updatedShapes = getUpdatedShapes(dimensions, updatedDimensions, shapesArray);\n // transform shapes array back into shapes map\n\n onUpdateShapes(groupShapes(updatedShapes));\n onUpdateImageDimension(updatedDimensions);\n };\n\n render() {\n const {\n classes,\n configuration,\n model,\n imageSupport,\n uploadSoundSupport,\n onConfigurationChanged,\n onImageUpload,\n onModelChangedByConfig,\n onPromptChanged,\n onRationaleChanged,\n onUpdateImageDimension,\n onTeacherInstructionsChanged,\n onUpdateShapes,\n } = this.props;\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n maxImageWidth = {},\n maxImageHeight = {},\n multipleCorrect = {},\n partialScoring = {},\n preserveAspectRatio = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n errors,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n const {\n prompt: promptError,\n rationale: rationaleError,\n shapes: shapesError,\n selections: selectionsError,\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 multipleCorrect: multipleCorrect.settings && toggle(multipleCorrect.label),\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n promptEnabled: prompt.settings && toggle(prompt.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 spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\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 onChangeModel={onModelChangedByConfig}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptContainer}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={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.promptContainer}>\n <EditableHtml\n markup={model.prompt || ''}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\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.subheading} variant=\"subheading\">\n Define Hotspot\n </Typography>\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'left'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ float: 'right' }} />\n </Tooltip>\n </div>\n\n <HotspotPalette\n hotspotColor={model.hotspotColor}\n hotspotList={model.hotspotList}\n outlineColor={model.outlineColor}\n outlineList={model.outlineList}\n onHotspotColorChange={(color) => this.handleColorChange('hotspot', color)}\n onOutlineColorChange={(color) => this.handleColorChange('outline', color)}\n />\n\n <HotspotContainer\n dimensions={model.dimensions}\n imageUrl={model.imageUrl}\n multipleCorrect={model.multipleCorrect}\n hasErrors={!!shapesError || !!selectionsError}\n hotspotColor={model.hotspotColor}\n outlineColor={model.outlineColor}\n onUpdateImageDimension={onUpdateImageDimension}\n onUpdateShapes={onUpdateShapes}\n onImageUpload={onImageUpload}\n shapes={model.shapes}\n strokeWidth={model.strokeWidth}\n preserveAspectRatioEnabled={preserveAspectRatio.enabled}\n insertImage={imageSupport && imageSupport.add}\n />\n {shapesError && <div className={classes.errorText}>{shapesError}</div>}\n {selectionsError && <div className={classes.errorText}>{selectionsError}</div>}\n\n {model.imageUrl && (\n <React.Fragment>\n <Typography variant=\"subheading\">Image Dimensions</Typography>\n\n <div className={classes.dimensions}>\n <NumberTextField\n key=\"hotspot-manual-width\"\n label=\"Width\"\n value={model.dimensions.width}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'width')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n\n <NumberTextField\n key=\"hotspot-manual-height\"\n label=\"Height\"\n value={model.dimensions.height}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'height')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n </div>\n </React.Fragment>\n )}\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptContainer}>\n <EditableHtml\n markup={model.rationale || ''}\n onChange={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 styles = (theme) => ({\n dimensions: {\n display: 'flex',\n marginBottom: theme.spacing.unit * 1.5,\n },\n field: {\n flex: 1,\n width: '90%',\n },\n promptContainer: {\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n width: '100%',\n },\n subheading: {\n marginRight: theme.spacing.unit,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\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\nRoot.propTypes = {\n classes: PropTypes.object.isRequired,\n configuration: PropTypes.object,\n model: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func,\n delete: PropTypes.func,\n }),\n uploadSoundSupport: PropTypes.shape({\n add: PropTypes.func,\n delete: PropTypes.func,\n }),\n onImageUpload: PropTypes.func.isRequired,\n onColorChanged: PropTypes.func.isRequired,\n onPromptChanged: PropTypes.func.isRequired,\n onUpdateImageDimension: PropTypes.func.isRequired,\n onUpdateShapes: PropTypes.func.isRequired,\n onModelChangedByConfig: PropTypes.func.isRequired,\n onRationaleChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n onTeacherInstructionsChanged: PropTypes.func.isRequired,\n};\n\nexport default withStyles(styles)(Root);\n"],"file":"root.js"}
|
package/configure/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
11
|
"@material-ui/icons": "^3.0.2",
|
|
12
12
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
13
|
-
"@pie-lib/pie-toolbox": "1.12.
|
|
13
|
+
"@pie-lib/pie-toolbox": "1.12.2",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
15
15
|
"debug": "^3.1.0",
|
|
16
16
|
"konva": "^3.2.4",
|
|
@@ -69,6 +69,7 @@ exports[`Root render renders 1`] = `
|
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
71
|
"label": "Prompt",
|
|
72
|
+
"required": false,
|
|
72
73
|
"settings": true,
|
|
73
74
|
},
|
|
74
75
|
"rationale": Object {
|
|
@@ -84,6 +85,7 @@ exports[`Root render renders 1`] = `
|
|
|
84
85
|
},
|
|
85
86
|
},
|
|
86
87
|
"label": "Rationale",
|
|
88
|
+
"required": false,
|
|
87
89
|
"settings": true,
|
|
88
90
|
},
|
|
89
91
|
"settingsPanelDisabled": false,
|
|
@@ -105,6 +107,7 @@ exports[`Root render renders 1`] = `
|
|
|
105
107
|
},
|
|
106
108
|
},
|
|
107
109
|
"label": "Teacher Instructions",
|
|
110
|
+
"required": false,
|
|
108
111
|
"settings": true,
|
|
109
112
|
},
|
|
110
113
|
"withRubric": Object {
|
|
@@ -46,6 +46,7 @@ export default {
|
|
|
46
46
|
video: { disabled: false },
|
|
47
47
|
image: { disabled: false },
|
|
48
48
|
},
|
|
49
|
+
required: false,
|
|
49
50
|
},
|
|
50
51
|
prompt: {
|
|
51
52
|
settings: true,
|
|
@@ -55,6 +56,7 @@ export default {
|
|
|
55
56
|
video: { disabled: false },
|
|
56
57
|
image: { disabled: false },
|
|
57
58
|
},
|
|
59
|
+
required: false,
|
|
58
60
|
},
|
|
59
61
|
settingsPanelDisabled: false,
|
|
60
62
|
spellCheck: {
|
|
@@ -70,6 +72,7 @@ export default {
|
|
|
70
72
|
video: { disabled: false },
|
|
71
73
|
image: { disabled: false },
|
|
72
74
|
},
|
|
75
|
+
required: false,
|
|
73
76
|
},
|
|
74
77
|
preserveAspectRatio: {
|
|
75
78
|
settings: false,
|
package/configure/src/root.jsx
CHANGED
|
@@ -89,7 +89,13 @@ export class Root extends React.Component {
|
|
|
89
89
|
teacherInstructionsEnabled,
|
|
90
90
|
toolbarEditorPosition,
|
|
91
91
|
} = model || {};
|
|
92
|
-
const {
|
|
92
|
+
const {
|
|
93
|
+
prompt: promptError,
|
|
94
|
+
rationale: rationaleError,
|
|
95
|
+
shapes: shapesError,
|
|
96
|
+
selections: selectionsError,
|
|
97
|
+
teacherInstructions: teacherInstructionsError,
|
|
98
|
+
} = errors || {};
|
|
93
99
|
const validationMessage = generateValidationMessage(configuration);
|
|
94
100
|
|
|
95
101
|
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
@@ -142,6 +148,7 @@ export class Root extends React.Component {
|
|
|
142
148
|
onChange={onTeacherInstructionsChanged}
|
|
143
149
|
imageSupport={imageSupport}
|
|
144
150
|
nonEmpty={false}
|
|
151
|
+
error={teacherInstructionsError}
|
|
145
152
|
toolbarOpts={toolbarOpts}
|
|
146
153
|
pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}
|
|
147
154
|
spellCheck={spellCheckEnabled}
|
|
@@ -151,6 +158,7 @@ export class Root extends React.Component {
|
|
|
151
158
|
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
152
159
|
mathMlOptions={mathMlOptions}
|
|
153
160
|
/>
|
|
161
|
+
{teacherInstructionsError && <div className={classes.errorText}>{teacherInstructionsError}</div>}
|
|
154
162
|
</InputContainer>
|
|
155
163
|
)}
|
|
156
164
|
|
|
@@ -161,6 +169,7 @@ export class Root extends React.Component {
|
|
|
161
169
|
onChange={onPromptChanged}
|
|
162
170
|
imageSupport={imageSupport}
|
|
163
171
|
nonEmpty={false}
|
|
172
|
+
error={promptError}
|
|
164
173
|
toolbarOpts={toolbarOpts}
|
|
165
174
|
pluginProps={getPluginProps(prompt?.inputConfiguration)}
|
|
166
175
|
spellCheck={spellCheckEnabled}
|
|
@@ -170,6 +179,7 @@ export class Root extends React.Component {
|
|
|
170
179
|
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
171
180
|
mathMlOptions={mathMlOptions}
|
|
172
181
|
/>
|
|
182
|
+
{promptError && <div className={classes.errorText}>{promptError}</div>}
|
|
173
183
|
</InputContainer>
|
|
174
184
|
)}
|
|
175
185
|
|
|
@@ -249,6 +259,7 @@ export class Root extends React.Component {
|
|
|
249
259
|
markup={model.rationale || ''}
|
|
250
260
|
onChange={onRationaleChanged}
|
|
251
261
|
imageSupport={imageSupport}
|
|
262
|
+
error={rationaleError}
|
|
252
263
|
toolbarOpts={toolbarOpts}
|
|
253
264
|
pluginProps={getPluginProps(rationale?.inputConfiguration)}
|
|
254
265
|
spellCheck={spellCheckEnabled}
|
|
@@ -258,6 +269,7 @@ export class Root extends React.Component {
|
|
|
258
269
|
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
259
270
|
mathMlOptions={mathMlOptions}
|
|
260
271
|
/>
|
|
272
|
+
{rationaleError && <div className={classes.errorText}>{rationaleError}</div>}
|
|
261
273
|
</InputContainer>
|
|
262
274
|
)}
|
|
263
275
|
</layout.ConfigLayout>
|
package/controller/lib/index.js
CHANGED
|
@@ -232,10 +232,20 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
232
232
|
resolve(null);
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
|
-
};
|
|
235
|
+
}; // remove all html tags
|
|
236
|
+
|
|
236
237
|
|
|
237
238
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
238
239
|
|
|
240
|
+
var getInnerText = function getInnerText(html) {
|
|
241
|
+
return (html || '').replaceAll(/<[^>]*>/g, '');
|
|
242
|
+
}; // remove all html tags except img and iframe
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
var getContent = function getContent(html) {
|
|
246
|
+
return (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
|
|
247
|
+
};
|
|
248
|
+
|
|
239
249
|
var validate = function validate() {
|
|
240
250
|
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
241
251
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -245,6 +255,13 @@ var validate = function validate() {
|
|
|
245
255
|
maxShapes = config.maxShapes,
|
|
246
256
|
maxSelections = config.maxSelections;
|
|
247
257
|
var errors = {};
|
|
258
|
+
['teacherInstructions', 'prompt', 'rationale'].forEach(function (field) {
|
|
259
|
+
var _config$field;
|
|
260
|
+
|
|
261
|
+
if ((_config$field = config[field]) !== null && _config$field !== void 0 && _config$field.required && !getContent(model[field])) {
|
|
262
|
+
errors[field] = 'This field is required.';
|
|
263
|
+
}
|
|
264
|
+
});
|
|
248
265
|
var allShapes = Object.values(shapes || {}).reduce(function (acc, shape) {
|
|
249
266
|
return [].concat((0, _toConsumableArray2["default"])(acc), (0, _toConsumableArray2["default"])(shape));
|
|
250
267
|
}, []);
|
|
@@ -254,15 +271,15 @@ var validate = function validate() {
|
|
|
254
271
|
var nbOfShapes = (allShapes || []).length;
|
|
255
272
|
|
|
256
273
|
if (nbOfShapes < minShapes) {
|
|
257
|
-
errors.
|
|
274
|
+
errors.shapes = "There should be at least ".concat(minShapes, " shapes defined.");
|
|
258
275
|
} else if (nbOfShapes > maxShapes) {
|
|
259
|
-
errors.
|
|
276
|
+
errors.shapes = "No more than ".concat(maxShapes, " shapes should be defined.");
|
|
260
277
|
}
|
|
261
278
|
|
|
262
279
|
if (nbOfSelections < 1) {
|
|
263
|
-
errors.
|
|
280
|
+
errors.selections = 'There should be at least 1 shape selected.';
|
|
264
281
|
} else if (nbOfSelections > maxSelections) {
|
|
265
|
-
errors.
|
|
282
|
+
errors.selections = "No more than ".concat(maxSelections, " shapes should be selected.");
|
|
266
283
|
}
|
|
267
284
|
|
|
268
285
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","defaults","model","session","env","normalizedQuestion","imageUrl","dimensions","hotspotColor","multipleCorrect","outlineColor","partialScoring","prompt","shapes","language","rectangles","polygons","circles","Promise","resolve","out","disabled","mode","map","index","rectProps","polyProps","circleProps","responseCorrect","undefined","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","promptEnabled","strokeWidth","createDefaultModel","getScore","config","answers","partialScoringEnabled","enabled","correctAnswers","selectedChoices","choices","correctChoices","filter","choice","correct","forEach","shape","selected","answer","id","correctlySelected","extraAnswers","length","total","str","toFixed","parseFloat","outcome","score","empty","returnShapesCorrect","i","push","createCorrectResponseSession","rectangleCorrect","polygonsCorrect","circlesCorrect","validate","minShapes","maxShapes","maxSelections","errors","allShapes","Object","values","reduce","acc","nbOfSelections","nbOfShapes","shapesError","selectionsError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;;A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,GAAG,CAACL,SAAS,IAAI,EAAd,EAAkBG,MAAlB,CAAyB,UAACC,GAAD,EAAM9B,KAAN;AAAA,WAAiBA,KAAK,CAACF,OAAN,GAAgBgC,GAAG,GAAG,CAAtB,GAA0BA,GAA3C;AAAA,GAAzB,EAA0E,CAA1E,CAAvB;AAEA,MAAME,UAAU,GAAG,CAACN,SAAS,IAAI,EAAd,EAAkBpB,MAArC;;AAEA,MAAI0B,UAAU,GAAGV,SAAjB,EAA4B;AAC1BG,IAAAA,MAAM,CAACQ,WAAP,sCAAiDX,SAAjD;AACD,GAFD,MAEO,IAAIU,UAAU,GAAGT,SAAjB,EAA4B;AACjCE,IAAAA,MAAM,CAACQ,WAAP,0BAAqCV,SAArC;AACD;;AAED,MAAIQ,cAAc,GAAG,CAArB,EAAwB;AACtBN,IAAAA,MAAM,CAACS,eAAP,GAAyB,4CAAzB;AACD,GAFD,MAEO,IAAIH,cAAc,GAAGP,aAArB,EAAoC;AACzCC,IAAAA,MAAM,CAACS,eAAP,0BAAyCV,aAAzC;AACD;;AAED,SAAOC,MAAP;AACD,CAxBM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\n\nimport { isResponseCorrect } from './utils';\n\nimport defaults from './defaults';\n\nconst log = debug('pie-elements:hotspot:controller');\n\nexport const normalize = (question) => ({\n ...defaults,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n dimensions,\n hotspotColor,\n multipleCorrect,\n outlineColor,\n partialScoring,\n prompt,\n shapes,\n language,\n } = normalizedQuestion;\n const { rectangles, polygons, circles } = shapes || {};\n\n return new Promise((resolve) => {\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n dimensions,\n imageUrl,\n outlineColor,\n hotspotColor,\n multipleCorrect,\n partialScoring,\n language,\n shapes: {\n ...shapes,\n // eslint-disable-next-line no-unused-vars\n rectangles: (rectangles || []).map(({ index, ...rectProps }) => ({ ...rectProps })),\n // eslint-disable-next-line no-unused-vars\n polygons: (polygons || []).map(({ index, ...polyProps }) => ({ ...polyProps })),\n // eslint-disable-next-line no-unused-vars\n circles: (circles || []).map(({ index, ...circleProps }) => ({ ...circleProps })),\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\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 out.prompt = normalizedQuestion.promptEnabled ? prompt : null;\n out.strokeWidth = normalizedQuestion.strokeWidth;\n\n // console.log(out);\n resolve(out);\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst getScore = (config, session, env = {}) => {\n const { answers } = session || {};\n\n if (!config.shapes || (!config.shapes.rectangles && !config.shapes.polygons && !config.shapes.circles)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [], circles = [] } = {} } = config;\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n if (!partialScoringEnabled) {\n return isResponseCorrect(config, session) ? 1 : 0;\n }\n\n let correctAnswers = 0;\n let selectedChoices = 0;\n\n const choices = [...rectangles, ...polygons, ...circles];\n\n const correctChoices = choices.filter((choice) => choice.correct);\n\n choices.forEach((shape) => {\n const selected = answers && answers.filter((answer) => answer.id === shape.id)[0];\n const correctlySelected = shape.correct && selected;\n\n if (selected) {\n selectedChoices += 1;\n }\n\n if (correctlySelected) {\n correctAnswers += 1;\n }\n });\n\n const extraAnswers = selectedChoices > correctChoices.length ? selectedChoices - correctChoices.length : 0;\n\n const total = correctChoices.length === 0 ? 1 : correctChoices.length;\n const str = ((correctAnswers - extraAnswers) / total).toFixed(2);\n\n return str < 0 ? 0 : parseFloat(str);\n};\n\nexport function outcome(config, session, env = {}) {\n return new Promise((resolve) => {\n log('outcome...');\n\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (session.answers) {\n const score = getScore(config, session, env);\n resolve({ score });\n } else {\n resolve({ score: 0, empty: true });\n }\n });\n}\n\nconst returnShapesCorrect = (shapes) => {\n let answers = [];\n\n shapes.forEach((i) => {\n const { correct, id } = i;\n if (correct) {\n answers.push({ id });\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { shapes: { rectangles = [], circles = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n const circlesCorrect = returnShapesCorrect(circles);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect, ...circlesCorrect],\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { shapes } = model;\n const { minShapes = 2, maxShapes, maxSelections } = config;\n const errors = {};\n\n const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);\n\n const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);\n\n const nbOfShapes = (allShapes || []).length;\n\n if (nbOfShapes < minShapes) {\n errors.shapesError = `There should be at least ${minShapes} shapes defined.`;\n } else if (nbOfShapes > maxShapes) {\n errors.shapesError = `No more than ${maxShapes} shapes should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selectionsError = 'There should be at least 1 shape selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selectionsError = `No more than ${maxSelections} shapes should be selected.`;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","defaults","model","session","env","normalizedQuestion","imageUrl","dimensions","hotspotColor","multipleCorrect","outlineColor","partialScoring","prompt","shapes","language","rectangles","polygons","circles","Promise","resolve","out","disabled","mode","map","index","rectProps","polyProps","circleProps","responseCorrect","undefined","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","promptEnabled","strokeWidth","createDefaultModel","getScore","config","answers","partialScoringEnabled","enabled","correctAnswers","selectedChoices","choices","correctChoices","filter","choice","correct","forEach","shape","selected","answer","id","correctlySelected","extraAnswers","length","total","str","toFixed","parseFloat","outcome","score","empty","returnShapesCorrect","i","push","createCorrectResponseSession","rectangleCorrect","polygonsCorrect","circlesCorrect","getInnerText","html","replaceAll","getContent","replace","validate","minShapes","maxShapes","maxSelections","errors","field","required","allShapes","Object","values","reduce","acc","nbOfSelections","nbOfShapes","selections"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;;AAEO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,QAAD;AAAA,yCACpBC,oBADoB,GAEpBD,QAFoB;AAAA,CAAlB;;;;AAKA,SAASE,KAAT,CAAeF,QAAf,EAAyBG,OAAzB,EAAkCC,GAAlC,EAAuC;AAC5C,MAAMC,kBAAkB,GAAGN,SAAS,CAACC,QAAD,CAApC;AACA,MACEM,QADF,GAUID,kBAVJ,CACEC,QADF;AAAA,MAEEC,UAFF,GAUIF,kBAVJ,CAEEE,UAFF;AAAA,MAGEC,YAHF,GAUIH,kBAVJ,CAGEG,YAHF;AAAA,MAIEC,eAJF,GAUIJ,kBAVJ,CAIEI,eAJF;AAAA,MAKEC,YALF,GAUIL,kBAVJ,CAKEK,YALF;AAAA,MAMEC,cANF,GAUIN,kBAVJ,CAMEM,cANF;AAAA,MAOEC,MAPF,GAUIP,kBAVJ,CAOEO,MAPF;AAAA,MAQEC,MARF,GAUIR,kBAVJ,CAQEQ,MARF;AAAA,MASEC,QATF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AACL,SAAS,IAAI,EAAd,EAAkBG,MAAlB,CAAyB,UAACC,GAAD,EAAMrC,KAAN;AAAA,WAAiBA,KAAK,CAACF,OAAN,GAAgBuC,GAAG,GAAG,CAAtB,GAA0BA,GAA3C;AAAA,GAAzB,EAA0E,CAA1E,CAAvB;AAEA,MAAME,UAAU,GAAG,CAACN,SAAS,IAAI,EAAd,EAAkB3B,MAArC;;AAEA,MAAIiC,UAAU,GAAGZ,SAAjB,EAA4B;AAC1BG,IAAAA,MAAM,CAACpE,MAAP,sCAA4CiE,SAA5C;AACD,GAFD,MAEO,IAAIY,UAAU,GAAGX,SAAjB,EAA4B;AACjCE,IAAAA,MAAM,CAACpE,MAAP,0BAAgCkE,SAAhC;AACD;;AAED,MAAIU,cAAc,GAAG,CAArB,EAAwB;AACtBR,IAAAA,MAAM,CAACU,UAAP,GAAoB,4CAApB;AACD,GAFD,MAEO,IAAIF,cAAc,GAAGT,aAArB,EAAoC;AACzCC,IAAAA,MAAM,CAACU,UAAP,0BAAoCX,aAApC;AACD;;AAED,SAAOC,MAAP;AACD,CA9BM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\n\nimport { isResponseCorrect } from './utils';\n\nimport defaults from './defaults';\n\nconst log = debug('pie-elements:hotspot:controller');\n\nexport const normalize = (question) => ({\n ...defaults,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n dimensions,\n hotspotColor,\n multipleCorrect,\n outlineColor,\n partialScoring,\n prompt,\n shapes,\n language,\n } = normalizedQuestion;\n const { rectangles, polygons, circles } = shapes || {};\n\n return new Promise((resolve) => {\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n dimensions,\n imageUrl,\n outlineColor,\n hotspotColor,\n multipleCorrect,\n partialScoring,\n language,\n shapes: {\n ...shapes,\n // eslint-disable-next-line no-unused-vars\n rectangles: (rectangles || []).map(({ index, ...rectProps }) => ({ ...rectProps })),\n // eslint-disable-next-line no-unused-vars\n polygons: (polygons || []).map(({ index, ...polyProps }) => ({ ...polyProps })),\n // eslint-disable-next-line no-unused-vars\n circles: (circles || []).map(({ index, ...circleProps }) => ({ ...circleProps })),\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\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 out.prompt = normalizedQuestion.promptEnabled ? prompt : null;\n out.strokeWidth = normalizedQuestion.strokeWidth;\n\n // console.log(out);\n resolve(out);\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst getScore = (config, session, env = {}) => {\n const { answers } = session || {};\n\n if (!config.shapes || (!config.shapes.rectangles && !config.shapes.polygons && !config.shapes.circles)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [], circles = [] } = {} } = config;\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n if (!partialScoringEnabled) {\n return isResponseCorrect(config, session) ? 1 : 0;\n }\n\n let correctAnswers = 0;\n let selectedChoices = 0;\n\n const choices = [...rectangles, ...polygons, ...circles];\n\n const correctChoices = choices.filter((choice) => choice.correct);\n\n choices.forEach((shape) => {\n const selected = answers && answers.filter((answer) => answer.id === shape.id)[0];\n const correctlySelected = shape.correct && selected;\n\n if (selected) {\n selectedChoices += 1;\n }\n\n if (correctlySelected) {\n correctAnswers += 1;\n }\n });\n\n const extraAnswers = selectedChoices > correctChoices.length ? selectedChoices - correctChoices.length : 0;\n\n const total = correctChoices.length === 0 ? 1 : correctChoices.length;\n const str = ((correctAnswers - extraAnswers) / total).toFixed(2);\n\n return str < 0 ? 0 : parseFloat(str);\n};\n\nexport function outcome(config, session, env = {}) {\n return new Promise((resolve) => {\n log('outcome...');\n\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (session.answers) {\n const score = getScore(config, session, env);\n resolve({ score });\n } else {\n resolve({ score: 0, empty: true });\n }\n });\n}\n\nconst returnShapesCorrect = (shapes) => {\n let answers = [];\n\n shapes.forEach((i) => {\n const { correct, id } = i;\n if (correct) {\n answers.push({ id });\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { shapes: { rectangles = [], circles = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n const circlesCorrect = returnShapesCorrect(circles);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect, ...circlesCorrect],\n id: '1',\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 { shapes } = model;\n const { minShapes = 2, maxShapes, maxSelections } = config;\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 const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);\n\n const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);\n\n const nbOfShapes = (allShapes || []).length;\n\n if (nbOfShapes < minShapes) {\n errors.shapes = `There should be at least ${minShapes} shapes defined.`;\n } else if (nbOfShapes > maxShapes) {\n errors.shapes = `No more than ${maxShapes} shapes should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selections = 'There should be at least 1 shape selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selections = `No more than ${maxSelections} shapes should be selected.`;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/controller/src/index.js
CHANGED
|
@@ -167,11 +167,23 @@ export const createCorrectResponseSession = (question, env) => {
|
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
+
// remove all html tags
|
|
171
|
+
const getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
172
|
+
|
|
173
|
+
// remove all html tags except img and iframe
|
|
174
|
+
const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
|
|
175
|
+
|
|
170
176
|
export const validate = (model = {}, config = {}) => {
|
|
171
177
|
const { shapes } = model;
|
|
172
178
|
const { minShapes = 2, maxShapes, maxSelections } = config;
|
|
173
179
|
const errors = {};
|
|
174
180
|
|
|
181
|
+
['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {
|
|
182
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
183
|
+
errors[field] = 'This field is required.';
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
175
187
|
const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);
|
|
176
188
|
|
|
177
189
|
const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);
|
|
@@ -179,15 +191,15 @@ export const validate = (model = {}, config = {}) => {
|
|
|
179
191
|
const nbOfShapes = (allShapes || []).length;
|
|
180
192
|
|
|
181
193
|
if (nbOfShapes < minShapes) {
|
|
182
|
-
errors.
|
|
194
|
+
errors.shapes = `There should be at least ${minShapes} shapes defined.`;
|
|
183
195
|
} else if (nbOfShapes > maxShapes) {
|
|
184
|
-
errors.
|
|
196
|
+
errors.shapes = `No more than ${maxShapes} shapes should be defined.`;
|
|
185
197
|
}
|
|
186
198
|
|
|
187
199
|
if (nbOfSelections < 1) {
|
|
188
|
-
errors.
|
|
200
|
+
errors.selections = 'There should be at least 1 shape selected.';
|
|
189
201
|
} else if (nbOfSelections > maxSelections) {
|
|
190
|
-
errors.
|
|
202
|
+
errors.selections = `No more than ${maxSelections} shapes should be selected.`;
|
|
191
203
|
}
|
|
192
204
|
|
|
193
205
|
return errors;
|
package/docs/config-schema.json
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"rationale": {
|
|
89
|
-
"title": "
|
|
89
|
+
"title": "EditableHtmlPluginConfigureRequired",
|
|
90
90
|
"type": "object",
|
|
91
91
|
"properties": {
|
|
92
92
|
"inputConfiguration": {
|
|
@@ -139,6 +139,11 @@
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
},
|
|
142
|
+
"required": {
|
|
143
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
144
|
+
"type": "boolean",
|
|
145
|
+
"title": "required"
|
|
146
|
+
},
|
|
142
147
|
"settings": {
|
|
143
148
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
144
149
|
"type": "boolean",
|
|
@@ -152,7 +157,7 @@
|
|
|
152
157
|
}
|
|
153
158
|
},
|
|
154
159
|
"prompt": {
|
|
155
|
-
"title": "
|
|
160
|
+
"title": "EditableHtmlPluginConfigureRequired",
|
|
156
161
|
"type": "object",
|
|
157
162
|
"properties": {
|
|
158
163
|
"inputConfiguration": {
|
|
@@ -205,6 +210,11 @@
|
|
|
205
210
|
}
|
|
206
211
|
}
|
|
207
212
|
},
|
|
213
|
+
"required": {
|
|
214
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
215
|
+
"type": "boolean",
|
|
216
|
+
"title": "required"
|
|
217
|
+
},
|
|
208
218
|
"settings": {
|
|
209
219
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
210
220
|
"type": "boolean",
|
|
@@ -218,7 +228,7 @@
|
|
|
218
228
|
}
|
|
219
229
|
},
|
|
220
230
|
"teacherInstructions": {
|
|
221
|
-
"title": "
|
|
231
|
+
"title": "EditableHtmlPluginConfigureRequired",
|
|
222
232
|
"type": "object",
|
|
223
233
|
"properties": {
|
|
224
234
|
"inputConfiguration": {
|
|
@@ -271,6 +281,11 @@
|
|
|
271
281
|
}
|
|
272
282
|
}
|
|
273
283
|
},
|
|
284
|
+
"required": {
|
|
285
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
286
|
+
"type": "boolean",
|
|
287
|
+
"title": "required"
|
|
288
|
+
},
|
|
274
289
|
"settings": {
|
|
275
290
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
276
291
|
"type": "boolean",
|
|
@@ -610,8 +625,8 @@
|
|
|
610
625
|
}
|
|
611
626
|
}
|
|
612
627
|
},
|
|
613
|
-
"
|
|
614
|
-
"title": "
|
|
628
|
+
"EditableHtmlPluginConfigureRequired": {
|
|
629
|
+
"title": "EditableHtmlPluginConfigureRequired",
|
|
615
630
|
"type": "object",
|
|
616
631
|
"properties": {
|
|
617
632
|
"inputConfiguration": {
|
|
@@ -664,6 +679,11 @@
|
|
|
664
679
|
}
|
|
665
680
|
}
|
|
666
681
|
},
|
|
682
|
+
"required": {
|
|
683
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
684
|
+
"type": "boolean",
|
|
685
|
+
"title": "required"
|
|
686
|
+
},
|
|
667
687
|
"settings": {
|
|
668
688
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
669
689
|
"type": "boolean",
|
|
@@ -102,6 +102,10 @@ Properties of the `image` object:
|
|
|
102
102
|
|
|
103
103
|
Indicates if the plugin is disabled or not
|
|
104
104
|
|
|
105
|
+
## `required` (boolean)
|
|
106
|
+
|
|
107
|
+
Indicates if the item is required and the value cannot be empty
|
|
108
|
+
|
|
105
109
|
## `settings` (boolean)
|
|
106
110
|
|
|
107
111
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -150,6 +154,10 @@ Properties of the `image` object:
|
|
|
150
154
|
|
|
151
155
|
Indicates if the plugin is disabled or not
|
|
152
156
|
|
|
157
|
+
## `required` (boolean)
|
|
158
|
+
|
|
159
|
+
Indicates if the item is required and the value cannot be empty
|
|
160
|
+
|
|
153
161
|
## `settings` (boolean)
|
|
154
162
|
|
|
155
163
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -198,6 +206,10 @@ Properties of the `image` object:
|
|
|
198
206
|
|
|
199
207
|
Indicates if the plugin is disabled or not
|
|
200
208
|
|
|
209
|
+
## `required` (boolean)
|
|
210
|
+
|
|
211
|
+
Indicates if the item is required and the value cannot be empty
|
|
212
|
+
|
|
201
213
|
## `settings` (boolean)
|
|
202
214
|
|
|
203
215
|
Indicates if the item has to be displayed in the Settings Panel
|
|
@@ -456,9 +468,9 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
456
468
|
|
|
457
469
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
458
470
|
|
|
459
|
-
## `
|
|
471
|
+
## `EditableHtmlPluginConfigureRequired` (object)
|
|
460
472
|
|
|
461
|
-
Properties of the `
|
|
473
|
+
Properties of the `EditableHtmlPluginConfigureRequired` object:
|
|
462
474
|
|
|
463
475
|
### `inputConfiguration` (object)
|
|
464
476
|
|
|
@@ -496,6 +508,10 @@ Properties of the `image` object:
|
|
|
496
508
|
|
|
497
509
|
Indicates if the plugin is disabled or not
|
|
498
510
|
|
|
511
|
+
### `required` (boolean)
|
|
512
|
+
|
|
513
|
+
Indicates if the item is required and the value cannot be empty
|
|
514
|
+
|
|
499
515
|
### `settings` (boolean)
|
|
500
516
|
|
|
501
517
|
Indicates if the item has to be displayed in the Settings Panel
|
package/docs/pie-schema.json
CHANGED
|
@@ -338,8 +338,8 @@
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
},
|
|
341
|
-
"
|
|
342
|
-
"title": "
|
|
341
|
+
"EditableHtmlPluginConfigureRequired": {
|
|
342
|
+
"title": "EditableHtmlPluginConfigureRequired",
|
|
343
343
|
"type": "object",
|
|
344
344
|
"properties": {
|
|
345
345
|
"inputConfiguration": {
|
|
@@ -392,6 +392,11 @@
|
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
},
|
|
395
|
+
"required": {
|
|
396
|
+
"description": "Indicates if the item is required and the value cannot be empty",
|
|
397
|
+
"type": "boolean",
|
|
398
|
+
"title": "required"
|
|
399
|
+
},
|
|
395
400
|
"settings": {
|
|
396
401
|
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
397
402
|
"type": "boolean",
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -240,9 +240,9 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
240
240
|
|
|
241
241
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
242
242
|
|
|
243
|
-
## `
|
|
243
|
+
## `EditableHtmlPluginConfigureRequired` (object)
|
|
244
244
|
|
|
245
|
-
Properties of the `
|
|
245
|
+
Properties of the `EditableHtmlPluginConfigureRequired` object:
|
|
246
246
|
|
|
247
247
|
### `inputConfiguration` (object)
|
|
248
248
|
|
|
@@ -280,6 +280,10 @@ Properties of the `image` object:
|
|
|
280
280
|
|
|
281
281
|
Indicates if the plugin is disabled or not
|
|
282
282
|
|
|
283
|
+
### `required` (boolean)
|
|
284
|
+
|
|
285
|
+
Indicates if the item is required and the value cannot be empty
|
|
286
|
+
|
|
283
287
|
### `settings` (boolean)
|
|
284
288
|
|
|
285
289
|
Indicates if the item has to be displayed in the Settings Panel
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot",
|
|
3
|
-
"version": "6.12.1-next.
|
|
3
|
+
"version": "6.12.1-next.33+8fc82ab19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.3",
|
|
11
11
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
12
|
-
"@pie-lib/pie-toolbox": "1.12.
|
|
12
|
+
"@pie-lib/pie-toolbox": "1.12.2",
|
|
13
13
|
"konva": "^3.2.5",
|
|
14
14
|
"prop-types": "^15.6.1",
|
|
15
15
|
"react": "^16.8.1",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"author": "pie framework developers",
|
|
20
20
|
"license": "ISC",
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "8fc82ab19baf45aecb40e4b364a7c307a9840130",
|
|
22
22
|
"scripts": {
|
|
23
23
|
"postpublish": "../../scripts/postpublish"
|
|
24
24
|
},
|