@pie-element/categorize 13.1.2-next.4 → 13.1.2-next.6
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/author/defaults.d.ts +0 -1
- package/dist/author/defaults.js +2 -4
- package/dist/author/design/buttons.js +3 -3
- package/dist/author/design/categories/alternateResponses.js +2 -2
- package/dist/author/design/categories/category.js +2 -2
- package/dist/author/design/categories/choice-preview.js +1 -1
- package/dist/author/design/categories/droppable-placeholder.js +1 -1
- package/dist/author/design/categories/index.js +3 -3
- package/dist/author/design/choices/choice.js +2 -2
- package/dist/author/design/choices/config.js +1 -1
- package/dist/author/design/choices/index.js +3 -3
- package/dist/author/design/header.js +1 -1
- package/dist/author/design/index.js +78 -68
- package/dist/author/design/input-header.js +1 -1
- package/dist/author/index.d.ts +0 -1
- package/dist/author/index.js +2 -2
- package/dist/author/main.js +2 -2
- package/dist/author/utils.js +1 -1
- package/dist/browser/alert-dialog-BtccZZm9.js +11509 -0
- package/dist/browser/alert-dialog-BtccZZm9.js.map +1 -0
- package/dist/browser/author/index.js +41841 -834
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +196 -123
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/delivery/index.js +294 -293
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/browser/{dist-DnGF41FP.js → dist-C11U2GIc.js} +301 -388
- package/dist/browser/dist-C11U2GIc.js.map +1 -0
- package/dist/browser/rolldown-runtime-CWhphoD1.js +32 -0
- package/dist/controller/defaults.d.ts +0 -1
- package/dist/controller/defaults.js +2 -4
- package/dist/controller/index.d.ts +1 -0
- package/dist/controller/index.js +92 -79
- package/dist/delivery/categorize/categories.js +3 -3
- package/dist/delivery/categorize/category.js +1 -1
- package/dist/delivery/categorize/choice.js +1 -1
- package/dist/delivery/categorize/choices.js +1 -1
- package/dist/delivery/categorize/grid-content.js +1 -1
- package/dist/delivery/categorize/index.js +3 -3
- package/dist/delivery/index.js +2 -2
- package/dist/index.iife.js +33 -33
- package/package.json +15 -10
- package/dist/browser/dist-7UsF60Ks.js +0 -55705
- package/dist/browser/dist-7UsF60Ks.js.map +0 -1
- package/dist/browser/dist-DnGF41FP.js.map +0 -1
|
@@ -1,6 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var
|
|
1
|
+
import { i as e } from "../rolldown-runtime-CWhphoD1.js";
|
|
2
|
+
import { D as t, E as n, g as r, t as i } from "../dist-C11U2GIc.js";
|
|
3
|
+
var a = (0, (/* @__PURE__ */ e(t(), 1)).default)("@pie-lib:categorize:scoring"), o = (e) => !e || !e.weighting ? [] : e.weighting.enabled && e.weighting && e.weighting.rules || [], s = (e, t) => {
|
|
4
|
+
if (a("partial? ", e), !(!e || !e.enabled)) {
|
|
5
|
+
let n = e.rules.find((e) => e.category === t);
|
|
6
|
+
return n && n.rules || [];
|
|
7
|
+
}
|
|
8
|
+
}, c = (e, t) => new Promise((n) => {
|
|
9
|
+
a("categories: ", e, "scoring: ", t);
|
|
10
|
+
let r = o(t), i = e.map((e) => ({
|
|
11
|
+
...r.find((t) => t.category === e.id) || { points: 1 },
|
|
12
|
+
category: e.id
|
|
13
|
+
}));
|
|
14
|
+
a("weights: ", i);
|
|
15
|
+
let c = e.reduce((e, t) => {
|
|
16
|
+
let n = i.find((e) => e.category === t.id);
|
|
17
|
+
return e += n.points;
|
|
18
|
+
}, 0);
|
|
19
|
+
a("total: ", c);
|
|
20
|
+
let l = e.map((e) => {
|
|
21
|
+
let n = i.find((t) => t.category === e.id).points;
|
|
22
|
+
if (a("category: ", e), e.correct === !0) return {
|
|
23
|
+
category: e.id,
|
|
24
|
+
score: n,
|
|
25
|
+
points: n
|
|
26
|
+
};
|
|
27
|
+
{
|
|
28
|
+
let r = s(t.partial, e.id);
|
|
29
|
+
if (a("partial rules for category: ", r), r) {
|
|
30
|
+
let t = (e.choices || []).filter((e) => e.correct).length;
|
|
31
|
+
a("correctCount: ", t);
|
|
32
|
+
let i = r.find((e) => e.count === t);
|
|
33
|
+
a("rule: ", i), i ||= {
|
|
34
|
+
percent: 0,
|
|
35
|
+
count: t
|
|
36
|
+
};
|
|
37
|
+
let o = n * (i.percent / 100);
|
|
38
|
+
return {
|
|
39
|
+
category: e.id,
|
|
40
|
+
score: o,
|
|
41
|
+
points: n,
|
|
42
|
+
partial: {
|
|
43
|
+
correctChoices: t,
|
|
44
|
+
rule: i
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
} else return {
|
|
48
|
+
category: e.id,
|
|
49
|
+
score: 0,
|
|
50
|
+
points: n
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}), u = l.reduce((e, t) => e += t.score, 0);
|
|
54
|
+
a("weightedScore: ", u), n({
|
|
55
|
+
score: parseFloat((u / c).toFixed(2), 10),
|
|
56
|
+
details: {
|
|
57
|
+
weighted: {
|
|
58
|
+
total: c,
|
|
59
|
+
score: u
|
|
60
|
+
},
|
|
61
|
+
categories: l
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}), l = {
|
|
4
65
|
correct: {
|
|
5
66
|
type: "default",
|
|
6
67
|
default: "Correct",
|
|
@@ -22,19 +83,19 @@ var i = {
|
|
|
22
83
|
custom: "You have not entered a response"
|
|
23
84
|
}
|
|
24
85
|
};
|
|
25
|
-
function
|
|
86
|
+
function u(e) {
|
|
26
87
|
return e === "partially-correct" ? "partial" : e;
|
|
27
88
|
}
|
|
28
|
-
function
|
|
89
|
+
function d(e, t = {}) {
|
|
29
90
|
return new Promise((n) => {
|
|
30
91
|
let r = {
|
|
31
|
-
...
|
|
92
|
+
...l,
|
|
32
93
|
...t
|
|
33
|
-
},
|
|
34
|
-
|
|
94
|
+
}, i = u(e), a = r[i], o = l[i];
|
|
95
|
+
f(a, o[a.type]).then(n);
|
|
35
96
|
});
|
|
36
97
|
}
|
|
37
|
-
function
|
|
98
|
+
function f(e, t) {
|
|
38
99
|
return new Promise((n) => {
|
|
39
100
|
if (!e || e.type === "none") {
|
|
40
101
|
n(void 0);
|
|
@@ -45,18 +106,18 @@ function s(e, t) {
|
|
|
45
106
|
}
|
|
46
107
|
//#endregion
|
|
47
108
|
//#region ../../shared/controller-utils/dist/index.js
|
|
48
|
-
var
|
|
109
|
+
var p = Object.defineProperty, m = (e, t) => {
|
|
49
110
|
let n = {};
|
|
50
|
-
for (var r in e)
|
|
111
|
+
for (var r in e) p(n, r, {
|
|
51
112
|
get: e[r],
|
|
52
113
|
enumerable: !0
|
|
53
114
|
});
|
|
54
|
-
return t ||
|
|
115
|
+
return t || p(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
55
116
|
};
|
|
56
|
-
function
|
|
117
|
+
function h(e) {
|
|
57
118
|
return Array.isArray(e) ? e.filter((e) => e != null) : [];
|
|
58
119
|
}
|
|
59
|
-
function
|
|
120
|
+
function g(e) {
|
|
60
121
|
let t = [...e];
|
|
61
122
|
for (let e = t.length - 1; e > 0; e--) {
|
|
62
123
|
let n = Math.floor(Math.random() * (e + 1));
|
|
@@ -64,44 +125,67 @@ function d(e) {
|
|
|
64
125
|
}
|
|
65
126
|
return t;
|
|
66
127
|
}
|
|
67
|
-
function
|
|
68
|
-
return e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object"
|
|
128
|
+
function _(e) {
|
|
129
|
+
return e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" && Object.keys(e).length === 0;
|
|
69
130
|
}
|
|
70
|
-
async function
|
|
71
|
-
let i =
|
|
131
|
+
async function v(e, t, n, r = "value") {
|
|
132
|
+
let i = h(t?.data?.shuffledValues ?? t?.shuffledValues ?? []);
|
|
72
133
|
if (!t) {
|
|
73
134
|
console.warn("Unable to save shuffled choices because there's no session.");
|
|
74
135
|
return;
|
|
75
136
|
}
|
|
76
|
-
if (!
|
|
77
|
-
let a =
|
|
137
|
+
if (!_(i)) return h(i.map((t) => e.find((e) => e[r] === t)));
|
|
138
|
+
let a = g(e);
|
|
78
139
|
if (n && typeof n == "function") try {
|
|
79
|
-
let e =
|
|
80
|
-
|
|
140
|
+
let e = h(a.map((e) => e[r]));
|
|
141
|
+
_(e) ? console.error(`shuffledValues is an empty array - refusing to call updateSession. shuffledChoices: ${JSON.stringify(a)}, key: ${r}`) : t.id && t.element && await n(t.id, t.element, { shuffledValues: e });
|
|
81
142
|
} catch (e) {
|
|
82
143
|
console.warn("Unable to save shuffled order for choices"), console.error(e);
|
|
83
144
|
}
|
|
84
145
|
else console.warn("Unable to save shuffled choices, shuffle will happen every time.");
|
|
85
146
|
return a;
|
|
86
147
|
}
|
|
87
|
-
function
|
|
148
|
+
function y(e, t, n) {
|
|
88
149
|
return !!(e.lockChoiceOrder || n["@pie-element"]?.lockChoiceOrder || (n.role ?? "student") === "instructor");
|
|
89
150
|
}
|
|
90
|
-
var
|
|
91
|
-
function
|
|
92
|
-
return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n
|
|
151
|
+
var b = /* @__PURE__ */ m({ enabled: () => x });
|
|
152
|
+
function x(e, t, n) {
|
|
153
|
+
return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n != "boolean" || n;
|
|
93
154
|
}
|
|
94
155
|
//#endregion
|
|
95
|
-
//#region src/controller/
|
|
96
|
-
var
|
|
156
|
+
//#region src/controller/defaults.ts
|
|
157
|
+
var S = {
|
|
158
|
+
alternates: [],
|
|
159
|
+
categories: [],
|
|
160
|
+
categoriesPerRow: 2,
|
|
161
|
+
choices: [],
|
|
162
|
+
choicesLabel: "",
|
|
163
|
+
choicesPosition: "below",
|
|
164
|
+
correctResponse: [],
|
|
165
|
+
feedbackEnabled: !1,
|
|
166
|
+
lockChoiceOrder: !0,
|
|
167
|
+
maxAnswerChoices: 6,
|
|
168
|
+
maxChoicesPerCategory: 0,
|
|
169
|
+
partialScoring: !0,
|
|
170
|
+
prompt: "",
|
|
171
|
+
promptEnabled: !0,
|
|
172
|
+
rationale: "",
|
|
173
|
+
rationaleEnabled: !0,
|
|
174
|
+
rowLabels: [""],
|
|
175
|
+
studentInstructionsEnabled: !0,
|
|
176
|
+
teacherInstructions: "",
|
|
177
|
+
teacherInstructionsEnabled: !0,
|
|
178
|
+
toolbarEditorPosition: "bottom",
|
|
179
|
+
minRowHeight: "80px"
|
|
180
|
+
}, C = {
|
|
97
181
|
enabled: "Yes",
|
|
98
182
|
disabled: "No",
|
|
99
183
|
perChoice: "Set Per Choice"
|
|
100
|
-
},
|
|
184
|
+
}, w = (e, t) => {
|
|
101
185
|
if (e.length < 1 || t.length < 1) return -1;
|
|
102
186
|
let n = JSON.stringify(e.sort());
|
|
103
187
|
return t.reduce((e, t) => t.length > 0 ? [...e, JSON.stringify(t.sort())] : e, []).findIndex((e) => e.length && e === n);
|
|
104
|
-
},
|
|
188
|
+
}, T = (e) => {
|
|
105
189
|
if (e.length <= 1) return -1;
|
|
106
190
|
let t = /* @__PURE__ */ new Set(), n = e.reduce((e, t) => t.length > 0 ? [...e, JSON.stringify(t.sort())] : e, []);
|
|
107
191
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -109,7 +193,7 @@ var _ = {
|
|
|
109
193
|
t.add(n[e]);
|
|
110
194
|
}
|
|
111
195
|
return -1;
|
|
112
|
-
},
|
|
196
|
+
}, E = (e, t, n) => {
|
|
113
197
|
let r = e.map((e) => e.choices), i = [r.flat()], a = r.filter((e) => e.length).length;
|
|
114
198
|
if (t.length) {
|
|
115
199
|
let e = t[0]?.length || 0;
|
|
@@ -124,31 +208,7 @@ var _ = {
|
|
|
124
208
|
possibleResponses: i,
|
|
125
209
|
hasUnplacedChoices: o
|
|
126
210
|
};
|
|
127
|
-
},
|
|
128
|
-
allowMultiplePlacementsEnabled: _.enabled,
|
|
129
|
-
alternates: [],
|
|
130
|
-
categories: [],
|
|
131
|
-
categoriesPerRow: 2,
|
|
132
|
-
choices: [],
|
|
133
|
-
choicesLabel: "",
|
|
134
|
-
choicesPosition: "below",
|
|
135
|
-
correctResponse: [],
|
|
136
|
-
feedbackEnabled: !1,
|
|
137
|
-
lockChoiceOrder: !0,
|
|
138
|
-
maxAnswerChoices: 6,
|
|
139
|
-
maxChoicesPerCategory: 0,
|
|
140
|
-
partialScoring: !0,
|
|
141
|
-
prompt: "",
|
|
142
|
-
promptEnabled: !0,
|
|
143
|
-
rationale: "",
|
|
144
|
-
rationaleEnabled: !0,
|
|
145
|
-
rowLabels: [""],
|
|
146
|
-
studentInstructionsEnabled: !0,
|
|
147
|
-
teacherInstructions: "",
|
|
148
|
-
teacherInstructionsEnabled: !0,
|
|
149
|
-
toolbarEditorPosition: "bottom",
|
|
150
|
-
minRowHeight: "80px"
|
|
151
|
-
}, { translator: S } = e, C = (e, t) => {
|
|
211
|
+
}, { translator: D } = n, O = (e, t) => {
|
|
152
212
|
let { placements: n, score: r } = t.reduce((e, { choices: t = [] }) => ({
|
|
153
213
|
placements: e.placements + t.length,
|
|
154
214
|
score: e.score + t.filter((e) => e.correct).length
|
|
@@ -157,99 +217,112 @@ var _ = {
|
|
|
157
217
|
score: 0
|
|
158
218
|
}), { maxScore: i } = e.reduce((e, { choices: t }) => ({ maxScore: e.maxScore + t.length }), { maxScore: 0 }), a = (r - (n > i ? n - i : 0)) / i;
|
|
159
219
|
return a < 0 ? 0 : parseFloat(a.toFixed(2));
|
|
160
|
-
},
|
|
220
|
+
}, k = (e) => e.map((e) => e.alternateResponses).filter((e) => e), A = (e, t, n) => {
|
|
161
221
|
if (!t || Object.keys(t).length === 0) return 0;
|
|
162
|
-
let { categories:
|
|
222
|
+
let { categories: r, choices: a } = e || {}, { correctResponse: o } = e || {}, { answers: s } = t || {};
|
|
163
223
|
s ||= [], o ||= [];
|
|
164
|
-
let { categories: c, correct: l } = r
|
|
165
|
-
return
|
|
166
|
-
},
|
|
224
|
+
let { categories: c, correct: l } = i(r, a, s, o), u = k(o);
|
|
225
|
+
return b.enabled(e, n) && !u.length ? O(o, c) : +!!l;
|
|
226
|
+
}, j = (e, t, n) => new Promise((r) => {
|
|
167
227
|
if (n.mode === "evaluate") {
|
|
168
|
-
let i =
|
|
228
|
+
let i = A(e, t, n);
|
|
169
229
|
r(i === 1 ? "correct" : i === 0 ? "incorrect" : "partially-correct");
|
|
170
230
|
} else r(void 0);
|
|
171
|
-
}),
|
|
231
|
+
}), M = (e = {}) => new Promise((t) => {
|
|
172
232
|
t({
|
|
173
|
-
...
|
|
233
|
+
...S,
|
|
174
234
|
...e
|
|
175
235
|
});
|
|
176
|
-
}),
|
|
177
|
-
...
|
|
236
|
+
}), N = (e) => ({
|
|
237
|
+
...S,
|
|
178
238
|
...e
|
|
179
|
-
}),
|
|
180
|
-
let i =
|
|
239
|
+
}), P = async (e, t, n, r) => {
|
|
240
|
+
let i = N(e), a = await j(i, t, n), { mode: o, role: s } = n || {}, { categories: c, categoriesPerRow: l, choicesLabel: u, choicesPosition: f, correctResponse: p, feedback: m, feedbackEnabled: h, promptEnabled: g, prompt: _, rowLabels: b, rationaleEnabled: x, rationale: S, teacherInstructionsEnabled: w, teacherInstructions: T, language: O, maxChoicesPerCategory: A, extraCSSRules: M, minRowHeight: P, fontSizeFactor: F, autoplayAudioEnabled: I, completeAudioEnabled: L, customAudioButton: R } = i, { choices: z, note: B } = i, V, H = y(i, t, n), U = p.map((e) => {
|
|
181
241
|
let t = (e.choices || []).filter((e) => e !== "null");
|
|
182
242
|
return {
|
|
183
243
|
...e,
|
|
184
244
|
choices: t
|
|
185
245
|
};
|
|
186
246
|
});
|
|
187
|
-
|
|
188
|
-
let
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
247
|
+
o === "evaluate" && h && (V = await d(a, m)), H || (z = await v(z, t, r, "id"));
|
|
248
|
+
let W = (() => {
|
|
249
|
+
if (e.allowMultiplePlacementsEnabled != null) return e.allowMultiplePlacementsEnabled;
|
|
250
|
+
let t = (p || []).flatMap((e) => e.choices || []);
|
|
251
|
+
return t.length === new Set(t).size ? C.disabled : C.enabled;
|
|
252
|
+
})();
|
|
253
|
+
z = (z || []).map((e) => {
|
|
254
|
+
let t;
|
|
255
|
+
return t = W === C.enabled ? 0 : W === C.disabled ? 1 : e.categoryCount || 0, {
|
|
256
|
+
...e,
|
|
257
|
+
categoryCount: t
|
|
258
|
+
};
|
|
259
|
+
}), B ||= D.t("common:commonCorrectAnswerWithAlternates", { lng: O });
|
|
260
|
+
let G = k(U), { responseAreasToBeFilled: K, possibleResponses: q, hasUnplacedChoices: J } = E(U, i.allowAlternateEnabled ? G : [], i.choices), Y = {
|
|
261
|
+
categories: c || [],
|
|
262
|
+
categoriesPerRow: l || 2,
|
|
263
|
+
maxChoicesPerCategory: A,
|
|
192
264
|
correctness: a,
|
|
193
|
-
choices:
|
|
194
|
-
choicesLabel:
|
|
265
|
+
choices: z || [],
|
|
266
|
+
choicesLabel: u || "",
|
|
195
267
|
choicesPosition: f,
|
|
196
|
-
disabled:
|
|
197
|
-
feedback:
|
|
198
|
-
lockChoiceOrder:
|
|
199
|
-
prompt:
|
|
200
|
-
rowLabels:
|
|
201
|
-
note:
|
|
268
|
+
disabled: o !== "gather",
|
|
269
|
+
feedback: V,
|
|
270
|
+
lockChoiceOrder: H,
|
|
271
|
+
prompt: g ? _ : null,
|
|
272
|
+
rowLabels: b,
|
|
273
|
+
note: B,
|
|
202
274
|
env: n,
|
|
203
|
-
showNote:
|
|
204
|
-
correctResponse:
|
|
205
|
-
language:
|
|
275
|
+
showNote: G && G.length > 0,
|
|
276
|
+
correctResponse: o === "evaluate" ? U : void 0,
|
|
277
|
+
language: O,
|
|
206
278
|
extraCSSRules: M,
|
|
207
|
-
fontSizeFactor:
|
|
208
|
-
minRowHeight:
|
|
209
|
-
autoplayAudioEnabled:
|
|
210
|
-
completeAudioEnabled:
|
|
211
|
-
customAudioButton:
|
|
212
|
-
possibleResponses:
|
|
213
|
-
responseAreasToBeFilled:
|
|
214
|
-
hasUnplacedChoices:
|
|
279
|
+
fontSizeFactor: F,
|
|
280
|
+
minRowHeight: P,
|
|
281
|
+
autoplayAudioEnabled: I,
|
|
282
|
+
completeAudioEnabled: L,
|
|
283
|
+
customAudioButton: R,
|
|
284
|
+
possibleResponses: q,
|
|
285
|
+
responseAreasToBeFilled: K,
|
|
286
|
+
hasUnplacedChoices: J,
|
|
287
|
+
...e.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: W }
|
|
215
288
|
};
|
|
216
|
-
return
|
|
217
|
-
},
|
|
218
|
-
let
|
|
219
|
-
if (l > 0 ? (
|
|
220
|
-
let
|
|
221
|
-
if (
|
|
289
|
+
return s === "instructor" && (o === "view" || o === "evaluate") ? (Y.rationale = x ? S : null, Y.teacherInstructions = w ? T : null) : (Y.rationale = null, Y.teacherInstructions = null), Y;
|
|
290
|
+
}, F = (e, t, n) => {
|
|
291
|
+
let r = [], { answers: a } = t || {}, { categories: o, choices: s, correctResponse: c } = e || {}, l = a.reduce((e, t) => e + (t.choices?.length || 0), 0), u = k(c).length > 0, d = b.enabled(e, n), f = (l > 0 ? i(o, s, a, c) : null)?.categories || [];
|
|
292
|
+
if (l > 0 ? (r.push(`Student placed ${l} choice(s) into categories.`), (o || []).forEach((e) => {
|
|
293
|
+
let t = e.id, n = f.find((e) => e.id === t), i = n && n.choices || [], a = (c || []).find((e) => e.category === t), o = a && a.choices || [];
|
|
294
|
+
if (o.length > 0) if (i.length === 0) r.push(`Category ${t}: student left empty (should contain ${o.length} choice(s)).`);
|
|
222
295
|
else {
|
|
223
|
-
let e =
|
|
224
|
-
e > 0 &&
|
|
296
|
+
let e = i.filter((e) => e.correct).length, n = i.length - e;
|
|
297
|
+
e > 0 && n === 0 ? r.push(`Category ${t}: student placed ${e} correct choice(s).`) : e === 0 && n > 0 ? r.push(`Category ${t}: student placed ${n} incorrect choice(s).`) : r.push(`Category ${t}: student placed ${e} correct and ${n} incorrect choice(s).`);
|
|
225
298
|
}
|
|
226
|
-
})) :
|
|
299
|
+
})) : r.push("Student did not place any choices into categories."), u && r.push("Alternate response combinations are accepted for this question."), u) r.push("Score calculated using all-or-nothing scoring (alternate responses disable partial scoring)."), r.push("Student must get all categories completely correct to receive full credit.");
|
|
227
300
|
else if (d) {
|
|
228
|
-
if (
|
|
301
|
+
if (r.push("Score calculated using partial scoring."), r.push("Student receives credit for each correct placement, with deductions for incorrect placements beyond required amount."), l > 0) {
|
|
229
302
|
let e = f.reduce((e, t) => e + (t.choices || []).filter((e) => e.correct).length, 0), t = l - e, n = (c || []).reduce((e, t) => e + (t.choices || []).length, 0);
|
|
230
|
-
if (
|
|
303
|
+
if (r.push(`Partial scoring calculation: ${e} correct placements, ${t} incorrect placements.`), l > n) {
|
|
231
304
|
let e = l - n;
|
|
232
|
-
|
|
305
|
+
r.push(`${e} extra placement(s) beyond required amount will be deducted from score.`);
|
|
233
306
|
}
|
|
234
307
|
}
|
|
235
|
-
} else
|
|
236
|
-
let p =
|
|
237
|
-
return
|
|
238
|
-
},
|
|
239
|
-
if (!t ||
|
|
308
|
+
} else r.push("Score calculated using all-or-nothing scoring."), r.push("Student must get all categories completely correct to receive full credit.");
|
|
309
|
+
let p = A(e, t, n);
|
|
310
|
+
return r.push(`Final score: ${p}.`), r;
|
|
311
|
+
}, I = (e, t, n) => n.mode === "evaluate" ? new Promise((i) => {
|
|
312
|
+
if (!t || r(t)) i({
|
|
240
313
|
score: 0,
|
|
241
314
|
empty: !0,
|
|
242
315
|
traceLog: ["Student did not place any choices into categories. Score is 0."]
|
|
243
316
|
});
|
|
244
317
|
else {
|
|
245
|
-
let
|
|
318
|
+
let r = F(e, t, n);
|
|
246
319
|
i({
|
|
247
|
-
score:
|
|
320
|
+
score: A(e, t, n),
|
|
248
321
|
empty: !1,
|
|
249
|
-
traceLog:
|
|
322
|
+
traceLog: r
|
|
250
323
|
});
|
|
251
324
|
}
|
|
252
|
-
}) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")),
|
|
325
|
+
}) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")), L = (e, t) => new Promise((n) => {
|
|
253
326
|
let { mode: r, role: i } = t || {};
|
|
254
327
|
if (r !== "evaluate" && i === "instructor") {
|
|
255
328
|
let { correctResponse: t } = e;
|
|
@@ -258,22 +331,22 @@ var _ = {
|
|
|
258
331
|
id: 1
|
|
259
332
|
});
|
|
260
333
|
} else return n(null);
|
|
261
|
-
}),
|
|
262
|
-
let { categories:
|
|
334
|
+
}), R = (e) => (e || "").replaceAll(/<[^>]*>/g, ""), z = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), B = (e = {}, t = {}) => {
|
|
335
|
+
let { categories: n, choices: i, correctResponse: a, maxAnswerChoices: o } = e, { minChoices: s = 1, minCategories: c = 1, maxCategories: l = 12, maxLengthPerChoice: u = 300, maxLengthPerCategory: d = 150 } = t, f = [...i || []].reverse(), p = {}, m = {}, h = {};
|
|
263
336
|
[
|
|
264
337
|
"teacherInstructions",
|
|
265
338
|
"prompt",
|
|
266
339
|
"rationale"
|
|
267
340
|
].forEach((n) => {
|
|
268
|
-
t[n]?.required && !
|
|
269
|
-
}), (
|
|
341
|
+
t[n]?.required && !z(e[n]) && (p[n] = "This field is required.");
|
|
342
|
+
}), (n || []).forEach((e) => {
|
|
270
343
|
let { id: t, label: n } = e;
|
|
271
|
-
|
|
344
|
+
R(n).length > d && (h[t] = `Category labels should be no more than ${d} characters long.`);
|
|
272
345
|
}), (f || []).forEach((e, t) => {
|
|
273
346
|
let { id: n, content: r } = e;
|
|
274
|
-
|
|
347
|
+
R(r).length > u && (m[n] = `Tokens should be no more than ${u} characters long.`), z(r) ? f.slice(t + 1).some((e) => e.content === r) && (m[n] = "Tokens content should be unique.") : m[n] = "Tokens should not be empty.";
|
|
275
348
|
});
|
|
276
|
-
let g = (
|
|
349
|
+
let g = (n || []).length, _ = (i || []).length;
|
|
277
350
|
if (g > l ? p.categoriesError = `No more than ${l} categories should be defined.` : g < c && (p.categoriesError = `There should be at least ${c} category defined.`), _ < s ? p.choicesError = `There should be at least ${s} choices defined.` : _ > o && (p.choicesError = `No more than ${o} choices should be defined.`), _ && g) {
|
|
278
351
|
let e = !1;
|
|
279
352
|
(a || []).forEach((t) => {
|
|
@@ -285,15 +358,15 @@ var _ = {
|
|
|
285
358
|
let t = -1, n = "";
|
|
286
359
|
(a || []).forEach((e) => {
|
|
287
360
|
let { choices: r = [], alternateResponses: i = [], category: a } = e;
|
|
288
|
-
t === -1 && (t =
|
|
361
|
+
t === -1 && (t = w(r, i), t === -1 && (t = T(i)), n = a);
|
|
289
362
|
}), t > -1 && (p.duplicateAlternate = {
|
|
290
363
|
index: t,
|
|
291
364
|
category: n
|
|
292
365
|
}), e || (p.associationError = "At least one token should be assigned to at least one category.");
|
|
293
366
|
}
|
|
294
|
-
return
|
|
367
|
+
return r(m) || (p.choicesErrors = m), r(h) || (p.categoriesErrors = h), p;
|
|
295
368
|
};
|
|
296
369
|
//#endregion
|
|
297
|
-
export {
|
|
370
|
+
export { L as createCorrectResponseSession, M as createDefaultModel, j as getCorrectness, F as getLogTrace, O as getPartialScore, A as getTotalScore, P as model, N as normalize, I as outcome, c as score, B as validate };
|
|
298
371
|
|
|
299
372
|
//# sourceMappingURL=index.js.map
|