@pie-element/multiple-choice 6.2.0 → 6.2.1-beta.1443
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +346 -0
- package/README.md +1 -1
- package/configure/CHANGELOG.md +321 -0
- package/configure/lib/defaults.js +22 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +16 -2
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +204 -159
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +18 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +5 -5
- package/controller/CHANGELOG.md +35 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +61 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +2 -2
- package/docs/config-schema.json +115 -0
- package/docs/config-schema.json.md +89 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +13 -11
- package/docs/demo/index.html +1 -1
- package/docs/demo/session.js +1 -1
- package/docs/pie-schema.json +38 -0
- package/docs/pie-schema.json.md +28 -0
- package/lib/choice-input.js +17 -10
- package/lib/choice-input.js.map +1 -1
- package/lib/choice.js +14 -3
- package/lib/choice.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/main.js +4 -1
- package/lib/main.js.map +1 -1
- package/lib/multiple-choice.js +12 -3
- package/lib/multiple-choice.js.map +1 -1
- package/lib/print.js +2 -0
- package/lib/print.js.map +1 -1
- package/lib/session-updater.js.map +1 -1
- package/package.json +6 -6
- package/module/configure.js +0 -771
- package/module/controller.js +0 -20641
- package/module/demo.js +0 -77
- package/module/element.js +0 -2004
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -115
- package/module/print.html +0 -18
- package/module/print.js +0 -1966
package/configure/lib/main.js
CHANGED
|
@@ -37,23 +37,23 @@ var _styles = require("@material-ui/core/styles");
|
|
|
37
37
|
|
|
38
38
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
39
39
|
|
|
40
|
-
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
41
|
-
|
|
42
40
|
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
43
41
|
|
|
44
|
-
var
|
|
42
|
+
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
43
|
+
|
|
44
|
+
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _utils = require("./utils");
|
|
49
49
|
|
|
50
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
51
|
|
|
52
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
53
|
|
|
54
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
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
55
|
|
|
56
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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
57
|
|
|
58
58
|
var Panel = _configUi.settings.Panel,
|
|
59
59
|
toggle = _configUi.settings.toggle,
|
|
@@ -84,9 +84,6 @@ var styles = function styles(theme) {
|
|
|
84
84
|
accessibility: {
|
|
85
85
|
paddingTop: theme.spacing.unit * 2
|
|
86
86
|
},
|
|
87
|
-
design: {
|
|
88
|
-
paddingTop: theme.spacing.unit * 3
|
|
89
|
-
},
|
|
90
87
|
choiceConfigurationHolder: {
|
|
91
88
|
display: 'flex',
|
|
92
89
|
flexDirection: 'column',
|
|
@@ -102,6 +99,7 @@ var styles = function styles(theme) {
|
|
|
102
99
|
margin: 0
|
|
103
100
|
},
|
|
104
101
|
addButton: {
|
|
102
|
+
marginTop: theme.spacing.unit * 3,
|
|
105
103
|
"float": 'right'
|
|
106
104
|
},
|
|
107
105
|
disableButton: {
|
|
@@ -114,6 +112,28 @@ var styles = function styles(theme) {
|
|
|
114
112
|
'&:focus': {
|
|
115
113
|
backgroundColor: _renderUi.color.disabled()
|
|
116
114
|
}
|
|
115
|
+
},
|
|
116
|
+
flexContainer: {
|
|
117
|
+
display: 'flex',
|
|
118
|
+
alignItems: 'center',
|
|
119
|
+
marginBottom: theme.spacing.unit
|
|
120
|
+
},
|
|
121
|
+
titleText: {
|
|
122
|
+
fontFamily: 'Cerebri Sans',
|
|
123
|
+
fontSize: theme.typography.fontSize + 2,
|
|
124
|
+
lineHeight: '19px',
|
|
125
|
+
color: '#495B8F',
|
|
126
|
+
marginRight: theme.spacing.unit
|
|
127
|
+
},
|
|
128
|
+
tooltip: {
|
|
129
|
+
fontSize: theme.typography.fontSize - 2,
|
|
130
|
+
whiteSpace: 'pre',
|
|
131
|
+
maxWidth: '500px'
|
|
132
|
+
},
|
|
133
|
+
errorText: {
|
|
134
|
+
fontSize: theme.typography.fontSize - 2,
|
|
135
|
+
color: 'red',
|
|
136
|
+
paddingTop: theme.spacing.unit
|
|
117
137
|
}
|
|
118
138
|
};
|
|
119
139
|
};
|
|
@@ -127,6 +147,7 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
127
147
|
onRemoveChoice = props.onRemoveChoice,
|
|
128
148
|
onAddChoice = props.onAddChoice,
|
|
129
149
|
imageSupport = props.imageSupport,
|
|
150
|
+
uploadSoundSupport = props.uploadSoundSupport,
|
|
130
151
|
onChangeModel = props.onChangeModel,
|
|
131
152
|
onConfigurationChanged = props.onConfigurationChanged,
|
|
132
153
|
onTeacherInstructionsChanged = props.onTeacherInstructionsChanged;
|
|
@@ -162,7 +183,15 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
162
183
|
sequentialChoiceLabels = _ref$sequentialChoice === void 0 ? {} : _ref$sequentialChoice,
|
|
163
184
|
settingsPanelDisabled = _ref.settingsPanelDisabled,
|
|
164
185
|
choicesLayout = _ref.choicesLayout,
|
|
165
|
-
|
|
186
|
+
_ref$spellCheck = _ref.spellCheck,
|
|
187
|
+
spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
|
|
188
|
+
gridColumns = _ref.gridColumns,
|
|
189
|
+
_ref$maxImageWidth = _ref.maxImageWidth,
|
|
190
|
+
maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
|
|
191
|
+
_ref$maxImageHeight = _ref.maxImageHeight,
|
|
192
|
+
maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
|
|
193
|
+
_ref$withRubric = _ref.withRubric,
|
|
194
|
+
withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric;
|
|
166
195
|
|
|
167
196
|
var _ref2 = configuration || {},
|
|
168
197
|
maxAnswerChoices = _ref2.maxAnswerChoices;
|
|
@@ -174,9 +203,17 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
174
203
|
accessibilityLabelsEnabled = _ref3.accessibilityLabelsEnabled,
|
|
175
204
|
feedbackEnabled = _ref3.feedbackEnabled,
|
|
176
205
|
promptEnabled = _ref3.promptEnabled,
|
|
177
|
-
|
|
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;
|
|
178
215
|
|
|
179
|
-
var nrOfColumnsAvailable = choices && choices.length ? Array.from({
|
|
216
|
+
var nrOfColumnsAvailable = choices !== null && choices !== void 0 && choices.length ? Array.from({
|
|
180
217
|
length: choices.length
|
|
181
218
|
}, function (_, i) {
|
|
182
219
|
return "".concat(i + 1);
|
|
@@ -189,24 +226,51 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
189
226
|
disabled: true
|
|
190
227
|
}
|
|
191
228
|
};
|
|
192
|
-
var toolbarOpts = {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
case 'top':
|
|
196
|
-
toolbarOpts.position = 'top';
|
|
197
|
-
break;
|
|
198
|
-
|
|
199
|
-
default:
|
|
200
|
-
toolbarOpts.position = 'bottom';
|
|
201
|
-
break;
|
|
202
|
-
} // if old property is used, set maxAnswerChoices to 9
|
|
203
|
-
|
|
229
|
+
var toolbarOpts = {
|
|
230
|
+
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
231
|
+
}; // if old property is used, set maxAnswerChoices to 9
|
|
204
232
|
|
|
205
233
|
if (limitChoicesNumber) {
|
|
206
234
|
maxAnswerChoices = MAX_CHOICES;
|
|
207
235
|
}
|
|
208
236
|
|
|
209
|
-
var
|
|
237
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
238
|
+
var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
239
|
+
var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
240
|
+
var addChoiceButtonTooltip = maxAnswerChoices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices ? "Only ".concat(maxAnswerChoices, " allowed maximum") : '';
|
|
241
|
+
var panelSettings = {
|
|
242
|
+
choiceMode: choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),
|
|
243
|
+
'sequentialChoiceLabels.enabled': sequentialChoiceLabels.settings && toggle(sequentialChoiceLabels.label, true),
|
|
244
|
+
choicePrefix: choicePrefix.settings && radio(choicePrefix.label, ['numbers', 'letters']),
|
|
245
|
+
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
246
|
+
lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
|
|
247
|
+
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
248
|
+
choicesLayout: choicesLayout.settings && dropdown(choicesLayout.label, ['vertical', 'grid', 'horizontal']),
|
|
249
|
+
gridColumns: choicesLayout.settings && model.choicesLayout === 'grid' && nrOfColumnsAvailable.length > 0 && dropdown(gridColumns.label, nrOfColumnsAvailable)
|
|
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
|
+
hideSettings: settingsPanelDisabled,
|
|
263
|
+
settings: /*#__PURE__*/_react["default"].createElement(Panel, {
|
|
264
|
+
model: model,
|
|
265
|
+
onChangeModel: onChangeModel,
|
|
266
|
+
configuration: configuration,
|
|
267
|
+
onChangeConfiguration: onConfigurationChanged,
|
|
268
|
+
groups: {
|
|
269
|
+
Settings: panelSettings,
|
|
270
|
+
Properties: panelProperties
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
210
274
|
label: teacherInstructions.label,
|
|
211
275
|
className: classes.promptHolder
|
|
212
276
|
}, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
@@ -215,7 +279,16 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
215
279
|
onChange: onTeacherInstructionsChanged,
|
|
216
280
|
imageSupport: imageSupport,
|
|
217
281
|
nonEmpty: false,
|
|
218
|
-
toolbarOpts: toolbarOpts
|
|
282
|
+
toolbarOpts: toolbarOpts,
|
|
283
|
+
spellCheck: spellCheckEnabled,
|
|
284
|
+
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
285
|
+
maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
|
|
286
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
287
|
+
languageCharactersProps: [{
|
|
288
|
+
language: 'spanish'
|
|
289
|
+
}, {
|
|
290
|
+
language: 'special'
|
|
291
|
+
}]
|
|
219
292
|
})), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
220
293
|
label: prompt.label,
|
|
221
294
|
className: classes.promptHolder
|
|
@@ -226,8 +299,32 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
226
299
|
imageSupport: imageSupport,
|
|
227
300
|
nonEmpty: false,
|
|
228
301
|
disableUnderline: true,
|
|
229
|
-
toolbarOpts: toolbarOpts
|
|
230
|
-
|
|
302
|
+
toolbarOpts: toolbarOpts,
|
|
303
|
+
spellCheck: spellCheckEnabled,
|
|
304
|
+
maxImageWidth: maxImageWidth && maxImageWidth.prompt,
|
|
305
|
+
maxImageHeight: maxImageHeight && maxImageHeight.prompt,
|
|
306
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
307
|
+
languageCharactersProps: [{
|
|
308
|
+
language: 'spanish'
|
|
309
|
+
}, {
|
|
310
|
+
language: 'special'
|
|
311
|
+
}]
|
|
312
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
313
|
+
className: classes.flexContainer
|
|
314
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
315
|
+
className: classes.titleText
|
|
316
|
+
}, "Choices"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
317
|
+
classes: {
|
|
318
|
+
tooltip: classes.tooltip
|
|
319
|
+
},
|
|
320
|
+
disableFocusListener: true,
|
|
321
|
+
disableTouchListener: true,
|
|
322
|
+
placement: 'right',
|
|
323
|
+
title: validationMessage
|
|
324
|
+
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
325
|
+
fontSize: 'small',
|
|
326
|
+
color: 'primary'
|
|
327
|
+
}))), choices.map(function (choice, index) {
|
|
231
328
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
232
329
|
key: "choice-".concat(index),
|
|
233
330
|
className: classes.choiceConfigurationHolder
|
|
@@ -240,6 +337,7 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
240
337
|
data: choice,
|
|
241
338
|
defaultFeedback: {},
|
|
242
339
|
imageSupport: imageSupport,
|
|
340
|
+
disableImageAlignmentButtons: true,
|
|
243
341
|
onDelete: function onDelete() {
|
|
244
342
|
return onRemoveChoice(index);
|
|
245
343
|
},
|
|
@@ -249,7 +347,13 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
249
347
|
allowFeedBack: feedbackEnabled,
|
|
250
348
|
allowDelete: deleteChoice.settings,
|
|
251
349
|
noLabels: true,
|
|
252
|
-
toolbarOpts: toolbarOpts
|
|
350
|
+
toolbarOpts: toolbarOpts,
|
|
351
|
+
spellCheck: spellCheckEnabled,
|
|
352
|
+
error: (choicesErrors === null || choicesErrors === void 0 ? void 0 : choicesErrors[choice.value]) || null,
|
|
353
|
+
noCorrectAnswerError: correctResponseError,
|
|
354
|
+
maxImageWidth: maxImageWidth && maxImageWidth.choices || defaultImageMaxWidth,
|
|
355
|
+
maxImageHeight: maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight,
|
|
356
|
+
uploadSoundSupport: uploadSoundSupport
|
|
253
357
|
}), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
254
358
|
key: "rationale-".concat(index),
|
|
255
359
|
label: rationale.label,
|
|
@@ -264,7 +368,16 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
264
368
|
},
|
|
265
369
|
imageSupport: imageSupport,
|
|
266
370
|
toolbarOpts: toolbarOpts,
|
|
267
|
-
pluginProps: labelPlugins
|
|
371
|
+
pluginProps: labelPlugins,
|
|
372
|
+
spellCheck: spellCheckEnabled,
|
|
373
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
374
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
375
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
376
|
+
languageCharactersProps: [{
|
|
377
|
+
language: 'spanish'
|
|
378
|
+
}, {
|
|
379
|
+
language: 'special'
|
|
380
|
+
}]
|
|
268
381
|
})), accessibilityLabelsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
269
382
|
key: "accessibility-".concat(index),
|
|
270
383
|
label: accessibility.label,
|
|
@@ -278,79 +391,37 @@ var Design = (0, _styles.withStyles)(styles)(function (props) {
|
|
|
278
391
|
}));
|
|
279
392
|
},
|
|
280
393
|
imageSupport: imageSupport,
|
|
281
|
-
pluginProps: labelPlugins
|
|
394
|
+
pluginProps: labelPlugins,
|
|
395
|
+
spellCheck: spellCheckEnabled,
|
|
396
|
+
maxImageWidth: maxImageWidth && maxImageWidth.choices || defaultImageMaxWidth,
|
|
397
|
+
maxImageHeight: maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight,
|
|
398
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
399
|
+
languageCharactersProps: [{
|
|
400
|
+
language: 'spanish'
|
|
401
|
+
}, {
|
|
402
|
+
language: 'special'
|
|
403
|
+
}]
|
|
282
404
|
})));
|
|
283
|
-
}),
|
|
284
|
-
|
|
405
|
+
}), correctResponseError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
406
|
+
className: classes.errorText
|
|
407
|
+
}, correctResponseError), answerChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
408
|
+
className: classes.errorText
|
|
409
|
+
}, answerChoicesError), addChoiceButton.settings && /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
410
|
+
title: addChoiceButtonTooltip,
|
|
285
411
|
classes: {
|
|
286
412
|
tooltip: classes.tooltip
|
|
287
413
|
}
|
|
288
414
|
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
289
415
|
classes: {
|
|
290
|
-
root: maxAnswerChoices &&
|
|
416
|
+
root: maxAnswerChoices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices && classes.disableButton
|
|
291
417
|
},
|
|
292
418
|
className: classes.addButton,
|
|
293
419
|
variant: "contained",
|
|
294
420
|
color: "primary",
|
|
295
421
|
onClick: onAddChoice
|
|
296
|
-
}, addChoiceButton.label)));
|
|
297
|
-
|
|
298
|
-
var settingsInPanel = {
|
|
299
|
-
choiceMode: choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),
|
|
300
|
-
'sequentialChoiceLabels.enabled': sequentialChoiceLabels.settings && toggle(sequentialChoiceLabels.label, true),
|
|
301
|
-
choicePrefix: choicePrefix.settings && radio(choicePrefix.label, ['numbers', 'letters']),
|
|
302
|
-
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
303
|
-
lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
|
|
304
|
-
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
305
|
-
choicesLayout: choicesLayout.settings && dropdown(choicesLayout.label, ['vertical', 'grid', 'horizontal']),
|
|
306
|
-
gridColumns: choicesLayout.settings && model.choicesLayout === 'grid' && nrOfColumnsAvailable.length > 0 && dropdown(gridColumns.label, nrOfColumnsAvailable)
|
|
307
|
-
};
|
|
308
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
309
|
-
className: classes.design
|
|
310
|
-
}, settingsPanelDisabled ? Content : /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
|
|
311
|
-
settings: /*#__PURE__*/_react["default"].createElement(Panel, {
|
|
312
|
-
model: model,
|
|
313
|
-
onChangeModel: onChangeModel,
|
|
314
|
-
configuration: configuration,
|
|
315
|
-
onChangeConfiguration: onConfigurationChanged,
|
|
316
|
-
groups: {
|
|
317
|
-
Settings: settingsInPanel,
|
|
318
|
-
Properties: {
|
|
319
|
-
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
320
|
-
studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
|
|
321
|
-
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
322
|
-
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
323
|
-
accessibilityLabelsEnabled: accessibility.settings && toggle(accessibility.label),
|
|
324
|
-
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
})
|
|
328
|
-
}, Content));
|
|
422
|
+
}, addChoiceButton.label))));
|
|
329
423
|
});
|
|
330
424
|
|
|
331
|
-
var InfoDialog = function InfoDialog(_ref4) {
|
|
332
|
-
var open = _ref4.open,
|
|
333
|
-
onCancel = _ref4.onCancel,
|
|
334
|
-
onOk = _ref4.onOk,
|
|
335
|
-
title = _ref4.title;
|
|
336
|
-
return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
337
|
-
open: open
|
|
338
|
-
}, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, onOk && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
339
|
-
onClick: onOk,
|
|
340
|
-
color: "primary"
|
|
341
|
-
}, "OK"), onCancel && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
342
|
-
onClick: onCancel,
|
|
343
|
-
color: "primary"
|
|
344
|
-
}, "Cancel")));
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
InfoDialog.propTypes = {
|
|
348
|
-
open: _propTypes["default"].bool,
|
|
349
|
-
onCancel: _propTypes["default"].func,
|
|
350
|
-
onOk: _propTypes["default"].func,
|
|
351
|
-
title: _propTypes["default"].string
|
|
352
|
-
};
|
|
353
|
-
|
|
354
425
|
var Main = /*#__PURE__*/function (_React$Component) {
|
|
355
426
|
(0, _inherits2["default"])(Main, _React$Component);
|
|
356
427
|
|
|
@@ -367,49 +438,33 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
367
438
|
|
|
368
439
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
369
440
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
370
|
-
|
|
371
|
-
open: false
|
|
372
|
-
}
|
|
441
|
+
showWarning: false
|
|
373
442
|
});
|
|
374
443
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRemoveChoice", function (index) {
|
|
375
444
|
var _this$props = _this.props,
|
|
376
445
|
model = _this$props.model,
|
|
377
|
-
configuration = _this$props.configuration
|
|
446
|
+
configuration = _this$props.configuration,
|
|
447
|
+
onModelChanged = _this$props.onModelChanged;
|
|
378
448
|
|
|
379
449
|
var _ref5 = configuration || {},
|
|
380
450
|
minAnswerChoices = _ref5.minAnswerChoices;
|
|
381
451
|
|
|
382
452
|
if (minAnswerChoices && model.choices.length === minAnswerChoices) {
|
|
383
453
|
_this.setState({
|
|
384
|
-
|
|
385
|
-
open: true,
|
|
386
|
-
message: "There can't be less than ".concat(minAnswerChoices, " choices."),
|
|
387
|
-
onOk: function onOk() {
|
|
388
|
-
_this.setState({
|
|
389
|
-
dialog: {
|
|
390
|
-
open: false
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
},
|
|
394
|
-
onCancel: function onCancel() {
|
|
395
|
-
return _this.setState({
|
|
396
|
-
dialog: {
|
|
397
|
-
open: false
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
}
|
|
454
|
+
showWarning: true
|
|
402
455
|
});
|
|
403
|
-
} else {
|
|
404
|
-
model.choices.splice(index, 1);
|
|
405
456
|
|
|
406
|
-
|
|
457
|
+
return;
|
|
407
458
|
}
|
|
459
|
+
|
|
460
|
+
model.choices.splice(index, 1);
|
|
461
|
+
onModelChanged(model);
|
|
408
462
|
});
|
|
409
463
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function () {
|
|
410
464
|
var _this$props2 = _this.props,
|
|
411
465
|
model = _this$props2.model,
|
|
412
|
-
configuration = _this$props2.configuration
|
|
466
|
+
configuration = _this$props2.configuration,
|
|
467
|
+
onModelChanged = _this$props2.onModelChanged;
|
|
413
468
|
|
|
414
469
|
var _ref6 = configuration || {},
|
|
415
470
|
maxAnswerChoices = _ref6.maxAnswerChoices;
|
|
@@ -422,43 +477,25 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
422
477
|
maxAnswerChoices = MAX_CHOICES;
|
|
423
478
|
}
|
|
424
479
|
|
|
425
|
-
if (maxAnswerChoices && model.choices.length
|
|
426
|
-
|
|
427
|
-
dialog: {
|
|
428
|
-
open: true,
|
|
429
|
-
message: "There can't be more than ".concat(maxAnswerChoices, " choices."),
|
|
430
|
-
onOk: function onOk() {
|
|
431
|
-
_this.setState({
|
|
432
|
-
dialog: {
|
|
433
|
-
open: false
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
},
|
|
437
|
-
onCancel: function onCancel() {
|
|
438
|
-
return _this.setState({
|
|
439
|
-
dialog: {
|
|
440
|
-
open: false
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
} else {
|
|
447
|
-
model.choices.push({
|
|
448
|
-
label: '',
|
|
449
|
-
value: _configUi.choiceUtils.firstAvailableIndex(model.choices.map(function (c) {
|
|
450
|
-
return c.value;
|
|
451
|
-
}), 0),
|
|
452
|
-
feedback: {
|
|
453
|
-
type: 'none'
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
_this.props.onModelChanged(model);
|
|
480
|
+
if (maxAnswerChoices && model.choices.length >= maxAnswerChoices) {
|
|
481
|
+
return;
|
|
458
482
|
}
|
|
483
|
+
|
|
484
|
+
model.choices.push({
|
|
485
|
+
label: '',
|
|
486
|
+
value: _configUi.choiceUtils.firstAvailableIndex(model.choices.map(function (c) {
|
|
487
|
+
return c.value;
|
|
488
|
+
}), 0),
|
|
489
|
+
feedback: {
|
|
490
|
+
type: 'none'
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
onModelChanged(model);
|
|
459
494
|
});
|
|
460
495
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (index, choice) {
|
|
461
|
-
var
|
|
496
|
+
var _this$props3 = _this.props,
|
|
497
|
+
model = _this$props3.model,
|
|
498
|
+
onModelChanged = _this$props3.onModelChanged;
|
|
462
499
|
|
|
463
500
|
if (choice.correct && model.choiceMode === 'radio') {
|
|
464
501
|
model.choices = model.choices.map(function (c) {
|
|
@@ -469,8 +506,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
469
506
|
}
|
|
470
507
|
|
|
471
508
|
model.choices.splice(index, 1, choice);
|
|
472
|
-
|
|
473
|
-
_this.props.onModelChanged(model);
|
|
509
|
+
onModelChanged(model);
|
|
474
510
|
});
|
|
475
511
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
|
|
476
512
|
_this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
|
|
@@ -521,12 +557,21 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
521
557
|
(0, _createClass2["default"])(Main, [{
|
|
522
558
|
key: "render",
|
|
523
559
|
value: function render() {
|
|
524
|
-
var
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
560
|
+
var _this2 = this;
|
|
561
|
+
|
|
562
|
+
var _this$props$configura = this.props.configuration;
|
|
563
|
+
_this$props$configura = _this$props$configura === void 0 ? {} : _this$props$configura;
|
|
564
|
+
var minAnswerChoices = _this$props$configura.minAnswerChoices;
|
|
565
|
+
var showWarning = this.state.showWarning;
|
|
566
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
567
|
+
open: showWarning,
|
|
568
|
+
title: "Warning",
|
|
569
|
+
text: "There can't be less than ".concat(minAnswerChoices || 0, " choices."),
|
|
570
|
+
onConfirm: function onConfirm() {
|
|
571
|
+
return _this2.setState({
|
|
572
|
+
showWarning: false
|
|
573
|
+
});
|
|
574
|
+
}
|
|
530
575
|
}), /*#__PURE__*/_react["default"].createElement(Design, (0, _extends2["default"])({}, this.props, {
|
|
531
576
|
onChangeModel: this.onModelChanged,
|
|
532
577
|
onRemoveChoice: this.onRemoveChoice,
|