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

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
package/module/element.js DELETED
@@ -1,1221 +0,0 @@
1
- import {_dll_react, _dll_react_transition_group, _dll_material_ui__core_styles, _dll_prop_types, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_react_dom, _dll_pie_lib__math_rendering} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
2
- function createCommonjsModule(fn, module) {
3
- return (module = {
4
- exports: {}
5
- }, fn(module, module.exports), module.exports);
6
- }
7
- var classnames = createCommonjsModule(function (module) {
8
- (function () {
9
- var hasOwn = ({}).hasOwnProperty;
10
- function classNames() {
11
- var classes = [];
12
- for (var i = 0; i < arguments.length; i++) {
13
- var arg = arguments[i];
14
- if (!arg) continue;
15
- var argType = typeof arg;
16
- if (argType === 'string' || argType === 'number') {
17
- classes.push(arg);
18
- } else if (Array.isArray(arg) && arg.length) {
19
- var inner = classNames.apply(null, arg);
20
- if (inner) {
21
- classes.push(inner);
22
- }
23
- } else if (argType === 'object') {
24
- for (var key in arg) {
25
- if (hasOwn.call(arg, key) && arg[key]) {
26
- classes.push(key);
27
- }
28
- }
29
- }
30
- }
31
- return classes.join(' ');
32
- }
33
- if (module.exports) {
34
- classNames.default = classNames;
35
- module.exports = classNames;
36
- } else {
37
- window.classNames = classNames;
38
- }
39
- })();
40
- });
41
- const React = _dll_react;
42
- const {TransitionGroup: TransitionGroup} = _dll_react_transition_group;
43
- const {CSSTransition: CSSTransition} = _dll_react_transition_group;
44
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
45
- const PropTypes = _dll_prop_types;
46
- const {color: color} = _dll_pie_lib__render_ui;
47
- const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/multiple-choice/src/feedback-tick.jsx";
48
- const stylesheet = {
49
- incorrect: {
50
- fill: `var(--feedback-incorrect-bg-color, ${color.incorrect()})`
51
- },
52
- correct: {
53
- fill: `var(--feedback-correct-bg-color, ${color.correct()})`
54
- },
55
- feedbackTick: {
56
- width: '33px',
57
- height: '33px',
58
- '& svg': {
59
- position: 'absolute',
60
- display: 'inline-block',
61
- width: '33px',
62
- height: '33px',
63
- verticalAlign: 'middle',
64
- '& hide': {
65
- display: 'none'
66
- }
67
- }
68
- },
69
- feedbackTickEnter: {
70
- opacity: '0',
71
- left: '-50px'
72
- },
73
- feedbackTickEnterActive: {
74
- opacity: '1',
75
- left: '0px',
76
- transition: 'left 500ms ease-in 200ms, opacity 500ms linear 200ms'
77
- },
78
- feedbackTickLeave: {
79
- opacity: '1',
80
- left: '0px'
81
- },
82
- feedbackTickLeaveActive: {
83
- opacity: '0',
84
- left: '-50px',
85
- transition: 'left 300ms ease-in, opacity 300ms'
86
- }
87
- };
88
- class FeedbackTick extends React.Component {
89
- static __initStatic() {
90
- this.propTypes = {
91
- classes: PropTypes.object.isRequired,
92
- correctness: PropTypes.string
93
- };
94
- }
95
- constructor(props) {
96
- super(props);
97
- this.incorrectIcon = React.createElement('svg', {
98
- key: "1",
99
- preserveAspectRatio: "xMinYMin meet",
100
- x: "0px",
101
- y: "0px",
102
- viewBox: "0 0 44 40",
103
- style: {
104
- enableBackground: 'new 0 0 44 40'
105
- },
106
- __self: this,
107
- __source: {
108
- fileName: _jsxFileName,
109
- lineNumber: 56
110
- }
111
- }, React.createElement('g', {
112
- __self: this,
113
- __source: {
114
- fileName: _jsxFileName,
115
- lineNumber: 64
116
- }
117
- }, React.createElement('rect', {
118
- x: "11",
119
- y: "17.3",
120
- transform: "matrix(0.7071 -0.7071 0.7071 0.7071 -7.852 19.2507)",
121
- className: this.props.classes.incorrect,
122
- width: "16.6",
123
- height: "3.7",
124
- __self: this,
125
- __source: {
126
- fileName: _jsxFileName,
127
- lineNumber: 65
128
- }
129
- }), React.createElement('rect', {
130
- x: "17.4",
131
- y: "10.7",
132
- transform: "matrix(0.7071 -0.7071 0.7071 0.7071 -7.8175 19.209)",
133
- className: this.props.classes.incorrect,
134
- width: "3.7",
135
- height: "16.6",
136
- __self: this,
137
- __source: {
138
- fileName: _jsxFileName,
139
- lineNumber: 73
140
- }
141
- })));
142
- this.correctIcon = React.createElement('svg', {
143
- key: "2",
144
- preserveAspectRatio: "xMinYMin meet",
145
- version: "1.1",
146
- x: "0px",
147
- y: "0px",
148
- viewBox: "0 0 44 40",
149
- style: {
150
- enableBackground: 'new 0 0 44 40'
151
- },
152
- __self: this,
153
- __source: {
154
- fileName: _jsxFileName,
155
- lineNumber: 86
156
- }
157
- }, React.createElement('polygon', {
158
- className: this.props.classes.correct,
159
- points: "19.1,28.6 11.8,22.3 14.4,19.2 17.9,22.1 23.9,11.4 27.5,13.4",
160
- __self: this,
161
- __source: {
162
- fileName: _jsxFileName,
163
- lineNumber: 95
164
- }
165
- }));
166
- }
167
- render() {
168
- const {correctness, classes} = this.props;
169
- const icon = (() => {
170
- if (correctness === 'incorrect') {
171
- return this.incorrectIcon;
172
- } else if (correctness === 'correct') {
173
- return this.correctIcon;
174
- }
175
- })();
176
- return React.createElement('div', {
177
- className: classes.feedbackTick,
178
- __self: this,
179
- __source: {
180
- fileName: _jsxFileName,
181
- lineNumber: 115
182
- }
183
- }, React.createElement(TransitionGroup, {
184
- __self: this,
185
- __source: {
186
- fileName: _jsxFileName,
187
- lineNumber: 116
188
- }
189
- }, correctness && React.createElement(CSSTransition, {
190
- classNames: {
191
- enter: classes.feedbackTickEnter,
192
- enterActive: classes.feedbackTickEnterActive,
193
- exit: classes.feedbackTickLeave,
194
- exitActive: classes.feedbackTickLeaveActive
195
- },
196
- timeout: {
197
- enter: 700,
198
- exit: 300
199
- },
200
- __self: this,
201
- __source: {
202
- fileName: _jsxFileName,
203
- lineNumber: 118
204
- }
205
- }, icon)));
206
- }
207
- }
208
- FeedbackTick.__initStatic();
209
- var FeedbackTick$1 = withStyles(stylesheet, {
210
- name: 'FeedbackTick'
211
- })(FeedbackTick);
212
- const {FormControlLabel: FormControlLabel} = _dll_material_ui__core;
213
- const {Checkbox: Checkbox} = _dll_material_ui__core;
214
- const {Radio: Radio} = _dll_material_ui__core;
215
- const React$1 = _dll_react;
216
- const PropTypes$1 = _dll_prop_types;
217
- const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
218
- const {Feedback: Feedback} = _dll_pie_lib__render_ui;
219
- const {color: color$1} = _dll_pie_lib__render_ui;
220
- const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__render_ui;
221
- const _jsxFileName$1 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/multiple-choice/src/choice-input.jsx";
222
- const styleSheet = () => ({
223
- row: {
224
- display: 'flex',
225
- alignItems: 'center',
226
- backgroundColor: color$1.background()
227
- },
228
- checkboxHolder: {
229
- display: 'flex',
230
- alignItems: 'center',
231
- backgroundColor: color$1.background(),
232
- flex: 1,
233
- '& label': {
234
- color: color$1.text()
235
- }
236
- }
237
- });
238
- const formStyleSheet = {
239
- label: {
240
- color: `${color$1.text()} !important`,
241
- backgroundColor: color$1.background()
242
- }
243
- };
244
- const StyledFormControlLabel = withStyles$1(formStyleSheet, {
245
- name: 'FormControlLabel'
246
- })(props => React$1.createElement(FormControlLabel, {
247
- ...props,
248
- classes: {
249
- label: props.classes.label
250
- },
251
- __self: undefined,
252
- __source: {
253
- fileName: _jsxFileName$1,
254
- lineNumber: 39
255
- }
256
- }));
257
- const CLASS_NAME = 'multiple-choice-component';
258
- const colorStyle = (varName, fallback) => ({
259
- [`&.${CLASS_NAME}`]: {
260
- color: `var(--choice-input-${varName}, ${fallback}) !important`
261
- }
262
- });
263
- const inputStyles = {
264
- 'correct-root': colorStyle('correct-color', color$1.text()),
265
- 'correct-checked': colorStyle('correct-selected-color', color$1.correct()),
266
- 'correct-disabled': colorStyle('correct-disabled-color', color$1.disabled()),
267
- 'incorrect-root': colorStyle('incorrect-color', color$1.incorrect()),
268
- 'incorrect-checked': colorStyle('incorrect-checked', color$1.incorrect()),
269
- 'incorrect-disabled': colorStyle('incorrect-disabled-color', color$1.disabled()),
270
- root: {
271
- ...colorStyle('color', color$1.text()),
272
- '&:hover': {
273
- color: `${color$1.primaryLight()} !important`
274
- }
275
- },
276
- checked: colorStyle('selected-color', color$1.primary()),
277
- disabled: {
278
- ...colorStyle('disabled-color', color$1.text()),
279
- opacity: 0.6,
280
- cursor: 'not-allowed !important',
281
- pointerEvents: 'initial !important'
282
- }
283
- };
284
- const StyledCheckbox = withStyles$1(inputStyles)(props => {
285
- const {correctness, classes, checked, onChange, disabled} = props;
286
- const key = k => correctness ? `${correctness}-${k}` : k;
287
- const resolved = {
288
- root: classes[key('root')],
289
- checked: classes[key('checked')],
290
- disabled: classes[key('disabled')]
291
- };
292
- const miniProps = {
293
- checked,
294
- onChange,
295
- disabled
296
- };
297
- return React$1.createElement(Checkbox, {
298
- ...miniProps,
299
- className: CLASS_NAME,
300
- classes: {
301
- root: resolved.root,
302
- checked: resolved.checked,
303
- disabled: resolved.disabled
304
- },
305
- __self: undefined,
306
- __source: {
307
- fileName: _jsxFileName$1,
308
- lineNumber: 85
309
- }
310
- });
311
- });
312
- const StyledRadio = withStyles$1(inputStyles)(props => {
313
- const {correctness, classes, checked, onChange, disabled} = props;
314
- const key = k => correctness ? `${correctness}-${k}` : k;
315
- const resolved = {
316
- root: classes[key('root')],
317
- checked: classes[key('checked')],
318
- disabled: classes[key('disabled')]
319
- };
320
- const miniProps = {
321
- checked,
322
- onChange,
323
- disabled
324
- };
325
- return React$1.createElement(Radio, {
326
- ...miniProps,
327
- className: CLASS_NAME,
328
- classes: {
329
- root: resolved.root,
330
- checked: resolved.checked
331
- },
332
- __self: undefined,
333
- __source: {
334
- fileName: _jsxFileName$1,
335
- lineNumber: 110
336
- }
337
- });
338
- });
339
- class ChoiceInput extends React$1.Component {
340
- static __initStatic() {
341
- this.propTypes = {
342
- choiceMode: PropTypes$1.oneOf(['radio', 'checkbox']),
343
- displayKey: PropTypes$1.string.isRequired,
344
- checked: PropTypes$1.bool.isRequired,
345
- correctness: PropTypes$1.string,
346
- disabled: PropTypes$1.bool.isRequired,
347
- feedback: PropTypes$1.string,
348
- label: PropTypes$1.string.isRequired,
349
- rationale: PropTypes$1.string,
350
- onChange: PropTypes$1.func.isRequired,
351
- value: PropTypes$1.string.isRequired,
352
- classes: PropTypes$1.object,
353
- className: PropTypes$1.string
354
- };
355
- }
356
- static __initStatic2() {
357
- this.defaultProps = {
358
- rationale: null,
359
- checked: false
360
- };
361
- }
362
- constructor(props) {
363
- super(props);
364
- this.onToggleChoice = this.onToggleChoice.bind(this);
365
- }
366
- onToggleChoice() {
367
- this.props.onChange({
368
- value: this.props.value,
369
- selected: !this.props.checked
370
- });
371
- }
372
- render() {
373
- const {choiceMode, disabled, displayKey, feedback, label, checked, correctness, classes, className, rationale} = this.props;
374
- const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
375
- const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';
376
- return React$1.createElement('div', {
377
- className: classnames(className, 'corespring-' + classSuffix),
378
- __self: this,
379
- __source: {
380
- fileName: _jsxFileName$1,
381
- lineNumber: 172
382
- }
383
- }, React$1.createElement('div', {
384
- className: classes.row,
385
- __self: this,
386
- __source: {
387
- fileName: _jsxFileName$1,
388
- lineNumber: 173
389
- }
390
- }, React$1.createElement(FeedbackTick$1, {
391
- correctness: correctness,
392
- __self: this,
393
- __source: {
394
- fileName: _jsxFileName$1,
395
- lineNumber: 174
396
- }
397
- }), React$1.createElement('div', {
398
- className: classes.checkboxHolder,
399
- __self: this,
400
- __source: {
401
- fileName: _jsxFileName$1,
402
- lineNumber: 175
403
- }
404
- }, React$1.createElement(StyledFormControlLabel, {
405
- disabled: disabled,
406
- label: displayKey ? displayKey + '. ' : '',
407
- control: React$1.createElement(Tag, {
408
- checked: checked,
409
- correctness: correctness,
410
- onChange: this.onToggleChoice,
411
- __self: this,
412
- __source: {
413
- fileName: _jsxFileName$1,
414
- lineNumber: 180
415
- }
416
- }),
417
- __self: this,
418
- __source: {
419
- fileName: _jsxFileName$1,
420
- lineNumber: 176
421
- }
422
- }), React$1.createElement(PreviewPrompt, {
423
- className: "label",
424
- onClick: this.onToggleChoice,
425
- prompt: label,
426
- tagName: "span",
427
- __self: this,
428
- __source: {
429
- fileName: _jsxFileName$1,
430
- lineNumber: 187
431
- }
432
- }))), rationale && React$1.createElement(PreviewPrompt, {
433
- className: "rationale",
434
- prompt: rationale,
435
- __self: this,
436
- __source: {
437
- fileName: _jsxFileName$1,
438
- lineNumber: 196
439
- }
440
- }), React$1.createElement(Feedback, {
441
- feedback: feedback,
442
- correctness: correctness,
443
- __self: this,
444
- __source: {
445
- fileName: _jsxFileName$1,
446
- lineNumber: 198
447
- }
448
- }));
449
- }
450
- }
451
- ChoiceInput.__initStatic();
452
- ChoiceInput.__initStatic2();
453
- var ChoiceInput$1 = withStyles$1(styleSheet)(ChoiceInput);
454
- const React$2 = _dll_react;
455
- const PropTypes$2 = _dll_prop_types;
456
- const CorrectAnswerToggle = _dll_pie_lib__correct_answer_toggle;
457
- const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
458
- const {color: color$2} = _dll_pie_lib__render_ui;
459
- const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
460
- const {PreviewPrompt: PreviewPrompt$1} = _dll_pie_lib__render_ui;
461
- const _jsxFileName$2 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/multiple-choice/src/multiple-choice.jsx";
462
- class Choice extends React$2.Component {
463
- constructor(...args) {
464
- super(...args);
465
- Choice.prototype.__init.call(this);
466
- }
467
- __init() {
468
- this.onChange = choice => {
469
- const {disabled, onChoiceChanged} = this.props;
470
- if (!disabled) {
471
- onChoiceChanged(choice);
472
- }
473
- };
474
- }
475
- render() {
476
- const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes} = this.props;
477
- const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
478
- const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
479
- const choiceProps = {
480
- ...choice,
481
- checked,
482
- choiceMode,
483
- disabled,
484
- feedback,
485
- correctness,
486
- displayKey,
487
- onChange: this.onChange
488
- };
489
- const names = classnames(classes.choice, {
490
- [classes.last]: index === choicesLength - 1
491
- });
492
- return React$2.createElement('div', {
493
- className: choiceClass,
494
- key: index,
495
- __self: this,
496
- __source: {
497
- fileName: _jsxFileName$2,
498
- lineNumber: 54
499
- }
500
- }, React$2.createElement(ChoiceInput$1, {
501
- ...choiceProps,
502
- className: names,
503
- __self: this,
504
- __source: {
505
- fileName: _jsxFileName$2,
506
- lineNumber: 55
507
- }
508
- }));
509
- }
510
- }
511
- Choice.propTypes = {
512
- choiceMode: PropTypes$2.oneOf(['radio', 'checkbox']),
513
- choice: PropTypes$2.object,
514
- disabled: PropTypes$2.bool.isRequired,
515
- onChoiceChanged: PropTypes$2.func.isRequired,
516
- classes: PropTypes$2.object.isRequired,
517
- index: PropTypes$2.number,
518
- choicesLength: PropTypes$2.number,
519
- showCorrect: PropTypes$2.bool,
520
- isEvaluateMode: PropTypes$2.bool,
521
- checked: PropTypes$2.bool,
522
- correctness: PropTypes$2.string,
523
- displayKey: PropTypes$2.string
524
- };
525
- const StyledChoice = withStyles$2({
526
- choice: {
527
- paddingTop: '20px',
528
- paddingBottom: '10px',
529
- borderBottom: '1px solid #E0DEE0'
530
- },
531
- last: {
532
- borderBottom: 'none'
533
- }
534
- })(Choice);
535
- const styles = {
536
- corespringChoice: {
537
- backgroundColor: color$2.background(),
538
- padding: '5px',
539
- '& *': {
540
- '-webkit-font-smoothing': 'antialiased'
541
- }
542
- }
543
- };
544
- class MultipleChoice extends React$2.Component {
545
- static __initStatic() {
546
- this.propTypes = {
547
- mode: PropTypes$2.oneOf(['gather', 'view', 'evaluate']),
548
- choiceMode: PropTypes$2.oneOf(['radio', 'checkbox']),
549
- keyMode: PropTypes$2.oneOf(['numbers', 'letters', 'none']),
550
- choices: PropTypes$2.array,
551
- prompt: PropTypes$2.string,
552
- teacherInstructions: PropTypes$2.string,
553
- session: PropTypes$2.object,
554
- disabled: PropTypes$2.bool.isRequired,
555
- onChoiceChanged: PropTypes$2.func.isRequired,
556
- responseCorrect: PropTypes$2.bool,
557
- classes: PropTypes$2.object.isRequired,
558
- correctResponse: PropTypes$2.array
559
- };
560
- }
561
- constructor(props) {
562
- super(props);
563
- MultipleChoice.prototype.__init2.call(this);
564
- this.state = {
565
- showCorrect: false
566
- };
567
- this.onToggle = this.onToggle.bind(this);
568
- }
569
- onToggle() {
570
- if (this.props.mode === 'evaluate') {
571
- this.setState({
572
- showCorrect: !this.state.showCorrect
573
- });
574
- }
575
- }
576
- UNSAFE_componentWillReceiveProps(nextProps) {
577
- if (!nextProps.correctResponse) {
578
- this.setState({
579
- showCorrect: false
580
- });
581
- }
582
- }
583
- isSelected(value) {
584
- const sessionValue = this.props.session && this.props.session.value;
585
- return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;
586
- }
587
- indexToSymbol(index) {
588
- if (this.props.keyMode === 'numbers') {
589
- return `${index + 1}`;
590
- }
591
- if (this.props.keyMode === 'letters') {
592
- return String.fromCharCode(97 + index).toUpperCase();
593
- }
594
- return '';
595
- }
596
- __init2() {
597
- this.getCorrectness = (choice = {}) => {
598
- const isCorrect = choice.correct;
599
- const isChecked = this.isSelected(choice.value);
600
- if (this.state.showCorrect) {
601
- return isCorrect ? 'correct' : undefined;
602
- }
603
- if (isCorrect) {
604
- if (isChecked) {
605
- return 'correct';
606
- } else {
607
- return 'incorrect';
608
- }
609
- } else {
610
- if (isChecked) {
611
- return 'incorrect';
612
- } else {
613
- return undefined;
614
- }
615
- }
616
- };
617
- }
618
- render() {
619
- const {mode, disabled, choices = [], choiceMode, prompt, onChoiceChanged, responseCorrect, teacherInstructions, classes} = this.props;
620
- const {showCorrect} = this.state;
621
- const isEvaluateMode = mode === 'evaluate';
622
- return React$2.createElement('div', {
623
- className: classes.corespringChoice,
624
- __self: this,
625
- __source: {
626
- fileName: _jsxFileName$2,
627
- lineNumber: 200
628
- }
629
- }, teacherInstructions && React$2.createElement(Collapsible, {
630
- labels: {
631
- hidden: 'Show Teacher Instructions',
632
- visible: 'Hide Teacher Instructions'
633
- },
634
- __self: this,
635
- __source: {
636
- fileName: _jsxFileName$2,
637
- lineNumber: 202
638
- }
639
- }, React$2.createElement(PreviewPrompt$1, {
640
- className: "prompt",
641
- prompt: teacherInstructions,
642
- __self: this,
643
- __source: {
644
- fileName: _jsxFileName$2,
645
- lineNumber: 208
646
- }
647
- })), React$2.createElement('br', {
648
- __self: this,
649
- __source: {
650
- fileName: _jsxFileName$2,
651
- lineNumber: 211
652
- }
653
- }), React$2.createElement(CorrectAnswerToggle, {
654
- show: isEvaluateMode && !responseCorrect,
655
- toggled: this.state.showCorrect,
656
- onToggle: this.onToggle.bind(this),
657
- __self: this,
658
- __source: {
659
- fileName: _jsxFileName$2,
660
- lineNumber: 212
661
- }
662
- }), React$2.createElement('br', {
663
- __self: this,
664
- __source: {
665
- fileName: _jsxFileName$2,
666
- lineNumber: 217
667
- }
668
- }), React$2.createElement(PreviewPrompt$1, {
669
- className: "prompt",
670
- prompt: prompt,
671
- __self: this,
672
- __source: {
673
- fileName: _jsxFileName$2,
674
- lineNumber: 218
675
- }
676
- }), choices.map((choice, index) => React$2.createElement(StyledChoice, {
677
- key: `choice-${index}`,
678
- choice: choice,
679
- index: index,
680
- choicesLength: choices.length,
681
- showCorrect: showCorrect,
682
- isEvaluateMode: isEvaluateMode,
683
- choiceMode: choiceMode,
684
- disabled: disabled,
685
- onChoiceChanged: onChoiceChanged,
686
- checked: showCorrect ? choice.correct || false : this.isSelected(choice.value),
687
- correctness: isEvaluateMode ? this.getCorrectness(choice) : undefined,
688
- displayKey: this.indexToSymbol(index),
689
- __self: this,
690
- __source: {
691
- fileName: _jsxFileName$2,
692
- lineNumber: 220
693
- }
694
- })));
695
- }
696
- }
697
- MultipleChoice.__initStatic();
698
- MultipleChoice.defaultProps = {
699
- session: {
700
- value: []
701
- }
702
- };
703
- var MultipleChoice$1 = withStyles$2(styles)(MultipleChoice);
704
- const React$3 = _dll_react;
705
- const PropTypes$3 = _dll_prop_types;
706
- const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
707
- const {createMuiTheme: createMuiTheme} = _dll_material_ui__core_styles;
708
- const {MuiThemeProvider: MuiThemeProvider} = _dll_material_ui__core_styles;
709
- const {PreviewLayout: PreviewLayout} = _dll_pie_lib__render_ui;
710
- const _jsxFileName$3 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/multiple-choice/src/main.jsx";
711
- class Main extends React$3.Component {
712
- static __initStatic() {
713
- this.propTypes = {
714
- model: PropTypes$3.object,
715
- session: PropTypes$3.object,
716
- onChoiceChanged: PropTypes$3.func,
717
- classes: PropTypes$3.object.isRequired
718
- };
719
- }
720
- static __initStatic2() {
721
- this.defaultProps = {
722
- model: {},
723
- session: {}
724
- };
725
- }
726
- constructor(props) {
727
- super(props);
728
- }
729
- render() {
730
- const {model, onChoiceChanged, session, classes} = this.props;
731
- return React$3.createElement(PreviewLayout, {
732
- __self: this,
733
- __source: {
734
- fileName: _jsxFileName$3,
735
- lineNumber: 30
736
- }
737
- }, model.partLabel && React$3.createElement('p', {
738
- __self: this,
739
- __source: {
740
- fileName: _jsxFileName$3,
741
- lineNumber: 31
742
- }
743
- }, model.partLabel), React$3.createElement('div', {
744
- className: classnames(classes.root, classes[model.className]),
745
- __self: this,
746
- __source: {
747
- fileName: _jsxFileName$3,
748
- lineNumber: 32
749
- }
750
- }, React$3.createElement(MultipleChoice$1, {
751
- ...model,
752
- session: session,
753
- onChoiceChanged: onChoiceChanged,
754
- __self: this,
755
- __source: {
756
- fileName: _jsxFileName$3,
757
- lineNumber: 33
758
- }
759
- })));
760
- }
761
- }
762
- Main.__initStatic();
763
- Main.__initStatic2();
764
- const Styled = withStyles$3({}, {
765
- name: 'Main'
766
- })(Main);
767
- const theme = createMuiTheme({
768
- typography: {
769
- useNextVariants: true
770
- }
771
- });
772
- const Root = props => React$3.createElement(MuiThemeProvider, {
773
- theme: theme,
774
- __self: undefined,
775
- __source: {
776
- fileName: _jsxFileName$3,
777
- lineNumber: 53
778
- }
779
- }, React$3.createElement(Styled, {
780
- ...props,
781
- __self: undefined,
782
- __source: {
783
- fileName: _jsxFileName$3,
784
- lineNumber: 54
785
- }
786
- }));
787
- var s = 1000;
788
- var m = s * 60;
789
- var h = m * 60;
790
- var d = h * 24;
791
- var w = d * 7;
792
- var y = d * 365.25;
793
- var ms = function (val, options) {
794
- options = options || ({});
795
- var type = typeof val;
796
- if (type === 'string' && val.length > 0) {
797
- return parse(val);
798
- } else if (type === 'number' && isFinite(val)) {
799
- return options.long ? fmtLong(val) : fmtShort(val);
800
- }
801
- throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
802
- };
803
- function parse(str) {
804
- str = String(str);
805
- if (str.length > 100) {
806
- return;
807
- }
808
- 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);
809
- if (!match) {
810
- return;
811
- }
812
- var n = parseFloat(match[1]);
813
- var type = (match[2] || 'ms').toLowerCase();
814
- switch (type) {
815
- case 'years':
816
- case 'year':
817
- case 'yrs':
818
- case 'yr':
819
- case 'y':
820
- return n * y;
821
- case 'weeks':
822
- case 'week':
823
- case 'w':
824
- return n * w;
825
- case 'days':
826
- case 'day':
827
- case 'd':
828
- return n * d;
829
- case 'hours':
830
- case 'hour':
831
- case 'hrs':
832
- case 'hr':
833
- case 'h':
834
- return n * h;
835
- case 'minutes':
836
- case 'minute':
837
- case 'mins':
838
- case 'min':
839
- case 'm':
840
- return n * m;
841
- case 'seconds':
842
- case 'second':
843
- case 'secs':
844
- case 'sec':
845
- case 's':
846
- return n * s;
847
- case 'milliseconds':
848
- case 'millisecond':
849
- case 'msecs':
850
- case 'msec':
851
- case 'ms':
852
- return n;
853
- default:
854
- return undefined;
855
- }
856
- }
857
- function fmtShort(ms) {
858
- var msAbs = Math.abs(ms);
859
- if (msAbs >= d) {
860
- return Math.round(ms / d) + 'd';
861
- }
862
- if (msAbs >= h) {
863
- return Math.round(ms / h) + 'h';
864
- }
865
- if (msAbs >= m) {
866
- return Math.round(ms / m) + 'm';
867
- }
868
- if (msAbs >= s) {
869
- return Math.round(ms / s) + 's';
870
- }
871
- return ms + 'ms';
872
- }
873
- function fmtLong(ms) {
874
- var msAbs = Math.abs(ms);
875
- if (msAbs >= d) {
876
- return plural(ms, msAbs, d, 'day');
877
- }
878
- if (msAbs >= h) {
879
- return plural(ms, msAbs, h, 'hour');
880
- }
881
- if (msAbs >= m) {
882
- return plural(ms, msAbs, m, 'minute');
883
- }
884
- if (msAbs >= s) {
885
- return plural(ms, msAbs, s, 'second');
886
- }
887
- return ms + ' ms';
888
- }
889
- function plural(ms, msAbs, n, name) {
890
- var isPlural = msAbs >= n * 1.5;
891
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
892
- }
893
- function setup(env) {
894
- createDebug.debug = createDebug;
895
- createDebug.default = createDebug;
896
- createDebug.coerce = coerce;
897
- createDebug.disable = disable;
898
- createDebug.enable = enable;
899
- createDebug.enabled = enabled;
900
- createDebug.humanize = ms;
901
- createDebug.destroy = destroy;
902
- Object.keys(env).forEach(key => {
903
- createDebug[key] = env[key];
904
- });
905
- createDebug.names = [];
906
- createDebug.skips = [];
907
- createDebug.formatters = {};
908
- function selectColor(namespace) {
909
- let hash = 0;
910
- for (let i = 0; i < namespace.length; i++) {
911
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
912
- hash |= 0;
913
- }
914
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
915
- }
916
- createDebug.selectColor = selectColor;
917
- function createDebug(namespace) {
918
- let prevTime;
919
- let enableOverride = null;
920
- function debug(...args) {
921
- if (!debug.enabled) {
922
- return;
923
- }
924
- const self = debug;
925
- const curr = Number(new Date());
926
- const ms = curr - (prevTime || curr);
927
- self.diff = ms;
928
- self.prev = prevTime;
929
- self.curr = curr;
930
- prevTime = curr;
931
- args[0] = createDebug.coerce(args[0]);
932
- if (typeof args[0] !== 'string') {
933
- args.unshift('%O');
934
- }
935
- let index = 0;
936
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
937
- if (match === '%%') {
938
- return '%';
939
- }
940
- index++;
941
- const formatter = createDebug.formatters[format];
942
- if (typeof formatter === 'function') {
943
- const val = args[index];
944
- match = formatter.call(self, val);
945
- args.splice(index, 1);
946
- index--;
947
- }
948
- return match;
949
- });
950
- createDebug.formatArgs.call(self, args);
951
- const logFn = self.log || createDebug.log;
952
- logFn.apply(self, args);
953
- }
954
- debug.namespace = namespace;
955
- debug.useColors = createDebug.useColors();
956
- debug.color = createDebug.selectColor(namespace);
957
- debug.extend = extend;
958
- debug.destroy = createDebug.destroy;
959
- Object.defineProperty(debug, 'enabled', {
960
- enumerable: true,
961
- configurable: false,
962
- get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
963
- set: v => {
964
- enableOverride = v;
965
- }
966
- });
967
- if (typeof createDebug.init === 'function') {
968
- createDebug.init(debug);
969
- }
970
- return debug;
971
- }
972
- function extend(namespace, delimiter) {
973
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
974
- newDebug.log = this.log;
975
- return newDebug;
976
- }
977
- function enable(namespaces) {
978
- createDebug.save(namespaces);
979
- createDebug.names = [];
980
- createDebug.skips = [];
981
- let i;
982
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
983
- const len = split.length;
984
- for (i = 0; i < len; i++) {
985
- if (!split[i]) {
986
- continue;
987
- }
988
- namespaces = split[i].replace(/\*/g, '.*?');
989
- if (namespaces[0] === '-') {
990
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
991
- } else {
992
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
993
- }
994
- }
995
- }
996
- function disable() {
997
- const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)].join(',');
998
- createDebug.enable('');
999
- return namespaces;
1000
- }
1001
- function enabled(name) {
1002
- if (name[name.length - 1] === '*') {
1003
- return true;
1004
- }
1005
- let i;
1006
- let len;
1007
- for ((i = 0, len = createDebug.skips.length); i < len; i++) {
1008
- if (createDebug.skips[i].test(name)) {
1009
- return false;
1010
- }
1011
- }
1012
- for ((i = 0, len = createDebug.names.length); i < len; i++) {
1013
- if (createDebug.names[i].test(name)) {
1014
- return true;
1015
- }
1016
- }
1017
- return false;
1018
- }
1019
- function toNamespace(regexp) {
1020
- return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
1021
- }
1022
- function coerce(val) {
1023
- if (val instanceof Error) {
1024
- return val.stack || val.message;
1025
- }
1026
- return val;
1027
- }
1028
- function destroy() {
1029
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1030
- }
1031
- createDebug.enable(createDebug.load());
1032
- return createDebug;
1033
- }
1034
- var common = setup;
1035
- var browser = createCommonjsModule(function (module, exports) {
1036
- exports.formatArgs = formatArgs;
1037
- exports.save = save;
1038
- exports.load = load;
1039
- exports.useColors = useColors;
1040
- exports.storage = localstorage();
1041
- exports.destroy = (() => {
1042
- let warned = false;
1043
- return () => {
1044
- if (!warned) {
1045
- warned = true;
1046
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1047
- }
1048
- };
1049
- })();
1050
- 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'];
1051
- function useColors() {
1052
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1053
- return true;
1054
- }
1055
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1056
- return false;
1057
- }
1058
- 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+)/);
1059
- }
1060
- function formatArgs(args) {
1061
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
1062
- if (!this.useColors) {
1063
- return;
1064
- }
1065
- const c = 'color: ' + this.color;
1066
- args.splice(1, 0, c, 'color: inherit');
1067
- let index = 0;
1068
- let lastC = 0;
1069
- args[0].replace(/%[a-zA-Z%]/g, match => {
1070
- if (match === '%%') {
1071
- return;
1072
- }
1073
- index++;
1074
- if (match === '%c') {
1075
- lastC = index;
1076
- }
1077
- });
1078
- args.splice(lastC, 0, c);
1079
- }
1080
- exports.log = console.debug || console.log || (() => {});
1081
- function save(namespaces) {
1082
- try {
1083
- if (namespaces) {
1084
- exports.storage.setItem('debug', namespaces);
1085
- } else {
1086
- exports.storage.removeItem('debug');
1087
- }
1088
- } catch (error) {}
1089
- }
1090
- function load() {
1091
- let r;
1092
- try {
1093
- r = exports.storage.getItem('debug');
1094
- } catch (error) {}
1095
- if (!r && typeof process !== 'undefined' && ('env' in process)) {
1096
- r = process.env.DEBUG;
1097
- }
1098
- return r;
1099
- }
1100
- function localstorage() {
1101
- try {
1102
- return localStorage;
1103
- } catch (error) {}
1104
- }
1105
- module.exports = common(exports);
1106
- const {formatters} = module.exports;
1107
- formatters.j = function (v) {
1108
- try {
1109
- return JSON.stringify(v);
1110
- } catch (error) {
1111
- return '[UnexpectedJSONParseError]: ' + error.message;
1112
- }
1113
- };
1114
- });
1115
- browser.formatArgs;
1116
- browser.save;
1117
- browser.load;
1118
- browser.useColors;
1119
- browser.storage;
1120
- browser.destroy;
1121
- browser.colors;
1122
- browser.log;
1123
- const {concat: concat} = _dll_lodash;
1124
- const {uniq: uniq} = _dll_lodash;
1125
- const {without: without} = _dll_lodash;
1126
- function updateSessionValue(session, choiceMode, data) {
1127
- session.value = session.value || [];
1128
- if (choiceMode === 'checkbox') {
1129
- if (data.selected) {
1130
- session.value = uniq(concat(session.value, [data.value]));
1131
- } else {
1132
- session.value = without(session.value, data.value);
1133
- }
1134
- }
1135
- if (choiceMode === 'radio') {
1136
- if (data.selected) {
1137
- session.value = [data.value];
1138
- } else {
1139
- session.value = [];
1140
- }
1141
- }
1142
- }
1143
- const React$4 = _dll_react;
1144
- const ReactDOM = _dll_react_dom;
1145
- const {debounce: debounce} = _dll_lodash;
1146
- const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
1147
- const log = browser('pie-ui:multiple-choice');
1148
- const isComplete = session => !!(session && session.value && session.value.length);
1149
- class MultipleChoice$2 extends HTMLElement {
1150
- constructor() {
1151
- super();
1152
- this._model = null;
1153
- this._session = null;
1154
- this._rerender = debounce(() => {
1155
- if (this._model && this._session) {
1156
- var element = React$4.createElement(Root, {
1157
- model: this._model,
1158
- session: this._session,
1159
- onChoiceChanged: this._onChange.bind(this)
1160
- });
1161
- ReactDOM.render(element, this, () => {
1162
- log('render complete - render math');
1163
- renderMath(this);
1164
- });
1165
- } else {
1166
- log('skip');
1167
- }
1168
- }, 50, {
1169
- leading: false,
1170
- trailing: true
1171
- });
1172
- this._dispatchResponseChanged = debounce(() => {
1173
- var event = new CustomEvent('session-changed', {
1174
- bubbles: true,
1175
- composed: true,
1176
- detail: {
1177
- complete: isComplete(this._session),
1178
- component: this.tagName.toLowerCase()
1179
- }
1180
- });
1181
- this.dispatchEvent(event);
1182
- });
1183
- this._dispatchModelSet = debounce(() => {
1184
- this.dispatchEvent(new CustomEvent('model-set', {
1185
- bubbles: true,
1186
- composed: true,
1187
- detail: {
1188
- complete: isComplete(this._session),
1189
- component: this.tagName.toLowerCase(),
1190
- hasModel: this._model !== undefined
1191
- }
1192
- }));
1193
- }, 50, {
1194
- leading: false,
1195
- trailing: true
1196
- });
1197
- }
1198
- set model(s) {
1199
- this._model = s;
1200
- this._rerender();
1201
- this._dispatchModelSet();
1202
- }
1203
- get session() {
1204
- return this._session;
1205
- }
1206
- set session(s) {
1207
- this._session = s;
1208
- this._rerender();
1209
- this._dispatchResponseChanged();
1210
- }
1211
- _onChange(data) {
1212
- updateSessionValue(this._session, this._model.choiceMode, data);
1213
- this._dispatchResponseChanged();
1214
- this._rerender();
1215
- }
1216
- connectedCallback() {
1217
- this._rerender();
1218
- }
1219
- }
1220
- export default MultipleChoice$2;
1221
- export {isComplete};