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