@enspiredigital/xlms-headless 0.0.5 → 0.0.7

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.
@@ -11,7 +11,7 @@ export declare function useMatching(question: MatchingQuestionType): {
11
11
  attempts: number;
12
12
  canAnswer: boolean;
13
13
  select: (targetId: string, sourceId: string) => void;
14
- remove: (targetId: string) => void;
14
+ remove: (id: string) => void;
15
15
  submit: () => {
16
16
  isCorrect: boolean;
17
17
  score: number;
@@ -1 +1 @@
1
- {"version":3,"file":"useMatching.d.ts","sourceRoot":"","sources":["../../src/hooks/useMatching.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,wBAAgB,WAAW,CAAC,QAAQ,EAAE,oBAAoB;;;;;;;;;;;uBAkB9B,MAAM,YAAY,MAAM;uBAaxB,MAAM;;;;;;;EAkFjC"}
1
+ {"version":3,"file":"useMatching.d.ts","sourceRoot":"","sources":["../../src/hooks/useMatching.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,wBAAgB,WAAW,CAAC,QAAQ,EAAE,oBAAoB;;;;;;;;;;;uBAkB9B,MAAM,YAAY,MAAM;iBAa9B,MAAM;;;;;;;EAoF3B"}
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { useState as b, useEffect as B } from "react";
2
2
  function S() {
3
- const [t, e] = b(null), [s, i] = b(null), [a, p] = b(0);
4
- function g(c) {
5
- t || (e(!0), i(c), p((C) => C + 1));
3
+ const [t, e] = b(null), [s, c] = b(null), [a, p] = b(0);
4
+ function g(u) {
5
+ t || (e(!0), c(u), p((C) => C + 1));
6
6
  }
7
7
  function r() {
8
- e(!1), i(null);
8
+ e(!1), c(null);
9
9
  }
10
10
  return {
11
11
  // state
@@ -21,23 +21,23 @@ function S() {
21
21
  }
22
22
  function k(t, e) {
23
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;
24
+ const s = new Set(t), c = new Set(e);
25
+ if (s.size !== c.size) return !1;
26
26
  for (const a of s)
27
- if (!i.has(a)) return !1;
27
+ if (!c.has(a)) return !1;
28
28
  return !0;
29
29
  }
30
30
  function V(t) {
31
31
  const {
32
32
  canAnswer: e,
33
33
  submitted: s,
34
- isCorrect: i,
34
+ isCorrect: c,
35
35
  attempts: a,
36
36
  resetQuestion: p,
37
37
  submitQuestion: g
38
- } = S(), [r, c] = b([]);
38
+ } = S(), [r, u] = b([]);
39
39
  function C(d) {
40
- c((n) => t.options.allowMultipleAnswers ? n.includes(d) ? n.filter((l) => l !== d) : [...n, d] : [d]);
40
+ u((n) => t.options.allowMultipleAnswers ? n.includes(d) ? n.filter((l) => l !== d) : [...n, d] : [d]);
41
41
  }
42
42
  function h() {
43
43
  if (r.length === 0) return;
@@ -48,7 +48,7 @@ function V(t) {
48
48
  g(n);
49
49
  }
50
50
  function I() {
51
- c([]), p();
51
+ u([]), p();
52
52
  }
53
53
  return {
54
54
  // data
@@ -60,7 +60,7 @@ function V(t) {
60
60
  reset: I,
61
61
  // base
62
62
  submitted: s,
63
- isCorrect: i,
63
+ isCorrect: c,
64
64
  attempts: a,
65
65
  canAnswer: e
66
66
  };
@@ -69,36 +69,38 @@ function v(t) {
69
69
  const {
70
70
  canAnswer: e,
71
71
  submitted: s,
72
- isCorrect: i,
72
+ isCorrect: c,
73
73
  attempts: a,
74
74
  submitQuestion: p,
75
75
  resetQuestion: g
76
- } = S(), [r, c] = b([]), [C, h] = b(
76
+ } = S(), [r, u] = b([]), [C, h] = b(
77
77
  []
78
78
  ), [I, d] = b(
79
79
  []
80
80
  );
81
81
  function n(o, m) {
82
- c((u) => [
83
- ...u.filter(
82
+ u((i) => [
83
+ ...i.filter(
84
84
  (A) => A.targetId !== o && A.sourceId !== m
85
85
  ),
86
86
  { targetId: o, sourceId: m }
87
87
  ]);
88
88
  }
89
89
  function l(o) {
90
- c((m) => m.filter((u) => u.targetId !== o));
90
+ u(
91
+ (m) => m.filter((i) => i.targetId !== o && i.sourceId !== o)
92
+ );
91
93
  }
92
94
  function f() {
93
95
  let o = 0, m = !0;
94
- return t.options.targets.forEach((u) => {
95
- const A = r.find((M) => M.targetId === u.id), x = t.options.sources[u.content.correct_position - 1];
96
- A && x && A.sourceId === x.id ? o += u.content.point : m = !1;
96
+ return t.options.targets.forEach((i) => {
97
+ const A = r.find((M) => M.targetId === i.id), x = t.options.sources[i.content.correct_position - 1];
98
+ A && x && A.sourceId === x.id ? o += i.content.point : m = !1;
97
99
  }), {
98
100
  isCorrect: m,
99
101
  score: o,
100
102
  maxScore: t.options.targets.reduce(
101
- (u, A) => u + A.content.point,
103
+ (i, A) => i + A.content.point,
102
104
  0
103
105
  )
104
106
  };
@@ -108,16 +110,16 @@ function v(t) {
108
110
  return p(o.isCorrect), o;
109
111
  }
110
112
  function w() {
111
- c([]), g();
113
+ u([]), g();
112
114
  }
113
115
  return B(() => {
114
116
  const o = t.options.sources.filter(
115
- (m) => !r.some((u) => u.sourceId === m.id)
117
+ (m) => !r.some((i) => i.sourceId === m.id)
116
118
  );
117
119
  h(o);
118
120
  }, [r, t.options.sources]), B(() => {
119
121
  const o = t.options.targets.filter(
120
- (m) => !r.some((u) => u.targetId === m.id)
122
+ (m) => !r.some((i) => i.targetId === m.id)
121
123
  );
122
124
  d(o);
123
125
  }, [r, t.options.targets]), {
@@ -130,7 +132,7 @@ function v(t) {
130
132
  availableTargets: I,
131
133
  // base
132
134
  submitted: s,
133
- isCorrect: i,
135
+ isCorrect: c,
134
136
  attempts: a,
135
137
  canAnswer: e,
136
138
  // actions
@@ -144,7 +146,7 @@ function T(t) {
144
146
  const {
145
147
  canAnswer: e,
146
148
  submitted: s,
147
- isCorrect: i,
149
+ isCorrect: c,
148
150
  attempts: a,
149
151
  resetQuestion: p,
150
152
  submitQuestion: g
@@ -152,7 +154,7 @@ function T(t) {
152
154
  function r() {
153
155
  g(!0);
154
156
  }
155
- function c() {
157
+ function u() {
156
158
  p();
157
159
  }
158
160
  return {
@@ -162,10 +164,10 @@ function T(t) {
162
164
  type: t.options.urlType,
163
165
  // actions
164
166
  submit: r,
165
- reset: c,
167
+ reset: u,
166
168
  // base
167
169
  submitted: s,
168
- isCorrect: i,
170
+ isCorrect: c,
169
171
  attempts: a,
170
172
  canAnswer: e
171
173
  };
@@ -174,13 +176,13 @@ function _(t) {
174
176
  const {
175
177
  canAnswer: e,
176
178
  submitted: s,
177
- isCorrect: i,
179
+ isCorrect: c,
178
180
  attempts: a,
179
181
  submitQuestion: p,
180
182
  resetQuestion: g
181
- } = S(), [r, c] = b([]);
183
+ } = S(), [r, u] = b([]);
182
184
  function C(n, l) {
183
- e && c((f) => {
185
+ e && u((f) => {
184
186
  const Q = f.findIndex((w) => w.targetId === n);
185
187
  if (Q >= 0) {
186
188
  const w = [...f];
@@ -212,7 +214,7 @@ function _(t) {
212
214
  return p(n.isCorrect), n;
213
215
  }
214
216
  function d() {
215
- c([]), g();
217
+ u([]), g();
216
218
  }
217
219
  return {
218
220
  // data
@@ -221,7 +223,7 @@ function _(t) {
221
223
  question: t,
222
224
  // base
223
225
  submitted: s,
224
- isCorrect: i,
226
+ isCorrect: c,
225
227
  attempts: a,
226
228
  canAnswer: e,
227
229
  // actions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enspiredigital/xlms-headless",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",