@pie-element/placement-ordering 12.3.4-next.3 → 13.0.0-beta.1

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +0 -11
  2. package/configure/CHANGELOG.md +0 -11
  3. package/configure/lib/choice-editor.js +189 -414
  4. package/configure/lib/choice-editor.js.map +1 -1
  5. package/configure/lib/choice-tile.js +172 -263
  6. package/configure/lib/choice-tile.js.map +1 -1
  7. package/configure/lib/defaults.js +2 -4
  8. package/configure/lib/defaults.js.map +1 -1
  9. package/configure/lib/design.js +389 -455
  10. package/configure/lib/design.js.map +1 -1
  11. package/configure/lib/help.js +5 -13
  12. package/configure/lib/help.js.map +1 -1
  13. package/configure/lib/index.js +118 -193
  14. package/configure/lib/index.js.map +1 -1
  15. package/configure/lib/utils.js +99 -4
  16. package/configure/lib/utils.js.map +1 -1
  17. package/configure/package.json +12 -10
  18. package/controller/CHANGELOG.md +0 -11
  19. package/controller/lib/defaults.js +2 -3
  20. package/controller/lib/defaults.js.map +1 -1
  21. package/controller/lib/index.js +133 -218
  22. package/controller/lib/index.js.map +1 -1
  23. package/controller/lib/scoring.js +35 -78
  24. package/controller/lib/scoring.js.map +1 -1
  25. package/controller/package.json +4 -4
  26. package/lib/index.js +63 -127
  27. package/lib/index.js.map +1 -1
  28. package/lib/main.js +20 -57
  29. package/lib/main.js.map +1 -1
  30. package/lib/ordering.js +52 -98
  31. package/lib/ordering.js.map +1 -1
  32. package/lib/placement-ordering.js +331 -381
  33. package/lib/placement-ordering.js.map +1 -1
  34. package/lib/tile.js +193 -267
  35. package/lib/tile.js.map +1 -1
  36. package/lib/tiler.js +126 -204
  37. package/lib/tiler.js.map +1 -1
  38. package/lib/utils.js +6 -18
  39. package/lib/utils.js.map +1 -1
  40. package/package.json +14 -11
  41. package/esm/configure.js +0 -25814
  42. package/esm/configure.js.map +0 -1
  43. package/esm/controller.js +0 -21221
  44. package/esm/controller.js.map +0 -1
  45. package/esm/element.js +0 -17874
  46. package/esm/element.js.map +0 -1
  47. package/esm/package.json +0 -3
@@ -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["default"] = void 0;
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 _Button = _interopRequireDefault(require("@material-ui/core/Button"));
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
- var slot = 1;
62
- var ids = choices.map(function (c) {
63
- return c.id;
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
- var log = (0, _debug["default"])('@pie-element:placement-ordering:configure:choice-editor');
74
-
75
- function updateResponseOrChoices(response, choices, from, to) {
76
- var fromType = from.type,
77
- fromIndex = from.index;
78
- var toType = to.type,
79
- placeAtIndex = to.index;
80
-
81
- if (fromType === 'target' && toType === 'target') {
82
- var updatedResponse = (0, _cloneDeep["default"])(response) || [];
83
-
84
- var _updatedResponse$redu = updatedResponse.reduce(function (acc, item, index) {
85
- if (index === fromIndex) {
86
- acc.movedItem = item;
87
- } else {
88
- acc.remainingItems.push(item);
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
- return {
136
- response: response,
137
- choices: choices
138
- };
139
- }
140
-
141
- function buildTiles(choices, response, instanceId) {
142
- var targets = response.map(function (r, index) {
143
- var respId = r && r.id;
144
- var choice = choices.find(function (c) {
145
- return respId !== undefined && respId !== null && c.id === respId;
146
- });
147
- return _objectSpread(_objectSpread({
148
- type: 'target',
149
- instanceId: instanceId
150
- }, choice), {}, {
151
- draggable: true,
152
- index: index,
153
- editable: false
154
- });
155
- });
156
- var processedChoices = choices.map(function (m) {
157
- return Object.assign({}, m, {
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
- _this.instanceId = (0, _uniqueId["default"])();
184
-
185
- _this.onChoiceChange = function (choice) {
186
- var _this$props = _this.props,
187
- choices = _this$props.choices,
188
- onChange = _this$props.onChange,
189
- correctResponse = _this$props.correctResponse;
190
- var index = choices.findIndex(function (c) {
191
- return c.id === choice.id;
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
- _this.onDelete = function (choice) {
200
- var _this$props2 = _this.props,
201
- choices = _this$props2.choices,
202
- onChange = _this$props2.onChange,
203
- correctResponse = _this$props2.correctResponse,
204
- choicesLabel = _this$props2.choicesLabel;
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
- _this.setState({
94
+ this.setState({
208
95
  warning: {
209
96
  open: true,
210
- text: "There have to be at least 3 ".concat(choicesLabel, ".")
97
+ text: `There have to be at least 3 ${choicesLabel}.`
211
98
  }
212
99
  });
213
100
  } else {
214
- var updatedChoices = choices.filter(function (c) {
215
- return c.id !== choice.id;
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
- _this.addChoice = function () {
225
- var _this$props3 = _this.props,
226
- choices = _this$props3.choices,
227
- correctResponse = _this$props3.correctResponse,
228
- onChange = _this$props3.onChange,
229
- choicesLabel = _this$props3.choicesLabel;
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
- _this.setState({
114
+ this.setState({
233
115
  warning: {
234
116
  open: true,
235
- text: "There can be maximum 10 ".concat(choicesLabel, ".")
117
+ text: `There can be maximum 10 ${choicesLabel}.`
236
118
  }
237
119
  });
238
120
  } else {
239
- var freeId = findFreeChoiceSlot(choices);
240
- var id = "c".concat(freeId);
241
- var newChoice = {
242
- id: id,
121
+ const freeId = findFreeChoiceSlot(choices);
122
+ const id = `c${freeId}`;
123
+ const newChoice = {
124
+ id,
243
125
  label: ''
244
126
  };
245
- var newCorrectResponse = {
246
- id: 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
- var updatedChoices = choices.concat([newChoice]);
255
- var updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
135
+ const updatedChoices = choices.concat([newChoice]);
136
+ const updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
256
137
  onChange(updatedChoices, updatedCorrectResponse);
257
138
  }
258
139
  };
259
-
260
- _this.shuffleChoices = function () {
261
- var _this$props4 = _this.props,
262
- onChange = _this$props4.onChange,
263
- choices = _this$props4.choices,
264
- correctResponse = _this$props4.correctResponse,
265
- placementArea = _this$props4.placementArea;
266
- var shuffled = (0, _shuffle["default"])(choices); // if placementArea is disabled, make sure we don't shuffle choices in the correct order
267
-
268
- var shuffledCorrect = !placementArea && (0, _isEqual["default"])(shuffled.map(function (item) {
269
- return item.id;
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
- var shuffledTwice = (0, _shuffle["default"])(shuffled);
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
- (0, _createClass2["default"])(ChoiceEditor, [{
301
- key: "render",
302
- value: function render() {
303
- var _this2 = this;
304
-
305
- var _this$props5 = this.props,
306
- classes = _this$props5.classes,
307
- correctResponse = _this$props5.correctResponse,
308
- choices = _this$props5.choices,
309
- imageSupport = _this$props5.imageSupport,
310
- toolbarOpts = _this$props5.toolbarOpts,
311
- pluginProps = _this$props5.pluginProps,
312
- singularChoiceLabel = _this$props5.singularChoiceLabel,
313
- pluralChoiceLabel = _this$props5.pluralChoiceLabel,
314
- choicesLabel = _this$props5.choicesLabel,
315
- spellCheck = _this$props5.spellCheck,
316
- maxImageWidth = _this$props5.maxImageWidth,
317
- maxImageHeight = _this$props5.maxImageHeight,
318
- errors = _this$props5.errors,
319
- _this$props5$mathMlOp = _this$props5.mathMlOptions,
320
- mathMlOptions = _this$props5$mathMlOp === void 0 ? {} : _this$props5$mathMlOp;
321
- var warning = this.state.warning;
322
-
323
- var _ref = errors || {},
324
- choicesErrors = _ref.choicesErrors,
325
- orderError = _ref.orderError;
326
-
327
- var ordering = {
328
- choices: choices,
329
- response: !correctResponse || (0, _isEmpty["default"])(correctResponse) ? new Array(choices.length) : correctResponse,
330
- tiles: buildTiles(choices, correctResponse, this.instanceId)
331
- };
332
- var vTilerStyle = {
333
- gridTemplateColumns: 'repeat(2, 1fr)',
334
- gridTemplateRows: "repeat(".concat(choices.length, ", 1fr)")
335
- };
336
- return /*#__PURE__*/_react["default"].createElement("div", {
337
- className: classes.choiceEditor
338
- }, /*#__PURE__*/_react["default"].createElement("div", {
339
- className: classes.vtiler,
340
- style: {
341
- gridTemplateColumns: 'repeat(2, 1fr)'
342
- }
343
- }, /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
344
- label: "Student ".concat(choicesLabel || 'Choices'),
345
- className: classes.columnLabel
346
- }), /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
347
- label: "Correct Order",
348
- className: classes.columnLabel
349
- })), /*#__PURE__*/_react["default"].createElement("div", {
350
- className: classes.vtiler,
351
- style: vTilerStyle
352
- }, ordering.tiles.map(function (choice, index) {
353
- return /*#__PURE__*/_react["default"].createElement(_choiceTile["default"], {
354
- choice: choice,
355
- index: index,
356
- key: index,
357
- imageSupport: imageSupport,
358
- onDelete: _this2.onDelete.bind(_this2, choice),
359
- onChoiceChange: _this2.onChoiceChange,
360
- onDropChoice: function onDropChoice(source, index) {
361
- return _this2.onDropChoice(ordering, choice, source, index);
362
- },
363
- toolbarOpts: toolbarOpts,
364
- pluginProps: pluginProps,
365
- choices: choices,
366
- choicesLabel: choicesLabel,
367
- spellCheck: spellCheck,
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
- return ChoiceEditor;
410
- }(_react["default"].Component);
411
-
412
- (0, _defineProperty2["default"])(ChoiceEditor, "propTypes", {
413
- classes: _propTypes["default"].object.isRequired,
414
- correctResponse: _propTypes["default"].array.isRequired,
415
- choices: _propTypes["default"].array.isRequired,
416
- onChange: _propTypes["default"].func.isRequired,
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["default"].object,
422
- maxImageWidth: _propTypes["default"].object,
423
- toolbarOpts: _propTypes["default"].object,
424
- pluginProps: _propTypes["default"].object,
425
- placementArea: _propTypes["default"].bool,
426
- singularChoiceLabel: _propTypes["default"].string,
427
- pluralChoiceLabel: _propTypes["default"].string,
428
- choicesLabel: _propTypes["default"].string,
429
- errors: _propTypes["default"].object,
430
- spellCheck: _propTypes["default"].bool
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