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