@pie-element/multiple-choice 5.9.2 → 5.9.3-next.1008

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 (47) hide show
  1. package/CHANGELOG.md +203 -0
  2. package/PRINT.md +35 -0
  3. package/configure/CHANGELOG.md +172 -0
  4. package/configure/lib/defaults.js +36 -9
  5. package/configure/lib/defaults.js.map +1 -1
  6. package/configure/lib/index.js +10 -5
  7. package/configure/lib/index.js.map +1 -1
  8. package/configure/lib/main.js +263 -49
  9. package/configure/lib/main.js.map +1 -1
  10. package/configure/lib/utils.js +18 -0
  11. package/configure/lib/utils.js.map +1 -0
  12. package/configure/package.json +4 -4
  13. package/controller/CHANGELOG.md +43 -0
  14. package/controller/lib/defaults.js +4 -2
  15. package/controller/lib/defaults.js.map +1 -1
  16. package/controller/lib/index.js +85 -9
  17. package/controller/lib/index.js.map +1 -1
  18. package/controller/lib/utils.js +9 -1
  19. package/controller/lib/utils.js.map +1 -1
  20. package/controller/package.json +1 -1
  21. package/docs/config-schema.json +137 -1
  22. package/docs/config-schema.json.md +107 -3
  23. package/docs/demo/generate.js +10 -5
  24. package/docs/pie-schema.json +63 -4
  25. package/docs/pie-schema.json.md +53 -2
  26. package/lib/choice-input.js +44 -20
  27. package/lib/choice-input.js.map +1 -1
  28. package/lib/choice.js +157 -0
  29. package/lib/choice.js.map +1 -0
  30. package/lib/feedback-tick.js +1 -1
  31. package/lib/feedback-tick.js.map +1 -1
  32. package/lib/index.js +2 -2
  33. package/lib/index.js.map +1 -1
  34. package/lib/main.js +1 -1
  35. package/lib/main.js.map +1 -1
  36. package/lib/multiple-choice.js +70 -143
  37. package/lib/multiple-choice.js.map +1 -1
  38. package/lib/print.js +129 -0
  39. package/lib/print.js.map +1 -0
  40. package/package.json +11 -7
  41. package/docs/demo/pie.manifest.json +0 -11
  42. package/module/configure.js +0 -881
  43. package/module/controller.js +0 -20268
  44. package/module/demo.js +0 -74
  45. package/module/element.js +0 -1221
  46. package/module/index.html +0 -16
  47. package/module/manifest.json +0 -10
@@ -1,881 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_material_ui__core, _dll_lodash, _dll_pie_lib__render_ui, _dll_react_dom} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
2
- import {_dll_pie_lib__editable_html, _dll_pie_lib__config_ui, _dll_pie_framework__pie_configure_events} from "../../shared-config@^1.8.13/module/index.js";
3
- function createCommonjsModule(fn, module) {
4
- return (module = {
5
- exports: {}
6
- }, fn(module, module.exports), module.exports);
7
- }
8
- var s = 1000;
9
- var m = s * 60;
10
- var h = m * 60;
11
- var d = h * 24;
12
- var w = d * 7;
13
- var y = d * 365.25;
14
- var ms = function (val, options) {
15
- options = options || ({});
16
- var type = typeof val;
17
- if (type === 'string' && val.length > 0) {
18
- return parse(val);
19
- } else if (type === 'number' && isFinite(val)) {
20
- return options.long ? fmtLong(val) : fmtShort(val);
21
- }
22
- throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
23
- };
24
- function parse(str) {
25
- str = String(str);
26
- if (str.length > 100) {
27
- return;
28
- }
29
- var match = (/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i).exec(str);
30
- if (!match) {
31
- return;
32
- }
33
- var n = parseFloat(match[1]);
34
- var type = (match[2] || 'ms').toLowerCase();
35
- switch (type) {
36
- case 'years':
37
- case 'year':
38
- case 'yrs':
39
- case 'yr':
40
- case 'y':
41
- return n * y;
42
- case 'weeks':
43
- case 'week':
44
- case 'w':
45
- return n * w;
46
- case 'days':
47
- case 'day':
48
- case 'd':
49
- return n * d;
50
- case 'hours':
51
- case 'hour':
52
- case 'hrs':
53
- case 'hr':
54
- case 'h':
55
- return n * h;
56
- case 'minutes':
57
- case 'minute':
58
- case 'mins':
59
- case 'min':
60
- case 'm':
61
- return n * m;
62
- case 'seconds':
63
- case 'second':
64
- case 'secs':
65
- case 'sec':
66
- case 's':
67
- return n * s;
68
- case 'milliseconds':
69
- case 'millisecond':
70
- case 'msecs':
71
- case 'msec':
72
- case 'ms':
73
- return n;
74
- default:
75
- return undefined;
76
- }
77
- }
78
- function fmtShort(ms) {
79
- var msAbs = Math.abs(ms);
80
- if (msAbs >= d) {
81
- return Math.round(ms / d) + 'd';
82
- }
83
- if (msAbs >= h) {
84
- return Math.round(ms / h) + 'h';
85
- }
86
- if (msAbs >= m) {
87
- return Math.round(ms / m) + 'm';
88
- }
89
- if (msAbs >= s) {
90
- return Math.round(ms / s) + 's';
91
- }
92
- return ms + 'ms';
93
- }
94
- function fmtLong(ms) {
95
- var msAbs = Math.abs(ms);
96
- if (msAbs >= d) {
97
- return plural(ms, msAbs, d, 'day');
98
- }
99
- if (msAbs >= h) {
100
- return plural(ms, msAbs, h, 'hour');
101
- }
102
- if (msAbs >= m) {
103
- return plural(ms, msAbs, m, 'minute');
104
- }
105
- if (msAbs >= s) {
106
- return plural(ms, msAbs, s, 'second');
107
- }
108
- return ms + ' ms';
109
- }
110
- function plural(ms, msAbs, n, name) {
111
- var isPlural = msAbs >= n * 1.5;
112
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
113
- }
114
- function setup(env) {
115
- createDebug.debug = createDebug;
116
- createDebug.default = createDebug;
117
- createDebug.coerce = coerce;
118
- createDebug.disable = disable;
119
- createDebug.enable = enable;
120
- createDebug.enabled = enabled;
121
- createDebug.humanize = ms;
122
- Object.keys(env).forEach(function (key) {
123
- createDebug[key] = env[key];
124
- });
125
- createDebug.instances = [];
126
- createDebug.names = [];
127
- createDebug.skips = [];
128
- createDebug.formatters = {};
129
- function selectColor(namespace) {
130
- var hash = 0;
131
- for (var i = 0; i < namespace.length; i++) {
132
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
133
- hash |= 0;
134
- }
135
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
136
- }
137
- createDebug.selectColor = selectColor;
138
- function createDebug(namespace) {
139
- var prevTime;
140
- function debug() {
141
- if (!debug.enabled) {
142
- return;
143
- }
144
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
145
- args[_key] = arguments[_key];
146
- }
147
- var self = debug;
148
- var curr = Number(new Date());
149
- var ms = curr - (prevTime || curr);
150
- self.diff = ms;
151
- self.prev = prevTime;
152
- self.curr = curr;
153
- prevTime = curr;
154
- args[0] = createDebug.coerce(args[0]);
155
- if (typeof args[0] !== 'string') {
156
- args.unshift('%O');
157
- }
158
- var index = 0;
159
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
160
- if (match === '%%') {
161
- return match;
162
- }
163
- index++;
164
- var formatter = createDebug.formatters[format];
165
- if (typeof formatter === 'function') {
166
- var val = args[index];
167
- match = formatter.call(self, val);
168
- args.splice(index, 1);
169
- index--;
170
- }
171
- return match;
172
- });
173
- createDebug.formatArgs.call(self, args);
174
- var logFn = self.log || createDebug.log;
175
- logFn.apply(self, args);
176
- }
177
- debug.namespace = namespace;
178
- debug.enabled = createDebug.enabled(namespace);
179
- debug.useColors = createDebug.useColors();
180
- debug.color = selectColor(namespace);
181
- debug.destroy = destroy;
182
- debug.extend = extend;
183
- if (typeof createDebug.init === 'function') {
184
- createDebug.init(debug);
185
- }
186
- createDebug.instances.push(debug);
187
- return debug;
188
- }
189
- function destroy() {
190
- var index = createDebug.instances.indexOf(this);
191
- if (index !== -1) {
192
- createDebug.instances.splice(index, 1);
193
- return true;
194
- }
195
- return false;
196
- }
197
- function extend(namespace, delimiter) {
198
- return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
199
- }
200
- function enable(namespaces) {
201
- createDebug.save(namespaces);
202
- createDebug.names = [];
203
- createDebug.skips = [];
204
- var i;
205
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
206
- var len = split.length;
207
- for (i = 0; i < len; i++) {
208
- if (!split[i]) {
209
- continue;
210
- }
211
- namespaces = split[i].replace(/\*/g, '.*?');
212
- if (namespaces[0] === '-') {
213
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
214
- } else {
215
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
216
- }
217
- }
218
- for (i = 0; i < createDebug.instances.length; i++) {
219
- var instance = createDebug.instances[i];
220
- instance.enabled = createDebug.enabled(instance.namespace);
221
- }
222
- }
223
- function disable() {
224
- createDebug.enable('');
225
- }
226
- function enabled(name) {
227
- if (name[name.length - 1] === '*') {
228
- return true;
229
- }
230
- var i;
231
- var len;
232
- for ((i = 0, len = createDebug.skips.length); i < len; i++) {
233
- if (createDebug.skips[i].test(name)) {
234
- return false;
235
- }
236
- }
237
- for ((i = 0, len = createDebug.names.length); i < len; i++) {
238
- if (createDebug.names[i].test(name)) {
239
- return true;
240
- }
241
- }
242
- return false;
243
- }
244
- function coerce(val) {
245
- if (val instanceof Error) {
246
- return val.stack || val.message;
247
- }
248
- return val;
249
- }
250
- createDebug.enable(createDebug.load());
251
- return createDebug;
252
- }
253
- var common = setup;
254
- var browser = createCommonjsModule(function (module, exports) {
255
- function _typeof(obj) {
256
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
257
- _typeof = function _typeof(obj) {
258
- return typeof obj;
259
- };
260
- } else {
261
- _typeof = function _typeof(obj) {
262
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
263
- };
264
- }
265
- return _typeof(obj);
266
- }
267
- exports.log = log;
268
- exports.formatArgs = formatArgs;
269
- exports.save = save;
270
- exports.load = load;
271
- exports.useColors = useColors;
272
- exports.storage = localstorage();
273
- exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
274
- function useColors() {
275
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
276
- return true;
277
- }
278
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
279
- return false;
280
- }
281
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
282
- }
283
- function formatArgs(args) {
284
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
285
- if (!this.useColors) {
286
- return;
287
- }
288
- var c = 'color: ' + this.color;
289
- args.splice(1, 0, c, 'color: inherit');
290
- var index = 0;
291
- var lastC = 0;
292
- args[0].replace(/%[a-zA-Z%]/g, function (match) {
293
- if (match === '%%') {
294
- return;
295
- }
296
- index++;
297
- if (match === '%c') {
298
- lastC = index;
299
- }
300
- });
301
- args.splice(lastC, 0, c);
302
- }
303
- function log() {
304
- var _console;
305
- return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
306
- }
307
- function save(namespaces) {
308
- try {
309
- if (namespaces) {
310
- exports.storage.setItem('debug', namespaces);
311
- } else {
312
- exports.storage.removeItem('debug');
313
- }
314
- } catch (error) {}
315
- }
316
- function load() {
317
- var r;
318
- try {
319
- r = exports.storage.getItem('debug');
320
- } catch (error) {}
321
- if (!r && typeof process !== 'undefined' && ('env' in process)) {
322
- r = process.env.DEBUG;
323
- }
324
- return r;
325
- }
326
- function localstorage() {
327
- try {
328
- return localStorage;
329
- } catch (error) {}
330
- }
331
- module.exports = common(exports);
332
- var formatters = module.exports.formatters;
333
- formatters.j = function (v) {
334
- try {
335
- return JSON.stringify(v);
336
- } catch (error) {
337
- return '[UnexpectedJSONParseError]: ' + error.message;
338
- }
339
- };
340
- });
341
- browser.log;
342
- browser.formatArgs;
343
- browser.save;
344
- browser.load;
345
- browser.useColors;
346
- browser.storage;
347
- browser.colors;
348
- const React = _dll_react;
349
- const PropTypes = _dll_prop_types;
350
- const {color: color} = _dll_pie_lib__render_ui;
351
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
352
- const {Button: Button} = _dll_material_ui__core;
353
- const {Tooltip: Tooltip} = _dll_material_ui__core;
354
- const {merge: merge} = _dll_lodash;
355
- const EditableHtml = _dll_pie_lib__editable_html;
356
- const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
357
- const {ChoiceConfiguration: ChoiceConfiguration} = _dll_pie_lib__config_ui;
358
- const {settings: settings} = _dll_pie_lib__config_ui;
359
- const {layout: layout} = _dll_pie_lib__config_ui;
360
- const {choiceUtils: utils} = _dll_pie_lib__config_ui;
361
- const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/packages/multiple-choice/configure/src/main.jsx";
362
- const {Panel, toggle, radio} = settings;
363
- const MAX_CHOICES = 9;
364
- const styles = theme => ({
365
- promptHolder: {
366
- width: '100%',
367
- paddingBottom: theme.spacing.unit * 2,
368
- marginBottom: theme.spacing.unit * 2
369
- },
370
- prompt: {
371
- paddingTop: theme.spacing.unit * 2,
372
- width: '100%'
373
- },
374
- rationaleHolder: {
375
- width: '70%'
376
- },
377
- rationale: {
378
- paddingTop: theme.spacing.unit * 2
379
- },
380
- design: {
381
- paddingTop: theme.spacing.unit * 3
382
- },
383
- choiceConfigurationHolder: {
384
- display: 'flex',
385
- flexDirection: 'column',
386
- alignItems: 'center'
387
- },
388
- choiceConfiguration: {
389
- width: '100%',
390
- paddingTop: theme.spacing.unit * 2,
391
- paddingBottom: theme.spacing.unit * 2
392
- },
393
- switchElement: {
394
- justifyContent: 'space-between',
395
- margin: 0
396
- },
397
- addButton: {
398
- float: 'right'
399
- },
400
- disableButton: {
401
- cursor: 'not-allowed',
402
- pointerEvents: 'all',
403
- backgroundColor: color.disabled(),
404
- '&:hover': {
405
- backgroundColor: color.disabled()
406
- },
407
- '&:focus': {
408
- backgroundColor: color.disabled()
409
- }
410
- }
411
- });
412
- const Design = withStyles(styles)(props => {
413
- const {classes, model, configuration, onPromptChanged, onChoiceChanged, onRemoveChoice, onAddChoice, imageSupport, onChangeModel, onConfigurationChanged, onTeacherInstructionsChanged} = props;
414
- const {prompt = {}, addChoiceButton = {}, limitChoicesNumber = {}, feedback = {}, deleteChoice = {}, choiceMode = {}, choicePrefix = {}, partialScoring = {}, lockChoiceOrder = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, scoringType = {}, sequentialChoiceLabels = {}, settingsPanelDisabled} = configuration || ({});
415
- const {limitChoicesNumber: limitChoicesNumberModel, teacherInstructionsEnabled, rationaleEnabled, feedbackEnabled, promptEnabled} = model || ({});
416
- const Content = React.createElement('div', {
417
- __self: undefined,
418
- __source: {
419
- fileName: _jsxFileName,
420
- lineNumber: 110
421
- }
422
- }, teacherInstructionsEnabled && React.createElement(InputContainer, {
423
- label: teacherInstructions.label,
424
- className: classes.promptHolder,
425
- __self: undefined,
426
- __source: {
427
- fileName: _jsxFileName,
428
- lineNumber: 112
429
- }
430
- }, React.createElement(EditableHtml, {
431
- className: classes.prompt,
432
- markup: model.teacherInstructions || '',
433
- onChange: onTeacherInstructionsChanged,
434
- imageSupport: imageSupport,
435
- nonEmpty: false,
436
- __self: undefined,
437
- __source: {
438
- fileName: _jsxFileName,
439
- lineNumber: 116
440
- }
441
- })), promptEnabled && React.createElement(InputContainer, {
442
- label: prompt.label,
443
- className: classes.promptHolder,
444
- __self: undefined,
445
- __source: {
446
- fileName: _jsxFileName,
447
- lineNumber: 127
448
- }
449
- }, React.createElement(EditableHtml, {
450
- className: classes.prompt,
451
- markup: model.prompt,
452
- onChange: onPromptChanged,
453
- imageSupport: imageSupport,
454
- nonEmpty: false,
455
- disableUnderline: true,
456
- __self: undefined,
457
- __source: {
458
- fileName: _jsxFileName,
459
- lineNumber: 128
460
- }
461
- })), model.choices.map((choice, index) => React.createElement('div', {
462
- key: `choice-${index}`,
463
- className: classes.choiceConfigurationHolder,
464
- __self: undefined,
465
- __source: {
466
- fileName: _jsxFileName,
467
- lineNumber: 139
468
- }
469
- }, React.createElement(ChoiceConfiguration, {
470
- key: index,
471
- index: index + 1,
472
- useLetterOrdering: model.choicePrefix === 'letters',
473
- className: classes.choiceConfiguration,
474
- mode: model.choiceMode,
475
- data: choice,
476
- defaultFeedback: {},
477
- imageSupport: imageSupport,
478
- onDelete: () => onRemoveChoice(index),
479
- onChange: c => onChoiceChanged(index, c),
480
- allowFeedBack: feedbackEnabled,
481
- allowDelete: deleteChoice.settings,
482
- noLabels: true,
483
- __self: undefined,
484
- __source: {
485
- fileName: _jsxFileName,
486
- lineNumber: 143
487
- }
488
- }), rationaleEnabled && React.createElement(InputContainer, {
489
- key: `rationale-${index}`,
490
- label: rationale.label,
491
- className: classes.rationaleHolder,
492
- __self: undefined,
493
- __source: {
494
- fileName: _jsxFileName,
495
- lineNumber: 159
496
- }
497
- }, React.createElement(EditableHtml, {
498
- className: classes.rationale,
499
- markup: choice.rationale || '',
500
- onChange: c => onChoiceChanged(index, {
501
- ...choice,
502
- rationale: c
503
- }),
504
- imageSupport: imageSupport,
505
- __self: undefined,
506
- __source: {
507
- fileName: _jsxFileName,
508
- lineNumber: 164
509
- }
510
- })))), React.createElement('br', {
511
- __self: undefined,
512
- __source: {
513
- fileName: _jsxFileName,
514
- lineNumber: 179
515
- }
516
- }), addChoiceButton.settings && React.createElement(Tooltip, {
517
- title: limitChoicesNumberModel && model.choices.length >= MAX_CHOICES ? `Only ${MAX_CHOICES} allowed maximum` : '',
518
- classes: {
519
- tooltip: classes.tooltip
520
- },
521
- __self: undefined,
522
- __source: {
523
- fileName: _jsxFileName,
524
- lineNumber: 181
525
- }
526
- }, React.createElement(Button, {
527
- classes: {
528
- root: limitChoicesNumberModel && model.choices.length >= MAX_CHOICES ? classes.disableButton : undefined
529
- },
530
- className: classes.addButton,
531
- variant: "contained",
532
- color: "primary",
533
- onClick: onAddChoice,
534
- __self: undefined,
535
- __source: {
536
- fileName: _jsxFileName,
537
- lineNumber: 182
538
- }
539
- }, addChoiceButton.label)));
540
- return React.createElement('div', {
541
- className: classes.design,
542
- __self: undefined,
543
- __source: {
544
- fileName: _jsxFileName,
545
- lineNumber: 197
546
- }
547
- }, settingsPanelDisabled ? Content : React.createElement(layout.ConfigLayout, {
548
- settings: React.createElement(Panel, {
549
- model: model,
550
- onChangeModel: onChangeModel,
551
- configuration: configuration,
552
- onChangeConfiguration: onConfigurationChanged,
553
- groups: {
554
- Settings: {
555
- choiceMode: choiceMode.settings && radio(choiceMode.label, ['checkbox', 'radio']),
556
- 'sequentialChoiceLabels.enabled': sequentialChoiceLabels.settings && toggle(sequentialChoiceLabels.label, true),
557
- choicePrefix: choicePrefix.settings && radio(choicePrefix.label, ['numbers', 'letters']),
558
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
559
- limitChoicesNumber: limitChoicesNumber.settings && toggle(limitChoicesNumber.label),
560
- lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
561
- feedbackEnabled: feedback.settings && toggle(feedback.label)
562
- },
563
- Properties: {
564
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
565
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
566
- promptEnabled: prompt.settings && toggle(prompt.label),
567
- rationaleEnabled: rationale.settings && toggle(rationale.label),
568
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
569
- }
570
- },
571
- __self: undefined,
572
- __source: {
573
- fileName: _jsxFileName,
574
- lineNumber: 203
575
- }
576
- }),
577
- __self: undefined,
578
- __source: {
579
- fileName: _jsxFileName,
580
- lineNumber: 201
581
- }
582
- }, Content));
583
- });
584
- class Main extends React.Component {
585
- constructor(...args) {
586
- super(...args);
587
- Main.prototype.__init.call(this);
588
- Main.prototype.__init2.call(this);
589
- Main.prototype.__init3.call(this);
590
- Main.prototype.__init4.call(this);
591
- Main.prototype.__init5.call(this);
592
- Main.prototype.__init6.call(this);
593
- }
594
- static __initStatic() {
595
- this.propTypes = {
596
- model: PropTypes.object.isRequired,
597
- disableSidePanel: PropTypes.bool,
598
- onModelChanged: PropTypes.func.isRequired,
599
- onConfigurationChanged: PropTypes.func.isRequired,
600
- classes: PropTypes.object.isRequired,
601
- imageSupport: PropTypes.shape({
602
- add: PropTypes.func.isRequired,
603
- delete: PropTypes.func.isRequired
604
- })
605
- };
606
- }
607
- __init() {
608
- this.onRemoveChoice = index => {
609
- const {model} = this.props;
610
- model.choices.splice(index, 1);
611
- this.props.onModelChanged(model);
612
- };
613
- }
614
- __init2() {
615
- this.onAddChoice = () => {
616
- const {model} = this.props;
617
- if (!model.limitChoicesNumber || model.limitChoicesNumber && model.choices.length < MAX_CHOICES) {
618
- model.choices.push({
619
- label: '',
620
- value: utils.firstAvailableIndex(model.choices.map(c => c.value), 0),
621
- feedback: {
622
- type: 'none'
623
- }
624
- });
625
- this.props.onModelChanged(model);
626
- }
627
- };
628
- }
629
- __init3() {
630
- this.onChoiceChanged = (index, choice) => {
631
- const {model} = this.props;
632
- if (choice.correct && model.choiceMode === 'radio') {
633
- model.choices = model.choices.map(c => {
634
- return merge({}, c, {
635
- correct: false
636
- });
637
- });
638
- }
639
- model.choices.splice(index, 1, choice);
640
- this.props.onModelChanged(model);
641
- };
642
- }
643
- __init4() {
644
- this.onPromptChanged = prompt => {
645
- this.props.onModelChanged({
646
- ...this.props.model,
647
- prompt
648
- });
649
- };
650
- }
651
- __init5() {
652
- this.onTeacherInstructionsChanged = teacherInstructions => {
653
- this.props.onModelChanged({
654
- ...this.props.model,
655
- teacherInstructions
656
- });
657
- };
658
- }
659
- __init6() {
660
- this.onModelChanged = (model, key) => {
661
- const {onModelChanged} = this.props;
662
- switch (key) {
663
- case 'choiceMode':
664
- {
665
- let value = model.choiceMode;
666
- if (value === 'radio') {
667
- let correctFound = false;
668
- model.choices = model.choices.map(c => {
669
- if (correctFound) {
670
- c.correct = false;
671
- return c;
672
- }
673
- if (c.correct) {
674
- correctFound = true;
675
- }
676
- return c;
677
- });
678
- }
679
- onModelChanged(model, true);
680
- break;
681
- }
682
- default:
683
- onModelChanged(model);
684
- break;
685
- }
686
- };
687
- }
688
- render() {
689
- return React.createElement(Design, {
690
- ...this.props,
691
- onChangeModel: this.onModelChanged,
692
- onRemoveChoice: this.onRemoveChoice,
693
- onChoiceChanged: this.onChoiceChanged,
694
- onAddChoice: this.onAddChoice,
695
- onPromptChanged: this.onPromptChanged,
696
- onTeacherInstructionsChanged: this.onTeacherInstructionsChanged,
697
- __self: this,
698
- __source: {
699
- fileName: _jsxFileName,
700
- lineNumber: 348
701
- }
702
- });
703
- }
704
- }
705
- Main.__initStatic();
706
- const Styled = withStyles(styles)(Main);
707
- var sensibleDefaults = {
708
- model: {
709
- choiceMode: 'checkbox',
710
- choicePrefix: 'letters',
711
- choices: [],
712
- prompt: 'Question Prompt goes here',
713
- lockChoiceOrder: true,
714
- partialScoring: true,
715
- scoringType: 'auto',
716
- feedbackEnabled: true,
717
- promptEnabled: true,
718
- rationaleEnabled: true,
719
- limitChoicesNumber: true,
720
- teacherInstructionsEnabled: true,
721
- studentInstructionsEnabled: true
722
- },
723
- configuration: {
724
- answerChoiceCount: 0,
725
- addChoiceButton: {
726
- settings: true,
727
- label: 'Add a Choice'
728
- },
729
- limitChoicesNumber: {
730
- settings: true,
731
- label: 'Limit choices to 9'
732
- },
733
- choiceMode: {
734
- settings: true,
735
- label: 'Response Type'
736
- },
737
- choicePrefix: {
738
- settings: true,
739
- label: 'Choice Labels'
740
- },
741
- deleteChoice: {
742
- settings: true
743
- },
744
- feedback: {
745
- settings: true,
746
- label: 'Feedback'
747
- },
748
- prompt: {
749
- settings: true,
750
- label: 'Prompt'
751
- },
752
- lockChoiceOrder: {
753
- settings: true,
754
- label: 'Lock Choice Order'
755
- },
756
- partialScoring: {
757
- settings: false,
758
- label: 'Allow Partial Scoring'
759
- },
760
- rationale: {
761
- settings: true,
762
- label: 'Rationale'
763
- },
764
- scoringType: {
765
- settings: false,
766
- label: 'Scoring Type'
767
- },
768
- studentInstructions: {
769
- settings: false,
770
- label: 'Student Instructions'
771
- },
772
- teacherInstructions: {
773
- settings: true,
774
- label: 'Teacher Instructions'
775
- }
776
- }
777
- };
778
- const React$1 = _dll_react;
779
- const ReactDOM = _dll_react_dom;
780
- const {defaults: defaults} = _dll_lodash;
781
- const {DeleteImageEvent: DeleteImageEvent} = _dll_pie_framework__pie_configure_events;
782
- const {InsertImageEvent: InsertImageEvent} = _dll_pie_framework__pie_configure_events;
783
- const {ModelUpdatedEvent: ModelUpdatedEvent} = _dll_pie_framework__pie_configure_events;
784
- const {choiceUtils: utils$1} = _dll_pie_lib__config_ui;
785
- const log = browser('multiple-choice:configure');
786
- const generateFormattedChoices = (choices, choiceCount = 0) => {
787
- if (!choices || choices.length === 0) {
788
- let formattedChoices = [];
789
- for (let i = 0; i < choiceCount; i++) {
790
- formattedChoices.push({
791
- value: `${i}`,
792
- label: '',
793
- feedback: {
794
- type: 'none',
795
- value: ''
796
- }
797
- });
798
- }
799
- return formattedChoices;
800
- }
801
- return choices;
802
- };
803
- const prepareCustomizationObject = (config, model) => {
804
- const configuration = defaults(config, sensibleDefaults.configuration);
805
- return {
806
- configuration,
807
- model: {
808
- ...model,
809
- choices: generateFormattedChoices(model && model.choices || [], configuration && configuration.answerChoiceCount)
810
- }
811
- };
812
- };
813
- class MultipleChoice extends HTMLElement {
814
- static __initStatic() {
815
- this.createDefaultModel = (model = {}) => utils$1.normalizeChoices({
816
- ...sensibleDefaults.model,
817
- ...model,
818
- choices: generateFormattedChoices(model && model.choices || [])
819
- });
820
- }
821
- constructor() {
822
- super();
823
- this._model = MultipleChoice.createDefaultModel();
824
- this._configuration = sensibleDefaults.configuration;
825
- this.onModelChanged = this.onModelChanged.bind(this);
826
- this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
827
- }
828
- set model(s) {
829
- this._model = MultipleChoice.createDefaultModel(s);
830
- this._render();
831
- }
832
- set configuration(c) {
833
- const info = prepareCustomizationObject(c, this._model);
834
- this.onModelChanged(info.model);
835
- this._configuration = info.configuration;
836
- this._render();
837
- }
838
- set disableSidePanel(s) {
839
- this._disableSidePanel = s;
840
- this._render();
841
- }
842
- dispatchModelUpdated(reset) {
843
- const resetValue = !!reset;
844
- this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));
845
- }
846
- onModelChanged(m, reset) {
847
- this._model = m;
848
- this._render();
849
- this.dispatchModelUpdated(reset);
850
- }
851
- onConfigurationChanged(c) {
852
- this._configuration = prepareCustomizationObject(c, this._model).configuration;
853
- if (this._model) {
854
- this.onModelChanged(this._model);
855
- }
856
- this._render();
857
- }
858
- insertImage(handler) {
859
- this.dispatchEvent(new InsertImageEvent(handler));
860
- }
861
- onDeleteImage(src, done) {
862
- this.dispatchEvent(new DeleteImageEvent(src, done));
863
- }
864
- _render() {
865
- log('_render');
866
- let element = React$1.createElement(Styled, {
867
- model: this._model,
868
- configuration: this._configuration,
869
- onModelChanged: this.onModelChanged,
870
- onConfigurationChanged: this.onConfigurationChanged,
871
- disableSidePanel: this._disableSidePanel,
872
- imageSupport: {
873
- add: this.insertImage.bind(this),
874
- delete: this.onDeleteImage.bind(this)
875
- }
876
- });
877
- ReactDOM.render(element, this);
878
- }
879
- }
880
- MultipleChoice.__initStatic();
881
- export default MultipleChoice;