@pie-element/hotspot 4.10.17 → 4.11.2
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 +37 -0
- package/configure/CHANGELOG.md +27 -0
- package/configure/lib/defaults.js +2 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/root.js +54 -5
- package/configure/lib/root.js.map +1 -1
- package/configure/lib/utils.js +13 -1
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +3 -3
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +32 -4
- package/configure/src/defaults.js +2 -1
- package/configure/src/root.jsx +48 -7
- package/configure/src/utils.js +23 -1
- package/controller/CHANGELOG.md +12 -0
- package/controller/lib/index.js +35 -0
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/index.js +26 -0
- package/docs/config-schema.json +133 -0
- package/docs/config-schema.json.md +105 -0
- package/docs/pie-schema.json +16 -0
- package/docs/pie-schema.json.md +12 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,43 @@
|
|
|
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
|
+
## [4.11.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@4.11.1...@pie-element/hotspot@4.11.2) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/hotspot
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [4.11.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@4.11.0...@pie-element/hotspot@4.11.1) (2022-05-09)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/hotspot
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [4.11.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@4.10.17...@pie-element/hotspot@4.11.0) (2022-05-03)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* added getters for the session PD-1668 ([de8a754](https://github.com/pie-framework/pie-elements/commit/de8a754f4580370b127257c435e43db405b4bdc4))
|
|
28
|
+
* **hotspot:** add support for --pie-zoom css property PD-360 ([f2dc70d](https://github.com/pie-framework/pie-elements/commit/f2dc70dc4b27bdab76c68cd938dc1b734b50a80f))
|
|
29
|
+
* **hotspot:** add support for --pie-zoom css property PD-360 (review) ([cf34390](https://github.com/pie-framework/pie-elements/commit/cf34390d29c9291bd82b75c649d5b4d1b6c78fdf))
|
|
30
|
+
* **hotspot:** add support for removing --pie-zoom css property PD-360 ([3e7a293](https://github.com/pie-framework/pie-elements/commit/3e7a29385d84264b167ad5f2e9a75ef38e9c14f3))
|
|
31
|
+
* **hotspot:** use "prompt" class on PreviewPrompt PD-1553 ([9650b64](https://github.com/pie-framework/pie-elements/commit/9650b646414ecb9ee6d9a362f4cc1a129d92d357))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **hotspot:** added configurable validation PD-1702 ([18eb985](https://github.com/pie-framework/pie-elements/commit/18eb98568adf9248dc616a9ae71d9f8394b62fc1))
|
|
37
|
+
* **hotspot:** PD-1703 implement ui/ux for item validation ([a962183](https://github.com/pie-framework/pie-elements/commit/a962183d0941936b69a95b32002135507d769170))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
6
43
|
## [4.10.17](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@4.10.16...@pie-element/hotspot@4.10.17) (2022-04-12)
|
|
7
44
|
|
|
8
45
|
**Note:** Version bump only for package @pie-element/hotspot
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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
|
+
## [4.7.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@4.7.1...@pie-element/hotspot-configure@4.7.2) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/hotspot-configure
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [4.7.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@4.7.0...@pie-element/hotspot-configure@4.7.1) (2022-05-09)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/hotspot-configure
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [4.7.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@4.6.16...@pie-element/hotspot-configure@4.7.0) (2022-05-03)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **hotspot:** PD-1703 implement ui/ux for item validation ([a962183](https://github.com/pie-framework/pie-elements/commit/a962183d0941936b69a95b32002135507d769170))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [4.6.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@4.6.15...@pie-element/hotspot-configure@4.6.16) (2022-04-12)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @pie-element/hotspot-configure
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","promptEnabled","imageUrl","shapes","rectangles","polygons","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","settings","label","rationale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AAE,YADG;AAEVD,MAAAA,QAAQ,EAAC,KAFC;AAGVI,MAAAA,OAAO,EAAC;AAHE,KAjBC;AAsBbC,IAAAA,mBAAmB,EAAE;AACnBL,MAAAA,QAAQ,EAAE,IADS;AAEnBC,MAAAA,KAAK,EAAE;AAFY,KAtBR;AA0BbK,IAAAA,mBAAmB,EAAE;AACnBN,MAAAA,QAAQ,EAAE,KADS;AAEnBI,MAAAA,OAAO,EAAE,IAFU;AAGnBH,MAAAA,KAAK,EAAE;AAHY;
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","promptEnabled","imageUrl","shapes","rectangles","polygons","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","settings","label","rationale","spellCheck","enabled","teacherInstructions","preserveAspectRatio","minShapes"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,MAAM,EAAE,6BADH;AAELC,IAAAA,qBAAqB,EAAE,QAFlB;AAGLC,IAAAA,aAAa,EAAE,IAHV;AAILC,IAAAA,QAAQ,EAAE,EAJL;AAKLC,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAE,EADN;AAENC,MAAAA,QAAQ,EAAE;AAFJ,KALH;AASLC,IAAAA,eAAe,EAAE,IATZ;AAULC,IAAAA,cAAc,EAAE,KAVX;AAWLC,IAAAA,UAAU,EAAE;AACVC,MAAAA,MAAM,EAAE,CADE;AAEVC,MAAAA,KAAK,EAAE;AAFG,KAXP;AAeLC,IAAAA,YAAY,EAAE,2BAfT;AAgBLC,IAAAA,WAAW,EAAE,CACX,2BADW,CAhBR;AAmBLC,IAAAA,YAAY,EAAE,MAnBT;AAoBLC,IAAAA,WAAW,EAAE,CACX,MADW,CApBR;AAuBLC,IAAAA,gBAAgB,EAAE,IAvBb;AAwBLC,IAAAA,0BAA0B,EAAE,IAxBvB;AAyBLC,IAAAA,0BAA0B,EAAE,IAzBvB;AA0BLC,IAAAA,WAAW,EAAE;AA1BR,GADM;AA6BbC,EAAAA,aAAa,EAAE;AACbb,IAAAA,eAAe,EAAE;AACfc,MAAAA,QAAQ,EAAE,IADK;AAEfC,MAAAA,KAAK,EAAE;AAFQ,KADJ;AAKbd,IAAAA,cAAc,EAAE;AACda,MAAAA,QAAQ,EAAE,KADI;AAEdC,MAAAA,KAAK,EAAE;AAFO,KALH;AASbC,IAAAA,SAAS,EAAE;AACTF,MAAAA,QAAQ,EAAE,IADD;AAETC,MAAAA,KAAK,EAAE;AAFE,KATE;AAabtB,IAAAA,MAAM,EAAE;AACNqB,MAAAA,QAAQ,EAAE,IADJ;AAENC,MAAAA,KAAK,EAAE;AAFD,KAbK;AAiBbE,IAAAA,UAAU,EAAE;AACVF,MAAAA,KAAK,EAAE,YADG;AAEVD,MAAAA,QAAQ,EAAC,KAFC;AAGVI,MAAAA,OAAO,EAAC;AAHE,KAjBC;AAsBbC,IAAAA,mBAAmB,EAAE;AACnBL,MAAAA,QAAQ,EAAE,IADS;AAEnBC,MAAAA,KAAK,EAAE;AAFY,KAtBR;AA0BbK,IAAAA,mBAAmB,EAAE;AACnBN,MAAAA,QAAQ,EAAE,KADS;AAEnBI,MAAAA,OAAO,EAAE,IAFU;AAGnBH,MAAAA,KAAK,EAAE;AAHY,KA1BR;AA+BbM,IAAAA,SAAS,EAAE;AA/BE;AA7BF,C","sourcesContent":["export default {\n model: {\n prompt: 'This is the question prompt',\n toolbarEditorPosition: 'bottom',\n promptEnabled: true,\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.65)',\n hotspotList: [\n 'rgba(137, 183, 244, 0.65)'\n ],\n outlineColor: 'blue',\n outlineList: [\n 'blue'\n ],\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 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 }\n};\n"],"file":"defaults.js"}
|
package/configure/lib/root.js
CHANGED
|
@@ -29,14 +29,20 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
29
29
|
|
|
30
30
|
var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
31
31
|
|
|
32
|
+
var _styles = require("@material-ui/core/styles");
|
|
33
|
+
|
|
32
34
|
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
33
35
|
|
|
34
|
-
var
|
|
36
|
+
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
37
|
+
|
|
38
|
+
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
35
39
|
|
|
36
40
|
var _hotspotPalette = _interopRequireDefault(require("./hotspot-palette"));
|
|
37
41
|
|
|
38
42
|
var _hotspotContainer = _interopRequireDefault(require("./hotspot-container"));
|
|
39
43
|
|
|
44
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
45
|
+
|
|
40
46
|
var _utils = require("./utils");
|
|
41
47
|
|
|
42
48
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -134,9 +140,15 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
134
140
|
teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
|
|
135
141
|
promptEnabled = _ref2.promptEnabled,
|
|
136
142
|
rationaleEnabled = _ref2.rationaleEnabled,
|
|
137
|
-
spellCheckEnabled = _ref2.spellCheckEnabled
|
|
143
|
+
spellCheckEnabled = _ref2.spellCheckEnabled,
|
|
144
|
+
errors = _ref2.errors;
|
|
145
|
+
|
|
146
|
+
var _ref3 = errors || {},
|
|
147
|
+
shapesError = _ref3.shapesError,
|
|
148
|
+
selectionsError = _ref3.selectionsError;
|
|
138
149
|
|
|
139
150
|
var toolbarOpts = {};
|
|
151
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
140
152
|
|
|
141
153
|
switch (model.toolbarEditorPosition) {
|
|
142
154
|
case 'top':
|
|
@@ -200,10 +212,30 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
200
212
|
imageSupport: imageSupport,
|
|
201
213
|
toolbarOpts: toolbarOpts,
|
|
202
214
|
spellCheck: spellCheckEnabled
|
|
203
|
-
})), /*#__PURE__*/_react["default"].createElement(
|
|
204
|
-
className: classes.label,
|
|
215
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
216
|
+
className: (0, _classnames["default"])(classes.label, classes.flexContainer)
|
|
217
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
218
|
+
className: classes.subheading,
|
|
205
219
|
variant: "subheading"
|
|
206
|
-
}, "Define Hotspot"), /*#__PURE__*/_react["default"].createElement(
|
|
220
|
+
}, "Define Hotspot"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
221
|
+
classes: {
|
|
222
|
+
tooltip: classes.tooltip
|
|
223
|
+
},
|
|
224
|
+
disableFocusListener: true,
|
|
225
|
+
disableTouchListener: true,
|
|
226
|
+
placement: 'left',
|
|
227
|
+
title: validationMessage
|
|
228
|
+
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
229
|
+
fontSize: 'small',
|
|
230
|
+
color: 'primary',
|
|
231
|
+
style: {
|
|
232
|
+
"float": 'right'
|
|
233
|
+
}
|
|
234
|
+
}))), shapesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
235
|
+
className: classes.errorText
|
|
236
|
+
}, shapesError), selectionsError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
237
|
+
className: classes.errorText
|
|
238
|
+
}, selectionsError), /*#__PURE__*/_react["default"].createElement(_hotspotPalette["default"], {
|
|
207
239
|
hotspotColor: model.hotspotColor,
|
|
208
240
|
hotspotList: model.hotspotList,
|
|
209
241
|
outlineColor: model.outlineColor,
|
|
@@ -282,12 +314,29 @@ var styles = function styles(theme) {
|
|
|
282
314
|
paddingTop: theme.spacing.unit * 2,
|
|
283
315
|
width: '100%'
|
|
284
316
|
},
|
|
317
|
+
subheading: {
|
|
318
|
+
marginRight: '5px'
|
|
319
|
+
},
|
|
285
320
|
regular: {
|
|
286
321
|
marginBottom: theme.spacing.unit * 3
|
|
287
322
|
},
|
|
288
323
|
switchElement: {
|
|
289
324
|
justifyContent: 'space-between',
|
|
290
325
|
margin: 0
|
|
326
|
+
},
|
|
327
|
+
flexContainer: {
|
|
328
|
+
display: 'flex',
|
|
329
|
+
alignItems: 'center'
|
|
330
|
+
},
|
|
331
|
+
tooltip: {
|
|
332
|
+
fontSize: '12px',
|
|
333
|
+
whiteSpace: 'pre',
|
|
334
|
+
maxWidth: '500px'
|
|
335
|
+
},
|
|
336
|
+
errorText: {
|
|
337
|
+
fontSize: '12px',
|
|
338
|
+
color: 'red',
|
|
339
|
+
padding: '5px 0'
|
|
291
340
|
}
|
|
292
341
|
};
|
|
293
342
|
};
|
|
@@ -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","onConfigurationChanged","onImageUpload","onModelChangedByConfig","onPromptChanged","onRationaleChanged","onTeacherInstructionsChanged","multipleCorrect","partialScoring","prompt","teacherInstructions","rationale","spellCheck","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","toolbarOpts","toolbarEditorPosition","position","base","label","Properties","regular","hotspotColor","hotspotList","outlineColor","outlineList","handleColorChange","imageUrl","strokeWidth","width","e","handleOnUpdateImageDimensions","field","height","React","Component","styles","theme","marginTop","spacing","unit","container","display","flex","paddingTop","marginBottom","switchElement","justifyContent","margin","propTypes","PropTypes","object","isRequired","shape","add","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAEA;;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,i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V,CAAeH,UAbxB;AAcfjD,EAAAA,kBAAkB,EAAE+C,sBAAUK,IAAV,CAAeH,UAdpB;AAefrD,EAAAA,sBAAsB,EAAEmD,sBAAUK,IAAV,CAAeH,UAfxB;AAgBfhD,EAAAA,4BAA4B,EAAE8C,sBAAUK,IAAV,CAAeH;AAhB9B,CAAjB;;eAmBe,wBAAWhB,MAAX,EAAmB3D,IAAnB,C","sourcesContent":["import React from 'react';\nimport {\n settings,\n layout,\n InputContainer,\n NumberTextField\n} from '@pie-lib/config-ui';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport Typography from '@material-ui/core/Typography';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport HotspotPalette from './hotspot-palette';\nimport HotspotContainer from './hotspot-container';\nimport { updateImageDimensions, 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 onConfigurationChanged,\n onImageUpload,\n onModelChangedByConfig,\n onPromptChanged,\n onRationaleChanged,\n onUpdateImageDimension,\n onTeacherInstructionsChanged,\n onUpdateShapes\n } = this.props;\n const {\n multipleCorrect = {},\n partialScoring = {},\n prompt = {},\n teacherInstructions = {},\n rationale = {},\n spellCheck = {},\n preserveAspectRatio = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled } = model || {};\n const toolbarOpts = {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n return (\n <div className={classes.base}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onModelChangedByConfig}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings': {\n multipleCorrect:\n multipleCorrect.settings && toggle(multipleCorrect.label),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n promptEnabled:\n prompt.settings && toggle(prompt.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n }\n }}\n />\n }\n >\n <div className={classes.regular}>\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.prompt}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.prompt}>\n <EditableHtml\n markup={model.prompt || ''}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.prompt}\n >\n <EditableHtml\n markup={model.rationale || ''}\n onChange={onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n <Typography className={classes.label} variant=\"subheading\">\n Define Hotspot\n </Typography>\n\n <HotspotPalette\n hotspotColor={model.hotspotColor}\n hotspotList={model.hotspotList}\n outlineColor={model.outlineColor}\n outlineList={model.outlineList}\n onHotspotColorChange={color =>\n this.handleColorChange('hotspot', color)\n }\n onOutlineColorChange={color =>\n this.handleColorChange('outline', color)\n }\n />\n\n <HotspotContainer\n dimensions={model.dimensions}\n imageUrl={model.imageUrl}\n multipleCorrect={model.multipleCorrect}\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 />\n\n {model.imageUrl && (\n <div>\n <Typography className={classes.label} variant=\"subheading\">\n Image Dimensions\n </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 <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 </div>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n base: {\n marginTop: theme.spacing.unit * 3\n },\n container: {\n display: 'flex',\n marginTop: theme.spacing.unit\n },\n dimensions: {\n display: 'flex'\n },\n field: {\n flex: 1,\n width: '90%'\n },\n label: {\n marginTop: theme.spacing.unit * 4\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n regular: {\n marginBottom: theme.spacing.unit * 3\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\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 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","Root","fieldType","color","onColorChanged","props","cType","value","resizeType","model","dimensions","shapes","configuration","preserveAspectRatio","onUpdateImageDimension","onUpdateShapes","nextImageDimensions","updatedDimensions","enabled","shapesArray","updatedShapes","classes","imageSupport","onConfigurationChanged","onImageUpload","onModelChangedByConfig","onPromptChanged","onRationaleChanged","onTeacherInstructionsChanged","multipleCorrect","partialScoring","prompt","teacherInstructions","rationale","spellCheck","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","errors","shapesError","selectionsError","toolbarOpts","validationMessage","toolbarEditorPosition","position","base","label","Properties","regular","flexContainer","subheading","tooltip","errorText","hotspotColor","hotspotList","outlineColor","outlineList","handleColorChange","imageUrl","strokeWidth","width","e","handleOnUpdateImageDimensions","field","height","React","Component","styles","theme","marginTop","spacing","unit","container","display","flex","paddingTop","marginRight","marginBottom","switchElement","justifyContent","margin","alignItems","fontSize","whiteSpace","maxWidth","padding","propTypes","PropTypes","object","isRequired","shape","add","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA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L;AAGPC,MAAAA,QAAQ,EAAE;AAHH,KApCc;AAyCvBhC,IAAAA,SAAS,EAAE;AACT8B,MAAAA,QAAQ,EAAE,MADD;AAEThF,MAAAA,KAAK,EAAE,KAFE;AAGTmF,MAAAA,OAAO,EAAE;AAHA;AAzCY,GAAL;AAAA,CAApB;;AAgDArF,IAAI,CAACsF,SAAL,GAAiB;AACflE,EAAAA,OAAO,EAAEmE,sBAAUC,MAAV,CAAiBC,UADX;AAEf9E,EAAAA,aAAa,EAAE4E,sBAAUC,MAFV;AAGfhF,EAAAA,KAAK,EAAE+E,sBAAUC,MAAV,CAAiBC,UAHT;AAIfpE,EAAAA,YAAY,EAAEkE,sBAAUG,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEJ,sBAAUK,IADa;AAE5B,cAAQL,sBAAUK;AAFU,GAAhB,CAJC;AAQfrE,EAAAA,aAAa,EAAEgE,sBAAUK,IAAV,CAAeH,UARf;AASftF,EAAAA,cAAc,EAAEoF,sBAAUK,IAAV,CAAeH,UAThB;AAUfhE,EAAAA,eAAe,EAAE8D,sBAAUK,IAAV,CAAeH,UAVjB;AAWf5E,EAAAA,sBAAsB,EAAE0E,sBAAUK,IAAV,CAAeH,UAXxB;AAYf3E,EAAAA,cAAc,EAAEyE,sBAAUK,IAAV,CAAeH,UAZhB;AAafjE,EAAAA,sBAAsB,EAAE+D,sBAAUK,IAAV,CAAeH,UAbxB;AAcf/D,EAAAA,kBAAkB,EAAE6D,sBAAUK,IAAV,CAAeH,UAdpB;AAefnE,EAAAA,sBAAsB,EAAEiE,sBAAUK,IAAV,CAAeH,UAfxB;AAgBf9D,EAAAA,4BAA4B,EAAE4D,sBAAUK,IAAV,CAAeH;AAhB9B,CAAjB;;eAmBe,wBAAWtB,MAAX,EAAmBnE,IAAnB,C","sourcesContent":["import React from 'react';\nimport {\n settings,\n layout,\n InputContainer,\n NumberTextField\n} 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 classNames from 'classnames';\nimport {\n updateImageDimensions,\n generateValidationMessage,\n getUpdatedShapes,\n getAllShapes,\n groupShapes\n} 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 onConfigurationChanged,\n onImageUpload,\n onModelChangedByConfig,\n onPromptChanged,\n onRationaleChanged,\n onUpdateImageDimension,\n onTeacherInstructionsChanged,\n onUpdateShapes\n } = this.props;\n const {\n multipleCorrect = {},\n partialScoring = {},\n prompt = {},\n teacherInstructions = {},\n rationale = {},\n spellCheck = {},\n preserveAspectRatio = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled, errors } = model || {};\n const { shapesError, selectionsError } = errors || {};\n const toolbarOpts = {};\n\n const validationMessage = generateValidationMessage(configuration);\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n return (\n <div className={classes.base}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onModelChangedByConfig}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings': {\n multipleCorrect:\n multipleCorrect.settings && toggle(multipleCorrect.label),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n promptEnabled:\n prompt.settings && toggle(prompt.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n }\n }}\n />\n }\n >\n <div className={classes.regular}>\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.prompt}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.prompt}>\n <EditableHtml\n markup={model.prompt || ''}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.prompt}\n >\n <EditableHtml\n markup={model.rationale || ''}\n onChange={onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n <div className={classNames(classes.label, 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 {shapesError && <div className={classes.errorText}>{shapesError}</div>}\n {selectionsError && <div className={classes.errorText}>{selectionsError}</div>}\n\n <HotspotPalette\n hotspotColor={model.hotspotColor}\n hotspotList={model.hotspotList}\n outlineColor={model.outlineColor}\n outlineList={model.outlineList}\n onHotspotColorChange={color =>\n this.handleColorChange('hotspot', color)\n }\n onOutlineColorChange={color =>\n this.handleColorChange('outline', color)\n }\n />\n\n <HotspotContainer\n dimensions={model.dimensions}\n imageUrl={model.imageUrl}\n multipleCorrect={model.multipleCorrect}\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 />\n\n {model.imageUrl && (\n <div>\n <Typography className={classes.label} variant=\"subheading\">\n Image Dimensions\n </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 <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 </div>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n base: {\n marginTop: theme.spacing.unit * 3\n },\n container: {\n display: 'flex',\n marginTop: theme.spacing.unit\n },\n dimensions: {\n display: 'flex'\n },\n field: {\n flex: 1,\n width: '90%'\n },\n label: {\n marginTop: theme.spacing.unit * 4\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n subheading: {\n marginRight: '5px'\n },\n regular: {\n marginBottom: theme.spacing.unit * 3\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center'\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0'\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 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/lib/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.updateImageDimensions = exports.groupShapes = exports.getUpdatedShapes = exports.getUpdatedRectangle = exports.getUpdatedPlygon = exports.getAllShapes = void 0;
|
|
8
|
+
exports.updateImageDimensions = exports.groupShapes = exports.getUpdatedShapes = exports.getUpdatedRectangle = exports.getUpdatedPlygon = exports.getAllShapes = exports.generateValidationMessage = void 0;
|
|
9
9
|
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
11
|
|
|
@@ -145,4 +145,16 @@ var groupShapes = function groupShapes(shapesArray) {
|
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
exports.groupShapes = groupShapes;
|
|
148
|
+
|
|
149
|
+
var generateValidationMessage = function generateValidationMessage(config) {
|
|
150
|
+
var minShapes = config.minShapes,
|
|
151
|
+
maxShapes = config.maxShapes,
|
|
152
|
+
maxSelections = config.maxSelections;
|
|
153
|
+
var shapesMessage = "\nThere should be at least ".concat(minShapes, " ") + (maxShapes ? "and at most ".concat(maxShapes, " ") : '') + 'shapes defined.';
|
|
154
|
+
var selectionsMessage = "\nThere should be at least 1 " + (maxSelections ? "and at most ".concat(maxSelections, " ") : '') + 'shape' + (maxSelections ? 's' : '') + ' selected.';
|
|
155
|
+
var message = 'Validation requirements:' + shapesMessage + selectionsMessage;
|
|
156
|
+
return message;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
exports.generateValidationMessage = generateValidationMessage;
|
|
148
160
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["updateImageDimensions","initialDim","nextDim","keepAspectRatio","resizeType","imageAspectRatio","width","height","getDelta","referenceInitialValue","referenceNextValue","currentValue","getUpdatedRectangle","shape","x","y","getUpdatedPlygon","points","map","point","getUpdatedShapes","shapes","group","getAllShapes","shapesMap","shapesArray","shapesKeys","Object","keys","length","reduce","acc","currentShapeKey","concat","index","groupShapes","rectangles","polygons","shapeProps"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;AAEA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,UAAD,EAAaC,OAAb,EAAsBC,eAAtB,EAAuCC,UAAvC,EAAsD;AAClF;AACA,MAAID,eAAJ,EAAqB;AACnB,QAAME,gBAAgB,GAAGJ,UAAU,CAACK,KAAX,GAAmBL,UAAU,CAACM,MAAvD;;AAEA,QAAIH,UAAU,KAAK,QAAnB,EAA6B;AAC3B;AACA,aAAO;AACLE,QAAAA,KAAK,EAA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SAAS,CAACQ,eAAD,CAAT,GACIR,SAAS,CAACQ,eAAD,CAAT,CAA2Bd,GAA3B,CAA+B,UAACL,KAAD,EAAQqB,KAAR;AAAA,6CAC5BrB,KAD4B;AAE/BS,QAAAA,KAAK,EAAEU,eAFwB;AAG/BE,QAAAA,KAAK,EAAErB,KAAK,CAACqB,KAAN,IAAeH,GAAG,CAACF,MAAJ,GAAaK;AAHJ;AAAA,KAA/B,CADJ,GAMI,EAPN,CADgB;AAAA,GAAlB,EASAT,WATA,CADG,GAWHA,WAXJ;AAYD,CAjBD,C,CAmBA;AACA;AACA;AACA;AACA;;;;;AACA,IAAMU,WAAW,GAAG,SAAdA,WAAc,CAACV,WAAD,EAAiB;AACnCA,EAAAA,WAAW,GAAGA,WAAW,IAAI,EAA7B;AACA,MAAMD,SAAS,GAAG;AAChBY,IAAAA,UAAU,EAAE,EADI;AAEhBC,IAAAA,QAAQ,EAAE;AAFM,GAAlB;;AAKA,MAAIZ,WAAW,CAACI,MAAhB,EAAwB;AACtB,WAAOJ,WAAW,CAACK,MAAZ,CAAmB,UAACC,GAAD,QAAmC;AAAA,UAA3BT,KAA2B,QAA3BA,KAA2B;AAAA,UAAjBgB,UAAiB;AAC3DP,MAAAA,GAAG,CAACT,KAAD,CAAH,iDAAkBS,GAAG,CAACT,KAAD,CAAH,IAAc,EAAhC,IAAqCgB,UAArC;AACA,aAAOP,GAAP;AACD,KAHM,EAGJP,SAHI,CAAP;AAID;;AAED,SAAO,2BAAUA,SAAV,CAAP;AACD,CAfD","sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\n\nconst updateImageDimensions = (initialDim, nextDim, keepAspectRatio, resizeType) => {\n // if we want to keep image aspect ratio\n if (keepAspectRatio) {\n const imageAspectRatio = initialDim.width / initialDim.height;\n\n if (resizeType === 'height') {\n // if we want to change image height => we update the width accordingly\n return {\n width: nextDim.height * imageAspectRatio,\n height: nextDim.height\n }\n }\n\n // if we want to change image width => we update the height accordingly\n return {\n width: nextDim.width,\n height: nextDim.width / imageAspectRatio\n }\n }\n\n // if we don't want to keep aspect ratio, we just update both values\n return {\n width: nextDim.width,\n height: nextDim.height\n }\n};\n\n// referenceInitialValue = the initial value of the Stage\n// referenceNextValue = the next value of the Stage\n// currentValue = the value that has to be re-sized influenced by the changes that were made on the Stage\nconst getDelta = (referenceInitialValue, referenceNextValue, currentValue) => (referenceNextValue / referenceInitialValue) * currentValue;\n\nconst getUpdatedRectangle = (initialDim, nextDim, shape) => ({\n ...shape,\n width: getDelta(initialDim.width, nextDim.width, shape.width),\n height: getDelta(initialDim.height, nextDim.height, shape.height),\n x: getDelta(initialDim.width, nextDim.width, shape.x),\n y: getDelta(initialDim.height, nextDim.height, shape.y),\n});\n\nconst getUpdatedPlygon = (initialDim, nextDim, shape) => ({\n ...shape,\n points: shape.points.map(point => ({\n x: getDelta(initialDim.width, nextDim.width, point.x),\n y: getDelta(initialDim.height, nextDim.height, point.y),\n }))\n});\n\n// initialDim = the initial dimensions: { width, height } of the Stage\n// nextDim = the next dimensions: { width, height } of the Stage\n// shapes = array of shapes that have to be re-sized and re-positioned\nconst getUpdatedShapes = (initialDim, nextDim, shapes) => {\n return shapes.map(shape => {\n if (shape.group === 'rectangles') {\n return getUpdatedRectangle(initialDim, nextDim, shape);\n }\n\n if (shape.group === 'polygons') {\n return getUpdatedPlygon(initialDim, nextDim, shape);\n }\n });\n};\n\n// converts shapes map to shapes array\n// example:\n// from: { rectangles: [r1], polygons: [p1, p2]}\n// to: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// if a shape has index defined, keep it, otherwise initialize it\n// index is used for the UNDO function\nconst getAllShapes = (shapesMap) => {\n shapesMap = shapesMap || {};\n const shapesArray = [];\n const shapesKeys = Object.keys(shapesMap);\n\n return shapesKeys.length\n ? shapesKeys.reduce((acc, currentShapeKey) =>\n acc.concat(\n shapesMap[currentShapeKey]\n ? shapesMap[currentShapeKey].map((shape, index) => ({\n ...shape,\n group: currentShapeKey,\n index: shape.index || acc.length + index\n }))\n : []),\n shapesArray)\n : shapesArray;\n};\n\n// converts shapes array to shapes map\n// is the reverse of getAllShapes function\n// example:\n// from: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// to: { rectangles: [r1], polygons: [p1, p2]}\nconst groupShapes = (shapesArray) => {\n shapesArray = shapesArray || [];\n const shapesMap = {\n rectangles: [],\n polygons: []\n };\n\n if (shapesArray.length) {\n return shapesArray.reduce((acc, { group, ...shapeProps }) => {\n acc[group] = [...(acc[group] || []), shapeProps];\n return acc;\n }, shapesMap);\n }\n\n return cloneDeep(shapesMap);\n};\n\n
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["updateImageDimensions","initialDim","nextDim","keepAspectRatio","resizeType","imageAspectRatio","width","height","getDelta","referenceInitialValue","referenceNextValue","currentValue","getUpdatedRectangle","shape","x","y","getUpdatedPlygon","points","map","point","getUpdatedShapes","shapes","group","getAllShapes","shapesMap","shapesArray","shapesKeys","Object","keys","length","reduce","acc","currentShapeKey","concat","index","groupShapes","rectangles","polygons","shapeProps","generateValidationMessage","config","minShapes","maxShapes","maxSelections","shapesMessage","selectionsMessage","message"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;AAEA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,UAAD,EAAaC,OAAb,EAAsBC,eAAtB,EAAuCC,UAAvC,EAAsD;AAClF;AACA,MAAID,eAAJ,EAAqB;AACnB,QAAME,gBAAgB,GAAGJ,UAAU,CAACK,KAAX,GAAmBL,UAAU,CAACM,MAAvD;;AAEA,QAAIH,UAAU,KAAK,QAAnB,EAA6B;AAC3B;AACA,aAAO;AACLE,QAAAA,KAAK,EAAEJ,OAAO,CAACK,MAAR,GAAiBF,gBADnB;AAELE,QAAAA,MAAM,EAAEL,OAAO,CAACK;AAFX,OAAP;AAID,KATkB,CAWnB;;;AACA,WAAO;AACLD,MAAAA,KAAK,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AG,GAAH,GAAS,EAFC,IAEM,YAFhC;AAIA,MAAMG,OAAO,GAAG,6BAA6BF,aAA7B,GAA6CC,iBAA7D;AAEA,SAAOC,OAAP;AACD,CAbD","sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\n\nconst updateImageDimensions = (initialDim, nextDim, keepAspectRatio, resizeType) => {\n // if we want to keep image aspect ratio\n if (keepAspectRatio) {\n const imageAspectRatio = initialDim.width / initialDim.height;\n\n if (resizeType === 'height') {\n // if we want to change image height => we update the width accordingly\n return {\n width: nextDim.height * imageAspectRatio,\n height: nextDim.height\n }\n }\n\n // if we want to change image width => we update the height accordingly\n return {\n width: nextDim.width,\n height: nextDim.width / imageAspectRatio\n }\n }\n\n // if we don't want to keep aspect ratio, we just update both values\n return {\n width: nextDim.width,\n height: nextDim.height\n }\n};\n\n// referenceInitialValue = the initial value of the Stage\n// referenceNextValue = the next value of the Stage\n// currentValue = the value that has to be re-sized influenced by the changes that were made on the Stage\nconst getDelta = (referenceInitialValue, referenceNextValue, currentValue) => (referenceNextValue / referenceInitialValue) * currentValue;\n\nconst getUpdatedRectangle = (initialDim, nextDim, shape) => ({\n ...shape,\n width: getDelta(initialDim.width, nextDim.width, shape.width),\n height: getDelta(initialDim.height, nextDim.height, shape.height),\n x: getDelta(initialDim.width, nextDim.width, shape.x),\n y: getDelta(initialDim.height, nextDim.height, shape.y),\n});\n\nconst getUpdatedPlygon = (initialDim, nextDim, shape) => ({\n ...shape,\n points: shape.points.map(point => ({\n x: getDelta(initialDim.width, nextDim.width, point.x),\n y: getDelta(initialDim.height, nextDim.height, point.y),\n }))\n});\n\n// initialDim = the initial dimensions: { width, height } of the Stage\n// nextDim = the next dimensions: { width, height } of the Stage\n// shapes = array of shapes that have to be re-sized and re-positioned\nconst getUpdatedShapes = (initialDim, nextDim, shapes) => {\n return shapes.map(shape => {\n if (shape.group === 'rectangles') {\n return getUpdatedRectangle(initialDim, nextDim, shape);\n }\n\n if (shape.group === 'polygons') {\n return getUpdatedPlygon(initialDim, nextDim, shape);\n }\n });\n};\n\n// converts shapes map to shapes array\n// example:\n// from: { rectangles: [r1], polygons: [p1, p2]}\n// to: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// if a shape has index defined, keep it, otherwise initialize it\n// index is used for the UNDO function\nconst getAllShapes = (shapesMap) => {\n shapesMap = shapesMap || {};\n const shapesArray = [];\n const shapesKeys = Object.keys(shapesMap);\n\n return shapesKeys.length\n ? shapesKeys.reduce((acc, currentShapeKey) =>\n acc.concat(\n shapesMap[currentShapeKey]\n ? shapesMap[currentShapeKey].map((shape, index) => ({\n ...shape,\n group: currentShapeKey,\n index: shape.index || acc.length + index\n }))\n : []),\n shapesArray)\n : shapesArray;\n};\n\n// converts shapes array to shapes map\n// is the reverse of getAllShapes function\n// example:\n// from: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// to: { rectangles: [r1], polygons: [p1, p2]}\nconst groupShapes = (shapesArray) => {\n shapesArray = shapesArray || [];\n const shapesMap = {\n rectangles: [],\n polygons: []\n };\n\n if (shapesArray.length) {\n return shapesArray.reduce((acc, { group, ...shapeProps }) => {\n acc[group] = [...(acc[group] || []), shapeProps];\n return acc;\n }, shapesMap);\n }\n\n return cloneDeep(shapesMap);\n};\n\nconst generateValidationMessage = config => {\n const { minShapes, maxShapes, maxSelections } = config;\n\n const shapesMessage = `\\nThere should be at least ${minShapes} ` +\n (maxShapes ? `and at most ${maxShapes} ` : '') + 'shapes defined.';\n\n const selectionsMessage = `\\nThere should be at least 1 ` +\n (maxSelections ? `and at most ${maxSelections} ` : '') + 'shape' +\n (maxSelections ? 's' : '') + ' selected.';\n\n const message = 'Validation requirements:' + shapesMessage + selectionsMessage;\n\n return message;\n};\n\nexport {\n updateImageDimensions,\n generateValidationMessage,\n getUpdatedShapes,\n getAllShapes,\n groupShapes,\n getUpdatedRectangle,\n getUpdatedPlygon\n};\n"],"file":"utils.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": "4.
|
|
4
|
+
"version": "4.7.2",
|
|
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.2.0",
|
|
13
|
-
"@pie-lib/config-ui": "^10.
|
|
14
|
-
"@pie-lib/editable-html": "^7.
|
|
13
|
+
"@pie-lib/config-ui": "^10.13.0",
|
|
14
|
+
"@pie-lib/editable-html": "^7.22.3",
|
|
15
15
|
"classnames": "^2.2.6",
|
|
16
16
|
"debug": "^3.1.0",
|
|
17
17
|
"konva": "^3.2.4",
|
|
@@ -7,6 +7,7 @@ exports[`Root render renders 1`] = `
|
|
|
7
7
|
<Panel
|
|
8
8
|
configuration={
|
|
9
9
|
Object {
|
|
10
|
+
"minShapes": 2,
|
|
10
11
|
"multipleCorrect": Object {
|
|
11
12
|
"label": "Multiple Correct Responses",
|
|
12
13
|
"settings": true,
|
|
@@ -176,11 +177,38 @@ exports[`Root render renders 1`] = `
|
|
|
176
177
|
}
|
|
177
178
|
>
|
|
178
179
|
<div>
|
|
179
|
-
<
|
|
180
|
-
|
|
180
|
+
<div
|
|
181
|
+
className=""
|
|
181
182
|
>
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
<WithStyles(Typography)
|
|
184
|
+
variant="subheading"
|
|
185
|
+
>
|
|
186
|
+
Define Hotspot
|
|
187
|
+
</WithStyles(Typography)>
|
|
188
|
+
<WithStyles(Tooltip)
|
|
189
|
+
classes={
|
|
190
|
+
Object {
|
|
191
|
+
"tooltip": undefined,
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
disableFocusListener={true}
|
|
195
|
+
disableTouchListener={true}
|
|
196
|
+
placement="left"
|
|
197
|
+
title="Validation requirements:
|
|
198
|
+
There should be at least 2 shapes defined.
|
|
199
|
+
There should be at least 1 shape selected."
|
|
200
|
+
>
|
|
201
|
+
<pure(InfoIcon)
|
|
202
|
+
color="primary"
|
|
203
|
+
fontSize="small"
|
|
204
|
+
style={
|
|
205
|
+
Object {
|
|
206
|
+
"float": "right",
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/>
|
|
210
|
+
</WithStyles(Tooltip)>
|
|
211
|
+
</div>
|
|
184
212
|
<WithStyles(Palette)
|
|
185
213
|
hotspotColor="rgba(137, 183, 244, 0.65)"
|
|
186
214
|
hotspotList={
|
package/configure/src/root.jsx
CHANGED
|
@@ -7,12 +7,20 @@ import {
|
|
|
7
7
|
} from '@pie-lib/config-ui';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import EditableHtml from '@pie-lib/editable-html';
|
|
10
|
-
import Typography from '@material-ui/core/Typography';
|
|
11
10
|
import { withStyles } from '@material-ui/core/styles';
|
|
12
|
-
|
|
11
|
+
import Typography from '@material-ui/core/Typography';
|
|
12
|
+
import Info from '@material-ui/icons/Info';
|
|
13
|
+
import Tooltip from '@material-ui/core/Tooltip';
|
|
13
14
|
import HotspotPalette from './hotspot-palette';
|
|
14
15
|
import HotspotContainer from './hotspot-container';
|
|
15
|
-
import
|
|
16
|
+
import classNames from 'classnames';
|
|
17
|
+
import {
|
|
18
|
+
updateImageDimensions,
|
|
19
|
+
generateValidationMessage,
|
|
20
|
+
getUpdatedShapes,
|
|
21
|
+
getAllShapes,
|
|
22
|
+
groupShapes
|
|
23
|
+
} from './utils';
|
|
16
24
|
|
|
17
25
|
const { Panel, toggle } = settings;
|
|
18
26
|
|
|
@@ -75,9 +83,12 @@ export class Root extends React.Component {
|
|
|
75
83
|
spellCheck = {},
|
|
76
84
|
preserveAspectRatio = {}
|
|
77
85
|
} = configuration || {};
|
|
78
|
-
const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled } = model || {};
|
|
86
|
+
const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled, errors } = model || {};
|
|
87
|
+
const { shapesError, selectionsError } = errors || {};
|
|
79
88
|
const toolbarOpts = {};
|
|
80
89
|
|
|
90
|
+
const validationMessage = generateValidationMessage(configuration);
|
|
91
|
+
|
|
81
92
|
switch (model.toolbarEditorPosition) {
|
|
82
93
|
case 'top':
|
|
83
94
|
toolbarOpts.position = 'top';
|
|
@@ -157,9 +168,22 @@ export class Root extends React.Component {
|
|
|
157
168
|
</InputContainer>
|
|
158
169
|
)}
|
|
159
170
|
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
<div className={classNames(classes.label, classes.flexContainer)}>
|
|
172
|
+
<Typography className={classes.subheading} variant="subheading">
|
|
173
|
+
Define Hotspot
|
|
174
|
+
</Typography>
|
|
175
|
+
<Tooltip
|
|
176
|
+
classes={{ tooltip: classes.tooltip }}
|
|
177
|
+
disableFocusListener
|
|
178
|
+
disableTouchListener
|
|
179
|
+
placement={'left'}
|
|
180
|
+
title={validationMessage}
|
|
181
|
+
>
|
|
182
|
+
<Info fontSize={'small'} color={'primary'} style={{ float: 'right' }}/>
|
|
183
|
+
</Tooltip>
|
|
184
|
+
</div>
|
|
185
|
+
{shapesError && <div className={classes.errorText}>{shapesError}</div>}
|
|
186
|
+
{selectionsError && <div className={classes.errorText}>{selectionsError}</div>}
|
|
163
187
|
|
|
164
188
|
<HotspotPalette
|
|
165
189
|
hotspotColor={model.hotspotColor}
|
|
@@ -245,12 +269,29 @@ const styles = theme => ({
|
|
|
245
269
|
paddingTop: theme.spacing.unit * 2,
|
|
246
270
|
width: '100%'
|
|
247
271
|
},
|
|
272
|
+
subheading: {
|
|
273
|
+
marginRight: '5px'
|
|
274
|
+
},
|
|
248
275
|
regular: {
|
|
249
276
|
marginBottom: theme.spacing.unit * 3
|
|
250
277
|
},
|
|
251
278
|
switchElement: {
|
|
252
279
|
justifyContent: 'space-between',
|
|
253
280
|
margin: 0
|
|
281
|
+
},
|
|
282
|
+
flexContainer: {
|
|
283
|
+
display: 'flex',
|
|
284
|
+
alignItems: 'center'
|
|
285
|
+
},
|
|
286
|
+
tooltip: {
|
|
287
|
+
fontSize: '12px',
|
|
288
|
+
whiteSpace: 'pre',
|
|
289
|
+
maxWidth: '500px',
|
|
290
|
+
},
|
|
291
|
+
errorText: {
|
|
292
|
+
fontSize: '12px',
|
|
293
|
+
color: 'red',
|
|
294
|
+
padding: '5px 0'
|
|
254
295
|
}
|
|
255
296
|
});
|
|
256
297
|
|
package/configure/src/utils.js
CHANGED
|
@@ -110,5 +110,27 @@ const groupShapes = (shapesArray) => {
|
|
|
110
110
|
return cloneDeep(shapesMap);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
const generateValidationMessage = config => {
|
|
114
|
+
const { minShapes, maxShapes, maxSelections } = config;
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
const shapesMessage = `\nThere should be at least ${minShapes} ` +
|
|
117
|
+
(maxShapes ? `and at most ${maxShapes} ` : '') + 'shapes defined.';
|
|
118
|
+
|
|
119
|
+
const selectionsMessage = `\nThere should be at least 1 ` +
|
|
120
|
+
(maxSelections ? `and at most ${maxSelections} ` : '') + 'shape' +
|
|
121
|
+
(maxSelections ? 's' : '') + ' selected.';
|
|
122
|
+
|
|
123
|
+
const message = 'Validation requirements:' + shapesMessage + selectionsMessage;
|
|
124
|
+
|
|
125
|
+
return message;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
updateImageDimensions,
|
|
130
|
+
generateValidationMessage,
|
|
131
|
+
getUpdatedShapes,
|
|
132
|
+
getAllShapes,
|
|
133
|
+
groupShapes,
|
|
134
|
+
getUpdatedRectangle,
|
|
135
|
+
getUpdatedPlygon
|
|
136
|
+
};
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.5.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.4.8...@pie-element/hotspot-controller@3.5.0) (2022-05-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **hotspot:** added configurable validation PD-1702 ([18eb985](https://github.com/pie-framework/pie-elements/commit/18eb98568adf9248dc616a9ae71d9f8394b62fc1))
|
|
12
|
+
* **hotspot:** PD-1703 implement ui/ux for item validation ([a962183](https://github.com/pie-framework/pie-elements/commit/a962183d0941936b69a95b32002135507d769170))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [3.4.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.4.3...@pie-element/hotspot-controller@3.4.5) (2021-11-11)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @pie-element/hotspot-controller
|
package/controller/lib/index.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
|
|
|
9
9
|
exports.model = model;
|
|
10
10
|
exports.normalize = void 0;
|
|
11
11
|
exports.outcome = outcome;
|
|
12
|
+
exports.validate = void 0;
|
|
12
13
|
|
|
13
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
14
15
|
|
|
@@ -225,4 +226,38 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
225
226
|
};
|
|
226
227
|
|
|
227
228
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
229
|
+
|
|
230
|
+
var validate = function validate() {
|
|
231
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
232
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
233
|
+
var shapes = model.shapes;
|
|
234
|
+
var _config$minShapes = config.minShapes,
|
|
235
|
+
minShapes = _config$minShapes === void 0 ? 2 : _config$minShapes,
|
|
236
|
+
maxShapes = config.maxShapes,
|
|
237
|
+
maxSelections = config.maxSelections;
|
|
238
|
+
var errors = {};
|
|
239
|
+
var allShapes = Object.values(shapes || {}).reduce(function (acc, shape) {
|
|
240
|
+
return [].concat((0, _toConsumableArray2["default"])(acc), (0, _toConsumableArray2["default"])(shape));
|
|
241
|
+
}, []);
|
|
242
|
+
var nbOfSelections = (allShapes || []).reduce(function (acc, shape) {
|
|
243
|
+
return shape.correct ? acc + 1 : acc;
|
|
244
|
+
}, 0);
|
|
245
|
+
var nbOfShapes = (allShapes || []).length;
|
|
246
|
+
|
|
247
|
+
if (nbOfShapes < minShapes) {
|
|
248
|
+
errors.shapesError = "There should be at least ".concat(minShapes, " shapes defined.");
|
|
249
|
+
} else if (nbOfShapes > maxShapes) {
|
|
250
|
+
errors.shapesError = "No more than ".concat(maxShapes, " shapes should be defined.");
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (nbOfSelections < 1) {
|
|
254
|
+
errors.selectionsError = 'There should be at least 1 shape selected.';
|
|
255
|
+
} else if (nbOfSelections > maxSelections) {
|
|
256
|
+
errors.selectionsError = "No more than ".concat(maxSelections, " shapes should be selected.");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return errors;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
exports.validate = validate;
|
|
228
263
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","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","teacherInstructions","createDefaultModel","defaults","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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;;AAEO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,QAAQ;AAAA;AAC/BC,IAAAA,aAAa,EAAE,IADgB;AAE/BC,IAAAA,gBAAgB,EAAE,IAFa;AAG/BC,IAAAA,0BAA0B,EAAE,IAHG;AAI/BC,IAAAA,0BAA0B,EAAE,IAJG;AAK/BC,IAAAA,WAAW,EAAE;AALkB,KAM5BL,QAN4B;AAAA,CAA1B;;;;AASA,SAASM,KAAT,CAAeN,QAAf,EAAyBO,OAAzB,EAAkCC,GAAlC,EAAuC;AAC5C,MAAMC,kBAAkB,GAAGV,SAAS,CAACC,QAAD,CAApC;AACA,MACEU,QADF,GASID,kBATJ,CACEC,QADF;AAAA,MAEEC,UAFF,GASIF,kBATJ,CAEEE,UAFF;AAAA,MAGEC,YAHF,GASIH,kBATJ,CAGEG,YAHF;AAAA,MAIEC,eAJF,GASIJ,kBATJ,CAIEI,eAJF;AAAA,MAKEC,YALF,GASIL,kBATJ,CAKEK,YALF;AAAA,MAMEC,cANF,GASIN,kBATJ,CAMEM,cANF;AAAA,MAOEC,MAPF,GASIP,kBATJ,CAOEO,MAPF;AAAA,MAQEC,MARF,GASIR,kBATJ,CAQEQ,MARF;;AAUA,aAAiCA,MAAM,IAAI,EAA3C;AAAA,MAAQC,UAAR,QAAQA,UAAR;AAAA,MAAoBC,QAApB,QAAoBA,QAApB;;AAEA,SAAO,IAAIC,OAAJ,CAAY,UAAAC,O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AG,CAACuB,IAAJ,KAAa,YAA5C,EAA0D;AACxD,6BAA4D/B,QAA5D,CAAQiB,MAAR;AAAA,uDAAqD,EAArD;AAAA,mDAAkBC,UAAlB;AAAA,UAAkBA,UAAlB,sCAA+B,EAA/B;AAAA,mDAAmCC,QAAnC;AAAA,UAAmCA,QAAnC,sCAA8C,EAA9C;AAEA,UAAMgD,gBAAgB,GAAGJ,mBAAmB,CAAC7C,UAAD,CAA5C;AACA,UAAMkD,eAAe,GAAGL,mBAAmB,CAAC5C,QAAD,CAA3C;AAEAE,MAAAA,OAAO,CAAC;AACNiB,QAAAA,OAAO,gDACF6B,gBADE,uCAEFC,eAFE,EADD;AAKNhB,QAAAA,EAAE,EAAE;AALE,OAAD,CAAP;AAOD,KAbD,MAaO;AACL/B,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAjBM,CAAP;AAkBD,CAnBM","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 promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n strokeWidth: 5,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n dimensions,\n hotspotColor,\n multipleCorrect,\n outlineColor,\n partialScoring,\n prompt,\n shapes\n } = 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:\n env.mode === 'evaluate'\n ? isResponseCorrect(normalizedQuestion, session)\n : 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 ? normalizedQuestion.teacherInstructions : 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: [\n ...rectangleCorrect,\n ...polygonsCorrect\n ],\n id: '1'\n });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","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","teacherInstructions","createDefaultModel","defaults","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,CAAAC,QAAQ;AAAA;AAC/BC,IAAAA,aAAa,EAAE,IADgB;AAE/BC,IAAAA,gBAAgB,EAAE,IAF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ACD,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 promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n strokeWidth: 5,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n dimensions,\n hotspotColor,\n multipleCorrect,\n outlineColor,\n partialScoring,\n prompt,\n shapes\n } = 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:\n env.mode === 'evaluate'\n ? isResponseCorrect(normalizedQuestion, session)\n : 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 ? normalizedQuestion.teacherInstructions : 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: [\n ...rectangleCorrect,\n ...polygonsCorrect\n ],\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
|
@@ -169,3 +169,29 @@ export const createCorrectResponseSession = (question, env) => {
|
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
};
|
|
172
|
+
|
|
173
|
+
export const validate = (model = {}, config = {}) => {
|
|
174
|
+
const { shapes } = model;
|
|
175
|
+
const { minShapes = 2, maxShapes, maxSelections } = config;
|
|
176
|
+
const errors = {};
|
|
177
|
+
|
|
178
|
+
const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);
|
|
179
|
+
|
|
180
|
+
const nbOfSelections = (allShapes || []).reduce((acc, shape) => shape.correct ? acc + 1 : acc, 0);
|
|
181
|
+
|
|
182
|
+
const nbOfShapes = (allShapes || []).length;
|
|
183
|
+
|
|
184
|
+
if (nbOfShapes < minShapes) {
|
|
185
|
+
errors.shapesError = `There should be at least ${minShapes} shapes defined.`;
|
|
186
|
+
} else if (nbOfShapes > maxShapes) {
|
|
187
|
+
errors.shapesError = `No more than ${maxShapes} shapes should be defined.`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (nbOfSelections < 1) {
|
|
191
|
+
errors.selectionsError = 'There should be at least 1 shape selected.';
|
|
192
|
+
} else if (nbOfSelections > maxSelections) {
|
|
193
|
+
errors.selectionsError = `No more than ${maxSelections} shapes should be selected.`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return errors;
|
|
197
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Config Object for @pie-elements/hotspot",
|
|
3
|
+
"additionalProperties": false,
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"multipleCorrect": {
|
|
7
|
+
"title": "ConfigureProp",
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"settings": {
|
|
11
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
12
|
+
"type": "boolean",
|
|
13
|
+
"title": "settings"
|
|
14
|
+
},
|
|
15
|
+
"label": {
|
|
16
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"title": "label"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"partialScoring": {
|
|
23
|
+
"title": "ConfigureProp",
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"settings": {
|
|
27
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"title": "settings"
|
|
30
|
+
},
|
|
31
|
+
"label": {
|
|
32
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"title": "label"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"rationale": {
|
|
39
|
+
"title": "ConfigureProp",
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"settings": {
|
|
43
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"title": "settings"
|
|
46
|
+
},
|
|
47
|
+
"label": {
|
|
48
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"title": "label"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"spellCheck": {
|
|
55
|
+
"title": "ConfigureProp",
|
|
56
|
+
"type": "object",
|
|
57
|
+
"properties": {
|
|
58
|
+
"settings": {
|
|
59
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"title": "settings"
|
|
62
|
+
},
|
|
63
|
+
"label": {
|
|
64
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
65
|
+
"type": "string",
|
|
66
|
+
"title": "label"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"preserveAspectRatio": {
|
|
71
|
+
"title": "ConfigureProp",
|
|
72
|
+
"type": "object",
|
|
73
|
+
"properties": {
|
|
74
|
+
"settings": {
|
|
75
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"title": "settings"
|
|
78
|
+
},
|
|
79
|
+
"label": {
|
|
80
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
81
|
+
"type": "string",
|
|
82
|
+
"title": "label"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"minShapes": {
|
|
87
|
+
"description": "Minimum number of shapes",
|
|
88
|
+
"type": "number",
|
|
89
|
+
"title": "minShapes"
|
|
90
|
+
},
|
|
91
|
+
"maxShapes": {
|
|
92
|
+
"description": "Maximum number of shapes",
|
|
93
|
+
"type": "number",
|
|
94
|
+
"title": "maxShapes"
|
|
95
|
+
},
|
|
96
|
+
"maxSelections": {
|
|
97
|
+
"description": "Maximum number of selected shapes in correct answer",
|
|
98
|
+
"type": "number",
|
|
99
|
+
"title": "maxSelections"
|
|
100
|
+
},
|
|
101
|
+
"showPrompt": {
|
|
102
|
+
"description": "Determines whether prompt field will be displayed or not",
|
|
103
|
+
"default": true,
|
|
104
|
+
"type": "boolean",
|
|
105
|
+
"title": "showPrompt"
|
|
106
|
+
},
|
|
107
|
+
"promptLabel": {
|
|
108
|
+
"description": "The label for the item stem/prompt field",
|
|
109
|
+
"default": "Item Stemm",
|
|
110
|
+
"type": "string",
|
|
111
|
+
"title": "promptLabel"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"definitions": {
|
|
115
|
+
"ConfigureProp": {
|
|
116
|
+
"title": "ConfigureProp",
|
|
117
|
+
"type": "object",
|
|
118
|
+
"properties": {
|
|
119
|
+
"settings": {
|
|
120
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
121
|
+
"type": "boolean",
|
|
122
|
+
"title": "settings"
|
|
123
|
+
},
|
|
124
|
+
"label": {
|
|
125
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
126
|
+
"type": "string",
|
|
127
|
+
"title": "label"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
133
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Config Object for @pie-elements/hotspot
|
|
2
|
+
|
|
3
|
+
The schema defines the following properties:
|
|
4
|
+
|
|
5
|
+
# `multipleCorrect` (object)
|
|
6
|
+
|
|
7
|
+
Properties of the `multipleCorrect` object:
|
|
8
|
+
|
|
9
|
+
## `settings` (boolean)
|
|
10
|
+
|
|
11
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
12
|
+
|
|
13
|
+
## `label` (string)
|
|
14
|
+
|
|
15
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
16
|
+
|
|
17
|
+
# `partialScoring` (object)
|
|
18
|
+
|
|
19
|
+
Properties of the `partialScoring` object:
|
|
20
|
+
|
|
21
|
+
## `settings` (boolean)
|
|
22
|
+
|
|
23
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
24
|
+
|
|
25
|
+
## `label` (string)
|
|
26
|
+
|
|
27
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
28
|
+
|
|
29
|
+
# `rationale` (object)
|
|
30
|
+
|
|
31
|
+
Properties of the `rationale` object:
|
|
32
|
+
|
|
33
|
+
## `settings` (boolean)
|
|
34
|
+
|
|
35
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
36
|
+
|
|
37
|
+
## `label` (string)
|
|
38
|
+
|
|
39
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
40
|
+
|
|
41
|
+
# `spellCheck` (object)
|
|
42
|
+
|
|
43
|
+
Properties of the `spellCheck` object:
|
|
44
|
+
|
|
45
|
+
## `settings` (boolean)
|
|
46
|
+
|
|
47
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
48
|
+
|
|
49
|
+
## `label` (string)
|
|
50
|
+
|
|
51
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
52
|
+
|
|
53
|
+
# `preserveAspectRatio` (object)
|
|
54
|
+
|
|
55
|
+
Properties of the `preserveAspectRatio` object:
|
|
56
|
+
|
|
57
|
+
## `settings` (boolean)
|
|
58
|
+
|
|
59
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
60
|
+
|
|
61
|
+
## `label` (string)
|
|
62
|
+
|
|
63
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
64
|
+
|
|
65
|
+
# `minShapes` (number)
|
|
66
|
+
|
|
67
|
+
Minimum number of shapes
|
|
68
|
+
|
|
69
|
+
# `maxShapes` (number)
|
|
70
|
+
|
|
71
|
+
Maximum number of shapes
|
|
72
|
+
|
|
73
|
+
# `maxSelections` (number)
|
|
74
|
+
|
|
75
|
+
Maximum number of selected shapes in correct answer
|
|
76
|
+
|
|
77
|
+
# `showPrompt` (boolean)
|
|
78
|
+
|
|
79
|
+
Determines whether prompt field will be displayed or not
|
|
80
|
+
|
|
81
|
+
Default: `true`
|
|
82
|
+
|
|
83
|
+
# `promptLabel` (string)
|
|
84
|
+
|
|
85
|
+
The label for the item stem/prompt field
|
|
86
|
+
|
|
87
|
+
Default: `"Item Stemm"`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
# Sub Schemas
|
|
92
|
+
|
|
93
|
+
The schema defines the following additional types:
|
|
94
|
+
|
|
95
|
+
## `ConfigureProp` (object)
|
|
96
|
+
|
|
97
|
+
Properties of the `ConfigureProp` object:
|
|
98
|
+
|
|
99
|
+
### `settings` (boolean)
|
|
100
|
+
|
|
101
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
102
|
+
|
|
103
|
+
### `label` (string)
|
|
104
|
+
|
|
105
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
package/docs/pie-schema.json
CHANGED
|
@@ -250,6 +250,22 @@
|
|
|
250
250
|
"teacherInstructionsEnabled"
|
|
251
251
|
],
|
|
252
252
|
"definitions": {
|
|
253
|
+
"ConfigureProp": {
|
|
254
|
+
"title": "ConfigureProp",
|
|
255
|
+
"type": "object",
|
|
256
|
+
"properties": {
|
|
257
|
+
"settings": {
|
|
258
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
259
|
+
"type": "boolean",
|
|
260
|
+
"title": "settings"
|
|
261
|
+
},
|
|
262
|
+
"label": {
|
|
263
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
264
|
+
"type": "string",
|
|
265
|
+
"title": "label"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
253
269
|
"Shape": {
|
|
254
270
|
"title": "Shape",
|
|
255
271
|
"type": "object",
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -175,6 +175,18 @@ The html Element tag name
|
|
|
175
175
|
|
|
176
176
|
The schema defines the following additional types:
|
|
177
177
|
|
|
178
|
+
## `ConfigureProp` (object)
|
|
179
|
+
|
|
180
|
+
Properties of the `ConfigureProp` object:
|
|
181
|
+
|
|
182
|
+
### `settings` (boolean)
|
|
183
|
+
|
|
184
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
185
|
+
|
|
186
|
+
### `label` (string)
|
|
187
|
+
|
|
188
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
189
|
+
|
|
178
190
|
## `Shape` (object)
|
|
179
191
|
|
|
180
192
|
Properties of the `Shape` object:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.3",
|
|
11
11
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
12
|
-
"@pie-lib/math-rendering": "^2.
|
|
13
|
-
"@pie-lib/render-ui": "^4.12.
|
|
12
|
+
"@pie-lib/math-rendering": "^2.4.0",
|
|
13
|
+
"@pie-lib/render-ui": "^4.12.6",
|
|
14
14
|
"konva": "^3.2.5",
|
|
15
15
|
"prop-types": "^15.6.1",
|
|
16
16
|
"react": "^16.8.1",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "pie framework developers",
|
|
21
21
|
"license": "ISC",
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "8ea971e13e74d785cd35a04fd9fe1abe1fa2dabf",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"postpublish": "../../scripts/postpublish"
|
|
25
25
|
},
|