@pie-element/ebsr 7.0.21 → 7.0.24-next.1

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.
@@ -1,472 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_lodash, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.10/module/index.js";
2
- import MultipleChoiceConfigure from '@pie-element/multiple-choice/configure/lib';
3
- import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.0.33/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
- 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
- lib.InsertImageEvent = InsertImageEvent;
49
- const React$1 = _dll_react;
50
- const PropTypes = _dll_prop_types;
51
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
52
- const {cloneDeep: cloneDeep$1} = _dll_lodash;
53
- const {settings: settings} = _dll_pie_lib__config_ui;
54
- const {layout: layout} = _dll_pie_lib__config_ui;
55
- const _jsxFileName = "/home/circleci/repo/packages/ebsr/configure/src/main.jsx";
56
- const {Panel, toggle, radio, dropdown} = settings;
57
- const styles = theme => ({
58
- design: {
59
- paddingTop: theme.spacing.unit * 3
60
- },
61
- part: {
62
- display: 'flex',
63
- flexDirection: 'column',
64
- padding: '16px 0 32px'
65
- }
66
- });
67
- class Main extends React$1.Component {
68
- constructor(...args) {
69
- super(...args);
70
- Main.prototype.__init.call(this);
71
- Main.prototype.__init2.call(this);
72
- }
73
- static __initStatic() {
74
- this.propTypes = {
75
- classes: PropTypes.object,
76
- configuration: PropTypes.object,
77
- model: PropTypes.object,
78
- onModelChanged: PropTypes.func,
79
- onConfigurationChanged: PropTypes.func
80
- };
81
- }
82
- __init() {
83
- this.removeExtraChoices = choices => {
84
- let correctFound = false;
85
- return (choices || []).map(choice => {
86
- if (correctFound) {
87
- choice.correct = false;
88
- return choice;
89
- }
90
- if (choice.correct) {
91
- correctFound = true;
92
- }
93
- return choice;
94
- });
95
- };
96
- }
97
- __init2() {
98
- this.onModelChanged = (model, key) => {
99
- const {onModelChanged} = this.props;
100
- if (key === 'partA.choiceMode' && model.partA.choiceMode === 'radio') {
101
- model.partA.choices = this.removeExtraChoices(model.partA.choices);
102
- return onModelChanged(model, true);
103
- }
104
- if (key === 'partB.choiceMode' && model.partB.choiceMode === 'radio') {
105
- model.partB.choices = this.removeExtraChoices(model.partB.choices);
106
- return onModelChanged(model, true);
107
- }
108
- return onModelChanged(model);
109
- };
110
- }
111
- render() {
112
- const {classes, model, configuration, onConfigurationChanged} = this.props;
113
- const {partLabelType, partA: modelPartA, partB: modelPartB} = model;
114
- const {partA, partB, partialScoring, scoringType, ...generalConfiguration} = configuration;
115
- const {feedback: feedbackA = {}, choiceMode: choiceModeA = {}, choicePrefix: choicePrefixA = {}, lockChoiceOrder: lockChoiceOrderA = {}, prompt: promptA = {}, teacherInstructions: teacherInstructionsA = {}, studentInstructions: studentInstructionsA = {}, choicesLayout: choicesLayoutA = {}, gridColumns: gridColumnsA = {}, rationale: rationaleA = {}, spellCheck: spellCheckA = {}} = partA || ({});
116
- const {feedback: feedbackB = {}, choiceMode: choiceModeB = {}, choicePrefix: choicePrefixB = {}, lockChoiceOrder: lockChoiceOrderB = {}, prompt: promptB = {}, teacherInstructions: teacherInstructionsB = {}, studentInstructions: studentInstructionsB = {}, choicesLayout: choicesLayoutB = {}, gridColumns: gridColumnsB = {}, rationale: rationaleB = {}, spellCheck: spellCheckB = {}} = partB || ({});
117
- const type = partLabelType || 'Numbers';
118
- const typeIsNumber = type === 'Numbers';
119
- const firstPart = `Part ${typeIsNumber ? '1' : 'A'}`;
120
- const secondPart = `Part ${typeIsNumber ? '2' : 'B'}`;
121
- const nrOfColumnsAvailable = {
122
- partA: modelPartA.choices && modelPartA.choices.length ? Array.from({
123
- length: modelPartA.choices.length
124
- }, (_, i) => `${i + 1}`) : [],
125
- partB: modelPartB.choices && modelPartB.choices.length ? Array.from({
126
- length: modelPartB.choices.length
127
- }, (_, i) => `${i + 1}`) : []
128
- };
129
- return React$1.createElement('div', {
130
- className: classes.design,
131
- __self: this,
132
- __source: {
133
- fileName: _jsxFileName,
134
- lineNumber: 111
135
- }
136
- }, React$1.createElement(layout.ConfigLayout, {
137
- settings: React$1.createElement(Panel, {
138
- model: model,
139
- onChangeModel: this.onModelChanged,
140
- configuration: configuration,
141
- onChangeConfiguration: onConfigurationChanged,
142
- groups: {
143
- 'Settings for both': {
144
- partLabels: generalConfiguration.partLabels.settings && toggle(generalConfiguration.partLabels.label),
145
- partLabelType: model.partLabels && dropdown('', ['Numbers', 'Letters']),
146
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
147
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
148
- },
149
- [`Settings ${firstPart}`]: {
150
- 'partA.choiceMode': choiceModeA.settings && radio(choiceModeA.label, ['checkbox', 'radio']),
151
- 'partA.choicePrefix': choicePrefixA.settings && radio(choicePrefixA.label, ['numbers', 'letters']),
152
- 'partA.lockChoiceOrder': lockChoiceOrderA.settings && toggle(lockChoiceOrderA.label),
153
- 'partA.choicesLayout': choicesLayoutA.settings && dropdown(choicesLayoutA.label, ['vertical', 'grid', 'horizontal']),
154
- 'partA.gridColumns': choicesLayoutA.settings && modelPartA.choicesLayout === 'grid' && nrOfColumnsAvailable.partA.length > 0 && dropdown(gridColumnsA.label, nrOfColumnsAvailable.partA)
155
- },
156
- [`Properties ${firstPart}`]: {
157
- 'partA.feedbackEnabled': feedbackA.settings && toggle(feedbackA.label),
158
- 'partA.promptEnabled': promptA.settings && toggle(promptA.label),
159
- 'partA.teacherInstructionsEnabled': teacherInstructionsA.settings && toggle(teacherInstructionsA.label),
160
- 'partA.studentInstructionsEnabled': studentInstructionsA.settings && toggle(studentInstructionsA.label),
161
- 'partA.rationaleEnabled': rationaleA.settings && toggle(rationaleA.label),
162
- 'partA.spellCheckEnabled': spellCheckA.settings && toggle(spellCheckA.label)
163
- },
164
- [`Settings ${secondPart}`]: {
165
- 'partB.choiceMode': choiceModeB.settings && radio(choiceModeB.label, ['checkbox', 'radio']),
166
- 'partB.choicePrefix': choicePrefixB.settings && radio(choicePrefixB.label, ['numbers', 'letters']),
167
- 'partB.lockChoiceOrder': lockChoiceOrderB.settings && toggle(lockChoiceOrderB.label),
168
- 'partB.choicesLayout': choicesLayoutB.settings && dropdown(choicesLayoutB.label, ['vertical', 'grid', 'horizontal']),
169
- 'partB.gridColumns': choicesLayoutB.settings && modelPartB.choicesLayout === 'grid' && nrOfColumnsAvailable.partB.length > 0 && dropdown(gridColumnsB.label, nrOfColumnsAvailable.partB)
170
- },
171
- [`Properties ${secondPart}`]: {
172
- 'partB.feedbackEnabled': feedbackB.settings && toggle(feedbackB.label),
173
- 'partB.promptEnabled': promptB.settings && toggle(promptB.label),
174
- 'partB.teacherInstructionsEnabled': teacherInstructionsB.settings && toggle(teacherInstructionsB.label),
175
- 'partB.studentInstructionsEnabled': studentInstructionsB.settings && toggle(studentInstructionsB.label),
176
- 'partB.rationaleEnabled': rationaleB.settings && toggle(rationaleB.label),
177
- 'partB.spellCheckEnabled': spellCheckB.settings && toggle(spellCheckB.label)
178
- }
179
- },
180
- __self: this,
181
- __source: {
182
- fileName: _jsxFileName,
183
- lineNumber: 114
184
- }
185
- }),
186
- __self: this,
187
- __source: {
188
- fileName: _jsxFileName,
189
- lineNumber: 112
190
- }
191
- }, React$1.createElement('div', {
192
- __self: this,
193
- __source: {
194
- fileName: _jsxFileName,
195
- lineNumber: 201
196
- }
197
- }, React$1.createElement('div', {
198
- className: classes.part,
199
- __self: this,
200
- __source: {
201
- fileName: _jsxFileName,
202
- lineNumber: 202
203
- }
204
- }, model.partLabels && React$1.createElement('p', {
205
- __self: this,
206
- __source: {
207
- fileName: _jsxFileName,
208
- lineNumber: 203
209
- }
210
- }, firstPart), React$1.createElement('ebsr-multiple-choice-configure', {
211
- id: "A",
212
- key: "partA",
213
- ref: ref => {
214
- if (ref) {
215
- this.partA = ref;
216
- this.partA._model = cloneDeep$1(this.props.model.partA);
217
- this.partA.configuration = {
218
- ...partA,
219
- ...generalConfiguration
220
- };
221
- }
222
- },
223
- __self: this,
224
- __source: {
225
- fileName: _jsxFileName,
226
- lineNumber: 204
227
- }
228
- })), React$1.createElement('div', {
229
- className: classes.part,
230
- __self: this,
231
- __source: {
232
- fileName: _jsxFileName,
233
- lineNumber: 221
234
- }
235
- }, model.partLabels && React$1.createElement('p', {
236
- __self: this,
237
- __source: {
238
- fileName: _jsxFileName,
239
- lineNumber: 222
240
- }
241
- }, secondPart), React$1.createElement('ebsr-multiple-choice-configure', {
242
- id: "B",
243
- key: "partB",
244
- ref: ref => {
245
- if (ref) {
246
- this.partB = ref;
247
- this.partB._model = cloneDeep$1(this.props.model.partB);
248
- this.partB.configuration = {
249
- ...partB,
250
- ...generalConfiguration
251
- };
252
- }
253
- },
254
- __self: this,
255
- __source: {
256
- fileName: _jsxFileName,
257
- lineNumber: 223
258
- }
259
- })))));
260
- }
261
- }
262
- Main.__initStatic();
263
- const Styled = withStyles(styles)(Main);
264
- const {cloneDeep: cloneDeep} = _dll_lodash;
265
- const defaultConfig = {
266
- addChoiceButton: {
267
- settings: true,
268
- label: 'Add a Choice'
269
- },
270
- choiceMode: {
271
- settings: true,
272
- label: 'Response Type'
273
- },
274
- choicePrefix: {
275
- settings: true,
276
- label: 'Choice Labels'
277
- },
278
- deleteChoice: {
279
- settings: true
280
- },
281
- feedback: {
282
- settings: true,
283
- label: 'Feedback'
284
- },
285
- lockChoiceOrder: {
286
- settings: true,
287
- label: 'Lock Choice Order'
288
- },
289
- prompt: {
290
- settings: true,
291
- label: 'Prompt'
292
- },
293
- rationale: {
294
- settings: true,
295
- label: 'Rationale'
296
- },
297
- studentInstructions: {
298
- settings: false,
299
- label: 'Student Instructions'
300
- },
301
- teacherInstructions: {
302
- settings: true,
303
- label: 'Teacher Instructions'
304
- },
305
- choicesLayout: {
306
- settings: false,
307
- label: 'Choices Layout'
308
- },
309
- gridColumns: {
310
- label: 'Grid columns'
311
- },
312
- spellCheck: {
313
- label: 'Spellcheck',
314
- settings: false,
315
- enabled: true
316
- }
317
- };
318
- const partModel = base => ({
319
- choiceMode: 'radio',
320
- choices: [],
321
- choicePrefix: 'numbers',
322
- prompt: 'Prompt',
323
- rationaleEnabled: true,
324
- feedbackEnabled: true,
325
- promptEnabled: true,
326
- teacherInstructions: '',
327
- rationale: '',
328
- teacherInstructionsEnabled: true,
329
- studentInstructionsEnabled: true,
330
- spellCheckEnabled: true,
331
- choicesLayout: 'vertical',
332
- gridColumns: '2',
333
- ...base
334
- });
335
- var sensibleDefaults = {
336
- model: {
337
- partLabels: true,
338
- partLabelType: 'Letters',
339
- partialScoring: false,
340
- partA: partModel({
341
- prompt: 'Prompt A'
342
- }),
343
- partB: partModel({
344
- prompt: 'Prompt B'
345
- })
346
- },
347
- configuration: {
348
- partialScoring: {
349
- label: 'Allow Partial Scoring',
350
- settings: false
351
- },
352
- scoringType: {
353
- settings: false,
354
- label: 'Scoring Type'
355
- },
356
- partA: cloneDeep(defaultConfig),
357
- partB: cloneDeep(defaultConfig),
358
- partLabels: {
359
- settings: true,
360
- label: 'Part Labels'
361
- },
362
- settingsPanelDisabled: true
363
- }
364
- };
365
- const React = _dll_react;
366
- const ReactDOM = _dll_react_dom;
367
- const {defaults: defaults} = _dll_lodash;
368
- const MODEL_UPDATED = ModelUpdatedEvent_1.TYPE;
369
- const MC_TAG_NAME = 'ebsr-multiple-choice-configure';
370
- class EbsrMCConfigure extends MultipleChoiceConfigure {}
371
- const defineMultipleChoice = () => {
372
- if (!customElements.get(MC_TAG_NAME)) {
373
- customElements.define(MC_TAG_NAME, EbsrMCConfigure);
374
- }
375
- };
376
- defineMultipleChoice();
377
- const prepareCustomizationObject = (config, model) => {
378
- const configuration = defaults(config, sensibleDefaults.configuration);
379
- configuration.settingsPanelDisabled = true;
380
- return {
381
- configuration,
382
- model
383
- };
384
- };
385
- const {model: modelDefault} = sensibleDefaults || ({});
386
- class EbsrConfigure extends HTMLElement {
387
- static __initStatic() {
388
- this.createDefaultModel = ({partA = {}, partB = {}, ...model} = {}, defaults = modelDefault) => ({
389
- ...defaults,
390
- ...model,
391
- partA: {
392
- ...defaults.partA,
393
- ...partA,
394
- choicesLayout: partA.choicesLayout || partA.verticalMode === false && 'horizontal' || defaults.partA.choicesLayout
395
- },
396
- partB: {
397
- ...defaults.partB,
398
- ...partB,
399
- choicesLayout: partB.choicesLayout || partB.verticalMode === false && 'horizontal' || defaults.partB.choicesLayout
400
- }
401
- });
402
- }
403
- constructor() {
404
- super();
405
- EbsrConfigure.prototype.__init.call(this);
406
- EbsrConfigure.prototype.__init2.call(this);
407
- this._model = EbsrConfigure.createDefaultModel();
408
- this._configuration = sensibleDefaults.configuration;
409
- this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
410
- }
411
- set model(m) {
412
- this._model = EbsrConfigure.createDefaultModel(m, this._model);
413
- this._render();
414
- }
415
- dispatchModelUpdated(reset) {
416
- const resetValue = !!reset;
417
- this.dispatchEvent(new ModelUpdatedEvent_1(this._model, resetValue));
418
- }
419
- __init() {
420
- this.onModelChanged = (m, reset) => {
421
- this._model = EbsrConfigure.createDefaultModel(m, this._model);
422
- this.dispatchModelUpdated(reset);
423
- this._render();
424
- };
425
- }
426
- set configuration(c) {
427
- const info = prepareCustomizationObject(c, this._model);
428
- this._configuration = info.configuration;
429
- this._render();
430
- }
431
- onConfigurationChanged(c) {
432
- this._configuration = prepareCustomizationObject(c, this._model).configuration;
433
- if (this._model) {
434
- this.onModelChanged(this._model);
435
- }
436
- this._render();
437
- }
438
- __init2() {
439
- this.onModelUpdated = e => {
440
- if (e.target === this) {
441
- return;
442
- }
443
- e.preventDefault();
444
- e.stopImmediatePropagation();
445
- const id = e.target && e.target.getAttribute('id');
446
- if (id) {
447
- if (e.update) {
448
- this._model[`part${id}`] = e.update;
449
- }
450
- this.dispatchEvent(new ModelUpdatedEvent_1(this._model));
451
- }
452
- };
453
- }
454
- connectedCallback() {
455
- this.addEventListener(MODEL_UPDATED, this.onModelUpdated);
456
- this._render();
457
- }
458
- disconnectedCallback() {
459
- this.removeEventListener(MODEL_UPDATED, this.onModelUpdated);
460
- }
461
- _render() {
462
- let element = React.createElement(Styled, {
463
- model: this._model,
464
- configuration: this._configuration,
465
- onModelChanged: this.onModelChanged,
466
- onConfigurationChanged: this.onConfigurationChanged
467
- });
468
- ReactDOM.render(element, this);
469
- }
470
- }
471
- EbsrConfigure.__initStatic();
472
- export {EbsrConfigure as default};