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