@pie-element/hotspot 4.8.4-next.137 → 4.8.4-next.1370
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 +263 -0
- package/configure/CHANGELOG.md +233 -0
- package/configure/lib/defaults.js +20 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/hotspot-container.js +26 -12
- package/configure/lib/hotspot-container.js.map +1 -1
- package/configure/lib/hotspot-drawable.js +11 -5
- package/configure/lib/hotspot-drawable.js.map +1 -1
- package/configure/lib/hotspot-palette.js +1 -1
- package/configure/lib/hotspot-palette.js.map +1 -1
- package/configure/lib/hotspot-polygon.js +1 -1
- package/configure/lib/hotspot-polygon.js.map +1 -1
- package/configure/lib/hotspot-rectangle.js +1 -1
- package/configure/lib/hotspot-rectangle.js.map +1 -1
- package/configure/lib/index.js +17 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +107 -13
- package/configure/lib/root.js.map +1 -1
- package/configure/lib/utils.js +18 -4
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +4 -4
- package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +1 -0
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +53 -4
- package/configure/src/defaults.js +20 -0
- package/configure/src/hotspot-container.jsx +16 -5
- package/configure/src/hotspot-drawable.jsx +8 -2
- package/configure/src/index.js +14 -0
- package/configure/src/root.jsx +87 -9
- package/configure/src/utils.js +23 -1
- package/controller/CHANGELOG.md +50 -0
- package/controller/lib/index.js +44 -5
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/index.js +26 -0
- package/docs/config-schema.json +212 -0
- package/docs/config-schema.json.md +165 -0
- package/docs/demo/generate.js +1 -0
- package/docs/pie-schema.json +49 -0
- package/docs/pie-schema.json.md +36 -0
- package/lib/hotspot/container.js +25 -7
- package/lib/hotspot/container.js.map +1 -1
- package/lib/hotspot/image.js +1 -1
- package/lib/hotspot/image.js.map +1 -1
- package/lib/hotspot/index.js +72 -18
- package/lib/hotspot/index.js.map +1 -1
- package/lib/hotspot/polygon.js +46 -20
- package/lib/hotspot/polygon.js.map +1 -1
- package/lib/hotspot/rectangle.js +46 -20
- package/lib/hotspot/rectangle.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/session-updater.js.map +1 -1
- package/package.json +6 -4
- package/src/__tests__/__snapshots__/{container-test.jsx.snap → container.test.jsx.snap} +8 -0
- package/src/__tests__/__snapshots__/image.test.jsx.snap +43 -0
- package/src/__tests__/__snapshots__/{polygon-test.jsx.snap → polygon.test.jsx.snap} +11 -0
- package/src/__tests__/__snapshots__/{rectangle-test.jsx.snap → rectangle.test.jsx.snap} +11 -0
- package/src/__tests__/{container-test.jsx → container.test.jsx} +57 -0
- package/src/__tests__/{image-test.jsx → image.test.jsx} +0 -0
- package/src/__tests__/polygon.test.jsx +224 -0
- package/src/__tests__/rectangle.test.jsx +233 -0
- package/src/__tests__/{session-updater-test.jsx → session-updater.test.jsx} +0 -0
- package/src/hotspot/container.jsx +23 -3
- package/src/hotspot/index.jsx +68 -8
- package/src/hotspot/polygon.jsx +40 -17
- package/src/hotspot/rectangle.jsx +40 -17
- package/src/index.js +5 -0
- package/src/__tests__/__snapshots__/image-test.jsx.snap +0 -21
- package/src/__tests__/polygon-test.jsx +0 -77
- package/src/__tests__/rectangle-test.jsx +0 -78
package/configure/src/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
ModelUpdatedEvent,
|
|
6
6
|
DeleteImageEvent,
|
|
7
7
|
InsertImageEvent,
|
|
8
|
+
InsertSoundEvent,
|
|
9
|
+
DeleteSoundEvent
|
|
8
10
|
} from '@pie-framework/pie-configure-events';
|
|
9
11
|
|
|
10
12
|
import Root from './root';
|
|
@@ -125,6 +127,14 @@ export default class HotspotConfigure extends HTMLElement {
|
|
|
125
127
|
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
126
128
|
};
|
|
127
129
|
|
|
130
|
+
insertSound(handler) {
|
|
131
|
+
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
onDeleteSound(src, done) {
|
|
135
|
+
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
_render() {
|
|
129
139
|
log('_render');
|
|
130
140
|
let element = React.createElement(Root, {
|
|
@@ -140,6 +150,10 @@ export default class HotspotConfigure extends HTMLElement {
|
|
|
140
150
|
add: this.insertImage,
|
|
141
151
|
delete: this.onDeleteImage
|
|
142
152
|
},
|
|
153
|
+
uploadSoundSupport: {
|
|
154
|
+
add: this.insertSound.bind(this),
|
|
155
|
+
delete: this.onDeleteSound.bind(this)
|
|
156
|
+
},
|
|
143
157
|
onUpdateShapes: this.onUpdateShapes,
|
|
144
158
|
onModelChangedByConfig: this.onModelChangedByConfig,
|
|
145
159
|
onTeacherInstructionsChanged: this.onTeacherInstructionsChanged,
|
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
|
|
|
@@ -57,6 +65,7 @@ export class Root extends React.Component {
|
|
|
57
65
|
configuration,
|
|
58
66
|
model,
|
|
59
67
|
imageSupport,
|
|
68
|
+
uploadSoundSupport,
|
|
60
69
|
onConfigurationChanged,
|
|
61
70
|
onImageUpload,
|
|
62
71
|
onModelChangedByConfig,
|
|
@@ -72,11 +81,28 @@ export class Root extends React.Component {
|
|
|
72
81
|
prompt = {},
|
|
73
82
|
teacherInstructions = {},
|
|
74
83
|
rationale = {},
|
|
75
|
-
|
|
84
|
+
spellCheck = {},
|
|
85
|
+
preserveAspectRatio = {},
|
|
86
|
+
maxImageWidth = {},
|
|
87
|
+
maxImageHeight = {},
|
|
88
|
+
withRubric
|
|
76
89
|
} = configuration || {};
|
|
77
|
-
const {
|
|
90
|
+
const {
|
|
91
|
+
teacherInstructionsEnabled,
|
|
92
|
+
promptEnabled,
|
|
93
|
+
rationaleEnabled,
|
|
94
|
+
spellCheckEnabled,
|
|
95
|
+
errors,
|
|
96
|
+
rubricEnabled
|
|
97
|
+
} = model || {};
|
|
98
|
+
const { shapesError, selectionsError } = errors || {};
|
|
78
99
|
const toolbarOpts = {};
|
|
79
100
|
|
|
101
|
+
const validationMessage = generateValidationMessage(configuration);
|
|
102
|
+
|
|
103
|
+
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
104
|
+
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
105
|
+
|
|
80
106
|
switch (model.toolbarEditorPosition) {
|
|
81
107
|
case 'top':
|
|
82
108
|
toolbarOpts.position = 'top';
|
|
@@ -107,7 +133,10 @@ export class Root extends React.Component {
|
|
|
107
133
|
Properties: {
|
|
108
134
|
teacherInstructionsEnabled:
|
|
109
135
|
teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
110
|
-
rationaleEnabled: rationale.settings && toggle(rationale.label)
|
|
136
|
+
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
137
|
+
spellCheckEnabled:
|
|
138
|
+
spellCheck.settings && toggle(spellCheck.label),
|
|
139
|
+
rubricEnabled: withRubric.settings && toggle(withRubric.label)
|
|
111
140
|
}
|
|
112
141
|
}}
|
|
113
142
|
/>
|
|
@@ -122,6 +151,11 @@ export class Root extends React.Component {
|
|
|
122
151
|
imageSupport={imageSupport}
|
|
123
152
|
nonEmpty={false}
|
|
124
153
|
toolbarOpts={toolbarOpts}
|
|
154
|
+
spellCheck={spellCheckEnabled}
|
|
155
|
+
maxImageWidth={maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth}
|
|
156
|
+
maxImageHeight={maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight}
|
|
157
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
158
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
125
159
|
/>
|
|
126
160
|
</InputContainer>
|
|
127
161
|
)}
|
|
@@ -133,6 +167,11 @@ export class Root extends React.Component {
|
|
|
133
167
|
imageSupport={imageSupport}
|
|
134
168
|
nonEmpty={false}
|
|
135
169
|
toolbarOpts={toolbarOpts}
|
|
170
|
+
spellCheck={spellCheckEnabled}
|
|
171
|
+
maxImageWidth={defaultImageMaxWidth}
|
|
172
|
+
maxImageHeight={defaultImageMaxHeight}
|
|
173
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
174
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
136
175
|
/>
|
|
137
176
|
</InputContainer>
|
|
138
177
|
)}
|
|
@@ -147,13 +186,31 @@ export class Root extends React.Component {
|
|
|
147
186
|
onChange={onRationaleChanged}
|
|
148
187
|
imageSupport={imageSupport}
|
|
149
188
|
toolbarOpts={toolbarOpts}
|
|
189
|
+
spellCheck={spellCheckEnabled}
|
|
190
|
+
maxImageWidth={maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth}
|
|
191
|
+
maxImageHeight={maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight}
|
|
192
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
193
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
150
194
|
/>
|
|
151
195
|
</InputContainer>
|
|
152
196
|
)}
|
|
153
197
|
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
|
|
198
|
+
<div className={classNames(classes.label, classes.flexContainer)}>
|
|
199
|
+
<Typography className={classes.subheading} variant="subheading">
|
|
200
|
+
Define Hotspot
|
|
201
|
+
</Typography>
|
|
202
|
+
<Tooltip
|
|
203
|
+
classes={{ tooltip: classes.tooltip }}
|
|
204
|
+
disableFocusListener
|
|
205
|
+
disableTouchListener
|
|
206
|
+
placement={'left'}
|
|
207
|
+
title={validationMessage}
|
|
208
|
+
>
|
|
209
|
+
<Info fontSize={'small'} color={'primary'} style={{ float: 'right' }}/>
|
|
210
|
+
</Tooltip>
|
|
211
|
+
</div>
|
|
212
|
+
{shapesError && <div className={classes.errorText}>{shapesError}</div>}
|
|
213
|
+
{selectionsError && <div className={classes.errorText}>{selectionsError}</div>}
|
|
157
214
|
|
|
158
215
|
<HotspotPalette
|
|
159
216
|
hotspotColor={model.hotspotColor}
|
|
@@ -239,12 +296,29 @@ const styles = theme => ({
|
|
|
239
296
|
paddingTop: theme.spacing.unit * 2,
|
|
240
297
|
width: '100%'
|
|
241
298
|
},
|
|
299
|
+
subheading: {
|
|
300
|
+
marginRight: '5px'
|
|
301
|
+
},
|
|
242
302
|
regular: {
|
|
243
303
|
marginBottom: theme.spacing.unit * 3
|
|
244
304
|
},
|
|
245
305
|
switchElement: {
|
|
246
306
|
justifyContent: 'space-between',
|
|
247
307
|
margin: 0
|
|
308
|
+
},
|
|
309
|
+
flexContainer: {
|
|
310
|
+
display: 'flex',
|
|
311
|
+
alignItems: 'center'
|
|
312
|
+
},
|
|
313
|
+
tooltip: {
|
|
314
|
+
fontSize: '12px',
|
|
315
|
+
whiteSpace: 'pre',
|
|
316
|
+
maxWidth: '500px',
|
|
317
|
+
},
|
|
318
|
+
errorText: {
|
|
319
|
+
fontSize: '12px',
|
|
320
|
+
color: 'red',
|
|
321
|
+
padding: '5px 0'
|
|
248
322
|
}
|
|
249
323
|
});
|
|
250
324
|
|
|
@@ -256,6 +330,10 @@ Root.propTypes = {
|
|
|
256
330
|
add: PropTypes.func,
|
|
257
331
|
delete: PropTypes.func
|
|
258
332
|
}),
|
|
333
|
+
uploadSoundSupport: PropTypes.shape({
|
|
334
|
+
add: PropTypes.func,
|
|
335
|
+
delete: PropTypes.func
|
|
336
|
+
}),
|
|
259
337
|
onImageUpload: PropTypes.func.isRequired,
|
|
260
338
|
onColorChanged: PropTypes.func.isRequired,
|
|
261
339
|
onPromptChanged: PropTypes.func.isRequired,
|
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,56 @@
|
|
|
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
|
+
|
|
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)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @pie-element/hotspot-controller
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [3.4.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.4.3...@pie-element/hotspot-controller@3.4.4) (2021-11-11)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @pie-element/hotspot-controller
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## [3.4.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.4.1...@pie-element/hotspot-controller@3.4.3) (2021-08-05)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## [3.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.4.0...@pie-element/hotspot-controller@3.4.1) (2021-06-29)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Bug Fixes
|
|
49
|
+
|
|
50
|
+
* **hotspot:** partial scoring not working correctly PD-816 ([#583](https://github.com/pie-framework/pie-elements/issues/583)) ([8266134](https://github.com/pie-framework/pie-elements/commit/8266134bd0e298a89cbcbeb1f8ad16bb803e60ae))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
6
56
|
# [3.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@3.3.15...@pie-element/hotspot-controller@3.4.0) (2021-04-07)
|
|
7
57
|
|
|
8
58
|
|
package/controller/lib/index.js
CHANGED
|
@@ -5,9 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
|
|
8
9
|
exports.model = model;
|
|
10
|
+
exports.normalize = void 0;
|
|
9
11
|
exports.outcome = outcome;
|
|
10
|
-
exports.
|
|
12
|
+
exports.validate = void 0;
|
|
11
13
|
|
|
12
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
15
|
|
|
@@ -25,9 +27,12 @@ var _utils = require("./utils");
|
|
|
25
27
|
|
|
26
28
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
var _excluded = ["index"],
|
|
31
|
+
_excluded2 = ["index"];
|
|
29
32
|
|
|
30
|
-
function
|
|
33
|
+
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; }
|
|
34
|
+
|
|
35
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
36
|
|
|
32
37
|
var log = (0, _debug["default"])('pie-elements:hotspot:controller');
|
|
33
38
|
|
|
@@ -72,13 +77,13 @@ function model(question, session, env) {
|
|
|
72
77
|
// eslint-disable-next-line no-unused-vars
|
|
73
78
|
rectangles: (rectangles || []).map(function (_ref2) {
|
|
74
79
|
var index = _ref2.index,
|
|
75
|
-
rectProps = (0, _objectWithoutProperties2["default"])(_ref2,
|
|
80
|
+
rectProps = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
76
81
|
return _objectSpread({}, rectProps);
|
|
77
82
|
}),
|
|
78
83
|
// eslint-disable-next-line no-unused-vars
|
|
79
84
|
polygons: (polygons || []).map(function (_ref3) {
|
|
80
85
|
var index = _ref3.index,
|
|
81
|
-
polyProps = (0, _objectWithoutProperties2["default"])(_ref3,
|
|
86
|
+
polyProps = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
|
|
82
87
|
return _objectSpread({}, polyProps);
|
|
83
88
|
})
|
|
84
89
|
}),
|
|
@@ -221,4 +226,38 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
221
226
|
};
|
|
222
227
|
|
|
223
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;
|
|
224
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;AAD4C,MAG1CU,QAH0C,GAWxCD,kBAXwC,CAG1CC,QAH0C;AAAA,MAI1CC,UAJ0C,GAWxCF,kBAXwC,CAI1CE,UAJ0C;AAAA,MAK1CC,YAL0C,GAWxCH,kBAXwC,CAK1CG,YAL0C;AAAA,MAM1CC,eAN0C,GAWxCJ,kBAXwC,CAM1CI,eAN0C;AAAA,MAO1CC,YAP0C,GAWxCL,kBAXwC,CAO1CK,YAP0C;AAAA,MAQ1CC,cAR0C,GAWxCN,kBAXwC,CAQ1CM,cAR0C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GALD;AAMA,SAAOd,OAAP;AACD,CAVD;;AAYO,IAAM4B,4BAA4B,GAAG,SAA/BA,4BAA+B,CAAClE,QAAD,EAAWQ,GAAX,EAAmB;AAC7D,SAAO,IAAIY,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5B,QAAIb,GAAG,CAACgB,IAAJ,KAAa,UAAb,IAA2BhB,GAAG,CAACuB,IAAJ,KAAa,YAA5C,EAA0D;AAAA,6BACI/B,QADJ,CAChDiB,MADgD;AAAA,uDACH,EADG;AAAA,mDACtCC,UADsC;AAAA,UACtCA,UADsC,sCACzB,EADyB;AAAA,mDACrBC,QADqB;AAAA,UACrBA,QADqB,sCACV,EADU;AAGxD,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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DX,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 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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","id","sort","isResponseCorrect","question","session","shapes","rectangles","polygons","correctResponseIds","answers","length","answerIds","a"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAAaA,OAAO,CACnDC,MAD4C,CACrC,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,OAAN;AAAA,GADoC,EAE5CC,GAF4C,CAExC,UAAAF,CAAC;AAAA,WAAIA,CAAC,CAACG,EAAN;AAAA,GAFuC,EAG5CC,IAH4C,EAAb;AAAA,CAA3B;;;;AAKA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,OAAX,EAAuB;
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","id","sort","isResponseCorrect","question","session","shapes","rectangles","polygons","correctResponseIds","answers","length","answerIds","a"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAAaA,OAAO,CACnDC,MAD4C,CACrC,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,OAAN;AAAA,GADoC,EAE5CC,GAF4C,CAExC,UAAAF,CAAC;AAAA,WAAIA,CAAC,CAACG,EAAN;AAAA,GAFuC,EAG5CC,IAH4C,EAAb;AAAA,CAA3B;;;;AAKA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,OAAX,EAAuB;AACtD,yBAA6CD,QAA7C,CAAQE,MAAR;AAAA,MAAkBC,UAAlB,oBAAkBA,UAAlB;AAAA,MAA8BC,QAA9B,oBAA8BA,QAA9B;AACA,MAAMZ,OAAO,iDAAOW,UAAP,uCAAsBC,QAAtB,EAAb;AACA,MAAIC,kBAAkB,GAAGd,kBAAkB,CAACC,OAAD,CAA3C;;AAEA,MAAI,CAACS,OAAD,IAAY,yBAAQA,OAAR,CAAhB,EAAkC;AAChC,WAAO,KAAP;AACD;;AAED,MAAIA,OAAO,CAACK,OAAR,IAAmBL,OAAO,CAACK,OAAR,CAAgBC,MAAvC,EAA+C;AAC7C,QAAIC,SAAS,GAAG,CAACP,OAAO,CAACK,OAAR,IAAmB,EAApB,EAAwBV,GAAxB,CAA4B,UAAAa,CAAC;AAAA,aAAIA,CAAC,CAACZ,EAAN;AAAA,KAA7B,CAAhB;AAEA,WAAO,yBAAQW,SAAS,CAACV,IAAV,EAAR,EAA0BO,kBAA1B,CAAP;AACD,GAJD,MAIO,IAAI,EAAEA,kBAAkB,IAAIA,kBAAkB,CAACE,MAA3C,CAAJ,EAAwD;AAC7D,WAAO,IAAP;AACD;;AAED,SAAO,KAAP;AACD,CAlBM","sourcesContent":["import isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\n\nexport const getCorrectResponse = (choices) => choices\n .filter(c => c.correct)\n .map(c => c.id)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n const { shapes: { rectangles, polygons } } = question;\n const choices = [...rectangles, ...polygons];\n let correctResponseIds = getCorrectResponse(choices);\n\n if (!session || isEmpty(session)) {\n return false;\n }\n\n if (session.answers && session.answers.length) {\n let answerIds = (session.answers || []).map(a => a.id);\n\n return isEqual(answerIds.sort(), correctResponseIds);\n } else if (!(correctResponseIds && correctResponseIds.length)) {\n return true;\n }\n\n return false;\n};\n"],"file":"utils.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
|
+
};
|