@pie-element/placement-ordering 12.3.4-next.0 → 13.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/choice-editor.js +189 -414
- package/configure/lib/choice-editor.js.map +1 -1
- package/configure/lib/choice-tile.js +172 -263
- package/configure/lib/choice-tile.js.map +1 -1
- package/configure/lib/defaults.js +2 -4
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design.js +389 -455
- package/configure/lib/design.js.map +1 -1
- package/configure/lib/help.js +5 -13
- package/configure/lib/help.js.map +1 -1
- package/configure/lib/index.js +118 -193
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/utils.js +99 -4
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +12 -10
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +133 -218
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/scoring.js +35 -78
- package/controller/lib/scoring.js.map +1 -1
- package/controller/package.json +4 -4
- package/lib/index.js +63 -127
- package/lib/index.js.map +1 -1
- package/lib/main.js +20 -57
- package/lib/main.js.map +1 -1
- package/lib/ordering.js +52 -98
- package/lib/ordering.js.map +1 -1
- package/lib/placement-ordering.js +331 -381
- package/lib/placement-ordering.js.map +1 -1
- package/lib/tile.js +193 -267
- package/lib/tile.js.map +1 -1
- package/lib/tiler.js +126 -204
- package/lib/tiler.js.map +1 -1
- package/lib/utils.js +6 -18
- package/lib/utils.js.map +1 -1
- package/package.json +14 -11
|
@@ -1,478 +1,253 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
7
|
+
exports.default = void 0;
|
|
22
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
25
|
-
|
|
26
|
-
var _choiceTile = _interopRequireDefault(require("./choice-tile"));
|
|
27
|
-
|
|
28
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
-
|
|
30
10
|
var _react = _interopRequireDefault(require("react"));
|
|
31
|
-
|
|
32
11
|
var _debug = _interopRequireDefault(require("debug"));
|
|
33
|
-
|
|
34
|
-
var _styles = require("@material-ui/core/styles");
|
|
35
|
-
|
|
36
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
37
|
-
|
|
38
|
-
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
39
|
-
|
|
40
|
-
var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
|
|
41
|
-
|
|
42
12
|
var _shuffle = _interopRequireDefault(require("lodash/shuffle"));
|
|
43
|
-
|
|
44
13
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
14
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
15
|
+
var _styles = require("@mui/material/styles");
|
|
48
16
|
var _renderUi = require("@pie-lib/render-ui");
|
|
49
|
-
|
|
50
17
|
var _configUi = require("@pie-lib/config-ui");
|
|
51
|
-
|
|
52
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
53
|
-
|
|
54
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
55
|
-
|
|
56
|
-
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; }
|
|
57
|
-
|
|
58
|
-
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; }
|
|
59
|
-
|
|
18
|
+
var _choiceTile = _interopRequireDefault(require("./choice-tile"));
|
|
60
19
|
function findFreeChoiceSlot(choices) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
while (ids.includes("c".concat(slot))) {
|
|
20
|
+
let slot = 1;
|
|
21
|
+
const ids = choices.map(c => c.id);
|
|
22
|
+
while (ids.includes(`c${slot}`)) {
|
|
67
23
|
slot++;
|
|
68
24
|
}
|
|
69
|
-
|
|
70
25
|
return slot;
|
|
71
26
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return acc;
|
|
92
|
-
}, {
|
|
93
|
-
movedItem: null,
|
|
94
|
-
remainingItems: []
|
|
95
|
-
}),
|
|
96
|
-
movedItem = _updatedResponse$redu.movedItem,
|
|
97
|
-
remainingItems = _updatedResponse$redu.remainingItems;
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
response: [].concat((0, _toConsumableArray2["default"])(remainingItems.slice(0, placeAtIndex)), [movedItem], (0, _toConsumableArray2["default"])(remainingItems.slice(placeAtIndex))),
|
|
101
|
-
choices: choices
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (fromType === 'choice' && toType === 'choice') {
|
|
106
|
-
var updatedChoices = (0, _cloneDeep["default"])(choices) || [];
|
|
107
|
-
|
|
108
|
-
var _updatedChoices$reduc = updatedChoices.reduce(function (acc, item, index) {
|
|
109
|
-
if (item.id === from.id) {
|
|
110
|
-
acc.movedItem = item;
|
|
111
|
-
} else {
|
|
112
|
-
acc.remainingItems.push(item);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (item.id === to.id) {
|
|
116
|
-
acc.toIndex = index;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return acc;
|
|
120
|
-
}, {
|
|
121
|
-
movedItem: null,
|
|
122
|
-
remainingItems: [],
|
|
123
|
-
toIndex: null
|
|
124
|
-
}),
|
|
125
|
-
_movedItem = _updatedChoices$reduc.movedItem,
|
|
126
|
-
_remainingItems = _updatedChoices$reduc.remainingItems,
|
|
127
|
-
toIndex = _updatedChoices$reduc.toIndex;
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
response: response,
|
|
131
|
-
choices: [].concat((0, _toConsumableArray2["default"])(_remainingItems.slice(0, toIndex)), [_movedItem], (0, _toConsumableArray2["default"])(_remainingItems.slice(toIndex)))
|
|
132
|
-
};
|
|
27
|
+
const log = (0, _debug.default)('@pie-element:placement-ordering:configure:choice-editor');
|
|
28
|
+
const StyledControls = (0, _styles.styled)('div')({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'space-between'
|
|
32
|
+
});
|
|
33
|
+
const StyledAddButton = (0, _styles.styled)(_Button.default)(({
|
|
34
|
+
theme
|
|
35
|
+
}) => ({
|
|
36
|
+
marginTop: theme.spacing(2.5),
|
|
37
|
+
paddingLeft: theme.spacing(1.5),
|
|
38
|
+
paddingRight: theme.spacing(1.5),
|
|
39
|
+
'& .MuiButton-label': {
|
|
40
|
+
transition: 'opacity 200ms linear',
|
|
41
|
+
'&:hover': {
|
|
42
|
+
opacity: 0.3
|
|
43
|
+
}
|
|
133
44
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
type: 'choice',
|
|
159
|
-
droppable: false,
|
|
160
|
-
draggable: true,
|
|
161
|
-
instanceId: instanceId,
|
|
162
|
-
editable: true
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
return processedChoices.concat(targets);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
|
|
169
|
-
(0, _inherits2["default"])(ChoiceEditor, _React$Component);
|
|
170
|
-
|
|
171
|
-
var _super = _createSuper(ChoiceEditor);
|
|
172
|
-
|
|
173
|
-
function ChoiceEditor(props) {
|
|
174
|
-
var _this;
|
|
175
|
-
|
|
176
|
-
(0, _classCallCheck2["default"])(this, ChoiceEditor);
|
|
177
|
-
_this = _super.call(this, props);
|
|
178
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
45
|
+
}));
|
|
46
|
+
const StyledVTiler = (0, _styles.styled)('div')({
|
|
47
|
+
gridAutoFlow: 'column',
|
|
48
|
+
display: 'grid',
|
|
49
|
+
gridGap: '10px',
|
|
50
|
+
alignItems: 'center'
|
|
51
|
+
});
|
|
52
|
+
const StyledColumnLabel = (0, _styles.styled)(_renderUi.InputContainer)(({
|
|
53
|
+
theme
|
|
54
|
+
}) => ({
|
|
55
|
+
width: '100%',
|
|
56
|
+
paddingTop: theme.spacing(2)
|
|
57
|
+
}));
|
|
58
|
+
const ErrorText = (0, _styles.styled)('div')(({
|
|
59
|
+
theme
|
|
60
|
+
}) => ({
|
|
61
|
+
fontSize: theme.typography.fontSize - 2,
|
|
62
|
+
color: theme.palette.error.main,
|
|
63
|
+
paddingTop: theme.spacing(1)
|
|
64
|
+
}));
|
|
65
|
+
class ChoiceEditor extends _react.default.Component {
|
|
66
|
+
constructor(props) {
|
|
67
|
+
super(props);
|
|
68
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
179
69
|
warning: {
|
|
180
70
|
open: false
|
|
181
71
|
}
|
|
182
72
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
});
|
|
193
|
-
choices.splice(index, 1, _objectSpread(_objectSpread({}, choices[index]), {}, {
|
|
73
|
+
this.onChoiceChange = choice => {
|
|
74
|
+
const {
|
|
75
|
+
choices,
|
|
76
|
+
onChange,
|
|
77
|
+
correctResponse
|
|
78
|
+
} = this.props;
|
|
79
|
+
const index = choices.findIndex(c => c.id === choice.id);
|
|
80
|
+
choices.splice(index, 1, {
|
|
81
|
+
...choices[index],
|
|
194
82
|
label: choice.label
|
|
195
|
-
})
|
|
83
|
+
});
|
|
196
84
|
onChange(choices, correctResponse);
|
|
197
85
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
86
|
+
this.onDelete = choice => {
|
|
87
|
+
const {
|
|
88
|
+
choices,
|
|
89
|
+
onChange,
|
|
90
|
+
correctResponse,
|
|
91
|
+
choicesLabel
|
|
92
|
+
} = this.props;
|
|
206
93
|
if (choices && choices.length === 3) {
|
|
207
|
-
|
|
94
|
+
this.setState({
|
|
208
95
|
warning: {
|
|
209
96
|
open: true,
|
|
210
|
-
text:
|
|
97
|
+
text: `There have to be at least 3 ${choicesLabel}.`
|
|
211
98
|
}
|
|
212
99
|
});
|
|
213
100
|
} else {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
217
|
-
var updatedCorrectResponse = correctResponse.filter(function (v) {
|
|
218
|
-
return v.id !== choice.id;
|
|
219
|
-
});
|
|
101
|
+
const updatedChoices = choices.filter(c => c.id !== choice.id);
|
|
102
|
+
const updatedCorrectResponse = correctResponse.filter(v => v.id !== choice.id);
|
|
220
103
|
onChange(updatedChoices, updatedCorrectResponse);
|
|
221
104
|
}
|
|
222
105
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
106
|
+
this.addChoice = () => {
|
|
107
|
+
const {
|
|
108
|
+
choices,
|
|
109
|
+
correctResponse,
|
|
110
|
+
onChange,
|
|
111
|
+
choicesLabel
|
|
112
|
+
} = this.props;
|
|
231
113
|
if (choices && choices.length === 10) {
|
|
232
|
-
|
|
114
|
+
this.setState({
|
|
233
115
|
warning: {
|
|
234
116
|
open: true,
|
|
235
|
-
text:
|
|
117
|
+
text: `There can be maximum 10 ${choicesLabel}.`
|
|
236
118
|
}
|
|
237
119
|
});
|
|
238
120
|
} else {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
id
|
|
121
|
+
const freeId = findFreeChoiceSlot(choices);
|
|
122
|
+
const id = `c${freeId}`;
|
|
123
|
+
const newChoice = {
|
|
124
|
+
id,
|
|
243
125
|
label: ''
|
|
244
126
|
};
|
|
245
|
-
|
|
246
|
-
id
|
|
247
|
-
|
|
127
|
+
const newCorrectResponse = {
|
|
128
|
+
id,
|
|
248
129
|
/**
|
|
249
130
|
* Note: weights are not configurable in the existing component
|
|
250
131
|
* so we'll want do disable this in the controller and ignore it for now.
|
|
251
132
|
*/
|
|
252
133
|
weight: 0
|
|
253
134
|
};
|
|
254
|
-
|
|
255
|
-
|
|
135
|
+
const updatedChoices = choices.concat([newChoice]);
|
|
136
|
+
const updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
|
|
256
137
|
onChange(updatedChoices, updatedCorrectResponse);
|
|
257
138
|
}
|
|
258
139
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}), correctResponse.map(function (item) {
|
|
271
|
-
return item.id;
|
|
272
|
-
}));
|
|
273
|
-
|
|
140
|
+
this.shuffleChoices = () => {
|
|
141
|
+
const {
|
|
142
|
+
onChange,
|
|
143
|
+
choices,
|
|
144
|
+
correctResponse,
|
|
145
|
+
placementArea
|
|
146
|
+
} = this.props;
|
|
147
|
+
let shuffled = (0, _shuffle.default)(choices);
|
|
148
|
+
|
|
149
|
+
// if placementArea is disabled, make sure we don't shuffle choices in the correct order
|
|
150
|
+
const shuffledCorrect = !placementArea && (0, _isEqual.default)(shuffled.map(item => item.id), correctResponse.map(item => item.id));
|
|
274
151
|
if (shuffledCorrect) {
|
|
275
|
-
|
|
152
|
+
const shuffledTwice = (0, _shuffle.default)(shuffled);
|
|
276
153
|
onChange(shuffledTwice, correctResponse);
|
|
277
154
|
} else {
|
|
278
155
|
onChange(shuffled, correctResponse);
|
|
279
156
|
}
|
|
280
157
|
};
|
|
281
|
-
|
|
282
|
-
_this.onDropChoice = function (ordering, target, source) {
|
|
283
|
-
var onChange = _this.props.onChange;
|
|
284
|
-
var from = ordering.tiles.find(function (t) {
|
|
285
|
-
return t.id === source.id && t.type === source.type;
|
|
286
|
-
});
|
|
287
|
-
var to = target;
|
|
288
|
-
log('[onDropChoice] ', from, to);
|
|
289
|
-
|
|
290
|
-
var _updateResponseOrChoi = updateResponseOrChoices(ordering.response, ordering.choices, from, to),
|
|
291
|
-
response = _updateResponseOrChoi.response,
|
|
292
|
-
choices = _updateResponseOrChoi.choices;
|
|
293
|
-
|
|
294
|
-
onChange(choices, response);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
return _this;
|
|
298
158
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
maxImageWidth: maxImageWidth,
|
|
369
|
-
maxImageHeight: maxImageHeight,
|
|
370
|
-
error: (choicesErrors === null || choicesErrors === void 0 ? void 0 : choicesErrors[choice.id]) || orderError && ' ' || null,
|
|
371
|
-
mathMlOptions: mathMlOptions
|
|
372
|
-
});
|
|
373
|
-
})), orderError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
374
|
-
className: classes.errorText
|
|
375
|
-
}, orderError), /*#__PURE__*/_react["default"].createElement("div", {
|
|
376
|
-
className: classes.controls
|
|
377
|
-
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
378
|
-
onClick: this.shuffleChoices,
|
|
379
|
-
size: "small",
|
|
380
|
-
variant: "contained",
|
|
381
|
-
color: "default",
|
|
382
|
-
classes: {
|
|
383
|
-
root: classes.addButtonRoot,
|
|
384
|
-
label: classes.addButtonLabel
|
|
385
|
-
}
|
|
386
|
-
}, "SHUFFLE ".concat(pluralChoiceLabel).toUpperCase()), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
387
|
-
onClick: this.addChoice,
|
|
388
|
-
size: "small",
|
|
389
|
-
variant: "contained",
|
|
390
|
-
color: "default",
|
|
391
|
-
classes: {
|
|
392
|
-
root: classes.addButtonRoot,
|
|
393
|
-
label: classes.addButtonLabel
|
|
394
|
-
}
|
|
395
|
-
}, "ADD ".concat(singularChoiceLabel).toUpperCase())), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
396
|
-
open: warning.open,
|
|
397
|
-
title: "Warning",
|
|
398
|
-
text: warning.text,
|
|
399
|
-
onConfirm: function onConfirm() {
|
|
400
|
-
return _this2.setState({
|
|
401
|
-
warning: {
|
|
402
|
-
open: false
|
|
403
|
-
}
|
|
404
|
-
});
|
|
159
|
+
render() {
|
|
160
|
+
const {
|
|
161
|
+
correctResponse,
|
|
162
|
+
choices,
|
|
163
|
+
imageSupport,
|
|
164
|
+
toolbarOpts,
|
|
165
|
+
pluginProps,
|
|
166
|
+
singularChoiceLabel,
|
|
167
|
+
pluralChoiceLabel,
|
|
168
|
+
choicesLabel,
|
|
169
|
+
spellCheck,
|
|
170
|
+
maxImageWidth,
|
|
171
|
+
maxImageHeight,
|
|
172
|
+
errors,
|
|
173
|
+
mathMlOptions = {},
|
|
174
|
+
ordering
|
|
175
|
+
} = this.props;
|
|
176
|
+
const {
|
|
177
|
+
warning
|
|
178
|
+
} = this.state;
|
|
179
|
+
const {
|
|
180
|
+
choicesErrors,
|
|
181
|
+
orderError
|
|
182
|
+
} = errors || {};
|
|
183
|
+
const vTilerStyle = {
|
|
184
|
+
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
185
|
+
gridTemplateRows: `repeat(${choices.length}, 1fr)`
|
|
186
|
+
};
|
|
187
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(StyledVTiler, {
|
|
188
|
+
style: {
|
|
189
|
+
gridTemplateColumns: 'repeat(2, 1fr)'
|
|
190
|
+
}
|
|
191
|
+
}, /*#__PURE__*/_react.default.createElement(StyledColumnLabel, {
|
|
192
|
+
label: `Student ${choicesLabel || 'Choices'}`
|
|
193
|
+
}), /*#__PURE__*/_react.default.createElement(StyledColumnLabel, {
|
|
194
|
+
label: "Correct Order"
|
|
195
|
+
})), /*#__PURE__*/_react.default.createElement(StyledVTiler, {
|
|
196
|
+
style: vTilerStyle
|
|
197
|
+
}, ordering.tiles.map((choice, index) => /*#__PURE__*/_react.default.createElement(_choiceTile.default, {
|
|
198
|
+
key: `${choice.type}-${choice.id}`,
|
|
199
|
+
choice: choice,
|
|
200
|
+
index: index,
|
|
201
|
+
imageSupport: imageSupport,
|
|
202
|
+
onDelete: this.onDelete.bind(this, choice),
|
|
203
|
+
onChoiceChange: this.onChoiceChange,
|
|
204
|
+
toolbarOpts: toolbarOpts,
|
|
205
|
+
pluginProps: pluginProps,
|
|
206
|
+
choices: choices,
|
|
207
|
+
choicesLabel: choicesLabel,
|
|
208
|
+
spellCheck: spellCheck,
|
|
209
|
+
maxImageWidth: maxImageWidth,
|
|
210
|
+
maxImageHeight: maxImageHeight,
|
|
211
|
+
error: choicesErrors?.[choice.id] || orderError && ' ' || null,
|
|
212
|
+
mathMlOptions: mathMlOptions
|
|
213
|
+
}))), orderError && /*#__PURE__*/_react.default.createElement(ErrorText, null, orderError), /*#__PURE__*/_react.default.createElement(StyledControls, null, /*#__PURE__*/_react.default.createElement(StyledAddButton, {
|
|
214
|
+
onClick: this.shuffleChoices,
|
|
215
|
+
size: "small",
|
|
216
|
+
variant: "contained"
|
|
217
|
+
}, `SHUFFLE ${pluralChoiceLabel}`.toUpperCase()), /*#__PURE__*/_react.default.createElement(StyledAddButton, {
|
|
218
|
+
onClick: this.addChoice,
|
|
219
|
+
size: "small",
|
|
220
|
+
variant: "contained"
|
|
221
|
+
}, `ADD ${singularChoiceLabel}`.toUpperCase())), /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
|
|
222
|
+
open: warning.open,
|
|
223
|
+
title: "Warning",
|
|
224
|
+
text: warning.text,
|
|
225
|
+
onConfirm: () => this.setState({
|
|
226
|
+
warning: {
|
|
227
|
+
open: false
|
|
405
228
|
}
|
|
406
|
-
})
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
imageSupport: _propTypes["default"].shape({
|
|
418
|
-
add: _propTypes["default"].func.isRequired,
|
|
419
|
-
"delete": _propTypes["default"].func.isRequired
|
|
229
|
+
})
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
(0, _defineProperty2.default)(ChoiceEditor, "propTypes", {
|
|
234
|
+
correctResponse: _propTypes.default.array.isRequired,
|
|
235
|
+
choices: _propTypes.default.array.isRequired,
|
|
236
|
+
onChange: _propTypes.default.func.isRequired,
|
|
237
|
+
imageSupport: _propTypes.default.shape({
|
|
238
|
+
add: _propTypes.default.func.isRequired,
|
|
239
|
+
delete: _propTypes.default.func.isRequired
|
|
420
240
|
}),
|
|
421
|
-
maxImageHeight: _propTypes
|
|
422
|
-
maxImageWidth: _propTypes
|
|
423
|
-
toolbarOpts: _propTypes
|
|
424
|
-
pluginProps: _propTypes
|
|
425
|
-
placementArea: _propTypes
|
|
426
|
-
singularChoiceLabel: _propTypes
|
|
427
|
-
pluralChoiceLabel: _propTypes
|
|
428
|
-
choicesLabel: _propTypes
|
|
429
|
-
errors: _propTypes
|
|
430
|
-
spellCheck: _propTypes
|
|
241
|
+
maxImageHeight: _propTypes.default.object,
|
|
242
|
+
maxImageWidth: _propTypes.default.object,
|
|
243
|
+
toolbarOpts: _propTypes.default.object,
|
|
244
|
+
pluginProps: _propTypes.default.object,
|
|
245
|
+
placementArea: _propTypes.default.bool,
|
|
246
|
+
singularChoiceLabel: _propTypes.default.string,
|
|
247
|
+
pluralChoiceLabel: _propTypes.default.string,
|
|
248
|
+
choicesLabel: _propTypes.default.string,
|
|
249
|
+
errors: _propTypes.default.object,
|
|
250
|
+
spellCheck: _propTypes.default.bool
|
|
431
251
|
});
|
|
432
|
-
|
|
433
|
-
var styles = function styles(theme) {
|
|
434
|
-
return {
|
|
435
|
-
allToggle: {},
|
|
436
|
-
choiceEditor: {},
|
|
437
|
-
controls: {
|
|
438
|
-
display: 'flex',
|
|
439
|
-
alignItems: 'center',
|
|
440
|
-
justifyContent: 'space-between'
|
|
441
|
-
},
|
|
442
|
-
root: {
|
|
443
|
-
width: '30px',
|
|
444
|
-
height: '30px',
|
|
445
|
-
fill: theme.palette.primary[500]
|
|
446
|
-
},
|
|
447
|
-
addButtonRoot: {
|
|
448
|
-
marginTop: theme.spacing.unit * 2.5,
|
|
449
|
-
paddingHorizontal: theme.spacing.unit * 1.5
|
|
450
|
-
},
|
|
451
|
-
addButtonLabel: {
|
|
452
|
-
transition: 'opacity 200ms linear',
|
|
453
|
-
'&:hover': {
|
|
454
|
-
opacity: 0.3
|
|
455
|
-
}
|
|
456
|
-
},
|
|
457
|
-
vtiler: {
|
|
458
|
-
gridAutoFlow: 'column',
|
|
459
|
-
display: 'grid',
|
|
460
|
-
gridGap: '10px',
|
|
461
|
-
alignItems: 'center'
|
|
462
|
-
},
|
|
463
|
-
columnLabel: {
|
|
464
|
-
width: '100%',
|
|
465
|
-
paddingTop: theme.spacing.unit * 2
|
|
466
|
-
},
|
|
467
|
-
errorText: {
|
|
468
|
-
fontSize: theme.typography.fontSize - 2,
|
|
469
|
-
color: theme.palette.error.main,
|
|
470
|
-
paddingTop: theme.spacing.unit
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
var _default = (0, _styles.withStyles)(styles)(ChoiceEditor);
|
|
476
|
-
|
|
477
|
-
exports["default"] = _default;
|
|
252
|
+
var _default = exports.default = ChoiceEditor;
|
|
478
253
|
//# sourceMappingURL=choice-editor.js.map
|