@pie-element/categorize 13.1.2-next.5 → 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.
Files changed (45) hide show
  1. package/dist/author/defaults.d.ts +0 -1
  2. package/dist/author/defaults.js +2 -4
  3. package/dist/author/design/buttons.js +3 -3
  4. package/dist/author/design/categories/alternateResponses.js +2 -2
  5. package/dist/author/design/categories/category.js +2 -2
  6. package/dist/author/design/categories/choice-preview.js +1 -1
  7. package/dist/author/design/categories/droppable-placeholder.js +1 -1
  8. package/dist/author/design/categories/index.js +3 -3
  9. package/dist/author/design/choices/choice.js +2 -2
  10. package/dist/author/design/choices/config.js +1 -1
  11. package/dist/author/design/choices/index.js +3 -3
  12. package/dist/author/design/header.js +1 -1
  13. package/dist/author/design/index.js +78 -68
  14. package/dist/author/design/input-header.js +1 -1
  15. package/dist/author/index.d.ts +0 -1
  16. package/dist/author/index.js +2 -2
  17. package/dist/author/main.js +2 -2
  18. package/dist/author/utils.js +1 -1
  19. package/dist/browser/alert-dialog-BtccZZm9.js +11509 -0
  20. package/dist/browser/alert-dialog-BtccZZm9.js.map +1 -0
  21. package/dist/browser/author/index.js +41841 -834
  22. package/dist/browser/author/index.js.map +1 -1
  23. package/dist/browser/controller/index.js +196 -123
  24. package/dist/browser/controller/index.js.map +1 -1
  25. package/dist/browser/delivery/index.js +294 -293
  26. package/dist/browser/delivery/index.js.map +1 -1
  27. package/dist/browser/{dist-DnGF41FP.js → dist-C11U2GIc.js} +301 -388
  28. package/dist/browser/dist-C11U2GIc.js.map +1 -0
  29. package/dist/browser/rolldown-runtime-CWhphoD1.js +32 -0
  30. package/dist/controller/defaults.d.ts +0 -1
  31. package/dist/controller/defaults.js +2 -4
  32. package/dist/controller/index.d.ts +1 -0
  33. package/dist/controller/index.js +92 -79
  34. package/dist/delivery/categorize/categories.js +3 -3
  35. package/dist/delivery/categorize/category.js +1 -1
  36. package/dist/delivery/categorize/choice.js +1 -1
  37. package/dist/delivery/categorize/choices.js +1 -1
  38. package/dist/delivery/categorize/grid-content.js +1 -1
  39. package/dist/delivery/categorize/index.js +3 -3
  40. package/dist/delivery/index.js +2 -2
  41. package/dist/index.iife.js +33 -33
  42. package/package.json +14 -9
  43. package/dist/browser/dist-7UsF60Ks.js +0 -55705
  44. package/dist/browser/dist-7UsF60Ks.js.map +0 -1
  45. package/dist/browser/dist-DnGF41FP.js.map +0 -1
@@ -1,6 +1,67 @@
1
- import { D as e, E as t, g as n, t as r } from "../dist-DnGF41FP.js";
2
- //#region ../../shared/feedback/dist/index.js
3
- var i = {
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 a(e) {
86
+ function u(e) {
26
87
  return e === "partially-correct" ? "partial" : e;
27
88
  }
28
- function o(e, t = {}) {
89
+ function d(e, t = {}) {
29
90
  return new Promise((n) => {
30
91
  let r = {
31
- ...i,
92
+ ...l,
32
93
  ...t
33
- }, o = a(e), c = r[o], l = i[o];
34
- s(c, l[c.type]).then(n);
94
+ }, i = u(e), a = r[i], o = l[i];
95
+ f(a, o[a.type]).then(n);
35
96
  });
36
97
  }
37
- function s(e, t) {
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 c = Object.defineProperty, l = (e, t) => {
109
+ var p = Object.defineProperty, m = (e, t) => {
49
110
  let n = {};
50
- for (var r in e) c(n, r, {
111
+ for (var r in e) p(n, r, {
51
112
  get: e[r],
52
113
  enumerable: !0
53
114
  });
54
- return t || c(n, Symbol.toStringTag, { value: "Module" }), n;
115
+ return t || p(n, Symbol.toStringTag, { value: "Module" }), n;
55
116
  };
56
- function u(e) {
117
+ function h(e) {
57
118
  return Array.isArray(e) ? e.filter((e) => e != null) : [];
58
119
  }
59
- function d(e) {
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 f(e) {
68
- return e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.keys(e).length === 0 : !1;
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 p(e, t, n, r = "value") {
71
- let i = u(t?.data?.shuffledValues ?? t?.shuffledValues ?? []);
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 (!f(i)) return u(i.map((t) => e.find((e) => e[r] === t)));
77
- let a = d(e);
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 = u(a.map((e) => e[r]));
80
- f(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 });
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 m(e, t, n) {
148
+ function y(e, t, n) {
88
149
  return !!(e.lockChoiceOrder || n["@pie-element"]?.lockChoiceOrder || (n.role ?? "student") === "instructor");
89
150
  }
90
- var h = /* @__PURE__ */ l({ enabled: () => g });
91
- function g(e, t, n) {
92
- return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n == "boolean" ? n : !0;
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/utils.ts
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
- }, v = (e, t) => {
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
- }, y = (e) => {
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
- }, b = (e, t, n) => {
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
- }, x = {
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
- }, w = (e) => e.map((e) => e.alternateResponses).filter((e) => e), T = (e, t, n) => {
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: i, choices: a } = e || {}, { correctResponse: o } = e || {}, { answers: s } = t || {};
222
+ let { categories: r, choices: a } = e || {}, { correctResponse: o } = e || {}, { answers: s } = t || {};
163
223
  s ||= [], o ||= [];
164
- let { categories: c, correct: l } = r(i, a, s, o), u = w(o);
165
- return h.enabled(e, n) && !u.length ? C(o, c) : +!!l;
166
- }, E = (e, t, n) => new Promise((r) => {
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 = T(e, t, n);
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
- }), D = (e = {}) => new Promise((t) => {
231
+ }), M = (e = {}) => new Promise((t) => {
172
232
  t({
173
- ...x,
233
+ ...S,
174
234
  ...e
175
235
  });
176
- }), O = (e) => ({
177
- ...x,
236
+ }), N = (e) => ({
237
+ ...S,
178
238
  ...e
179
- }), k = async (e, t, n, r) => {
180
- let i = O(e), a = await E(i, t, n), { mode: s, role: c } = n || {}, { categories: l, categoriesPerRow: u, choicesLabel: d, choicesPosition: f, correctResponse: h, feedback: g, feedbackEnabled: _, promptEnabled: v, prompt: y, rowLabels: x, rationaleEnabled: C, rationale: T, teacherInstructionsEnabled: D, teacherInstructions: k, language: A, maxChoicesPerCategory: j, extraCSSRules: M, minRowHeight: N, fontSizeFactor: P, autoplayAudioEnabled: F, completeAudioEnabled: I, customAudioButton: L } = i, { choices: R, note: z } = i, B, V = m(i, t, n), H = h.map((e) => {
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
- s === "evaluate" && _ && (B = await o(a, g)), V || (R = await p(R, t, r, "id")), z ||= S.t("common:commonCorrectAnswerWithAlternates", { lng: A });
188
- let U = w(H), { responseAreasToBeFilled: W, possibleResponses: G, hasUnplacedChoices: K } = b(H, i.allowAlternateEnabled ? U : [], i.choices), q = {
189
- categories: l || [],
190
- categoriesPerRow: u || 2,
191
- maxChoicesPerCategory: j,
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: R || [],
194
- choicesLabel: d || "",
265
+ choices: z || [],
266
+ choicesLabel: u || "",
195
267
  choicesPosition: f,
196
- disabled: s !== "gather",
197
- feedback: B,
198
- lockChoiceOrder: V,
199
- prompt: v ? y : null,
200
- rowLabels: x,
201
- note: z,
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: U && U.length > 0,
204
- correctResponse: s === "evaluate" ? H : void 0,
205
- language: A,
275
+ showNote: G && G.length > 0,
276
+ correctResponse: o === "evaluate" ? U : void 0,
277
+ language: O,
206
278
  extraCSSRules: M,
207
- fontSizeFactor: P,
208
- minRowHeight: N,
209
- autoplayAudioEnabled: F,
210
- completeAudioEnabled: I,
211
- customAudioButton: L,
212
- possibleResponses: G,
213
- responseAreasToBeFilled: W,
214
- hasUnplacedChoices: K
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 c === "instructor" && (s === "view" || s === "evaluate") ? (q.rationale = C ? T : null, q.teacherInstructions = D ? k : null) : (q.rationale = null, q.teacherInstructions = null), q;
217
- }, A = (e, t, n) => {
218
- let i = [], { answers: a } = t || {}, { categories: o, choices: s, correctResponse: c } = e || {}, l = a.reduce((e, t) => e + (t.choices?.length || 0), 0), u = w(c).length > 0, d = h.enabled(e, n), f = (l > 0 ? r(o, s, a, c) : null)?.categories || [];
219
- if (l > 0 ? (i.push(`Student placed ${l} choice(s) into categories.`), (o || []).forEach((e, t) => {
220
- let n = e.id, r = f.find((e) => e.id === n), a = r && r.choices || [], o = (c || []).find((e) => e.category === n), s = o && o.choices || [];
221
- if (s.length > 0) if (a.length === 0) i.push(`Category ${n}: student left empty (should contain ${s.length} choice(s)).`);
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 = a.filter((e) => e.correct).length, t = a.length - e;
224
- e > 0 && t === 0 ? i.push(`Category ${n}: student placed ${e} correct choice(s).`) : e === 0 && t > 0 ? i.push(`Category ${n}: student placed ${t} incorrect choice(s).`) : i.push(`Category ${n}: student placed ${e} correct and ${t} incorrect choice(s).`);
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
- })) : i.push("Student did not place any choices into categories."), u && i.push("Alternate response combinations are accepted for this question."), u) i.push("Score calculated using all-or-nothing scoring (alternate responses disable partial scoring)."), i.push("Student must get all categories completely correct to receive full credit.");
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 (i.push("Score calculated using partial scoring."), i.push("Student receives credit for each correct placement, with deductions for incorrect placements beyond required amount."), l > 0) {
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 (i.push(`Partial scoring calculation: ${e} correct placements, ${t} incorrect placements.`), l > n) {
303
+ if (r.push(`Partial scoring calculation: ${e} correct placements, ${t} incorrect placements.`), l > n) {
231
304
  let e = l - n;
232
- i.push(`${e} extra placement(s) beyond required amount will be deducted from score.`);
305
+ r.push(`${e} extra placement(s) beyond required amount will be deducted from score.`);
233
306
  }
234
307
  }
235
- } else i.push("Score calculated using all-or-nothing scoring."), i.push("Student must get all categories completely correct to receive full credit.");
236
- let p = T(e, t, n);
237
- return i.push(`Final score: ${p}.`), i;
238
- }, j = (e, t, r) => r.mode === "evaluate" ? new Promise((i) => {
239
- if (!t || n(t)) i({
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 n = A(e, t, r);
318
+ let r = F(e, t, n);
246
319
  i({
247
- score: T(e, t, r),
320
+ score: A(e, t, n),
248
321
  empty: !1,
249
- traceLog: n
322
+ traceLog: r
250
323
  });
251
324
  }
252
- }) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")), M = (e, t) => new Promise((n) => {
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
- }), N = (e) => (e || "").replaceAll(/<[^>]*>/g, ""), P = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), F = (e = {}, t = {}) => {
262
- let { categories: r, 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 = {};
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 && !P(e[n]) && (p[n] = "This field is required.");
269
- }), (r || []).forEach((e) => {
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
- N(n).length > d && (h[t] = `Category labels should be no more than ${d} characters long.`);
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
- N(r).length > u && (m[n] = `Tokens should be no more than ${u} characters long.`), P(r) ? f.slice(t + 1).some((e) => e.content === r) && (m[n] = "Tokens content should be unique.") : m[n] = "Tokens should not be empty.";
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 = (r || []).length, _ = (i || []).length;
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 = v(r, i), t === -1 && (t = y(i)), n = a);
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 n(m) || (p.choicesErrors = m), n(h) || (p.categoriesErrors = h), p;
367
+ return r(m) || (p.choicesErrors = m), r(h) || (p.categoriesErrors = h), p;
295
368
  };
296
369
  //#endregion
297
- export { M as createCorrectResponseSession, D as createDefaultModel, E as getCorrectness, A as getLogTrace, C as getPartialScore, T as getTotalScore, k as model, O as normalize, j as outcome, t as score, F as validate };
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