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