@enspiredigital/xlms-headless 0.0.18 → 0.0.19
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/dist/hooks/useOrdering.d.ts.map +1 -1
- package/dist/index.js +187 -176
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOrdering.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrdering.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useOrdering.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrdering.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,oBAAoB;;;;;;;;;;;0BA4B3B,MAAM,WAAW,MAAM;qBAU5B,MAAM;uBAQJ,MAAM;6BAQA,MAAM,eAAe,MAAM;;;;;;;EAwE5D"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useState as x, useEffect as
|
|
2
|
-
function
|
|
3
|
-
const [t,
|
|
1
|
+
import { useState as x, useEffect as B, useMemo as y } from "react";
|
|
2
|
+
function M() {
|
|
3
|
+
const [t, o] = x(null), [c, f] = x(null), [m, b] = x(0);
|
|
4
4
|
function w(l) {
|
|
5
|
-
|
|
5
|
+
o(!0), f(l), b((A) => A + 1);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
7
|
+
function i() {
|
|
8
|
+
o(!1), f(null);
|
|
9
9
|
}
|
|
10
10
|
return {
|
|
11
11
|
// state
|
|
@@ -16,36 +16,44 @@ function O() {
|
|
|
16
16
|
canAnswer: !t,
|
|
17
17
|
// actions
|
|
18
18
|
submitQuestion: w,
|
|
19
|
-
resetQuestion:
|
|
19
|
+
resetQuestion: i
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
if (t.length !==
|
|
24
|
-
const c = new Set(t),
|
|
25
|
-
if (c.size !==
|
|
22
|
+
function j(t, o) {
|
|
23
|
+
if (t.length !== o.length) return !1;
|
|
24
|
+
const c = new Set(t), f = new Set(o);
|
|
25
|
+
if (c.size !== f.size) return !1;
|
|
26
26
|
for (const m of c)
|
|
27
|
-
if (!
|
|
27
|
+
if (!f.has(m)) return !1;
|
|
28
28
|
return !0;
|
|
29
29
|
}
|
|
30
|
+
function D(t) {
|
|
31
|
+
const o = [...t];
|
|
32
|
+
for (let c = o.length - 1; c > 0; c--) {
|
|
33
|
+
const f = Math.floor(Math.random() * (c + 1));
|
|
34
|
+
[o[c], o[f]] = [o[f], o[c]];
|
|
35
|
+
}
|
|
36
|
+
return o;
|
|
37
|
+
}
|
|
30
38
|
function E(t) {
|
|
31
39
|
const {
|
|
32
|
-
canAnswer:
|
|
40
|
+
canAnswer: o,
|
|
33
41
|
submitted: c,
|
|
34
|
-
isCorrect:
|
|
42
|
+
isCorrect: f,
|
|
35
43
|
attempts: m,
|
|
36
44
|
resetQuestion: b,
|
|
37
45
|
submitQuestion: w
|
|
38
|
-
} =
|
|
46
|
+
} = M(), [i, l] = x([]);
|
|
39
47
|
function A(I) {
|
|
40
|
-
l((
|
|
48
|
+
l((d) => t.options.allowMultipleAnswers ? d.includes(I) ? d.filter((g) => g !== I) : [...d, I] : [I]);
|
|
41
49
|
}
|
|
42
50
|
function S() {
|
|
43
|
-
if (
|
|
51
|
+
if (i.length === 0) return;
|
|
44
52
|
const I = t.options.answers.reduce(
|
|
45
53
|
(g, p) => (p.is_correct && g.push(p.id), g),
|
|
46
54
|
[]
|
|
47
|
-
),
|
|
48
|
-
w(
|
|
55
|
+
), d = j(i, I);
|
|
56
|
+
w(d);
|
|
49
57
|
}
|
|
50
58
|
function Q() {
|
|
51
59
|
l([]), b();
|
|
@@ -53,32 +61,32 @@ function E(t) {
|
|
|
53
61
|
return {
|
|
54
62
|
// data
|
|
55
63
|
question: t,
|
|
56
|
-
selectedIds:
|
|
64
|
+
selectedIds: i,
|
|
57
65
|
// actions
|
|
58
66
|
select: A,
|
|
59
67
|
submit: S,
|
|
60
68
|
reset: Q,
|
|
61
69
|
// base
|
|
62
70
|
submitted: c,
|
|
63
|
-
isCorrect:
|
|
71
|
+
isCorrect: f,
|
|
64
72
|
attempts: m,
|
|
65
|
-
canAnswer:
|
|
73
|
+
canAnswer: o
|
|
66
74
|
};
|
|
67
75
|
}
|
|
68
|
-
function
|
|
76
|
+
function V(t) {
|
|
69
77
|
const {
|
|
70
|
-
canAnswer:
|
|
78
|
+
canAnswer: o,
|
|
71
79
|
submitted: c,
|
|
72
|
-
isCorrect:
|
|
80
|
+
isCorrect: f,
|
|
73
81
|
attempts: m,
|
|
74
82
|
submitQuestion: b,
|
|
75
83
|
resetQuestion: w
|
|
76
|
-
} =
|
|
84
|
+
} = M(), [i, l] = x([]), [A, S] = x(
|
|
77
85
|
[]
|
|
78
86
|
), [Q, I] = x(
|
|
79
87
|
[]
|
|
80
88
|
);
|
|
81
|
-
function
|
|
89
|
+
function d(e, n) {
|
|
82
90
|
l((r) => [
|
|
83
91
|
...r.filter(
|
|
84
92
|
(u) => u.targetId !== e && u.sourceId !== n
|
|
@@ -94,7 +102,7 @@ function j(t) {
|
|
|
94
102
|
function p() {
|
|
95
103
|
let e = 0, n = !0;
|
|
96
104
|
return t.options.targets.forEach((r) => {
|
|
97
|
-
const u =
|
|
105
|
+
const u = i.find((C) => C.targetId === r.id), h = t.options.sources[r.content.correct_position - 1];
|
|
98
106
|
u && h && u.sourceId === h.id ? e += r.content.point : n = !1;
|
|
99
107
|
}), {
|
|
100
108
|
isCorrect: n,
|
|
@@ -112,46 +120,46 @@ function j(t) {
|
|
|
112
120
|
function s() {
|
|
113
121
|
l([]), w();
|
|
114
122
|
}
|
|
115
|
-
return
|
|
123
|
+
return B(() => {
|
|
116
124
|
const e = t.options.sources.filter(
|
|
117
|
-
(n) => !
|
|
125
|
+
(n) => !i.some((r) => r.sourceId === n.id)
|
|
118
126
|
);
|
|
119
127
|
S(e);
|
|
120
|
-
}, [
|
|
128
|
+
}, [i, t.options.sources]), B(() => {
|
|
121
129
|
const e = t.options.targets.filter(
|
|
122
|
-
(n) => !
|
|
130
|
+
(n) => !i.some((r) => r.targetId === n.id)
|
|
123
131
|
);
|
|
124
132
|
I(e);
|
|
125
|
-
}, [
|
|
133
|
+
}, [i, t.options.targets]), {
|
|
126
134
|
// data
|
|
127
135
|
sources: t.options.sources,
|
|
128
136
|
targets: t.options.targets,
|
|
129
|
-
answers:
|
|
137
|
+
answers: i,
|
|
130
138
|
question: t,
|
|
131
139
|
availableSources: A,
|
|
132
140
|
availableTargets: Q,
|
|
133
141
|
// base
|
|
134
142
|
submitted: c,
|
|
135
|
-
isCorrect:
|
|
143
|
+
isCorrect: f,
|
|
136
144
|
attempts: m,
|
|
137
|
-
canAnswer:
|
|
145
|
+
canAnswer: o,
|
|
138
146
|
// actions
|
|
139
|
-
select:
|
|
147
|
+
select: d,
|
|
140
148
|
remove: g,
|
|
141
149
|
submit: a,
|
|
142
150
|
reset: s
|
|
143
151
|
};
|
|
144
152
|
}
|
|
145
|
-
function
|
|
153
|
+
function T(t) {
|
|
146
154
|
const {
|
|
147
|
-
canAnswer:
|
|
155
|
+
canAnswer: o,
|
|
148
156
|
submitted: c,
|
|
149
|
-
isCorrect:
|
|
157
|
+
isCorrect: f,
|
|
150
158
|
attempts: m,
|
|
151
159
|
resetQuestion: b,
|
|
152
160
|
submitQuestion: w
|
|
153
|
-
} =
|
|
154
|
-
function
|
|
161
|
+
} = M();
|
|
162
|
+
function i() {
|
|
155
163
|
w(!0);
|
|
156
164
|
}
|
|
157
165
|
function l() {
|
|
@@ -163,29 +171,29 @@ function V(t) {
|
|
|
163
171
|
url: t.options.url,
|
|
164
172
|
type: t.options.urlType,
|
|
165
173
|
// actions
|
|
166
|
-
submit:
|
|
174
|
+
submit: i,
|
|
167
175
|
reset: l,
|
|
168
176
|
// base
|
|
169
177
|
submitted: c,
|
|
170
|
-
isCorrect:
|
|
178
|
+
isCorrect: f,
|
|
171
179
|
attempts: m,
|
|
172
|
-
canAnswer:
|
|
180
|
+
canAnswer: o
|
|
173
181
|
};
|
|
174
182
|
}
|
|
175
|
-
function
|
|
183
|
+
function F(t) {
|
|
176
184
|
const {
|
|
177
|
-
canAnswer:
|
|
185
|
+
canAnswer: o,
|
|
178
186
|
submitted: c,
|
|
179
|
-
isCorrect:
|
|
187
|
+
isCorrect: f,
|
|
180
188
|
attempts: m,
|
|
181
189
|
submitQuestion: b,
|
|
182
190
|
resetQuestion: w
|
|
183
|
-
} =
|
|
184
|
-
const e = new Set(
|
|
191
|
+
} = M(), [i, l] = x([]), [A, S] = x(null), Q = y(() => {
|
|
192
|
+
const e = new Set(i.map((n) => n.itemId));
|
|
185
193
|
return t.options.answers.filter(
|
|
186
194
|
(n) => !e.has(String(n.id))
|
|
187
195
|
);
|
|
188
|
-
}, [
|
|
196
|
+
}, [i, t.options.answers]);
|
|
189
197
|
function I(e, n) {
|
|
190
198
|
l((r) => [
|
|
191
199
|
...r.filter(
|
|
@@ -197,7 +205,7 @@ function T(t) {
|
|
|
197
205
|
}
|
|
198
206
|
]);
|
|
199
207
|
}
|
|
200
|
-
function
|
|
208
|
+
function d(e) {
|
|
201
209
|
l((n) => n.filter((r) => r.itemId !== e));
|
|
202
210
|
}
|
|
203
211
|
function g(e, n) {
|
|
@@ -205,15 +213,15 @@ function T(t) {
|
|
|
205
213
|
}
|
|
206
214
|
function p() {
|
|
207
215
|
let e = 0, n = !0, r = 0;
|
|
208
|
-
const u = t.correct_answers.list, h = new Map(
|
|
216
|
+
const u = t.correct_answers.list, h = new Map(i.map((C) => [C.blankIndex, C.itemId]));
|
|
209
217
|
return Object.entries(u).forEach(([C, k]) => {
|
|
210
|
-
const
|
|
218
|
+
const O = C, v = h.get(O);
|
|
211
219
|
if (!v) {
|
|
212
220
|
n = !1;
|
|
213
221
|
return;
|
|
214
222
|
}
|
|
215
|
-
const
|
|
216
|
-
|
|
223
|
+
const L = t.options.answers.find((_) => _.id === v);
|
|
224
|
+
L && String(L.group_position) === String(k) ? (e++, r += L.point) : n = !1;
|
|
217
225
|
}), {
|
|
218
226
|
isCorrect: n,
|
|
219
227
|
correctCount: e,
|
|
@@ -233,35 +241,37 @@ function T(t) {
|
|
|
233
241
|
// data
|
|
234
242
|
items: t.options.answers,
|
|
235
243
|
groups: t.options.groups,
|
|
236
|
-
answers:
|
|
244
|
+
answers: i,
|
|
237
245
|
availableItems: Q,
|
|
238
246
|
question: t,
|
|
239
247
|
draggingItemId: A,
|
|
240
248
|
// base
|
|
241
249
|
submitted: c,
|
|
242
|
-
isCorrect:
|
|
250
|
+
isCorrect: f,
|
|
243
251
|
attempts: m,
|
|
244
|
-
canAnswer:
|
|
252
|
+
canAnswer: o,
|
|
245
253
|
// actions
|
|
246
254
|
dropItem: I,
|
|
247
|
-
removeItem:
|
|
255
|
+
removeItem: d,
|
|
248
256
|
moveItem: g,
|
|
249
257
|
setDraggingItemId: S,
|
|
250
258
|
submit: a,
|
|
251
259
|
reset: s
|
|
252
260
|
};
|
|
253
261
|
}
|
|
254
|
-
function
|
|
262
|
+
function z(t) {
|
|
255
263
|
const {
|
|
256
|
-
canAnswer:
|
|
264
|
+
canAnswer: o,
|
|
257
265
|
submitted: c,
|
|
258
|
-
isCorrect:
|
|
266
|
+
isCorrect: f,
|
|
259
267
|
attempts: m,
|
|
260
268
|
submitQuestion: b,
|
|
261
269
|
resetQuestion: w
|
|
262
|
-
} =
|
|
270
|
+
} = M(), [i, l] = x(() => D(
|
|
271
|
+
t.options.answers.map((s) => String(s.id))
|
|
272
|
+
)), A = y(() => i.map(
|
|
263
273
|
(s) => t.options.answers.find((e) => String(e.id) === s)
|
|
264
|
-
).filter((s) => s !== void 0), [
|
|
274
|
+
).filter((s) => s !== void 0), [i, t.options.answers]);
|
|
265
275
|
function S(s, e) {
|
|
266
276
|
l((n) => {
|
|
267
277
|
const r = [...n], [u] = r.splice(s, 1);
|
|
@@ -269,21 +279,21 @@ function F(t) {
|
|
|
269
279
|
});
|
|
270
280
|
}
|
|
271
281
|
function Q(s) {
|
|
272
|
-
const e =
|
|
282
|
+
const e = i.indexOf(s);
|
|
273
283
|
e > 0 && S(e, e - 1);
|
|
274
284
|
}
|
|
275
285
|
function I(s) {
|
|
276
|
-
const e =
|
|
277
|
-
e <
|
|
286
|
+
const e = i.indexOf(s);
|
|
287
|
+
e < i.length - 1 && S(e, e + 1);
|
|
278
288
|
}
|
|
279
|
-
function
|
|
280
|
-
const n =
|
|
281
|
-
n !== -1 && e >= 0 && e <
|
|
289
|
+
function d(s, e) {
|
|
290
|
+
const n = i.indexOf(s);
|
|
291
|
+
n !== -1 && e >= 0 && e < i.length && S(n, e);
|
|
282
292
|
}
|
|
283
293
|
function g() {
|
|
284
294
|
let s = 0, e = !0;
|
|
285
295
|
return t.options.answers.forEach((n, r) => {
|
|
286
|
-
const u =
|
|
296
|
+
const u = i.indexOf(String(n.id));
|
|
287
297
|
u !== -1 && u + 1 === n.correct_position ? s += n.point : e = !1;
|
|
288
298
|
}), {
|
|
289
299
|
isCorrect: e,
|
|
@@ -306,42 +316,42 @@ function F(t) {
|
|
|
306
316
|
items: t.options.answers,
|
|
307
317
|
groups: t.options.groups,
|
|
308
318
|
orderedItems: A,
|
|
309
|
-
orderedItemIds:
|
|
319
|
+
orderedItemIds: i,
|
|
310
320
|
question: t,
|
|
311
321
|
// base
|
|
312
322
|
submitted: c,
|
|
313
|
-
isCorrect:
|
|
323
|
+
isCorrect: f,
|
|
314
324
|
attempts: m,
|
|
315
|
-
canAnswer:
|
|
325
|
+
canAnswer: o,
|
|
316
326
|
// actions
|
|
317
327
|
setOrderedItemIds: l,
|
|
318
328
|
moveItem: S,
|
|
319
329
|
moveUp: Q,
|
|
320
330
|
moveDown: I,
|
|
321
|
-
moveToPosition:
|
|
331
|
+
moveToPosition: d,
|
|
322
332
|
submit: p,
|
|
323
333
|
reset: a
|
|
324
334
|
};
|
|
325
335
|
}
|
|
326
|
-
function
|
|
336
|
+
function G(t) {
|
|
327
337
|
const {
|
|
328
|
-
canAnswer:
|
|
338
|
+
canAnswer: o,
|
|
329
339
|
submitted: c,
|
|
330
|
-
isCorrect:
|
|
340
|
+
isCorrect: f,
|
|
331
341
|
attempts: m,
|
|
332
342
|
submitQuestion: b,
|
|
333
343
|
resetQuestion: w
|
|
334
|
-
} =
|
|
335
|
-
const e = new Set(
|
|
344
|
+
} = M(), [i, l] = x([]), A = y(() => {
|
|
345
|
+
const e = new Set(i.map((n) => n.labelId));
|
|
336
346
|
return t.options.labels.filter(
|
|
337
347
|
(n) => !e.has(String(n.id))
|
|
338
348
|
);
|
|
339
|
-
}, [
|
|
349
|
+
}, [i, t.options.labels]);
|
|
340
350
|
function S(e, n, r, u) {
|
|
341
351
|
const h = t.options.blanks.find((C) => String(C.id) === n);
|
|
342
352
|
h && l((C) => [
|
|
343
353
|
...C.filter(
|
|
344
|
-
(
|
|
354
|
+
(O) => O.labelId !== e && O.blankId !== n
|
|
345
355
|
),
|
|
346
356
|
{
|
|
347
357
|
labelId: e,
|
|
@@ -357,20 +367,20 @@ function z(t) {
|
|
|
357
367
|
function I(e, n, r, u) {
|
|
358
368
|
S(e, n, r, u);
|
|
359
369
|
}
|
|
360
|
-
function
|
|
361
|
-
const n =
|
|
370
|
+
function d(e) {
|
|
371
|
+
const n = i.find((r) => r.blankId === e);
|
|
362
372
|
return n && t.options.labels.find(
|
|
363
373
|
(r) => String(r.id) === n.labelId
|
|
364
374
|
) || null;
|
|
365
375
|
}
|
|
366
376
|
function g(e) {
|
|
367
|
-
const n =
|
|
377
|
+
const n = i.find((r) => r.labelId === e);
|
|
368
378
|
return n ? n.blankId : null;
|
|
369
379
|
}
|
|
370
380
|
function p() {
|
|
371
381
|
let e = 0, n = !0;
|
|
372
382
|
return t.options.labels.forEach((r) => {
|
|
373
|
-
const u =
|
|
383
|
+
const u = i.find(
|
|
374
384
|
(C) => String(C.labelId) === String(r.id)
|
|
375
385
|
), h = t.options.blanks.find(
|
|
376
386
|
(C, k) => k + 1 === r.correct_position
|
|
@@ -399,64 +409,64 @@ function z(t) {
|
|
|
399
409
|
groups: t.options.groups,
|
|
400
410
|
imageWidth: t.image_width,
|
|
401
411
|
imageHeight: t.image_height,
|
|
402
|
-
answers:
|
|
412
|
+
answers: i,
|
|
403
413
|
availableLabels: A,
|
|
404
414
|
question: t,
|
|
405
415
|
// base
|
|
406
416
|
submitted: c,
|
|
407
|
-
isCorrect:
|
|
417
|
+
isCorrect: f,
|
|
408
418
|
attempts: m,
|
|
409
|
-
canAnswer:
|
|
419
|
+
canAnswer: o,
|
|
410
420
|
// actions
|
|
411
421
|
attachLabel: S,
|
|
412
422
|
removeLabel: Q,
|
|
413
423
|
moveLabel: I,
|
|
414
|
-
getLabelAtBlank:
|
|
424
|
+
getLabelAtBlank: d,
|
|
415
425
|
getBlankForLabel: g,
|
|
416
426
|
submit: a,
|
|
417
427
|
reset: s
|
|
418
428
|
};
|
|
419
429
|
}
|
|
420
|
-
function
|
|
430
|
+
function W(t) {
|
|
421
431
|
const {
|
|
422
|
-
canAnswer:
|
|
432
|
+
canAnswer: o,
|
|
423
433
|
submitted: c,
|
|
424
|
-
isCorrect:
|
|
434
|
+
isCorrect: f,
|
|
425
435
|
attempts: m,
|
|
426
436
|
submitQuestion: b,
|
|
427
437
|
resetQuestion: w
|
|
428
|
-
} =
|
|
429
|
-
function A(
|
|
438
|
+
} = M(), [i, l] = x([]);
|
|
439
|
+
function A(d, g) {
|
|
430
440
|
l((p) => {
|
|
431
|
-
const a = p.findIndex((s) => s.blankId ===
|
|
441
|
+
const a = p.findIndex((s) => s.blankId === d);
|
|
432
442
|
if (a >= 0) {
|
|
433
443
|
const s = [...p];
|
|
434
|
-
return s[a] = { blankId:
|
|
444
|
+
return s[a] = { blankId: d, value: g }, s;
|
|
435
445
|
}
|
|
436
|
-
return [...p, { blankId:
|
|
446
|
+
return [...p, { blankId: d, value: g }];
|
|
437
447
|
});
|
|
438
448
|
}
|
|
439
449
|
function S() {
|
|
440
|
-
let
|
|
450
|
+
let d = 0, g = 0, p = 0;
|
|
441
451
|
const a = t.correct_answers.list || {}, s = Object.keys(a).length;
|
|
442
452
|
Object.entries(a).forEach(([n, r]) => {
|
|
443
453
|
const u = String(r).trim().toLowerCase(), h = t.options.answers.find(
|
|
444
454
|
(v) => v.correct_position === Number(n)
|
|
445
455
|
), C = h && h.point || 1;
|
|
446
456
|
p += C;
|
|
447
|
-
const k =
|
|
448
|
-
(k ? String(k.value).trim().toLowerCase() : "") === u && (
|
|
457
|
+
const k = i.find((v) => v.blankId === n);
|
|
458
|
+
(k ? String(k.value).trim().toLowerCase() : "") === u && (d += C, g++);
|
|
449
459
|
});
|
|
450
460
|
const e = g === s && s > 0;
|
|
451
461
|
return p === 0 && s > 0 && (p = s), {
|
|
452
462
|
isCorrect: e,
|
|
453
|
-
score: Math.round(
|
|
463
|
+
score: Math.round(d * 100) / 100,
|
|
454
464
|
maxScore: Math.round(p * 100) / 100
|
|
455
465
|
};
|
|
456
466
|
}
|
|
457
467
|
function Q() {
|
|
458
|
-
const
|
|
459
|
-
return b(
|
|
468
|
+
const d = S();
|
|
469
|
+
return b(d.isCorrect), d;
|
|
460
470
|
}
|
|
461
471
|
function I() {
|
|
462
472
|
l([]), w();
|
|
@@ -464,28 +474,28 @@ function G(t) {
|
|
|
464
474
|
return {
|
|
465
475
|
// data
|
|
466
476
|
groups: t.options.groups,
|
|
467
|
-
answers:
|
|
477
|
+
answers: i,
|
|
468
478
|
question: t,
|
|
469
479
|
// base
|
|
470
480
|
submitted: c,
|
|
471
|
-
isCorrect:
|
|
481
|
+
isCorrect: f,
|
|
472
482
|
attempts: m,
|
|
473
|
-
canAnswer:
|
|
483
|
+
canAnswer: o,
|
|
474
484
|
// actions
|
|
475
485
|
answer: A,
|
|
476
486
|
submit: Q,
|
|
477
487
|
reset: I
|
|
478
488
|
};
|
|
479
489
|
}
|
|
480
|
-
function
|
|
490
|
+
function H(t) {
|
|
481
491
|
const {
|
|
482
|
-
canAnswer:
|
|
492
|
+
canAnswer: o,
|
|
483
493
|
submitted: c,
|
|
484
|
-
isCorrect:
|
|
494
|
+
isCorrect: f,
|
|
485
495
|
attempts: m,
|
|
486
496
|
submitQuestion: b,
|
|
487
497
|
resetQuestion: w
|
|
488
|
-
} =
|
|
498
|
+
} = M(), [i, l] = x([]);
|
|
489
499
|
function A(a, s) {
|
|
490
500
|
l((e) => {
|
|
491
501
|
const n = e.findIndex((r) => r.itemId === a);
|
|
@@ -504,10 +514,10 @@ function W(t) {
|
|
|
504
514
|
const n = t.correct_answers.list || {}, r = Object.keys(n).length;
|
|
505
515
|
let u = 0;
|
|
506
516
|
return Object.entries(n).forEach(([C, k]) => {
|
|
507
|
-
const
|
|
517
|
+
const O = t.options.items.find((_) => _.id === C), v = O ? O.point : 0;
|
|
508
518
|
u += v;
|
|
509
|
-
const
|
|
510
|
-
|
|
519
|
+
const L = i.find((_) => _.itemId === C);
|
|
520
|
+
L && L.categoryId === k && (a += v, s++);
|
|
511
521
|
}), a = Math.round(a * 100) / 100, u = Math.round(u * 100) / 100, {
|
|
512
522
|
isCorrect: s === r && r > 0,
|
|
513
523
|
score: a,
|
|
@@ -518,20 +528,20 @@ function W(t) {
|
|
|
518
528
|
const a = Q();
|
|
519
529
|
return b(a.isCorrect), a;
|
|
520
530
|
}
|
|
521
|
-
function
|
|
531
|
+
function d() {
|
|
522
532
|
l([]), w();
|
|
523
533
|
}
|
|
524
|
-
const g =
|
|
525
|
-
(a) => !
|
|
526
|
-
), [t.options.items,
|
|
527
|
-
const s =
|
|
534
|
+
const g = y(() => t.options.items.filter(
|
|
535
|
+
(a) => !i.some((s) => s.itemId === a.id)
|
|
536
|
+
), [t.options.items, i]), p = y(() => t.options.categories.map((a) => {
|
|
537
|
+
const s = i.filter((e) => e.categoryId === a.id).map((e) => ({
|
|
528
538
|
...t.options.items.find((r) => r.id === e.itemId)
|
|
529
539
|
}));
|
|
530
540
|
return {
|
|
531
541
|
...a,
|
|
532
542
|
items: s
|
|
533
543
|
};
|
|
534
|
-
}), [t.options.categories, t.options.items,
|
|
544
|
+
}), [t.options.categories, t.options.items, i]);
|
|
535
545
|
return {
|
|
536
546
|
// data
|
|
537
547
|
categories: t.options.categories,
|
|
@@ -539,30 +549,30 @@ function W(t) {
|
|
|
539
549
|
question: t,
|
|
540
550
|
categoriesWithItems: p,
|
|
541
551
|
// state
|
|
542
|
-
answers:
|
|
552
|
+
answers: i,
|
|
543
553
|
unassignedItems: g,
|
|
544
554
|
// base
|
|
545
555
|
submitted: c,
|
|
546
|
-
isCorrect:
|
|
556
|
+
isCorrect: f,
|
|
547
557
|
attempts: m,
|
|
548
|
-
canAnswer:
|
|
558
|
+
canAnswer: o,
|
|
549
559
|
// actions
|
|
550
560
|
move: A,
|
|
551
561
|
remove: S,
|
|
552
562
|
submit: I,
|
|
553
|
-
reset:
|
|
563
|
+
reset: d
|
|
554
564
|
};
|
|
555
565
|
}
|
|
556
|
-
function
|
|
566
|
+
function N(t) {
|
|
557
567
|
const {
|
|
558
|
-
canAnswer:
|
|
568
|
+
canAnswer: o,
|
|
559
569
|
submitted: c,
|
|
560
|
-
isCorrect:
|
|
570
|
+
isCorrect: f,
|
|
561
571
|
attempts: m,
|
|
562
572
|
resetQuestion: b,
|
|
563
573
|
submitQuestion: w
|
|
564
|
-
} =
|
|
565
|
-
function
|
|
574
|
+
} = M();
|
|
575
|
+
function i() {
|
|
566
576
|
c || w(!0);
|
|
567
577
|
}
|
|
568
578
|
function l() {
|
|
@@ -574,97 +584,98 @@ function H(t) {
|
|
|
574
584
|
url: t.options.url,
|
|
575
585
|
type: t.options.urlType,
|
|
576
586
|
// actions
|
|
577
|
-
submit:
|
|
587
|
+
submit: i,
|
|
578
588
|
reset: l,
|
|
579
589
|
// base
|
|
580
590
|
submitted: c,
|
|
581
|
-
isCorrect:
|
|
591
|
+
isCorrect: f,
|
|
582
592
|
attempts: m,
|
|
583
|
-
canAnswer:
|
|
593
|
+
canAnswer: o
|
|
584
594
|
};
|
|
585
595
|
}
|
|
586
|
-
function P({
|
|
587
|
-
getData: t,
|
|
588
|
-
children: i
|
|
589
|
-
}) {
|
|
590
|
-
const c = E(t());
|
|
591
|
-
return i(c);
|
|
592
|
-
}
|
|
593
596
|
function U({
|
|
594
597
|
getData: t,
|
|
595
|
-
children:
|
|
598
|
+
children: o
|
|
596
599
|
}) {
|
|
597
|
-
const c =
|
|
598
|
-
return
|
|
600
|
+
const c = E(t());
|
|
601
|
+
return o(c);
|
|
599
602
|
}
|
|
600
603
|
function J({
|
|
601
604
|
getData: t,
|
|
602
|
-
children:
|
|
605
|
+
children: o
|
|
603
606
|
}) {
|
|
604
607
|
const c = V(t());
|
|
605
|
-
return
|
|
608
|
+
return o(c);
|
|
606
609
|
}
|
|
607
610
|
function R({
|
|
608
611
|
getData: t,
|
|
609
|
-
children:
|
|
612
|
+
children: o
|
|
610
613
|
}) {
|
|
611
614
|
const c = T(t());
|
|
612
|
-
return
|
|
615
|
+
return o(c);
|
|
613
616
|
}
|
|
614
617
|
function X({
|
|
615
618
|
getData: t,
|
|
616
|
-
children:
|
|
619
|
+
children: o
|
|
617
620
|
}) {
|
|
618
621
|
const c = F(t());
|
|
619
|
-
return
|
|
622
|
+
return o(c);
|
|
620
623
|
}
|
|
621
624
|
function Y({
|
|
622
625
|
getData: t,
|
|
623
|
-
children:
|
|
626
|
+
children: o
|
|
624
627
|
}) {
|
|
625
628
|
const c = z(t());
|
|
626
|
-
return
|
|
629
|
+
return o(c);
|
|
627
630
|
}
|
|
628
631
|
function Z({
|
|
629
632
|
getData: t,
|
|
630
|
-
children:
|
|
633
|
+
children: o
|
|
631
634
|
}) {
|
|
632
635
|
const c = G(t());
|
|
633
|
-
return
|
|
636
|
+
return o(c);
|
|
634
637
|
}
|
|
635
638
|
function $({
|
|
636
639
|
getData: t,
|
|
637
|
-
children:
|
|
640
|
+
children: o
|
|
638
641
|
}) {
|
|
639
642
|
const c = W(t());
|
|
640
|
-
return
|
|
643
|
+
return o(c);
|
|
641
644
|
}
|
|
642
645
|
function K({
|
|
643
646
|
getData: t,
|
|
644
|
-
children:
|
|
647
|
+
children: o
|
|
645
648
|
}) {
|
|
646
649
|
const c = H(t());
|
|
647
|
-
return
|
|
650
|
+
return o(c);
|
|
651
|
+
}
|
|
652
|
+
function q({
|
|
653
|
+
getData: t,
|
|
654
|
+
children: o
|
|
655
|
+
}) {
|
|
656
|
+
const c = N(t());
|
|
657
|
+
return o(c);
|
|
648
658
|
}
|
|
649
659
|
export {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
W as
|
|
664
|
-
|
|
665
|
-
|
|
660
|
+
X as DragDropQuestion,
|
|
661
|
+
$ as FillInBlankQuestion,
|
|
662
|
+
K as GroupingQuestion,
|
|
663
|
+
Z as LabelingQuestion,
|
|
664
|
+
J as MatchingQuestion,
|
|
665
|
+
U as MultipleChoicesQuestion,
|
|
666
|
+
Y as OrderingQuestion,
|
|
667
|
+
q as PowerpointQuestion,
|
|
668
|
+
R as VideoQuestion,
|
|
669
|
+
j as isSameSet,
|
|
670
|
+
D as shuffleArray,
|
|
671
|
+
M as useBaseQuestion,
|
|
672
|
+
F as useDragDrop,
|
|
673
|
+
W as useFillInBlank,
|
|
674
|
+
H as useGrouping,
|
|
675
|
+
G as useLabeling,
|
|
676
|
+
V as useMatching,
|
|
666
677
|
E as useMultipleChoice,
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
678
|
+
z as useOrdering,
|
|
679
|
+
N as usePowerpoint,
|
|
680
|
+
T as useVideo
|
|
670
681
|
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,WAajD"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,WAajD;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAO/C"}
|