@pie-element/placement-ordering 7.5.3-next.137 → 7.5.3-next.1372
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +305 -0
- package/configure/CHANGELOG.md +273 -0
- package/configure/lib/choice-editor.js +224 -53
- package/configure/lib/choice-editor.js.map +1 -1
- package/configure/lib/choice-tile.js +71 -9
- package/configure/lib/choice-tile.js.map +1 -1
- package/configure/lib/defaults.js +22 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design.js +146 -13
- package/configure/lib/design.js.map +1 -1
- package/configure/lib/index.js +17 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/utils.js +14 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +6 -5
- package/controller/CHANGELOG.md +85 -0
- package/controller/lib/index.js +42 -9
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/scoring.js +11 -4
- package/controller/lib/scoring.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +140 -0
- package/docs/config-schema.json.md +109 -1
- package/docs/demo/generate.js +4 -3
- package/docs/pie-schema.json +54 -30
- package/docs/pie-schema.json.md +38 -28
- package/lib/index.js +5 -2
- package/lib/index.js.map +1 -1
- package/lib/main.js +1 -1
- package/lib/main.js.map +1 -1
- package/lib/ordering.js +2 -1
- package/lib/ordering.js.map +1 -1
- package/lib/placement-ordering.js +12 -15
- package/lib/placement-ordering.js.map +1 -1
- package/lib/tile.js +1 -1
- package/lib/tile.js.map +1 -1
- package/lib/tiler.js +3 -3
- package/lib/tiler.js.map +1 -1
- package/package.json +5 -5
|
@@ -134,6 +134,18 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
134
134
|
|
|
135
135
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
136
136
|
|
|
137
|
+
# `spellCheck` (object)
|
|
138
|
+
|
|
139
|
+
Properties of the `spellCheck` object:
|
|
140
|
+
|
|
141
|
+
## `settings` (boolean)
|
|
142
|
+
|
|
143
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
144
|
+
|
|
145
|
+
## `label` (string)
|
|
146
|
+
|
|
147
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
148
|
+
|
|
137
149
|
# `removeTilesAfterPlacing` (object)
|
|
138
150
|
|
|
139
151
|
Properties of the `removeTilesAfterPlacing` object:
|
|
@@ -194,6 +206,74 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
194
206
|
|
|
195
207
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
196
208
|
|
|
209
|
+
# `maxImageWidth` (object)
|
|
210
|
+
|
|
211
|
+
Properties of the `maxImageWidth` object:
|
|
212
|
+
|
|
213
|
+
## `teacherInstructions` (number)
|
|
214
|
+
|
|
215
|
+
Indicates the max dimension for images in teacher instructions
|
|
216
|
+
|
|
217
|
+
## `prompt` (number)
|
|
218
|
+
|
|
219
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
220
|
+
|
|
221
|
+
## `rationale` (number)
|
|
222
|
+
|
|
223
|
+
Indicates the max dimension for images in rationale
|
|
224
|
+
|
|
225
|
+
## `choicesWithPlacementArea` (number)
|
|
226
|
+
|
|
227
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is enabled
|
|
228
|
+
|
|
229
|
+
## `choicesWithoutPlacementArea` (number)
|
|
230
|
+
|
|
231
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is disabled
|
|
232
|
+
|
|
233
|
+
## `choices` (number)
|
|
234
|
+
|
|
235
|
+
Only available for the height prop: indicates the max height for images in choices and choices labels
|
|
236
|
+
|
|
237
|
+
# `maxImageHeight` (object)
|
|
238
|
+
|
|
239
|
+
Properties of the `maxImageHeight` object:
|
|
240
|
+
|
|
241
|
+
## `teacherInstructions` (number)
|
|
242
|
+
|
|
243
|
+
Indicates the max dimension for images in teacher instructions
|
|
244
|
+
|
|
245
|
+
## `prompt` (number)
|
|
246
|
+
|
|
247
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
248
|
+
|
|
249
|
+
## `rationale` (number)
|
|
250
|
+
|
|
251
|
+
Indicates the max dimension for images in rationale
|
|
252
|
+
|
|
253
|
+
## `choicesWithPlacementArea` (number)
|
|
254
|
+
|
|
255
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is enabled
|
|
256
|
+
|
|
257
|
+
## `choicesWithoutPlacementArea` (number)
|
|
258
|
+
|
|
259
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is disabled
|
|
260
|
+
|
|
261
|
+
## `choices` (number)
|
|
262
|
+
|
|
263
|
+
Only available for the height prop: indicates the max height for images in choices and choices labels
|
|
264
|
+
|
|
265
|
+
# `withRubric` (object)
|
|
266
|
+
|
|
267
|
+
Properties of the `withRubric` object:
|
|
268
|
+
|
|
269
|
+
## `settings` (boolean)
|
|
270
|
+
|
|
271
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
272
|
+
|
|
273
|
+
## `label` (string)
|
|
274
|
+
|
|
275
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
276
|
+
|
|
197
277
|
# `showPrompt` (boolean)
|
|
198
278
|
|
|
199
279
|
Determines whether prompt field will be displayed or not
|
|
@@ -228,4 +308,32 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
228
308
|
|
|
229
309
|
### `label` (string)
|
|
230
310
|
|
|
231
|
-
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
311
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
312
|
+
|
|
313
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
314
|
+
|
|
315
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
316
|
+
|
|
317
|
+
### `teacherInstructions` (number)
|
|
318
|
+
|
|
319
|
+
Indicates the max dimension for images in teacher instructions
|
|
320
|
+
|
|
321
|
+
### `prompt` (number)
|
|
322
|
+
|
|
323
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
324
|
+
|
|
325
|
+
### `rationale` (number)
|
|
326
|
+
|
|
327
|
+
Indicates the max dimension for images in rationale
|
|
328
|
+
|
|
329
|
+
### `choicesWithPlacementArea` (number)
|
|
330
|
+
|
|
331
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is enabled
|
|
332
|
+
|
|
333
|
+
### `choicesWithoutPlacementArea` (number)
|
|
334
|
+
|
|
335
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is disabled
|
|
336
|
+
|
|
337
|
+
### `choices` (number)
|
|
338
|
+
|
|
339
|
+
Only available for the height prop: indicates the max height for images in choices and choices labels
|
package/docs/demo/generate.js
CHANGED
|
@@ -22,7 +22,7 @@ exports.model = (id, element) => ({
|
|
|
22
22
|
],
|
|
23
23
|
correctResponse: ['c1', 'c2', 'c3', 'c4'],
|
|
24
24
|
alternateResponses: [
|
|
25
|
-
['c4', 'c3', 'c2', 'c1']
|
|
25
|
+
{ response: ['c4', 'c3', 'c2', 'c1'] },
|
|
26
26
|
],
|
|
27
27
|
enableImages: false,
|
|
28
28
|
feedback: {
|
|
@@ -46,8 +46,9 @@ exports.model = (id, element) => ({
|
|
|
46
46
|
numberedGuides: false,
|
|
47
47
|
orientation: 'vertical',
|
|
48
48
|
partialScoring: false,
|
|
49
|
-
placementArea:
|
|
49
|
+
placementArea: false,
|
|
50
50
|
scoringType: 'auto',
|
|
51
51
|
targetLabel: 'Answers',
|
|
52
|
-
toolbarEditorPosition: 'bottom'
|
|
52
|
+
toolbarEditorPosition: 'bottom',
|
|
53
|
+
rubricEnabled: false
|
|
53
54
|
});
|
package/docs/pie-schema.json
CHANGED
|
@@ -24,18 +24,6 @@
|
|
|
24
24
|
"description": "The label of the choice",
|
|
25
25
|
"type": "string",
|
|
26
26
|
"title": "label"
|
|
27
|
-
},
|
|
28
|
-
"moveOnDrag": {
|
|
29
|
-
"description": "Indicates if choice will be removed after is placed into a placement area",
|
|
30
|
-
"default": false,
|
|
31
|
-
"type": "boolean",
|
|
32
|
-
"title": "moveOnDrag"
|
|
33
|
-
},
|
|
34
|
-
"lockChoiceOrder": {
|
|
35
|
-
"description": "If the entire array of choices can lockChoiceOrder, each choice itself\nhas this property to indicate if it should lockChoiceOrder",
|
|
36
|
-
"default": true,
|
|
37
|
-
"type": "boolean",
|
|
38
|
-
"title": "lockChoiceOrder"
|
|
39
27
|
}
|
|
40
28
|
},
|
|
41
29
|
"required": [
|
|
@@ -75,17 +63,17 @@
|
|
|
75
63
|
"title": "AlternateResponse",
|
|
76
64
|
"type": "object",
|
|
77
65
|
"properties": {
|
|
78
|
-
"
|
|
66
|
+
"response": {
|
|
79
67
|
"description": "Array that contains the alternate response ids",
|
|
80
68
|
"type": "array",
|
|
81
69
|
"items": {
|
|
82
70
|
"type": "string"
|
|
83
71
|
},
|
|
84
|
-
"title": "
|
|
72
|
+
"title": "response"
|
|
85
73
|
}
|
|
86
74
|
},
|
|
87
75
|
"required": [
|
|
88
|
-
"
|
|
76
|
+
"response"
|
|
89
77
|
]
|
|
90
78
|
},
|
|
91
79
|
"title": "alternateResponses"
|
|
@@ -359,6 +347,11 @@
|
|
|
359
347
|
"type": "boolean",
|
|
360
348
|
"title": "choiceLabelEnabled"
|
|
361
349
|
},
|
|
350
|
+
"spellCheckEnabled": {
|
|
351
|
+
"description": "Indicates if spellcheck is enabled for the author. Default value is true",
|
|
352
|
+
"type": "boolean",
|
|
353
|
+
"title": "spellCheckEnabled"
|
|
354
|
+
},
|
|
362
355
|
"note": {
|
|
363
356
|
"description": "Indicates the note for the answer",
|
|
364
357
|
"type": "string",
|
|
@@ -374,6 +367,11 @@
|
|
|
374
367
|
"type": "string",
|
|
375
368
|
"title": "toolbarEditorPosition"
|
|
376
369
|
},
|
|
370
|
+
"rubricEnabled": {
|
|
371
|
+
"description": "Indicates if Rubric is enabled",
|
|
372
|
+
"type": "boolean",
|
|
373
|
+
"title": "rubricEnabled"
|
|
374
|
+
},
|
|
377
375
|
"id": {
|
|
378
376
|
"description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
|
|
379
377
|
"type": "string",
|
|
@@ -392,6 +390,8 @@
|
|
|
392
390
|
"feedbackEnabled",
|
|
393
391
|
"id",
|
|
394
392
|
"rationaleEnabled",
|
|
393
|
+
"rubricEnabled",
|
|
394
|
+
"spellCheckEnabled",
|
|
395
395
|
"studentInstructionsEnabled",
|
|
396
396
|
"teacherInstructionsEnabled"
|
|
397
397
|
],
|
|
@@ -412,6 +412,42 @@
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
},
|
|
415
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
416
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
417
|
+
"type": "object",
|
|
418
|
+
"properties": {
|
|
419
|
+
"teacherInstructions": {
|
|
420
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
421
|
+
"type": "number",
|
|
422
|
+
"title": "teacherInstructions"
|
|
423
|
+
},
|
|
424
|
+
"prompt": {
|
|
425
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
426
|
+
"type": "number",
|
|
427
|
+
"title": "prompt"
|
|
428
|
+
},
|
|
429
|
+
"rationale": {
|
|
430
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
431
|
+
"type": "number",
|
|
432
|
+
"title": "rationale"
|
|
433
|
+
},
|
|
434
|
+
"choicesWithPlacementArea": {
|
|
435
|
+
"description": "Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is enabled",
|
|
436
|
+
"type": "number",
|
|
437
|
+
"title": "choicesWithPlacementArea"
|
|
438
|
+
},
|
|
439
|
+
"choicesWithoutPlacementArea": {
|
|
440
|
+
"description": "Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is disabled",
|
|
441
|
+
"type": "number",
|
|
442
|
+
"title": "choicesWithoutPlacementArea"
|
|
443
|
+
},
|
|
444
|
+
"choices": {
|
|
445
|
+
"description": "Only available for the height prop: indicates the max height for images in choices and choices labels",
|
|
446
|
+
"type": "number",
|
|
447
|
+
"title": "choices"
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
},
|
|
415
451
|
"Choice": {
|
|
416
452
|
"title": "Choice",
|
|
417
453
|
"type": "object",
|
|
@@ -425,18 +461,6 @@
|
|
|
425
461
|
"description": "The label of the choice",
|
|
426
462
|
"type": "string",
|
|
427
463
|
"title": "label"
|
|
428
|
-
},
|
|
429
|
-
"moveOnDrag": {
|
|
430
|
-
"description": "Indicates if choice will be removed after is placed into a placement area",
|
|
431
|
-
"default": false,
|
|
432
|
-
"type": "boolean",
|
|
433
|
-
"title": "moveOnDrag"
|
|
434
|
-
},
|
|
435
|
-
"lockChoiceOrder": {
|
|
436
|
-
"description": "If the entire array of choices can lockChoiceOrder, each choice itself\nhas this property to indicate if it should lockChoiceOrder",
|
|
437
|
-
"default": true,
|
|
438
|
-
"type": "boolean",
|
|
439
|
-
"title": "lockChoiceOrder"
|
|
440
464
|
}
|
|
441
465
|
},
|
|
442
466
|
"required": [
|
|
@@ -466,17 +490,17 @@
|
|
|
466
490
|
"title": "AlternateResponse",
|
|
467
491
|
"type": "object",
|
|
468
492
|
"properties": {
|
|
469
|
-
"
|
|
493
|
+
"response": {
|
|
470
494
|
"description": "Array that contains the alternate response ids",
|
|
471
495
|
"type": "array",
|
|
472
496
|
"items": {
|
|
473
497
|
"type": "string"
|
|
474
498
|
},
|
|
475
|
-
"title": "
|
|
499
|
+
"title": "response"
|
|
476
500
|
}
|
|
477
501
|
},
|
|
478
502
|
"required": [
|
|
479
|
-
"
|
|
503
|
+
"response"
|
|
480
504
|
]
|
|
481
505
|
},
|
|
482
506
|
"ComplexFeedbackType": {
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -22,19 +22,6 @@ The id of the choice
|
|
|
22
22
|
|
|
23
23
|
The label of the choice
|
|
24
24
|
|
|
25
|
-
## `moveOnDrag` (boolean)
|
|
26
|
-
|
|
27
|
-
Indicates if choice will be removed after is placed into a placement area
|
|
28
|
-
|
|
29
|
-
Default: `false`
|
|
30
|
-
|
|
31
|
-
## `lockChoiceOrder` (boolean)
|
|
32
|
-
|
|
33
|
-
If the entire array of choices can lockChoiceOrder, each choice itself
|
|
34
|
-
has this property to indicate if it should lockChoiceOrder
|
|
35
|
-
|
|
36
|
-
Default: `true`
|
|
37
|
-
|
|
38
25
|
# `correctResponse` (array)
|
|
39
26
|
|
|
40
27
|
Array of the correct responses in the correct order
|
|
@@ -60,7 +47,7 @@ The object is an array with all elements of the type `object`.
|
|
|
60
47
|
|
|
61
48
|
The array object has the following properties:
|
|
62
49
|
|
|
63
|
-
## `
|
|
50
|
+
## `response` (array, required)
|
|
64
51
|
|
|
65
52
|
Array that contains the alternate response ids
|
|
66
53
|
|
|
@@ -168,6 +155,10 @@ Indicates if Teacher Instructions are enabled
|
|
|
168
155
|
|
|
169
156
|
Indicates if Choice Label is enabled
|
|
170
157
|
|
|
158
|
+
# `spellCheckEnabled` (boolean, required)
|
|
159
|
+
|
|
160
|
+
Indicates if spellcheck is enabled for the author. Default value is true
|
|
161
|
+
|
|
171
162
|
# `note` (string)
|
|
172
163
|
|
|
173
164
|
Indicates the note for the answer
|
|
@@ -183,6 +174,10 @@ This element must be one of the following enum values:
|
|
|
183
174
|
|
|
184
175
|
Default: `": 'bottom'"`
|
|
185
176
|
|
|
177
|
+
# `rubricEnabled` (boolean, required)
|
|
178
|
+
|
|
179
|
+
Indicates if Rubric is enabled
|
|
180
|
+
|
|
186
181
|
# `id` (string, required)
|
|
187
182
|
|
|
188
183
|
Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
|
|
@@ -209,30 +204,45 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
209
204
|
|
|
210
205
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
211
206
|
|
|
212
|
-
## `
|
|
207
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
213
208
|
|
|
214
|
-
Properties of the `
|
|
209
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
215
210
|
|
|
216
|
-
### `
|
|
211
|
+
### `teacherInstructions` (number)
|
|
217
212
|
|
|
218
|
-
|
|
213
|
+
Indicates the max dimension for images in teacher instructions
|
|
219
214
|
|
|
220
|
-
### `
|
|
215
|
+
### `prompt` (number)
|
|
221
216
|
|
|
222
|
-
|
|
217
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
218
|
+
|
|
219
|
+
### `rationale` (number)
|
|
220
|
+
|
|
221
|
+
Indicates the max dimension for images in rationale
|
|
222
|
+
|
|
223
|
+
### `choicesWithPlacementArea` (number)
|
|
223
224
|
|
|
224
|
-
|
|
225
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is enabled
|
|
225
226
|
|
|
226
|
-
|
|
227
|
+
### `choicesWithoutPlacementArea` (number)
|
|
227
228
|
|
|
228
|
-
|
|
229
|
+
Only available for the width prop: indicates the max width for images in choices and choices labels when placement area is disabled
|
|
229
230
|
|
|
230
|
-
### `
|
|
231
|
+
### `choices` (number)
|
|
231
232
|
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
Only available for the height prop: indicates the max height for images in choices and choices labels
|
|
234
|
+
|
|
235
|
+
## `Choice` (object)
|
|
236
|
+
|
|
237
|
+
Properties of the `Choice` object:
|
|
234
238
|
|
|
235
|
-
|
|
239
|
+
### `id` (string, required)
|
|
240
|
+
|
|
241
|
+
The id of the choice
|
|
242
|
+
|
|
243
|
+
### `label` (string)
|
|
244
|
+
|
|
245
|
+
The label of the choice
|
|
236
246
|
|
|
237
247
|
## `CorrectResponse` (object)
|
|
238
248
|
|
|
@@ -251,7 +261,7 @@ Note: weights are not configurable in the existing component so we'll ignore it
|
|
|
251
261
|
|
|
252
262
|
Properties of the `AlternateResponse` object:
|
|
253
263
|
|
|
254
|
-
### `
|
|
264
|
+
### `response` (array, required)
|
|
255
265
|
|
|
256
266
|
Array that contains the alternate response ids
|
|
257
267
|
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports["default"] = void 0;
|
|
8
9
|
Object.defineProperty(exports, "swap", {
|
|
9
10
|
enumerable: true,
|
|
10
11
|
get: function get() {
|
|
@@ -17,7 +18,6 @@ Object.defineProperty(exports, "withDragContext", {
|
|
|
17
18
|
return _drag.withDragContext;
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
|
-
exports["default"] = void 0;
|
|
21
21
|
|
|
22
22
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
23
23
|
|
|
@@ -51,7 +51,7 @@ var _drag = require("@pie-lib/drag");
|
|
|
51
51
|
|
|
52
52
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
53
53
|
|
|
54
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
54
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
55
55
|
|
|
56
56
|
var log = (0, _debug["default"])('pie-elements:placement-ordering');
|
|
57
57
|
|
|
@@ -116,6 +116,9 @@ var Ordering = /*#__PURE__*/function (_HTMLElement) {
|
|
|
116
116
|
}
|
|
117
117
|
}, {
|
|
118
118
|
key: "session",
|
|
119
|
+
get: function get() {
|
|
120
|
+
return this._session;
|
|
121
|
+
},
|
|
119
122
|
set: function set(newSession) {
|
|
120
123
|
this._session = newSession;
|
|
121
124
|
this.render();
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","Ordering","sessionChange","bind","_model","_session","element","React","createElement","Main","model","session","onSessionChange","ReactDOM","render","value","dispatchEvent","CustomEvent","bubbles","detail","component","tagName","toLowerCase","complete","length","completeLength","newModel","newSession","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;;IAIqBC,Q;;;;;AACnB,sBAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,IAAnB,gDAArB;AAFY;AAGb;;;;WAED,kBAAS;AAAA;;AACP,UAAI,KAAKC,MAAL,IAAe,KAAKC,QAAxB,EAAkC;AAChCL,QAAAA,GAAG,CAAC,oBAAD,EAAuB,KAAKK,QAA5B,CAAH;AACAL,QAAAA,GAAG,CAAC,kBAAD,EAAqB,KAAKI,MAA1B,CAAH;;AAEA,YAAME,OAAO,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACxCC,UAAAA,KAAK,EAAE,KAAKN,MAD4B;AAExCO,UAAAA,OAAO,EAAE,KAAKN,QAF0B;AAGxCO,UAAAA,eAAe,EAAE,KAAKV;AAHkB,SAA1B,CAAhB;;AAMAW,6BAASC,MAAT,CAAgBR,OAAhB,EAAyB,IAAzB,EAA+B,YAAM;AACnC,yCAAW,MAAX;AACD,SAFD;AAGD;AACF;;;WAED,uBAAcK,OAAd,EAAuB;AACrB,WAAKN,QAAL,CAAcU,KAAd,GAAsBJ,OAAO,CAACI,KAA9B;AACA,WAAKD,MAAL;AACA,WAAKE,aAAL,CACE,IAAIC,WAAJ,CAAgB,iBAAhB,EAAmC;AACjCC,QAAAA,OAAO,EAAE,IADwB;AAEjCC,QAAAA,MAAM,EAAE;AACNC,UAAAA,SAAS,EAAE,KAAKC,OAAL,CAAaC,WAAb,EADL;AAENC,UAAAA,QAAQ,EACN,KAAKlB,QAAL,IACA,KAAKA,QAAL,CAAcU,KADd,IAEA,yBAAQ,KAAKV,QAAL,CAAcU,KAAtB,EAA6BS,MAA7B,KAAwC,KAAKpB,MAAL,CAAYqB;AALhD;AAFyB,OAAnC,CADF;AAYD;;;SAED,aAAUC,QAAV,EAAoB;AAClB,WAAKtB,MAAL,GAAcsB,QAAd;AACA,WAAKZ,MAAL;AACA,WAAKE,aAAL,CACE,IAAIC,WAAJ,CAAgB,WAAhB,EAA6B;AAC3BC,QAAAA,OAAO,EAAE,IADkB;AAE3BC,QAAAA,MAAM,EAAE;AACNI,UAAAA,QAAQ,EAAE;AADJ;AAFmB,OAA7B,CADF;AAQD;;;
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","Ordering","sessionChange","bind","_model","_session","element","React","createElement","Main","model","session","onSessionChange","ReactDOM","render","value","dispatchEvent","CustomEvent","bubbles","detail","component","tagName","toLowerCase","complete","length","completeLength","newModel","newSession","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;;IAIqBC,Q;;;;;AACnB,sBAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,IAAnB,gDAArB;AAFY;AAGb;;;;WAED,kBAAS;AAAA;;AACP,UAAI,KAAKC,MAAL,IAAe,KAAKC,QAAxB,EAAkC;AAChCL,QAAAA,GAAG,CAAC,oB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L,GAAgBsB,UAAhB;AACA,WAAKb,MAAL;AACD;;;kDAxDmCc,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport compact from 'lodash/compact';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { swap } from './ordering';\nimport { withDragContext } from '@pie-lib/drag';\nconst log = debug('pie-elements:placement-ordering');\n\nexport { withDragContext, swap };\n\nexport default class Ordering extends HTMLElement {\n constructor() {\n super();\n this.sessionChange = this.sessionChange.bind(this);\n }\n\n render() {\n if (this._model && this._session) {\n log('[render] session: ', this._session);\n log('[render] model: ', this._model);\n\n const element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onSessionChange: this.sessionChange\n });\n\n ReactDOM.render(element, this, () => {\n renderMath(this);\n });\n }\n }\n\n sessionChange(session) {\n this._session.value = session.value;\n this.render();\n this.dispatchEvent(\n new CustomEvent('session-changed', {\n bubbles: true,\n detail: {\n component: this.tagName.toLowerCase(),\n complete:\n this._session &&\n this._session.value &&\n compact(this._session.value).length === this._model.completeLength\n }\n })\n );\n }\n\n set model(newModel) {\n this._model = newModel;\n this.render();\n this.dispatchEvent(\n new CustomEvent('model-set', {\n bubbles: true,\n detail: {\n complete: false\n }\n })\n );\n }\n\n set session(newSession) {\n this._session = newSession;\n this.render();\n }\n\n get session() {\n return this._session;\n }\n}\n"],"file":"index.js"}
|
package/lib/main.js
CHANGED
|
@@ -29,7 +29,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
29
29
|
|
|
30
30
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
31
31
|
|
|
32
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
32
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
33
|
|
|
34
34
|
var Main = /*#__PURE__*/function (_React$Component) {
|
|
35
35
|
(0, _inherits2["default"])(Main, _React$Component);
|
package/lib/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.jsx"],"names":["Main","props","model","session","onSessionChange","React","Component","PropTypes","object","isRequired","oneOfType","array","func","out"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;IAEMA,I;;;;;;;;;;;;WAUJ,kBAAS;
|
|
1
|
+
{"version":3,"sources":["../src/main.jsx"],"names":["Main","props","model","session","onSessionChange","React","Component","PropTypes","object","isRequired","oneOfType","array","func","out"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;IAEMA,I;;;;;;;;;;;;WAUJ,kBAAS;AACP,wBAA4C,KAAKC,KAAjD;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,OAAf,eAAeA,OAAf;AAAA,UAAwBC,eAAxB,eAAwBA,eAAxB;AACA,0BACE,gCAAC,6BAAD;AACE,QAAA,KAAK,EAAEF,KADT;AAEE,QAAA,OAAO,EAAEC,OAFX;AAGE,QAAA,eAAe,EAAEC;AAHnB,QADF;AAOD;;;EAnBgBC,kBAAMC,S;;iCAAnBN,I,eACe;AACjBE,EAAAA,KAAK,EAAEK,sBAAUC,MAAV,CAAiBC,UADP;AAEjBN,EAAAA,OAAO,EAAEI,sBAAUG,SAAV,CAAoB,CAC3BH,sBAAUI,KAAV,CAAgBF,UADW,EAE3BF,sBAAUC,MAAV,CAAiBC,UAFU,CAApB,CAFQ;AAMjBL,EAAAA,eAAe,EAAEG,sBAAUK,IAAV,CAAeH;AANf,C;AAoBrB,IAAMI,GAAG,GAAG,2BAAgBb,IAAhB,CAAZ;eACea,G","sourcesContent":["import PlacementOrdering from './placement-ordering';\nimport React from 'react';\nimport { withDragContext } from '@pie-lib/drag';\n\nimport PropTypes from 'prop-types';\n\nclass Main extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n session: PropTypes.oneOfType([\n PropTypes.array.isRequired,\n PropTypes.object.isRequired\n ]),\n onSessionChange: PropTypes.func.isRequired\n };\n\n render() {\n const { model, session, onSessionChange } = this.props;\n return (\n <PlacementOrdering\n model={model}\n session={session}\n onSessionChange={onSessionChange}\n />\n );\n }\n}\nconst out = withDragContext(Main);\nexport default out;\n"],"file":"main.js"}
|
package/lib/ordering.js
CHANGED
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.buildState = buildState;
|
|
9
|
+
exports.push = void 0;
|
|
9
10
|
exports.reducer = reducer;
|
|
10
|
-
exports.swap =
|
|
11
|
+
exports.swap = void 0;
|
|
11
12
|
|
|
12
13
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
14
|
|
package/lib/ordering.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ordering.js"],"names":["log","push","arr","fromIndex","toIndex","movedItem","find","item","index","remainingItems","filter","slice","swap","length","undefined","Error","update","tmp","removeResponse","state","targetTile","response","id","updateResponse","from","to","opts","includeTargets","type","findIndex","r","buildTiles","choices","outcomes","targets","i","choice","c","outcome","out","Object","assign","empty","draggable","processedChoices","map","m","indexOf","allowSameChoiceInTargets","droppable","concat","reduce","acc","emptyTile","choiceTile","buildState","Array","tiles","reducer","action","target"],"mappings":";;;;;;;;;;;;;AAAA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Deep from 'lodash/cloneDeep';\nimport debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport map from 'lodash/map';\nimport assign from 'lodash/assign';\n\nconst log = debug('pie-elements:placement-ordering:ordering');\n\nexport const push = (arr, fromIndex, toIndex) => {\n const movedItem = arr.find((item, index) => index === fromIndex);\n const remainingItems = arr.filter((item, index) => index !== fromIndex);\n\n return [\n ...remainingItems.slice(0, toIndex),\n movedItem,\n ...remainingItems.slice(toIndex)\n ];\n}\n\nexport const swap = (arr, fromIndex, toIndex) => {\n log('[swap]', arr, fromIndex, toIndex);\n if (\n !arr ||\n arr.length <= 1 ||\n fromIndex === undefined ||\n toIndex === undefined\n ) {\n throw new Error(\n `swap requires a non-empty array, fromIndex, toIndex: ${arr}, ${fromIndex} ${toIndex}`\n );\n }\n const update = cloneDeep(arr);\n const tmp = arr[toIndex];\n update[toIndex] = update[fromIndex];\n update[fromIndex] = tmp;\n return update;\n};\n\nfunction removeResponse(state, targetTile) {\n const update = cloneDeep(state.response);\n\n if (update[targetTile.index] === targetTile.id) {\n update[targetTile.index] = undefined;\n } else {\n throw new Error(\n `Tried to remove from index: ${\n targetTile.index\n }, but the id doesn't match: array: ${update}, target: ${targetTile.id}`\n );\n }\n return update;\n}\n\nfunction updateResponse(state, from, to) {\n const { response, opts } = state;\n const update = cloneDeep(response);\n if (opts.includeTargets) {\n if (from.type === 'choice' && to.type === 'target') {\n update[to.index] = from.id;\n return update;\n } else if (from.type === 'target' && to.type === 'choice') {\n update[from.index] = undefined;\n return update;\n } else if (from.type === 'target' && to.type === 'target') {\n return swap(response, from.index, to.index);\n } else {\n log('do nothing to the response');\n return response;\n }\n } else {\n const fromIndex = state.response.findIndex(\n r => r !== undefined && r === from.id\n );\n const toIndex = state.response.findIndex(\n r => r !== undefined && r === to.id\n );\n log('fromIndex: ', fromIndex, 'toIndex:', toIndex);\n return push(state.response, fromIndex, toIndex);\n }\n}\n\nfunction buildTiles(choices, response, outcomes, opts) {\n if (opts.includeTargets) {\n const targets = [];\n for (let i = 0; i < response.length; i++) {\n const r = response[i];\n\n const choice = choices.find(\n c => r !== undefined && r !== null && c.id === r\n );\n //TODO: index needs to match too!!\n const outcome = outcomes[i];\n\n const out = Object.assign(\n { type: 'target', index: i, empty: choice === undefined },\n choice,\n outcome,\n { draggable: choice !== undefined }\n );\n\n targets.push(out);\n }\n\n const processedChoices = choices.map(m => {\n if (response.indexOf(m.id) !== -1 && !opts.allowSameChoiceInTargets) {\n return {\n type: 'choice',\n empty: true,\n droppable: true,\n draggable: false\n };\n } else {\n return Object.assign({}, m, {\n type: 'choice',\n droppable: false,\n draggable: true\n });\n }\n });\n\n return processedChoices.concat(targets);\n } else {\n return response.reduce((acc, id, index) => {\n const emptyTile = Object.assign(\n { type: 'empty', draggable: false, droppable: true },\n choices.find(m => m.id === id),\n outcomes[index]\n );\n const choiceTile = Object.assign(\n { type: 'choice', draggable: true, droppable: true },\n choices.find(m => m.id === id),\n outcomes[index]\n )\n\n if(index === 0) {\n acc.push(emptyTile)\n }\n\n acc.push(choiceTile, emptyTile);\n\n return acc;\n }, []);\n }\n}\n\nexport function buildState(choices, response, outcomes, opts) {\n opts = assign({ includeTargets: true }, opts);\n\n outcomes = outcomes || [];\n response =\n !response || isEmpty(response)\n ? opts.includeTargets\n ? new Array(choices.length)\n : map(choices, c => c.id)\n : response;\n return {\n choices,\n response,\n opts,\n outcomes,\n tiles: buildTiles(choices, response, outcomes, opts)\n };\n}\n\nexport function reducer(action, state) {\n switch (action.type) {\n case 'move': {\n const { from, to } = action;\n const response = updateResponse(state, from, to);\n const tiles = buildTiles(\n state.choices,\n response,\n state.outcomes,\n state.opts\n );\n return Object.assign({}, state, { response, tiles });\n }\n case 'remove': {\n const { target } = action;\n const response = removeResponse(state, target);\n const tiles = buildTiles(\n state.choices,\n response,\n state.outcomes,\n state.opts\n );\n return Object.assign({}, state, { response, tiles });\n }\n }\n return state;\n}\n"],"file":"ordering.js"}
|
|
1
|
+
{"version":3,"sources":["../src/ordering.js"],"names":["log","push","arr","fromIndex","toIndex","movedItem","find","item","index","remainingItems","filter","slice","swap","length","undefined","Error","update","tmp","removeResponse","state","targetTile","response","id","updateResponse","from","to","opts","includeTargets","type","findIndex","r","buildTiles","choices","outcomes","targets","i","choice","c","outcome","out","Object","assign","empty","draggable","processedChoices","map","m","indexOf","allowSameChoiceInTargets","droppable","concat","reduce","acc","emptyTile","choiceTile","buildState","Array","tiles","reducer","action","target"],"mappings":";;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAACC,GAAD,EAAMC,SAAN,EAAiBC,OAAjB,EAA6B;AAC/C,MAAMC,SAAS,GAAGH,GAAG,CAACI,IAAJ,CAAS,UAACC,IAAD,EAAOC,KAAP;AAAA,WAAiBA,KAAK,KAAKL,SAA3B;AAAA,GAAT,CAAlB;AACA,MAAMM,cAAc,GAAGP,GAAG,CAACQ,MAAJ,CAAW,UAACH,IAAD,EAAOC,KAAP;AAAA,WAAiBA,KAAK,KAAKL,SAA3B;AAAA,GAAX,CAAvB;AAEA,uDACKM,cAAc,CAACE,KAAf,CAAqB,CAArB,EAAwBP,OAAxB,CADL,IAEEC,SAFF,uCAGKI,cAAc,CAACE,KAAf,CAAqBP,OAArB,CAHL;AAKD,CATM;;;;AAWA,IAAMQ,IAAI,GAAG,SAAPA,IAAO,CAACV,GAAD,EAAMC,SAAN,EAAiBC,OAAjB,EAA6B;AAC/CJ,EAAAA,GAAG,CAAC,QAAD,EAAWE,GAAX,EAAgBC,SAAhB,EAA2BC,OAA3B,CAAH;;AACA,MACE,CAACF,GAAD,IACAA,GAAG,CAACW,MAAJ,IAAc,CADd,IAEAV,SAAS,KAAKW,SAFd,IAGAV,OAAO,KAAKU,SAJd,EAKE;AACA,UAAM,IAAIC,KAAJ,gEACoDb,GADpD,eAC4DC,SAD5D,cACyEC,OADzE,EA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AMH,MAAK,GAAG1B,UAAU,CACtBZ,KAAK,CAACa,OADgB,EAEtBX,SAFsB,EAGtBF,KAAK,CAACc,QAHgB,EAItBd,KAAK,CAACO,IAJgB,CAAxB;;AAMA,eAAOc,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBtB,KAAlB,EAAyB;AAAEE,UAAAA,QAAQ,EAARA,SAAF;AAAYoC,UAAAA,KAAK,EAALA;AAAZ,SAAzB,CAAP;AACD;AAtBH;;AAwBA,SAAOtC,KAAP;AACD","sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\nimport debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport map from 'lodash/map';\nimport assign from 'lodash/assign';\n\nconst log = debug('pie-elements:placement-ordering:ordering');\n\nexport const push = (arr, fromIndex, toIndex) => {\n const movedItem = arr.find((item, index) => index === fromIndex);\n const remainingItems = arr.filter((item, index) => index !== fromIndex);\n\n return [\n ...remainingItems.slice(0, toIndex),\n movedItem,\n ...remainingItems.slice(toIndex)\n ];\n}\n\nexport const swap = (arr, fromIndex, toIndex) => {\n log('[swap]', arr, fromIndex, toIndex);\n if (\n !arr ||\n arr.length <= 1 ||\n fromIndex === undefined ||\n toIndex === undefined\n ) {\n throw new Error(\n `swap requires a non-empty array, fromIndex, toIndex: ${arr}, ${fromIndex} ${toIndex}`\n );\n }\n const update = cloneDeep(arr);\n const tmp = arr[toIndex];\n update[toIndex] = update[fromIndex];\n update[fromIndex] = tmp;\n return update;\n};\n\nfunction removeResponse(state, targetTile) {\n const update = cloneDeep(state.response);\n\n if (update[targetTile.index] === targetTile.id) {\n update[targetTile.index] = undefined;\n } else {\n throw new Error(\n `Tried to remove from index: ${\n targetTile.index\n }, but the id doesn't match: array: ${update}, target: ${targetTile.id}`\n );\n }\n return update;\n}\n\nfunction updateResponse(state, from, to) {\n const { response, opts } = state;\n const update = cloneDeep(response);\n if (opts.includeTargets) {\n if (from.type === 'choice' && to.type === 'target') {\n update[to.index] = from.id;\n return update;\n } else if (from.type === 'target' && to.type === 'choice') {\n update[from.index] = undefined;\n return update;\n } else if (from.type === 'target' && to.type === 'target') {\n return swap(response, from.index, to.index);\n } else {\n log('do nothing to the response');\n return response;\n }\n } else {\n const fromIndex = state.response.findIndex(\n r => r !== undefined && r === from.id\n );\n const toIndex = state.response.findIndex(\n r => r !== undefined && r === to.id\n );\n log('fromIndex: ', fromIndex, 'toIndex:', toIndex);\n return push(state.response, fromIndex, toIndex);\n }\n}\n\nfunction buildTiles(choices, response, outcomes, opts) {\n if (opts.includeTargets) {\n const targets = [];\n for (let i = 0; i < response.length; i++) {\n const r = response[i];\n\n const choice = choices.find(\n c => r !== undefined && r !== null && c.id === r\n );\n //TODO: index needs to match too!!\n const outcome = outcomes[i];\n\n const out = Object.assign(\n { type: 'target', index: i, empty: choice === undefined },\n choice,\n outcome,\n { draggable: choice !== undefined }\n );\n\n targets.push(out);\n }\n\n const processedChoices = choices.map(m => {\n if (response.indexOf(m.id) !== -1 && !opts.allowSameChoiceInTargets) {\n return {\n type: 'choice',\n empty: true,\n droppable: true,\n draggable: false\n };\n } else {\n return Object.assign({}, m, {\n type: 'choice',\n droppable: false,\n draggable: true\n });\n }\n });\n\n return processedChoices.concat(targets);\n } else {\n return response.reduce((acc, id, index) => {\n const emptyTile = Object.assign(\n { type: 'empty', draggable: false, droppable: true },\n choices.find(m => m.id === id),\n outcomes[index]\n );\n const choiceTile = Object.assign(\n { type: 'choice', draggable: true, droppable: true },\n choices.find(m => m.id === id),\n outcomes[index]\n )\n\n if(index === 0) {\n acc.push(emptyTile)\n }\n\n acc.push(choiceTile, emptyTile);\n\n return acc;\n }, []);\n }\n}\n\nexport function buildState(choices, response, outcomes, opts) {\n opts = assign({ includeTargets: true }, opts);\n\n outcomes = outcomes || [];\n response =\n !response || isEmpty(response)\n ? opts.includeTargets\n ? new Array(choices.length)\n : map(choices, c => c.id)\n : response;\n return {\n choices,\n response,\n opts,\n outcomes,\n tiles: buildTiles(choices, response, outcomes, opts)\n };\n}\n\nexport function reducer(action, state) {\n switch (action.type) {\n case 'move': {\n const { from, to } = action;\n const response = updateResponse(state, from, to);\n const tiles = buildTiles(\n state.choices,\n response,\n state.outcomes,\n state.opts\n );\n return Object.assign({}, state, { response, tiles });\n }\n case 'remove': {\n const { target } = action;\n const response = removeResponse(state, target);\n const tiles = buildTiles(\n state.choices,\n response,\n state.outcomes,\n state.opts\n );\n return Object.assign({}, state, { response, tiles });\n }\n }\n return state;\n}\n"],"file":"ordering.js"}
|
|
@@ -51,9 +51,11 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
51
51
|
|
|
52
52
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
53
53
|
|
|
54
|
+
var _excluded = ["tiler", "ordering", "onDropChoice", "onRemoveChoice"];
|
|
55
|
+
|
|
54
56
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
55
57
|
|
|
56
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
58
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
57
59
|
|
|
58
60
|
var log = (0, _debug["default"])('pie-elements:placement-ordering');
|
|
59
61
|
|
|
@@ -62,7 +64,7 @@ var OrderingTiler = function OrderingTiler(props) {
|
|
|
62
64
|
ordering = props.ordering,
|
|
63
65
|
_onDropChoice = props.onDropChoice,
|
|
64
66
|
_onRemoveChoice = props.onRemoveChoice,
|
|
65
|
-
compProps = (0, _objectWithoutProperties2["default"])(props,
|
|
67
|
+
compProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
66
68
|
return /*#__PURE__*/_react["default"].createElement(Comp, (0, _extends2["default"])({}, compProps, {
|
|
67
69
|
tiles: ordering.tiles,
|
|
68
70
|
onDropChoice: function onDropChoice(t, s) {
|
|
@@ -260,20 +262,17 @@ var PlacementOrdering = /*#__PURE__*/function (_React$Component) {
|
|
|
260
262
|
visible: 'Hide Teacher Instructions'
|
|
261
263
|
},
|
|
262
264
|
className: classes.collapsible
|
|
263
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
264
|
-
|
|
265
|
-
__html: teacherInstructions
|
|
266
|
-
}
|
|
265
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
266
|
+
prompt: teacherInstructions
|
|
267
267
|
})), /*#__PURE__*/_react["default"].createElement("br", null)), /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
|
|
268
268
|
show: showToggle,
|
|
269
269
|
toggled: showingCorrect,
|
|
270
270
|
onToggle: this.toggleCorrect
|
|
271
271
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
272
|
-
className: classes.prompt
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}), /*#__PURE__*/_react["default"].createElement(OrderingTiler, {
|
|
272
|
+
className: classes.prompt
|
|
273
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
274
|
+
prompt: prompt
|
|
275
|
+
})), /*#__PURE__*/_react["default"].createElement(OrderingTiler, {
|
|
277
276
|
instanceId: this.instanceId,
|
|
278
277
|
choiceLabel: config.choiceLabel,
|
|
279
278
|
targetLabel: config.targetLabel,
|
|
@@ -297,10 +296,8 @@ var PlacementOrdering = /*#__PURE__*/function (_React$Component) {
|
|
|
297
296
|
visible: 'Hide Rationale'
|
|
298
297
|
},
|
|
299
298
|
className: classes.collapsible
|
|
300
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
301
|
-
|
|
302
|
-
__html: rationale
|
|
303
|
-
}
|
|
299
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
300
|
+
prompt: rationale
|
|
304
301
|
})), !showingCorrect && /*#__PURE__*/_react["default"].createElement(_renderUi.Feedback, {
|
|
305
302
|
correctness: correctness,
|
|
306
303
|
feedback: feedback
|