@pie-element/explicit-constructed-response 3.9.3-next.137 → 3.9.3-next.1370

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
  exports["default"] = exports.Main = void 0;
11
11
 
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
12
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
15
 
14
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -31,6 +33,10 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
31
33
 
32
34
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
33
35
 
36
+ var _pick = _interopRequireDefault(require("lodash/pick"));
37
+
38
+ var _throttle = _interopRequireDefault(require("lodash/throttle"));
39
+
34
40
  var _editableHtml = _interopRequireWildcard(require("@pie-lib/editable-html"));
35
41
 
36
42
  var _configUi = require("@pie-lib/config-ui");
@@ -39,17 +45,29 @@ var _styles = require("@material-ui/core/styles");
39
45
 
40
46
  var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
41
47
 
48
+ var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
49
+
50
+ var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
51
+
42
52
  var _ecrToolbar = _interopRequireDefault(require("./ecr-toolbar"));
43
53
 
44
54
  var _alternateResponses = _interopRequireDefault(require("./alternateResponses"));
45
55
 
46
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
56
+ var _markupUtils = require("./markupUtils");
47
57
 
48
- 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; }
58
+ var _utils = require("./utils");
59
+
60
+ 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); }
61
+
62
+ 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; }
63
+
64
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
65
+
66
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
49
67
 
50
68
  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); }; }
51
69
 
52
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
70
+ 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; } }
53
71
 
54
72
  var toggle = _configUi.settings.toggle,
55
73
  Panel = _configUi.settings.Panel;
@@ -93,6 +111,20 @@ var styles = function styles(theme) {
93
111
  fontSize: '16px',
94
112
  lineHeight: '19px',
95
113
  marginTop: theme.spacing.unit * 4
114
+ },
115
+ tooltip: {
116
+ fontSize: '12px',
117
+ whiteSpace: 'pre',
118
+ maxWidth: '500px'
119
+ },
120
+ errorText: {
121
+ fontSize: '12px',
122
+ color: 'red',
123
+ padding: '5px 0'
124
+ },
125
+ flexContainer: {
126
+ display: 'flex',
127
+ alignItems: 'end'
96
128
  }
97
129
  };
98
130
  };
@@ -150,70 +182,168 @@ var Main = /*#__PURE__*/function (_React$Component) {
150
182
  choices: choices
151
183
  }));
152
184
  });
185
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLengthChanged", function (maxLengthPerChoice) {
186
+ var _this$props2 = _this.props,
187
+ model = _this$props2.model,
188
+ onModelChanged = _this$props2.onModelChanged;
189
+ onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
190
+ maxLengthPerChoice: maxLengthPerChoice
191
+ }));
192
+ });
153
193
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeResponse", function (index, newVal) {
154
- var choices = _this.props.model.choices;
194
+ var _this$props3 = _this.props,
195
+ model = _this$props3.model,
196
+ onModelChanged = _this$props3.onModelChanged;
197
+ var choices = model.choices;
198
+ var maxLengthPerChoice = model.maxLengthPerChoice;
199
+ var newValLength = (newVal || '').length;
155
200
 
156
201
  if (!choices[index]) {
157
202
  choices[index] = [{
158
- label: '',
203
+ label: newVal || '',
159
204
  value: '0'
160
- }];
161
- }
205
+ }]; // add default values for missing choices up to the new index position
162
206
 
163
- choices[index][0].label = newVal || '';
207
+ var nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;
208
+ maxLengthPerChoice = [].concat((0, _toConsumableArray2["default"])(maxLengthPerChoice), (0, _toConsumableArray2["default"])(Array(nbOfMissingChoices).fill(1)));
209
+ maxLengthPerChoice.splice(index, 0, (0, _markupUtils.getAdjustedLength)(newValLength));
210
+ } else {
211
+ choices[index][0].label = newVal || '';
164
212
 
165
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
166
- choices: choices
213
+ if (maxLengthPerChoice && (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)) {
214
+ maxLengthPerChoice[index] = (0, _markupUtils.getAdjustedLength)(newValLength);
215
+ }
216
+ }
217
+
218
+ onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
219
+ choices: choices,
220
+ maxLengthPerChoice: maxLengthPerChoice
167
221
  }));
168
222
  });
169
223
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (markup) {
170
- var choices = _this.props.model.choices;
224
+ var _this$props4 = _this.props,
225
+ _this$props4$model = _this$props4.model,
226
+ choices = _this$props4$model.choices,
227
+ maxLengthPerChoice = _this$props4$model.maxLengthPerChoice,
228
+ onModelChanged = _this$props4.onModelChanged;
171
229
  var domMarkup = createElementFromHTML(markup);
172
230
  var allRespAreas = domMarkup.querySelectorAll('[data-type="explicit_constructed_response"]');
173
231
  var allChoices = {};
232
+ var updatedMaxLengthPerChoice = [];
174
233
  allRespAreas.forEach(function (el, index) {
175
- el.dataset.index = index;
176
- });
177
- allRespAreas.forEach(function (el, index) {
178
- var newChoices = (0, _cloneDeep["default"])(Object.values(choices)[index]);
234
+ var newChoices = (0, _cloneDeep["default"])(choices[el.dataset.index]);
179
235
 
180
236
  if (newChoices) {
181
237
  newChoices[0] = {
182
238
  label: el.dataset.value || '',
183
239
  value: '0'
184
240
  };
241
+ updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];
185
242
  }
186
243
 
187
- allChoices[el.dataset.index] = newChoices;
244
+ allChoices[index] = newChoices;
245
+ el.dataset.index = index;
188
246
  });
189
247
 
190
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
191
- choices: allChoices,
192
- slateMarkup: domMarkup.innerHTML
193
- }));
248
+ var callback = function callback() {
249
+ return onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
250
+ choices: allChoices,
251
+ slateMarkup: domMarkup.innerHTML,
252
+ maxLengthPerChoice: updatedMaxLengthPerChoice
253
+ }));
254
+ };
255
+
256
+ _this.setState({
257
+ cachedChoices: undefined
258
+ }, callback);
194
259
  });
260
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onHandleAreaChange", (0, _throttle["default"])(function (nodes) {
261
+ var _this$props5 = _this.props,
262
+ choices = _this$props5.model.choices,
263
+ onModelChanged = _this$props5.onModelChanged;
264
+ var cachedChoices = _this.state.cachedChoices;
265
+
266
+ if (!nodes) {
267
+ return;
268
+ }
269
+
270
+ var newChoices = choices ? (0, _cloneDeep["default"])(choices) : {};
271
+ var newCachedChoices = cachedChoices ? (0, _cloneDeep["default"])(cachedChoices) : {};
272
+ nodes.forEach(function (node) {
273
+ var keyForNode = node.data.get('index');
274
+
275
+ if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {
276
+ Object.assign(newChoices, (0, _pick["default"])(newCachedChoices, keyForNode));
277
+
278
+ if (newCachedChoices.hasOwnProperty(keyForNode)) {
279
+ delete newCachedChoices[keyForNode];
280
+ }
281
+ } else {
282
+ Object.assign(newCachedChoices, (0, _pick["default"])(newChoices, keyForNode));
283
+
284
+ if (newChoices.hasOwnProperty(keyForNode)) {
285
+ delete newChoices[keyForNode];
286
+ }
287
+ }
288
+ });
289
+
290
+ var callback = function callback() {
291
+ return onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
292
+ choices: newChoices
293
+ }));
294
+ };
295
+
296
+ _this.setState({
297
+ cachedChoices: newCachedChoices
298
+ }, callback);
299
+ }, 500, {
300
+ trailing: false,
301
+ leading: true
302
+ }));
195
303
  return _this;
196
304
  }
197
305
 
198
306
  (0, _createClass2["default"])(Main, [{
199
307
  key: "componentDidMount",
200
308
  value: function componentDidMount() {
201
- var slateMarkup = this.props.model.slateMarkup;
309
+ var _this$props6 = this.props,
310
+ _this$props6$model = _this$props6.model,
311
+ slateMarkup = _this$props6$model.slateMarkup,
312
+ choices = _this$props6$model.choices,
313
+ _this$props6$model$ma = _this$props6$model.maxLengthPerChoice,
314
+ maxLengthPerChoice = _this$props6$model$ma === void 0 ? [] : _this$props6$model$ma,
315
+ onModelChanged = _this$props6.onModelChanged;
316
+ var undefinedLengths = !maxLengthPerChoice.length;
202
317
  this.setState({
203
318
  markup: slateMarkup
319
+ }); // calculate maxLengthPerChoice array if it is not defined or defined incorrectly
320
+
321
+ Object.values(choices).forEach(function (choice, index) {
322
+ var labelLengthsArr = (choice || []).map(function (choice) {
323
+ return (choice.label || '').length;
324
+ });
325
+ var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
326
+
327
+ if (undefinedLengths || !maxLengthPerChoice[index] || maxLengthPerChoice[index] < length || maxLengthPerChoice[index] > length + 10) {
328
+ maxLengthPerChoice[index] = (0, _markupUtils.getAdjustedLength)(length);
329
+ }
204
330
  });
331
+ onModelChanged(_objectSpread(_objectSpread({}, this.props.model), {}, {
332
+ maxLengthPerChoice: maxLengthPerChoice
333
+ }));
205
334
  }
206
335
  }, {
207
336
  key: "render",
208
337
  value: function render() {
209
338
  var _this2 = this;
210
339
 
211
- var _this$props2 = this.props,
212
- classes = _this$props2.classes,
213
- model = _this$props2.model,
214
- configuration = _this$props2.configuration,
215
- onConfigurationChanged = _this$props2.onConfigurationChanged,
216
- imageSupport = _this$props2.imageSupport;
340
+ var _this$props7 = this.props,
341
+ classes = _this$props7.classes,
342
+ model = _this$props7.model,
343
+ configuration = _this$props7.configuration,
344
+ onConfigurationChanged = _this$props7.onConfigurationChanged,
345
+ imageSupport = _this$props7.imageSupport,
346
+ uploadSoundSupport = _this$props7.uploadSoundSupport;
217
347
 
218
348
  var _ref = configuration || {},
219
349
  _ref$prompt = _ref.prompt,
@@ -223,15 +353,40 @@ var Main = /*#__PURE__*/function (_React$Component) {
223
353
  _ref$rationale = _ref.rationale,
224
354
  rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
225
355
  _ref$teacherInstructi = _ref.teacherInstructions,
226
- teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi;
356
+ teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
357
+ _ref$maxLengthPerChoi = _ref.maxLengthPerChoice,
358
+ maxLengthPerChoice = _ref$maxLengthPerChoi === void 0 ? {} : _ref$maxLengthPerChoi,
359
+ _ref$spellCheck = _ref.spellCheck,
360
+ spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
361
+ _ref$playerSpellCheck = _ref.playerSpellCheck,
362
+ playerSpellCheck = _ref$playerSpellCheck === void 0 ? {} : _ref$playerSpellCheck,
363
+ maxResponseAreas = _ref.maxResponseAreas,
364
+ _ref$maxImageWidth = _ref.maxImageWidth,
365
+ maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
366
+ _ref$maxImageHeight = _ref.maxImageHeight,
367
+ maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
368
+ withRubric = _ref.withRubric;
227
369
 
228
370
  var _ref2 = model || {},
229
371
  teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
230
372
  promptEnabled = _ref2.promptEnabled,
231
- rationaleEnabled = _ref2.rationaleEnabled;
373
+ rationaleEnabled = _ref2.rationaleEnabled,
374
+ maxLengthPerChoiceEnabled = _ref2.maxLengthPerChoiceEnabled,
375
+ spellCheckEnabled = _ref2.spellCheckEnabled,
376
+ errors = _ref2.errors,
377
+ rubricEnabled = _ref2.rubricEnabled;
232
378
 
233
379
  var toolbarOpts = {};
234
380
 
381
+ var _ref3 = errors || {},
382
+ responseAreasError = _ref3.responseAreasError,
383
+ _ref3$choicesErrors = _ref3.choicesErrors,
384
+ choicesErrors = _ref3$choicesErrors === void 0 ? {} : _ref3$choicesErrors;
385
+
386
+ var validationMessage = (0, _utils.generateValidationMessage)(configuration);
387
+ var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
388
+ var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
389
+
235
390
  switch (model.toolbarEditorPosition) {
236
391
  case 'top':
237
392
  toolbarOpts.position = 'top';
@@ -256,12 +411,16 @@ var Main = /*#__PURE__*/function (_React$Component) {
256
411
  },
257
412
  groups: {
258
413
  Settings: {
259
- partialScoring: partialScoring.settings && toggle(partialScoring.label)
414
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
415
+ maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label)
260
416
  },
261
417
  Properties: {
262
418
  teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
263
419
  rationaleEnabled: rationale.settings && toggle(rationale.label),
264
- promptEnabled: prompt.settings && toggle(prompt.label)
420
+ promptEnabled: prompt.settings && toggle(prompt.label),
421
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
422
+ playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),
423
+ rubricEnabled: withRubric.settings && toggle(withRubric.label)
265
424
  }
266
425
  }
267
426
  })
@@ -274,7 +433,16 @@ var Main = /*#__PURE__*/function (_React$Component) {
274
433
  onChange: this.onTeacherInstructionsChanged,
275
434
  imageSupport: imageSupport,
276
435
  nonEmpty: false,
277
- toolbarOpts: toolbarOpts
436
+ toolbarOpts: toolbarOpts,
437
+ spellCheck: spellCheckEnabled,
438
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
439
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
440
+ uploadSoundSupport: uploadSoundSupport,
441
+ languageCharactersProps: [{
442
+ language: 'spanish'
443
+ }, {
444
+ language: 'special'
445
+ }]
278
446
  })), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
279
447
  label: prompt.label,
280
448
  className: classes.promptHolder
@@ -285,19 +453,48 @@ var Main = /*#__PURE__*/function (_React$Component) {
285
453
  imageSupport: imageSupport,
286
454
  nonEmpty: false,
287
455
  disableUnderline: true,
288
- toolbarOpts: toolbarOpts
289
- })), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
456
+ toolbarOpts: toolbarOpts,
457
+ spellCheck: spellCheckEnabled,
458
+ maxImageWidth: defaultImageMaxWidth,
459
+ maxImageHeight: defaultImageMaxHeight,
460
+ uploadSoundSupport: uploadSoundSupport,
461
+ languageCharactersProps: [{
462
+ language: 'spanish'
463
+ }, {
464
+ language: 'special'
465
+ }]
466
+ })), /*#__PURE__*/_react["default"].createElement("div", {
467
+ className: classes.flexContainer
468
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
290
469
  className: classes.text
291
- }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
470
+ }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
471
+ classes: {
472
+ tooltip: classes.tooltip
473
+ },
474
+ disableFocusListener: true,
475
+ disableTouchListener: true,
476
+ placement: 'right',
477
+ title: validationMessage
478
+ }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
479
+ fontSize: 'small',
480
+ color: 'primary',
481
+ style: {
482
+ marginLeft: '5px'
483
+ }
484
+ }))), responseAreasError && /*#__PURE__*/_react["default"].createElement("div", {
485
+ className: classes.errorText
486
+ }, responseAreasError), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
292
487
  activePlugins: _editableHtml.ALL_PLUGINS,
293
488
  toolbarOpts: {
294
489
  position: 'top'
295
490
  },
491
+ spellCheck: spellCheckEnabled,
296
492
  responseAreaProps: {
297
493
  type: 'explicit-constructed-response',
298
494
  options: {
299
495
  duplicates: true
300
496
  },
497
+ maxResponseAreas: maxResponseAreas,
301
498
  respAreaToolbar: function respAreaToolbar(node, value, onToolbarDone) {
302
499
  var model = _this2.props.model;
303
500
  var correctChoice = (model.choices[node.data.get('index')] || [])[0];
@@ -312,7 +509,11 @@ var Main = /*#__PURE__*/function (_React$Component) {
312
509
  correctChoice: correctChoice
313
510
  });
314
511
  };
315
- }
512
+ },
513
+ error: function error() {
514
+ return choicesErrors;
515
+ },
516
+ onHandleAreaChange: this.onHandleAreaChange
316
517
  },
317
518
  className: classes.markup,
318
519
  markup: model.slateMarkup,
@@ -320,12 +521,23 @@ var Main = /*#__PURE__*/function (_React$Component) {
320
521
  imageSupport: imageSupport,
321
522
  onBlur: this.onBlur,
322
523
  disabled: false,
323
- highlightShape: false
524
+ highlightShape: false,
525
+ error: responseAreasError,
526
+ uploadSoundSupport: uploadSoundSupport,
527
+ languageCharactersProps: [{
528
+ language: 'spanish'
529
+ }, {
530
+ language: 'special'
531
+ }]
324
532
  }), !(0, _isEmpty["default"])(model.choices) && /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
325
533
  className: classes.text
326
- }, "Define Alternates"), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
534
+ }, "Define Alternates ".concat(maxLengthPerChoiceEnabled ? 'and Character Limits' : '')), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
327
535
  model: model,
328
- onChange: this.onResponsesChanged
536
+ onChange: this.onResponsesChanged,
537
+ onLengthChange: this.onLengthChanged,
538
+ maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
539
+ spellCheck: spellCheckEnabled,
540
+ choicesErrors: choicesErrors
329
541
  }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
330
542
  label: rationale.label,
331
543
  className: classes.promptHolder
@@ -334,7 +546,16 @@ var Main = /*#__PURE__*/function (_React$Component) {
334
546
  markup: model.rationale || '',
335
547
  onChange: this.onRationaleChanged,
336
548
  imageSupport: imageSupport,
337
- toolbarOpts: toolbarOpts
549
+ toolbarOpts: toolbarOpts,
550
+ spellCheck: spellCheckEnabled,
551
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
552
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
553
+ uploadSoundSupport: uploadSoundSupport,
554
+ languageCharactersProps: [{
555
+ language: 'spanish'
556
+ }, {
557
+ language: 'special'
558
+ }]
338
559
  })))));
339
560
  }
340
561
  }]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","markup","minHeight","design","choiceConfiguration","switchElement","justifyContent","margin","addButton","text","color","fontFamily","fontSize","lineHeight","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","rationale","teacherInstructions","slateMarkup","choices","index","label","value","domMarkup","allRespAreas","querySelectorAll","allChoices","forEach","el","dataset","newChoices","Object","values","setState","classes","configuration","onConfigurationChanged","imageSupport","partialScoring","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","toolbarOpts","toolbarEditorPosition","position","onModelChange","Settings","Properties","onTeacherInstructionsChanged","onPromptChanged","ALL_PLUGINS","type","options","duplicates","respAreaToolbar","node","onToolbarDone","correctChoice","data","get","onChangeResponse","onChange","onBlur","onResponsesChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;;;IAFQA,M,GAAkBC,kB,CAAlBD,M;IAAQE,K,GAAUD,kB,CAAVC,K;;AAIhB,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,aAAa,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADS;AAMvBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENH,MAAAA,KAAK,EAAE;AAFD,KANe;AAUvBO,IAAAA,MAAM,EAAE;AACNC,MAAAA,SAAS,EAAE,OADL;AAENF,MAAAA,UAAU,EAAER,KAAK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B;AAPG,C;AAmRrB,IAAMM,MAAM,GAAG,wBAAW/F,MAAX,EAAmB+B,IAAnB,CAAf;eAEegE,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\n\nconst { toggle, Panel } = settings;\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\n\nconst styles = theme => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px'\n }\n },\n design: {\n paddingTop: theme.spacing.unit * 3\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n addButton: {\n float: 'right'\n },\n text: {\n color: '#495B8F',\n fontFamily: 'Cerebri Sans',\n fontSize: '16px',\n lineHeight: '19px',\n marginTop: theme.spacing.unit * 4\n }\n});\n\nconst createElementFromHTML = htmlString => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n })\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup }\n } = this.props;\n\n this.setState({\n markup: slateMarkup\n });\n }\n\n onModelChange = newVal => {\n this.props.onModelChanged({\n ...this.props.model,\n ...newVal\n });\n };\n\n onPromptChanged = prompt => {\n this.props.onModelChanged({\n ...this.props.model,\n prompt\n });\n };\n\n onRationaleChanged = rationale => {\n this.props.onModelChanged({\n ...this.props.model,\n rationale\n });\n };\n\n onTeacherInstructionsChanged = teacherInstructions => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({\n ...model,\n teacherInstructions\n });\n };\n\n onMarkupChanged = slateMarkup => {\n this.props.onModelChanged({\n ...this.props.model,\n slateMarkup\n });\n };\n\n onResponsesChanged = choices => {\n this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onChangeResponse = (index, newVal) => {\n const {\n model: { choices }\n } = this.props;\n\n if (!choices[index]) {\n choices[index] = [{ label: '', value: '0' }];\n }\n\n choices[index][0].label = newVal || '';\n\n this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onChange = markup => {\n const {\n model: { choices }\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll(\n '[data-type=\"explicit_constructed_response\"]'\n );\n\n const allChoices = {};\n\n allRespAreas.forEach((el, index) => {\n el.dataset.index = index;\n });\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(Object.values(choices)[index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0'\n };\n }\n\n allChoices[el.dataset.index] = newChoices;\n });\n\n this.props.onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML\n });\n };\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged,\n imageSupport\n } = this.props;\n const {\n prompt = {},\n partialScoring = {},\n rationale = {},\n teacherInstructions = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled } =\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 <div className={classes.design}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={model => this.onModelChange(model)}\n onChangeConfiguration={configuration =>\n onConfigurationChanged(configuration, true)\n }\n groups={{\n Settings: {\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label)\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label)\n }\n }}\n />\n }\n >\n <div>\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.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n <Typography className={classes.text}>\n Define Template, Choices, and Correct Responses\n </Typography>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true\n },\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[\n node.data.get('index')\n ] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={newVal =>\n this.onChangeResponse(node.data.get('index'), newVal)\n }\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n />\n );\n }\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n />\n {!isEmpty(model.choices) && (\n <Typography className={classes.text}>\n Define Alternates\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n />\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.onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n />\n </InputContainer>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","markup","minHeight","design","choiceConfiguration","switchElement","justifyContent","margin","addButton","text","color","fontFamily","fontSize","lineHeight","marginTop","tooltip","whiteSpace","maxWidth","errorText","padding","flexContainer","display","alignItems","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","get","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","partialScoring","spellCheck","playerSpellCheck","maxResponseAreas","maxImageWidth","maxImageHeight","withRubric","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","maxLengthPerChoiceEnabled","spellCheckEnabled","errors","rubricEnabled","toolbarOpts","responseAreasError","choicesErrors","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarEditorPosition","position","onModelChange","Settings","Properties","playerSpellCheckEnabled","onTeacherInstructionsChanged","language","onPromptChanged","marginLeft","ALL_PLUGINS","type","options","duplicates","respAreaToolbar","onToolbarDone","correctChoice","onChangeResponse","error","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAQA,MAAR,GAA0BC,kBAA1B,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAA0BD,kBAA1B,CAAgBC,KAAhB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,aAAa,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADS;AAMvBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENH,MAAAA,KAAK,EAAE;AAFD,KANe;AAUvBO,IAAAA,MAAM,EAAE;AACNC,MAAAA,SAAS,EAAE,OADL;AAENF,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAF3B;AAGNH,MAAAA,KAAK,EAAE,MAHD;AAIN,sCAAgC;AAC9BQ,QAAAA,SAAS,EAAE;AADmB;AAJ1B,KAVe;AAkBvBC,IAAAA,MAAM,EAAE;AACNH,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN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AAa,EAAEP,aAAa,IAAIA,aAAa,CAACvD,SAA/B,IAA4CqE,oBAP7D;AAQE,QAAA,cAAc,EAAEb,cAAc,IAAIA,cAAc,CAACxD,SAAjC,IAA8CsE,qBARhE;AASE,QAAA,kBAAkB,EAAEpB,kBATtB;AAUE,QAAA,uBAAuB,EAAE,CAAC;AAAE4B,UAAAA,QAAQ,EAAE;AAAZ,SAAD,EAA0B;AAAEA,UAAAA,QAAQ,EAAE;AAAZ,SAA1B;AAV3B,QAJF,CA5HJ,CAjCF,CADF,CADF;AAqLD;;;EA3buBkB,kBAAMC,S;;;iCAAnBtG,I,eACQ;AACjBoD,EAAAA,aAAa,EAAEmD,sBAAUC,MAAV,CAAiBC,UADf;AAEjBrG,EAAAA,KAAK,EAAEmG,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjBxG,EAAAA,cAAc,EAAEoG,sBAAUK,IAAV,CAAeH,UAJd;AAKjBpD,EAAAA,sBAAsB,EAAEkD,sBAAUK,IAAV,CAAeH,UALtB;AAMjBtD,EAAAA,OAAO,EAAEoD,sBAAUC,MAAV,CAAiBC,UANT;AAOjBnD,EAAAA,YAAY,EAAEiD,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB;AAPG,C;AA6brB,IAAMM,MAAM,GAAG,wBAAWtJ,MAAX,EAAmBuC,IAAnB,CAAf;eAEe+G,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport EditableHtml, {ALL_PLUGINS} from '@pie-lib/editable-html';\n// import EditableHtmlNew from 'editable-html';\nimport {InputContainer, layout, settings} from '@pie-lib/config-ui';\nimport {withStyles} from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { getAdjustedLength } from './markupUtils';\nimport {generateValidationMessage} from './utils';\n\nconst { toggle, Panel } = settings;\n\nconst styles = theme => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px'\n }\n },\n design: {\n paddingTop: theme.spacing.unit * 3\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n addButton: {\n float: 'right'\n },\n text: {\n color: '#495B8F',\n fontFamily: 'Cerebri Sans',\n fontSize: '16px',\n lineHeight: '19px',\n marginTop: theme.spacing.unit * 4\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0'\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'end'\n }\n});\n\nconst createElementFromHTML = htmlString => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n })\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = []},\n onModelChanged\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map(choice => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths\n || !maxLengthPerChoice[index]\n || maxLengthPerChoice[index] < length\n || maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({\n ...this.props.model,\n maxLengthPerChoice\n });\n }\n\n onModelChange = newVal => {\n this.props.onModelChanged({\n ...this.props.model,\n ...newVal\n });\n };\n\n onPromptChanged = prompt => {\n this.props.onModelChanged({\n ...this.props.model,\n prompt\n });\n };\n\n onRationaleChanged = rationale => {\n this.props.onModelChanged({\n ...this.props.model,\n rationale\n });\n };\n\n onTeacherInstructionsChanged = teacherInstructions => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({\n ...model,\n teacherInstructions\n });\n };\n\n onMarkupChanged = slateMarkup => {\n this.props.onModelChanged({\n ...this.props.model,\n slateMarkup\n });\n };\n\n onResponsesChanged = choices => {\n this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onLengthChanged = maxLengthPerChoice => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({\n ...model,\n maxLengthPerChoice\n });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged} = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = (newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [ ...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1) ];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice\n && (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({\n ...model,\n choices,\n maxLengthPerChoice\n });\n };\n\n onChange = markup => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll(\n '[data-type=\"explicit_constructed_response\"]'\n );\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0'\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () => onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice\n });\n\n this.setState({\n cachedChoices: undefined\n }, callback);\n };\n\n onHandleAreaChange = throttle((nodes) => {\n const {\n model: { choices },\n onModelChanged\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.get('index');\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({\n ...this.props.model,\n choices: newChoices\n });\n\n this.setState({\n cachedChoices: newCachedChoices\n }, callback);\n }, 500, { trailing: false, leading: true });\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged,\n imageSupport,\n uploadSoundSupport\n } = this.props;\n const {\n prompt = {},\n partialScoring = {},\n rationale = {},\n teacherInstructions = {},\n maxLengthPerChoice = {},\n spellCheck = {},\n playerSpellCheck = {},\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n withRubric,\n } = configuration || {};\n const {\n teacherInstructionsEnabled,\n promptEnabled,\n rationaleEnabled,\n maxLengthPerChoiceEnabled,\n spellCheckEnabled,\n errors,\n rubricEnabled\n } = model || {};\n const toolbarOpts = {};\n\n const { responseAreasError, choicesErrors = {} } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\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 <div className={classes.design}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={model => this.onModelChange(model)}\n onChangeConfiguration={configuration =>\n onConfigurationChanged(configuration, true)\n }\n groups={{\n Settings: {\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled:\n maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled:\n playerSpellCheck.settings && toggle(playerSpellCheck.label),\n rubricEnabled: withRubric.settings && toggle(withRubric.label)\n }\n }}\n />\n }\n >\n <div>\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.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth}\n maxImageHeight={maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n {/*<EditableHtmlNew*/}\n {/* className={classes.prompt}*/}\n {/* markup={model.prompt}*/}\n {/* onChange={this.onPromptChanged}*/}\n {/* imageSupport={imageSupport}*/}\n {/* nonEmpty={false}*/}\n {/* disableUnderline*/}\n {/* toolbarOpts={toolbarOpts}*/}\n {/* spellCheck={spellCheckEnabled}*/}\n {/*/>*/}\n </InputContainer>\n )}\n <div className={classes.flexContainer}>\n <Typography className={classes.text}>\n Define Template, Choices, and Correct Responses\n </Typography>\n <Tooltip\n classes={{tooltip: classes.tooltip}}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }}/>\n </Tooltip>\n </div>\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[\n node.data.get('index')\n ] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={newVal =>\n this.onChangeResponse(node.data.get('index'), newVal)\n }\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n {!isEmpty(model.choices) && (\n <Typography className={classes.text}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n />\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.onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth}\n maxImageHeight={maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n </InputContainer>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
@@ -5,12 +5,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.createSlateMarkup = exports.processMarkup = exports.removeUnwantedCharacters = void 0;
8
+ exports.removeUnwantedCharacters = exports.processMarkup = exports.getAdjustedLength = exports.createSlateMarkup = void 0;
9
9
 
10
10
  var _escape = _interopRequireDefault(require("lodash/escape"));
11
11
 
12
+ // do not remove \t from \times, \triangle, \tan, \theta or \therefore
13
+ var tSymbols = 'imes|riangle|an|heta|herefore'; // do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
14
+
15
+ var nSymbols = 'throot|parallel|cong|approx|eq|e|sim'; // match all \t and \n that are not part of math symbols that starts with \t or \n
16
+
17
+ var matchTabAndNewLine = new RegExp("(\\t(?!".concat(tSymbols, "))|(\\n(?!").concat(nSymbols, "))|(\\\\t(?!").concat(tSymbols, "))|(\\\\n(?!").concat(nSymbols, "))"), 'g');
18
+
12
19
  var removeUnwantedCharacters = function removeUnwantedCharacters(markup) {
13
- return markup.replace(/(\t+(?!imes))|(\n)|(\\t+(?!imes))|(\\n)/g, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
20
+ return markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
14
21
  };
15
22
 
16
23
  exports.removeUnwantedCharacters = removeUnwantedCharacters;
@@ -45,7 +52,26 @@ var createSlateMarkup = function createSlateMarkup(markup, choices) {
45
52
  var label = choices[g][0].label || '';
46
53
  return "<span data-type=\"explicit_constructed_response\" data-index=\"".concat(g, "\" data-value=\"").concat((0, _escape["default"])(label), "\"></span>");
47
54
  });
48
- };
55
+ }; // also used in controller/src/index.js
56
+
49
57
 
50
58
  exports.createSlateMarkup = createSlateMarkup;
59
+
60
+ var getAdjustedLength = function getAdjustedLength(length) {
61
+ if (length <= 2) {
62
+ return length + 2;
63
+ }
64
+
65
+ if (length <= 4) {
66
+ return length + 3;
67
+ }
68
+
69
+ if (length <= 6) {
70
+ return length + 4;
71
+ }
72
+
73
+ return length + 5;
74
+ };
75
+
76
+ exports.getAdjustedLength = getAdjustedLength;
51
77
  //# sourceMappingURL=markupUtils.js.map