@pie-element/multiple-choice 8.5.1-next.41 → 8.5.1-next.42

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/package.json +1 -1
  2. package/controller/package.json +1 -1
  3. package/package.json +3 -3
  4. package/configure/lib/defaults.js +0 -201
  5. package/configure/lib/defaults.js.map +0 -1
  6. package/configure/lib/index.js +0 -248
  7. package/configure/lib/index.js.map +0 -1
  8. package/configure/lib/main.js +0 -615
  9. package/configure/lib/main.js.map +0 -1
  10. package/configure/lib/utils.js +0 -18
  11. package/configure/lib/utils.js.map +0 -1
  12. package/controller/lib/defaults.js +0 -18
  13. package/controller/lib/defaults.js.map +0 -1
  14. package/controller/lib/index.js +0 -306
  15. package/controller/lib/index.js.map +0 -1
  16. package/controller/lib/utils.js +0 -36
  17. package/controller/lib/utils.js.map +0 -1
  18. package/lib/choice-input.js +0 -332
  19. package/lib/choice-input.js.map +0 -1
  20. package/lib/choice.js +0 -165
  21. package/lib/choice.js.map +0 -1
  22. package/lib/feedback-tick.js +0 -174
  23. package/lib/feedback-tick.js.map +0 -1
  24. package/lib/index.js +0 -156
  25. package/lib/index.js.map +0 -1
  26. package/lib/main.js +0 -96
  27. package/lib/main.js.map +0 -1
  28. package/lib/multiple-choice.js +0 -359
  29. package/lib/multiple-choice.js.map +0 -1
  30. package/lib/print.js +0 -129
  31. package/lib/print.js.map +0 -1
  32. package/lib/session-updater.js +0 -35
  33. package/lib/session-updater.js.map +0 -1
  34. package/module/configure.js +0 -11084
  35. package/module/controller.js +0 -20824
  36. package/module/demo.js +0 -78
  37. package/module/element.js +0 -9747
  38. package/module/index.html +0 -21
  39. package/module/manifest.json +0 -14
  40. package/module/print-demo.js +0 -116
  41. package/module/print.html +0 -18
  42. package/module/print.js +0 -9709
@@ -1,615 +0,0 @@
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
- choicesErrors = _ref4.choicesErrors,
213
- correctResponseError = _ref4.correctResponseError,
214
- answerChoicesError = _ref4.answerChoicesError;
215
-
216
- var nrOfColumnsAvailable = choices !== null && choices !== void 0 && choices.length ? Array.from({
217
- length: choices.length
218
- }, function (_, i) {
219
- return "".concat(i + 1);
220
- }) : [];
221
- var _configuration$baseIn = configuration.baseInputConfiguration,
222
- baseInputConfiguration = _configuration$baseIn === void 0 ? {} : _configuration$baseIn;
223
- var toolbarOpts = {
224
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
225
- }; // if old property is used, set maxAnswerChoices to 9
226
-
227
- if (limitChoicesNumber) {
228
- maxAnswerChoices = MAX_CHOICES;
229
- }
230
-
231
- var getPluginProps = function getPluginProps(props) {
232
- return Object.assign(_objectSpread({}, baseInputConfiguration), props || {});
233
- };
234
-
235
- var validationMessage = (0, _utils.generateValidationMessage)(configuration);
236
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
237
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
238
- var addChoiceButtonTooltip = maxAnswerChoices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices ? "Only ".concat(maxAnswerChoices, " allowed maximum") : '';
239
- var panelSettings = {
240
- choiceMode: choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),
241
- 'sequentialChoiceLabels.enabled': sequentialChoiceLabels.settings && toggle(sequentialChoiceLabels.label, true),
242
- choicePrefix: choicePrefix.settings && radio(choicePrefix.label, ['numbers', 'letters']),
243
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
244
- lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
245
- feedbackEnabled: feedback.settings && toggle(feedback.label),
246
- choicesLayout: choicesLayout.settings && dropdown(choicesLayout.label, ['vertical', 'grid', 'horizontal']),
247
- gridColumns: choicesLayout.settings && model.choicesLayout === 'grid' && nrOfColumnsAvailable.length > 0 && dropdown(gridColumns.label, nrOfColumnsAvailable),
248
- 'language.enabled': language.settings && toggle(language.label, true),
249
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
250
- };
251
- var panelProperties = {
252
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
253
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
254
- promptEnabled: prompt.settings && toggle(prompt.label),
255
- rationaleEnabled: rationale.settings && toggle(rationale.label),
256
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
257
- accessibilityLabelsEnabled: accessibility.settings && toggle(accessibility.label),
258
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
259
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
260
- };
261
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
262
- dimensions: contentDimensions,
263
- hideSettings: settingsPanelDisabled,
264
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
265
- model: model,
266
- onChangeModel: onChangeModel,
267
- configuration: configuration,
268
- onChangeConfiguration: onConfigurationChanged,
269
- groups: {
270
- Settings: panelSettings,
271
- Properties: panelProperties
272
- }
273
- })
274
- }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
275
- label: teacherInstructions.label,
276
- className: classes.promptHolder
277
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
278
- className: classes.prompt,
279
- markup: model.teacherInstructions || '',
280
- onChange: onTeacherInstructionsChanged,
281
- imageSupport: imageSupport,
282
- nonEmpty: false,
283
- toolbarOpts: toolbarOpts,
284
- pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$teache = configuration.teacherInstructions) === null || _configuration$teache === void 0 ? void 0 : _configuration$teache.inputConfiguration),
285
- spellCheck: spellCheckEnabled,
286
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
287
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
288
- uploadSoundSupport: uploadSoundSupport,
289
- languageCharactersProps: [{
290
- language: 'spanish'
291
- }, {
292
- language: 'special'
293
- }],
294
- mathMlOptions: mathMlOptions
295
- })), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
296
- label: prompt.label,
297
- className: classes.promptHolder
298
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
299
- className: classes.prompt,
300
- markup: model.prompt,
301
- onChange: onPromptChanged,
302
- imageSupport: imageSupport,
303
- nonEmpty: false,
304
- disableUnderline: true,
305
- toolbarOpts: toolbarOpts,
306
- pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$prompt = configuration.prompt) === null || _configuration$prompt === void 0 ? void 0 : _configuration$prompt.inputConfiguration),
307
- spellCheck: spellCheckEnabled,
308
- maxImageWidth: maxImageWidth && maxImageWidth.prompt,
309
- maxImageHeight: maxImageHeight && maxImageHeight.prompt,
310
- uploadSoundSupport: uploadSoundSupport,
311
- languageCharactersProps: [{
312
- language: 'spanish'
313
- }, {
314
- language: 'special'
315
- }],
316
- mathMlOptions: mathMlOptions
317
- })), /*#__PURE__*/_react["default"].createElement("div", {
318
- className: classes.flexContainer
319
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
320
- className: classes.titleText
321
- }, "Choices"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
322
- classes: {
323
- tooltip: classes.tooltip
324
- },
325
- disableFocusListener: true,
326
- disableTouchListener: true,
327
- placement: 'right',
328
- title: validationMessage
329
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
330
- fontSize: 'small',
331
- color: 'primary'
332
- }))), choices.map(function (choice, index) {
333
- var _configuration$choice, _configuration$ration, _configuration$access;
334
-
335
- return /*#__PURE__*/_react["default"].createElement("div", {
336
- key: "choice-".concat(index),
337
- className: classes.choiceConfigurationHolder
338
- }, /*#__PURE__*/_react["default"].createElement(_configUi.ChoiceConfiguration, {
339
- key: index,
340
- index: index + 1,
341
- useLetterOrdering: model.choicePrefix === 'letters',
342
- className: classes.choiceConfiguration,
343
- mode: model.choiceMode,
344
- data: choice,
345
- defaultFeedback: {},
346
- imageSupport: imageSupport,
347
- disableImageAlignmentButtons: true,
348
- onDelete: function onDelete() {
349
- return onRemoveChoice(index);
350
- },
351
- onChange: function onChange(c) {
352
- return onChoiceChanged(index, c);
353
- },
354
- allowFeedBack: feedbackEnabled,
355
- allowDelete: deleteChoice.settings,
356
- noLabels: true,
357
- pluginOpts: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$choice = configuration.choices) === null || _configuration$choice === void 0 ? void 0 : _configuration$choice.inputConfiguration),
358
- toolbarOpts: toolbarOpts,
359
- spellCheck: spellCheckEnabled,
360
- error: (choicesErrors === null || choicesErrors === void 0 ? void 0 : choicesErrors[choice.value]) || null,
361
- noCorrectAnswerError: correctResponseError,
362
- maxImageWidth: maxImageWidth && maxImageWidth.choices || defaultImageMaxWidth,
363
- maxImageHeight: maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight,
364
- uploadSoundSupport: uploadSoundSupport,
365
- mathMlOptions: mathMlOptions
366
- }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
367
- key: "rationale-".concat(index),
368
- label: rationale.label,
369
- className: classes.rationaleHolder
370
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
371
- className: classes.rationale,
372
- markup: choice.rationale || '',
373
- onChange: function onChange(c) {
374
- return onChoiceChanged(index, _objectSpread(_objectSpread({}, choice), {}, {
375
- rationale: c
376
- }));
377
- },
378
- imageSupport: imageSupport,
379
- toolbarOpts: toolbarOpts,
380
- pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$ration = configuration.rationale) === null || _configuration$ration === void 0 ? void 0 : _configuration$ration.inputConfiguration),
381
- spellCheck: spellCheckEnabled,
382
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
383
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
384
- uploadSoundSupport: uploadSoundSupport,
385
- languageCharactersProps: [{
386
- language: 'spanish'
387
- }, {
388
- language: 'special'
389
- }],
390
- mathMlOptions: mathMlOptions
391
- })), accessibilityLabelsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
392
- key: "accessibility-".concat(index),
393
- label: accessibility.label,
394
- className: classes.accessibilityHolder
395
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
396
- className: classes.accessibility,
397
- markup: choice.accessibility || '',
398
- onChange: function onChange(c) {
399
- return onChoiceChanged(index, _objectSpread(_objectSpread({}, choice), {}, {
400
- accessibility: c
401
- }));
402
- },
403
- imageSupport: imageSupport,
404
- pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$access = configuration.accessibility) === null || _configuration$access === void 0 ? void 0 : _configuration$access.inputConfiguration),
405
- spellCheck: spellCheckEnabled,
406
- maxImageWidth: maxImageWidth && maxImageWidth.choices || defaultImageMaxWidth,
407
- maxImageHeight: maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight,
408
- uploadSoundSupport: uploadSoundSupport,
409
- languageCharactersProps: [{
410
- language: 'spanish'
411
- }, {
412
- language: 'special'
413
- }],
414
- mathMlOptions: mathMlOptions
415
- })));
416
- }), correctResponseError && /*#__PURE__*/_react["default"].createElement("div", {
417
- className: classes.errorText
418
- }, correctResponseError), answerChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
419
- className: classes.errorText
420
- }, answerChoicesError), addChoiceButton.settings && /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
421
- title: addChoiceButtonTooltip,
422
- classes: {
423
- tooltip: classes.tooltip
424
- }
425
- }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
426
- classes: {
427
- root: maxAnswerChoices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices && classes.disableButton
428
- },
429
- className: classes.addButton,
430
- variant: "contained",
431
- color: "primary",
432
- onClick: onAddChoice
433
- }, addChoiceButton.label)));
434
- });
435
-
436
- var Main = /*#__PURE__*/function (_React$Component) {
437
- (0, _inherits2["default"])(Main, _React$Component);
438
-
439
- var _super = _createSuper(Main);
440
-
441
- function Main() {
442
- var _this;
443
-
444
- (0, _classCallCheck2["default"])(this, Main);
445
-
446
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
447
- args[_key] = arguments[_key];
448
- }
449
-
450
- _this = _super.call.apply(_super, [this].concat(args));
451
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
452
- showWarning: false
453
- });
454
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRemoveChoice", function (index) {
455
- var _this$props = _this.props,
456
- model = _this$props.model,
457
- configuration = _this$props.configuration,
458
- onModelChanged = _this$props.onModelChanged;
459
-
460
- var _ref5 = configuration || {},
461
- minAnswerChoices = _ref5.minAnswerChoices;
462
-
463
- if (minAnswerChoices && model.choices.length === minAnswerChoices) {
464
- _this.setState({
465
- showWarning: true
466
- });
467
-
468
- return;
469
- }
470
-
471
- model.choices.splice(index, 1);
472
- onModelChanged(model);
473
- });
474
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function () {
475
- var _this$props2 = _this.props,
476
- model = _this$props2.model,
477
- configuration = _this$props2.configuration,
478
- onModelChanged = _this$props2.onModelChanged;
479
-
480
- var _ref6 = configuration || {},
481
- maxAnswerChoices = _ref6.maxAnswerChoices;
482
-
483
- var _ref7 = model || {},
484
- limitChoicesNumber = _ref7.limitChoicesNumber; // if old property is used, set maxAnswerChoices to 9
485
-
486
-
487
- if (limitChoicesNumber) {
488
- maxAnswerChoices = MAX_CHOICES;
489
- }
490
-
491
- if (maxAnswerChoices && model.choices.length >= maxAnswerChoices) {
492
- return;
493
- }
494
-
495
- model.choices.push({
496
- label: '',
497
- value: _configUi.choiceUtils.firstAvailableIndex(model.choices.map(function (c) {
498
- return c.value;
499
- }), 0),
500
- feedback: {
501
- type: 'none'
502
- }
503
- });
504
- onModelChanged(model);
505
- });
506
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (index, choice) {
507
- var _this$props3 = _this.props,
508
- model = _this$props3.model,
509
- onModelChanged = _this$props3.onModelChanged;
510
-
511
- if (choice.correct && model.choiceMode === 'radio') {
512
- model.choices = model.choices.map(function (c) {
513
- return (0, _merge["default"])({}, c, {
514
- correct: false
515
- });
516
- });
517
- }
518
-
519
- model.choices.splice(index, 1, choice);
520
- onModelChanged(model);
521
- });
522
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
523
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
524
- prompt: prompt
525
- }));
526
- });
527
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
528
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
529
- teacherInstructions: teacherInstructions
530
- }));
531
- });
532
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChanged", function (model, key) {
533
- var onModelChanged = _this.props.onModelChanged;
534
-
535
- switch (key) {
536
- case 'choiceMode':
537
- {
538
- var value = model.choiceMode;
539
-
540
- if (value === 'radio') {
541
- var correctFound = false;
542
- model.choices = model.choices.map(function (c) {
543
- if (correctFound) {
544
- c.correct = false;
545
- return c;
546
- }
547
-
548
- if (c.correct) {
549
- correctFound = true;
550
- }
551
-
552
- return c;
553
- });
554
- }
555
-
556
- onModelChanged(model, true);
557
- break;
558
- }
559
-
560
- default:
561
- onModelChanged(model);
562
- break;
563
- }
564
- });
565
- return _this;
566
- }
567
-
568
- (0, _createClass2["default"])(Main, [{
569
- key: "render",
570
- value: function render() {
571
- var _this2 = this;
572
-
573
- var _this$props$configura = this.props.configuration;
574
- _this$props$configura = _this$props$configura === void 0 ? {} : _this$props$configura;
575
- var minAnswerChoices = _this$props$configura.minAnswerChoices;
576
- var showWarning = this.state.showWarning;
577
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
578
- open: showWarning,
579
- title: "Warning",
580
- text: "There can't be less than ".concat(minAnswerChoices || 0, " choices."),
581
- onConfirm: function onConfirm() {
582
- return _this2.setState({
583
- showWarning: false
584
- });
585
- }
586
- }), /*#__PURE__*/_react["default"].createElement(Design, (0, _extends2["default"])({}, this.props, {
587
- onChangeModel: this.onModelChanged,
588
- onRemoveChoice: this.onRemoveChoice,
589
- onChoiceChanged: this.onChoiceChanged,
590
- onAddChoice: this.onAddChoice,
591
- onPromptChanged: this.onPromptChanged,
592
- onTeacherInstructionsChanged: this.onTeacherInstructionsChanged
593
- })));
594
- }
595
- }]);
596
- return Main;
597
- }(_react["default"].Component);
598
-
599
- exports.Main = Main;
600
- (0, _defineProperty2["default"])(Main, "propTypes", {
601
- model: _propTypes["default"].object.isRequired,
602
- configuration: _propTypes["default"].object.isRequired,
603
- disableSidePanel: _propTypes["default"].bool,
604
- onModelChanged: _propTypes["default"].func.isRequired,
605
- onConfigurationChanged: _propTypes["default"].func.isRequired,
606
- classes: _propTypes["default"].object.isRequired,
607
- imageSupport: _propTypes["default"].shape({
608
- add: _propTypes["default"].func.isRequired,
609
- "delete": _propTypes["default"].func.isRequired
610
- })
611
- });
612
- var Styled = (0, _styles.withStyles)(styles)(Main);
613
- var _default = Styled;
614
- exports["default"] = _default;
615
- //# sourceMappingURL=main.js.map