@pie-element/multiple-choice 5.9.3-next.459 → 5.9.3-next.472
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/module/configure.js +660 -0
- package/module/controller.js +20641 -0
- package/module/demo.js +77 -0
- package/module/element.js +2003 -0
- package/module/index.html +21 -0
- package/module/manifest.json +14 -0
- package/module/print-demo.js +115 -0
- package/module/print.html +18 -0
- package/module/print.js +1963 -0
- package/package.json +2 -2
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_material_ui__core, _dll_lodash, _dll_pie_lib__render_ui, _dll_debug, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.2.14/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.0.15/module/index.js";
|
|
3
|
+
import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.0.15/module/index.js";
|
|
4
|
+
var lib = {};
|
|
5
|
+
Object.defineProperty(lib, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
class ModelUpdatedEvent extends CustomEvent {
|
|
9
|
+
constructor(update, reset = false) {
|
|
10
|
+
super(ModelUpdatedEvent.TYPE, {
|
|
11
|
+
bubbles: true,
|
|
12
|
+
detail: {
|
|
13
|
+
update,
|
|
14
|
+
reset
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
this.update = update;
|
|
18
|
+
this.reset = reset;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
ModelUpdatedEvent.TYPE = 'model.updated';
|
|
22
|
+
var ModelUpdatedEvent_1 = lib.ModelUpdatedEvent = ModelUpdatedEvent;
|
|
23
|
+
class DeleteImageEvent extends CustomEvent {
|
|
24
|
+
constructor(src, done) {
|
|
25
|
+
super(DeleteImageEvent.TYPE, {
|
|
26
|
+
bubbles: true,
|
|
27
|
+
detail: {
|
|
28
|
+
src,
|
|
29
|
+
done
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.src = src;
|
|
33
|
+
this.done = done;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
DeleteImageEvent.TYPE = 'delete.image';
|
|
37
|
+
var DeleteImageEvent_1 = lib.DeleteImageEvent = DeleteImageEvent;
|
|
38
|
+
class InsertImageEvent extends CustomEvent {
|
|
39
|
+
constructor(handler) {
|
|
40
|
+
super(InsertImageEvent.TYPE, {
|
|
41
|
+
bubbles: true,
|
|
42
|
+
detail: handler
|
|
43
|
+
});
|
|
44
|
+
this.handler = handler;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
InsertImageEvent.TYPE = 'insert.image';
|
|
48
|
+
var InsertImageEvent_1 = lib.InsertImageEvent = InsertImageEvent;
|
|
49
|
+
const React$1 = _dll_react;
|
|
50
|
+
const PropTypes = _dll_prop_types;
|
|
51
|
+
const {color: color} = _dll_pie_lib__render_ui;
|
|
52
|
+
const {withStyles: withStyles} = _dll_material_ui__core_styles;
|
|
53
|
+
const {Button: Button} = _dll_material_ui__core;
|
|
54
|
+
const {Tooltip: Tooltip} = _dll_material_ui__core;
|
|
55
|
+
const {merge: merge} = _dll_lodash;
|
|
56
|
+
const EditableHtml = _dll_pie_lib__editable_html;
|
|
57
|
+
const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
|
|
58
|
+
const {ChoiceConfiguration: ChoiceConfiguration} = _dll_pie_lib__config_ui;
|
|
59
|
+
const {settings: settings} = _dll_pie_lib__config_ui;
|
|
60
|
+
const {layout: layout} = _dll_pie_lib__config_ui;
|
|
61
|
+
const {choiceUtils: utils$1} = _dll_pie_lib__config_ui;
|
|
62
|
+
const _jsxFileName = "/home/circleci/repo/packages/multiple-choice/configure/src/main.jsx";
|
|
63
|
+
const {Panel, toggle, radio, dropdown} = settings;
|
|
64
|
+
const MAX_CHOICES = 9;
|
|
65
|
+
const styles = theme => ({
|
|
66
|
+
promptHolder: {
|
|
67
|
+
width: '100%',
|
|
68
|
+
paddingBottom: theme.spacing.unit * 2,
|
|
69
|
+
marginBottom: theme.spacing.unit * 2
|
|
70
|
+
},
|
|
71
|
+
prompt: {
|
|
72
|
+
paddingTop: theme.spacing.unit * 2,
|
|
73
|
+
width: '100%'
|
|
74
|
+
},
|
|
75
|
+
rationaleHolder: {
|
|
76
|
+
width: '70%'
|
|
77
|
+
},
|
|
78
|
+
accessibilityHolder: {
|
|
79
|
+
width: '70%'
|
|
80
|
+
},
|
|
81
|
+
rationale: {
|
|
82
|
+
paddingTop: theme.spacing.unit * 2
|
|
83
|
+
},
|
|
84
|
+
accessibility: {
|
|
85
|
+
paddingTop: theme.spacing.unit * 2
|
|
86
|
+
},
|
|
87
|
+
design: {
|
|
88
|
+
paddingTop: theme.spacing.unit * 3
|
|
89
|
+
},
|
|
90
|
+
choiceConfigurationHolder: {
|
|
91
|
+
display: 'flex',
|
|
92
|
+
flexDirection: 'column',
|
|
93
|
+
alignItems: 'center'
|
|
94
|
+
},
|
|
95
|
+
choiceConfiguration: {
|
|
96
|
+
width: '100%',
|
|
97
|
+
paddingTop: theme.spacing.unit * 2,
|
|
98
|
+
paddingBottom: theme.spacing.unit * 2
|
|
99
|
+
},
|
|
100
|
+
switchElement: {
|
|
101
|
+
justifyContent: 'space-between',
|
|
102
|
+
margin: 0
|
|
103
|
+
},
|
|
104
|
+
addButton: {
|
|
105
|
+
float: 'right'
|
|
106
|
+
},
|
|
107
|
+
disableButton: {
|
|
108
|
+
cursor: 'not-allowed',
|
|
109
|
+
pointerEvents: 'all',
|
|
110
|
+
backgroundColor: color.disabled(),
|
|
111
|
+
'&:hover': {
|
|
112
|
+
backgroundColor: color.disabled()
|
|
113
|
+
},
|
|
114
|
+
'&:focus': {
|
|
115
|
+
backgroundColor: color.disabled()
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
const Design = withStyles(styles)(props => {
|
|
120
|
+
const {classes, model, configuration, onPromptChanged, onChoiceChanged, onRemoveChoice, onAddChoice, imageSupport, onChangeModel, onConfigurationChanged, onTeacherInstructionsChanged} = props;
|
|
121
|
+
const {prompt = {}, addChoiceButton = {}, limitChoicesNumber = {}, feedback = {}, deleteChoice = {}, choiceMode = {}, choicePrefix = {}, partialScoring = {}, lockChoiceOrder = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, accessibility = {}, scoringType = {}, sequentialChoiceLabels = {}, settingsPanelDisabled, choicesLayout, gridColumns} = configuration || ({});
|
|
122
|
+
const {limitChoicesNumber: limitChoicesNumberModel, teacherInstructionsEnabled, rationaleEnabled, accessibilityLabelsEnabled, feedbackEnabled, promptEnabled, choices} = model || ({});
|
|
123
|
+
const nrOfColumnsAvailable = choices && choices.length ? Array.from({
|
|
124
|
+
length: choices.length
|
|
125
|
+
}, (_, i) => `${i + 1}`) : [];
|
|
126
|
+
const labelPlugins = {
|
|
127
|
+
audio: {
|
|
128
|
+
disabled: true
|
|
129
|
+
},
|
|
130
|
+
video: {
|
|
131
|
+
disabled: true
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const toolbarOpts = {};
|
|
135
|
+
switch (model.toolbarEditorPosition) {
|
|
136
|
+
case 'top':
|
|
137
|
+
toolbarOpts.position = 'top';
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
toolbarOpts.position = 'bottom';
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
const Content = React$1.createElement('div', {
|
|
144
|
+
__self: undefined,
|
|
145
|
+
__source: {
|
|
146
|
+
fileName: _jsxFileName,
|
|
147
|
+
lineNumber: 141
|
|
148
|
+
}
|
|
149
|
+
}, teacherInstructionsEnabled && React$1.createElement(InputContainer, {
|
|
150
|
+
label: teacherInstructions.label,
|
|
151
|
+
className: classes.promptHolder,
|
|
152
|
+
__self: undefined,
|
|
153
|
+
__source: {
|
|
154
|
+
fileName: _jsxFileName,
|
|
155
|
+
lineNumber: 143
|
|
156
|
+
}
|
|
157
|
+
}, React$1.createElement(EditableHtml, {
|
|
158
|
+
className: classes.prompt,
|
|
159
|
+
markup: model.teacherInstructions || '',
|
|
160
|
+
onChange: onTeacherInstructionsChanged,
|
|
161
|
+
imageSupport: imageSupport,
|
|
162
|
+
nonEmpty: false,
|
|
163
|
+
toolbarOpts: toolbarOpts,
|
|
164
|
+
__self: undefined,
|
|
165
|
+
__source: {
|
|
166
|
+
fileName: _jsxFileName,
|
|
167
|
+
lineNumber: 147
|
|
168
|
+
}
|
|
169
|
+
})), promptEnabled && React$1.createElement(InputContainer, {
|
|
170
|
+
label: prompt.label,
|
|
171
|
+
className: classes.promptHolder,
|
|
172
|
+
__self: undefined,
|
|
173
|
+
__source: {
|
|
174
|
+
fileName: _jsxFileName,
|
|
175
|
+
lineNumber: 159
|
|
176
|
+
}
|
|
177
|
+
}, React$1.createElement(EditableHtml, {
|
|
178
|
+
className: classes.prompt,
|
|
179
|
+
markup: model.prompt,
|
|
180
|
+
onChange: onPromptChanged,
|
|
181
|
+
imageSupport: imageSupport,
|
|
182
|
+
nonEmpty: false,
|
|
183
|
+
disableUnderline: true,
|
|
184
|
+
toolbarOpts: toolbarOpts,
|
|
185
|
+
__self: undefined,
|
|
186
|
+
__source: {
|
|
187
|
+
fileName: _jsxFileName,
|
|
188
|
+
lineNumber: 160
|
|
189
|
+
}
|
|
190
|
+
})), model.choices.map((choice, index) => React$1.createElement('div', {
|
|
191
|
+
key: `choice-${index}`,
|
|
192
|
+
className: classes.choiceConfigurationHolder,
|
|
193
|
+
__self: undefined,
|
|
194
|
+
__source: {
|
|
195
|
+
fileName: _jsxFileName,
|
|
196
|
+
lineNumber: 172
|
|
197
|
+
}
|
|
198
|
+
}, React$1.createElement(ChoiceConfiguration, {
|
|
199
|
+
key: index,
|
|
200
|
+
index: index + 1,
|
|
201
|
+
useLetterOrdering: model.choicePrefix === 'letters',
|
|
202
|
+
className: classes.choiceConfiguration,
|
|
203
|
+
mode: model.choiceMode,
|
|
204
|
+
data: choice,
|
|
205
|
+
defaultFeedback: {},
|
|
206
|
+
imageSupport: imageSupport,
|
|
207
|
+
onDelete: () => onRemoveChoice(index),
|
|
208
|
+
onChange: c => onChoiceChanged(index, c),
|
|
209
|
+
allowFeedBack: feedbackEnabled,
|
|
210
|
+
allowDelete: deleteChoice.settings,
|
|
211
|
+
noLabels: true,
|
|
212
|
+
toolbarOpts: toolbarOpts,
|
|
213
|
+
__self: undefined,
|
|
214
|
+
__source: {
|
|
215
|
+
fileName: _jsxFileName,
|
|
216
|
+
lineNumber: 176
|
|
217
|
+
}
|
|
218
|
+
}), rationaleEnabled && React$1.createElement(InputContainer, {
|
|
219
|
+
key: `rationale-${index}`,
|
|
220
|
+
label: rationale.label,
|
|
221
|
+
className: classes.rationaleHolder,
|
|
222
|
+
__self: undefined,
|
|
223
|
+
__source: {
|
|
224
|
+
fileName: _jsxFileName,
|
|
225
|
+
lineNumber: 193
|
|
226
|
+
}
|
|
227
|
+
}, React$1.createElement(EditableHtml, {
|
|
228
|
+
className: classes.rationale,
|
|
229
|
+
markup: choice.rationale || '',
|
|
230
|
+
onChange: c => onChoiceChanged(index, {
|
|
231
|
+
...choice,
|
|
232
|
+
rationale: c
|
|
233
|
+
}),
|
|
234
|
+
imageSupport: imageSupport,
|
|
235
|
+
toolbarOpts: toolbarOpts,
|
|
236
|
+
pluginProps: labelPlugins,
|
|
237
|
+
__self: undefined,
|
|
238
|
+
__source: {
|
|
239
|
+
fileName: _jsxFileName,
|
|
240
|
+
lineNumber: 198
|
|
241
|
+
}
|
|
242
|
+
})), accessibilityLabelsEnabled && React$1.createElement(InputContainer, {
|
|
243
|
+
key: `accessibility-${index}`,
|
|
244
|
+
label: accessibility.label,
|
|
245
|
+
className: classes.accessibilityHolder,
|
|
246
|
+
__self: undefined,
|
|
247
|
+
__source: {
|
|
248
|
+
fileName: _jsxFileName,
|
|
249
|
+
lineNumber: 214
|
|
250
|
+
}
|
|
251
|
+
}, React$1.createElement(EditableHtml, {
|
|
252
|
+
className: classes.accessibility,
|
|
253
|
+
markup: choice.accessibility || '',
|
|
254
|
+
onChange: c => onChoiceChanged(index, {
|
|
255
|
+
...choice,
|
|
256
|
+
accessibility: c
|
|
257
|
+
}),
|
|
258
|
+
imageSupport: imageSupport,
|
|
259
|
+
pluginProps: labelPlugins,
|
|
260
|
+
__self: undefined,
|
|
261
|
+
__source: {
|
|
262
|
+
fileName: _jsxFileName,
|
|
263
|
+
lineNumber: 219
|
|
264
|
+
}
|
|
265
|
+
})))), React$1.createElement('br', {
|
|
266
|
+
__self: undefined,
|
|
267
|
+
__source: {
|
|
268
|
+
fileName: _jsxFileName,
|
|
269
|
+
lineNumber: 235
|
|
270
|
+
}
|
|
271
|
+
}), addChoiceButton.settings && React$1.createElement(Tooltip, {
|
|
272
|
+
title: limitChoicesNumberModel && model.choices.length >= MAX_CHOICES ? `Only ${MAX_CHOICES} allowed maximum` : '',
|
|
273
|
+
classes: {
|
|
274
|
+
tooltip: classes.tooltip
|
|
275
|
+
},
|
|
276
|
+
__self: undefined,
|
|
277
|
+
__source: {
|
|
278
|
+
fileName: _jsxFileName,
|
|
279
|
+
lineNumber: 237
|
|
280
|
+
}
|
|
281
|
+
}, React$1.createElement(Button, {
|
|
282
|
+
classes: {
|
|
283
|
+
root: limitChoicesNumberModel && model.choices.length >= MAX_CHOICES ? classes.disableButton : undefined
|
|
284
|
+
},
|
|
285
|
+
className: classes.addButton,
|
|
286
|
+
variant: "contained",
|
|
287
|
+
color: "primary",
|
|
288
|
+
onClick: onAddChoice,
|
|
289
|
+
__self: undefined,
|
|
290
|
+
__source: {
|
|
291
|
+
fileName: _jsxFileName,
|
|
292
|
+
lineNumber: 238
|
|
293
|
+
}
|
|
294
|
+
}, addChoiceButton.label)));
|
|
295
|
+
const settingsInPanel = {
|
|
296
|
+
choiceMode: choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),
|
|
297
|
+
'sequentialChoiceLabels.enabled': sequentialChoiceLabels.settings && toggle(sequentialChoiceLabels.label, true),
|
|
298
|
+
choicePrefix: choicePrefix.settings && radio(choicePrefix.label, ['numbers', 'letters']),
|
|
299
|
+
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
300
|
+
limitChoicesNumber: limitChoicesNumber.settings && toggle(limitChoicesNumber.label),
|
|
301
|
+
lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
|
|
302
|
+
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
303
|
+
choicesLayout: choicesLayout.settings && dropdown(choicesLayout.label, ['vertical', 'grid', 'horizontal']),
|
|
304
|
+
gridColumns: choicesLayout.settings && model.choicesLayout === 'grid' && nrOfColumnsAvailable.length > 0 && dropdown(gridColumns.label, nrOfColumnsAvailable)
|
|
305
|
+
};
|
|
306
|
+
return React$1.createElement('div', {
|
|
307
|
+
className: classes.design,
|
|
308
|
+
__self: undefined,
|
|
309
|
+
__source: {
|
|
310
|
+
fileName: _jsxFileName,
|
|
311
|
+
lineNumber: 278
|
|
312
|
+
}
|
|
313
|
+
}, settingsPanelDisabled ? Content : React$1.createElement(layout.ConfigLayout, {
|
|
314
|
+
settings: React$1.createElement(Panel, {
|
|
315
|
+
model: model,
|
|
316
|
+
onChangeModel: onChangeModel,
|
|
317
|
+
configuration: configuration,
|
|
318
|
+
onChangeConfiguration: onConfigurationChanged,
|
|
319
|
+
groups: {
|
|
320
|
+
Settings: settingsInPanel,
|
|
321
|
+
Properties: {
|
|
322
|
+
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
323
|
+
studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
|
|
324
|
+
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
325
|
+
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
326
|
+
accessibilityLabelsEnabled: accessibility.settings && toggle(accessibility.label),
|
|
327
|
+
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
__self: undefined,
|
|
331
|
+
__source: {
|
|
332
|
+
fileName: _jsxFileName,
|
|
333
|
+
lineNumber: 284
|
|
334
|
+
}
|
|
335
|
+
}),
|
|
336
|
+
__self: undefined,
|
|
337
|
+
__source: {
|
|
338
|
+
fileName: _jsxFileName,
|
|
339
|
+
lineNumber: 282
|
|
340
|
+
}
|
|
341
|
+
}, Content));
|
|
342
|
+
});
|
|
343
|
+
class Main extends React$1.Component {
|
|
344
|
+
constructor(...args) {
|
|
345
|
+
super(...args);
|
|
346
|
+
Main.prototype.__init.call(this);
|
|
347
|
+
Main.prototype.__init2.call(this);
|
|
348
|
+
Main.prototype.__init3.call(this);
|
|
349
|
+
Main.prototype.__init4.call(this);
|
|
350
|
+
Main.prototype.__init5.call(this);
|
|
351
|
+
Main.prototype.__init6.call(this);
|
|
352
|
+
}
|
|
353
|
+
static __initStatic() {
|
|
354
|
+
this.propTypes = {
|
|
355
|
+
model: PropTypes.object.isRequired,
|
|
356
|
+
disableSidePanel: PropTypes.bool,
|
|
357
|
+
onModelChanged: PropTypes.func.isRequired,
|
|
358
|
+
onConfigurationChanged: PropTypes.func.isRequired,
|
|
359
|
+
classes: PropTypes.object.isRequired,
|
|
360
|
+
imageSupport: PropTypes.shape({
|
|
361
|
+
add: PropTypes.func.isRequired,
|
|
362
|
+
delete: PropTypes.func.isRequired
|
|
363
|
+
})
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
__init() {
|
|
367
|
+
this.onRemoveChoice = index => {
|
|
368
|
+
const {model} = this.props;
|
|
369
|
+
model.choices.splice(index, 1);
|
|
370
|
+
this.props.onModelChanged(model);
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
__init2() {
|
|
374
|
+
this.onAddChoice = () => {
|
|
375
|
+
const {model} = this.props;
|
|
376
|
+
if (!model.limitChoicesNumber || model.limitChoicesNumber && model.choices.length < MAX_CHOICES) {
|
|
377
|
+
model.choices.push({
|
|
378
|
+
label: '',
|
|
379
|
+
value: utils$1.firstAvailableIndex(model.choices.map(c => c.value), 0),
|
|
380
|
+
feedback: {
|
|
381
|
+
type: 'none'
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
this.props.onModelChanged(model);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
__init3() {
|
|
389
|
+
this.onChoiceChanged = (index, choice) => {
|
|
390
|
+
const {model} = this.props;
|
|
391
|
+
if (choice.correct && model.choiceMode === 'radio') {
|
|
392
|
+
model.choices = model.choices.map(c => {
|
|
393
|
+
return merge({}, c, {
|
|
394
|
+
correct: false
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
model.choices.splice(index, 1, choice);
|
|
399
|
+
this.props.onModelChanged(model);
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
__init4() {
|
|
403
|
+
this.onPromptChanged = prompt => {
|
|
404
|
+
this.props.onModelChanged({
|
|
405
|
+
...this.props.model,
|
|
406
|
+
prompt
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
__init5() {
|
|
411
|
+
this.onTeacherInstructionsChanged = teacherInstructions => {
|
|
412
|
+
this.props.onModelChanged({
|
|
413
|
+
...this.props.model,
|
|
414
|
+
teacherInstructions
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
__init6() {
|
|
419
|
+
this.onModelChanged = (model, key) => {
|
|
420
|
+
const {onModelChanged} = this.props;
|
|
421
|
+
switch (key) {
|
|
422
|
+
case 'choiceMode':
|
|
423
|
+
{
|
|
424
|
+
let value = model.choiceMode;
|
|
425
|
+
if (value === 'radio') {
|
|
426
|
+
let correctFound = false;
|
|
427
|
+
model.choices = model.choices.map(c => {
|
|
428
|
+
if (correctFound) {
|
|
429
|
+
c.correct = false;
|
|
430
|
+
return c;
|
|
431
|
+
}
|
|
432
|
+
if (c.correct) {
|
|
433
|
+
correctFound = true;
|
|
434
|
+
}
|
|
435
|
+
return c;
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
onModelChanged(model, true);
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
default:
|
|
442
|
+
onModelChanged(model);
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
render() {
|
|
448
|
+
return React$1.createElement(Design, {
|
|
449
|
+
...this.props,
|
|
450
|
+
onChangeModel: this.onModelChanged,
|
|
451
|
+
onRemoveChoice: this.onRemoveChoice,
|
|
452
|
+
onChoiceChanged: this.onChoiceChanged,
|
|
453
|
+
onAddChoice: this.onAddChoice,
|
|
454
|
+
onPromptChanged: this.onPromptChanged,
|
|
455
|
+
onTeacherInstructionsChanged: this.onTeacherInstructionsChanged,
|
|
456
|
+
__self: this,
|
|
457
|
+
__source: {
|
|
458
|
+
fileName: _jsxFileName,
|
|
459
|
+
lineNumber: 414
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
Main.__initStatic();
|
|
465
|
+
const Styled = withStyles(styles)(Main);
|
|
466
|
+
var sensibleDefaults = {
|
|
467
|
+
model: {
|
|
468
|
+
choiceMode: 'checkbox',
|
|
469
|
+
choicePrefix: 'letters',
|
|
470
|
+
choices: [],
|
|
471
|
+
prompt: 'Question Prompt goes here',
|
|
472
|
+
lockChoiceOrder: true,
|
|
473
|
+
partialScoring: true,
|
|
474
|
+
scoringType: 'auto',
|
|
475
|
+
feedbackEnabled: true,
|
|
476
|
+
promptEnabled: true,
|
|
477
|
+
rationaleEnabled: true,
|
|
478
|
+
limitChoicesNumber: true,
|
|
479
|
+
teacherInstructionsEnabled: true,
|
|
480
|
+
studentInstructionsEnabled: true,
|
|
481
|
+
toolbarEditorPosition: 'bottom',
|
|
482
|
+
choicesLayout: 'vertical',
|
|
483
|
+
gridColumns: '2'
|
|
484
|
+
},
|
|
485
|
+
configuration: {
|
|
486
|
+
choicesLayout: {
|
|
487
|
+
settings: false,
|
|
488
|
+
label: 'Choices Layout'
|
|
489
|
+
},
|
|
490
|
+
gridColumns: {
|
|
491
|
+
label: 'Grid columns'
|
|
492
|
+
},
|
|
493
|
+
answerChoiceCount: 0,
|
|
494
|
+
addChoiceButton: {
|
|
495
|
+
settings: true,
|
|
496
|
+
label: 'Add a Choice'
|
|
497
|
+
},
|
|
498
|
+
limitChoicesNumber: {
|
|
499
|
+
settings: true,
|
|
500
|
+
label: 'Limit choices to 9'
|
|
501
|
+
},
|
|
502
|
+
choiceMode: {
|
|
503
|
+
settings: true,
|
|
504
|
+
label: 'Response Type'
|
|
505
|
+
},
|
|
506
|
+
choicePrefix: {
|
|
507
|
+
settings: true,
|
|
508
|
+
label: 'Choice Labels'
|
|
509
|
+
},
|
|
510
|
+
deleteChoice: {
|
|
511
|
+
settings: true
|
|
512
|
+
},
|
|
513
|
+
feedback: {
|
|
514
|
+
settings: true,
|
|
515
|
+
label: 'Feedback'
|
|
516
|
+
},
|
|
517
|
+
prompt: {
|
|
518
|
+
settings: true,
|
|
519
|
+
label: 'Prompt'
|
|
520
|
+
},
|
|
521
|
+
lockChoiceOrder: {
|
|
522
|
+
settings: true,
|
|
523
|
+
label: 'Lock Choice Order'
|
|
524
|
+
},
|
|
525
|
+
partialScoring: {
|
|
526
|
+
settings: false,
|
|
527
|
+
label: 'Allow Partial Scoring'
|
|
528
|
+
},
|
|
529
|
+
rationale: {
|
|
530
|
+
settings: true,
|
|
531
|
+
label: 'Rationale'
|
|
532
|
+
},
|
|
533
|
+
accessibility: {
|
|
534
|
+
settings: false,
|
|
535
|
+
label: 'Accessibility Label'
|
|
536
|
+
},
|
|
537
|
+
scoringType: {
|
|
538
|
+
settings: false,
|
|
539
|
+
label: 'Scoring Type'
|
|
540
|
+
},
|
|
541
|
+
studentInstructions: {
|
|
542
|
+
settings: false,
|
|
543
|
+
label: 'Student Instructions'
|
|
544
|
+
},
|
|
545
|
+
teacherInstructions: {
|
|
546
|
+
settings: true,
|
|
547
|
+
label: 'Teacher Instructions'
|
|
548
|
+
},
|
|
549
|
+
toolbarEditorPosition: {
|
|
550
|
+
settings: false,
|
|
551
|
+
label: 'Toolbar Editor Position'
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const React = _dll_react;
|
|
556
|
+
const ReactDOM = _dll_react_dom;
|
|
557
|
+
const debug = _dll_debug;
|
|
558
|
+
const {defaults: defaults} = _dll_lodash;
|
|
559
|
+
const {choiceUtils: utils} = _dll_pie_lib__config_ui;
|
|
560
|
+
const log = debug('multiple-choice:configure');
|
|
561
|
+
const generateFormattedChoices = (choices, choiceCount = 0) => {
|
|
562
|
+
if (!choices || choices.length === 0) {
|
|
563
|
+
let formattedChoices = [];
|
|
564
|
+
for (let i = 0; i < choiceCount; i++) {
|
|
565
|
+
formattedChoices.push({
|
|
566
|
+
value: `${i}`,
|
|
567
|
+
label: '',
|
|
568
|
+
feedback: {
|
|
569
|
+
type: 'none',
|
|
570
|
+
value: ''
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
return formattedChoices;
|
|
575
|
+
}
|
|
576
|
+
return choices;
|
|
577
|
+
};
|
|
578
|
+
const prepareCustomizationObject = (config, model) => {
|
|
579
|
+
const configuration = defaults(config, sensibleDefaults.configuration);
|
|
580
|
+
return {
|
|
581
|
+
configuration,
|
|
582
|
+
model: {
|
|
583
|
+
...model,
|
|
584
|
+
choices: generateFormattedChoices(model && model.choices || [], configuration && configuration.answerChoiceCount)
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
class MultipleChoice extends HTMLElement {
|
|
589
|
+
static __initStatic() {
|
|
590
|
+
this.createDefaultModel = (model = {}) => {
|
|
591
|
+
const normalizedModel = utils.normalizeChoices({
|
|
592
|
+
...sensibleDefaults.model,
|
|
593
|
+
...model,
|
|
594
|
+
choices: generateFormattedChoices(model && model.choices || [])
|
|
595
|
+
});
|
|
596
|
+
normalizedModel.choicesLayout = model.choicesLayout || model.verticalMode === false && 'horizontal' || sensibleDefaults.model.choicesLayout;
|
|
597
|
+
return normalizedModel;
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
constructor() {
|
|
601
|
+
super();
|
|
602
|
+
this._model = MultipleChoice.createDefaultModel();
|
|
603
|
+
this._configuration = sensibleDefaults.configuration;
|
|
604
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
605
|
+
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
606
|
+
}
|
|
607
|
+
set model(s) {
|
|
608
|
+
this._model = MultipleChoice.createDefaultModel(s);
|
|
609
|
+
this._render();
|
|
610
|
+
}
|
|
611
|
+
set configuration(c) {
|
|
612
|
+
const info = prepareCustomizationObject(c, this._model);
|
|
613
|
+
this.onModelChanged(info.model);
|
|
614
|
+
this._configuration = info.configuration;
|
|
615
|
+
this._render();
|
|
616
|
+
}
|
|
617
|
+
set disableSidePanel(s) {
|
|
618
|
+
this._disableSidePanel = s;
|
|
619
|
+
this._render();
|
|
620
|
+
}
|
|
621
|
+
dispatchModelUpdated(reset) {
|
|
622
|
+
const resetValue = !!reset;
|
|
623
|
+
this.dispatchEvent(new ModelUpdatedEvent_1(this._model, resetValue));
|
|
624
|
+
}
|
|
625
|
+
onModelChanged(m, reset) {
|
|
626
|
+
this._model = m;
|
|
627
|
+
this._render();
|
|
628
|
+
this.dispatchModelUpdated(reset);
|
|
629
|
+
}
|
|
630
|
+
onConfigurationChanged(c) {
|
|
631
|
+
this._configuration = prepareCustomizationObject(c, this._model).configuration;
|
|
632
|
+
if (this._model) {
|
|
633
|
+
this.onModelChanged(this._model);
|
|
634
|
+
}
|
|
635
|
+
this._render();
|
|
636
|
+
}
|
|
637
|
+
insertImage(handler) {
|
|
638
|
+
this.dispatchEvent(new InsertImageEvent_1(handler));
|
|
639
|
+
}
|
|
640
|
+
onDeleteImage(src, done) {
|
|
641
|
+
this.dispatchEvent(new DeleteImageEvent_1(src, done));
|
|
642
|
+
}
|
|
643
|
+
_render() {
|
|
644
|
+
log('_render');
|
|
645
|
+
let element = React.createElement(Styled, {
|
|
646
|
+
model: this._model,
|
|
647
|
+
configuration: this._configuration,
|
|
648
|
+
onModelChanged: this.onModelChanged,
|
|
649
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
650
|
+
disableSidePanel: this._disableSidePanel,
|
|
651
|
+
imageSupport: {
|
|
652
|
+
add: this.insertImage.bind(this),
|
|
653
|
+
delete: this.onDeleteImage.bind(this)
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
ReactDOM.render(element, this);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
MultipleChoice.__initStatic();
|
|
660
|
+
export {MultipleChoice as default};
|