@enspiredigital/xlms-headless 0.0.9 → 0.0.11

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