@pie-element/explicit-constructed-response 4.6.1-beta.0 → 4.6.1-beta.3

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,578 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = exports.Main = void 0;
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
-
22
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
-
24
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
-
26
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
- var _react = _interopRequireDefault(require("react"));
29
-
30
- var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
- var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
33
-
34
- var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
35
-
36
- var _pick = _interopRequireDefault(require("lodash/pick"));
37
-
38
- var _throttle = _interopRequireDefault(require("lodash/throttle"));
39
-
40
- var _editableHtml = _interopRequireWildcard(require("@pie-lib/editable-html"));
41
-
42
- var _configUi = require("@pie-lib/config-ui");
43
-
44
- var _styles = require("@material-ui/core/styles");
45
-
46
- var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
47
-
48
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
49
-
50
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
51
-
52
- var _ecrToolbar = _interopRequireDefault(require("./ecr-toolbar"));
53
-
54
- var _alternateResponses = _interopRequireDefault(require("./alternateResponses"));
55
-
56
- var _markupUtils = require("./markupUtils");
57
-
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; }
67
-
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); }; }
69
-
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; } }
71
-
72
- var toggle = _configUi.settings.toggle,
73
- Panel = _configUi.settings.Panel;
74
-
75
- var styles = function styles(theme) {
76
- return {
77
- promptHolder: {
78
- width: '100%',
79
- paddingBottom: theme.spacing.unit * 2,
80
- marginBottom: theme.spacing.unit * 2
81
- },
82
- prompt: {
83
- paddingTop: theme.spacing.unit * 2,
84
- width: '100%'
85
- },
86
- markup: {
87
- minHeight: '100px',
88
- paddingTop: theme.spacing.unit * 2,
89
- width: '100%',
90
- '& [data-slate-editor="true"]': {
91
- minHeight: '100px'
92
- }
93
- },
94
- design: {
95
- paddingTop: theme.spacing.unit * 3
96
- },
97
- choiceConfiguration: {
98
- paddingTop: theme.spacing.unit * 2,
99
- paddingBottom: theme.spacing.unit * 2
100
- },
101
- switchElement: {
102
- justifyContent: 'space-between',
103
- margin: 0
104
- },
105
- addButton: {
106
- "float": 'right'
107
- },
108
- text: {
109
- color: '#495B8F',
110
- fontFamily: 'Cerebri Sans',
111
- fontSize: theme.typography.fontSize + 2,
112
- lineHeight: '19px',
113
- marginTop: theme.spacing.unit * 4
114
- },
115
- tooltip: {
116
- fontSize: theme.typography.fontSize - 2,
117
- whiteSpace: 'pre',
118
- maxWidth: '500px'
119
- },
120
- errorText: {
121
- fontSize: theme.typography.fontSize - 2,
122
- color: 'red',
123
- paddingTop: theme.spacing.unit
124
- },
125
- flexContainer: {
126
- display: 'flex',
127
- alignItems: 'end'
128
- }
129
- };
130
- };
131
-
132
- var createElementFromHTML = function createElementFromHTML(htmlString) {
133
- var div = document.createElement('div');
134
- div.innerHTML = htmlString.trim();
135
- return div;
136
- };
137
-
138
- var Main = /*#__PURE__*/function (_React$Component) {
139
- (0, _inherits2["default"])(Main, _React$Component);
140
-
141
- var _super = _createSuper(Main);
142
-
143
- function Main() {
144
- var _this;
145
-
146
- (0, _classCallCheck2["default"])(this, Main);
147
-
148
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
149
- args[_key] = arguments[_key];
150
- }
151
-
152
- _this = _super.call.apply(_super, [this].concat(args));
153
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {});
154
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChange", function (newVal) {
155
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), newVal));
156
- });
157
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
158
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
159
- prompt: prompt
160
- }));
161
- });
162
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChanged", function (rationale) {
163
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
164
- rationale: rationale
165
- }));
166
- });
167
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
168
- var _this$props = _this.props,
169
- model = _this$props.model,
170
- onModelChanged = _this$props.onModelChanged;
171
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
172
- teacherInstructions: teacherInstructions
173
- }));
174
- });
175
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMarkupChanged", function (slateMarkup) {
176
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
177
- slateMarkup: slateMarkup
178
- }));
179
- });
180
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onResponsesChanged", function (choices) {
181
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
182
- choices: choices
183
- }));
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
- });
193
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeResponse", function (index, newVal) {
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;
200
-
201
- if (!choices[index]) {
202
- choices[index] = [{
203
- label: newVal || '',
204
- value: '0'
205
- }]; // add default values for missing choices up to the new index position
206
-
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 || '';
212
-
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
221
- }));
222
- });
223
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (markup) {
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;
229
- var domMarkup = createElementFromHTML(markup);
230
- var allRespAreas = domMarkup.querySelectorAll('[data-type="explicit_constructed_response"]');
231
- var allChoices = {};
232
- var updatedMaxLengthPerChoice = [];
233
- allRespAreas.forEach(function (el, index) {
234
- var newChoices = (0, _cloneDeep["default"])(choices[el.dataset.index]);
235
-
236
- if (newChoices) {
237
- newChoices[0] = {
238
- label: el.dataset.value || '',
239
- value: '0'
240
- };
241
- updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];
242
- }
243
-
244
- allChoices[index] = newChoices;
245
- el.dataset.index = index;
246
- });
247
-
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);
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.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
- }));
303
- return _this;
304
- }
305
-
306
- (0, _createClass2["default"])(Main, [{
307
- key: "componentDidMount",
308
- value: function componentDidMount() {
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;
317
- this.setState({
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
- }
330
- });
331
- onModelChanged(_objectSpread(_objectSpread({}, this.props.model), {}, {
332
- maxLengthPerChoice: maxLengthPerChoice
333
- }));
334
- }
335
- }, {
336
- key: "render",
337
- value: function render() {
338
- var _this2 = this;
339
-
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;
347
-
348
- var _ref = configuration || {},
349
- _ref$maxImageWidth = _ref.maxImageWidth,
350
- maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
351
- _ref$maxImageHeight = _ref.maxImageHeight,
352
- maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
353
- _ref$maxLengthPerChoi = _ref.maxLengthPerChoice,
354
- maxLengthPerChoice = _ref$maxLengthPerChoi === void 0 ? {} : _ref$maxLengthPerChoi,
355
- maxResponseAreas = _ref.maxResponseAreas,
356
- _ref$partialScoring = _ref.partialScoring,
357
- partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
358
- _ref$playerSpellCheck = _ref.playerSpellCheck,
359
- playerSpellCheck = _ref$playerSpellCheck === void 0 ? {} : _ref$playerSpellCheck,
360
- _ref$prompt = _ref.prompt,
361
- prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
362
- _ref$rationale = _ref.rationale,
363
- rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
364
- settingsPanelDisabled = _ref.settingsPanelDisabled,
365
- _ref$spellCheck = _ref.spellCheck,
366
- spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
367
- _ref$teacherInstructi = _ref.teacherInstructions,
368
- teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
369
- _ref$withRubric = _ref.withRubric,
370
- withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric;
371
-
372
- var _ref2 = model || {},
373
- errors = _ref2.errors,
374
- maxLengthPerChoiceEnabled = _ref2.maxLengthPerChoiceEnabled,
375
- promptEnabled = _ref2.promptEnabled,
376
- rationaleEnabled = _ref2.rationaleEnabled,
377
- spellCheckEnabled = _ref2.spellCheckEnabled,
378
- teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
379
- toolbarEditorPosition = _ref2.toolbarEditorPosition;
380
-
381
- var _ref3 = errors || {},
382
- _ref3$choicesErrors = _ref3.choicesErrors,
383
- choicesErrors = _ref3$choicesErrors === void 0 ? {} : _ref3$choicesErrors,
384
- responseAreasError = _ref3.responseAreasError;
385
-
386
- var validationMessage = (0, _utils.generateValidationMessage)(configuration);
387
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
388
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
389
- var toolbarOpts = {
390
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
391
- };
392
- var panelSettings = {
393
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
394
- maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label)
395
- };
396
- var panelProperties = {
397
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
398
- rationaleEnabled: rationale.settings && toggle(rationale.label),
399
- promptEnabled: prompt.settings && toggle(prompt.label),
400
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
401
- playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),
402
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
403
- };
404
- return /*#__PURE__*/_react["default"].createElement("div", {
405
- className: classes.design
406
- }, /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
407
- hideSettings: settingsPanelDisabled,
408
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
409
- model: model,
410
- configuration: configuration,
411
- onChangeModel: function onChangeModel(model) {
412
- return _this2.onModelChange(model);
413
- },
414
- onChangeConfiguration: function onChangeConfiguration(configuration) {
415
- return onConfigurationChanged(configuration, true);
416
- },
417
- groups: {
418
- Settings: panelSettings,
419
- Properties: panelProperties
420
- }
421
- })
422
- }, /*#__PURE__*/_react["default"].createElement("div", null, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
423
- label: teacherInstructions.label,
424
- className: classes.promptHolder
425
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
426
- className: classes.prompt,
427
- markup: model.teacherInstructions || '',
428
- onChange: this.onTeacherInstructionsChanged,
429
- imageSupport: imageSupport,
430
- nonEmpty: false,
431
- toolbarOpts: toolbarOpts,
432
- spellCheck: spellCheckEnabled,
433
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
434
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
435
- uploadSoundSupport: uploadSoundSupport,
436
- languageCharactersProps: [{
437
- language: 'spanish'
438
- }, {
439
- language: 'special'
440
- }]
441
- })), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
442
- label: prompt.label,
443
- className: classes.promptHolder
444
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
445
- className: classes.prompt,
446
- markup: model.prompt,
447
- onChange: this.onPromptChanged,
448
- imageSupport: imageSupport,
449
- nonEmpty: false,
450
- disableUnderline: true,
451
- toolbarOpts: toolbarOpts,
452
- spellCheck: spellCheckEnabled,
453
- maxImageWidth: defaultImageMaxWidth,
454
- maxImageHeight: defaultImageMaxHeight,
455
- uploadSoundSupport: uploadSoundSupport,
456
- languageCharactersProps: [{
457
- language: 'spanish'
458
- }, {
459
- language: 'special'
460
- }]
461
- })), /*#__PURE__*/_react["default"].createElement("div", {
462
- className: classes.flexContainer
463
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
464
- className: classes.text
465
- }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
466
- classes: {
467
- tooltip: classes.tooltip
468
- },
469
- disableFocusListener: true,
470
- disableTouchListener: true,
471
- placement: 'right',
472
- title: validationMessage
473
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
474
- fontSize: 'small',
475
- color: 'primary',
476
- style: {
477
- marginLeft: '8px'
478
- }
479
- }))), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
480
- activePlugins: _editableHtml.ALL_PLUGINS,
481
- toolbarOpts: {
482
- position: 'top'
483
- },
484
- spellCheck: spellCheckEnabled,
485
- responseAreaProps: {
486
- type: 'explicit-constructed-response',
487
- options: {
488
- duplicates: true
489
- },
490
- maxResponseAreas: maxResponseAreas,
491
- respAreaToolbar: function respAreaToolbar(node, nodePath, editor, onToolbarDone) {
492
- var model = _this2.props.model;
493
- var correctChoice = (model.choices[node.data.index] || [])[0];
494
- return function () {
495
- return /*#__PURE__*/_react["default"].createElement(_ecrToolbar["default"], {
496
- onChangeResponse: function onChangeResponse(newVal) {
497
- return _this2.onChangeResponse(node.data.index, newVal);
498
- },
499
- node: node,
500
- nodePath: nodePath,
501
- editor: editor,
502
- onToolbarDone: onToolbarDone,
503
- correctChoice: correctChoice
504
- });
505
- };
506
- },
507
- error: function error() {
508
- return choicesErrors;
509
- },
510
- onHandleAreaChange: this.onHandleAreaChange
511
- },
512
- className: classes.markup,
513
- markup: model.slateMarkup,
514
- onChange: this.onChange,
515
- imageSupport: imageSupport,
516
- disableImageAlignmentButtons: true,
517
- onBlur: this.onBlur,
518
- disabled: false,
519
- highlightShape: false,
520
- error: responseAreasError,
521
- uploadSoundSupport: uploadSoundSupport,
522
- languageCharactersProps: [{
523
- language: 'spanish'
524
- }, {
525
- language: 'special'
526
- }]
527
- }), responseAreasError && /*#__PURE__*/_react["default"].createElement("div", {
528
- className: classes.errorText
529
- }, responseAreasError), !(0, _isEmpty["default"])(model.choices) && /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
530
- className: classes.text
531
- }, "Define Alternates ".concat(maxLengthPerChoiceEnabled ? 'and Character Limits' : '')), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
532
- model: model,
533
- onChange: this.onResponsesChanged,
534
- onLengthChange: this.onLengthChanged,
535
- maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
536
- spellCheck: spellCheckEnabled,
537
- choicesErrors: choicesErrors
538
- }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
539
- label: rationale.label,
540
- className: classes.promptHolder
541
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
542
- className: classes.prompt,
543
- markup: model.rationale || '',
544
- onChange: this.onRationaleChanged,
545
- imageSupport: imageSupport,
546
- toolbarOpts: toolbarOpts,
547
- spellCheck: spellCheckEnabled,
548
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
549
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
550
- uploadSoundSupport: uploadSoundSupport,
551
- languageCharactersProps: [{
552
- language: 'spanish'
553
- }, {
554
- language: 'special'
555
- }]
556
- })))));
557
- }
558
- }]);
559
- return Main;
560
- }(_react["default"].Component);
561
-
562
- exports.Main = Main;
563
- (0, _defineProperty2["default"])(Main, "propTypes", {
564
- configuration: _propTypes["default"].object.isRequired,
565
- model: _propTypes["default"].object.isRequired,
566
- disableSidePanel: _propTypes["default"].bool,
567
- onModelChanged: _propTypes["default"].func.isRequired,
568
- onConfigurationChanged: _propTypes["default"].func.isRequired,
569
- classes: _propTypes["default"].object.isRequired,
570
- imageSupport: _propTypes["default"].shape({
571
- add: _propTypes["default"].func.isRequired,
572
- "delete": _propTypes["default"].func.isRequired
573
- })
574
- });
575
- var Styled = (0, _styles.withStyles)(styles)(Main);
576
- var _default = Styled;
577
- exports["default"] = _default;
578
- //# sourceMappingURL=main.js.map
@@ -1 +0,0 @@
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","typography","lineHeight","marginTop","tooltip","whiteSpace","maxWidth","errorText","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","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","settingsPanelDisabled","spellCheck","withRubric","errors","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","responseAreasError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","panelProperties","playerSpellCheckEnabled","rubricEnabled","onModelChange","Settings","Properties","onTeacherInstructionsChanged","language","onPromptChanged","marginLeft","ALL_PLUGINS","type","options","duplicates","respAreaToolbar","nodePath","editor","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;;AA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c,EAAGjB,cAAc,IAAIA,cAAc,CAACnD,SAAlC,IAAgDqE,qBARlE;AASE,QAAA,kBAAkB,EAAEpB,kBATtB;AAUE,QAAA,uBAAuB,EAAE,CAAC;AAAE+B,UAAAA,QAAQ,EAAE;AAAZ,SAAD,EAA0B;AAAEA,UAAAA,QAAQ,EAAE;AAAZ,SAA1B;AAV3B,QADF,CA5GJ,CAfF,CADF,CADF;AAgJD;;;EAxXuBoB,kBAAMC,S;;;iCAAnB1G,I,eACQ;AACjBmD,EAAAA,aAAa,EAAEwD,sBAAUC,MAAV,CAAiBC,UADf;AAEjBzG,EAAAA,KAAK,EAAEuG,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjB5G,EAAAA,cAAc,EAAEwG,sBAAUK,IAAV,CAAeH,UAJd;AAKjBzD,EAAAA,sBAAsB,EAAEuD,sBAAUK,IAAV,CAAeH,UALtB;AAMjB3D,EAAAA,OAAO,EAAEyD,sBAAUC,MAAV,CAAiBC,UANT;AAOjBxD,EAAAA,YAAY,EAAEsD,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB;AAPG,C;AA0XrB,IAAMM,MAAM,GAAG,wBAAW1J,MAAX,EAAmBuC,IAAnB,CAAf;eAEemH,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: theme.typography.fontSize + 2,\n lineHeight: '19px',\n marginTop: theme.spacing.unit * 4,\n },\n tooltip: {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: 'red',\n paddingTop: theme.spacing.unit,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'end',\n },\n});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\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({ ...this.props.model, maxLengthPerChoice });\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({ ...this.props.model, prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({ ...this.props.model, rationale });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({ ...this.props.model, slateMarkup });\n };\n\n onResponsesChanged = (choices) => {\n this.props.onModelChanged({ ...this.props.model, choices });\n };\n\n onLengthChanged = (maxLengthPerChoice) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, maxLengthPerChoice });\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({ ...model, choices, maxLengthPerChoice });\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('[data-type=\"explicit_constructed_response\"]');\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 = () =>\n onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice,\n });\n\n this.setState({ cachedChoices: undefined }, callback);\n };\n\n onHandleAreaChange = throttle(\n (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.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({ ...this.props.model, choices: newChoices });\n\n this.setState({ cachedChoices: newCachedChoices }, callback);\n },\n 500,\n { trailing: false, leading: true },\n );\n\n render() {\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n maxImageWidth = {},\n maxImageHeight = {},\n maxLengthPerChoice = {},\n maxResponseAreas,\n partialScoring = {},\n playerSpellCheck = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n withRubric = {},\n } = configuration || {};\n const {\n errors,\n maxLengthPerChoiceEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const { choicesErrors = {}, responseAreasError } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n };\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n };\n\n return (\n <div className={classes.design}>\n <layout.ConfigLayout\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n <div>\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptHolder}>\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\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.promptHolder}>\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 </InputContainer>\n )}\n\n <div className={classes.flexContainer}>\n <Typography className={classes.text}>Define Template, Choices, and Correct Responses</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: '8px' }} />\n </Tooltip>\n </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, nodePath, editor, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.data.index] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.data.index, newVal)}\n node={node}\n nodePath={nodePath}\n editor={editor}\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 disableImageAlignmentButtons={true}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\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\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptHolder}>\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"}