@enspiredigital/xlms-headless 0.0.31 → 0.0.32
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/index.js
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { jsx as
|
|
3
|
-
function
|
|
4
|
-
const [t,
|
|
5
|
-
function
|
|
6
|
-
|
|
1
|
+
import { useState as C, useRef as j, useEffect as D, useMemo as F, useCallback as B } from "react";
|
|
2
|
+
import { jsx as G, Fragment as $ } from "react/jsx-runtime";
|
|
3
|
+
function L() {
|
|
4
|
+
const [t, s] = C(null), [i, d] = C(null), [g, S] = C(0);
|
|
5
|
+
function x(f) {
|
|
6
|
+
s(!0), f !== void 0 && d(f), S((w) => w + 1);
|
|
7
7
|
}
|
|
8
8
|
function o() {
|
|
9
|
-
|
|
9
|
+
s(!1), d(null);
|
|
10
10
|
}
|
|
11
11
|
return {
|
|
12
12
|
// state
|
|
13
13
|
submitted: t,
|
|
14
|
-
isCorrect:
|
|
15
|
-
attempts:
|
|
14
|
+
isCorrect: i,
|
|
15
|
+
attempts: g,
|
|
16
16
|
// derived
|
|
17
17
|
canAnswer: !t,
|
|
18
18
|
// actions
|
|
19
|
-
submitQuestion:
|
|
19
|
+
submitQuestion: x,
|
|
20
20
|
resetQuestion: o
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function J(t,
|
|
24
|
-
if (t.length !==
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
for (const
|
|
28
|
-
if (!
|
|
23
|
+
function J(t, s) {
|
|
24
|
+
if (t.length !== s.length) return !1;
|
|
25
|
+
const i = new Set(t), d = new Set(s);
|
|
26
|
+
if (i.size !== d.size) return !1;
|
|
27
|
+
for (const g of i)
|
|
28
|
+
if (!d.has(g)) return !1;
|
|
29
29
|
return !0;
|
|
30
30
|
}
|
|
31
31
|
function V(t) {
|
|
32
|
-
const
|
|
33
|
-
for (let
|
|
34
|
-
const
|
|
35
|
-
[
|
|
32
|
+
const s = [...t];
|
|
33
|
+
for (let i = s.length - 1; i > 0; i--) {
|
|
34
|
+
const d = Math.floor(Math.random() * (i + 1));
|
|
35
|
+
[s[i], s[d]] = [s[d], s[i]];
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return s;
|
|
38
38
|
}
|
|
39
39
|
function X(t) {
|
|
40
40
|
const {
|
|
41
|
-
canAnswer:
|
|
42
|
-
submitted:
|
|
43
|
-
isCorrect:
|
|
44
|
-
attempts:
|
|
45
|
-
resetQuestion:
|
|
46
|
-
submitQuestion:
|
|
47
|
-
} =
|
|
48
|
-
function b
|
|
49
|
-
|
|
41
|
+
canAnswer: s,
|
|
42
|
+
submitted: i,
|
|
43
|
+
isCorrect: d,
|
|
44
|
+
attempts: g,
|
|
45
|
+
resetQuestion: S,
|
|
46
|
+
submitQuestion: x
|
|
47
|
+
} = L(), [o, f] = C([]);
|
|
48
|
+
function w(b) {
|
|
49
|
+
f((m) => t.options.allowMultipleAnswers ? m.includes(b) ? m.filter((p) => p !== b) : [...m, b] : [b]);
|
|
50
50
|
}
|
|
51
51
|
function I() {
|
|
52
52
|
if (o.length === 0) return;
|
|
53
|
-
const
|
|
54
|
-
(
|
|
53
|
+
const b = t.options.answers.reduce(
|
|
54
|
+
(p, A) => (A.is_correct && p.push(A.id), p),
|
|
55
55
|
[]
|
|
56
|
-
),
|
|
57
|
-
|
|
56
|
+
), m = J(o, b);
|
|
57
|
+
x(m);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
59
|
+
function k() {
|
|
60
|
+
f([]), S();
|
|
61
61
|
}
|
|
62
62
|
return {
|
|
63
63
|
// data
|
|
64
64
|
question: t,
|
|
65
65
|
selectedIds: o,
|
|
66
66
|
// actions
|
|
67
|
-
select:
|
|
67
|
+
select: w,
|
|
68
68
|
submit: I,
|
|
69
|
-
reset:
|
|
69
|
+
reset: k,
|
|
70
70
|
// base
|
|
71
|
-
submitted:
|
|
72
|
-
isCorrect:
|
|
73
|
-
attempts:
|
|
74
|
-
canAnswer:
|
|
71
|
+
submitted: i,
|
|
72
|
+
isCorrect: d,
|
|
73
|
+
attempts: g,
|
|
74
|
+
canAnswer: s
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
function Y(t) {
|
|
78
78
|
const {
|
|
79
|
-
canAnswer:
|
|
80
|
-
submitted:
|
|
81
|
-
isCorrect:
|
|
82
|
-
attempts:
|
|
83
|
-
submitQuestion:
|
|
84
|
-
resetQuestion:
|
|
85
|
-
} =
|
|
79
|
+
canAnswer: s,
|
|
80
|
+
submitted: i,
|
|
81
|
+
isCorrect: d,
|
|
82
|
+
attempts: g,
|
|
83
|
+
submitQuestion: S,
|
|
84
|
+
resetQuestion: x
|
|
85
|
+
} = L(), [o, f] = C([]), [w, I] = C(
|
|
86
86
|
[]
|
|
87
|
-
), [
|
|
87
|
+
), [k, b] = C(
|
|
88
88
|
[]
|
|
89
|
-
),
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
...
|
|
93
|
-
(
|
|
89
|
+
), m = j([]);
|
|
90
|
+
function p(n, e) {
|
|
91
|
+
f((r) => [
|
|
92
|
+
...r.filter(
|
|
93
|
+
(l) => l.targetId !== n && l.sourceId !== e
|
|
94
94
|
),
|
|
95
|
-
{ targetId:
|
|
95
|
+
{ targetId: n, sourceId: e }
|
|
96
96
|
]);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
(
|
|
98
|
+
function A(n, e) {
|
|
99
|
+
f(
|
|
100
|
+
(r) => r.filter((l) => l.targetId !== n || l.sourceId !== e)
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
function h() {
|
|
104
|
-
let
|
|
105
|
-
return t.options.targets.forEach((
|
|
106
|
-
const
|
|
107
|
-
|
|
104
|
+
let n = 0, e = !0;
|
|
105
|
+
return t.options.targets.forEach((r) => {
|
|
106
|
+
const l = o.find((Q) => Q.targetId === r.id), v = t.options.sources[r.content.correct_position - 1];
|
|
107
|
+
l && v && l.sourceId === v.id ? n += r.content.point : e = !1;
|
|
108
108
|
}), {
|
|
109
|
-
isCorrect:
|
|
110
|
-
score:
|
|
109
|
+
isCorrect: e,
|
|
110
|
+
score: n,
|
|
111
111
|
maxScore: t.options.targets.reduce(
|
|
112
|
-
(
|
|
112
|
+
(r, l) => r + l.content.point,
|
|
113
113
|
0
|
|
114
114
|
)
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
return
|
|
117
|
+
function u() {
|
|
118
|
+
const n = h();
|
|
119
|
+
return S(n.isCorrect), n;
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
121
|
+
function c() {
|
|
122
|
+
f([]), x();
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
const
|
|
126
|
-
return t.options.targets.find((
|
|
124
|
+
function a(n) {
|
|
125
|
+
const e = o.find((r) => r.sourceId === n)?.targetId;
|
|
126
|
+
return t.options.targets.find((r) => r.id === e);
|
|
127
127
|
}
|
|
128
128
|
return D(() => {
|
|
129
|
-
const
|
|
130
|
-
(
|
|
129
|
+
const n = t.options.sources.filter(
|
|
130
|
+
(e) => !o.some((r) => r.sourceId === e.id)
|
|
131
131
|
);
|
|
132
|
-
I(
|
|
132
|
+
I(n);
|
|
133
133
|
}, [o, t.options.sources]), D(() => {
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
(
|
|
134
|
+
if (m.current.length === 0) return;
|
|
135
|
+
const n = m.current.filter(
|
|
136
|
+
(e) => !o.some((r) => r.targetId === e.id)
|
|
137
137
|
);
|
|
138
|
-
|
|
138
|
+
b(n);
|
|
139
139
|
}, [o]), D(() => {
|
|
140
|
-
|
|
140
|
+
m.current = V(t.options.targets);
|
|
141
141
|
}, [t.options.targets]), {
|
|
142
142
|
// data
|
|
143
143
|
sources: t.options.sources,
|
|
144
144
|
targets: t.options.targets,
|
|
145
145
|
answers: o,
|
|
146
146
|
question: t,
|
|
147
|
-
availableSources:
|
|
148
|
-
availableTargets:
|
|
147
|
+
availableSources: w,
|
|
148
|
+
availableTargets: k,
|
|
149
149
|
// base
|
|
150
|
-
submitted:
|
|
151
|
-
isCorrect:
|
|
152
|
-
attempts:
|
|
153
|
-
canAnswer:
|
|
150
|
+
submitted: i,
|
|
151
|
+
isCorrect: d,
|
|
152
|
+
attempts: g,
|
|
153
|
+
canAnswer: s,
|
|
154
154
|
// actions
|
|
155
|
-
getTargetBySourceId:
|
|
156
|
-
select:
|
|
157
|
-
remove:
|
|
158
|
-
submit:
|
|
159
|
-
reset:
|
|
155
|
+
getTargetBySourceId: a,
|
|
156
|
+
select: p,
|
|
157
|
+
remove: A,
|
|
158
|
+
submit: u,
|
|
159
|
+
reset: c
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
function Z(t) {
|
|
163
163
|
const {
|
|
164
|
-
canAnswer:
|
|
165
|
-
submitted:
|
|
166
|
-
isCorrect:
|
|
167
|
-
attempts:
|
|
168
|
-
resetQuestion:
|
|
169
|
-
submitQuestion:
|
|
170
|
-
} =
|
|
164
|
+
canAnswer: s,
|
|
165
|
+
submitted: i,
|
|
166
|
+
isCorrect: d,
|
|
167
|
+
attempts: g,
|
|
168
|
+
resetQuestion: S,
|
|
169
|
+
submitQuestion: x
|
|
170
|
+
} = L();
|
|
171
171
|
function o() {
|
|
172
|
-
|
|
172
|
+
x(!0);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
174
|
+
function f() {
|
|
175
|
+
S();
|
|
176
176
|
}
|
|
177
177
|
return {
|
|
178
178
|
// data
|
|
@@ -181,33 +181,30 @@ function Z(t) {
|
|
|
181
181
|
type: t.options.urlType,
|
|
182
182
|
// actions
|
|
183
183
|
submit: o,
|
|
184
|
-
reset:
|
|
184
|
+
reset: f,
|
|
185
185
|
// base
|
|
186
|
-
submitted:
|
|
187
|
-
isCorrect:
|
|
188
|
-
attempts:
|
|
189
|
-
canAnswer:
|
|
186
|
+
submitted: i,
|
|
187
|
+
isCorrect: d,
|
|
188
|
+
attempts: g,
|
|
189
|
+
canAnswer: s
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
function K(t) {
|
|
193
193
|
const {
|
|
194
|
-
canAnswer:
|
|
195
|
-
submitted:
|
|
196
|
-
isCorrect:
|
|
197
|
-
attempts:
|
|
198
|
-
submitQuestion:
|
|
199
|
-
resetQuestion:
|
|
200
|
-
} =
|
|
201
|
-
if (Q.current.length === 0) return;
|
|
194
|
+
canAnswer: s,
|
|
195
|
+
submitted: i,
|
|
196
|
+
isCorrect: d,
|
|
197
|
+
attempts: g,
|
|
198
|
+
submitQuestion: S,
|
|
199
|
+
resetQuestion: x
|
|
200
|
+
} = L(), [o, f] = C([]), [w, I] = C(null), [k, b] = C([]), m = F(() => {
|
|
202
201
|
const e = new Set(o.map((r) => r.itemId));
|
|
203
|
-
return
|
|
204
|
-
|
|
205
|
-
);
|
|
206
|
-
}, [o]);
|
|
202
|
+
return k.filter((r) => !e.has(String(r.id)));
|
|
203
|
+
}, [o, k]);
|
|
207
204
|
function p(e, r) {
|
|
208
|
-
|
|
209
|
-
...
|
|
210
|
-
(
|
|
205
|
+
f((l) => [
|
|
206
|
+
...l.filter(
|
|
207
|
+
(Q) => Q.blankIndex !== r && Q.itemId !== e
|
|
211
208
|
),
|
|
212
209
|
{
|
|
213
210
|
itemId: e,
|
|
@@ -215,213 +212,212 @@ function K(t) {
|
|
|
215
212
|
}
|
|
216
213
|
]);
|
|
217
214
|
}
|
|
218
|
-
function
|
|
219
|
-
|
|
215
|
+
function A(e) {
|
|
216
|
+
f((r) => r.filter((l) => l.itemId !== e));
|
|
220
217
|
}
|
|
221
|
-
function
|
|
218
|
+
function h(e, r) {
|
|
222
219
|
p(e, r);
|
|
223
220
|
}
|
|
224
|
-
function
|
|
225
|
-
let e = 0, r = !0,
|
|
226
|
-
const
|
|
227
|
-
return Object.entries(
|
|
228
|
-
const _ =
|
|
221
|
+
function u() {
|
|
222
|
+
let e = 0, r = !0, l = 0;
|
|
223
|
+
const v = t.correct_answers.list, Q = new Map(o.map((R) => [R.blankIndex, R.itemId]));
|
|
224
|
+
return Object.entries(v).forEach(([R, M]) => {
|
|
225
|
+
const _ = R, T = Q.get(_);
|
|
229
226
|
if (!T) {
|
|
230
227
|
r = !1;
|
|
231
228
|
return;
|
|
232
229
|
}
|
|
233
|
-
const
|
|
234
|
-
|
|
230
|
+
const E = t.options.answers.find((z) => z.id === T);
|
|
231
|
+
E && String(E.group_position) === String(M) ? (e++, l += E.point) : r = !1;
|
|
235
232
|
}), {
|
|
236
233
|
isCorrect: r,
|
|
237
234
|
correctCount: e,
|
|
238
|
-
totalCount: Object.keys(
|
|
235
|
+
totalCount: Object.keys(v).length,
|
|
239
236
|
maxScore: t.metadata.points,
|
|
240
|
-
score:
|
|
237
|
+
score: l
|
|
241
238
|
};
|
|
242
239
|
}
|
|
243
|
-
function
|
|
244
|
-
const e =
|
|
245
|
-
return
|
|
240
|
+
function c() {
|
|
241
|
+
const e = u();
|
|
242
|
+
return S(e.isCorrect), e;
|
|
246
243
|
}
|
|
247
244
|
function a() {
|
|
248
|
-
|
|
245
|
+
f([]), x();
|
|
249
246
|
}
|
|
250
|
-
function
|
|
251
|
-
const r = o.find((
|
|
252
|
-
return t.options.answers.find((
|
|
247
|
+
function n(e) {
|
|
248
|
+
const r = o.find((l) => l.blankIndex === e)?.itemId;
|
|
249
|
+
return t.options.answers.find((l) => l.id === r);
|
|
253
250
|
}
|
|
254
251
|
return D(() => {
|
|
255
|
-
|
|
252
|
+
b(V(t.options.answers));
|
|
256
253
|
}, [t.options.answers]), {
|
|
257
254
|
// data
|
|
258
255
|
items: t.options.answers,
|
|
259
256
|
groups: t.options.groups,
|
|
260
257
|
answers: o,
|
|
261
|
-
availableItems:
|
|
258
|
+
availableItems: m,
|
|
262
259
|
question: t,
|
|
263
|
-
draggingItemId:
|
|
260
|
+
draggingItemId: w,
|
|
264
261
|
// base
|
|
265
|
-
submitted:
|
|
266
|
-
isCorrect:
|
|
267
|
-
attempts:
|
|
268
|
-
canAnswer:
|
|
262
|
+
submitted: i,
|
|
263
|
+
isCorrect: d,
|
|
264
|
+
attempts: g,
|
|
265
|
+
canAnswer: s,
|
|
269
266
|
// actions
|
|
270
267
|
dropItem: p,
|
|
271
|
-
removeItem:
|
|
272
|
-
moveItem:
|
|
268
|
+
removeItem: A,
|
|
269
|
+
moveItem: h,
|
|
273
270
|
setDraggingItemId: I,
|
|
274
|
-
getItemByBlankId:
|
|
275
|
-
submit:
|
|
271
|
+
getItemByBlankId: n,
|
|
272
|
+
submit: c,
|
|
276
273
|
reset: a
|
|
277
274
|
};
|
|
278
275
|
}
|
|
279
276
|
function H(t) {
|
|
280
277
|
const {
|
|
281
|
-
canAnswer:
|
|
282
|
-
submitted:
|
|
283
|
-
isCorrect:
|
|
284
|
-
attempts:
|
|
285
|
-
submitQuestion:
|
|
286
|
-
resetQuestion:
|
|
287
|
-
} =
|
|
288
|
-
t.options.answers.map((
|
|
289
|
-
)),
|
|
290
|
-
(
|
|
291
|
-
).filter((
|
|
292
|
-
function I(
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
return
|
|
278
|
+
canAnswer: s,
|
|
279
|
+
submitted: i,
|
|
280
|
+
isCorrect: d,
|
|
281
|
+
attempts: g,
|
|
282
|
+
submitQuestion: S,
|
|
283
|
+
resetQuestion: x
|
|
284
|
+
} = L(), [o, f] = C(() => V(
|
|
285
|
+
t.options.answers.map((u) => String(u.id))
|
|
286
|
+
)), w = F(() => o.map(
|
|
287
|
+
(u) => t.options.answers.find((c) => String(c.id) === u)
|
|
288
|
+
).filter((u) => u !== void 0), [o, t.options.answers]);
|
|
289
|
+
function I(u, c) {
|
|
290
|
+
f((a) => {
|
|
291
|
+
const n = [...a], [e] = n.splice(u, 1);
|
|
292
|
+
return n.splice(c, 0, e), n;
|
|
296
293
|
});
|
|
297
294
|
}
|
|
298
|
-
function
|
|
299
|
-
const
|
|
300
|
-
|
|
295
|
+
function k(u) {
|
|
296
|
+
const c = o.indexOf(u);
|
|
297
|
+
c > 0 && I(c, c - 1);
|
|
301
298
|
}
|
|
302
|
-
function
|
|
303
|
-
const
|
|
304
|
-
|
|
299
|
+
function b(u) {
|
|
300
|
+
const c = o.indexOf(u);
|
|
301
|
+
c < o.length - 1 && I(c, c + 1);
|
|
305
302
|
}
|
|
306
|
-
function
|
|
307
|
-
const
|
|
308
|
-
|
|
303
|
+
function m(u, c) {
|
|
304
|
+
const a = o.indexOf(u);
|
|
305
|
+
a !== -1 && c >= 0 && c < o.length && I(a, c);
|
|
309
306
|
}
|
|
310
|
-
function
|
|
311
|
-
let
|
|
312
|
-
return t.options.answers.forEach((
|
|
313
|
-
const
|
|
314
|
-
|
|
307
|
+
function p() {
|
|
308
|
+
let u = 0, c = !0;
|
|
309
|
+
return t.options.answers.forEach((a, n) => {
|
|
310
|
+
const e = o.indexOf(String(a.id));
|
|
311
|
+
e !== -1 && e + 1 === a.correct_position ? u += a.point : c = !1;
|
|
315
312
|
}), {
|
|
316
|
-
isCorrect:
|
|
317
|
-
score:
|
|
313
|
+
isCorrect: c,
|
|
314
|
+
score: u,
|
|
318
315
|
maxScore: t.options.answers.reduce(
|
|
319
|
-
(
|
|
316
|
+
(a, n) => a + n.point,
|
|
320
317
|
0
|
|
321
318
|
)
|
|
322
319
|
};
|
|
323
320
|
}
|
|
324
|
-
function
|
|
325
|
-
const
|
|
326
|
-
return
|
|
321
|
+
function A() {
|
|
322
|
+
const u = p();
|
|
323
|
+
return S(u.isCorrect), u;
|
|
327
324
|
}
|
|
328
325
|
function h() {
|
|
329
|
-
|
|
326
|
+
f(t.options.answers.map((u) => String(u.id))), x();
|
|
330
327
|
}
|
|
331
328
|
return {
|
|
332
329
|
// data
|
|
333
330
|
items: t.options.answers,
|
|
334
331
|
groups: t.options.groups,
|
|
335
|
-
orderedItems:
|
|
332
|
+
orderedItems: w,
|
|
336
333
|
orderedItemIds: o,
|
|
337
334
|
question: t,
|
|
338
335
|
// base
|
|
339
|
-
submitted:
|
|
340
|
-
isCorrect:
|
|
341
|
-
attempts:
|
|
342
|
-
canAnswer:
|
|
336
|
+
submitted: i,
|
|
337
|
+
isCorrect: d,
|
|
338
|
+
attempts: g,
|
|
339
|
+
canAnswer: s,
|
|
343
340
|
// actions
|
|
344
|
-
setOrderedItemIds:
|
|
341
|
+
setOrderedItemIds: f,
|
|
345
342
|
moveItem: I,
|
|
346
|
-
moveUp:
|
|
347
|
-
moveDown:
|
|
348
|
-
moveToPosition:
|
|
349
|
-
submit:
|
|
343
|
+
moveUp: k,
|
|
344
|
+
moveDown: b,
|
|
345
|
+
moveToPosition: m,
|
|
346
|
+
submit: A,
|
|
350
347
|
reset: h
|
|
351
348
|
};
|
|
352
349
|
}
|
|
353
350
|
function q(t) {
|
|
354
351
|
const {
|
|
355
|
-
canAnswer:
|
|
356
|
-
submitted:
|
|
357
|
-
isCorrect:
|
|
358
|
-
attempts:
|
|
359
|
-
submitQuestion:
|
|
360
|
-
resetQuestion:
|
|
361
|
-
} =
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
(e) => !i.has(String(e.id))
|
|
352
|
+
canAnswer: s,
|
|
353
|
+
submitted: i,
|
|
354
|
+
isCorrect: d,
|
|
355
|
+
attempts: g,
|
|
356
|
+
submitQuestion: S,
|
|
357
|
+
resetQuestion: x
|
|
358
|
+
} = L(), [o, f] = C([]), [w, I] = C([]), k = F(() => {
|
|
359
|
+
const n = new Set(o.map((e) => e.labelId));
|
|
360
|
+
return w.filter(
|
|
361
|
+
(e) => !n.has(String(e.id))
|
|
366
362
|
);
|
|
367
|
-
}, [o]);
|
|
368
|
-
function
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
...
|
|
372
|
-
(
|
|
363
|
+
}, [o, w]);
|
|
364
|
+
function b(n, e, r, l) {
|
|
365
|
+
const v = t.options.blanks.find((Q) => String(Q.id) === e);
|
|
366
|
+
v && f((Q) => [
|
|
367
|
+
...Q.filter(
|
|
368
|
+
(M) => M.labelId !== n && M.blankId !== e
|
|
373
369
|
),
|
|
374
370
|
{
|
|
375
|
-
labelId:
|
|
371
|
+
labelId: n,
|
|
376
372
|
blankId: e,
|
|
377
|
-
x: r ??
|
|
378
|
-
y:
|
|
373
|
+
x: r ?? v.coordinates.x,
|
|
374
|
+
y: l ?? v.coordinates.y
|
|
379
375
|
}
|
|
380
376
|
]);
|
|
381
377
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
378
|
+
function m(n) {
|
|
379
|
+
f((e) => e.filter((r) => r.labelId !== n));
|
|
384
380
|
}
|
|
385
|
-
function p(
|
|
386
|
-
|
|
381
|
+
function p(n, e, r, l) {
|
|
382
|
+
b(n, e, r, l);
|
|
387
383
|
}
|
|
388
|
-
function
|
|
389
|
-
const e = o.find((r) => r.blankId ===
|
|
384
|
+
function A(n) {
|
|
385
|
+
const e = o.find((r) => r.blankId === n);
|
|
390
386
|
return e && t.options.labels.find(
|
|
391
387
|
(r) => String(r.id) === e.labelId
|
|
392
388
|
) || null;
|
|
393
389
|
}
|
|
394
|
-
function
|
|
395
|
-
const e = o.find((r) => r.labelId ===
|
|
390
|
+
function h(n) {
|
|
391
|
+
const e = o.find((r) => r.labelId === n);
|
|
396
392
|
return e ? e.blankId : null;
|
|
397
393
|
}
|
|
398
|
-
function
|
|
399
|
-
let
|
|
394
|
+
function u() {
|
|
395
|
+
let n = 0, e = !0;
|
|
400
396
|
return t.options.labels.forEach((r) => {
|
|
401
|
-
const
|
|
402
|
-
(
|
|
403
|
-
),
|
|
404
|
-
(
|
|
397
|
+
const l = o.find(
|
|
398
|
+
(Q) => String(Q.labelId) === String(r.id)
|
|
399
|
+
), v = t.options.blanks.find(
|
|
400
|
+
(Q, R) => R + 1 === r.correct_position
|
|
405
401
|
);
|
|
406
|
-
|
|
402
|
+
l && v && l.blankId === String(v.id) ? n += r.point : e = !1;
|
|
407
403
|
}), {
|
|
408
404
|
isCorrect: e,
|
|
409
|
-
score:
|
|
405
|
+
score: n,
|
|
410
406
|
maxScore: t.options.labels.reduce(
|
|
411
|
-
(r,
|
|
407
|
+
(r, l) => r + l.point,
|
|
412
408
|
0
|
|
413
409
|
)
|
|
414
410
|
};
|
|
415
411
|
}
|
|
416
|
-
function
|
|
417
|
-
const
|
|
418
|
-
return
|
|
412
|
+
function c() {
|
|
413
|
+
const n = u();
|
|
414
|
+
return S(n.isCorrect), n;
|
|
419
415
|
}
|
|
420
416
|
function a() {
|
|
421
|
-
|
|
417
|
+
f([]), x();
|
|
422
418
|
}
|
|
423
419
|
return D(() => {
|
|
424
|
-
|
|
420
|
+
I(V(t.options.labels));
|
|
425
421
|
}, [t.options.labels]), {
|
|
426
422
|
// data
|
|
427
423
|
labels: t.options.labels,
|
|
@@ -430,66 +426,66 @@ function q(t) {
|
|
|
430
426
|
imageWidth: t.image_width,
|
|
431
427
|
imageHeight: t.image_height,
|
|
432
428
|
answers: o,
|
|
433
|
-
availableLabels:
|
|
429
|
+
availableLabels: k,
|
|
434
430
|
question: t,
|
|
435
431
|
// base
|
|
436
|
-
submitted:
|
|
437
|
-
isCorrect:
|
|
438
|
-
attempts:
|
|
439
|
-
canAnswer:
|
|
432
|
+
submitted: i,
|
|
433
|
+
isCorrect: d,
|
|
434
|
+
attempts: g,
|
|
435
|
+
canAnswer: s,
|
|
440
436
|
// actions
|
|
441
|
-
attachLabel:
|
|
442
|
-
removeLabel:
|
|
437
|
+
attachLabel: b,
|
|
438
|
+
removeLabel: m,
|
|
443
439
|
moveLabel: p,
|
|
444
|
-
getLabelAtBlank:
|
|
445
|
-
getBlankForLabel:
|
|
446
|
-
submit:
|
|
440
|
+
getLabelAtBlank: A,
|
|
441
|
+
getBlankForLabel: h,
|
|
442
|
+
submit: c,
|
|
447
443
|
reset: a
|
|
448
444
|
};
|
|
449
445
|
}
|
|
450
446
|
function tt(t) {
|
|
451
447
|
const {
|
|
452
|
-
canAnswer:
|
|
453
|
-
submitted:
|
|
454
|
-
isCorrect:
|
|
455
|
-
attempts:
|
|
456
|
-
submitQuestion:
|
|
457
|
-
resetQuestion:
|
|
458
|
-
} =
|
|
459
|
-
function
|
|
460
|
-
|
|
461
|
-
const h =
|
|
448
|
+
canAnswer: s,
|
|
449
|
+
submitted: i,
|
|
450
|
+
isCorrect: d,
|
|
451
|
+
attempts: g,
|
|
452
|
+
submitQuestion: S,
|
|
453
|
+
resetQuestion: x
|
|
454
|
+
} = L(), [o, f] = C([]);
|
|
455
|
+
function w(m, p) {
|
|
456
|
+
f((A) => {
|
|
457
|
+
const h = A.findIndex((u) => u.blankId === m);
|
|
462
458
|
if (h >= 0) {
|
|
463
|
-
const
|
|
464
|
-
return
|
|
459
|
+
const u = [...A];
|
|
460
|
+
return u[h] = { blankId: m, value: p }, u;
|
|
465
461
|
}
|
|
466
|
-
return [...
|
|
462
|
+
return [...A, { blankId: m, value: p }];
|
|
467
463
|
});
|
|
468
464
|
}
|
|
469
465
|
function I() {
|
|
470
|
-
let
|
|
471
|
-
const h = t.correct_answers.list || {},
|
|
472
|
-
Object.entries(h).forEach(([
|
|
473
|
-
const
|
|
474
|
-
(
|
|
475
|
-
),
|
|
476
|
-
|
|
477
|
-
const v = o.find((
|
|
478
|
-
(v ? String(v.value).trim().toLowerCase() : "") ===
|
|
466
|
+
let m = 0, p = 0, A = 0;
|
|
467
|
+
const h = t.correct_answers.list || {}, u = Object.keys(h).length;
|
|
468
|
+
Object.entries(h).forEach(([a, n]) => {
|
|
469
|
+
const e = String(n).trim().toLowerCase(), r = t.options.answers.find(
|
|
470
|
+
(R) => R.correct_position === Number(a)
|
|
471
|
+
), l = r && r.point || 1;
|
|
472
|
+
A += l;
|
|
473
|
+
const v = o.find((R) => R.blankId === a);
|
|
474
|
+
(v ? String(v.value).trim().toLowerCase() : "") === e && (m += l, p++);
|
|
479
475
|
});
|
|
480
|
-
const
|
|
481
|
-
return
|
|
482
|
-
isCorrect:
|
|
483
|
-
score: Math.round(
|
|
484
|
-
maxScore: Math.round(
|
|
476
|
+
const c = p === u && u > 0;
|
|
477
|
+
return A === 0 && u > 0 && (A = u), {
|
|
478
|
+
isCorrect: c,
|
|
479
|
+
score: Math.round(m * 100) / 100,
|
|
480
|
+
maxScore: Math.round(A * 100) / 100
|
|
485
481
|
};
|
|
486
482
|
}
|
|
487
|
-
function
|
|
488
|
-
const
|
|
489
|
-
return
|
|
483
|
+
function k() {
|
|
484
|
+
const m = I();
|
|
485
|
+
return S(m.isCorrect), m;
|
|
490
486
|
}
|
|
491
|
-
function
|
|
492
|
-
|
|
487
|
+
function b() {
|
|
488
|
+
f([]), x();
|
|
493
489
|
}
|
|
494
490
|
return {
|
|
495
491
|
// data
|
|
@@ -497,108 +493,108 @@ function tt(t) {
|
|
|
497
493
|
answers: o,
|
|
498
494
|
question: t,
|
|
499
495
|
// base
|
|
500
|
-
submitted:
|
|
501
|
-
isCorrect:
|
|
502
|
-
attempts:
|
|
503
|
-
canAnswer:
|
|
496
|
+
submitted: i,
|
|
497
|
+
isCorrect: d,
|
|
498
|
+
attempts: g,
|
|
499
|
+
canAnswer: s,
|
|
504
500
|
// actions
|
|
505
|
-
answer:
|
|
506
|
-
submit:
|
|
507
|
-
reset:
|
|
501
|
+
answer: w,
|
|
502
|
+
submit: k,
|
|
503
|
+
reset: b
|
|
508
504
|
};
|
|
509
505
|
}
|
|
510
506
|
function et(t) {
|
|
511
507
|
const {
|
|
512
|
-
canAnswer:
|
|
513
|
-
submitted:
|
|
514
|
-
isCorrect:
|
|
515
|
-
attempts:
|
|
516
|
-
submitQuestion:
|
|
517
|
-
resetQuestion:
|
|
518
|
-
} =
|
|
519
|
-
function
|
|
520
|
-
|
|
521
|
-
const e =
|
|
508
|
+
canAnswer: s,
|
|
509
|
+
submitted: i,
|
|
510
|
+
isCorrect: d,
|
|
511
|
+
attempts: g,
|
|
512
|
+
submitQuestion: S,
|
|
513
|
+
resetQuestion: x
|
|
514
|
+
} = L(), [o, f] = C([]), [w, I] = C([]);
|
|
515
|
+
function k(c, a) {
|
|
516
|
+
f((n) => {
|
|
517
|
+
const e = n.findIndex((r) => r.itemId === c);
|
|
522
518
|
if (e >= 0) {
|
|
523
|
-
const r = [...
|
|
524
|
-
return r[e] = { itemId:
|
|
519
|
+
const r = [...n];
|
|
520
|
+
return r[e] = { itemId: c, categoryId: a }, r;
|
|
525
521
|
}
|
|
526
|
-
return [...
|
|
522
|
+
return [...n, { itemId: c, categoryId: a }];
|
|
527
523
|
});
|
|
528
524
|
}
|
|
529
|
-
function
|
|
530
|
-
|
|
525
|
+
function b(c) {
|
|
526
|
+
f((a) => a.filter((n) => n.itemId !== c));
|
|
531
527
|
}
|
|
532
|
-
function
|
|
533
|
-
let
|
|
528
|
+
function m() {
|
|
529
|
+
let c = 0, a = 0;
|
|
534
530
|
const e = t.correct_answers.list || {}, r = Object.keys(e).length;
|
|
535
|
-
let
|
|
536
|
-
return Object.entries(e).forEach(([
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
const T = o.find((
|
|
540
|
-
T && T.categoryId ===
|
|
541
|
-
}),
|
|
531
|
+
let l = 0;
|
|
532
|
+
return Object.entries(e).forEach(([Q, R]) => {
|
|
533
|
+
const M = t.options.items.find((E) => E.id === Q), _ = M ? M.point : 0;
|
|
534
|
+
l += _;
|
|
535
|
+
const T = o.find((E) => E.itemId === Q);
|
|
536
|
+
T && T.categoryId === R && (c += _, a++);
|
|
537
|
+
}), c = Math.round(c * 100) / 100, l = Math.round(l * 100) / 100, {
|
|
542
538
|
isCorrect: a === r && r > 0,
|
|
543
|
-
score:
|
|
544
|
-
maxScore:
|
|
539
|
+
score: c,
|
|
540
|
+
maxScore: l
|
|
545
541
|
};
|
|
546
542
|
}
|
|
547
543
|
function p() {
|
|
548
|
-
const
|
|
549
|
-
return
|
|
544
|
+
const c = m();
|
|
545
|
+
return S(c.isCorrect), c;
|
|
550
546
|
}
|
|
551
|
-
function
|
|
552
|
-
|
|
547
|
+
function A() {
|
|
548
|
+
f([]), x();
|
|
553
549
|
}
|
|
554
|
-
const
|
|
555
|
-
(
|
|
556
|
-
), [o]),
|
|
557
|
-
const a = o.filter((
|
|
558
|
-
...t.options.items.find((r) => r.id ===
|
|
550
|
+
const h = F(() => w.filter(
|
|
551
|
+
(c) => !o.some((a) => a.itemId === c.id)
|
|
552
|
+
), [o, w]), u = F(() => t.options.categories.map((c) => {
|
|
553
|
+
const a = o.filter((n) => n.categoryId === c.id).map((n) => ({
|
|
554
|
+
...t.options.items.find((r) => r.id === n.itemId)
|
|
559
555
|
}));
|
|
560
556
|
return {
|
|
561
|
-
...
|
|
557
|
+
...c,
|
|
562
558
|
items: a
|
|
563
559
|
};
|
|
564
560
|
}), [t.options.categories, t.options.items, o]);
|
|
565
561
|
return D(() => {
|
|
566
|
-
|
|
562
|
+
I(V(t.options.items));
|
|
567
563
|
}, [t.options.items]), {
|
|
568
564
|
// data
|
|
569
565
|
categories: t.options.categories,
|
|
570
566
|
allItems: t.options.items,
|
|
571
567
|
question: t,
|
|
572
|
-
categoriesWithItems:
|
|
568
|
+
categoriesWithItems: u,
|
|
573
569
|
// state
|
|
574
570
|
answers: o,
|
|
575
|
-
unassignedItems:
|
|
571
|
+
unassignedItems: h,
|
|
576
572
|
// base
|
|
577
|
-
submitted:
|
|
578
|
-
isCorrect:
|
|
579
|
-
attempts:
|
|
580
|
-
canAnswer:
|
|
573
|
+
submitted: i,
|
|
574
|
+
isCorrect: d,
|
|
575
|
+
attempts: g,
|
|
576
|
+
canAnswer: s,
|
|
581
577
|
// actions
|
|
582
|
-
move:
|
|
583
|
-
remove:
|
|
578
|
+
move: k,
|
|
579
|
+
remove: b,
|
|
584
580
|
submit: p,
|
|
585
|
-
reset:
|
|
581
|
+
reset: A
|
|
586
582
|
};
|
|
587
583
|
}
|
|
588
584
|
function rt(t) {
|
|
589
585
|
const {
|
|
590
|
-
canAnswer:
|
|
591
|
-
submitted:
|
|
592
|
-
isCorrect:
|
|
593
|
-
attempts:
|
|
594
|
-
resetQuestion:
|
|
595
|
-
submitQuestion:
|
|
596
|
-
} =
|
|
586
|
+
canAnswer: s,
|
|
587
|
+
submitted: i,
|
|
588
|
+
isCorrect: d,
|
|
589
|
+
attempts: g,
|
|
590
|
+
resetQuestion: S,
|
|
591
|
+
submitQuestion: x
|
|
592
|
+
} = L();
|
|
597
593
|
function o() {
|
|
598
|
-
|
|
594
|
+
i || x(!0);
|
|
599
595
|
}
|
|
600
|
-
function
|
|
601
|
-
|
|
596
|
+
function f() {
|
|
597
|
+
S();
|
|
602
598
|
}
|
|
603
599
|
return {
|
|
604
600
|
// data
|
|
@@ -607,248 +603,248 @@ function rt(t) {
|
|
|
607
603
|
type: t.options.urlType,
|
|
608
604
|
// actions
|
|
609
605
|
submit: o,
|
|
610
|
-
reset:
|
|
606
|
+
reset: f,
|
|
611
607
|
// base
|
|
612
|
-
submitted:
|
|
613
|
-
isCorrect:
|
|
614
|
-
attempts:
|
|
615
|
-
canAnswer:
|
|
608
|
+
submitted: i,
|
|
609
|
+
isCorrect: d,
|
|
610
|
+
attempts: g,
|
|
611
|
+
canAnswer: s
|
|
616
612
|
};
|
|
617
613
|
}
|
|
618
|
-
function nt(t,
|
|
619
|
-
const { canAnswer:
|
|
620
|
-
async (
|
|
621
|
-
if (
|
|
622
|
-
|
|
614
|
+
function nt(t, s) {
|
|
615
|
+
const { canAnswer: i, submitted: d, attempts: g, submitQuestion: S, resetQuestion: x } = L(), [o, f] = C(""), [w, I] = C(void 0), [k, b] = C(!1), [m, p] = C(void 0), A = B(
|
|
616
|
+
async (n) => {
|
|
617
|
+
if (s) {
|
|
618
|
+
b(!0), p(void 0);
|
|
623
619
|
try {
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
} catch (
|
|
627
|
-
console.error("File upload failed:",
|
|
628
|
-
|
|
620
|
+
const e = await s(n, n.name);
|
|
621
|
+
e.success && e.url ? I(e.url) : p(e.error || "Upload failed");
|
|
622
|
+
} catch (e) {
|
|
623
|
+
console.error("File upload failed:", e), p(
|
|
624
|
+
e instanceof Error ? e.message : "File upload failed"
|
|
629
625
|
);
|
|
630
626
|
} finally {
|
|
631
|
-
|
|
627
|
+
b(!1);
|
|
632
628
|
}
|
|
633
629
|
}
|
|
634
630
|
},
|
|
635
|
-
[
|
|
631
|
+
[s]
|
|
636
632
|
), h = B(async () => {
|
|
637
|
-
if (!(!
|
|
638
|
-
|
|
633
|
+
if (!(!s || !o)) {
|
|
634
|
+
b(!0), p(void 0);
|
|
639
635
|
try {
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
} catch (
|
|
643
|
-
console.error("Text upload failed:",
|
|
644
|
-
|
|
636
|
+
const n = new Blob([o], { type: "text/plain; charset=utf-8" }), e = `writing-${Date.now()}.txt`, r = await s(n, e);
|
|
637
|
+
r.success && r.url ? I(r.url) : p(r.error || "Upload failed");
|
|
638
|
+
} catch (n) {
|
|
639
|
+
console.error("Text upload failed:", n), p(
|
|
640
|
+
n instanceof Error ? n.message : "Text upload failed"
|
|
645
641
|
);
|
|
646
642
|
} finally {
|
|
647
|
-
|
|
643
|
+
b(!1);
|
|
648
644
|
}
|
|
649
645
|
}
|
|
650
|
-
}, [o,
|
|
646
|
+
}, [o, s]), u = F(
|
|
651
647
|
() => ({
|
|
652
648
|
type: "writing",
|
|
653
649
|
text: o,
|
|
654
|
-
fileUrl:
|
|
650
|
+
fileUrl: w
|
|
655
651
|
}),
|
|
656
|
-
[o,
|
|
657
|
-
),
|
|
658
|
-
|
|
659
|
-
}, [
|
|
652
|
+
[o, w]
|
|
653
|
+
), c = B(() => (S(), u), [S, u]), a = B(() => {
|
|
654
|
+
f(""), I(void 0), p(void 0), x();
|
|
655
|
+
}, [x]);
|
|
660
656
|
return {
|
|
661
657
|
question: t,
|
|
662
|
-
canAnswer:
|
|
663
|
-
submitted:
|
|
664
|
-
attempts:
|
|
658
|
+
canAnswer: i,
|
|
659
|
+
submitted: d,
|
|
660
|
+
attempts: g,
|
|
665
661
|
text: o,
|
|
666
|
-
setText:
|
|
667
|
-
fileUrl:
|
|
662
|
+
setText: f,
|
|
663
|
+
fileUrl: w,
|
|
668
664
|
setFileUrl: I,
|
|
669
|
-
isUploading:
|
|
670
|
-
uploadError:
|
|
671
|
-
uploadFile:
|
|
665
|
+
isUploading: k,
|
|
666
|
+
uploadError: m,
|
|
667
|
+
uploadFile: A,
|
|
672
668
|
uploadText: h,
|
|
673
|
-
submit:
|
|
674
|
-
reset:
|
|
675
|
-
payload:
|
|
669
|
+
submit: c,
|
|
670
|
+
reset: a,
|
|
671
|
+
payload: u
|
|
676
672
|
};
|
|
677
673
|
}
|
|
678
|
-
function st(t,
|
|
679
|
-
const { canAnswer:
|
|
680
|
-
|
|
674
|
+
function st(t, s) {
|
|
675
|
+
const { canAnswer: i, submitted: d, attempts: g, submitQuestion: S, resetQuestion: x } = L(), [o, f] = C(void 0), [w, I] = C("idle"), [k, b] = C(0), [m, p] = C(!1), [A, h] = C(void 0), [u, c] = C(!1), a = j(null), n = j([]), e = j(null), r = j(null), l = B(async () => {
|
|
676
|
+
c(!0);
|
|
681
677
|
try {
|
|
682
678
|
const y = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
683
|
-
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
W.data.size > 0 &&
|
|
687
|
-
},
|
|
688
|
-
const W = new Blob(
|
|
679
|
+
r.current = y;
|
|
680
|
+
const U = new MediaRecorder(y);
|
|
681
|
+
a.current = U, n.current = [], U.ondataavailable = (W) => {
|
|
682
|
+
W.data.size > 0 && n.current.push(W.data);
|
|
683
|
+
}, U.onstop = () => {
|
|
684
|
+
const W = new Blob(n.current, {
|
|
689
685
|
type: "audio/webm"
|
|
690
686
|
}), P = URL.createObjectURL(W);
|
|
691
|
-
|
|
692
|
-
},
|
|
693
|
-
let
|
|
694
|
-
|
|
695
|
-
|
|
687
|
+
f(P);
|
|
688
|
+
}, U.start(), I("recording"), b(0);
|
|
689
|
+
let O = 0;
|
|
690
|
+
e.current = setInterval(() => {
|
|
691
|
+
O++, b(O), O >= (t.metadata?.max_recording_time || 300) && R();
|
|
696
692
|
}, 1e3);
|
|
697
693
|
} catch (y) {
|
|
698
694
|
console.error("Failed to start recording:", y), h("Failed to access microphone");
|
|
699
695
|
}
|
|
700
696
|
}, []), v = B(() => {
|
|
701
|
-
|
|
702
|
-
}, [
|
|
703
|
-
|
|
704
|
-
|
|
697
|
+
a.current && w === "recording" && (a.current.pause(), I("paused"), e.current && clearInterval(e.current));
|
|
698
|
+
}, [w]), Q = B(() => {
|
|
699
|
+
a.current && w === "paused" && (a.current.resume(), I("recording"), e.current = setInterval(() => {
|
|
700
|
+
b((y) => y + 1);
|
|
705
701
|
}, 1e3));
|
|
706
|
-
}, [
|
|
707
|
-
|
|
708
|
-
}, []),
|
|
709
|
-
|
|
710
|
-
}, [
|
|
711
|
-
if (!(!
|
|
712
|
-
|
|
702
|
+
}, [w]), R = B(() => {
|
|
703
|
+
a.current && a.current.state !== "inactive" && (a.current.stop(), c(!1), I("stopped"), e.current && clearInterval(e.current), r.current && r.current.getTracks().forEach((y) => y.stop()));
|
|
704
|
+
}, []), M = B(() => {
|
|
705
|
+
u ? R() : l();
|
|
706
|
+
}, [u, l, R]), _ = B(async () => {
|
|
707
|
+
if (!(!n.current.length || !s)) {
|
|
708
|
+
p(!0), h(void 0);
|
|
713
709
|
try {
|
|
714
|
-
const y = new Blob(
|
|
710
|
+
const y = new Blob(n.current, {
|
|
715
711
|
type: "audio/webm"
|
|
716
|
-
}),
|
|
717
|
-
|
|
712
|
+
}), U = `speaking-${Date.now()}.webm`, O = await s(y, U);
|
|
713
|
+
O.success && O.url ? f(O.url) : h(O.error || "Upload failed");
|
|
718
714
|
} catch (y) {
|
|
719
715
|
console.error("Upload failed:", y), h(y instanceof Error ? y.message : "Upload failed");
|
|
720
716
|
} finally {
|
|
721
|
-
|
|
717
|
+
p(!1);
|
|
722
718
|
}
|
|
723
719
|
}
|
|
724
|
-
}, [t,
|
|
720
|
+
}, [t, s]), T = B(
|
|
725
721
|
async (y) => {
|
|
726
|
-
if (
|
|
727
|
-
|
|
722
|
+
if (s) {
|
|
723
|
+
p(!0), h(void 0);
|
|
728
724
|
try {
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
} catch (
|
|
732
|
-
console.error("File upload failed:",
|
|
733
|
-
|
|
725
|
+
const U = await s(y, y.name);
|
|
726
|
+
U.success && U.url ? f(U.url) : h(U.error || "Upload failed");
|
|
727
|
+
} catch (U) {
|
|
728
|
+
console.error("File upload failed:", U), h(
|
|
729
|
+
U instanceof Error ? U.message : "File upload failed"
|
|
734
730
|
);
|
|
735
731
|
} finally {
|
|
736
|
-
|
|
732
|
+
p(!1);
|
|
737
733
|
}
|
|
738
734
|
}
|
|
739
735
|
},
|
|
740
|
-
[
|
|
741
|
-
),
|
|
736
|
+
[s]
|
|
737
|
+
), E = F(
|
|
742
738
|
() => ({
|
|
743
739
|
type: "speaking",
|
|
744
740
|
audioUrl: o
|
|
745
741
|
}),
|
|
746
742
|
[t, o]
|
|
747
|
-
),
|
|
748
|
-
|
|
749
|
-
}, [
|
|
743
|
+
), z = B(() => (S(), E), [S, E]), N = B(() => {
|
|
744
|
+
f(void 0), I("idle"), b(0), h(void 0), n.current = [], e.current && clearInterval(e.current), r.current && r.current.getTracks().forEach((y) => y.stop()), x();
|
|
745
|
+
}, [x]);
|
|
750
746
|
return {
|
|
751
747
|
question: t,
|
|
752
|
-
canAnswer:
|
|
753
|
-
submitted:
|
|
754
|
-
attempts:
|
|
748
|
+
canAnswer: i,
|
|
749
|
+
submitted: d,
|
|
750
|
+
attempts: g,
|
|
755
751
|
audioUrl: o,
|
|
756
|
-
recordingState:
|
|
757
|
-
recordingTime:
|
|
758
|
-
isUploading:
|
|
759
|
-
uploadError:
|
|
760
|
-
isRecording:
|
|
761
|
-
payload:
|
|
762
|
-
setAudioUrl:
|
|
763
|
-
startRecording:
|
|
752
|
+
recordingState: w,
|
|
753
|
+
recordingTime: k,
|
|
754
|
+
isUploading: m,
|
|
755
|
+
uploadError: A,
|
|
756
|
+
isRecording: u,
|
|
757
|
+
payload: E,
|
|
758
|
+
setAudioUrl: f,
|
|
759
|
+
startRecording: l,
|
|
764
760
|
pauseRecording: v,
|
|
765
|
-
resumeRecording:
|
|
766
|
-
stopRecording:
|
|
767
|
-
toggleRecording:
|
|
768
|
-
uploadAudio:
|
|
769
|
-
uploadFile:
|
|
770
|
-
submit:
|
|
761
|
+
resumeRecording: Q,
|
|
762
|
+
stopRecording: R,
|
|
763
|
+
toggleRecording: M,
|
|
764
|
+
uploadAudio: _,
|
|
765
|
+
uploadFile: T,
|
|
766
|
+
submit: z,
|
|
771
767
|
reset: N
|
|
772
768
|
};
|
|
773
769
|
}
|
|
774
770
|
function ct({
|
|
775
771
|
getData: t,
|
|
776
|
-
children:
|
|
772
|
+
children: s
|
|
777
773
|
}) {
|
|
778
|
-
const
|
|
779
|
-
return
|
|
774
|
+
const i = X(t());
|
|
775
|
+
return s(i);
|
|
780
776
|
}
|
|
781
777
|
function ut({
|
|
782
778
|
getData: t,
|
|
783
|
-
children:
|
|
779
|
+
children: s
|
|
784
780
|
}) {
|
|
785
|
-
const
|
|
786
|
-
return
|
|
781
|
+
const i = Y(t());
|
|
782
|
+
return s(i);
|
|
787
783
|
}
|
|
788
784
|
function at({
|
|
789
785
|
getData: t,
|
|
790
|
-
children:
|
|
786
|
+
children: s
|
|
791
787
|
}) {
|
|
792
|
-
const
|
|
793
|
-
return
|
|
788
|
+
const i = Z(t());
|
|
789
|
+
return s(i);
|
|
794
790
|
}
|
|
795
791
|
function lt({
|
|
796
792
|
getData: t,
|
|
797
|
-
children:
|
|
793
|
+
children: s
|
|
798
794
|
}) {
|
|
799
|
-
const
|
|
800
|
-
return
|
|
795
|
+
const i = K(t());
|
|
796
|
+
return s(i);
|
|
801
797
|
}
|
|
802
798
|
function ft({
|
|
803
799
|
getData: t,
|
|
804
|
-
children:
|
|
800
|
+
children: s
|
|
805
801
|
}) {
|
|
806
|
-
const
|
|
807
|
-
return
|
|
802
|
+
const i = H(t());
|
|
803
|
+
return s(i);
|
|
808
804
|
}
|
|
809
805
|
function dt({
|
|
810
806
|
getData: t,
|
|
811
|
-
children:
|
|
807
|
+
children: s
|
|
812
808
|
}) {
|
|
813
|
-
const
|
|
814
|
-
return
|
|
809
|
+
const i = q(t());
|
|
810
|
+
return s(i);
|
|
815
811
|
}
|
|
816
812
|
function pt({
|
|
817
813
|
getData: t,
|
|
818
|
-
children:
|
|
814
|
+
children: s
|
|
819
815
|
}) {
|
|
820
|
-
const
|
|
821
|
-
return
|
|
816
|
+
const i = tt(t());
|
|
817
|
+
return s(i);
|
|
822
818
|
}
|
|
823
819
|
function mt({
|
|
824
820
|
getData: t,
|
|
825
|
-
children:
|
|
821
|
+
children: s
|
|
826
822
|
}) {
|
|
827
|
-
const
|
|
828
|
-
return
|
|
823
|
+
const i = et(t());
|
|
824
|
+
return s(i);
|
|
829
825
|
}
|
|
830
826
|
function gt({
|
|
831
827
|
getData: t,
|
|
832
|
-
children:
|
|
828
|
+
children: s
|
|
833
829
|
}) {
|
|
834
|
-
const
|
|
835
|
-
return
|
|
830
|
+
const i = rt(t());
|
|
831
|
+
return s(i);
|
|
836
832
|
}
|
|
837
833
|
function bt({
|
|
838
834
|
getData: t,
|
|
839
|
-
children:
|
|
840
|
-
uploadHandler:
|
|
835
|
+
children: s,
|
|
836
|
+
uploadHandler: i
|
|
841
837
|
}) {
|
|
842
|
-
const
|
|
843
|
-
return /* @__PURE__ */
|
|
838
|
+
const d = t(), g = nt(d, i);
|
|
839
|
+
return /* @__PURE__ */ G($, { children: s(g) });
|
|
844
840
|
}
|
|
845
841
|
function wt({
|
|
846
842
|
getData: t,
|
|
847
|
-
children:
|
|
848
|
-
uploadHandler:
|
|
843
|
+
children: s,
|
|
844
|
+
uploadHandler: i
|
|
849
845
|
}) {
|
|
850
|
-
const
|
|
851
|
-
return /* @__PURE__ */
|
|
846
|
+
const d = t(), g = st(d, i);
|
|
847
|
+
return /* @__PURE__ */ G($, { children: s(g) });
|
|
852
848
|
}
|
|
853
849
|
export {
|
|
854
850
|
lt as DragDropQuestion,
|
|
@@ -864,7 +860,7 @@ export {
|
|
|
864
860
|
bt as WritingQuestion,
|
|
865
861
|
J as isSameSet,
|
|
866
862
|
V as shuffleArray,
|
|
867
|
-
|
|
863
|
+
L as useBaseQuestion,
|
|
868
864
|
K as useDragDrop,
|
|
869
865
|
tt as useFillInBlank,
|
|
870
866
|
et as useGrouping,
|