@pie-element/multiple-choice 8.12.2-next.1 → 8.12.2-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/configure/lib/defaults.js +204 -0
  2. package/configure/lib/defaults.js.map +1 -0
  3. package/configure/lib/index.js +248 -0
  4. package/configure/lib/index.js.map +1 -0
  5. package/configure/lib/main.js +628 -0
  6. package/configure/lib/main.js.map +1 -0
  7. package/configure/lib/utils.js +18 -0
  8. package/configure/lib/utils.js.map +1 -0
  9. package/configure/package.json +1 -1
  10. package/controller/lib/defaults.js +18 -0
  11. package/controller/lib/defaults.js.map +1 -0
  12. package/controller/lib/index.js +335 -0
  13. package/controller/lib/index.js.map +1 -0
  14. package/controller/lib/utils.js +36 -0
  15. package/controller/lib/utils.js.map +1 -0
  16. package/controller/package.json +1 -1
  17. package/lib/choice-input.js +332 -0
  18. package/lib/choice-input.js.map +1 -0
  19. package/lib/choice.js +165 -0
  20. package/lib/choice.js.map +1 -0
  21. package/lib/feedback-tick.js +174 -0
  22. package/lib/feedback-tick.js.map +1 -0
  23. package/lib/index.js +156 -0
  24. package/lib/index.js.map +1 -0
  25. package/lib/main.js +96 -0
  26. package/lib/main.js.map +1 -0
  27. package/lib/multiple-choice.js +359 -0
  28. package/lib/multiple-choice.js.map +1 -0
  29. package/lib/print.js +129 -0
  30. package/lib/print.js.map +1 -0
  31. package/lib/session-updater.js +35 -0
  32. package/lib/session-updater.js.map +1 -0
  33. package/module/configure.js +11110 -0
  34. package/module/controller.js +20843 -0
  35. package/module/demo.js +78 -0
  36. package/module/element.js +9747 -0
  37. package/module/index.html +21 -0
  38. package/module/manifest.json +14 -0
  39. package/module/print-demo.js +116 -0
  40. package/module/print.html +18 -0
  41. package/module/print.js +9709 -0
  42. package/package.json +3 -3
@@ -0,0 +1,628 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.Main = void 0;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _react = _interopRequireDefault(require("react"));
27
+
28
+ var _propTypes = _interopRequireDefault(require("prop-types"));
29
+
30
+ var _editableHtml = require("@pie-lib/pie-toolbox/editable-html");
31
+
32
+ var _configUi = require("@pie-lib/pie-toolbox/config-ui");
33
+
34
+ var _renderUi = require("@pie-lib/pie-toolbox/render-ui");
35
+
36
+ var _styles = require("@material-ui/core/styles");
37
+
38
+ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
39
+
40
+ var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
41
+
42
+ var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
43
+
44
+ var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
45
+
46
+ var _merge = _interopRequireDefault(require("lodash/merge"));
47
+
48
+ var _utils = require("./utils");
49
+
50
+ 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
+
52
+ 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
+
54
+ 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; }
55
+
56
+ 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; }
57
+
58
+ var Panel = _configUi.settings.Panel,
59
+ toggle = _configUi.settings.toggle,
60
+ radio = _configUi.settings.radio,
61
+ dropdown = _configUi.settings.dropdown;
62
+ var MAX_CHOICES = 9;
63
+
64
+ var styles = function styles(theme) {
65
+ return {
66
+ promptHolder: {
67
+ width: '100%',
68
+ paddingTop: theme.spacing.unit * 2,
69
+ marginBottom: theme.spacing.unit * 2
70
+ },
71
+ rationaleHolder: {
72
+ flex: 1,
73
+ marginTop: theme.spacing.unit * 1.5,
74
+ paddingTop: theme.spacing.unit * 2,
75
+ marginLeft: theme.spacing.unit * 3.5
76
+ },
77
+ accessibilityHolder: {
78
+ flex: 1,
79
+ marginTop: theme.spacing.unit * 1.5,
80
+ paddingTop: theme.spacing.unit * 2,
81
+ marginLeft: theme.spacing.unit * 3.5
82
+ },
83
+ choiceConfigurationHolder: {
84
+ display: 'flex',
85
+ flexDirection: 'column',
86
+ marginBottom: theme.spacing.unit
87
+ },
88
+ choiceConfiguration: {
89
+ width: '100%'
90
+ },
91
+ switchElement: {
92
+ justifyContent: 'space-between',
93
+ margin: 0
94
+ },
95
+ addButton: {
96
+ marginTop: theme.spacing.unit,
97
+ "float": 'right'
98
+ },
99
+ disableButton: {
100
+ cursor: 'not-allowed',
101
+ pointerEvents: 'all',
102
+ backgroundColor: _renderUi.color.disabled(),
103
+ '&:hover': {
104
+ backgroundColor: _renderUi.color.disabled()
105
+ },
106
+ '&:focus': {
107
+ backgroundColor: _renderUi.color.disabled()
108
+ }
109
+ },
110
+ flexContainer: {
111
+ display: 'flex',
112
+ alignItems: 'center'
113
+ },
114
+ titleText: {
115
+ fontSize: theme.typography.fontSize + 2,
116
+ marginRight: theme.spacing.unit
117
+ },
118
+ tooltip: {
119
+ fontSize: theme.typography.fontSize - 2,
120
+ whiteSpace: 'pre',
121
+ maxWidth: '500px'
122
+ },
123
+ errorText: {
124
+ fontSize: theme.typography.fontSize - 2,
125
+ color: theme.palette.error.main,
126
+ paddingTop: theme.spacing.unit
127
+ }
128
+ };
129
+ };
130
+
131
+ var Design = (0, _styles.withStyles)(styles)(function (props) {
132
+ var _configuration$teache, _configuration$prompt;
133
+
134
+ var classes = props.classes,
135
+ model = props.model,
136
+ configuration = props.configuration,
137
+ onPromptChanged = props.onPromptChanged,
138
+ onChoiceChanged = props.onChoiceChanged,
139
+ onRemoveChoice = props.onRemoveChoice,
140
+ onAddChoice = props.onAddChoice,
141
+ imageSupport = props.imageSupport,
142
+ uploadSoundSupport = props.uploadSoundSupport,
143
+ onChangeModel = props.onChangeModel,
144
+ onConfigurationChanged = props.onConfigurationChanged,
145
+ onTeacherInstructionsChanged = props.onTeacherInstructionsChanged;
146
+
147
+ var _ref = configuration || {},
148
+ _ref$addChoiceButton = _ref.addChoiceButton,
149
+ addChoiceButton = _ref$addChoiceButton === void 0 ? {} : _ref$addChoiceButton,
150
+ _ref$contentDimension = _ref.contentDimensions,
151
+ contentDimensions = _ref$contentDimension === void 0 ? {} : _ref$contentDimension,
152
+ _ref$feedback = _ref.feedback,
153
+ feedback = _ref$feedback === void 0 ? {} : _ref$feedback,
154
+ _ref$deleteChoice = _ref.deleteChoice,
155
+ deleteChoice = _ref$deleteChoice === void 0 ? {} : _ref$deleteChoice,
156
+ _ref$choiceMode = _ref.choiceMode,
157
+ choiceMode = _ref$choiceMode === void 0 ? {} : _ref$choiceMode,
158
+ _ref$choicePrefix = _ref.choicePrefix,
159
+ choicePrefix = _ref$choicePrefix === void 0 ? {} : _ref$choicePrefix,
160
+ _ref$partialScoring = _ref.partialScoring,
161
+ partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
162
+ _ref$lockChoiceOrder = _ref.lockChoiceOrder,
163
+ lockChoiceOrder = _ref$lockChoiceOrder === void 0 ? {} : _ref$lockChoiceOrder,
164
+ _ref$teacherInstructi = _ref.teacherInstructions,
165
+ teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
166
+ _ref$studentInstructi = _ref.studentInstructions,
167
+ studentInstructions = _ref$studentInstructi === void 0 ? {} : _ref$studentInstructi,
168
+ _ref$rationale = _ref.rationale,
169
+ rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
170
+ _ref$accessibility = _ref.accessibility,
171
+ accessibility = _ref$accessibility === void 0 ? {} : _ref$accessibility,
172
+ _ref$scoringType = _ref.scoringType,
173
+ scoringType = _ref$scoringType === void 0 ? {} : _ref$scoringType,
174
+ _ref$sequentialChoice = _ref.sequentialChoiceLabels,
175
+ sequentialChoiceLabels = _ref$sequentialChoice === void 0 ? {} : _ref$sequentialChoice,
176
+ settingsPanelDisabled = _ref.settingsPanelDisabled,
177
+ choicesLayout = _ref.choicesLayout,
178
+ _ref$spellCheck = _ref.spellCheck,
179
+ spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
180
+ gridColumns = _ref.gridColumns,
181
+ _ref$maxImageWidth = _ref.maxImageWidth,
182
+ maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
183
+ _ref$maxImageHeight = _ref.maxImageHeight,
184
+ maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
185
+ _ref$prompt = _ref.prompt,
186
+ prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
187
+ _ref$withRubric = _ref.withRubric,
188
+ withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric,
189
+ _ref$mathMlOptions = _ref.mathMlOptions,
190
+ mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions,
191
+ _ref$language = _ref.language,
192
+ language = _ref$language === void 0 ? {} : _ref$language,
193
+ _ref$languageChoices = _ref.languageChoices,
194
+ languageChoices = _ref$languageChoices === void 0 ? {} : _ref$languageChoices;
195
+
196
+ var _ref2 = configuration || {},
197
+ maxAnswerChoices = _ref2.maxAnswerChoices;
198
+
199
+ var _ref3 = model || {},
200
+ limitChoicesNumber = _ref3.limitChoicesNumber,
201
+ teacherInstructionsEnabled = _ref3.teacherInstructionsEnabled,
202
+ rationaleEnabled = _ref3.rationaleEnabled,
203
+ accessibilityLabelsEnabled = _ref3.accessibilityLabelsEnabled,
204
+ feedbackEnabled = _ref3.feedbackEnabled,
205
+ promptEnabled = _ref3.promptEnabled,
206
+ spellCheckEnabled = _ref3.spellCheckEnabled,
207
+ choices = _ref3.choices,
208
+ errors = _ref3.errors,
209
+ toolbarEditorPosition = _ref3.toolbarEditorPosition;
210
+
211
+ var _ref4 = errors || {},
212
+ answerChoicesError = _ref4.answerChoices,
213
+ choicesErrors = _ref4.choices,
214
+ correctResponseError = _ref4.correctResponse,
215
+ promptError = _ref4.prompt,
216
+ rationaleErrors = _ref4.rationale,
217
+ teacherInstructionsError = _ref4.teacherInstructions;
218
+
219
+ var nrOfColumnsAvailable = choices !== null && choices !== void 0 && choices.length ? Array.from({
220
+ length: choices.length
221
+ }, function (_, i) {
222
+ return "".concat(i + 1);
223
+ }) : [];
224
+ var _configuration$baseIn = configuration.baseInputConfiguration,
225
+ baseInputConfiguration = _configuration$baseIn === void 0 ? {} : _configuration$baseIn;
226
+ var toolbarOpts = {
227
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
228
+ }; // if old property is used, set maxAnswerChoices to 9
229
+
230
+ if (limitChoicesNumber) {
231
+ maxAnswerChoices = MAX_CHOICES;
232
+ }
233
+
234
+ var getPluginProps = function getPluginProps() {
235
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
236
+ return _objectSpread(_objectSpread({}, baseInputConfiguration), props);
237
+ };
238
+
239
+ var validationMessage = (0, _utils.generateValidationMessage)(configuration);
240
+ var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
241
+ var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
242
+ var addChoiceButtonTooltip = maxAnswerChoices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices ? "Only ".concat(maxAnswerChoices, " allowed maximum") : '';
243
+ var panelSettings = {
244
+ choiceMode: choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),
245
+ 'sequentialChoiceLabels.enabled': sequentialChoiceLabels.settings && toggle(sequentialChoiceLabels.label, true),
246
+ choicePrefix: choicePrefix.settings && radio(choicePrefix.label, ['numbers', 'letters']),
247
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
248
+ lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
249
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
250
+ choicesLayout: choicesLayout.settings && dropdown(choicesLayout.label, ['vertical', 'grid', 'horizontal']),
251
+ gridColumns: choicesLayout.settings && model.choicesLayout === 'grid' && nrOfColumnsAvailable.length > 0 && dropdown(gridColumns.label, nrOfColumnsAvailable),
252
+ 'language.enabled': language.settings && toggle(language.label, true),
253
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
254
+ };
255
+ var panelProperties = {
256
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
257
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
258
+ promptEnabled: prompt.settings && toggle(prompt.label),
259
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
260
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
261
+ accessibilityLabelsEnabled: accessibility.settings && toggle(accessibility.label),
262
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
263
+ rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
264
+ };
265
+ return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
266
+ dimensions: contentDimensions,
267
+ hideSettings: settingsPanelDisabled,
268
+ settings: /*#__PURE__*/_react["default"].createElement(Panel, {
269
+ model: model,
270
+ onChangeModel: onChangeModel,
271
+ configuration: configuration,
272
+ onChangeConfiguration: onConfigurationChanged,
273
+ groups: {
274
+ Settings: panelSettings,
275
+ Properties: panelProperties
276
+ }
277
+ })
278
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
279
+ label: teacherInstructions.label,
280
+ className: classes.promptHolder
281
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
282
+ className: classes.prompt,
283
+ markup: model.teacherInstructions || '',
284
+ onChange: onTeacherInstructionsChanged,
285
+ imageSupport: imageSupport,
286
+ nonEmpty: false,
287
+ error: teacherInstructionsError,
288
+ toolbarOpts: toolbarOpts,
289
+ pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$teache = configuration.teacherInstructions) === null || _configuration$teache === void 0 ? void 0 : _configuration$teache.inputConfiguration),
290
+ spellCheck: spellCheckEnabled,
291
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
292
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
293
+ uploadSoundSupport: uploadSoundSupport,
294
+ languageCharactersProps: [{
295
+ language: 'spanish'
296
+ }, {
297
+ language: 'special'
298
+ }],
299
+ mathMlOptions: mathMlOptions
300
+ }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
301
+ className: classes.errorText
302
+ }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
303
+ label: prompt.label,
304
+ className: classes.promptHolder
305
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
306
+ className: classes.prompt,
307
+ markup: model.prompt,
308
+ onChange: onPromptChanged,
309
+ imageSupport: imageSupport,
310
+ nonEmpty: false,
311
+ disableUnderline: true,
312
+ error: promptError,
313
+ toolbarOpts: toolbarOpts,
314
+ pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$prompt = configuration.prompt) === null || _configuration$prompt === void 0 ? void 0 : _configuration$prompt.inputConfiguration),
315
+ spellCheck: spellCheckEnabled,
316
+ maxImageWidth: maxImageWidth && maxImageWidth.prompt,
317
+ maxImageHeight: maxImageHeight && maxImageHeight.prompt,
318
+ uploadSoundSupport: uploadSoundSupport,
319
+ languageCharactersProps: [{
320
+ language: 'spanish'
321
+ }, {
322
+ language: 'special'
323
+ }],
324
+ mathMlOptions: mathMlOptions
325
+ }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
326
+ className: classes.errorText
327
+ }, promptError)), /*#__PURE__*/_react["default"].createElement("div", {
328
+ className: classes.flexContainer
329
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
330
+ className: classes.titleText
331
+ }, "Choices"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
332
+ classes: {
333
+ tooltip: classes.tooltip
334
+ },
335
+ disableFocusListener: true,
336
+ disableTouchListener: true,
337
+ placement: 'right',
338
+ title: validationMessage
339
+ }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
340
+ fontSize: 'small',
341
+ color: 'primary'
342
+ }))), choices.map(function (choice, index) {
343
+ var _configuration$choice, _configuration$ration, _configuration$access;
344
+
345
+ return /*#__PURE__*/_react["default"].createElement("div", {
346
+ key: "choice-".concat(index),
347
+ className: classes.choiceConfigurationHolder
348
+ }, /*#__PURE__*/_react["default"].createElement(_configUi.ChoiceConfiguration, {
349
+ key: index,
350
+ index: index + 1,
351
+ useLetterOrdering: model.choicePrefix === 'letters',
352
+ className: classes.choiceConfiguration,
353
+ mode: model.choiceMode,
354
+ data: choice,
355
+ defaultFeedback: {},
356
+ imageSupport: imageSupport,
357
+ disableImageAlignmentButtons: true,
358
+ onDelete: function onDelete() {
359
+ return onRemoveChoice(index);
360
+ },
361
+ onChange: function onChange(c) {
362
+ return onChoiceChanged(index, c);
363
+ },
364
+ allowFeedBack: feedbackEnabled,
365
+ allowDelete: deleteChoice.settings,
366
+ noLabels: true,
367
+ pluginOpts: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$choice = configuration.choices) === null || _configuration$choice === void 0 ? void 0 : _configuration$choice.inputConfiguration),
368
+ toolbarOpts: toolbarOpts,
369
+ spellCheck: spellCheckEnabled,
370
+ error: (choicesErrors === null || choicesErrors === void 0 ? void 0 : choicesErrors[choice.value]) || null,
371
+ noCorrectAnswerError: correctResponseError,
372
+ maxImageWidth: maxImageWidth && maxImageWidth.choices || defaultImageMaxWidth,
373
+ maxImageHeight: maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight,
374
+ uploadSoundSupport: uploadSoundSupport,
375
+ mathMlOptions: mathMlOptions
376
+ }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
377
+ key: "rationale-".concat(index),
378
+ label: rationale.label,
379
+ className: classes.rationaleHolder
380
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
381
+ className: classes.rationale,
382
+ markup: choice.rationale || '',
383
+ onChange: function onChange(c) {
384
+ return onChoiceChanged(index, _objectSpread(_objectSpread({}, choice), {}, {
385
+ rationale: c
386
+ }));
387
+ },
388
+ imageSupport: imageSupport,
389
+ error: (rationaleErrors === null || rationaleErrors === void 0 ? void 0 : rationaleErrors[choice.value]) || null,
390
+ toolbarOpts: toolbarOpts,
391
+ pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$ration = configuration.rationale) === null || _configuration$ration === void 0 ? void 0 : _configuration$ration.inputConfiguration),
392
+ spellCheck: spellCheckEnabled,
393
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
394
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
395
+ uploadSoundSupport: uploadSoundSupport,
396
+ languageCharactersProps: [{
397
+ language: 'spanish'
398
+ }, {
399
+ language: 'special'
400
+ }],
401
+ mathMlOptions: mathMlOptions
402
+ }), (rationaleErrors === null || rationaleErrors === void 0 ? void 0 : rationaleErrors[choice.value]) && /*#__PURE__*/_react["default"].createElement("div", {
403
+ className: classes.errorText
404
+ }, rationaleErrors === null || rationaleErrors === void 0 ? void 0 : rationaleErrors[choice.value])), accessibilityLabelsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
405
+ key: "accessibility-".concat(index),
406
+ label: accessibility.label,
407
+ className: classes.accessibilityHolder
408
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
409
+ className: classes.accessibility,
410
+ markup: choice.accessibility || '',
411
+ onChange: function onChange(c) {
412
+ return onChoiceChanged(index, _objectSpread(_objectSpread({}, choice), {}, {
413
+ accessibility: c
414
+ }));
415
+ },
416
+ imageSupport: imageSupport,
417
+ pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$access = configuration.accessibility) === null || _configuration$access === void 0 ? void 0 : _configuration$access.inputConfiguration),
418
+ spellCheck: spellCheckEnabled,
419
+ maxImageWidth: maxImageWidth && maxImageWidth.choices || defaultImageMaxWidth,
420
+ maxImageHeight: maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight,
421
+ uploadSoundSupport: uploadSoundSupport,
422
+ languageCharactersProps: [{
423
+ language: 'spanish'
424
+ }, {
425
+ language: 'special'
426
+ }],
427
+ mathMlOptions: mathMlOptions
428
+ })));
429
+ }), correctResponseError && /*#__PURE__*/_react["default"].createElement("div", {
430
+ className: classes.errorText
431
+ }, correctResponseError), answerChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
432
+ className: classes.errorText
433
+ }, answerChoicesError), addChoiceButton.settings && /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
434
+ title: addChoiceButtonTooltip,
435
+ classes: {
436
+ tooltip: classes.tooltip
437
+ }
438
+ }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
439
+ classes: {
440
+ root: maxAnswerChoices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices && classes.disableButton
441
+ },
442
+ className: classes.addButton,
443
+ variant: "contained",
444
+ color: "primary",
445
+ onClick: onAddChoice
446
+ }, addChoiceButton.label)));
447
+ });
448
+
449
+ var Main = /*#__PURE__*/function (_React$Component) {
450
+ (0, _inherits2["default"])(Main, _React$Component);
451
+
452
+ var _super = _createSuper(Main);
453
+
454
+ function Main() {
455
+ var _this;
456
+
457
+ (0, _classCallCheck2["default"])(this, Main);
458
+
459
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
460
+ args[_key] = arguments[_key];
461
+ }
462
+
463
+ _this = _super.call.apply(_super, [this].concat(args));
464
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
465
+ showWarning: false
466
+ });
467
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRemoveChoice", function (index) {
468
+ var _this$props = _this.props,
469
+ model = _this$props.model,
470
+ configuration = _this$props.configuration,
471
+ onModelChanged = _this$props.onModelChanged;
472
+
473
+ var _ref5 = configuration || {},
474
+ minAnswerChoices = _ref5.minAnswerChoices;
475
+
476
+ if (minAnswerChoices && model.choices.length === minAnswerChoices) {
477
+ _this.setState({
478
+ showWarning: true
479
+ });
480
+
481
+ return;
482
+ }
483
+
484
+ model.choices.splice(index, 1);
485
+ onModelChanged(model);
486
+ });
487
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function () {
488
+ var _this$props2 = _this.props,
489
+ model = _this$props2.model,
490
+ configuration = _this$props2.configuration,
491
+ onModelChanged = _this$props2.onModelChanged;
492
+
493
+ var _ref6 = configuration || {},
494
+ maxAnswerChoices = _ref6.maxAnswerChoices;
495
+
496
+ var _ref7 = model || {},
497
+ limitChoicesNumber = _ref7.limitChoicesNumber; // if old property is used, set maxAnswerChoices to 9
498
+
499
+
500
+ if (limitChoicesNumber) {
501
+ maxAnswerChoices = MAX_CHOICES;
502
+ }
503
+
504
+ if (maxAnswerChoices && model.choices.length >= maxAnswerChoices) {
505
+ return;
506
+ }
507
+
508
+ model.choices.push({
509
+ label: '',
510
+ value: _configUi.choiceUtils.firstAvailableIndex(model.choices.map(function (c) {
511
+ return c.value;
512
+ }), 0),
513
+ feedback: {
514
+ type: 'none'
515
+ }
516
+ });
517
+ onModelChanged(model);
518
+ });
519
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (index, choice) {
520
+ var _this$props3 = _this.props,
521
+ model = _this$props3.model,
522
+ onModelChanged = _this$props3.onModelChanged;
523
+
524
+ if (choice.correct && model.choiceMode === 'radio') {
525
+ model.choices = model.choices.map(function (c) {
526
+ return (0, _merge["default"])({}, c, {
527
+ correct: false
528
+ });
529
+ });
530
+ }
531
+
532
+ model.choices.splice(index, 1, choice);
533
+ onModelChanged(model);
534
+ });
535
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
536
+ _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
537
+ prompt: prompt
538
+ }));
539
+ });
540
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
541
+ _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
542
+ teacherInstructions: teacherInstructions
543
+ }));
544
+ });
545
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChanged", function (model, key) {
546
+ var onModelChanged = _this.props.onModelChanged;
547
+
548
+ switch (key) {
549
+ case 'choiceMode':
550
+ {
551
+ var value = model.choiceMode;
552
+
553
+ if (value === 'radio') {
554
+ var correctFound = false;
555
+ model.choices = model.choices.map(function (c) {
556
+ if (correctFound) {
557
+ c.correct = false;
558
+ return c;
559
+ }
560
+
561
+ if (c.correct) {
562
+ correctFound = true;
563
+ }
564
+
565
+ return c;
566
+ });
567
+ }
568
+
569
+ onModelChanged(model, true);
570
+ break;
571
+ }
572
+
573
+ default:
574
+ onModelChanged(model);
575
+ break;
576
+ }
577
+ });
578
+ return _this;
579
+ }
580
+
581
+ (0, _createClass2["default"])(Main, [{
582
+ key: "render",
583
+ value: function render() {
584
+ var _this2 = this;
585
+
586
+ var _this$props$configura = this.props.configuration;
587
+ _this$props$configura = _this$props$configura === void 0 ? {} : _this$props$configura;
588
+ var minAnswerChoices = _this$props$configura.minAnswerChoices;
589
+ var showWarning = this.state.showWarning;
590
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
591
+ open: showWarning,
592
+ title: "Warning",
593
+ text: "There can't be less than ".concat(minAnswerChoices || 0, " choices."),
594
+ onConfirm: function onConfirm() {
595
+ return _this2.setState({
596
+ showWarning: false
597
+ });
598
+ }
599
+ }), /*#__PURE__*/_react["default"].createElement(Design, (0, _extends2["default"])({}, this.props, {
600
+ onChangeModel: this.onModelChanged,
601
+ onRemoveChoice: this.onRemoveChoice,
602
+ onChoiceChanged: this.onChoiceChanged,
603
+ onAddChoice: this.onAddChoice,
604
+ onPromptChanged: this.onPromptChanged,
605
+ onTeacherInstructionsChanged: this.onTeacherInstructionsChanged
606
+ })));
607
+ }
608
+ }]);
609
+ return Main;
610
+ }(_react["default"].Component);
611
+
612
+ exports.Main = Main;
613
+ (0, _defineProperty2["default"])(Main, "propTypes", {
614
+ model: _propTypes["default"].object.isRequired,
615
+ configuration: _propTypes["default"].object.isRequired,
616
+ disableSidePanel: _propTypes["default"].bool,
617
+ onModelChanged: _propTypes["default"].func.isRequired,
618
+ onConfigurationChanged: _propTypes["default"].func.isRequired,
619
+ classes: _propTypes["default"].object.isRequired,
620
+ imageSupport: _propTypes["default"].shape({
621
+ add: _propTypes["default"].func.isRequired,
622
+ "delete": _propTypes["default"].func.isRequired
623
+ })
624
+ });
625
+ var Styled = (0, _styles.withStyles)(styles)(Main);
626
+ var _default = Styled;
627
+ exports["default"] = _default;
628
+ //# sourceMappingURL=main.js.map