@pie-element/placement-ordering 7.6.3 → 7.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
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
+ ## [7.7.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@7.7.1...@pie-element/placement-ordering@7.7.2) (2021-11-29)
7
+
8
+ **Note:** Version bump only for package @pie-element/placement-ordering
9
+
10
+
11
+
12
+
13
+
14
+ ## [7.7.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@7.6.4...@pie-element/placement-ordering@7.7.1) (2021-11-11)
15
+
16
+ **Note:** Version bump only for package @pie-element/placement-ordering
17
+
18
+
19
+
20
+
21
+
22
+ # [7.7.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@7.5.2...@pie-element/placement-ordering@7.7.0) (2021-11-11)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **placement-ordering:** fix create correct session for IBX browse items PD-1349 ([e84c30d](https://github.com/pie-framework/pie-elements/commit/e84c30dd075085ef5d917f2893568bca2003d225))
28
+ * **placement-ordering:** fix issues with dragging answer choices in authoring PD-1329 ([286a495](https://github.com/pie-framework/pie-elements/commit/286a495e313cb33227a8672f38331b283c283583))
29
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
30
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
31
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
32
+ * **placement-ordering:** Updated documentation PD-305 ([ff31ac5](https://github.com/pie-framework/pie-elements/commit/ff31ac57139f59413748e88f152ef7629ae6e5be))
33
+
34
+
35
+ ### Features
36
+
37
+ * **placement-ordering:** add baseline validation for authoring PD-600, PD-1334 ([2350279](https://github.com/pie-framework/pie-elements/commit/23502790000e3c4f14e4dae6744519b004eb1172))
38
+ * **placement-ordering:** add shuffle button to UI for authoring PD-1300 ([734fcda](https://github.com/pie-framework/pie-elements/commit/734fcda4b50b50cb54d66789b854f270818ba6fc))
39
+ * **placement-ordering:** added option to set toolbar editor position ([9b1b291](https://github.com/pie-framework/pie-elements/commit/9b1b2916f2c34297f3d4b239e393376f87be3826))
40
+ * **placement-ordering:** remove list buttons from choice labels PD-1337 ([1f1f927](https://github.com/pie-framework/pie-elements/commit/1f1f9276a29d84b551a3eaa93e15738ef1e22681))
41
+
42
+
43
+
44
+
45
+
46
+
47
+ ## [7.6.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@7.6.3...@pie-element/placement-ordering@7.6.4) (2021-11-01)
48
+
49
+ **Note:** Version bump only for package @pie-element/placement-ordering
50
+
51
+
52
+
53
+
54
+
6
55
  ## [7.6.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@7.6.2...@pie-element/placement-ordering@7.6.3) (2021-10-04)
7
56
 
8
57
  **Note:** Version bump only for package @pie-element/placement-ordering
@@ -3,6 +3,53 @@
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
+ ## [5.5.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@5.5.1...@pie-element/placement-ordering-configure@5.5.2) (2021-11-29)
7
+
8
+ **Note:** Version bump only for package @pie-element/placement-ordering-configure
9
+
10
+
11
+
12
+
13
+
14
+ ## [5.5.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@5.4.3...@pie-element/placement-ordering-configure@5.5.1) (2021-11-11)
15
+
16
+ **Note:** Version bump only for package @pie-element/placement-ordering-configure
17
+
18
+
19
+
20
+
21
+
22
+ # [5.5.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@5.3.2...@pie-element/placement-ordering-configure@5.5.0) (2021-11-11)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **placement-ordering:** fix issues with dragging answer choices in authoring PD-1329 ([286a495](https://github.com/pie-framework/pie-elements/commit/286a495e313cb33227a8672f38331b283c283583))
28
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
29
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
30
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
31
+
32
+
33
+ ### Features
34
+
35
+ * **placement-ordering:** add baseline validation for authoring PD-600, PD-1334 ([2350279](https://github.com/pie-framework/pie-elements/commit/23502790000e3c4f14e4dae6744519b004eb1172))
36
+ * **placement-ordering:** add shuffle button to UI for authoring PD-1300 ([734fcda](https://github.com/pie-framework/pie-elements/commit/734fcda4b50b50cb54d66789b854f270818ba6fc))
37
+ * **placement-ordering:** added option to set toolbar editor position ([9b1b291](https://github.com/pie-framework/pie-elements/commit/9b1b2916f2c34297f3d4b239e393376f87be3826))
38
+ * **placement-ordering:** remove list buttons from choice labels PD-1337 ([1f1f927](https://github.com/pie-framework/pie-elements/commit/1f1f9276a29d84b551a3eaa93e15738ef1e22681))
39
+
40
+
41
+
42
+
43
+
44
+
45
+ ## [5.4.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@5.4.2...@pie-element/placement-ordering-configure@5.4.3) (2021-11-01)
46
+
47
+ **Note:** Version bump only for package @pie-element/placement-ordering-configure
48
+
49
+
50
+
51
+
52
+
6
53
  ## [5.4.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@5.4.1...@pie-element/placement-ordering-configure@5.4.2) (2021-10-04)
7
54
 
8
55
  **Note:** Version bump only for package @pie-element/placement-ordering-configure
@@ -5,12 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = void 0;
8
+ exports["default"] = exports.InfoDialog = void 0;
9
9
 
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
 
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
 
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
14
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
17
 
16
18
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -19,6 +21,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
19
21
 
20
22
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
23
 
24
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
25
+
22
26
  var _choiceTile = _interopRequireDefault(require("./choice-tile"));
23
27
 
24
28
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -35,8 +39,18 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
35
39
 
36
40
  var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
37
41
 
42
+ var _shuffle = _interopRequireDefault(require("lodash/shuffle"));
43
+
44
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
45
+
38
46
  var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
39
47
 
48
+ var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
49
+
50
+ var _DialogTitle = _interopRequireDefault(require("@material-ui/core/DialogTitle"));
51
+
52
+ var _DialogActions = _interopRequireDefault(require("@material-ui/core/DialogActions"));
53
+
40
54
  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); }; }
41
55
 
42
56
  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; } }
@@ -45,6 +59,25 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
45
59
 
46
60
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
47
61
 
62
+ var InfoDialog = function InfoDialog(_ref) {
63
+ var title = _ref.title,
64
+ open = _ref.open,
65
+ onOk = _ref.onOk;
66
+ return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
67
+ open: open
68
+ }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, onOk && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
69
+ onClick: onOk,
70
+ color: "primary"
71
+ }, "OK")));
72
+ };
73
+
74
+ exports.InfoDialog = InfoDialog;
75
+ InfoDialog.propTypes = {
76
+ title: _propTypes["default"].string,
77
+ open: _propTypes["default"].bool,
78
+ onOk: _propTypes["default"].func
79
+ };
80
+
48
81
  function findFreeChoiceSlot(choices) {
49
82
  var slot = 1;
50
83
  var ids = choices.map(function (c) {
@@ -60,26 +93,70 @@ function findFreeChoiceSlot(choices) {
60
93
 
61
94
  var log = (0, _debug["default"])('@pie-element:placement-ordering:configure:choice-editor');
62
95
 
63
- function updateResponse(response, from, to) {
64
- var update = (0, _cloneDeep["default"])(response);
65
- var fromType = from.type;
96
+ function updateResponseOrChoices(response, choices, from, to) {
97
+ var fromType = from.type,
98
+ fromIndex = from.index;
66
99
  var toType = to.type,
67
100
  placeAtIndex = to.index;
68
101
 
69
- if (fromType === 'choice' && toType === 'target' || fromType === 'target' && toType === 'target') {
70
- var optionToSwitch = update[placeAtIndex];
71
- var currentPositionOfOption = update.findIndex(function (up) {
72
- return up.id === from.id;
73
- });
74
- var option = update.find(function (up) {
75
- return up.id === from.id;
76
- });
77
- update[placeAtIndex] = option;
78
- update[currentPositionOfOption] = optionToSwitch;
79
- return update;
102
+ if (fromType === 'target' && toType === 'target') {
103
+ var updatedResponse = (0, _cloneDeep["default"])(response) || [];
104
+
105
+ var _updatedResponse$redu = updatedResponse.reduce(function (acc, item, index) {
106
+ if (index === fromIndex) {
107
+ acc.movedItem = item;
108
+ } else {
109
+ acc.remainingItems.push(item);
110
+ }
111
+
112
+ return acc;
113
+ }, {
114
+ movedItem: null,
115
+ remainingItems: []
116
+ }),
117
+ movedItem = _updatedResponse$redu.movedItem,
118
+ remainingItems = _updatedResponse$redu.remainingItems;
119
+
120
+ return {
121
+ response: [].concat((0, _toConsumableArray2["default"])(remainingItems.slice(0, placeAtIndex)), [movedItem], (0, _toConsumableArray2["default"])(remainingItems.slice(placeAtIndex))),
122
+ choices: choices
123
+ };
124
+ }
125
+
126
+ if (fromType === 'choice' && toType === 'choice') {
127
+ var updatedChoices = (0, _cloneDeep["default"])(choices) || [];
128
+
129
+ var _updatedChoices$reduc = updatedChoices.reduce(function (acc, item, index) {
130
+ if (item.id === from.id) {
131
+ acc.movedItem = item;
132
+ } else {
133
+ acc.remainingItems.push(item);
134
+ }
135
+
136
+ if (item.id === to.id) {
137
+ acc.toIndex = index;
138
+ }
139
+
140
+ return acc;
141
+ }, {
142
+ movedItem: null,
143
+ remainingItems: [],
144
+ toIndex: null
145
+ }),
146
+ _movedItem = _updatedChoices$reduc.movedItem,
147
+ _remainingItems = _updatedChoices$reduc.remainingItems,
148
+ toIndex = _updatedChoices$reduc.toIndex;
149
+
150
+ return {
151
+ response: response,
152
+ choices: [].concat((0, _toConsumableArray2["default"])(_remainingItems.slice(0, toIndex)), [_movedItem], (0, _toConsumableArray2["default"])(_remainingItems.slice(toIndex)))
153
+ };
80
154
  }
81
155
 
82
- return response;
156
+ return {
157
+ response: response,
158
+ choices: choices
159
+ };
83
160
  }
84
161
 
85
162
  function buildTiles(choices, response, instanceId) {
@@ -119,6 +196,11 @@ var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
119
196
 
120
197
  (0, _classCallCheck2["default"])(this, ChoiceEditor);
121
198
  _this = _super.call(this, props);
199
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
200
+ dialog: {
201
+ open: false
202
+ }
203
+ });
122
204
  _this.instanceId = (0, _uniqueId["default"])();
123
205
 
124
206
  _this.onChoiceChange = function (choice) {
@@ -140,51 +222,111 @@ var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
140
222
  var _this$props2 = _this.props,
141
223
  choices = _this$props2.choices,
142
224
  onChange = _this$props2.onChange,
143
- correctResponse = _this$props2.correctResponse;
144
- var updatedChoices = choices.filter(function (c) {
145
- return c.id !== choice.id;
146
- });
147
- var updatedCorrectResponse = correctResponse.filter(function (v) {
148
- return v.id !== choice.id;
149
- });
150
- onChange(updatedChoices, updatedCorrectResponse);
225
+ correctResponse = _this$props2.correctResponse,
226
+ choicesLabel = _this$props2.choicesLabel;
227
+
228
+ if (choices && choices.length === 3) {
229
+ _this.setState({
230
+ dialog: {
231
+ open: true,
232
+ message: "There have to be at least 3 ".concat(choicesLabel, "."),
233
+ onOk: function onOk() {
234
+ _this.setState({
235
+ dialog: {
236
+ open: false
237
+ }
238
+ });
239
+ }
240
+ }
241
+ });
242
+ } else {
243
+ var updatedChoices = choices.filter(function (c) {
244
+ return c.id !== choice.id;
245
+ });
246
+ var updatedCorrectResponse = correctResponse.filter(function (v) {
247
+ return v.id !== choice.id;
248
+ });
249
+ onChange(updatedChoices, updatedCorrectResponse);
250
+ }
151
251
  };
152
252
 
153
253
  _this.addChoice = function () {
154
254
  var _this$props3 = _this.props,
155
255
  choices = _this$props3.choices,
156
256
  correctResponse = _this$props3.correctResponse,
157
- onChange = _this$props3.onChange;
158
- var freeId = findFreeChoiceSlot(choices);
159
- var id = "c".concat(freeId);
160
- var newChoice = {
161
- id: id,
162
- label: ''
163
- };
164
- var newCorrectResponse = {
165
- id: id,
166
-
167
- /**
168
- * Note: weights are not configurable in the existing component
169
- * so we'll want do disable this in the controller and ignore it for now.
170
- */
171
- weight: 0
172
- };
173
- var updatedChoices = choices.concat([newChoice]);
174
- var updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
175
- onChange(updatedChoices, updatedCorrectResponse);
257
+ onChange = _this$props3.onChange,
258
+ choicesLabel = _this$props3.choicesLabel;
259
+
260
+ if (choices && choices.length === 10) {
261
+ _this.setState({
262
+ dialog: {
263
+ open: true,
264
+ message: "There can be maximum 10 ".concat(choicesLabel, "."),
265
+ onOk: function onOk() {
266
+ _this.setState({
267
+ dialog: {
268
+ open: false
269
+ }
270
+ });
271
+ }
272
+ }
273
+ });
274
+ } else {
275
+ var freeId = findFreeChoiceSlot(choices);
276
+ var id = "c".concat(freeId);
277
+ var newChoice = {
278
+ id: id,
279
+ label: ''
280
+ };
281
+ var newCorrectResponse = {
282
+ id: id,
283
+
284
+ /**
285
+ * Note: weights are not configurable in the existing component
286
+ * so we'll want do disable this in the controller and ignore it for now.
287
+ */
288
+ weight: 0
289
+ };
290
+ var updatedChoices = choices.concat([newChoice]);
291
+ var updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
292
+ onChange(updatedChoices, updatedCorrectResponse);
293
+ }
176
294
  };
177
295
 
178
- _this.onDropChoice = function (ordering, target, source) {
296
+ _this.shuffleChoices = function () {
179
297
  var _this$props4 = _this.props,
180
298
  onChange = _this$props4.onChange,
181
- choices = _this$props4.choices;
299
+ choices = _this$props4.choices,
300
+ correctResponse = _this$props4.correctResponse,
301
+ placementArea = _this$props4.placementArea;
302
+ var shuffled = (0, _shuffle["default"])(choices); // if placementArea is disabled, make sure we don't shuffle choices in the correct order
303
+
304
+ var shuffledCorrect = !placementArea && (0, _isEqual["default"])(shuffled.map(function (item) {
305
+ return item.id;
306
+ }), correctResponse.map(function (item) {
307
+ return item.id;
308
+ }));
309
+
310
+ if (shuffledCorrect) {
311
+ var shuffledTwice = (0, _shuffle["default"])(shuffled);
312
+ onChange(shuffledTwice, correctResponse);
313
+ } else {
314
+ onChange(shuffled, correctResponse);
315
+ }
316
+ };
317
+
318
+ _this.onDropChoice = function (ordering, target, source) {
319
+ var onChange = _this.props.onChange;
182
320
  var from = ordering.tiles.find(function (t) {
183
321
  return t.id === source.id && t.type === source.type;
184
322
  });
185
323
  var to = target;
186
324
  log('[onDropChoice] ', from, to);
187
- var response = updateResponse(ordering.response, from, to);
325
+
326
+ var _updateResponseOrChoi = updateResponseOrChoices(ordering.response, ordering.choices, from, to),
327
+ response = _updateResponseOrChoi.response,
328
+ choices = _updateResponseOrChoi.choices;
329
+
188
330
  onChange(choices, response);
189
331
  };
190
332
 
@@ -202,7 +344,11 @@ var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
202
344
  choices = _this$props5.choices,
203
345
  imageSupport = _this$props5.imageSupport,
204
346
  disableImages = _this$props5.disableImages,
205
- toolbarOpts = _this$props5.toolbarOpts;
347
+ toolbarOpts = _this$props5.toolbarOpts,
348
+ singularChoiceLabel = _this$props5.singularChoiceLabel,
349
+ pluralChoiceLabel = _this$props5.pluralChoiceLabel,
350
+ choicesLabel = _this$props5.choicesLabel;
351
+ var dialog = this.state.dialog;
206
352
  var ordering = {
207
353
  choices: choices,
208
354
  response: !correctResponse || (0, _isEmpty["default"])(correctResponse) ? new Array(choices.length) : correctResponse,
@@ -229,11 +375,22 @@ var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
229
375
  return _this2.onDropChoice(ordering, c, source, index);
230
376
  },
231
377
  disableImages: disableImages,
232
- toolbarOpts: toolbarOpts
378
+ toolbarOpts: toolbarOpts,
379
+ choices: choices,
380
+ choicesLabel: choicesLabel
233
381
  });
234
382
  })), /*#__PURE__*/_react["default"].createElement("div", {
235
383
  className: classes.controls
236
384
  }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
385
+ onClick: this.shuffleChoices,
386
+ size: "small",
387
+ variant: "contained",
388
+ color: "default",
389
+ classes: {
390
+ root: classes.addButtonRoot,
391
+ label: classes.addButtonLabel
392
+ }
393
+ }, "SHUFFLE ".concat(pluralChoiceLabel).toUpperCase()), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
237
394
  onClick: this.addChoice,
238
395
  size: "small",
239
396
  variant: "contained",
@@ -242,7 +399,11 @@ var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
242
399
  root: classes.addButtonRoot,
243
400
  label: classes.addButtonLabel
244
401
  }
245
- }, "ADD CHOICE")));
402
+ }, "ADD ".concat(singularChoiceLabel).toUpperCase())), /*#__PURE__*/_react["default"].createElement(InfoDialog, {
403
+ title: dialog.message,
404
+ open: dialog.open,
405
+ onOk: dialog.onOk
406
+ }));
246
407
  }
247
408
  }]);
248
409
  return ChoiceEditor;
@@ -258,7 +419,11 @@ var ChoiceEditor = /*#__PURE__*/function (_React$Component) {
258
419
  "delete": _propTypes["default"].func.isRequired
259
420
  }),
260
421
  disableImages: _propTypes["default"].bool,
261
- toolbarOpts: _propTypes["default"].object
422
+ toolbarOpts: _propTypes["default"].object,
423
+ placementArea: _propTypes["default"].bool,
424
+ singularChoiceLabel: _propTypes["default"].string,
425
+ pluralChoiceLabel: _propTypes["default"].string,
426
+ choicesLabel: _propTypes["default"].string
262
427
  });
263
428
 
264
429
  var styles = function styles(theme) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/choice-editor.jsx"],"names":["findFreeChoiceSlot","choices","slot","ids","map","c","id","includes","log","updateResponse","response","from","to","update","fromType","type","toType","placeAtIndex","index","optionToSwitch","currentPositionOfOption","findIndex","up","option","find","buildTiles","instanceId","targets","r","respId","choice","undefined","draggable","editable","processedChoices","m","Object","assign","droppable","concat","ChoiceEditor","props","onChoiceChange","onChange","correctResponse","toolbarOpts","splice","label","onDelete","updatedChoices","filter","updatedCorrectResponse","v","addChoice","freeId","newChoice","newCorrectResponse","weight","onDropChoice","ordering","target","source","tiles","t","classes","imageSupport","disableImages","Array","length","style","gridTemplateColumns","gridTemplateRows","choiceEditor","vtiler","bind","controls","root","addButtonRoot","addButtonLabel","React","Component","PropTypes","object","isRequired","array","func","shape","add","bool","styles","theme","allToggle","marginTop","display","alignItems","justifyContent","width","height","fill","palette","primary","paddingHorizontal","transition","opacity","gridAutoFlow","gridGap"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,SAASA,kBAAT,CAA4BC,OAA5B,EAAqC;AACnC,MAAIC,IAAI,GAAG,CAAX;AACA,MAAMC,GAAG,GAAGF,OAAO,CAACG,GAAR,CAAY,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,EAAN;AAAA,GAAb,CAAZ;;AACA,SAAOH,GAAG,CAACI,QAAJ,YAAiBL,IAAjB,EAAP,EAAiC;AAC/BA,IAAAA,IAAI;AACL;;AACD,SAAOA,IAAP;AACD;;AAED,IAAMM,GAAG,GAAG,uBAAM,yDAAN,CAAZ;;AAEA,SAASC,cAAT,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwCC,EAAxC,EAA4C;AAC1C,MAAMC,MAAM,GAAG,2BAAUH,QAA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Q;AAmBvBvB,IAAAA,cAAc,EAAE;AACdwB,MAAAA,UAAU,EAAE,sBADE;AAEd,iBAAW;AACTC,QAAAA,OAAO,EAAE;AADA;AAFG,KAnBO;AAyBvB9B,IAAAA,MAAM,EAAE;AACN+B,MAAAA,YAAY,EAAE,QADR;AAENX,MAAAA,OAAO,EAAE,MAFH;AAGNY,MAAAA,OAAO,EAAE;AAHH;AAzBe,GAAL;AAAA,CAApB;;eAgCe,wBAAWhB,MAAX,EAAmBjD,YAAnB,C","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 Button from '@material-ui/core/Button';\n\nfunction findFreeChoiceSlot(choices) {\n let slot = 1;\n const ids = choices.map(c => c.id);\n while (ids.includes(`c${slot}`)) {\n slot++;\n }\n return slot;\n}\n\nconst log = debug('@pie-element:placement-ordering:configure:choice-editor');\n\nfunction updateResponse(response, from, to) {\n const update = cloneDeep(response);\n const { type: fromType } = from;\n const { type: toType, index: placeAtIndex } = to;\n\n if ((fromType === 'choice' && toType === 'target') || (fromType === 'target' && toType === 'target')) {\n const optionToSwitch = update[placeAtIndex];\n\n const currentPositionOfOption = update.findIndex(up => up.id === from.id);\n const option = update.find(up => up.id === from.id);\n\n update[placeAtIndex] = option;\n update[currentPositionOfOption] = optionToSwitch;\n\n return update;\n }\n\n return response;\n}\n\nfunction buildTiles(choices, response, instanceId) {\n const targets = response.map((r, index) => {\n const respId = r && r.id;\n\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 };\n\n constructor(props) {\n super(props);\n\n this.instanceId = uniqueId();\n\n this.onChoiceChange = choice => {\n const { choices, onChange, correctResponse, toolbarOpts } = 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 } = this.props;\n const updatedChoices = choices.filter(c => c.id !== choice.id);\n const updatedCorrectResponse = correctResponse.filter(\n v => v.id !== choice.id\n );\n onChange(updatedChoices, updatedCorrectResponse);\n };\n\n this.addChoice = () => {\n const { choices, correctResponse, onChange } = this.props;\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([\n newCorrectResponse\n ]);\n\n onChange(updatedChoices, updatedCorrectResponse);\n };\n\n this.onDropChoice = (ordering, target, source) => {\n const { onChange, choices } = this.props;\n const from = ordering.tiles.find(\n t => t.id === source.id && t.type === source.type\n );\n const to = target;\n log('[onDropChoice] ', from, to);\n const response = updateResponse(ordering.response, from, to);\n\n onChange(choices, response);\n };\n }\n\n render() {\n const { classes, correctResponse, choices, imageSupport, disableImages, toolbarOpts } = this.props;\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 style = {\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={style}>\n\n {ordering.tiles.map((c, index) => (\n <ChoiceTile\n choice={c}\n index={index}\n key={index}\n imageSupport={imageSupport}\n onDelete={this.onDelete.bind(this, c)}\n onChoiceChange={this.onChoiceChange}\n onDropChoice={(source, index) => this.onDropChoice(ordering, c, source, index)}\n disableImages={disableImages}\n toolbarOpts={toolbarOpts}\n />\n ))}\n </div>\n <div className={classes.controls}>\n <Button\n onClick={this.addChoice}\n size=\"small\"\n variant=\"contained\"\n color=\"default\"\n classes={{\n root: classes.addButtonRoot,\n label: classes.addButtonLabel\n }}\n >\n ADD CHOICE\n </Button>\n </div>\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n allToggle: {},\n choiceEditor: {\n marginTop: '10px'\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: '24px',\n paddingHorizontal: '12px'\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});\n\nexport default withStyles(styles)(ChoiceEditor);\n"],"file":"choice-editor.js"}
1
+ {"version":3,"sources":["../src/choice-editor.jsx"],"names":["InfoDialog","title","open","onOk","propTypes","PropTypes","string","bool","func","findFreeChoiceSlot","choices","slot","ids","map","c","id","includes","log","updateResponseOrChoices","response","from","to","fromType","type","fromIndex","index","toType","placeAtIndex","updatedResponse","reduce","acc","item","movedItem","remainingItems","push","slice","updatedChoices","toIndex","buildTiles","instanceId","targets","r","respId","choice","find","undefined","draggable","editable","processedChoices","m","Object","assign","droppable","concat","ChoiceEditor","props","dialog","onChoiceChange","onChange","correctResponse","toolbarOpts","findIndex","splice","label","onDelete","choicesLabel","length","setState","message","filter","updatedCorrectResponse","v","addChoice","freeId","newChoice","newCorrectResponse","weight","shuffleChoices","placementArea","shuffled","shuffledCorrect","shuffledTwice","onDropChoice","ordering","target","source","tiles","t","classes","imageSupport","disableImages","singularChoiceLabel","pluralChoiceLabel","state","Array","style","gridTemplateColumns","gridTemplateRows","choiceEditor","vtiler","bind","controls","root","addButtonRoot","addButtonLabel","toUpperCase","React","Component","object","isRequired","array","shape","add","styles","theme","allToggle","marginTop","display","alignItems","justifyContent","width","height","fill","palette","primary","paddingHorizontal","transition","opacity","gridAutoFlow","gridGap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEO,IAAMA,UAAU,GAAG,SAAbA,UAAa;AAAA,MAAGC,KAAH,QAAGA,KAAH;AAAA,MAAUC,IAAV,QAAUA,IAAV;AAAA,MAAgBC,IAAhB,QAAgBA,IAAhB;AAAA,sBACxB,gCAAC,kBAAD;AAAQ,IAAA,IAAI,EAAED;AAAd,kBACE,gCAAC,uBAAD,QAAcD,KAAd,CADF,eAEE,gCAAC,yBAAD,QACGE,IAAI,iBACH,gCAAC,kBAAD;AAAQ,IAAA,OAAO,EAAEA,IAAjB;AAAuB,IAAA,KAAK,EAAC;AAA7B,UAFJ,CAFF,CADwB;AAAA,CAAnB;;;AAaPH,UAAU,CAACI,SAAX,GAAuB;AACrBH,EAAAA,KAAK,EAAEI,sBAAUC,MADI;AAErBJ,EAAAA,IAAI,EAAEG,sBAAUE,IAFK;AAGrBJ,EAAAA,IAAI,EAAEE,sBAAUG;AAHK,CAAvB;;AAMA,SAASC,kBAAT,CAA4BC,OAA5B,EAAqC;AACnC,MAAIC,IAAI,GAAG,CAAX;AACA,MAAMC,GAAG,GAAGF,OAAO,CAACG,GAAR,CAAY,UAAAC,CAAC;AAAA,W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rB,IAAM2G,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,SAAS,EAAE,EADY;AAEvBjB,IAAAA,YAAY,EAAE;AACZkB,MAAAA,SAAS,EAAE;AADC,KAFS;AAKvBf,IAAAA,QAAQ,EAAE;AACRgB,MAAAA,OAAO,EAAE,MADD;AAERC,MAAAA,UAAU,EAAE,QAFJ;AAGRC,MAAAA,cAAc,EAAE;AAHR,KALa;AAUvBjB,IAAAA,IAAI,EAAE;AACJkB,MAAAA,KAAK,EAAE,MADH;AAEJC,MAAAA,MAAM,EAAE,MAFJ;AAGJC,MAAAA,IAAI,EAAER,KAAK,CAACS,OAAN,CAAcC,OAAd,CAAsB,GAAtB;AAHF,KAViB;AAevBrB,IAAAA,aAAa,EAAE;AACba,MAAAA,SAAS,EAAE,MADE;AAEbS,MAAAA,iBAAiB,EAAE;AAFN,KAfQ;AAmBvBrB,IAAAA,cAAc,EAAE;AACdsB,MAAAA,UAAU,EAAE,sBADE;AAEd,iBAAW;AACTC,QAAAA,OAAO,EAAE;AADA;AAFG,KAnBO;AAyBvB5B,IAAAA,MAAM,EAAE;AACN6B,MAAAA,YAAY,EAAE,QADR;AAENX,MAAAA,OAAO,EAAE,MAFH;AAGNY,MAAAA,OAAO,EAAE;AAHH;AAzBe,GAAL;AAAA,CAApB;;eAgCe,wBAAWhB,MAAX,EAAmB3D,YAAnB,C","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 Dialog from '@material-ui/core/Dialog';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport DialogActions from '@material-ui/core/DialogActions';\n\nexport const InfoDialog = ({ title, open, onOk }) => (\n <Dialog open={open}>\n <DialogTitle>{title}</DialogTitle>\n <DialogActions>\n {onOk && (\n <Button onClick={onOk} color=\"primary\">\n OK\n </Button>\n )}\n </DialogActions>\n </Dialog>\n);\n\nInfoDialog.propTypes = {\n title: PropTypes.string,\n open: PropTypes.bool,\n onOk: PropTypes.func,\n};\n\nfunction findFreeChoiceSlot(choices) {\n let slot = 1;\n const ids = choices.map(c => c.id);\n while (ids.includes(`c${slot}`)) {\n slot++;\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: [\n ...remainingItems.slice(0, placeAtIndex),\n movedItem,\n ...remainingItems.slice(placeAtIndex)\n ],\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: [\n ...remainingItems.slice(0, toIndex),\n movedItem,\n ...remainingItems.slice(toIndex)\n ]\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\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 };\n\n state = {\n dialog: {\n open: false\n }\n };\n\n constructor(props) {\n super(props);\n\n this.instanceId = uniqueId();\n\n this.onChoiceChange = choice => {\n const { choices, onChange, correctResponse, toolbarOpts } = 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 dialog: {\n open: true,\n message: `There have to be at least 3 ${choicesLabel}.`,\n onOk: () => {\n this.setState(\n {\n dialog: {\n open: false,\n }\n }\n );\n }\n }\n });\n }\n else {\n const updatedChoices = choices.filter(c => c.id !== choice.id);\n const updatedCorrectResponse = correctResponse.filter(\n 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 dialog: {\n open: true,\n message: `There can be maximum 10 ${choicesLabel}.`,\n onOk: () => {\n this.setState(\n {\n dialog: {\n open: false,\n }\n }\n );\n }\n }\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([\n newCorrectResponse\n ]);\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 = !placementArea && isEqual(shuffled.map(item => item.id), correctResponse.map(item => item.id));\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(\n t => t.id === source.id && t.type === source.type\n );\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 } = this.props;\n const { dialog } = this.state;\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 style = {\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={style}>\n\n {ordering.tiles.map((c, index) => (\n <ChoiceTile\n choice={c}\n index={index}\n key={index}\n imageSupport={imageSupport}\n onDelete={this.onDelete.bind(this, c)}\n onChoiceChange={this.onChoiceChange}\n onDropChoice={(source, index) => this.onDropChoice(ordering, c, source, index)}\n disableImages={disableImages}\n toolbarOpts={toolbarOpts}\n choices={choices}\n choicesLabel={choicesLabel}\n />\n ))}\n </div>\n <div className={classes.controls}>\n <Button\n onClick={this.shuffleChoices}\n size=\"small\"\n variant=\"contained\"\n color=\"default\"\n classes={{\n root: classes.addButtonRoot,\n label: classes.addButtonLabel\n }}\n >\n {`SHUFFLE ${pluralChoiceLabel}`.toUpperCase()}\n </Button>\n <Button\n onClick={this.addChoice}\n size=\"small\"\n variant=\"contained\"\n color=\"default\"\n classes={{\n root: classes.addButtonRoot,\n label: classes.addButtonLabel\n }}\n >\n {`ADD ${singularChoiceLabel}`.toUpperCase()}\n </Button>\n </div>\n <InfoDialog\n title={dialog.message}\n open={dialog.open}\n onOk={dialog.onOk}\n />\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n allToggle: {},\n choiceEditor: {\n marginTop: '10px'\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: '24px',\n paddingHorizontal: '12px'\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});\n\nexport default withStyles(styles)(ChoiceEditor);\n"],"file":"choice-editor.js"}
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -21,7 +23,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
21
23
 
22
24
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
25
 
24
- var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
26
+ var _editableHtml = _interopRequireWildcard(require("@pie-lib/editable-html"));
25
27
 
26
28
  var _CardActions = _interopRequireDefault(require("@material-ui/core/CardActions"));
27
29
 
@@ -43,6 +45,12 @@ var _debug = _interopRequireDefault(require("debug"));
43
45
 
44
46
  var _styles = require("@material-ui/core/styles");
45
47
 
48
+ var _choiceEditor = require("./choice-editor");
49
+
50
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
51
+
52
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
53
+
46
54
  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); }; }
47
55
 
48
56
  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; } }
@@ -64,12 +72,43 @@ var ChoiceTile = /*#__PURE__*/function (_React$Component) {
64
72
  }
65
73
 
66
74
  _this = _super.call.apply(_super, [this].concat(args));
75
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
76
+ dialog: {
77
+ open: false
78
+ }
79
+ });
67
80
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLabelChange", function (label) {
68
81
  var _this$props = _this.props,
69
82
  choice = _this$props.choice,
70
- onChoiceChange = _this$props.onChoiceChange;
71
- choice.label = label;
72
- onChoiceChange(choice);
83
+ onChoiceChange = _this$props.onChoiceChange,
84
+ choices = _this$props.choices,
85
+ choicesLabel = _this$props.choicesLabel;
86
+ var currentValue = choice.label;
87
+ var sameValue = choices.filter(function (choice) {
88
+ var wasChanged = currentValue !== label && "<div>".concat(currentValue, "</div>") !== label;
89
+ var sameValueEntered = choice.label === label || "<div>".concat(choice.label, "</div>") === label;
90
+ return wasChanged && sameValueEntered;
91
+ });
92
+ var empty = label === '<div></div>';
93
+
94
+ if (sameValue.length || empty) {
95
+ _this.setState({
96
+ dialog: {
97
+ open: true,
98
+ message: "Each of the ".concat(choicesLabel, " must be non-empty and unique."),
99
+ onOk: function onOk() {
100
+ _this.setState({
101
+ dialog: {
102
+ open: false
103
+ }
104
+ });
105
+ }
106
+ }
107
+ });
108
+ } else {
109
+ choice.label = label;
110
+ onChoiceChange(choice);
111
+ }
73
112
  });
74
113
  return _this;
75
114
  }
@@ -89,6 +128,7 @@ var ChoiceTile = /*#__PURE__*/function (_React$Component) {
89
128
  imageSupport = _this$props2.imageSupport,
90
129
  disableImages = _this$props2.disableImages,
91
130
  toolbarOpts = _this$props2.toolbarOpts;
131
+ var dialog = this.state.dialog;
92
132
  var dragSourceOpts = {}; //dropEffect: moveOnDrag ? 'move' : 'copy'};
93
133
 
94
134
  var choicePlugins = {
@@ -102,6 +142,9 @@ var ChoiceTile = /*#__PURE__*/function (_React$Component) {
102
142
  disabled: true
103
143
  }
104
144
  };
145
+ var filteredDefaultPlugins = (_editableHtml.DEFAULT_PLUGINS || []).filter(function (p) {
146
+ return p !== 'bulleted-list' && p !== 'numbered-list';
147
+ });
105
148
  var opacity = isDragging ? 0 : 1;
106
149
 
107
150
  var markup = /*#__PURE__*/_react["default"].createElement("div", {
@@ -122,7 +165,9 @@ var ChoiceTile = /*#__PURE__*/function (_React$Component) {
122
165
  imageSupport: imageSupport || undefined,
123
166
  onChange: this.onLabelChange,
124
167
  pluginProps: choicePlugins,
125
- toolbarOpts: toolbarOpts
168
+ toolbarOpts: toolbarOpts,
169
+ activePlugins: filteredDefaultPlugins,
170
+ allowValidation: true
126
171
  }), editable && /*#__PURE__*/_react["default"].createElement("div", {
127
172
  className: classes.controls
128
173
  }, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
@@ -132,7 +177,11 @@ var ChoiceTile = /*#__PURE__*/function (_React$Component) {
132
177
  classes: {
133
178
  root: classes.removeCircle
134
179
  }
135
- }))));
180
+ }))), /*#__PURE__*/_react["default"].createElement(_choiceEditor.InfoDialog, {
181
+ title: dialog.message,
182
+ open: dialog.open,
183
+ onOk: dialog.onOk
184
+ }));
136
185
 
137
186
  return connectDragSource(connectDropTarget( /*#__PURE__*/_react["default"].createElement("div", null, markup)), dragSourceOpts);
138
187
  }
@@ -159,10 +208,12 @@ exports.ChoiceTile = ChoiceTile;
159
208
  "delete": _propTypes["default"].func.isRequired
160
209
  }),
161
210
  choice: _propTypes["default"].object,
211
+ choices: _propTypes["default"].array.isRequired,
162
212
  onChoiceChange: _propTypes["default"].func.isRequired,
163
213
  onDelete: _propTypes["default"].func.isRequired,
164
214
  disableImages: _propTypes["default"].bool,
165
- toolbarOpts: _propTypes["default"].object
215
+ toolbarOpts: _propTypes["default"].object,
216
+ choicesLabel: _propTypes["default"].string
166
217
  });
167
218
  var Styled = (0, _styles.withStyles)(function (theme) {
168
219
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/choice-tile.jsx"],"names":["log","ChoiceTile","label","props","choice","onChoiceChange","editable","isDragging","connectDragSource","connectDropTarget","classes","onDelete","imageSupport","disableImages","toolbarOpts","dragSourceOpts","choicePlugins","image","disabled","audio","video","opacity","markup","choiceTile","width","dragHandle","actions","prompt","targetPrompt","undefined","onLabelChange","controls","root","removeCircle","React","Component","PropTypes","func","isRequired","bool","id","any","string","isOver","object","type","empty","outcome","index","number","shape","add","Styled","theme","fill","palette","error","cursor","backgroundColor","marginTop","marginBottom","display","alignItems","justifyContent","border","color","NAME","choiceSource","beginDrag","instanceId","StyledSource","connect","monitor","dragSource","choiceTarget","hover","drop","item","getItem","didDrop","onDropChoice","StyledSourceAndTarget","dropTarget"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uDAAN,CAAZ;;IAEaC,U;;;;;;;;;;;;;;;sGAyBK,UAAAC,KAAK,EAAI;AACvB,wBAAmC,MAAKC,KAAxC;AAAA,UAAQC,MAAR,eAAQA,MAAR;AAAA,UAAgBC,cAAhB,eAAgBA,cAAhB;AACAD,MAAAA,MAAM,CAACF,KAAP,GAAeA,KAAf;AACAG,MAAAA,cAAc,CAACD,MAAD,CAAd;AACD,K;;;;;;WAED,kBAAS;AACP,yBAaI,KAAKD,KAbT;AAAA,6CACEC,MADF;AAAA,UAEIF,KAFJ,uBAEIA,KAFJ;AAAA,UAGII,QAHJ,uBAGIA,QAHJ;AAAA,UAKEC,UALF,gBAKEA,UALF;AAAA,UAMEC,iBANF,gBAMEA,iBANF;AAAA,UAOEC,iBAPF,gBAOEA,iBAPF;AAAA,UAQEC,OARF,gBAQEA,OARF;AAAA,UASEC,QATF,gBASEA,QATF;AAAA,UAUEC,YAVF,gBAUEA,YAVF;AAAA,UAWEC,aAXF,gBAWEA,aAXF;AAA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J,IAAX,EAAiBC,YAAjB,EAA+B,UAACI,OAAD,EAAUC,OAAV;AAAA,SAAuB;AACzEhE,IAAAA,iBAAiB,EAAE+D,OAAO,CAACE,UAAR,EADsD;AAEzElE,IAAAA,UAAU,EAAEiE,OAAO,CAACjE,UAAR;AAF6D,GAAvB;AAAA,CAA/B,EAGjB6C,MAHiB,CAArB;AAKA,IAAMsB,YAAY,GAAG;AACnBC,EAAAA,KADmB,mBACX;AACN3E,IAAAA,GAAG,CAAC,SAAD,CAAH;AACD,GAHkB;AAInB4E,EAAAA,IAJmB,gBAIdzE,KAJc,EAIPqE,OAJO,EAIE;AACnB,QAAMK,IAAI,GAAGL,OAAO,CAACM,OAAR,EAAb;AACA9E,IAAAA,GAAG,CAAC,eAAD,EAAkB6E,IAAlB,EAAwB,UAAxB,EAAoCL,OAAO,CAACO,OAAR,EAApC,CAAH;AAEA5E,IAAAA,KAAK,CAAC6E,YAAN,CAAmBH,IAAnB,EAAyB1E,KAAK,CAAC6C,KAA/B;AACD;AATkB,CAArB;AAYA,IAAMiC,qBAAqB,GAAG,0BAAWf,IAAX,EAAiBQ,YAAjB,EAA+B,UAACH,OAAD,EAAUC,OAAV;AAAA,SAAuB;AAClF/D,IAAAA,iBAAiB,EAAE8D,OAAO,CAACW,UAAR,EAD+D;AAElFvC,IAAAA,MAAM,EAAE6B,OAAO,CAAC7B,MAAR;AAF0E,GAAvB;AAAA,CAA/B,EAG1B2B,YAH0B,CAA9B;eAKeW,qB","sourcesContent":["import EditableHtml from '@pie-lib/editable-html';\nimport CardActions from '@material-ui/core/CardActions';\nimport DragHandle from '@material-ui/icons/DragHandle';\n\nimport { DragSource, DropTarget } from 'react-dnd';\nimport classNames from 'classnames';\n\nimport IconButton from '@material-ui/core/IconButton';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport RemoveCircle from '@material-ui/icons/RemoveCircle';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst log = debug('@pie-element:placement-ordering:configure:choice-tile');\n\nexport class ChoiceTile extends React.Component {\n static propTypes = {\n connectDragSource: PropTypes.func.isRequired,\n connectDropTarget: PropTypes.func.isRequired,\n isDragging: PropTypes.bool.isRequired,\n id: PropTypes.any,\n label: PropTypes.string,\n isOver: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n type: PropTypes.string,\n empty: PropTypes.bool,\n disabled: PropTypes.bool,\n outcome: PropTypes.object,\n index: PropTypes.number,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n }),\n choice: PropTypes.object,\n onChoiceChange: PropTypes.func.isRequired,\n onDelete: PropTypes.func.isRequired,\n disableImages: PropTypes.bool,\n toolbarOpts: PropTypes.object\n };\n\n onLabelChange = label => {\n const { choice, onChoiceChange } = this.props;\n choice.label = label;\n onChoiceChange(choice);\n };\n\n render() {\n const {\n choice: {\n label,\n editable\n },\n isDragging,\n connectDragSource,\n connectDropTarget,\n classes,\n onDelete,\n imageSupport,\n disableImages,\n toolbarOpts\n } = this.props;\n\n const dragSourceOpts = {}; //dropEffect: moveOnDrag ? 'move' : 'copy'};\n\n const choicePlugins = {\n image: {\n disabled: disableImages\n },\n audio: { disabled: true },\n video: { disabled: true }\n };\n\n const opacity = isDragging ? 0 : 1;\n const markup = (\n <div className={classes.choiceTile} style={{ opacity: opacity, width: '100%' }}>\n <CardActions>\n <span className={classNames(classes.dragHandle )}>\n <DragHandle className={classes.actions} />\n </span>\n </CardActions>\n <EditableHtml\n disabled={!editable}\n className={classNames(classes.prompt, !editable && classes.targetPrompt)}\n placeholder=\"Enter a choice\"\n markup={label}\n imageSupport={imageSupport || undefined}\n onChange={this.onLabelChange}\n pluginProps={choicePlugins}\n toolbarOpts={toolbarOpts}\n />\n {editable && (\n <div className={classes.controls}>\n <IconButton color='default' onClick={onDelete}>\n <RemoveCircle\n classes={{\n root: classes.removeCircle\n }}\n />\n </IconButton>\n </div>\n )}\n </div>\n );\n\n\n return connectDragSource(\n connectDropTarget(\n <div>\n {markup}\n </div>\n ),\n dragSourceOpts\n );\n }\n}\n\nconst Styled = withStyles(theme => ({\n removeCircle: {\n fill: theme.palette.error[500]\n },\n choiceTile: {\n cursor: 'move',\n backgroundColor: 'white',\n marginTop: '5px',\n marginBottom: '5px',\n display: 'flex',\n alignItems: 'center'\n },\n controls: {\n display: 'flex',\n justifyContent: 'flex-end'\n },\n prompt: {\n width: '80%',\n border: 'none',\n },\n targetPrompt: {\n backgroundColor: '#D7D7D7'\n },\n actions: {\n color: '#B1B1B1'\n }\n}))(ChoiceTile);\n\nconst NAME = 'choice-config';\n\nconst choiceSource = {\n beginDrag(props) {\n return {\n id: props.choice.id,\n index: props.index,\n type: props.choice.type,\n instanceId: props.choice.instanceId\n };\n }\n};\n\nconst StyledSource = DragSource(NAME, choiceSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging()\n}))(Styled);\n\nconst choiceTarget = {\n hover() {\n log('[hover]');\n },\n drop(props, monitor) {\n const item = monitor.getItem();\n log('[drop] item: ', item, 'didDrop?', monitor.didDrop());\n\n props.onDropChoice(item, props.index);\n }\n};\n\nconst StyledSourceAndTarget = DropTarget(NAME, choiceTarget, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver()\n}))(StyledSource);\n\nexport default StyledSourceAndTarget;\n"],"file":"choice-tile.js"}
1
+ {"version":3,"sources":["../src/choice-tile.jsx"],"names":["log","ChoiceTile","dialog","open","label","props","choice","onChoiceChange","choices","choicesLabel","currentValue","sameValue","filter","wasChanged","sameValueEntered","empty","length","setState","message","onOk","editable","isDragging","connectDragSource","connectDropTarget","classes","onDelete","imageSupport","disableImages","toolbarOpts","state","dragSourceOpts","choicePlugins","image","disabled","audio","video","filteredDefaultPlugins","DEFAULT_PLUGINS","p","opacity","markup","choiceTile","width","dragHandle","actions","prompt","targetPrompt","undefined","onLabelChange","controls","root","removeCircle","React","Component","PropTypes","func","isRequired","bool","id","any","string","isOver","object","type","outcome","index","number","shape","add","array","Styled","theme","fill","palette","error","cursor","backgroundColor","marginTop","marginBottom","display","alignItems","justifyContent","border","color","NAME","choiceSource","beginDrag","instanceId","StyledSource","connect","monitor","dragSource","choiceTarget","hover","drop","item","getItem","didDrop","onDropChoice","StyledSourceAndTarget","dropTarget"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uDAAN,CAAZ;;IAEaC,U;;;;;;;;;;;;;;;8FA2BH;AACNC,MAAAA,MAAM,EAAE;AACNC,QAAAA,IAAI,EAAE;AADA;AADF,K;sGAMQ,UAAAC,KAAK,EAAI;AACvB,wBAA0D,MAAKC,KAA/D;AAAA,UAAQC,MAAR,eAAQA,MAAR;AAAA,UAAgBC,cAAhB,eAAgBA,cAAhB;AAAA,UAAgCC,OAAhC,eAAgCA,OAAhC;AAAA,UAAyCC,YAAzC,eAAyCA,YAAzC;AACA,UAAMC,YAAY,GAAGJ,MAAM,CAACF,KAA5B;AACA,UAAMO,SAAS,GAAGH,OAAO,CAACI,MAAR,CAAe,UAAAN,MAAM,EAAI;AACzC,YAAMO,UAAU,GAAGH,YAAY,KAAKN,KAAjB,IAA0B,eAAQM,YAAR,gBAAiCN,KAA9E;AACA,YAAMU,gBAAgB,GAAGR,MAAM,CAACF,KAAP,KAAiBA,KAAjB,IAA0B,eAAQE,MAAM,CAACF,KAAf,gBAAiCA,KAApF;AAEA,eAAOS,UAAU,IAAIC,gBAArB;AACD,OALiB,CAAlB;AAOA,UAAMC,KAAK,GAAGX,KAAK,KAAK,aAAxB;;AAEA,UAAIO,SAAS,CAACK,MAAV,IAAoBD,KAAxB,EAA+B;AAC7B,cAAKE,QAAL,CAAc;AACZf,UAAAA,MAAM,EAAE;AACNC,YAAAA,IAAI,EAAE,IADA;AAENe,YAAAA,OAAO,wBAAiBT,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B,EAA+B,UAACI,OAAD,EAAUC,OAAV;AAAA,SAAuB;AACzEpE,IAAAA,iBAAiB,EAAEmE,OAAO,CAACE,UAAR,EADsD;AAEzEtE,IAAAA,UAAU,EAAEqE,OAAO,CAACrE,UAAR;AAF6D,GAAvB;AAAA,CAA/B,EAGjBiD,MAHiB,CAArB;AAKA,IAAMsB,YAAY,GAAG;AACnBC,EAAAA,KADmB,mBACX;AACN7F,IAAAA,GAAG,CAAC,SAAD,CAAH;AACD,GAHkB;AAInB8F,EAAAA,IAJmB,gBAIdzF,KAJc,EAIPqF,OAJO,EAIE;AACnB,QAAMK,IAAI,GAAGL,OAAO,CAACM,OAAR,EAAb;AACAhG,IAAAA,GAAG,CAAC,eAAD,EAAkB+F,IAAlB,EAAwB,UAAxB,EAAoCL,OAAO,CAACO,OAAR,EAApC,CAAH;AAEA5F,IAAAA,KAAK,CAAC6F,YAAN,CAAmBH,IAAnB,EAAyB1F,KAAK,CAAC4D,KAA/B;AACD;AATkB,CAArB;AAYA,IAAMkC,qBAAqB,GAAG,0BAAWf,IAAX,EAAiBQ,YAAjB,EAA+B,UAACH,OAAD,EAAUC,OAAV;AAAA,SAAuB;AAClFnE,IAAAA,iBAAiB,EAAEkE,OAAO,CAACW,UAAR,EAD+D;AAElFvC,IAAAA,MAAM,EAAE6B,OAAO,CAAC7B,MAAR;AAF0E,GAAvB;AAAA,CAA/B,EAG1B2B,YAH0B,CAA9B;eAKeW,qB","sourcesContent":["import EditableHtml, { DEFAULT_PLUGINS } from '@pie-lib/editable-html';\nimport CardActions from '@material-ui/core/CardActions';\nimport DragHandle from '@material-ui/icons/DragHandle';\n\nimport { DragSource, DropTarget } from 'react-dnd';\nimport classNames from 'classnames';\n\nimport IconButton from '@material-ui/core/IconButton';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport RemoveCircle from '@material-ui/icons/RemoveCircle';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport { InfoDialog } from './choice-editor';\n\nconst log = debug('@pie-element:placement-ordering:configure:choice-tile');\n\nexport class ChoiceTile extends React.Component {\n static propTypes = {\n connectDragSource: PropTypes.func.isRequired,\n connectDropTarget: PropTypes.func.isRequired,\n isDragging: PropTypes.bool.isRequired,\n id: PropTypes.any,\n label: PropTypes.string,\n isOver: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n type: PropTypes.string,\n empty: PropTypes.bool,\n disabled: PropTypes.bool,\n outcome: PropTypes.object,\n index: PropTypes.number,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n }),\n choice: PropTypes.object,\n choices: PropTypes.array.isRequired,\n onChoiceChange: PropTypes.func.isRequired,\n onDelete: PropTypes.func.isRequired,\n disableImages: PropTypes.bool,\n toolbarOpts: PropTypes.object,\n choicesLabel: PropTypes.string\n };\n\n state = {\n dialog: {\n open: false\n }\n };\n\n onLabelChange = label => {\n const { choice, onChoiceChange, choices, choicesLabel } = this.props;\n const currentValue = choice.label;\n const sameValue = choices.filter(choice => {\n const wasChanged = currentValue !== label && `<div>${currentValue}</div>` !== label;\n const sameValueEntered = choice.label === label || `<div>${choice.label}</div>` === label;\n\n return wasChanged && sameValueEntered;\n });\n\n const empty = label === '<div></div>';\n\n if (sameValue.length || empty) {\n this.setState({\n dialog: {\n open: true,\n message: `Each of the ${choicesLabel} must be non-empty and unique.`,\n onOk: () => {\n this.setState(\n {\n dialog: {\n open: false\n }\n }\n );\n }\n }\n });\n } else {\n choice.label = label;\n onChoiceChange(choice);\n }\n };\n\n render() {\n const {\n choice: {\n label,\n editable\n },\n isDragging,\n connectDragSource,\n connectDropTarget,\n classes,\n onDelete,\n imageSupport,\n disableImages,\n toolbarOpts\n } = this.props;\n const { dialog } = this.state;\n\n const dragSourceOpts = {}; //dropEffect: moveOnDrag ? 'move' : 'copy'};\n\n const choicePlugins = {\n image: {\n disabled: disableImages\n },\n audio: { disabled: true },\n video: { disabled: true }\n };\n const filteredDefaultPlugins = (DEFAULT_PLUGINS || [])\n .filter(p => p !== 'bulleted-list' && p !== 'numbered-list');\n\n const opacity = isDragging ? 0 : 1;\n const markup = (\n <div className={classes.choiceTile} style={{ opacity: opacity, width: '100%' }}>\n <CardActions>\n <span className={classNames(classes.dragHandle )}>\n <DragHandle className={classes.actions} />\n </span>\n </CardActions>\n <EditableHtml\n disabled={!editable}\n className={classNames(classes.prompt, !editable && classes.targetPrompt)}\n placeholder=\"Enter a choice\"\n markup={label}\n imageSupport={imageSupport || undefined}\n onChange={this.onLabelChange}\n pluginProps={choicePlugins}\n toolbarOpts={toolbarOpts}\n activePlugins={filteredDefaultPlugins}\n allowValidation\n />\n {editable && (\n <div className={classes.controls}>\n <IconButton color='default' onClick={onDelete}>\n <RemoveCircle\n classes={{\n root: classes.removeCircle\n }}\n />\n </IconButton>\n </div>\n )}\n <InfoDialog\n title={dialog.message}\n open={dialog.open}\n onOk={dialog.onOk}\n />\n </div>\n );\n\n\n return connectDragSource(\n connectDropTarget(\n <div>\n {markup}\n </div>\n ),\n dragSourceOpts\n );\n }\n}\n\nconst Styled = withStyles(theme => ({\n removeCircle: {\n fill: theme.palette.error[500]\n },\n choiceTile: {\n cursor: 'move',\n backgroundColor: 'white',\n marginTop: '5px',\n marginBottom: '5px',\n display: 'flex',\n alignItems: 'center'\n },\n controls: {\n display: 'flex',\n justifyContent: 'flex-end'\n },\n prompt: {\n width: '80%',\n border: 'none',\n },\n targetPrompt: {\n backgroundColor: '#D7D7D7'\n },\n actions: {\n color: '#B1B1B1'\n }\n}))(ChoiceTile);\n\nconst NAME = 'choice-config';\n\nconst choiceSource = {\n beginDrag(props) {\n return {\n id: props.choice.id,\n index: props.index,\n type: props.choice.type,\n instanceId: props.choice.instanceId\n };\n }\n};\n\nconst StyledSource = DragSource(NAME, choiceSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging()\n}))(Styled);\n\nconst choiceTarget = {\n hover() {\n log('[hover]');\n },\n drop(props, monitor) {\n const item = monitor.getItem();\n log('[drop] item: ', item, 'didDrop?', monitor.didDrop());\n\n props.onDropChoice(item, props.index);\n }\n};\n\nconst StyledSourceAndTarget = DropTarget(NAME, choiceTarget, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver()\n}))(StyledSource);\n\nexport default StyledSourceAndTarget;\n"],"file":"choice-tile.js"}
@@ -35,6 +35,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
35
35
 
36
36
  var _react = _interopRequireDefault(require("react"));
37
37
 
38
+ var _pluralize = _interopRequireDefault(require("pluralize"));
39
+
38
40
  var _choiceEditor = _interopRequireDefault(require("./choice-editor"));
39
41
 
40
42
  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); }; }
@@ -46,6 +48,16 @@ var Panel = _configUi.settings.Panel,
46
48
  toggle = _configUi.settings.toggle,
47
49
  radio = _configUi.settings.radio;
48
50
 
51
+ var getSingularAndPlural = function getSingularAndPlural(label) {
52
+ return !_pluralize["default"].isPlural(label) ? {
53
+ singularLabel: label,
54
+ pluralLabel: (0, _pluralize["default"])(label)
55
+ } : {
56
+ singularLabel: _pluralize["default"].singular(label),
57
+ pluralLabel: label
58
+ };
59
+ };
60
+
49
61
  var Design = /*#__PURE__*/function (_React$Component) {
50
62
  (0, _inherits2["default"])(Design, _React$Component);
51
63
 
@@ -149,6 +161,12 @@ var Design = /*#__PURE__*/function (_React$Component) {
149
161
 
150
162
  var toolbarOpts = {};
151
163
 
164
+ var _ref3 = choices && choices.label && getSingularAndPlural(choices.label) || {},
165
+ _ref3$singularLabel = _ref3.singularLabel,
166
+ singularLabel = _ref3$singularLabel === void 0 ? '' : _ref3$singularLabel,
167
+ _ref3$pluralLabel = _ref3.pluralLabel,
168
+ pluralLabel = _ref3$pluralLabel === void 0 ? '' : _ref3$pluralLabel;
169
+
152
170
  switch (model.toolbarEditorPosition) {
153
171
  case 'top':
154
172
  toolbarOpts.position = 'top';
@@ -220,11 +238,11 @@ var Design = /*#__PURE__*/function (_React$Component) {
220
238
  imageSupport: imageSupport,
221
239
  toolbarOpts: toolbarOpts
222
240
  }))), /*#__PURE__*/_react["default"].createElement(_configUi.FormSection, {
223
- label: "Define Choices"
241
+ label: "Define ".concat(pluralLabel)
224
242
  }, /*#__PURE__*/_react["default"].createElement("div", {
225
243
  className: classes.row
226
244
  }, choiceLabelEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
227
- label: choiceLabel && choiceLabel.label && choiceLabel.label.toUpperCase(),
245
+ label: choiceLabel && choiceLabel.label && "".concat(singularLabel, " label").toUpperCase(),
228
246
  className: classes.promptHolder
229
247
  }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
230
248
  className: classes.prompt,
@@ -240,7 +258,7 @@ var Design = /*#__PURE__*/function (_React$Component) {
240
258
  onChange: this.onAnswerAreaLabelChange,
241
259
  toolbarOpts: toolbarOpts
242
260
  }))), choices.settings && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
243
- label: choices && choices.label && choices.label.toUpperCase(),
261
+ label: choices && choices.label && pluralLabel.toUpperCase(),
244
262
  className: classes.promptHolder
245
263
  }, /*#__PURE__*/_react["default"].createElement(_choiceEditor["default"], {
246
264
  correctResponse: model.correctResponse,
@@ -248,7 +266,11 @@ var Design = /*#__PURE__*/function (_React$Component) {
248
266
  onChange: this.onChoiceEditorChange,
249
267
  imageSupport: imageSupport,
250
268
  disableImages: !model.enableImages,
251
- toolbarOpts: toolbarOpts
269
+ toolbarOpts: toolbarOpts,
270
+ choicesLabel: choices.label,
271
+ placementArea: model.placementArea,
272
+ singularChoiceLabel: singularLabel,
273
+ pluralChoiceLabel: pluralLabel
252
274
  }))), feedbackEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.FeedbackConfig, {
253
275
  feedback: model.feedback,
254
276
  onChange: this.onFeedbackChange,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/design.jsx"],"names":["log","Panel","settings","toggle","radio","Design","props","applyUpdate","modelFn","model","onModelChanged","update","changeHandler","modelPath","valuePath","value","v","onPromptChange","onTeacherInstructionsChange","onRationaleChange","onChoiceAreaLabelChange","onAnswerAreaLabelChange","onFeedbackChange","onChoiceEditorChange","choices","correctResponse","classes","imageSupport","configuration","onConfigurationChanged","choiceLabel","feedback","targetLabel","prompt","placementArea","numberedGuides","enableImages","orientation","removeTilesAfterPlacing","partialScoring","teacherInstructions","studentInstructions","rationale","scoringType","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","feedbackEnabled","choiceLabelEnabled","toolbarOpts","toolbarEditorPosition","position","Settings","label","Properties","studentInstructionsEnabled","promptHolder","toUpperCase","row","React","Component","defaultProps","propTypes","PropTypes","object","isRequired","func","theme","width","paddingTop","marginTop","spacing","unit","paddingBottom","display","gridAutoFlow","gridAutoColumns","gridGap"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wCAAN,CAAZ;AACA,IAAQC,KAAR,GAAiCC,kBAAjC,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAAiCD,kBAAjC,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAAiCF,kBAAjC,CAAuBE,KAAvB;;IAEaC,M;;;;;AACX,kBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;;AAEA,UAAKC,WAAL,GAAmB,UAAAC,OAAO,EAAI;AAC5B,wBAAkC,MAAKF,KAAvC;AAAA,UAAQG,KAAR,eAAQA,KAAR;AAAA,UAAeC,cAAf,eAAeA,cAAf;AACA,UAAMC,MAAM,GAAG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AAA,WAAW,EAAEsB;AAJf,QAzJJ,CADF;AAmKD;;;EA3PyBU,kBAAMC,S;;;AA8PlCvD,MAAM,CAACwD,YAAP,GAAsB;AACpBnD,EAAAA,cAAc,EAAE,0BAAM,CAAE,CADJ;AAEpBmB,EAAAA,sBAAsB,EAAE,kCAAM,CAAE;AAFZ,CAAtB;AAKAxB,MAAM,CAACyD,SAAP,GAAmB;AACjBrD,EAAAA,KAAK,EAAEsD,sBAAUC,MAAV,CAAiBC,UADP;AAEjBrC,EAAAA,aAAa,EAAEmC,sBAAUC,MAAV,CAAiBC,UAFf;AAGjBvD,EAAAA,cAAc,EAAEqD,sBAAUG,IAHT;AAIjBrC,EAAAA,sBAAsB,EAAEkC,sBAAUG,IAJjB;AAKjBxC,EAAAA,OAAO,EAAEqC,sBAAUC,MAAV,CAAiBC,UALT;AAMjBtC,EAAAA,YAAY,EAAEoC,sBAAUC;AANP,CAAnB;;eASe,2BACb,wBAAW,UAAAG,KAAK;AAAA,SAAK;AACnBX,IAAAA,YAAY,EAAE;AACZY,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,UAAU,EAAE,MAFA;AAGZC,MAAAA,SAAS,EAAE;AAHC,KADK;AAMnBrC,IAAAA,MAAM,EAAE;AACNoC,MAAAA,UAAU,EAAEF,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENC,MAAAA,aAAa,EAAEN,KAAK,CAACI,OAAN,CAAcC;AAFvB,KANW;AAUnBd,IAAAA,GAAG,EAAE;AACHgB,MAAAA,OAAO,EAAE,MADN;AAEHC,MAAAA,YAAY,EAAE,QAFX;AAGHC,MAAAA,eAAe,EAAE,KAHd;AAIHC,MAAAA,OAAO,EAAE;AAJN;AAVc,GAAL;AAAA,CAAhB,EAgBIxE,MAhBJ,CADa,C","sourcesContent":["import {\n FeedbackConfig,\n FormSection,\n InputContainer,\n settings,\n layout\n} from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { withStyles } from '@material-ui/core/styles';\nimport { withDragContext } from '@pie-lib/drag';\n\nimport debug from 'debug';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { get, set } from 'nested-property';\nimport PropTypes from 'prop-types';\nimport React from 'react';\n\nimport ChoiceEditor from './choice-editor';\n\nconst log = debug('@pie-element:placement-ordering:design');\nconst { Panel, toggle, radio } = settings;\n\nexport class Design extends React.Component {\n constructor(props) {\n super(props);\n\n this.applyUpdate = modelFn => {\n const { model, onModelChanged } = this.props;\n const update = modelFn(cloneDeep(model));\n\n onModelChanged(update);\n };\n\n this.changeHandler = (modelPath, valuePath) => {\n return value => {\n log('[changeHandler] value: ', value);\n\n const v = valuePath ? get(value, valuePath) : value;\n\n this.applyUpdate(model => {\n set(model, modelPath, v);\n return model;\n });\n };\n };\n\n this.onPromptChange = this.changeHandler('prompt');\n this.onTeacherInstructionsChange = this.changeHandler(\n 'teacherInstructions'\n );\n this.onRationaleChange = this.changeHandler('rationale');\n this.onChoiceAreaLabelChange = this.changeHandler(\n 'choiceLabel',\n 'target.value'\n );\n this.onAnswerAreaLabelChange = this.changeHandler(\n 'targetLabel',\n 'target.value'\n );\n this.onFeedbackChange = this.changeHandler('feedback');\n\n this.onChoiceEditorChange = (choices, correctResponse) => {\n const { model, onModelChanged } = this.props;\n const update = cloneDeep(model);\n\n update.choices = choices;\n update.correctResponse = correctResponse;\n onModelChanged(update);\n };\n }\n\n render() {\n const {\n model,\n classes,\n imageSupport,\n onModelChanged,\n configuration,\n onConfigurationChanged\n } = this.props;\n const {\n choiceLabel = {},\n choices = {},\n feedback = {},\n targetLabel = {},\n prompt = {},\n\n placementArea = {},\n numberedGuides = {},\n enableImages = {},\n orientation = {},\n removeTilesAfterPlacing = {},\n partialScoring = {},\n teacherInstructions = {},\n studentInstructions = {},\n rationale = {},\n scoringType = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, feedbackEnabled, choiceLabelEnabled } =\n model || {};\n const toolbarOpts = {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n return (\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={model => onModelChanged(model)}\n onChangeConfiguration={configuration =>\n onConfigurationChanged(configuration, true)\n }\n groups={{\n Settings: {\n choiceLabelEnabled:\n choiceLabel.settings && toggle(choiceLabel.label),\n placementArea:\n placementArea.settings && toggle(placementArea.label),\n numberedGuides:\n numberedGuides.settings &&\n model.placementArea &&\n toggle(numberedGuides.label),\n enableImages:\n enableImages.settings && toggle(enableImages.label),\n orientation:\n orientation.settings &&\n radio(orientation.label, ['vertical', 'horizontal']),\n removeTilesAfterPlacing:\n removeTilesAfterPlacing.settings &&\n toggle(removeTilesAfterPlacing.label),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n feedbackEnabled:\n feedback.settings && toggle(feedback.label)\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, ['auto', 'rubric'])\n }\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <FormSection label=\"Ordering\">\n <InputContainer\n label={prompt && prompt.label && prompt.label.toUpperCase()}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChange}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChange}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n </FormSection>\n )}\n\n <FormSection label=\"Define Choices\">\n <div className={classes.row}>\n {choiceLabelEnabled && (\n <InputContainer\n label={\n choiceLabel &&\n choiceLabel.label &&\n choiceLabel.label.toUpperCase()\n }\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.choiceLabel}\n onChange={this.onChoiceAreaLabelChange}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n\n {targetLabel.settings && model.placementArea && (\n <InputContainer\n label={\n targetLabel &&\n targetLabel.label &&\n targetLabel.label.toUpperCase()\n }\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.targetLabel}\n onChange={this.onAnswerAreaLabelChange}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n </div>\n\n {choices.settings && (\n <InputContainer\n label={choices && choices.label && choices.label.toUpperCase()}\n className={classes.promptHolder}\n >\n <ChoiceEditor\n correctResponse={model.correctResponse}\n choices={model.choices}\n onChange={this.onChoiceEditorChange}\n imageSupport={imageSupport}\n disableImages={!model.enableImages}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n </FormSection>\n\n {feedbackEnabled && (\n <FeedbackConfig\n feedback={model.feedback}\n onChange={this.onFeedbackChange}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n />\n )}\n </layout.ConfigLayout>\n );\n }\n}\n\nDesign.defaultProps = {\n onModelChanged: () => {},\n onConfigurationChanged: () => {}\n};\n\nDesign.propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n onModelChanged: PropTypes.func,\n onConfigurationChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.object\n};\n\nexport default withDragContext(\n withStyles(theme => ({\n promptHolder: {\n width: '100%',\n paddingTop: '12px',\n marginTop: '24px'\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit\n },\n row: {\n display: 'grid',\n gridAutoFlow: 'column',\n gridAutoColumns: '1fr',\n gridGap: '8px'\n }\n }))(Design)\n);\n"],"file":"design.js"}
1
+ {"version":3,"sources":["../src/design.jsx"],"names":["log","Panel","settings","toggle","radio","getSingularAndPlural","label","pluralize","isPlural","singularLabel","pluralLabel","singular","Design","props","applyUpdate","modelFn","model","onModelChanged","update","changeHandler","modelPath","valuePath","value","v","onPromptChange","onTeacherInstructionsChange","onRationaleChange","onChoiceAreaLabelChange","onAnswerAreaLabelChange","onFeedbackChange","onChoiceEditorChange","choices","correctResponse","classes","imageSupport","configuration","onConfigurationChanged","choiceLabel","feedback","targetLabel","prompt","placementArea","numberedGuides","enableImages","orientation","removeTilesAfterPlacing","partialScoring","teacherInstructions","studentInstructions","rationale","scoringType","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","feedbackEnabled","choiceLabelEnabled","toolbarOpts","toolbarEditorPosition","position","Settings","Properties","studentInstructionsEnabled","promptHolder","toUpperCase","row","React","Component","defaultProps","propTypes","PropTypes","object","isRequired","func","theme","width","paddingTop","marginTop","spacing","unit","paddingBottom","display","gridAutoFlow","gridAutoColumns","gridGap"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wCAAN,CAAZ;AACA,IAAQC,KAAR,GAAiCC,kBAAjC,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAAiCD,kBAAjC,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAAiCF,kBAAjC,CAAuBE,KAAvB;;AAEA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,C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AiBC,UADP;AAEjBpC,EAAAA,aAAa,EAAEkC,sBAAUC,MAAV,CAAiBC,UAFf;AAGjBtD,EAAAA,cAAc,EAAEoD,sBAAUG,IAHT;AAIjBpC,EAAAA,sBAAsB,EAAEiC,sBAAUG,IAJjB;AAKjBvC,EAAAA,OAAO,EAAEoC,sBAAUC,MAAV,CAAiBC,UALT;AAMjBrC,EAAAA,YAAY,EAAEmC,sBAAUC;AANP,CAAnB;;eASe,2BACb,wBAAW,UAAAG,KAAK;AAAA,SAAK;AACnBX,IAAAA,YAAY,EAAE;AACZY,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,UAAU,EAAE,MAFA;AAGZC,MAAAA,SAAS,EAAE;AAHC,KADK;AAMnBpC,IAAAA,MAAM,EAAE;AACNmC,MAAAA,UAAU,EAAEF,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENC,MAAAA,aAAa,EAAEN,KAAK,CAACI,OAAN,CAAcC;AAFvB,KANW;AAUnBd,IAAAA,GAAG,EAAE;AACHgB,MAAAA,OAAO,EAAE,MADN;AAEHC,MAAAA,YAAY,EAAE,QAFX;AAGHC,MAAAA,eAAe,EAAE,KAHd;AAIHC,MAAAA,OAAO,EAAE;AAJN;AAVc,GAAL;AAAA,CAAhB,EAgBIvE,MAhBJ,CADa,C","sourcesContent":["import {\n FeedbackConfig,\n FormSection,\n InputContainer,\n settings,\n layout\n} from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { withStyles } from '@material-ui/core/styles';\nimport { withDragContext } from '@pie-lib/drag';\n\nimport debug from 'debug';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { get, set } from 'nested-property';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport pluralize from 'pluralize';\n\nimport ChoiceEditor from './choice-editor';\n\nconst log = debug('@pie-element:placement-ordering:design');\nconst { Panel, toggle, radio } = settings;\n\nconst getSingularAndPlural = label => {\n return !pluralize.isPlural(label) ? {\n singularLabel: label,\n pluralLabel: pluralize(label)\n } : {\n singularLabel: pluralize.singular(label),\n pluralLabel: label\n };\n};\n\nexport class Design extends React.Component {\n constructor(props) {\n super(props);\n\n this.applyUpdate = modelFn => {\n const { model, onModelChanged } = this.props;\n const update = modelFn(cloneDeep(model));\n\n onModelChanged(update);\n };\n\n this.changeHandler = (modelPath, valuePath) => {\n return value => {\n log('[changeHandler] value: ', value);\n\n const v = valuePath ? get(value, valuePath) : value;\n\n this.applyUpdate(model => {\n set(model, modelPath, v);\n return model;\n });\n };\n };\n\n this.onPromptChange = this.changeHandler('prompt');\n this.onTeacherInstructionsChange = this.changeHandler(\n 'teacherInstructions'\n );\n this.onRationaleChange = this.changeHandler('rationale');\n this.onChoiceAreaLabelChange = this.changeHandler(\n 'choiceLabel',\n 'target.value'\n );\n this.onAnswerAreaLabelChange = this.changeHandler(\n 'targetLabel',\n 'target.value'\n );\n this.onFeedbackChange = this.changeHandler('feedback');\n\n this.onChoiceEditorChange = (choices, correctResponse) => {\n const { model, onModelChanged } = this.props;\n const update = cloneDeep(model);\n\n update.choices = choices;\n update.correctResponse = correctResponse;\n onModelChanged(update);\n };\n }\n\n render() {\n const {\n model,\n classes,\n imageSupport,\n onModelChanged,\n configuration,\n onConfigurationChanged\n } = this.props;\n const {\n choiceLabel = {},\n choices = {},\n feedback = {},\n targetLabel = {},\n prompt = {},\n\n placementArea = {},\n numberedGuides = {},\n enableImages = {},\n orientation = {},\n removeTilesAfterPlacing = {},\n partialScoring = {},\n teacherInstructions = {},\n studentInstructions = {},\n rationale = {},\n scoringType = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, feedbackEnabled, choiceLabelEnabled } =\n model || {};\n const toolbarOpts = {};\n const {\n singularLabel = '',\n pluralLabel = ''\n } = choices && choices.label && getSingularAndPlural(choices.label) || {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n return (\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={model => onModelChanged(model)}\n onChangeConfiguration={configuration =>\n onConfigurationChanged(configuration, true)\n }\n groups={{\n Settings: {\n choiceLabelEnabled:\n choiceLabel.settings && toggle(choiceLabel.label),\n placementArea:\n placementArea.settings && toggle(placementArea.label),\n numberedGuides:\n numberedGuides.settings &&\n model.placementArea &&\n toggle(numberedGuides.label),\n enableImages:\n enableImages.settings && toggle(enableImages.label),\n orientation:\n orientation.settings &&\n radio(orientation.label, ['vertical', 'horizontal']),\n removeTilesAfterPlacing:\n removeTilesAfterPlacing.settings &&\n toggle(removeTilesAfterPlacing.label),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n feedbackEnabled:\n feedback.settings && toggle(feedback.label)\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, ['auto', 'rubric'])\n }\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <FormSection label=\"Ordering\">\n <InputContainer\n label={prompt && prompt.label && prompt.label.toUpperCase()}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChange}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChange}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n </FormSection>\n )}\n\n <FormSection label={`Define ${pluralLabel}`}>\n <div className={classes.row}>\n {choiceLabelEnabled && (\n <InputContainer\n label={\n choiceLabel &&\n choiceLabel.label &&\n `${singularLabel} label`.toUpperCase()\n }\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.choiceLabel}\n onChange={this.onChoiceAreaLabelChange}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n\n {targetLabel.settings && model.placementArea && (\n <InputContainer\n label={\n targetLabel &&\n targetLabel.label &&\n targetLabel.label.toUpperCase()\n }\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.targetLabel}\n onChange={this.onAnswerAreaLabelChange}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n </div>\n\n {choices.settings && (\n <InputContainer\n label={choices && choices.label && pluralLabel.toUpperCase()}\n className={classes.promptHolder}\n >\n <ChoiceEditor\n correctResponse={model.correctResponse}\n choices={model.choices}\n onChange={this.onChoiceEditorChange}\n imageSupport={imageSupport}\n disableImages={!model.enableImages}\n toolbarOpts={toolbarOpts}\n choicesLabel={choices.label}\n placementArea={model.placementArea}\n singularChoiceLabel={singularLabel}\n pluralChoiceLabel={pluralLabel}\n />\n </InputContainer>\n )}\n </FormSection>\n\n {feedbackEnabled && (\n <FeedbackConfig\n feedback={model.feedback}\n onChange={this.onFeedbackChange}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n />\n )}\n </layout.ConfigLayout>\n );\n }\n}\n\nDesign.defaultProps = {\n onModelChanged: () => {},\n onConfigurationChanged: () => {}\n};\n\nDesign.propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n onModelChanged: PropTypes.func,\n onConfigurationChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.object\n};\n\nexport default withDragContext(\n withStyles(theme => ({\n promptHolder: {\n width: '100%',\n paddingTop: '12px',\n marginTop: '24px'\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit\n },\n row: {\n display: 'grid',\n gridAutoFlow: 'column',\n gridAutoColumns: '1fr',\n gridGap: '8px'\n }\n }))(Design)\n);\n"],"file":"design.js"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/placement-ordering-configure",
3
- "version": "5.4.2",
3
+ "version": "5.5.2",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -8,12 +8,13 @@
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@material-ui/icons": "^3.0.1",
10
10
  "@pie-framework/pie-configure-events": "^1.2.0",
11
- "@pie-lib/config-ui": "^10.10.11",
12
- "@pie-lib/editable-html": "^7.17.11",
13
- "@pie-lib/scoring-config": "^3.5.140",
11
+ "@pie-lib/config-ui": "^10.10.12",
12
+ "@pie-lib/editable-html": "^7.17.12",
13
+ "@pie-lib/scoring-config": "^3.5.141",
14
14
  "debug": "^3.1.0",
15
15
  "lodash": "^4.17.15",
16
16
  "nested-property": "^0.0.7",
17
+ "pluralize": "^8.0.0",
17
18
  "prop-types": "^15.6.2",
18
19
  "react": "^16.8.1",
19
20
  "react-dnd": "^9.3.2",
@@ -3,6 +3,39 @@
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
+ ## [6.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@6.3.3...@pie-element/placement-ordering-controller@6.4.1) (2021-11-11)
7
+
8
+ **Note:** Version bump only for package @pie-element/placement-ordering-controller
9
+
10
+
11
+
12
+
13
+
14
+ # [6.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@6.3.2...@pie-element/placement-ordering-controller@6.4.0) (2021-11-11)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **placement-ordering:** fix create correct session for IBX browse items PD-1349 ([e84c30d](https://github.com/pie-framework/pie-elements/commit/e84c30dd075085ef5d917f2893568bca2003d225))
20
+
21
+
22
+ ### Features
23
+
24
+ * **placement-ordering:** add baseline validation for authoring PD-600, PD-1334 ([2350279](https://github.com/pie-framework/pie-elements/commit/23502790000e3c4f14e4dae6744519b004eb1172))
25
+
26
+
27
+
28
+
29
+
30
+
31
+ ## [6.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@6.3.2...@pie-element/placement-ordering-controller@6.3.3) (2021-11-01)
32
+
33
+ **Note:** Version bump only for package @pie-element/placement-ordering-controller
34
+
35
+
36
+
37
+
38
+
6
39
  ## [6.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@6.3.0...@pie-element/placement-ordering-controller@6.3.2) (2021-08-05)
7
40
 
8
41
 
@@ -104,7 +104,9 @@ function model(question, session, env) {
104
104
  base.env = env;
105
105
  base.outcomes = [];
106
106
  base.completeLength = (normalizedQuestion.correctResponse || []).length;
107
- base.choices = normalizedQuestion.choices;
107
+ base.choices = (normalizedQuestion.choices || []).filter(function (choice) {
108
+ return choice.label;
109
+ });
108
110
  base.note = normalizedQuestion.note;
109
111
  base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0;
110
112
 
@@ -199,10 +201,9 @@ function model(question, session, env) {
199
201
  var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
200
202
  return new Promise(function (resolve) {
201
203
  if (env.mode !== 'evaluate' && env.role === 'instructor') {
202
- var correctResponse = question.correctResponse;
203
204
  resolve({
204
205
  id: '1',
205
- value: correctResponse
206
+ value: (0, _scoring.flattenCorrect)(question)
206
207
  });
207
208
  } else {
208
209
  resolve(null);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","questionError","Error","outcome","question","session","env","Promise","resolve","reject","_","isEmpty","score","empty","correctResponse","s","finalScore","partialScoring","enabled","e","createDefaultModel","model","defaults","normalize","rationaleEnabled","feedbackEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","normalizedQuestion","base","outcomes","completeLength","length","choices","note","showNote","alternateResponses","mode","placementArea","value","map","m","id","prompt","config","orientation","includeTargets","choiceLabelEnabled","targetLabel","choiceLabel","showOrdering","numberedGuides","allowSameChoiceInTargets","removeTilesAfterPlacing","disabled","role","rationale","teacherInstructions","allCorrectResponses","bestSetOfResponses","reduce","info","cr","currentScore","acc","c","idx","arr","allCorrect","correct","isEqual","correctness","feedback","then","createCorrectResponseSession"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,4CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB;AAAA,SAC3B,IAAIC,KAAJ,CAAU,qDAAV,CAD2B;AAAA,CAAtB;;;;AAGA,SAASC,OAAT,CAAiBC,QAAjB,EAA2BC,OAA3B,EAAoCC,GAApC,EAAyC;AAC9C,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,QAAI,CAACJ,OAAD,IAAYK,mBAAEC,OAAF,CAAUN,OAAV,CAAhB,EAAoC;AAClCG,MAAAA,OAAO,CAAC;AAAEI,QAAAA,KAAK,EAAE,CAAT;AAAYC,QAAAA,KAAK,EAAE;AAAnB,OAAD,CAAP;AACD;;AAED,QACE,CAACT,QAAD,IACA,CAACA,QAAQ,CAACU,eADV,IAEAJ,mBAAEC,OAAF,CAAUP,QAAQ,CAACU,eAAnB,CAHF,EAIE;AACAL,MAAAA,MAAM,CAACR,aAAa,EAAd,CAAN;AACD,KAND,MAMO;AACL,UAAI;AACF,YAAMc,CAAC,GAAG,oBAAMX,QAAN,EAAgBC,OAAhB,CAAV;AACA,YAAMW,UAAU,GAAGC,gCAAeC,OAAf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AAI;AAC5B,QAAIF,GAAG,CAACgC,IAAJ,KAAa,UAAb,IAA2BhC,GAAG,CAACkD,IAAJ,KAAa,YAA5C,EAA0D;AACxD,UAAQ1C,eAAR,GAA4BV,QAA5B,CAAQU,eAAR;AAEAN,MAAAA,OAAO,CAAC;AACNmC,QAAAA,EAAE,EAAE,GADE;AAENH,QAAAA,KAAK,EAAE1B;AAFD,OAAD,CAAP;AAID,KAPD,MAOO;AACLN,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAXM,CAAP;AAYD,CAbM","sourcesContent":["import { flattenCorrect, getAllCorrectResponses, score } from './scoring';\n\nimport _ from 'lodash';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { partialScoring } from '@pie-lib/controller-utils';\nimport debug from 'debug';\n\nimport defaults from './defaults';\n\nconst log = debug('@pie-element:placement-ordering:controller');\n\nexport const questionError = () =>\n new Error('Question is missing required array: correctResponse');\n\nexport function outcome(question, session, env) {\n return new Promise((resolve, reject) => {\n if (!session || _.isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (\n !question ||\n !question.correctResponse ||\n _.isEmpty(question.correctResponse)\n ) {\n reject(questionError());\n } else {\n try {\n const s = score(question, session);\n const finalScore = partialScoring.enabled(question, env || {})\n ? s\n : s === 1\n ? 1\n : 0;\n resolve({\n score: finalScore\n });\n } catch (e) {\n reject(e);\n }\n }\n });\n}\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => {\n resolve({\n ...defaults,\n ...model\n });\n });\n}\n\nexport const normalize = question => ({\n ...defaults,\n rationaleEnabled: true,\n feedbackEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async resolve => {\n const normalizedQuestion = normalize(question);\n const base = {};\n\n base.env = env;\n base.outcomes = [];\n base.completeLength = (normalizedQuestion.correctResponse || []).length;\n base.choices = normalizedQuestion.choices;\n base.note = normalizedQuestion.note;\n base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0;\n\n if (env.mode === 'gather' && !normalizedQuestion.placementArea) {\n session.value = base.choices.map(m => m.id);\n }\n\n log('[model] removing tileSize for the moment.');\n\n base.prompt = normalizedQuestion.promptEnabled\n ? normalizedQuestion.prompt\n : null;\n base.config = {\n orientation: normalizedQuestion.orientation || 'vertical',\n includeTargets: normalizedQuestion.placementArea,\n choiceLabelEnabled: normalizedQuestion.choiceLabelEnabled,\n targetLabel: normalizedQuestion.targetLabel,\n choiceLabel: normalizedQuestion.choiceLabel,\n showOrdering: normalizedQuestion.numberedGuides,\n allowSameChoiceInTargets: !normalizedQuestion.removeTilesAfterPlacing\n };\n\n base.disabled = env.mode !== 'gather';\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\n base.rationale = normalizedQuestion.rationaleEnabled\n ? normalizedQuestion.rationale\n : null;\n base.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled) {\n const value = (session && session.value) || [];\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n\n const bestSetOfResponses = allCorrectResponses.reduce(\n (info, cr) => {\n const currentScore = _.reduce(\n value,\n (acc, c, idx) => acc + (cr[idx] === c ? 1 : 0),\n 0\n );\n\n if (currentScore > info.score) {\n return {\n arr: cr,\n score: currentScore\n };\n }\n\n return info;\n },\n { arr: [], score: 0 }\n );\n\n base.outcomes = _.map(value, function(c, idx) {\n return {\n id: c,\n outcome: bestSetOfResponses.arr[idx] === c ? 'correct' : 'incorrect'\n };\n });\n\n const allCorrect = allCorrectResponses.reduce((correct, cr) => {\n if (_.isEqual(cr, value)) {\n return true;\n }\n\n return correct;\n }, false);\n\n base.correctness = allCorrect ? 'correct' : 'incorrect';\n\n if (!allCorrect) {\n base.correctResponse = flattenCorrect(normalizedQuestion);\n }\n\n getFeedbackForCorrectness(\n base.correctness,\n normalizedQuestion.feedback\n ).then(feedback => {\n base.feedback = feedback;\n resolve(base);\n });\n } else {\n resolve(base);\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({\n id: '1',\n value: correctResponse\n });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","questionError","Error","outcome","question","session","env","Promise","resolve","reject","_","isEmpty","score","empty","correctResponse","s","finalScore","partialScoring","enabled","e","createDefaultModel","model","defaults","normalize","rationaleEnabled","feedbackEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","normalizedQuestion","base","outcomes","completeLength","length","choices","filter","choice","label","note","showNote","alternateResponses","mode","placementArea","value","map","m","id","prompt","config","orientation","includeTargets","choiceLabelEnabled","targetLabel","choiceLabel","showOrdering","numberedGuides","allowSameChoiceInTargets","removeTilesAfterPlacing","disabled","role","rationale","teacherInstructions","allCorrectResponses","bestSetOfResponses","reduce","info","cr","currentScore","acc","c","idx","arr","allCorrect","correct","isEqual","correctness","feedback","then","createCorrectResponseSession"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,4CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB;AAAA,SAC3B,IAAIC,KAAJ,CAAU,qDAAV,CAD2B;AAAA,CAAtB;;;;AAGA,SAASC,OAAT,CAAiBC,QAAjB,EAA2BC,OAA3B,EAAoCC,GAApC,EAAyC;AAC9C,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,QAAI,CAAC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EAAiB;AACf1C,kBAAAA,IAAI,CAAChB,eAAL,GAAuB,6BAAee,kBAAf,CAAvB;AACD;;AAED,yDACEC,IAAI,CAAC6C,WADP,EAEE9C,kBAAkB,CAAC+C,QAFrB,EAGEC,IAHF,CAGO,UAAAD,QAAQ,EAAI;AACjB9C,kBAAAA,IAAI,CAAC8C,QAAL,GAAgBA,QAAhB;AACApE,kBAAAA,OAAO,CAACsB,IAAD,CAAP;AACD,iBAND;AAOD,eApDD,MAoDO;AACLtB,gBAAAA,OAAO,CAACsB,IAAD,CAAP;AACD;;AArGgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAZ;;AAAA;AAAA;AAAA;AAAA,MAAP;AAuGD;;AAEM,IAAMgD,4BAA4B,GAAG,SAA/BA,4BAA+B,CAAC1E,QAAD,EAAWE,GAAX,EAAmB;AAC7D,SAAO,IAAIC,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5B,QAAIF,GAAG,CAACmC,IAAJ,KAAa,UAAb,IAA2BnC,GAAG,CAACqD,IAAJ,KAAa,YAA5C,EAA0D;AACxDnD,MAAAA,OAAO,CAAC;AACNsC,QAAAA,EAAE,EAAE,GADE;AAENH,QAAAA,KAAK,EAAE,6BAAevC,QAAf;AAFD,OAAD,CAAP;AAID,KALD,MAKO;AACLI,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GATM,CAAP;AAUD,CAXM","sourcesContent":["import { flattenCorrect, getAllCorrectResponses, score } from './scoring';\n\nimport _ from 'lodash';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { partialScoring } from '@pie-lib/controller-utils';\nimport debug from 'debug';\n\nimport defaults from './defaults';\n\nconst log = debug('@pie-element:placement-ordering:controller');\n\nexport const questionError = () =>\n new Error('Question is missing required array: correctResponse');\n\nexport function outcome(question, session, env) {\n return new Promise((resolve, reject) => {\n if (!session || _.isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (\n !question ||\n !question.correctResponse ||\n _.isEmpty(question.correctResponse)\n ) {\n reject(questionError());\n } else {\n try {\n const s = score(question, session);\n const finalScore = partialScoring.enabled(question, env || {})\n ? s\n : s === 1\n ? 1\n : 0;\n resolve({\n score: finalScore\n });\n } catch (e) {\n reject(e);\n }\n }\n });\n}\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => {\n resolve({\n ...defaults,\n ...model\n });\n });\n}\n\nexport const normalize = question => ({\n ...defaults,\n rationaleEnabled: true,\n feedbackEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async resolve => {\n const normalizedQuestion = normalize(question);\n const base = {};\n\n base.env = env;\n base.outcomes = [];\n base.completeLength = (normalizedQuestion.correctResponse || []).length;\n base.choices = (normalizedQuestion.choices || []).filter(choice => choice.label);\n base.note = normalizedQuestion.note;\n base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0;\n\n if (env.mode === 'gather' && !normalizedQuestion.placementArea) {\n session.value = base.choices.map(m => m.id);\n }\n\n log('[model] removing tileSize for the moment.');\n\n base.prompt = normalizedQuestion.promptEnabled\n ? normalizedQuestion.prompt\n : null;\n base.config = {\n orientation: normalizedQuestion.orientation || 'vertical',\n includeTargets: normalizedQuestion.placementArea,\n choiceLabelEnabled: normalizedQuestion.choiceLabelEnabled,\n targetLabel: normalizedQuestion.targetLabel,\n choiceLabel: normalizedQuestion.choiceLabel,\n showOrdering: normalizedQuestion.numberedGuides,\n allowSameChoiceInTargets: !normalizedQuestion.removeTilesAfterPlacing\n };\n\n base.disabled = env.mode !== 'gather';\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\n base.rationale = normalizedQuestion.rationaleEnabled\n ? normalizedQuestion.rationale\n : null;\n base.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled) {\n const value = (session && session.value) || [];\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n\n const bestSetOfResponses = allCorrectResponses.reduce(\n (info, cr) => {\n const currentScore = _.reduce(\n value,\n (acc, c, idx) => acc + (cr[idx] === c ? 1 : 0),\n 0\n );\n\n if (currentScore > info.score) {\n return {\n arr: cr,\n score: currentScore\n };\n }\n\n return info;\n },\n { arr: [], score: 0 }\n );\n\n base.outcomes = _.map(value, function(c, idx) {\n return {\n id: c,\n outcome: bestSetOfResponses.arr[idx] === c ? 'correct' : 'incorrect'\n };\n });\n\n const allCorrect = allCorrectResponses.reduce((correct, cr) => {\n if (_.isEqual(cr, value)) {\n return true;\n }\n\n return correct;\n }, false);\n\n base.correctness = allCorrect ? 'correct' : 'incorrect';\n\n if (!allCorrect) {\n base.correctResponse = flattenCorrect(normalizedQuestion);\n }\n\n getFeedbackForCorrectness(\n base.correctness,\n normalizedQuestion.feedback\n ).then(feedback => {\n base.feedback = feedback;\n resolve(base);\n });\n } else {\n resolve(base);\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({\n id: '1',\n value: flattenCorrect(question)\n });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/placement-ordering-controller",
3
- "version": "6.3.2",
3
+ "version": "6.4.1",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/placement-ordering",
3
- "version": "7.6.3",
3
+ "version": "7.7.2",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.2",
11
- "@pie-lib/correct-answer-toggle": "^2.3.29",
11
+ "@pie-lib/correct-answer-toggle": "^2.3.32",
12
12
  "@pie-lib/drag": "^1.1.52",
13
- "@pie-lib/math-rendering": "^2.3.9",
14
- "@pie-lib/render-ui": "^4.12.0",
13
+ "@pie-lib/math-rendering": "^2.3.12",
14
+ "@pie-lib/render-ui": "^4.12.3",
15
15
  "debug": "^4.1.1",
16
16
  "decimal.js": "^10.0.0",
17
17
  "lodash": "^4.17.10",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "author": "",
26
26
  "license": "ISC",
27
- "gitHead": "5df8639d9e81211ec961ca9847c07ae708ed4374",
27
+ "gitHead": "25d4d90078b237c54893757434bb09258812b803",
28
28
  "scripts": {
29
29
  "postpublish": "../../scripts/postpublish"
30
30
  },