@pie-element/placement-ordering 8.7.1-beta.1 → 8.7.1-beta.4

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.
@@ -0,0 +1,409 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
16
+ var _choiceTile = _interopRequireDefault(require("./choice-tile"));
17
+ var _propTypes = _interopRequireDefault(require("prop-types"));
18
+ var _react = _interopRequireDefault(require("react"));
19
+ var _debug = _interopRequireDefault(require("debug"));
20
+ var _styles = require("@material-ui/core/styles");
21
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
22
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
23
+ var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
24
+ var _shuffle = _interopRequireDefault(require("lodash/shuffle"));
25
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
26
+ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
27
+ var _renderUi = require("@pie-lib/render-ui");
28
+ var _configUi = require("@pie-lib/config-ui");
29
+ 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); }; }
30
+ 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; } }
31
+ 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; }
32
+ 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; }
33
+ function findFreeChoiceSlot(choices) {
34
+ var slot = 1;
35
+ var ids = choices.map(function (c) {
36
+ return c.id;
37
+ });
38
+ while (ids.includes("c".concat(slot))) {
39
+ slot++;
40
+ }
41
+ return slot;
42
+ }
43
+ var log = (0, _debug["default"])('@pie-element:placement-ordering:configure:choice-editor');
44
+ function updateResponseOrChoices(response, choices, from, to) {
45
+ var fromType = from.type,
46
+ fromIndex = from.index;
47
+ var toType = to.type,
48
+ placeAtIndex = to.index;
49
+ if (fromType === 'target' && toType === 'target') {
50
+ var updatedResponse = (0, _cloneDeep["default"])(response) || [];
51
+ var _updatedResponse$redu = updatedResponse.reduce(function (acc, item, index) {
52
+ if (index === fromIndex) {
53
+ acc.movedItem = item;
54
+ } else {
55
+ acc.remainingItems.push(item);
56
+ }
57
+ return acc;
58
+ }, {
59
+ movedItem: null,
60
+ remainingItems: []
61
+ }),
62
+ movedItem = _updatedResponse$redu.movedItem,
63
+ remainingItems = _updatedResponse$redu.remainingItems;
64
+ return {
65
+ response: [].concat((0, _toConsumableArray2["default"])(remainingItems.slice(0, placeAtIndex)), [movedItem], (0, _toConsumableArray2["default"])(remainingItems.slice(placeAtIndex))),
66
+ choices: choices
67
+ };
68
+ }
69
+ if (fromType === 'choice' && toType === 'choice') {
70
+ var updatedChoices = (0, _cloneDeep["default"])(choices) || [];
71
+ var _updatedChoices$reduc = updatedChoices.reduce(function (acc, item, index) {
72
+ if (item.id === from.id) {
73
+ acc.movedItem = item;
74
+ } else {
75
+ acc.remainingItems.push(item);
76
+ }
77
+ if (item.id === to.id) {
78
+ acc.toIndex = index;
79
+ }
80
+ return acc;
81
+ }, {
82
+ movedItem: null,
83
+ remainingItems: [],
84
+ toIndex: null
85
+ }),
86
+ _movedItem = _updatedChoices$reduc.movedItem,
87
+ _remainingItems = _updatedChoices$reduc.remainingItems,
88
+ toIndex = _updatedChoices$reduc.toIndex;
89
+ return {
90
+ response: response,
91
+ choices: [].concat((0, _toConsumableArray2["default"])(_remainingItems.slice(0, toIndex)), [_movedItem], (0, _toConsumableArray2["default"])(_remainingItems.slice(toIndex)))
92
+ };
93
+ }
94
+ return {
95
+ response: response,
96
+ choices: choices
97
+ };
98
+ }
99
+ function buildTiles(choices, response, instanceId) {
100
+ var targets = response.map(function (r, index) {
101
+ var respId = r && r.id;
102
+ var choice = choices.find(function (c) {
103
+ return respId !== undefined && respId !== null && c.id === respId;
104
+ });
105
+ return _objectSpread(_objectSpread({
106
+ type: 'target',
107
+ instanceId: instanceId
108
+ }, choice), {}, {
109
+ draggable: true,
110
+ index: index,
111
+ editable: false
112
+ });
113
+ });
114
+ var processedChoices = choices.map(function (m) {
115
+ return Object.assign({}, m, {
116
+ type: 'choice',
117
+ droppable: false,
118
+ draggable: true,
119
+ instanceId: instanceId,
120
+ editable: true
121
+ });
122
+ });
123
+ return processedChoices.concat(targets);
124
+ }
125
+ var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
126
+ (0, _inherits2["default"])(ChoiceEditor, _React$Component);
127
+ var _super = _createSuper(ChoiceEditor);
128
+ function ChoiceEditor(props) {
129
+ var _this;
130
+ (0, _classCallCheck2["default"])(this, ChoiceEditor);
131
+ _this = _super.call(this, props);
132
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
133
+ warning: {
134
+ open: false
135
+ }
136
+ });
137
+ _this.instanceId = (0, _uniqueId["default"])();
138
+ _this.onChoiceChange = function (choice) {
139
+ var _this$props = _this.props,
140
+ choices = _this$props.choices,
141
+ onChange = _this$props.onChange,
142
+ correctResponse = _this$props.correctResponse;
143
+ var index = choices.findIndex(function (c) {
144
+ return c.id === choice.id;
145
+ });
146
+ choices.splice(index, 1, _objectSpread(_objectSpread({}, choices[index]), {}, {
147
+ label: choice.label
148
+ }));
149
+ onChange(choices, correctResponse);
150
+ };
151
+ _this.onDelete = function (choice) {
152
+ var _this$props2 = _this.props,
153
+ choices = _this$props2.choices,
154
+ onChange = _this$props2.onChange,
155
+ correctResponse = _this$props2.correctResponse,
156
+ choicesLabel = _this$props2.choicesLabel;
157
+ if (choices && choices.length === 3) {
158
+ _this.setState({
159
+ warning: {
160
+ open: true,
161
+ text: "There have to be at least 3 ".concat(choicesLabel, ".")
162
+ }
163
+ });
164
+ } else {
165
+ var updatedChoices = choices.filter(function (c) {
166
+ return c.id !== choice.id;
167
+ });
168
+ var updatedCorrectResponse = correctResponse.filter(function (v) {
169
+ return v.id !== choice.id;
170
+ });
171
+ onChange(updatedChoices, updatedCorrectResponse);
172
+ }
173
+ };
174
+ _this.addChoice = function () {
175
+ var _this$props3 = _this.props,
176
+ choices = _this$props3.choices,
177
+ correctResponse = _this$props3.correctResponse,
178
+ onChange = _this$props3.onChange,
179
+ choicesLabel = _this$props3.choicesLabel;
180
+ if (choices && choices.length === 10) {
181
+ _this.setState({
182
+ warning: {
183
+ open: true,
184
+ text: "There can be maximum 10 ".concat(choicesLabel, ".")
185
+ }
186
+ });
187
+ } else {
188
+ var freeId = findFreeChoiceSlot(choices);
189
+ var id = "c".concat(freeId);
190
+ var newChoice = {
191
+ id: id,
192
+ label: ''
193
+ };
194
+ var newCorrectResponse = {
195
+ id: id,
196
+ /**
197
+ * Note: weights are not configurable in the existing component
198
+ * so we'll want do disable this in the controller and ignore it for now.
199
+ */
200
+ weight: 0
201
+ };
202
+ var updatedChoices = choices.concat([newChoice]);
203
+ var updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
204
+ onChange(updatedChoices, updatedCorrectResponse);
205
+ }
206
+ };
207
+ _this.shuffleChoices = function () {
208
+ var _this$props4 = _this.props,
209
+ onChange = _this$props4.onChange,
210
+ choices = _this$props4.choices,
211
+ correctResponse = _this$props4.correctResponse,
212
+ placementArea = _this$props4.placementArea;
213
+ var shuffled = (0, _shuffle["default"])(choices);
214
+
215
+ // if placementArea is disabled, make sure we don't shuffle choices in the correct order
216
+ var shuffledCorrect = !placementArea && (0, _isEqual["default"])(shuffled.map(function (item) {
217
+ return item.id;
218
+ }), correctResponse.map(function (item) {
219
+ return item.id;
220
+ }));
221
+ if (shuffledCorrect) {
222
+ var shuffledTwice = (0, _shuffle["default"])(shuffled);
223
+ onChange(shuffledTwice, correctResponse);
224
+ } else {
225
+ onChange(shuffled, correctResponse);
226
+ }
227
+ };
228
+ _this.onDropChoice = function (ordering, target, source) {
229
+ var onChange = _this.props.onChange;
230
+ var from = ordering.tiles.find(function (t) {
231
+ return t.id === source.id && t.type === source.type;
232
+ });
233
+ var to = target;
234
+ log('[onDropChoice] ', from, to);
235
+ var _updateResponseOrChoi = updateResponseOrChoices(ordering.response, ordering.choices, from, to),
236
+ response = _updateResponseOrChoi.response,
237
+ choices = _updateResponseOrChoi.choices;
238
+ onChange(choices, response);
239
+ };
240
+ return _this;
241
+ }
242
+ (0, _createClass2["default"])(ChoiceEditor, [{
243
+ key: "render",
244
+ value: function render() {
245
+ var _this2 = this;
246
+ var _this$props5 = this.props,
247
+ classes = _this$props5.classes,
248
+ correctResponse = _this$props5.correctResponse,
249
+ choices = _this$props5.choices,
250
+ imageSupport = _this$props5.imageSupport,
251
+ disableImages = _this$props5.disableImages,
252
+ toolbarOpts = _this$props5.toolbarOpts,
253
+ singularChoiceLabel = _this$props5.singularChoiceLabel,
254
+ pluralChoiceLabel = _this$props5.pluralChoiceLabel,
255
+ choicesLabel = _this$props5.choicesLabel,
256
+ spellCheck = _this$props5.spellCheck,
257
+ maxImageWidth = _this$props5.maxImageWidth,
258
+ maxImageHeight = _this$props5.maxImageHeight,
259
+ errors = _this$props5.errors;
260
+ var warning = this.state.warning;
261
+ var _ref = errors || {},
262
+ choicesErrors = _ref.choicesErrors,
263
+ orderError = _ref.orderError;
264
+ var ordering = {
265
+ choices: choices,
266
+ response: !correctResponse || (0, _isEmpty["default"])(correctResponse) ? new Array(choices.length) : correctResponse,
267
+ tiles: buildTiles(choices, correctResponse, this.instanceId)
268
+ };
269
+ var vTilerStyle = {
270
+ gridTemplateColumns: 'repeat(2, 1fr)',
271
+ gridTemplateRows: "repeat(".concat(choices.length, ", 1fr)")
272
+ };
273
+ return /*#__PURE__*/_react["default"].createElement("div", {
274
+ className: classes.choiceEditor
275
+ }, /*#__PURE__*/_react["default"].createElement("div", {
276
+ className: classes.vtiler,
277
+ style: {
278
+ gridTemplateColumns: 'repeat(2, 1fr)'
279
+ }
280
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
281
+ label: "Student ".concat(choicesLabel || 'Choices'),
282
+ className: classes.columnLabel
283
+ }), /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
284
+ label: "Correct Order",
285
+ className: classes.columnLabel
286
+ })), /*#__PURE__*/_react["default"].createElement("div", {
287
+ className: classes.vtiler,
288
+ style: vTilerStyle
289
+ }, ordering.tiles.map(function (choice, index) {
290
+ return /*#__PURE__*/_react["default"].createElement(_choiceTile["default"], {
291
+ choice: choice,
292
+ index: index,
293
+ key: index,
294
+ imageSupport: imageSupport,
295
+ onDelete: _this2.onDelete.bind(_this2, choice),
296
+ onChoiceChange: _this2.onChoiceChange,
297
+ onDropChoice: function onDropChoice(source, index) {
298
+ return _this2.onDropChoice(ordering, choice, source, index);
299
+ },
300
+ disableImages: disableImages,
301
+ toolbarOpts: toolbarOpts,
302
+ choices: choices,
303
+ choicesLabel: choicesLabel,
304
+ spellCheck: spellCheck,
305
+ maxImageWidth: maxImageWidth,
306
+ maxImageHeight: maxImageHeight,
307
+ error: (choicesErrors === null || choicesErrors === void 0 ? void 0 : choicesErrors[choice.id]) || orderError && ' ' || null
308
+ });
309
+ })), orderError && /*#__PURE__*/_react["default"].createElement("div", {
310
+ className: classes.errorText
311
+ }, orderError), /*#__PURE__*/_react["default"].createElement("div", {
312
+ className: classes.controls
313
+ }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
314
+ onClick: this.shuffleChoices,
315
+ size: "small",
316
+ variant: "contained",
317
+ color: "default",
318
+ classes: {
319
+ root: classes.addButtonRoot,
320
+ label: classes.addButtonLabel
321
+ }
322
+ }, "SHUFFLE ".concat(pluralChoiceLabel).toUpperCase()), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
323
+ onClick: this.addChoice,
324
+ size: "small",
325
+ variant: "contained",
326
+ color: "default",
327
+ classes: {
328
+ root: classes.addButtonRoot,
329
+ label: classes.addButtonLabel
330
+ }
331
+ }, "ADD ".concat(singularChoiceLabel).toUpperCase())), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
332
+ open: warning.open,
333
+ title: "Warning",
334
+ text: warning.text,
335
+ onConfirm: function onConfirm() {
336
+ return _this2.setState({
337
+ warning: {
338
+ open: false
339
+ }
340
+ });
341
+ }
342
+ }));
343
+ }
344
+ }]);
345
+ return ChoiceEditor;
346
+ }(_react["default"].Component);
347
+ (0, _defineProperty2["default"])(ChoiceEditor, "propTypes", {
348
+ classes: _propTypes["default"].object.isRequired,
349
+ correctResponse: _propTypes["default"].array.isRequired,
350
+ choices: _propTypes["default"].array.isRequired,
351
+ onChange: _propTypes["default"].func.isRequired,
352
+ imageSupport: _propTypes["default"].shape({
353
+ add: _propTypes["default"].func.isRequired,
354
+ "delete": _propTypes["default"].func.isRequired
355
+ }),
356
+ disableImages: _propTypes["default"].bool,
357
+ toolbarOpts: _propTypes["default"].object,
358
+ placementArea: _propTypes["default"].bool,
359
+ singularChoiceLabel: _propTypes["default"].string,
360
+ pluralChoiceLabel: _propTypes["default"].string,
361
+ choicesLabel: _propTypes["default"].string,
362
+ errors: _propTypes["default"].object
363
+ });
364
+ var styles = function styles(theme) {
365
+ return {
366
+ allToggle: {},
367
+ choiceEditor: {
368
+ marginTop: theme.spacing.unit
369
+ },
370
+ controls: {
371
+ display: 'flex',
372
+ alignItems: 'center',
373
+ justifyContent: 'space-between'
374
+ },
375
+ root: {
376
+ width: '30px',
377
+ height: '30px',
378
+ fill: theme.palette.primary[500]
379
+ },
380
+ addButtonRoot: {
381
+ marginTop: theme.spacing.unit * 3,
382
+ paddingHorizontal: theme.spacing.unit * 1.5
383
+ },
384
+ addButtonLabel: {
385
+ transition: 'opacity 200ms linear',
386
+ '&:hover': {
387
+ opacity: 0.3
388
+ }
389
+ },
390
+ vtiler: {
391
+ gridAutoFlow: 'column',
392
+ display: 'grid',
393
+ gridGap: '10px'
394
+ },
395
+ columnLabel: {
396
+ width: '100%',
397
+ paddingTop: theme.spacing.unit * 3,
398
+ marginTop: theme.spacing.unit * 2
399
+ },
400
+ errorText: {
401
+ fontSize: theme.typography.fontSize - 2,
402
+ color: 'red',
403
+ paddingTop: theme.spacing.unit
404
+ }
405
+ };
406
+ };
407
+ var _default = (0, _styles.withStyles)(styles)(ChoiceEditor);
408
+ exports["default"] = _default;
409
+ //# sourceMappingURL=choice-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choice-editor.js","names":["_choiceTile","_interopRequireDefault","require","_propTypes","_react","_debug","_styles","_isEmpty","_cloneDeep","_uniqueId","_shuffle","_isEqual","_Button","_renderUi","_configUi","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","result","NewTarget","constructor","Reflect","construct","arguments","apply","_possibleConstructorReturn2","sham","Proxy","Boolean","prototype","valueOf","call","e","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","_objectSpread","target","i","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","findFreeChoiceSlot","choices","slot","ids","map","c","id","includes","concat","log","debug","updateResponseOrChoices","response","from","to","fromType","type","fromIndex","index","toType","placeAtIndex","updatedResponse","cloneDeep","_updatedResponse$redu","reduce","acc","item","movedItem","remainingItems","_toConsumableArray2","slice","updatedChoices","_updatedChoices$reduc","toIndex","buildTiles","instanceId","targets","r","respId","choice","find","undefined","draggable","editable","processedChoices","m","assign","droppable","ChoiceEditor","_React$Component","_inherits2","_super","props","_this","_classCallCheck2","_assertThisInitialized2","warning","open","uniqueId","onChoiceChange","_this$props","onChange","correctResponse","findIndex","splice","label","onDelete","_this$props2","choicesLabel","setState","text","updatedCorrectResponse","v","addChoice","_this$props3","freeId","newChoice","newCorrectResponse","weight","shuffleChoices","_this$props4","placementArea","shuffled","shuffle","shuffledCorrect","isEqual","shuffledTwice","onDropChoice","ordering","tiles","t","_updateResponseOrChoi","_createClass2","value","render","_this2","_this$props5","classes","imageSupport","disableImages","toolbarOpts","singularChoiceLabel","pluralChoiceLabel","spellCheck","maxImageWidth","maxImageHeight","errors","state","_ref","choicesErrors","orderError","isEmpty","Array","vTilerStyle","gridTemplateColumns","gridTemplateRows","createElement","className","choiceEditor","vtiler","style","InputContainer","columnLabel","bind","error","errorText","controls","onClick","size","variant","color","root","addButtonRoot","addButtonLabel","toUpperCase","AlertDialog","title","onConfirm","React","Component","PropTypes","isRequired","array","func","shape","add","bool","string","styles","theme","allToggle","marginTop","spacing","unit","display","alignItems","justifyContent","width","height","fill","palette","primary","paddingHorizontal","transition","opacity","gridAutoFlow","gridGap","paddingTop","fontSize","typography","_default","withStyles","exports"],"sources":["../src/choice-editor.jsx"],"sourcesContent":["import ChoiceTile from './choice-tile';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport isEmpty from 'lodash/isEmpty';\nimport cloneDeep from 'lodash/cloneDeep';\nimport uniqueId from 'lodash/uniqueId';\nimport shuffle from 'lodash/shuffle';\nimport isEqual from 'lodash/isEqual';\nimport Button from '@material-ui/core/Button';\nimport { InputContainer } from '@pie-lib/render-ui';\nimport { AlertDialog } from '@pie-lib/config-ui';\n\nfunction findFreeChoiceSlot(choices) {\n let slot = 1;\n const ids = choices.map((c) => c.id);\n\n while (ids.includes(`c${slot}`)) {\n slot++;\n }\n\n return slot;\n}\n\nconst log = debug('@pie-element:placement-ordering:configure:choice-editor');\n\nfunction updateResponseOrChoices(response, choices, from, to) {\n const { type: fromType, index: fromIndex } = from;\n const { type: toType, index: placeAtIndex } = to;\n\n if (fromType === 'target' && toType === 'target') {\n const updatedResponse = cloneDeep(response) || [];\n\n const { movedItem, remainingItems } = updatedResponse.reduce(\n (acc, item, index) => {\n if (index === fromIndex) {\n acc.movedItem = item;\n } else {\n acc.remainingItems.push(item);\n }\n\n return acc;\n },\n { movedItem: null, remainingItems: [] },\n );\n\n return {\n response: [...remainingItems.slice(0, placeAtIndex), movedItem, ...remainingItems.slice(placeAtIndex)],\n choices,\n };\n }\n\n if (fromType === 'choice' && toType === 'choice') {\n const updatedChoices = cloneDeep(choices) || [];\n\n const { movedItem, remainingItems, toIndex } = updatedChoices.reduce(\n (acc, item, index) => {\n if (item.id === from.id) {\n acc.movedItem = item;\n } else {\n acc.remainingItems.push(item);\n }\n\n if (item.id === to.id) {\n acc.toIndex = index;\n }\n\n return acc;\n },\n { movedItem: null, remainingItems: [], toIndex: null },\n );\n\n return {\n response,\n choices: [...remainingItems.slice(0, toIndex), movedItem, ...remainingItems.slice(toIndex)],\n };\n }\n\n return { response, choices };\n}\n\nfunction buildTiles(choices, response, instanceId) {\n const targets = response.map((r, index) => {\n const respId = r && r.id;\n const choice = choices.find((c) => respId !== undefined && respId !== null && c.id === respId);\n\n return {\n type: 'target',\n instanceId,\n ...choice,\n draggable: true,\n index,\n editable: false,\n };\n });\n\n const processedChoices = choices.map((m) => {\n return Object.assign({}, m, {\n type: 'choice',\n droppable: false,\n draggable: true,\n instanceId,\n editable: true,\n });\n });\n\n return processedChoices.concat(targets);\n}\n\nclass ChoiceEditor extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n correctResponse: PropTypes.array.isRequired,\n choices: PropTypes.array.isRequired,\n onChange: PropTypes.func.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n disableImages: PropTypes.bool,\n toolbarOpts: PropTypes.object,\n placementArea: PropTypes.bool,\n singularChoiceLabel: PropTypes.string,\n pluralChoiceLabel: PropTypes.string,\n choicesLabel: PropTypes.string,\n errors: PropTypes.object,\n };\n\n state = { warning: { open: false } };\n\n constructor(props) {\n super(props);\n\n this.instanceId = uniqueId();\n\n this.onChoiceChange = (choice) => {\n const { choices, onChange, correctResponse } = this.props;\n const index = choices.findIndex((c) => c.id === choice.id);\n\n choices.splice(index, 1, { ...choices[index], label: choice.label });\n onChange(choices, correctResponse);\n };\n\n this.onDelete = (choice) => {\n const { choices, onChange, correctResponse, choicesLabel } = this.props;\n\n if (choices && choices.length === 3) {\n this.setState({\n warning: {\n open: true,\n text: `There have to be at least 3 ${choicesLabel}.`,\n },\n });\n } else {\n const updatedChoices = choices.filter((c) => c.id !== choice.id);\n const updatedCorrectResponse = correctResponse.filter((v) => v.id !== choice.id);\n\n onChange(updatedChoices, updatedCorrectResponse);\n }\n };\n\n this.addChoice = () => {\n const { choices, correctResponse, onChange, choicesLabel } = this.props;\n\n if (choices && choices.length === 10) {\n this.setState({\n warning: {\n open: true,\n text: `There can be maximum 10 ${choicesLabel}.`,\n },\n });\n } else {\n const freeId = findFreeChoiceSlot(choices);\n const id = `c${freeId}`;\n const newChoice = { id, label: '' };\n\n const newCorrectResponse = {\n id,\n /**\n * Note: weights are not configurable in the existing component\n * so we'll want do disable this in the controller and ignore it for now.\n */\n weight: 0,\n };\n\n const updatedChoices = choices.concat([newChoice]);\n const updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);\n\n onChange(updatedChoices, updatedCorrectResponse);\n }\n };\n\n this.shuffleChoices = () => {\n const { onChange, choices, correctResponse, placementArea } = this.props;\n let shuffled = shuffle(choices);\n\n // if placementArea is disabled, make sure we don't shuffle choices in the correct order\n const shuffledCorrect =\n !placementArea &&\n isEqual(\n shuffled.map((item) => item.id),\n correctResponse.map((item) => item.id),\n );\n\n if (shuffledCorrect) {\n const shuffledTwice = shuffle(shuffled);\n\n onChange(shuffledTwice, correctResponse);\n } else {\n onChange(shuffled, correctResponse);\n }\n };\n\n this.onDropChoice = (ordering, target, source) => {\n const { onChange } = this.props;\n const from = ordering.tiles.find((t) => t.id === source.id && t.type === source.type);\n const to = target;\n log('[onDropChoice] ', from, to);\n const { response, choices } = updateResponseOrChoices(ordering.response, ordering.choices, from, to);\n\n onChange(choices, response);\n };\n }\n\n render() {\n const {\n classes,\n correctResponse,\n choices,\n imageSupport,\n disableImages,\n toolbarOpts,\n singularChoiceLabel,\n pluralChoiceLabel,\n choicesLabel,\n spellCheck,\n maxImageWidth,\n maxImageHeight,\n errors,\n } = this.props;\n const { warning } = this.state;\n const { choicesErrors, orderError } = errors || {};\n\n const ordering = {\n choices,\n response: !correctResponse || isEmpty(correctResponse) ? new Array(choices.length) : correctResponse,\n tiles: buildTiles(choices, correctResponse, this.instanceId),\n };\n\n const vTilerStyle = {\n gridTemplateColumns: 'repeat(2, 1fr)',\n gridTemplateRows: `repeat(${choices.length}, 1fr)`,\n };\n\n return (\n <div className={classes.choiceEditor}>\n <div className={classes.vtiler} style={{ gridTemplateColumns: 'repeat(2, 1fr)' }}>\n <InputContainer label={`Student ${choicesLabel || 'Choices'}`} className={classes.columnLabel} />\n <InputContainer label=\"Correct Order\" className={classes.columnLabel} />\n </div>\n\n <div className={classes.vtiler} style={vTilerStyle}>\n {ordering.tiles.map((choice, index) => (\n <ChoiceTile\n choice={choice}\n index={index}\n key={index}\n imageSupport={imageSupport}\n onDelete={this.onDelete.bind(this, choice)}\n onChoiceChange={this.onChoiceChange}\n onDropChoice={(source, index) => this.onDropChoice(ordering, choice, source, index)}\n disableImages={disableImages}\n toolbarOpts={toolbarOpts}\n choices={choices}\n choicesLabel={choicesLabel}\n spellCheck={spellCheck}\n maxImageWidth={maxImageWidth}\n maxImageHeight={maxImageHeight}\n error={choicesErrors?.[choice.id] || (orderError && ' ') || null}\n />\n ))}\n </div>\n\n {orderError && <div className={classes.errorText}>{orderError}</div>}\n\n <div className={classes.controls}>\n <Button\n onClick={this.shuffleChoices}\n size=\"small\"\n variant=\"contained\"\n color=\"default\"\n classes={{ root: classes.addButtonRoot, label: classes.addButtonLabel }}\n >\n {`SHUFFLE ${pluralChoiceLabel}`.toUpperCase()}\n </Button>\n\n <Button\n onClick={this.addChoice}\n size=\"small\"\n variant=\"contained\"\n color=\"default\"\n classes={{ root: classes.addButtonRoot, label: classes.addButtonLabel }}\n >\n {`ADD ${singularChoiceLabel}`.toUpperCase()}\n </Button>\n </div>\n\n <AlertDialog\n open={warning.open}\n title=\"Warning\"\n text={warning.text}\n onConfirm={() => this.setState({ warning: { open: false } })}\n />\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n allToggle: {},\n choiceEditor: {\n marginTop: theme.spacing.unit,\n },\n controls: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n root: {\n width: '30px',\n height: '30px',\n fill: theme.palette.primary[500],\n },\n addButtonRoot: {\n marginTop: theme.spacing.unit * 3,\n paddingHorizontal: theme.spacing.unit * 1.5,\n },\n addButtonLabel: {\n transition: 'opacity 200ms linear',\n '&:hover': {\n opacity: 0.3,\n },\n },\n vtiler: {\n gridAutoFlow: 'column',\n display: 'grid',\n gridGap: '10px',\n },\n columnLabel: {\n width: '100%',\n paddingTop: theme.spacing.unit * 3,\n marginTop: theme.spacing.unit * 2,\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: 'red',\n paddingTop: theme.spacing.unit,\n },\n});\n\nexport default withStyles(styles)(ChoiceEditor);\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,QAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,QAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,OAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,SAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AAAiD,SAAAa,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,aAAAL,OAAA,GAAAM,MAAA,MAAAL,yBAAA,QAAAM,SAAA,OAAAF,gBAAA,mBAAAG,WAAA,EAAAF,MAAA,GAAAG,OAAA,CAAAC,SAAA,CAA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