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