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