@pie-element/hotspot 5.14.6-next.7 → 5.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/configure/CHANGELOG.md +18 -0
- package/configure/lib/defaults.js +9 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +33 -1
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +10 -3
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +3 -3
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +11 -0
- package/configure/src/defaults.js +9 -0
- package/configure/src/index.js +28 -0
- package/configure/src/root.jsx +5 -1
- package/controller/CHANGELOG.md +11 -0
- package/controller/lib/index.js +3 -1
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/index.js +2 -1
- package/docs/config-schema.json +101 -0
- package/docs/config-schema.json.md +70 -1
- package/docs/pie-schema.json +46 -0
- package/docs/pie-schema.json.md +34 -0
- package/lib/hotspot/index.js +3 -1
- package/lib/hotspot/index.js.map +1 -1
- package/package.json +3 -2
- package/src/hotspot/index.jsx +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.15.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@5.14.5...@pie-element/hotspot@5.15.0) (2023-09-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-libs PD-3051 ([1e1a7a3](https://github.com/pie-framework/pie-elements/commit/1e1a7a38732eff5585ad789aea5a08c5e94720ae))
|
|
12
|
+
* update snapshots ([7f7432d](https://github.com/pie-framework/pie-elements/commit/7f7432d4e79747bd8824470ea19ebf7d40617fc5))
|
|
13
|
+
* updated pie-libs PD-2765, PD-3051 ([e6f5b17](https://github.com/pie-framework/pie-elements/commit/e6f5b17c95faf426898f897651863089a54ff3ff))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **hotspot:** translations PD-2802 PD-2795 ([15b03fd](https://github.com/pie-framework/pie-elements/commit/15b03fd1d6659364c4d765406c807d30dc5375d1))
|
|
19
|
+
* **select-text, inline-dropdown:** PD-2797-PD-2802 update documentation ([b8ba6c7](https://github.com/pie-framework/pie-elements/commit/b8ba6c7d12eea9d0d729a38e18e87a21ea496a8b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [5.14.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@5.14.4...@pie-element/hotspot@5.14.5) (2023-08-21)
|
|
7
26
|
|
|
8
27
|
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.11.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@5.10.5...@pie-element/hotspot-configure@5.11.0) (2023-09-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-libs PD-3051 ([1e1a7a3](https://github.com/pie-framework/pie-elements/commit/1e1a7a38732eff5585ad789aea5a08c5e94720ae))
|
|
12
|
+
* update snapshots ([7f7432d](https://github.com/pie-framework/pie-elements/commit/7f7432d4e79747bd8824470ea19ebf7d40617fc5))
|
|
13
|
+
* updated pie-libs PD-2765, PD-3051 ([e6f5b17](https://github.com/pie-framework/pie-elements/commit/e6f5b17c95faf426898f897651863089a54ff3ff))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **hotspot:** translations PD-2802 PD-2795 ([15b03fd](https://github.com/pie-framework/pie-elements/commit/15b03fd1d6659364c4d765406c807d30dc5375d1))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [5.10.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@5.10.4...@pie-element/hotspot-configure@5.10.5) (2023-08-21)
|
|
7
25
|
|
|
8
26
|
|
|
@@ -79,6 +79,15 @@ var _default = {
|
|
|
79
79
|
mathMlOptions: {
|
|
80
80
|
mmlOutput: false,
|
|
81
81
|
mmlEditing: false
|
|
82
|
+
},
|
|
83
|
+
language: {
|
|
84
|
+
settings: false,
|
|
85
|
+
label: 'Specify Language',
|
|
86
|
+
enabled: false
|
|
87
|
+
},
|
|
88
|
+
languageChoices: {
|
|
89
|
+
label: 'Language Choices',
|
|
90
|
+
options: []
|
|
82
91
|
}
|
|
83
92
|
}
|
|
84
93
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","imageUrl","shapes","rectangles","polygons","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","settings","label","rationale","settingsPanelDisabled","spellCheck","enabled","teacherInstructions","preserveAspectRatio","minShapes","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","mmlOutput","mmlEditing"],"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;AAFJ,KAJH;AAQLC,IAAAA,eAAe,EAAE,IARZ;AASLC,IAAAA,cAAc,EAAE,KAT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AAAA,KAAK,EAAE;AAHY,KA3BR;AAgCbO,IAAAA,SAAS,EAAE,CAhCE;AAiCbC,IAAAA,aAAa,EAAE;AACbH,MAAAA,mBAAmB,EAAE,GADR;AAEb3B,MAAAA,MAAM,EAAE,GAFK;AAGbuB,MAAAA,SAAS,EAAE;AAHE,KAjCF;AAsCbQ,IAAAA,cAAc,EAAE;AACdJ,MAAAA,mBAAmB,EAAE,GADP;AAEd3B,MAAAA,MAAM,EAAE,GAFM;AAGduB,MAAAA,SAAS,EAAE;AAHG,KAtCH;AA2CbS,IAAAA,UAAU,EAAE;AACVX,MAAAA,QAAQ,EAAE,KADA;AAEVC,MAAAA,KAAK,EAAE;AAFG,KA3CC;AA+CbW,IAAAA,aAAa,EAAE;AACbC,MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,UAAU,EAAE;AAFC
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","imageUrl","shapes","rectangles","polygons","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","settings","label","rationale","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;AAFJ,KAJH;AAQLC,IAAAA,eAAe,EAAE,IARZ;AASLC,IAAAA,cAAc,EAAE,KATX;AAULC,IAAAA,UAAU,EAAE;AACVC,MAAAA,MAAM,EAAE,CADE;AAEVC,MAAAA,KA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IAAAA,aAAa,EAAE;AACbH,MAAAA,mBAAmB,EAAE,GADR;AAEb3B,MAAAA,MAAM,EAAE,GAFK;AAGbuB,MAAAA,SAAS,EAAE;AAHE,KAjCF;AAsCbQ,IAAAA,cAAc,EAAE;AACdJ,MAAAA,mBAAmB,EAAE,GADP;AAEd3B,MAAAA,MAAM,EAAE,GAFM;AAGduB,MAAAA,SAAS,EAAE;AAHG,KAtCH;AA2CbS,IAAAA,UAAU,EAAE;AACVX,MAAAA,QAAQ,EAAE,KADA;AAEVC,MAAAA,KAAK,EAAE;AAFG,KA3CC;AA+CbW,IAAAA,aAAa,EAAE;AACbC,MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,UAAU,EAAE;AAFC,KA/CF;AAmDbC,IAAAA,QAAQ,EAAE;AACRf,MAAAA,QAAQ,EAAE,KADF;AAERC,MAAAA,KAAK,EAAE,kBAFC;AAGRI,MAAAA,OAAO,EAAE;AAHD,KAnDG;AAwDbW,IAAAA,eAAe,EAAE;AACff,MAAAA,KAAK,EAAE,kBADQ;AAEfgB,MAAAA,OAAO,EAAE;AAFM;AAxDJ;AAzBF,C","sourcesContent":["export default {\n model: {\n prompt: '',\n toolbarEditorPosition: 'bottom',\n imageUrl: '',\n shapes: {\n rectangles: [],\n polygons: [],\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 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 },\n prompt: {\n settings: true,\n label: 'Prompt',\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 },\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/index.js
CHANGED
|
@@ -139,7 +139,39 @@ var HotspotConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
|
139
139
|
}, {
|
|
140
140
|
key: "configuration",
|
|
141
141
|
set: function set(c) {
|
|
142
|
-
|
|
142
|
+
var _this2 = this;
|
|
143
|
+
|
|
144
|
+
this._configuration = c; // if language:enabled is true, then the corresponding default item model should include a language value;
|
|
145
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
146
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
147
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
148
|
+
|
|
149
|
+
if (c.language.enabled) {
|
|
150
|
+
var _c$languageChoices, _c$languageChoices$op;
|
|
151
|
+
|
|
152
|
+
if ((_c$languageChoices = c.languageChoices) !== null && _c$languageChoices !== void 0 && (_c$languageChoices$op = _c$languageChoices.options) !== null && _c$languageChoices$op !== void 0 && _c$languageChoices$op.length) {
|
|
153
|
+
this._model.language = c.languageChoices.options[0].value;
|
|
154
|
+
}
|
|
155
|
+
} else if (c.language.settings && this._model.language) {
|
|
156
|
+
this._configuration.language.enabled = true;
|
|
157
|
+
|
|
158
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
159
|
+
this._configuration.languageChoices.options = [];
|
|
160
|
+
} // check if the language is already included in the languageChoices.options array
|
|
161
|
+
// and if not, then add it.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if (!this._configuration.languageChoices.options.find(function (option) {
|
|
165
|
+
return option.value === _this2._model.language;
|
|
166
|
+
})) {
|
|
167
|
+
this._configuration.languageChoices.options.push({
|
|
168
|
+
value: this._model.language,
|
|
169
|
+
label: this._model.language
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
delete this._model.language;
|
|
174
|
+
}
|
|
143
175
|
|
|
144
176
|
this._render();
|
|
145
177
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","HotspotConfigure","c","_configuration","_render","m","propertyType","_model","shapes","rectangles","polygons","map","shape","correct","onModelChanged","colorType","color","prompt","rationale","teacherInstructions","dimensions","imageUrl","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","createDefaultModel","sensibleDefaults","configuration","bind","s","reset","resetValue","ModelUpdatedEvent","dispatchModelUpdated","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Root","model","onColorChanged","onImageUpload","onRationaleChanged","onConfigurationChanged","onPromptChanged","onUpdateImageDimension","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","onUpdateShapes","onModelChangedByConfig","onTeacherInstructionsChanged","ReactDOM","render","HTMLElement","hotspotList","hotspotColor","outlineList","outlineColor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAQA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEqBC,gB;;;;;AASnB,8BAAc;AAAA;;AAAA;AACZ;AADY,+GA6BW,UAACC,CAAD,EAAO;AAC9B,YAAKC,cAAL,GAAsBD,CAAtB;;AACA,YAAKE,OAAL;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AAC0C,KAAD,uEAAS,EAAT;AAAA,uDACvBd,qBAAiBc,KADM,GAEvBA,KAFuB;AAG1BoB,IAAAA,WAAW,EAAEpB,KAAK,CAACoB,WAAN,IAAqB,CAACpB,KAAK,CAACqB,YAAP,CAArB,IAA6CnC,qBAAiBc,KAAjB,CAAuBoB,WAHvD;AAI1BE,IAAAA,WAAW,EAAEtB,KAAK,CAACsB,WAAN,IAAqB,CAACtB,KAAK,CAACuB,YAAP,CAArB,IAA6CrC,qBAAiBc,KAAjB,CAAuBsB,WAJvD;AAK1BzD,IAAAA,MAAM,EAAEmC,KAAK,CAACnC,MAAN,IAAgBqB,qBAAiBc,KAAjB,CAAuBnC,MAAvC,IAAiD;AAL/B;AAAA,C","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debug from 'debug';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Root from './root';\nimport sensibleDefaults from './defaults';\n\nconst log = debug('hotspot:configure');\n\nexport default class HotspotConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...sensibleDefaults.model,\n ...model,\n hotspotList: model.hotspotList || [model.hotspotColor] || sensibleDefaults.model.hotspotList,\n outlineList: model.outlineList || [model.outlineColor] || sensibleDefaults.model.outlineList,\n shapes: model.shapes || sensibleDefaults.model.shapes || {},\n });\n\n constructor() {\n super();\n this._model = HotspotConfigure.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n set model(s) {\n this._model = HotspotConfigure.createDefaultModel(s);\n this._render();\n }\n\n set configuration(c) {\n this._configuration = c;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = m;\n this.dispatchModelUpdated(reset);\n this._render();\n }\n\n onConfigurationChanged = (c) => {\n this._configuration = c;\n this._render();\n };\n\n onModelChangedByConfig = (m, propertyType) => {\n const _model = m;\n\n if (propertyType === 'multipleCorrect') {\n const { rectangles = [], polygons = [] } = _model.shapes || {};\n\n _model.shapes.rectangles = rectangles.map((shape) => ({ ...shape, correct: false }));\n _model.shapes.polygons = polygons.map((shape) => ({ ...shape, correct: false }));\n }\n\n this.onModelChanged(_model);\n };\n\n onColorChanged = (colorType, color) => {\n this.onModelChanged({\n ...this._model,\n [colorType]: color,\n });\n };\n\n onPromptChanged = (prompt) => {\n this.onModelChanged({\n ...this._model,\n prompt,\n });\n };\n\n onRationaleChanged = (rationale) => {\n this.onModelChanged({\n ...this._model,\n rationale,\n });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.onModelChanged({\n ...this._model,\n teacherInstructions,\n });\n };\n\n onUpdateImageDimension = (dimensions) => {\n this.onModelChanged({\n ...this._model,\n dimensions,\n });\n };\n\n onUpdateShapes = (shapes) => {\n this.onModelChanged({\n ...this._model,\n shapes,\n });\n };\n\n onImageUpload = (imageUrl) => {\n this.onModelChanged({\n ...this._model,\n imageUrl,\n });\n };\n\n insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n onDeleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n };\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n let element = React.createElement(Root, {\n configuration: this._configuration,\n model: this._model,\n onColorChanged: this.onColorChanged,\n onImageUpload: this.onImageUpload,\n onRationaleChanged: this.onRationaleChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n onPromptChanged: this.onPromptChanged,\n onUpdateImageDimension: this.onUpdateImageDimension,\n imageSupport: {\n add: this.insertImage,\n delete: this.onDeleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n onUpdateShapes: this.onUpdateShapes,\n onModelChangedByConfig: this.onModelChangedByConfig,\n onTeacherInstructionsChanged: this.onTeacherInstructionsChanged,\n });\n\n ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","HotspotConfigure","c","_configuration","_render","m","propertyType","_model","shapes","rectangles","polygons","map","shape","correct","onModelChanged","colorType","color","prompt","rationale","teacherInstructions","dimensions","imageUrl","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","createDefaultModel","sensibleDefaults","configuration","bind","s","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","reset","resetValue","ModelUpdatedEvent","dispatchModelUpdated","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Root","model","onColorChanged","onImageUpload","onRationaleChanged","onConfigurationChanged","onPromptChanged","onUpdateImageDimension","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","onUpdateShapes","onModelChangedByConfig","onTeacherInstructionsChanged","ReactDOM","render","HTMLElement","hotspotList","hotspotColor","outlineList","outlineColor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAQA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEqBC,gB;;;;;AASnB,8BAAc;AAAA;;AAAA;AACZ;AADY,+GAyDW,UAACC,CAAD,EAAO;AAC9B,YAAKC,cAAL,GAAsBD,CAAtB;;AACA,YAAKE,OAAL;AACD,KA5Da;AAAA,+GA8DW,UAACC,CAAD,EAAIC,YAAJ,EAAqB;AAC5C,UAAMC,MAAM,GAAGF,CAAf;;AAEA,UAAIC,YAAY,KAAK,iBAArB,EAAwC;AACtC,mBAA2CC,MAAM,CAACC,MAAP,IAAiB,EAA5D;AAAA,mCAAQC,UAAR;AAAA,YAAQA,UAAR,gCAAqB,EAArB;AAAA,iCAA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,qBAAiByB,KAAjB,CAAuBsB,WAJvD;AAK1BpE,IAAAA,MAAM,EAAE8C,KAAK,CAAC9C,MAAN,IAAgBqB,qBAAiByB,KAAjB,CAAuB9C,MAAvC,IAAiD;AAL/B;AAAA,C","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debug from 'debug';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Root from './root';\nimport sensibleDefaults from './defaults';\n\nconst log = debug('hotspot:configure');\n\nexport default class HotspotConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...sensibleDefaults.model,\n ...model,\n hotspotList: model.hotspotList || [model.hotspotColor] || sensibleDefaults.model.hotspotList,\n outlineList: model.outlineList || [model.outlineColor] || sensibleDefaults.model.outlineList,\n shapes: model.shapes || sensibleDefaults.model.shapes || {},\n });\n\n constructor() {\n super();\n this._model = HotspotConfigure.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n set model(s) {\n this._model = HotspotConfigure.createDefaultModel(s);\n this._render();\n }\n\n set configuration(c) {\n this._configuration = c;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (c.language.enabled) {\n if (c.languageChoices?.options?.length) {\n this._model.language = c.languageChoices.options[0].value;\n }\n } else if (c.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = m;\n this.dispatchModelUpdated(reset);\n this._render();\n }\n\n onConfigurationChanged = (c) => {\n this._configuration = c;\n this._render();\n };\n\n onModelChangedByConfig = (m, propertyType) => {\n const _model = m;\n\n if (propertyType === 'multipleCorrect') {\n const { rectangles = [], polygons = [] } = _model.shapes || {};\n\n _model.shapes.rectangles = rectangles.map((shape) => ({ ...shape, correct: false }));\n _model.shapes.polygons = polygons.map((shape) => ({ ...shape, correct: false }));\n }\n\n this.onModelChanged(_model);\n };\n\n onColorChanged = (colorType, color) => {\n this.onModelChanged({\n ...this._model,\n [colorType]: color,\n });\n };\n\n onPromptChanged = (prompt) => {\n this.onModelChanged({\n ...this._model,\n prompt,\n });\n };\n\n onRationaleChanged = (rationale) => {\n this.onModelChanged({\n ...this._model,\n rationale,\n });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.onModelChanged({\n ...this._model,\n teacherInstructions,\n });\n };\n\n onUpdateImageDimension = (dimensions) => {\n this.onModelChanged({\n ...this._model,\n dimensions,\n });\n };\n\n onUpdateShapes = (shapes) => {\n this.onModelChanged({\n ...this._model,\n shapes,\n });\n };\n\n onImageUpload = (imageUrl) => {\n this.onModelChanged({\n ...this._model,\n imageUrl,\n });\n };\n\n insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n onDeleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n };\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n let element = React.createElement(Root, {\n configuration: this._configuration,\n model: this._model,\n onColorChanged: this.onColorChanged,\n onImageUpload: this.onImageUpload,\n onRationaleChanged: this.onRationaleChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n onPromptChanged: this.onPromptChanged,\n onUpdateImageDimension: this.onUpdateImageDimension,\n imageSupport: {\n add: this.insertImage,\n delete: this.onDeleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n onUpdateShapes: this.onUpdateShapes,\n onModelChangedByConfig: this.onModelChangedByConfig,\n onTeacherInstructionsChanged: this.onTeacherInstructionsChanged,\n });\n\n ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
|
package/configure/lib/root.js
CHANGED
|
@@ -52,7 +52,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
52
52
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
53
|
|
|
54
54
|
var Panel = _configUi.settings.Panel,
|
|
55
|
-
toggle = _configUi.settings.toggle
|
|
55
|
+
toggle = _configUi.settings.toggle,
|
|
56
|
+
dropdown = _configUi.settings.dropdown;
|
|
56
57
|
|
|
57
58
|
var Root = /*#__PURE__*/function (_React$Component) {
|
|
58
59
|
(0, _inherits2["default"])(Root, _React$Component);
|
|
@@ -144,7 +145,11 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
144
145
|
_ref$withRubric = _ref.withRubric,
|
|
145
146
|
withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric,
|
|
146
147
|
_ref$mathMlOptions = _ref.mathMlOptions,
|
|
147
|
-
mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions
|
|
148
|
+
mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions,
|
|
149
|
+
_ref$language = _ref.language,
|
|
150
|
+
language = _ref$language === void 0 ? {} : _ref$language,
|
|
151
|
+
_ref$languageChoices = _ref.languageChoices,
|
|
152
|
+
languageChoices = _ref$languageChoices === void 0 ? {} : _ref$languageChoices;
|
|
148
153
|
|
|
149
154
|
var _ref2 = model || {},
|
|
150
155
|
errors = _ref2.errors,
|
|
@@ -167,7 +172,9 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
167
172
|
var panelSettings = {
|
|
168
173
|
multipleCorrect: multipleCorrect.settings && toggle(multipleCorrect.label),
|
|
169
174
|
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
170
|
-
promptEnabled: prompt.settings && toggle(prompt.label)
|
|
175
|
+
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
176
|
+
'language.enabled': language.settings && toggle(language.label, true),
|
|
177
|
+
language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
|
|
171
178
|
};
|
|
172
179
|
var panelProperties = {
|
|
173
180
|
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/root.jsx"],"names":["Panel","settings","toggle","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","contentDimensions","maxImageWidth","maxImageHeight","multipleCorrect","partialScoring","prompt","rationale","settingsPanelDisabled","spellCheck","teacherInstructions","withRubric","mathMlOptions","errors","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","shapesError","selectionsError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","label","panelProperties","rubricEnabled","Settings","Properties","promptContainer","language","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,GAA0BC,kBAA1B,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA0BD,kBAA1B,CAAeC,MAAf;;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,CAlBqD,CAmBrD;;AACA,UAAMS,aAAa,GAAG,6BAAiBV,UAAjB,EAA6B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IAAV,CAAeF,UAdjB;AAefxF,EAAAA,sBAAsB,EAAEsF,sBAAUI,IAAV,CAAeF,UAfxB;AAgBfvF,EAAAA,cAAc,EAAEqF,sBAAUI,IAAV,CAAeF,UAhBhB;AAiBf5E,EAAAA,sBAAsB,EAAE0E,sBAAUI,IAAV,CAAeF,UAjBxB;AAkBf1E,EAAAA,kBAAkB,EAAEwE,sBAAUI,IAAV,CAAeF,UAlBpB;AAmBf9E,EAAAA,sBAAsB,EAAE4E,sBAAUI,IAAV,CAAeF,UAnBxB;AAoBfzE,EAAAA,4BAA4B,EAAEuE,sBAAUI,IAAV,CAAeF;AApB9B,CAAjB;;eAuBe,wBAAWpB,MAAX,EAAmBjF,IAAnB,C","sourcesContent":["import React from 'react';\nimport { settings, layout, InputContainer, NumberTextField } from '@pie-lib/config-ui';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/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 } = 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 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 } = 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 };\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 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 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 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 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","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","Settings","Properties","promptContainer","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,UAA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SAAL,GAAiB;AACfhF,EAAAA,OAAO,EAAEiF,sBAAUC,MAAV,CAAiBC,UADX;AAEf5F,EAAAA,aAAa,EAAE0F,sBAAUC,MAFV;AAGf9F,EAAAA,KAAK,EAAE6F,sBAAUC,MAAV,CAAiBC,UAHT;AAIflF,EAAAA,YAAY,EAAEgF,sBAAUG,KAAV,CAAgB;AAC5B9B,IAAAA,GAAG,EAAE2B,sBAAUI,IADa;AAE5B,cAAQJ,sBAAUI;AAFU,GAAhB,CAJC;AAQfnF,EAAAA,kBAAkB,EAAE+E,sBAAUG,KAAV,CAAgB;AAClC9B,IAAAA,GAAG,EAAE2B,sBAAUI,IADmB;AAElC,cAAQJ,sBAAUI;AAFgB,GAAhB,CARL;AAYfjF,EAAAA,aAAa,EAAE6E,sBAAUI,IAAV,CAAeF,UAZf;AAafpG,EAAAA,cAAc,EAAEkG,sBAAUI,IAAV,CAAeF,UAbhB;AAcf7E,EAAAA,eAAe,EAAE2E,sBAAUI,IAAV,CAAeF,UAdjB;AAef1F,EAAAA,sBAAsB,EAAEwF,sBAAUI,IAAV,CAAeF,UAfxB;AAgBfzF,EAAAA,cAAc,EAAEuF,sBAAUI,IAAV,CAAeF,UAhBhB;AAiBf9E,EAAAA,sBAAsB,EAAE4E,sBAAUI,IAAV,CAAeF,UAjBxB;AAkBf5E,EAAAA,kBAAkB,EAAE0E,sBAAUI,IAAV,CAAeF,UAlBpB;AAmBfhF,EAAAA,sBAAsB,EAAE8E,sBAAUI,IAAV,CAAeF,UAnBxB;AAoBf3E,EAAAA,4BAA4B,EAAEyE,sBAAUI,IAAV,CAAeF;AApB9B,CAAjB;;eAuBe,wBAAWpB,MAAX,EAAmBnF,IAAnB,C","sourcesContent":["import React from 'react';\nimport { settings, layout, InputContainer, NumberTextField } from '@pie-lib/config-ui';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/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 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 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 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 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 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"}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.11.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -10,8 +10,8 @@
|
|
|
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/config-ui": "^11.9.
|
|
14
|
-
"@pie-lib/editable-html": "^
|
|
13
|
+
"@pie-lib/config-ui": "^11.9.7",
|
|
14
|
+
"@pie-lib/editable-html": "^10.0.2",
|
|
15
15
|
"classnames": "^2.2.6",
|
|
16
16
|
"debug": "^3.1.0",
|
|
17
17
|
"konva": "^3.2.4",
|
|
@@ -8,6 +8,15 @@ exports[`Root render renders 1`] = `
|
|
|
8
8
|
<Panel
|
|
9
9
|
configuration={
|
|
10
10
|
Object {
|
|
11
|
+
"language": Object {
|
|
12
|
+
"enabled": false,
|
|
13
|
+
"label": "Specify Language",
|
|
14
|
+
"settings": false,
|
|
15
|
+
},
|
|
16
|
+
"languageChoices": Object {
|
|
17
|
+
"label": "Language Choices",
|
|
18
|
+
"options": Array [],
|
|
19
|
+
},
|
|
11
20
|
"mathMlOptions": Object {
|
|
12
21
|
"mmlEditing": false,
|
|
13
22
|
"mmlOutput": false,
|
|
@@ -69,6 +78,8 @@ exports[`Root render renders 1`] = `
|
|
|
69
78
|
"teacherInstructionsEnabled": undefined,
|
|
70
79
|
},
|
|
71
80
|
"Settings": Object {
|
|
81
|
+
"language": false,
|
|
82
|
+
"language.enabled": false,
|
|
72
83
|
"multipleCorrect": undefined,
|
|
73
84
|
"partialScoring": false,
|
|
74
85
|
"promptEnabled": undefined,
|
package/configure/src/index.js
CHANGED
|
@@ -37,6 +37,34 @@ export default class HotspotConfigure extends HTMLElement {
|
|
|
37
37
|
|
|
38
38
|
set configuration(c) {
|
|
39
39
|
this._configuration = c;
|
|
40
|
+
|
|
41
|
+
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
42
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
43
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
44
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
45
|
+
if (c.language.enabled) {
|
|
46
|
+
if (c.languageChoices?.options?.length) {
|
|
47
|
+
this._model.language = c.languageChoices.options[0].value;
|
|
48
|
+
}
|
|
49
|
+
} else if (c.language.settings && this._model.language) {
|
|
50
|
+
this._configuration.language.enabled = true;
|
|
51
|
+
|
|
52
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
53
|
+
this._configuration.languageChoices.options = [];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// check if the language is already included in the languageChoices.options array
|
|
57
|
+
// and if not, then add it.
|
|
58
|
+
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
59
|
+
this._configuration.languageChoices.options.push({
|
|
60
|
+
value: this._model.language,
|
|
61
|
+
label: this._model.language,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
delete this._model.language;
|
|
66
|
+
}
|
|
67
|
+
|
|
40
68
|
this._render();
|
|
41
69
|
}
|
|
42
70
|
|
package/configure/src/root.jsx
CHANGED
|
@@ -10,7 +10,7 @@ import HotspotPalette from './hotspot-palette';
|
|
|
10
10
|
import HotspotContainer from './hotspot-container';
|
|
11
11
|
import { updateImageDimensions, generateValidationMessage, getUpdatedShapes, getAllShapes, groupShapes } from './utils';
|
|
12
12
|
|
|
13
|
-
const { Panel, toggle } = settings;
|
|
13
|
+
const { Panel, toggle, dropdown } = settings;
|
|
14
14
|
|
|
15
15
|
export class Root extends React.Component {
|
|
16
16
|
handleColorChange = (fieldType, color) => {
|
|
@@ -77,6 +77,8 @@ export class Root extends React.Component {
|
|
|
77
77
|
teacherInstructions = {},
|
|
78
78
|
withRubric = {},
|
|
79
79
|
mathMlOptions = {},
|
|
80
|
+
language = {},
|
|
81
|
+
languageChoices = {},
|
|
80
82
|
} = configuration || {};
|
|
81
83
|
const {
|
|
82
84
|
errors,
|
|
@@ -100,6 +102,8 @@ export class Root extends React.Component {
|
|
|
100
102
|
multipleCorrect: multipleCorrect.settings && toggle(multipleCorrect.label),
|
|
101
103
|
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
102
104
|
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
105
|
+
'language.enabled': language.settings && toggle(language.label, true),
|
|
106
|
+
language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),
|
|
103
107
|
};
|
|
104
108
|
const panelProperties = {
|
|
105
109
|
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.7.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.6.3...@pie-element/hotspot-controller@3.7.0) (2023-09-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **hotspot:** translations PD-2802 PD-2795 ([15b03fd](https://github.com/pie-framework/pie-elements/commit/15b03fd1d6659364c4d765406c807d30dc5375d1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [3.6.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.6.2...@pie-element/hotspot-controller@3.6.3) (2023-07-06)
|
|
7
18
|
|
|
8
19
|
|
package/controller/lib/index.js
CHANGED
|
@@ -51,7 +51,8 @@ function model(question, session, env) {
|
|
|
51
51
|
outlineColor = normalizedQuestion.outlineColor,
|
|
52
52
|
partialScoring = normalizedQuestion.partialScoring,
|
|
53
53
|
prompt = normalizedQuestion.prompt,
|
|
54
|
-
shapes = normalizedQuestion.shapes
|
|
54
|
+
shapes = normalizedQuestion.shapes,
|
|
55
|
+
language = normalizedQuestion.language;
|
|
55
56
|
|
|
56
57
|
var _ref = shapes || {},
|
|
57
58
|
rectangles = _ref.rectangles,
|
|
@@ -67,6 +68,7 @@ function model(question, session, env) {
|
|
|
67
68
|
hotspotColor: hotspotColor,
|
|
68
69
|
multipleCorrect: multipleCorrect,
|
|
69
70
|
partialScoring: partialScoring,
|
|
71
|
+
language: language,
|
|
70
72
|
shapes: _objectSpread(_objectSpread({}, shapes), {}, {
|
|
71
73
|
// eslint-disable-next-line no-unused-vars
|
|
72
74
|
rectangles: (rectangles || []).map(function (_ref2) {
|
|
@@ -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","rectangles","polygons","Promise","resolve","out","disabled","mode","map","index","rectProps","polyProps","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","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;;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,MAAQM,QAAR,GACED,kBADF,CAAQC,QAAR;AAAA,MAAkBC,UAAlB,GACEF,kBADF,CAAkBE,UAAlB;AAAA,MAA8BC,YAA9B,GACEH,kBADF,CAA8BG,YAA9B;AAAA,MAA4CC,eAA5C,GACEJ,kBADF,CAA4CI,eAA5C;AAAA,MAA6DC,YAA7D,GACEL,kBADF,CAA6DK,YAA7D;AAAA,MAA2EC,cAA3E,GACEN,kBADF,CAA2EM,cAA3E;AAAA,MAA2FC,MAA3F,GACEP,kBADF,CAA2FO,MAA3F;AAAA,MAAmGC,MAAnG,GACER,kBADF,CAAmGQ,MAAnG;;AAEA,aAAiCA,MAAM,IAAI,EAA3C;AAAA,MAAQC,UAAR,QAAQA,UAAR;AAAA,MAAoBC,QAApB,QAAoBA,QAApB;;AAEA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9B,QAAMC,GAAG,GAAG;AACVC,MAAAA,QAAQ,EAAEf,GAAG,CAACgB,IAAJ,KAAa,QADb;AAEVA,MAAAA,IAAI,EAAEhB,GAAG,CAACgB,IAFA;AAGVb,MAAA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AAI,EAAd,EAAkBnB,MAArC;;AAEA,MAAIyB,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/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 { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes } =\n normalizedQuestion;\n const { rectangles, polygons } = 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 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 },\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)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [] } = {} } = 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];\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 = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect],\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","Promise","resolve","out","disabled","mode","map","index","rectProps","polyProps","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","validate","minShapes","maxShapes","maxSelections","errors","allShapes","Object","values","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;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/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 { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes, language } =\n normalizedQuestion;\n const { rectangles, polygons } = 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 },\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)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [] } = {} } = 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];\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 = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect],\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"}
|
package/controller/package.json
CHANGED
package/controller/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export const normalize = (question) => ({
|
|
|
15
15
|
|
|
16
16
|
export function model(question, session, env) {
|
|
17
17
|
const normalizedQuestion = normalize(question);
|
|
18
|
-
const { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes } =
|
|
18
|
+
const { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes, language } =
|
|
19
19
|
normalizedQuestion;
|
|
20
20
|
const { rectangles, polygons } = shapes || {};
|
|
21
21
|
|
|
@@ -29,6 +29,7 @@ export function model(question, session, env) {
|
|
|
29
29
|
hotspotColor,
|
|
30
30
|
multipleCorrect,
|
|
31
31
|
partialScoring,
|
|
32
|
+
language,
|
|
32
33
|
shapes: {
|
|
33
34
|
...shapes,
|
|
34
35
|
// eslint-disable-next-line no-unused-vars
|
package/docs/config-schema.json
CHANGED
|
@@ -177,6 +177,66 @@
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
|
+
"language": {
|
|
181
|
+
"title": "ConfigurePropWithEnabled",
|
|
182
|
+
"type": "object",
|
|
183
|
+
"properties": {
|
|
184
|
+
"settings": {
|
|
185
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
186
|
+
"type": "boolean",
|
|
187
|
+
"title": "settings"
|
|
188
|
+
},
|
|
189
|
+
"label": {
|
|
190
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
191
|
+
"type": "string",
|
|
192
|
+
"title": "label"
|
|
193
|
+
},
|
|
194
|
+
"enabled": {
|
|
195
|
+
"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)",
|
|
196
|
+
"type": "boolean",
|
|
197
|
+
"title": "enabled"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"languageChoices": {
|
|
202
|
+
"description": "Language choices configuration\nOnly available if language is enabled",
|
|
203
|
+
"type": "object",
|
|
204
|
+
"properties": {
|
|
205
|
+
"label": {
|
|
206
|
+
"type": "string",
|
|
207
|
+
"title": "label"
|
|
208
|
+
},
|
|
209
|
+
"options": {
|
|
210
|
+
"type": "array",
|
|
211
|
+
"items": {
|
|
212
|
+
"title": "ConfigureLanguageOptionsProp",
|
|
213
|
+
"type": "object",
|
|
214
|
+
"properties": {
|
|
215
|
+
"value": {
|
|
216
|
+
"description": "Value of the language option",
|
|
217
|
+
"type": "string",
|
|
218
|
+
"title": "value"
|
|
219
|
+
},
|
|
220
|
+
"label": {
|
|
221
|
+
"description": "Label of the language option",
|
|
222
|
+
"type": "string",
|
|
223
|
+
"title": "label"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"required": [
|
|
227
|
+
"label",
|
|
228
|
+
"value"
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
"title": "options"
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"required": [
|
|
235
|
+
"label",
|
|
236
|
+
"options"
|
|
237
|
+
],
|
|
238
|
+
"title": "languageChoices"
|
|
239
|
+
},
|
|
180
240
|
"showPrompt": {
|
|
181
241
|
"description": "Determines whether prompt field will be displayed or not",
|
|
182
242
|
"default": true,
|
|
@@ -293,6 +353,47 @@
|
|
|
293
353
|
"title": "mmlEditing"
|
|
294
354
|
}
|
|
295
355
|
}
|
|
356
|
+
},
|
|
357
|
+
"ConfigurePropWithEnabled": {
|
|
358
|
+
"title": "ConfigurePropWithEnabled",
|
|
359
|
+
"type": "object",
|
|
360
|
+
"properties": {
|
|
361
|
+
"settings": {
|
|
362
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
363
|
+
"type": "boolean",
|
|
364
|
+
"title": "settings"
|
|
365
|
+
},
|
|
366
|
+
"label": {
|
|
367
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
368
|
+
"type": "string",
|
|
369
|
+
"title": "label"
|
|
370
|
+
},
|
|
371
|
+
"enabled": {
|
|
372
|
+
"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)",
|
|
373
|
+
"type": "boolean",
|
|
374
|
+
"title": "enabled"
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"ConfigureLanguageOptionsProp": {
|
|
379
|
+
"title": "ConfigureLanguageOptionsProp",
|
|
380
|
+
"type": "object",
|
|
381
|
+
"properties": {
|
|
382
|
+
"value": {
|
|
383
|
+
"description": "Value of the language option",
|
|
384
|
+
"type": "string",
|
|
385
|
+
"title": "value"
|
|
386
|
+
},
|
|
387
|
+
"label": {
|
|
388
|
+
"description": "Label of the language option",
|
|
389
|
+
"type": "string",
|
|
390
|
+
"title": "label"
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
"required": [
|
|
394
|
+
"label",
|
|
395
|
+
"value"
|
|
396
|
+
]
|
|
296
397
|
}
|
|
297
398
|
},
|
|
298
399
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
@@ -134,6 +134,46 @@ Indicates if model should have mathML output instead of latex
|
|
|
134
134
|
|
|
135
135
|
Indicates if mathML that's already in model should be editable
|
|
136
136
|
|
|
137
|
+
# `language` (object)
|
|
138
|
+
|
|
139
|
+
Properties of the `language` object:
|
|
140
|
+
|
|
141
|
+
## `settings` (boolean)
|
|
142
|
+
|
|
143
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
144
|
+
|
|
145
|
+
## `label` (string)
|
|
146
|
+
|
|
147
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
148
|
+
|
|
149
|
+
## `enabled` (boolean)
|
|
150
|
+
|
|
151
|
+
Indicates the value of the item if it affects config-ui
|
|
152
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
153
|
+
|
|
154
|
+
# `languageChoices` (object)
|
|
155
|
+
|
|
156
|
+
Language choices configuration
|
|
157
|
+
Only available if language is enabled
|
|
158
|
+
|
|
159
|
+
Properties of the `languageChoices` object:
|
|
160
|
+
|
|
161
|
+
## `label` (string, required)
|
|
162
|
+
|
|
163
|
+
## `options` (array, required)
|
|
164
|
+
|
|
165
|
+
The object is an array with all elements of the type `object`.
|
|
166
|
+
|
|
167
|
+
The array object has the following properties:
|
|
168
|
+
|
|
169
|
+
### `value` (string, required)
|
|
170
|
+
|
|
171
|
+
Value of the language option
|
|
172
|
+
|
|
173
|
+
### `label` (string, required)
|
|
174
|
+
|
|
175
|
+
Label of the language option
|
|
176
|
+
|
|
137
177
|
# `showPrompt` (boolean)
|
|
138
178
|
|
|
139
179
|
Determines whether prompt field will be displayed or not
|
|
@@ -230,4 +270,33 @@ Indicates if model should have mathML output instead of latex
|
|
|
230
270
|
|
|
231
271
|
### `mmlEditing` (number)
|
|
232
272
|
|
|
233
|
-
Indicates if mathML that's already in model should be editable
|
|
273
|
+
Indicates if mathML that's already in model should be editable
|
|
274
|
+
|
|
275
|
+
## `ConfigurePropWithEnabled` (object)
|
|
276
|
+
|
|
277
|
+
Properties of the `ConfigurePropWithEnabled` object:
|
|
278
|
+
|
|
279
|
+
### `settings` (boolean)
|
|
280
|
+
|
|
281
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
282
|
+
|
|
283
|
+
### `label` (string)
|
|
284
|
+
|
|
285
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
286
|
+
|
|
287
|
+
### `enabled` (boolean)
|
|
288
|
+
|
|
289
|
+
Indicates the value of the item if it affects config-ui
|
|
290
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
291
|
+
|
|
292
|
+
## `ConfigureLanguageOptionsProp` (object)
|
|
293
|
+
|
|
294
|
+
Properties of the `ConfigureLanguageOptionsProp` object:
|
|
295
|
+
|
|
296
|
+
### `value` (string, required)
|
|
297
|
+
|
|
298
|
+
Value of the language option
|
|
299
|
+
|
|
300
|
+
### `label` (string, required)
|
|
301
|
+
|
|
302
|
+
Label of the language option
|
package/docs/pie-schema.json
CHANGED
|
@@ -230,6 +230,11 @@
|
|
|
230
230
|
"type": "boolean",
|
|
231
231
|
"title": "rubricEnabled"
|
|
232
232
|
},
|
|
233
|
+
"language": {
|
|
234
|
+
"description": "Indicates the language of the component\nSupported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX",
|
|
235
|
+
"type": "string",
|
|
236
|
+
"title": "language"
|
|
237
|
+
},
|
|
233
238
|
"id": {
|
|
234
239
|
"description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
|
|
235
240
|
"type": "string",
|
|
@@ -309,6 +314,47 @@
|
|
|
309
314
|
}
|
|
310
315
|
}
|
|
311
316
|
},
|
|
317
|
+
"ConfigurePropWithEnabled": {
|
|
318
|
+
"title": "ConfigurePropWithEnabled",
|
|
319
|
+
"type": "object",
|
|
320
|
+
"properties": {
|
|
321
|
+
"settings": {
|
|
322
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
323
|
+
"type": "boolean",
|
|
324
|
+
"title": "settings"
|
|
325
|
+
},
|
|
326
|
+
"label": {
|
|
327
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
328
|
+
"type": "string",
|
|
329
|
+
"title": "label"
|
|
330
|
+
},
|
|
331
|
+
"enabled": {
|
|
332
|
+
"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)",
|
|
333
|
+
"type": "boolean",
|
|
334
|
+
"title": "enabled"
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"ConfigureLanguageOptionsProp": {
|
|
339
|
+
"title": "ConfigureLanguageOptionsProp",
|
|
340
|
+
"type": "object",
|
|
341
|
+
"properties": {
|
|
342
|
+
"value": {
|
|
343
|
+
"description": "Value of the language option",
|
|
344
|
+
"type": "string",
|
|
345
|
+
"title": "value"
|
|
346
|
+
},
|
|
347
|
+
"label": {
|
|
348
|
+
"description": "Label of the language option",
|
|
349
|
+
"type": "string",
|
|
350
|
+
"title": "label"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"required": [
|
|
354
|
+
"label",
|
|
355
|
+
"value"
|
|
356
|
+
]
|
|
357
|
+
},
|
|
312
358
|
"Shape": {
|
|
313
359
|
"title": "Shape",
|
|
314
360
|
"type": "object",
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -165,6 +165,11 @@ Default: `": 'bottom'"`
|
|
|
165
165
|
|
|
166
166
|
Indicates if Rubric is enabled
|
|
167
167
|
|
|
168
|
+
# `language` (string)
|
|
169
|
+
|
|
170
|
+
Indicates the language of the component
|
|
171
|
+
Supported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX
|
|
172
|
+
|
|
168
173
|
# `id` (string, required)
|
|
169
174
|
|
|
170
175
|
Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
|
|
@@ -219,6 +224,35 @@ Indicates if model should have mathML output instead of latex
|
|
|
219
224
|
|
|
220
225
|
Indicates if mathML that's already in model should be editable
|
|
221
226
|
|
|
227
|
+
## `ConfigurePropWithEnabled` (object)
|
|
228
|
+
|
|
229
|
+
Properties of the `ConfigurePropWithEnabled` object:
|
|
230
|
+
|
|
231
|
+
### `settings` (boolean)
|
|
232
|
+
|
|
233
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
234
|
+
|
|
235
|
+
### `label` (string)
|
|
236
|
+
|
|
237
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
238
|
+
|
|
239
|
+
### `enabled` (boolean)
|
|
240
|
+
|
|
241
|
+
Indicates the value of the item if it affects config-ui
|
|
242
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
243
|
+
|
|
244
|
+
## `ConfigureLanguageOptionsProp` (object)
|
|
245
|
+
|
|
246
|
+
Properties of the `ConfigureLanguageOptionsProp` object:
|
|
247
|
+
|
|
248
|
+
### `value` (string, required)
|
|
249
|
+
|
|
250
|
+
Value of the language option
|
|
251
|
+
|
|
252
|
+
### `label` (string, required)
|
|
253
|
+
|
|
254
|
+
Label of the language option
|
|
255
|
+
|
|
222
256
|
## `Shape` (object)
|
|
223
257
|
|
|
224
258
|
Properties of the `Shape` object:
|
package/lib/hotspot/index.js
CHANGED
|
@@ -125,6 +125,7 @@ var HotspotComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
125
125
|
teacherInstructions = _this$props$model.teacherInstructions,
|
|
126
126
|
strokeWidth = _this$props$model.strokeWidth,
|
|
127
127
|
responseCorrect = _this$props$model.responseCorrect,
|
|
128
|
+
language = _this$props$model.language,
|
|
128
129
|
onSelectChoice = _this$props.onSelectChoice,
|
|
129
130
|
classes = _this$props.classes;
|
|
130
131
|
var showCorrect = this.state.showCorrect;
|
|
@@ -147,7 +148,8 @@ var HotspotComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
147
148
|
}), showCorrectAnswerToggle && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
|
|
148
149
|
show: showCorrectAnswerToggle,
|
|
149
150
|
toggled: showCorrect,
|
|
150
|
-
onToggle: this.onToggle.bind(this)
|
|
151
|
+
onToggle: this.onToggle.bind(this),
|
|
152
|
+
language: language
|
|
151
153
|
}), imageUrl ? /*#__PURE__*/_react["default"].createElement(_container["default"], {
|
|
152
154
|
isEvaluateMode: isEvaluateMode,
|
|
153
155
|
session: session,
|
package/lib/hotspot/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","main","hidden","visible","collapsible","onToggle","bind","React","Component","propTypes","PropTypes","object","isRequired","func","defaultProps","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEMA,gB;;;;;AACJ,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iGA2CR,YAAM;AACf,UAAQC,WAAR,GAAwB,MAAKC,KAA7B,CAAQD,WAAR;;AACA,YAAKE,QAAL,CAAc;AAAEF,QAAAA,WAAW,EAAE,CAACA;AAAhB,OAAd;AACD,KA9CkB;AAEjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,WAAW,EAAE,KADF;AAEXG,MAAAA,QAAQ,EAAE,IAFC;AAGXC,MAAAA,KAAK,E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E,IAAd;AAAoBC,UAAAA,eAAe,EAAE,CAAC,OAAD;AAArC,SAA9B;AACD;AACF;;;WAED,gCAAuB;AAAA;;AACrB,6BAAKpB,QAAL,kEAAeqB,UAAf;AACD;;;WAOD,kBAAS;AACP,
|
|
1
|
+
{"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","language","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","main","hidden","visible","collapsible","onToggle","bind","React","Component","propTypes","PropTypes","object","isRequired","func","defaultProps","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEMA,gB;;;;;AACJ,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iGA2CR,YAAM;AACf,UAAQC,WAAR,GAAwB,MAAKC,KAA7B,CAAQD,WAAR;;AACA,YAAKE,QAAL,CAAc;AAAEF,QAAAA,WAAW,EAAE,CAACA;AAAhB,OAAd;AACD,KA9CkB;AAEjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,WAAW,EAAE,KADF;AAEXG,MAAAA,QAAQ,EAAE,IAFC;AAGXC,MAAAA,KAAK,EAAE;AAHI,KAAb;AAFiB;AAOlB;;;;WAED,6BAAoB;AAAA;;AAClB,WAAKD,QAAL,GAAgB,IAAIE,gBAAJ,CAAqB,UAACC,SAAD,EAAe;AAClDA,QAAAA,SAAS,CAACC,OAAV,CAAkB,YAAM;AAAA;;AACtB,cAAMC,MAAM,4BAAGC,QAAQ,CAACC,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AAJC,CAA7B;AAOA1D,gBAAgB,CAAC4D,YAAjB,GAAgC;AAC9BhB,EAAAA,OAAO,EAAE;AADqB,CAAhC;;AAIA,IAAMiB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBf,IAAAA,IAAI,EAAE;AACJgB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFb,KADmB;AAKzBhB,IAAAA,WAAW,EAAE;AACXiB,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADxB,KALY;AAQzBtC,IAAAA,MAAM,EAAE;AACNuC,MAAAA,QAAQ,EAAE;AADJ;AARiB,GAAZ;AAAA,CAAf;;eAae,wBAAWT,MAAX,EAAmB7D,gBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { color, Collapsible, hasText, PreviewPrompt } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Container from './container';\n\nclass HotspotComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showCorrect: false,\n observer: null,\n scale: 1,\n };\n }\n\n componentDidMount() {\n this.observer = new MutationObserver((mutations) => {\n mutations.forEach(() => {\n const target = document.getElementById('question-container')?.style?.cssText;\n const zoom = target?.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));\n const zoomParsed = zoom?.replace(/\\s/g, '');\n\n if (zoomParsed) {\n const newScale = parseFloat(zoomParsed) / 100;\n\n if (newScale !== this.state.scale) {\n this.setState({\n scale: parseFloat(zoomParsed) / 100,\n });\n }\n } else if (!zoomParsed && this.state.scale !== 1) {\n this.setState({\n scale: 1,\n });\n }\n });\n });\n\n const target = document.getElementById('question-container');\n\n if (target) {\n this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });\n }\n }\n\n componentWillUnmount() {\n this.observer?.disconnect();\n }\n\n onToggle = () => {\n const { showCorrect } = this.state;\n this.setState({ showCorrect: !showCorrect });\n };\n\n render() {\n const {\n session,\n model: {\n disabled,\n imageUrl,\n prompt,\n mode,\n multipleCorrect,\n shapes,\n outlineColor,\n hotspotColor,\n dimensions,\n rationale,\n teacherInstructions,\n strokeWidth,\n responseCorrect,\n language,\n },\n onSelectChoice,\n classes,\n } = this.props;\n const { showCorrect } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n\n return (\n <div className={classes.main}>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt className=\"prompt\" prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt className=\"prompt\" prompt={prompt} />}\n\n {showCorrectAnswerToggle && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n {imageUrl ? (\n <Container\n isEvaluateMode={isEvaluateMode}\n session={session}\n dimensions={dimensions}\n imageUrl={imageUrl}\n hotspotColor={hotspotColor}\n multipleCorrect={multipleCorrect}\n outlineColor={outlineColor}\n onSelectChoice={onSelectChoice}\n shapes={shapes}\n disabled={disabled}\n strokeWidth={strokeWidth}\n scale={this.state.scale}\n showCorrect={showCorrect}\n />\n ) : null}\n\n {rationale && hasText(rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt className=\"prompt\" prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nHotspotComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n session: PropTypes.object.isRequired,\n};\n\nHotspotComponent.defaultProps = {\n classes: {},\n};\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n fontSize: 'inherit',\n },\n});\n\nexport default withStyles(styles)(HotspotComponent);\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@pie-lib/math-rendering": "^2.5.17",
|
|
14
14
|
"@pie-lib/render-ui": "^4.15.1",
|
|
15
15
|
"@pie-lib/test-utils": "^0.2.33",
|
|
16
|
+
"@pie-lib/translator": "^2.2.0",
|
|
16
17
|
"konva": "^3.2.5",
|
|
17
18
|
"prop-types": "^15.6.1",
|
|
18
19
|
"react": "^16.8.1",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
},
|
|
22
23
|
"author": "pie framework developers",
|
|
23
24
|
"license": "ISC",
|
|
24
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "601ddbccecfff533d0670698fe99ce91759165fe",
|
|
25
26
|
"scripts": {
|
|
26
27
|
"postpublish": "../../scripts/postpublish"
|
|
27
28
|
},
|
package/src/hotspot/index.jsx
CHANGED
|
@@ -72,6 +72,7 @@ class HotspotComponent extends React.Component {
|
|
|
72
72
|
teacherInstructions,
|
|
73
73
|
strokeWidth,
|
|
74
74
|
responseCorrect,
|
|
75
|
+
language,
|
|
75
76
|
},
|
|
76
77
|
onSelectChoice,
|
|
77
78
|
classes,
|
|
@@ -98,6 +99,7 @@ class HotspotComponent extends React.Component {
|
|
|
98
99
|
show={showCorrectAnswerToggle}
|
|
99
100
|
toggled={showCorrect}
|
|
100
101
|
onToggle={this.onToggle.bind(this)}
|
|
102
|
+
language={language}
|
|
101
103
|
/>
|
|
102
104
|
)}
|
|
103
105
|
|