@enspiredigital/xlms-headless 0.0.9 → 0.0.10
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/components/Grouping.d.ts +4 -0
- package/dist/components/Grouping.d.ts.map +1 -0
- package/dist/components/Powerpoint.d.ts +4 -0
- package/dist/components/Powerpoint.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useFillInBlank.d.ts +3 -3
- package/dist/hooks/useFillInBlank.d.ts.map +1 -1
- package/dist/hooks/useGrouping.d.ts +21 -0
- package/dist/hooks/useGrouping.d.ts.map +1 -0
- package/dist/hooks/usePowerpoint.d.ts +13 -0
- package/dist/hooks/usePowerpoint.d.ts.map +1 -0
- package/dist/index.js +249 -134
- package/dist/types/common.d.ts +1 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/fillInBlank.d.ts +19 -8
- package/dist/types/fillInBlank.d.ts.map +1 -1
- package/dist/types/grouping.d.ts +24 -0
- package/dist/types/grouping.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +23 -23
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GroupingQuestionType, PropsComponent } from '../types';
|
|
2
|
+
import { useGrouping } from '../hooks';
|
|
3
|
+
export declare function GroupingQuestion({ getData, children, }: PropsComponent<GroupingQuestionType, ReturnType<typeof useGrouping>>): import('react').ReactNode;
|
|
4
|
+
//# sourceMappingURL=Grouping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Grouping.d.ts","sourceRoot":"","sources":["../../src/components/Grouping.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,GACT,EAAE,cAAc,CAAC,oBAAoB,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,6BAGtE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PropsComponent, UrlQuestionType } from '../types';
|
|
2
|
+
import { usePowerpoint } from '../hooks';
|
|
3
|
+
export declare function PowerpointQuestion({ getData, children, }: PropsComponent<UrlQuestionType, ReturnType<typeof usePowerpoint>>): import('react').ReactNode;
|
|
4
|
+
//# sourceMappingURL=Powerpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Powerpoint.d.ts","sourceRoot":"","sources":["../../src/components/Powerpoint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,QAAQ,GACT,EAAE,cAAc,CAAC,eAAe,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,6BAGnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FillInBlankUserAnswer, FillInBlankQuestionType } from '../types/fillInBlank';
|
|
2
2
|
export declare function useFillInBlank(question: FillInBlankQuestionType): {
|
|
3
|
-
|
|
4
|
-
answers:
|
|
3
|
+
groups: import('..').FillInBlankGroup[];
|
|
4
|
+
answers: FillInBlankUserAnswer[];
|
|
5
5
|
question: FillInBlankQuestionType;
|
|
6
6
|
submitted: boolean | null;
|
|
7
7
|
isCorrect: boolean | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFillInBlank.d.ts","sourceRoot":"","sources":["../../src/hooks/useFillInBlank.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useFillInBlank.d.ts","sourceRoot":"","sources":["../../src/hooks/useFillInBlank.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,uBAAuB;;;;;;;;uBAYpC,MAAM,SAAS,MAAM;;;;;;;EA8EhD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GroupingAnswer, GroupingQuestionType } from '../types/grouping';
|
|
2
|
+
export declare function useGrouping(question: GroupingQuestionType): {
|
|
3
|
+
categories: import('..').GroupingCategory[];
|
|
4
|
+
allItems: import('..').GroupingItem[];
|
|
5
|
+
question: GroupingQuestionType;
|
|
6
|
+
answers: GroupingAnswer[];
|
|
7
|
+
unassignedItems: import('..').GroupingItem[];
|
|
8
|
+
submitted: boolean | null;
|
|
9
|
+
isCorrect: boolean | null;
|
|
10
|
+
attempts: number;
|
|
11
|
+
canAnswer: boolean;
|
|
12
|
+
move: (itemId: string, categoryId: string) => void;
|
|
13
|
+
remove: (itemId: string) => void;
|
|
14
|
+
submit: () => {
|
|
15
|
+
isCorrect: boolean;
|
|
16
|
+
score: number;
|
|
17
|
+
maxScore: number;
|
|
18
|
+
};
|
|
19
|
+
reset: () => void;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useGrouping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGrouping.d.ts","sourceRoot":"","sources":["../../src/hooks/useGrouping.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,oBAAoB;;;;;;;;;;mBAYlC,MAAM,cAAc,MAAM;qBAYxB,MAAM;;;;;;;EA+E/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UrlQuestionType } from '../types';
|
|
2
|
+
export declare function usePowerpoint(question: UrlQuestionType): {
|
|
3
|
+
question: UrlQuestionType;
|
|
4
|
+
url: string;
|
|
5
|
+
type: string;
|
|
6
|
+
submit: () => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
submitted: boolean | null;
|
|
9
|
+
isCorrect: boolean | null;
|
|
10
|
+
attempts: number;
|
|
11
|
+
canAnswer: boolean;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=usePowerpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePowerpoint.d.ts","sourceRoot":"","sources":["../../src/hooks/usePowerpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe;;;;;;;;;;EAmCtD"}
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const [t, e] =
|
|
4
|
-
function
|
|
5
|
-
e(!0),
|
|
1
|
+
import { useState as I, useEffect as _, useMemo as j } from "react";
|
|
2
|
+
function k() {
|
|
3
|
+
const [t, e] = I(null), [s, f] = I(null), [p, w] = I(0);
|
|
4
|
+
function g(u) {
|
|
5
|
+
e(!0), f(u), w((A) => A + 1);
|
|
6
6
|
}
|
|
7
7
|
function r() {
|
|
8
|
-
e(!1),
|
|
8
|
+
e(!1), f(null);
|
|
9
9
|
}
|
|
10
10
|
return {
|
|
11
11
|
// state
|
|
12
12
|
submitted: t,
|
|
13
13
|
isCorrect: s,
|
|
14
|
-
attempts:
|
|
14
|
+
attempts: p,
|
|
15
15
|
// derived
|
|
16
16
|
canAnswer: !t,
|
|
17
17
|
// actions
|
|
18
|
-
submitQuestion:
|
|
18
|
+
submitQuestion: g,
|
|
19
19
|
resetQuestion: r
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function E(t, e) {
|
|
23
23
|
if (t.length !== e.length) return !1;
|
|
24
|
-
const s = new Set(t),
|
|
25
|
-
if (s.size !==
|
|
26
|
-
for (const
|
|
27
|
-
if (!
|
|
24
|
+
const s = new Set(t), f = new Set(e);
|
|
25
|
+
if (s.size !== f.size) return !1;
|
|
26
|
+
for (const p of s)
|
|
27
|
+
if (!f.has(p)) return !1;
|
|
28
28
|
return !0;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function L(t) {
|
|
31
31
|
const {
|
|
32
32
|
canAnswer: e,
|
|
33
33
|
submitted: s,
|
|
34
|
-
isCorrect:
|
|
35
|
-
attempts:
|
|
36
|
-
resetQuestion:
|
|
37
|
-
submitQuestion:
|
|
38
|
-
} =
|
|
39
|
-
function A(
|
|
40
|
-
|
|
34
|
+
isCorrect: f,
|
|
35
|
+
attempts: p,
|
|
36
|
+
resetQuestion: w,
|
|
37
|
+
submitQuestion: g
|
|
38
|
+
} = k(), [r, u] = I([]);
|
|
39
|
+
function A(C) {
|
|
40
|
+
u((l) => t.options.allowMultipleAnswers ? l.includes(C) ? l.filter((d) => d !== C) : [...l, C] : [C]);
|
|
41
41
|
}
|
|
42
42
|
function h() {
|
|
43
43
|
if (r.length === 0) return;
|
|
44
|
-
const
|
|
45
|
-
(
|
|
44
|
+
const C = t.options.answers.reduce(
|
|
45
|
+
(d, n) => (n.is_correct && d.push(n.id), d),
|
|
46
46
|
[]
|
|
47
|
-
),
|
|
48
|
-
|
|
47
|
+
), l = E(r, C);
|
|
48
|
+
g(l);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
50
|
+
function S() {
|
|
51
|
+
u([]), w();
|
|
52
52
|
}
|
|
53
53
|
return {
|
|
54
54
|
// data
|
|
@@ -57,71 +57,71 @@ function V(t) {
|
|
|
57
57
|
// actions
|
|
58
58
|
select: A,
|
|
59
59
|
submit: h,
|
|
60
|
-
reset:
|
|
60
|
+
reset: S,
|
|
61
61
|
// base
|
|
62
62
|
submitted: s,
|
|
63
|
-
isCorrect:
|
|
64
|
-
attempts:
|
|
63
|
+
isCorrect: f,
|
|
64
|
+
attempts: p,
|
|
65
65
|
canAnswer: e
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function O(t) {
|
|
69
69
|
const {
|
|
70
70
|
canAnswer: e,
|
|
71
71
|
submitted: s,
|
|
72
|
-
isCorrect:
|
|
73
|
-
attempts:
|
|
74
|
-
submitQuestion:
|
|
75
|
-
resetQuestion:
|
|
76
|
-
} =
|
|
72
|
+
isCorrect: f,
|
|
73
|
+
attempts: p,
|
|
74
|
+
submitQuestion: w,
|
|
75
|
+
resetQuestion: g
|
|
76
|
+
} = k(), [r, u] = I([]), [A, h] = I(
|
|
77
77
|
[]
|
|
78
|
-
), [
|
|
78
|
+
), [S, C] = I(
|
|
79
79
|
[]
|
|
80
80
|
);
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
...
|
|
84
|
-
(
|
|
81
|
+
function l(o, i) {
|
|
82
|
+
u((c) => [
|
|
83
|
+
...c.filter(
|
|
84
|
+
(b) => b.targetId !== o && b.sourceId !== i
|
|
85
85
|
),
|
|
86
|
-
{ targetId: o, sourceId:
|
|
86
|
+
{ targetId: o, sourceId: i }
|
|
87
87
|
]);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
(
|
|
89
|
+
function d(o, i) {
|
|
90
|
+
u(
|
|
91
|
+
(c) => c.filter((b) => b.targetId !== o || b.sourceId !== i)
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
let o = 0,
|
|
96
|
-
return t.options.targets.forEach((
|
|
97
|
-
const
|
|
98
|
-
|
|
94
|
+
function n() {
|
|
95
|
+
let o = 0, i = !0;
|
|
96
|
+
return t.options.targets.forEach((c) => {
|
|
97
|
+
const b = r.find((x) => x.targetId === c.id), Q = t.options.sources[c.content.correct_position - 1];
|
|
98
|
+
b && Q && b.sourceId === Q.id ? o += c.content.point : i = !1;
|
|
99
99
|
}), {
|
|
100
|
-
isCorrect:
|
|
100
|
+
isCorrect: i,
|
|
101
101
|
score: o,
|
|
102
102
|
maxScore: t.options.targets.reduce(
|
|
103
|
-
(
|
|
103
|
+
(c, b) => c + b.content.point,
|
|
104
104
|
0
|
|
105
105
|
)
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
const o =
|
|
110
|
-
return
|
|
108
|
+
function m() {
|
|
109
|
+
const o = n();
|
|
110
|
+
return w(o.isCorrect), o;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
112
|
+
function a() {
|
|
113
|
+
u([]), g();
|
|
114
114
|
}
|
|
115
|
-
return
|
|
115
|
+
return _(() => {
|
|
116
116
|
const o = t.options.sources.filter(
|
|
117
|
-
(
|
|
117
|
+
(i) => !r.some((c) => c.sourceId === i.id)
|
|
118
118
|
);
|
|
119
119
|
h(o);
|
|
120
|
-
}, [r, t.options.sources]),
|
|
120
|
+
}, [r, t.options.sources]), _(() => {
|
|
121
121
|
const o = t.options.targets.filter(
|
|
122
|
-
(
|
|
122
|
+
(i) => !r.some((c) => c.targetId === i.id)
|
|
123
123
|
);
|
|
124
|
-
|
|
124
|
+
C(o);
|
|
125
125
|
}, [r, t.options.targets]), {
|
|
126
126
|
// data
|
|
127
127
|
sources: t.options.sources,
|
|
@@ -129,33 +129,33 @@ function v(t) {
|
|
|
129
129
|
answers: r,
|
|
130
130
|
question: t,
|
|
131
131
|
availableSources: A,
|
|
132
|
-
availableTargets:
|
|
132
|
+
availableTargets: S,
|
|
133
133
|
// base
|
|
134
134
|
submitted: s,
|
|
135
|
-
isCorrect:
|
|
136
|
-
attempts:
|
|
135
|
+
isCorrect: f,
|
|
136
|
+
attempts: p,
|
|
137
137
|
canAnswer: e,
|
|
138
138
|
// actions
|
|
139
|
-
select:
|
|
140
|
-
remove:
|
|
141
|
-
submit:
|
|
142
|
-
reset:
|
|
139
|
+
select: l,
|
|
140
|
+
remove: d,
|
|
141
|
+
submit: m,
|
|
142
|
+
reset: a
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
function T(t) {
|
|
146
146
|
const {
|
|
147
147
|
canAnswer: e,
|
|
148
148
|
submitted: s,
|
|
149
|
-
isCorrect:
|
|
150
|
-
attempts:
|
|
151
|
-
resetQuestion:
|
|
152
|
-
submitQuestion:
|
|
153
|
-
} =
|
|
149
|
+
isCorrect: f,
|
|
150
|
+
attempts: p,
|
|
151
|
+
resetQuestion: w,
|
|
152
|
+
submitQuestion: g
|
|
153
|
+
} = k();
|
|
154
154
|
function r() {
|
|
155
|
-
|
|
155
|
+
g(!0);
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
|
|
157
|
+
function u() {
|
|
158
|
+
w();
|
|
159
159
|
}
|
|
160
160
|
return {
|
|
161
161
|
// data
|
|
@@ -164,111 +164,226 @@ function T(t) {
|
|
|
164
164
|
type: t.options.urlType,
|
|
165
165
|
// actions
|
|
166
166
|
submit: r,
|
|
167
|
-
reset:
|
|
167
|
+
reset: u,
|
|
168
168
|
// base
|
|
169
169
|
submitted: s,
|
|
170
|
-
isCorrect:
|
|
171
|
-
attempts:
|
|
170
|
+
isCorrect: f,
|
|
171
|
+
attempts: p,
|
|
172
172
|
canAnswer: e
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function v(t) {
|
|
176
176
|
const {
|
|
177
177
|
canAnswer: e,
|
|
178
178
|
submitted: s,
|
|
179
|
-
isCorrect:
|
|
180
|
-
attempts:
|
|
181
|
-
submitQuestion:
|
|
182
|
-
resetQuestion:
|
|
183
|
-
} =
|
|
184
|
-
function A(
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
return
|
|
179
|
+
isCorrect: f,
|
|
180
|
+
attempts: p,
|
|
181
|
+
submitQuestion: w,
|
|
182
|
+
resetQuestion: g
|
|
183
|
+
} = k(), [r, u] = I([]);
|
|
184
|
+
function A(l, d) {
|
|
185
|
+
u((n) => {
|
|
186
|
+
const m = n.findIndex((a) => a.targetId === l);
|
|
187
|
+
if (m >= 0) {
|
|
188
|
+
const a = [...n];
|
|
189
|
+
return a[m] = { targetId: l, value: d }, a;
|
|
190
190
|
}
|
|
191
|
-
return [...
|
|
191
|
+
return [...n, { targetId: l, value: d }];
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
function h() {
|
|
195
|
-
let n =
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
isCorrect:
|
|
208
|
-
score:
|
|
209
|
-
maxScore:
|
|
195
|
+
let l = 0, d = 0, n = 0;
|
|
196
|
+
const m = t.correct_answers.list || {}, a = Object.keys(m).length;
|
|
197
|
+
Object.entries(m).forEach(([i, c]) => {
|
|
198
|
+
const b = String(c).trim().toLowerCase(), Q = t.options.answers.find(
|
|
199
|
+
(M) => M.correct_position === Number(i)
|
|
200
|
+
), x = Q && Q.point || 1;
|
|
201
|
+
n += x;
|
|
202
|
+
const B = r.find((M) => M.targetId === i);
|
|
203
|
+
(B ? String(B.value).trim().toLowerCase() : "") === b && (l += x, d++);
|
|
204
|
+
});
|
|
205
|
+
const o = d === a && a > 0;
|
|
206
|
+
return n === 0 && a > 0 && (n = a), {
|
|
207
|
+
isCorrect: o,
|
|
208
|
+
score: Math.round(l * 100) / 100,
|
|
209
|
+
maxScore: Math.round(n * 100) / 100
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
const
|
|
214
|
-
return
|
|
212
|
+
function S() {
|
|
213
|
+
const l = h();
|
|
214
|
+
return w(l.isCorrect), l;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
216
|
+
function C() {
|
|
217
|
+
u([]), g();
|
|
218
218
|
}
|
|
219
219
|
return {
|
|
220
220
|
// data
|
|
221
|
-
|
|
221
|
+
groups: t.options.groups,
|
|
222
222
|
answers: r,
|
|
223
223
|
question: t,
|
|
224
224
|
// base
|
|
225
225
|
submitted: s,
|
|
226
|
-
isCorrect:
|
|
227
|
-
attempts:
|
|
226
|
+
isCorrect: f,
|
|
227
|
+
attempts: p,
|
|
228
228
|
canAnswer: e,
|
|
229
229
|
// actions
|
|
230
230
|
answer: A,
|
|
231
|
-
submit:
|
|
232
|
-
reset:
|
|
231
|
+
submit: S,
|
|
232
|
+
reset: C
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function z(t) {
|
|
236
|
+
const {
|
|
237
|
+
canAnswer: e,
|
|
238
|
+
submitted: s,
|
|
239
|
+
isCorrect: f,
|
|
240
|
+
attempts: p,
|
|
241
|
+
submitQuestion: w,
|
|
242
|
+
resetQuestion: g
|
|
243
|
+
} = k(), [r, u] = I([]);
|
|
244
|
+
function A(n, m) {
|
|
245
|
+
u((a) => {
|
|
246
|
+
const o = a.findIndex((i) => i.itemId === n);
|
|
247
|
+
if (o >= 0) {
|
|
248
|
+
const i = [...a];
|
|
249
|
+
return i[o] = { itemId: n, categoryId: m }, i;
|
|
250
|
+
}
|
|
251
|
+
return [...a, { itemId: n, categoryId: m }];
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function h(n) {
|
|
255
|
+
u((m) => m.filter((a) => a.itemId !== n));
|
|
256
|
+
}
|
|
257
|
+
function S() {
|
|
258
|
+
let n = 0, m = 0;
|
|
259
|
+
const o = t.correct_answers.list || {}, i = Object.keys(o).length;
|
|
260
|
+
let c = 0;
|
|
261
|
+
return Object.entries(o).forEach(([Q, x]) => {
|
|
262
|
+
const B = t.options.items.find((y) => y.id === Q), V = B ? B.point : 0;
|
|
263
|
+
c += V;
|
|
264
|
+
const M = r.find((y) => y.itemId === Q);
|
|
265
|
+
M && M.categoryId === x && (n += V, m++);
|
|
266
|
+
}), n = Math.round(n * 100) / 100, c = Math.round(c * 100) / 100, {
|
|
267
|
+
isCorrect: m === i && i > 0,
|
|
268
|
+
score: n,
|
|
269
|
+
maxScore: c
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function C() {
|
|
273
|
+
const n = S();
|
|
274
|
+
return w(n.isCorrect), n;
|
|
275
|
+
}
|
|
276
|
+
function l() {
|
|
277
|
+
u([]), g();
|
|
278
|
+
}
|
|
279
|
+
const d = j(() => t.options.items.filter(
|
|
280
|
+
(n) => !r.some((m) => m.itemId === n.id)
|
|
281
|
+
), [t.options.items, r]);
|
|
282
|
+
return {
|
|
283
|
+
// data
|
|
284
|
+
categories: t.options.categories,
|
|
285
|
+
allItems: t.options.items,
|
|
286
|
+
question: t,
|
|
287
|
+
// state
|
|
288
|
+
answers: r,
|
|
289
|
+
unassignedItems: d,
|
|
290
|
+
// base
|
|
291
|
+
submitted: s,
|
|
292
|
+
isCorrect: f,
|
|
293
|
+
attempts: p,
|
|
294
|
+
canAnswer: e,
|
|
295
|
+
// actions
|
|
296
|
+
move: A,
|
|
297
|
+
remove: h,
|
|
298
|
+
submit: C,
|
|
299
|
+
reset: l
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function F(t) {
|
|
303
|
+
const {
|
|
304
|
+
canAnswer: e,
|
|
305
|
+
submitted: s,
|
|
306
|
+
isCorrect: f,
|
|
307
|
+
attempts: p,
|
|
308
|
+
resetQuestion: w,
|
|
309
|
+
submitQuestion: g
|
|
310
|
+
} = k();
|
|
311
|
+
function r() {
|
|
312
|
+
s || g(!0);
|
|
313
|
+
}
|
|
314
|
+
function u() {
|
|
315
|
+
w();
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
// data
|
|
319
|
+
question: t,
|
|
320
|
+
url: t.options.url,
|
|
321
|
+
type: t.options.urlType,
|
|
322
|
+
// actions
|
|
323
|
+
submit: r,
|
|
324
|
+
reset: u,
|
|
325
|
+
// base
|
|
326
|
+
submitted: s,
|
|
327
|
+
isCorrect: f,
|
|
328
|
+
attempts: p,
|
|
329
|
+
canAnswer: e
|
|
233
330
|
};
|
|
234
331
|
}
|
|
235
|
-
function
|
|
332
|
+
function P({
|
|
236
333
|
getData: t,
|
|
237
334
|
children: e
|
|
238
335
|
}) {
|
|
239
|
-
const s =
|
|
336
|
+
const s = L(t());
|
|
240
337
|
return e(s);
|
|
241
338
|
}
|
|
242
|
-
function
|
|
339
|
+
function N({
|
|
243
340
|
getData: t,
|
|
244
341
|
children: e
|
|
245
342
|
}) {
|
|
246
|
-
const s =
|
|
343
|
+
const s = O(t());
|
|
247
344
|
return e(s);
|
|
248
345
|
}
|
|
249
|
-
function
|
|
346
|
+
function D({
|
|
250
347
|
getData: t,
|
|
251
348
|
children: e
|
|
252
349
|
}) {
|
|
253
350
|
const s = T(t());
|
|
254
351
|
return e(s);
|
|
255
352
|
}
|
|
256
|
-
function
|
|
353
|
+
function H({
|
|
354
|
+
getData: t,
|
|
355
|
+
children: e
|
|
356
|
+
}) {
|
|
357
|
+
const s = v(t());
|
|
358
|
+
return e(s);
|
|
359
|
+
}
|
|
360
|
+
function J({
|
|
361
|
+
getData: t,
|
|
362
|
+
children: e
|
|
363
|
+
}) {
|
|
364
|
+
const s = z(t());
|
|
365
|
+
return e(s);
|
|
366
|
+
}
|
|
367
|
+
function R({
|
|
257
368
|
getData: t,
|
|
258
369
|
children: e
|
|
259
370
|
}) {
|
|
260
|
-
const s =
|
|
371
|
+
const s = F(t());
|
|
261
372
|
return e(s);
|
|
262
373
|
}
|
|
263
374
|
export {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
375
|
+
H as FillInBlankQuestion,
|
|
376
|
+
J as GroupingQuestion,
|
|
377
|
+
N as MatchingQuestion,
|
|
378
|
+
P as MultipleChoicesQuestion,
|
|
379
|
+
R as PowerpointQuestion,
|
|
380
|
+
D as VideoQuestion,
|
|
381
|
+
E as isSameSet,
|
|
382
|
+
k as useBaseQuestion,
|
|
383
|
+
v as useFillInBlank,
|
|
384
|
+
z as useGrouping,
|
|
385
|
+
O as useMatching,
|
|
386
|
+
L as useMultipleChoice,
|
|
387
|
+
F as usePowerpoint,
|
|
273
388
|
T as useVideo
|
|
274
389
|
};
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,KAAK;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;KAClB,CAAC;IACF,eAAe,EACX;QACE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACxB,GACD;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,KAAK;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;KAClB,CAAC;IACF,eAAe,EACX;QACE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACxB,GACD;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACrC,QAAQ,EAAE;QACR,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,cAAc,CAAC,IAAI,EAAE,GAAG;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC;CACnC"}
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import { BaseQuestion, Media } from './common';
|
|
2
2
|
export interface FillInBlankQuestionType extends BaseQuestion {
|
|
3
3
|
options: {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
answers: FillInBlankAnswer[];
|
|
5
|
+
groups: FillInBlankGroup[];
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
id: string;
|
|
10
|
-
content: {
|
|
11
|
-
correct_answer: string;
|
|
12
|
-
media?: Media;
|
|
7
|
+
correct_answers: {
|
|
8
|
+
list: Record<string, string>;
|
|
13
9
|
};
|
|
14
10
|
}
|
|
15
11
|
export interface FillInBlankAnswer {
|
|
12
|
+
id: string;
|
|
13
|
+
text: string;
|
|
14
|
+
point: number;
|
|
15
|
+
media: Media;
|
|
16
|
+
correct_position: number;
|
|
17
|
+
group_position?: number | null;
|
|
18
|
+
}
|
|
19
|
+
export interface FillInBlankGroup {
|
|
20
|
+
id: string;
|
|
21
|
+
position: number | null;
|
|
22
|
+
count: number;
|
|
23
|
+
text: string;
|
|
24
|
+
media: Media;
|
|
25
|
+
}
|
|
26
|
+
export interface FillInBlankUserAnswer {
|
|
16
27
|
targetId: string;
|
|
17
28
|
value: string;
|
|
18
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fillInBlank.d.ts","sourceRoot":"","sources":["../../src/types/fillInBlank.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"fillInBlank.d.ts","sourceRoot":"","sources":["../../src/types/fillInBlank.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE;QACP,OAAO,EAAE,iBAAiB,EAAE,CAAC;QAC7B,MAAM,EAAE,gBAAgB,EAAE,CAAC;KAC5B,CAAC;IACF,eAAe,EAAE;QACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC9B,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseQuestion, Media } from './common';
|
|
2
|
+
export interface GroupingQuestionType extends BaseQuestion {
|
|
3
|
+
options: {
|
|
4
|
+
categories: GroupingCategory[];
|
|
5
|
+
items: GroupingItem[];
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface GroupingCategory {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
media?: Media;
|
|
12
|
+
}
|
|
13
|
+
export interface GroupingItem {
|
|
14
|
+
id: string;
|
|
15
|
+
text: string;
|
|
16
|
+
point: number;
|
|
17
|
+
media?: Media;
|
|
18
|
+
group_position?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface GroupingAnswer {
|
|
21
|
+
itemId: string;
|
|
22
|
+
categoryId: string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=grouping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grouping.d.ts","sourceRoot":"","sources":["../../src/types/grouping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,OAAO,EAAE;QACP,UAAU,EAAE,gBAAgB,EAAE,CAAC;QAC/B,KAAK,EAAE,YAAY,EAAE,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@enspiredigital/xlms-headless",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
"./package.json": "./package.json",
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js",
|
|
13
|
-
"default": "./dist/index.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist",
|
|
18
|
-
"!**/*.tsbuildinfo"
|
|
19
|
-
],
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@enspiredigital/xlms-headless",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"!**/*.tsbuildinfo"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|