@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.
- 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 +14 -9
- 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
package/dist/controller/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import r from "./
|
|
3
|
-
import { buildState as
|
|
4
|
-
import
|
|
5
|
-
import { isEmpty as
|
|
6
|
-
import { getFeedbackForCorrectness as
|
|
7
|
-
import { getShuffledChoices as
|
|
1
|
+
import e from "./defaults.js";
|
|
2
|
+
import { getCompleteResponseDetails as t, isAlternateDuplicated as n, isCorrectResponseDuplicated as r, multiplePlacements as i } from "./utils.js";
|
|
3
|
+
import { buildState as a, score as o } from "@pie-lib/categorize";
|
|
4
|
+
import s from "@pie-lib/translator";
|
|
5
|
+
import { isEmpty as c } from "@pie-element/shared-lodash";
|
|
6
|
+
import { getFeedbackForCorrectness as l } from "@pie-element/shared-feedback";
|
|
7
|
+
import { getShuffledChoices as u, lockChoices as d, partialScoring as f } from "@pie-element/shared-controller-utils";
|
|
8
8
|
//#region src/controller/index.ts
|
|
9
|
-
var { translator:
|
|
9
|
+
var { translator: p } = s, m = (e, t) => {
|
|
10
10
|
let { placements: n, score: r } = t.reduce((e, { choices: t = [] }) => ({
|
|
11
11
|
placements: e.placements + t.length,
|
|
12
12
|
score: e.score + t.filter((e) => e.correct).length
|
|
@@ -15,74 +15,87 @@ var { translator: f } = o, p = (e, t) => {
|
|
|
15
15
|
score: 0
|
|
16
16
|
}), { maxScore: i } = e.reduce((e, { choices: t }) => ({ maxScore: e.maxScore + t.length }), { maxScore: 0 }), a = (r - (n > i ? n - i : 0)) / i;
|
|
17
17
|
return a < 0 ? 0 : parseFloat(a.toFixed(2));
|
|
18
|
-
},
|
|
18
|
+
}, h = (e) => e.map((e) => e.alternateResponses).filter((e) => e), g = (e, t, n) => {
|
|
19
19
|
if (!t || Object.keys(t).length === 0) return 0;
|
|
20
|
-
let { categories: r, choices:
|
|
20
|
+
let { categories: r, choices: i } = e || {}, { correctResponse: o } = e || {}, { answers: s } = t || {};
|
|
21
21
|
s ||= [], o ||= [];
|
|
22
|
-
let { categories: c, correct: l } =
|
|
23
|
-
return
|
|
24
|
-
},
|
|
22
|
+
let { categories: c, correct: l } = a(r, i, s, o), u = h(o);
|
|
23
|
+
return f.enabled(e, n) && !u.length ? m(o, c) : +!!l;
|
|
24
|
+
}, _ = (e, t, n) => new Promise((r) => {
|
|
25
25
|
if (n.mode === "evaluate") {
|
|
26
|
-
let i =
|
|
26
|
+
let i = g(e, t, n);
|
|
27
27
|
r(i === 1 ? "correct" : i === 0 ? "incorrect" : "partially-correct");
|
|
28
28
|
} else r(void 0);
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
...
|
|
32
|
-
...
|
|
29
|
+
}), v = (t = {}) => new Promise((n) => {
|
|
30
|
+
n({
|
|
31
|
+
...e,
|
|
32
|
+
...t
|
|
33
33
|
});
|
|
34
|
-
}),
|
|
35
|
-
...
|
|
36
|
-
...
|
|
37
|
-
}),
|
|
38
|
-
let
|
|
34
|
+
}), y = (t) => ({
|
|
35
|
+
...e,
|
|
36
|
+
...t
|
|
37
|
+
}), b = async (e, n, r, a) => {
|
|
38
|
+
let o = y(e), s = await _(o, n, r), { mode: c, role: f } = r || {}, { categories: m, categoriesPerRow: g, choicesLabel: v, choicesPosition: b, correctResponse: x, feedback: S, feedbackEnabled: C, promptEnabled: w, prompt: T, rowLabels: E, rationaleEnabled: D, rationale: O, teacherInstructionsEnabled: k, teacherInstructions: A, language: j, maxChoicesPerCategory: M, extraCSSRules: N, minRowHeight: P, fontSizeFactor: F, autoplayAudioEnabled: I, completeAudioEnabled: L, customAudioButton: R } = o, { choices: z, note: B } = o, V, H = d(o, n, r), U = x.map((e) => {
|
|
39
39
|
let t = (e.choices || []).filter((e) => e !== "null");
|
|
40
40
|
return {
|
|
41
41
|
...e,
|
|
42
42
|
choices: t
|
|
43
43
|
};
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
c === "evaluate" && C && (V = await l(s, S)), H || (z = await u(z, n, a, "id"));
|
|
46
|
+
let W = (() => {
|
|
47
|
+
if (e.allowMultiplePlacementsEnabled != null) return e.allowMultiplePlacementsEnabled;
|
|
48
|
+
let t = (x || []).flatMap((e) => e.choices || []);
|
|
49
|
+
return t.length === new Set(t).size ? i.disabled : i.enabled;
|
|
50
|
+
})();
|
|
51
|
+
z = (z || []).map((e) => {
|
|
52
|
+
let t;
|
|
53
|
+
return t = W === i.enabled ? 0 : W === i.disabled ? 1 : e.categoryCount || 0, {
|
|
54
|
+
...e,
|
|
55
|
+
categoryCount: t
|
|
56
|
+
};
|
|
57
|
+
}), B ||= p.t("common:commonCorrectAnswerWithAlternates", { lng: j });
|
|
58
|
+
let G = h(U), { responseAreasToBeFilled: K, possibleResponses: q, hasUnplacedChoices: J } = t(U, o.allowAlternateEnabled ? G : [], o.choices), Y = {
|
|
59
|
+
categories: m || [],
|
|
60
|
+
categoriesPerRow: g || 2,
|
|
61
|
+
maxChoicesPerCategory: M,
|
|
62
|
+
correctness: s,
|
|
63
|
+
choices: z || [],
|
|
64
|
+
choicesLabel: v || "",
|
|
65
|
+
choicesPosition: b,
|
|
66
|
+
disabled: c !== "gather",
|
|
67
|
+
feedback: V,
|
|
68
|
+
lockChoiceOrder: H,
|
|
69
|
+
prompt: w ? T : null,
|
|
70
|
+
rowLabels: E,
|
|
71
|
+
note: B,
|
|
60
72
|
env: r,
|
|
61
|
-
showNote:
|
|
62
|
-
correctResponse:
|
|
63
|
-
language:
|
|
64
|
-
extraCSSRules:
|
|
65
|
-
fontSizeFactor:
|
|
66
|
-
minRowHeight:
|
|
67
|
-
autoplayAudioEnabled:
|
|
68
|
-
completeAudioEnabled:
|
|
69
|
-
customAudioButton:
|
|
70
|
-
possibleResponses:
|
|
71
|
-
responseAreasToBeFilled:
|
|
72
|
-
hasUnplacedChoices:
|
|
73
|
+
showNote: G && G.length > 0,
|
|
74
|
+
correctResponse: c === "evaluate" ? U : void 0,
|
|
75
|
+
language: j,
|
|
76
|
+
extraCSSRules: N,
|
|
77
|
+
fontSizeFactor: F,
|
|
78
|
+
minRowHeight: P,
|
|
79
|
+
autoplayAudioEnabled: I,
|
|
80
|
+
completeAudioEnabled: L,
|
|
81
|
+
customAudioButton: R,
|
|
82
|
+
possibleResponses: q,
|
|
83
|
+
responseAreasToBeFilled: K,
|
|
84
|
+
hasUnplacedChoices: J,
|
|
85
|
+
...e.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: W }
|
|
73
86
|
};
|
|
74
|
-
return
|
|
75
|
-
},
|
|
76
|
-
let r = [], { answers:
|
|
77
|
-
if (l > 0 ? (r.push(`Student placed ${l} choice(s) into categories.`), (o || []).forEach((e
|
|
78
|
-
let
|
|
79
|
-
if (
|
|
87
|
+
return f === "instructor" && (c === "view" || c === "evaluate") ? (Y.rationale = D ? O : null, Y.teacherInstructions = k ? A : null) : (Y.rationale = null, Y.teacherInstructions = null), Y;
|
|
88
|
+
}, x = (e, t, n) => {
|
|
89
|
+
let r = [], { answers: i } = t || {}, { categories: o, choices: s, correctResponse: c } = e || {}, l = i.reduce((e, t) => e + (t.choices?.length || 0), 0), u = h(c).length > 0, d = f.enabled(e, n), p = (l > 0 ? a(o, s, i, c) : null)?.categories || [];
|
|
90
|
+
if (l > 0 ? (r.push(`Student placed ${l} choice(s) into categories.`), (o || []).forEach((e) => {
|
|
91
|
+
let t = e.id, n = p.find((e) => e.id === t), i = n && n.choices || [], a = (c || []).find((e) => e.category === t), o = a && a.choices || [];
|
|
92
|
+
if (o.length > 0) if (i.length === 0) r.push(`Category ${t}: student left empty (should contain ${o.length} choice(s)).`);
|
|
80
93
|
else {
|
|
81
|
-
let e =
|
|
82
|
-
e > 0 &&
|
|
94
|
+
let e = i.filter((e) => e.correct).length, n = i.length - e;
|
|
95
|
+
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).`);
|
|
83
96
|
}
|
|
84
97
|
})) : 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.");
|
|
85
|
-
else if (
|
|
98
|
+
else if (d) {
|
|
86
99
|
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) {
|
|
87
100
|
let e = p.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);
|
|
88
101
|
if (r.push(`Partial scoring calculation: ${e} correct placements, ${t} incorrect placements.`), l > n) {
|
|
@@ -91,23 +104,23 @@ var { translator: f } = o, p = (e, t) => {
|
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
106
|
} else r.push("Score calculated using all-or-nothing scoring."), r.push("Student must get all categories completely correct to receive full credit.");
|
|
94
|
-
let
|
|
95
|
-
return r.push(`Final score: ${
|
|
96
|
-
},
|
|
97
|
-
if (!t ||
|
|
107
|
+
let m = g(e, t, n);
|
|
108
|
+
return r.push(`Final score: ${m}.`), r;
|
|
109
|
+
}, S = (e, t, n) => n.mode === "evaluate" ? new Promise((r) => {
|
|
110
|
+
if (!t || c(t)) r({
|
|
98
111
|
score: 0,
|
|
99
112
|
empty: !0,
|
|
100
113
|
traceLog: ["Student did not place any choices into categories. Score is 0."]
|
|
101
114
|
});
|
|
102
115
|
else {
|
|
103
|
-
let i =
|
|
116
|
+
let i = x(e, t, n);
|
|
104
117
|
r({
|
|
105
|
-
score:
|
|
118
|
+
score: g(e, t, n),
|
|
106
119
|
empty: !1,
|
|
107
120
|
traceLog: i
|
|
108
121
|
});
|
|
109
122
|
}
|
|
110
|
-
}) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")),
|
|
123
|
+
}) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")), C = (e, t) => new Promise((n) => {
|
|
111
124
|
let { mode: r, role: i } = t || {};
|
|
112
125
|
if (r !== "evaluate" && i === "instructor") {
|
|
113
126
|
let { correctResponse: t } = e;
|
|
@@ -116,23 +129,23 @@ var { translator: f } = o, p = (e, t) => {
|
|
|
116
129
|
id: 1
|
|
117
130
|
});
|
|
118
131
|
} else return n(null);
|
|
119
|
-
}),
|
|
120
|
-
let { categories: i, choices: a, correctResponse: o, maxAnswerChoices:
|
|
132
|
+
}), w = (e) => (e || "").replaceAll(/<[^>]*>/g, ""), T = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), E = (e = {}, t = {}) => {
|
|
133
|
+
let { categories: i, choices: a, correctResponse: o, maxAnswerChoices: s } = e, { minChoices: l = 1, minCategories: u = 1, maxCategories: d = 12, maxLengthPerChoice: f = 300, maxLengthPerCategory: p = 150 } = t, m = [...a || []].reverse(), h = {}, g = {}, _ = {};
|
|
121
134
|
[
|
|
122
135
|
"teacherInstructions",
|
|
123
136
|
"prompt",
|
|
124
137
|
"rationale"
|
|
125
|
-
].forEach((
|
|
126
|
-
|
|
138
|
+
].forEach((n) => {
|
|
139
|
+
t[n]?.required && !T(e[n]) && (h[n] = "This field is required.");
|
|
127
140
|
}), (i || []).forEach((e) => {
|
|
128
141
|
let { id: t, label: n } = e;
|
|
129
|
-
|
|
142
|
+
w(n).length > p && (_[t] = `Category labels should be no more than ${p} characters long.`);
|
|
130
143
|
}), (m || []).forEach((e, t) => {
|
|
131
144
|
let { id: n, content: r } = e;
|
|
132
|
-
|
|
145
|
+
w(r).length > f && (g[n] = `Tokens should be no more than ${f} characters long.`), T(r) ? m.slice(t + 1).some((e) => e.content === r) && (g[n] = "Tokens content should be unique.") : g[n] = "Tokens should not be empty.";
|
|
133
146
|
});
|
|
134
147
|
let v = (i || []).length, y = (a || []).length;
|
|
135
|
-
if (v > d ? h.categoriesError = `No more than ${d} categories should be defined.` : v < u && (h.categoriesError = `There should be at least ${u} category defined.`), y < l ? h.choicesError = `There should be at least ${l} choices defined.` : y >
|
|
148
|
+
if (v > d ? h.categoriesError = `No more than ${d} categories should be defined.` : v < u && (h.categoriesError = `There should be at least ${u} category defined.`), y < l ? h.choicesError = `There should be at least ${l} choices defined.` : y > s && (h.choicesError = `No more than ${s} choices should be defined.`), y && v) {
|
|
136
149
|
let e = !1;
|
|
137
150
|
(o || []).forEach((t) => {
|
|
138
151
|
let { choices: n = [], alternateResponses: r = [] } = t;
|
|
@@ -140,16 +153,16 @@ var { translator: f } = o, p = (e, t) => {
|
|
|
140
153
|
(t || []).length && (e = !0);
|
|
141
154
|
});
|
|
142
155
|
});
|
|
143
|
-
let
|
|
156
|
+
let t = -1, i = "";
|
|
144
157
|
(o || []).forEach((e) => {
|
|
145
158
|
let { choices: a = [], alternateResponses: o = [], category: s } = e;
|
|
146
|
-
|
|
147
|
-
}),
|
|
148
|
-
index:
|
|
159
|
+
t === -1 && (t = r(a, o), t === -1 && (t = n(o)), i = s);
|
|
160
|
+
}), t > -1 && (h.duplicateAlternate = {
|
|
161
|
+
index: t,
|
|
149
162
|
category: i
|
|
150
163
|
}), e || (h.associationError = "At least one token should be assigned to at least one category.");
|
|
151
164
|
}
|
|
152
|
-
return
|
|
165
|
+
return c(g) || (h.choicesErrors = g), c(_) || (h.categoriesErrors = _), h;
|
|
153
166
|
};
|
|
154
167
|
//#endregion
|
|
155
|
-
export {
|
|
168
|
+
export { C as createCorrectResponseSession, v as createDefaultModel, _ as getCorrectness, x as getLogTrace, m as getPartialScore, g as getTotalScore, b as model, y as normalize, S as outcome, o as score, E as validate };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import e from "./grid-content.js";
|
|
2
|
-
import t,
|
|
1
|
+
import { GridContent as e } from "./grid-content.js";
|
|
2
|
+
import { Category as t, CategoryType as n } from "./category.js";
|
|
3
3
|
import r from "react";
|
|
4
4
|
import { color as i } from "@pie-lib/render-ui";
|
|
5
5
|
import a from "prop-types";
|
|
@@ -63,4 +63,4 @@ var l = class extends r.Component {
|
|
|
63
63
|
flexDirection: "column"
|
|
64
64
|
});
|
|
65
65
|
//#endregion
|
|
66
|
-
export { l as default };
|
|
66
|
+
export { l as Categories, l as default, n as CategoryType };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import e from "./choice.js";
|
|
2
|
-
import t from "./choices.js";
|
|
3
|
-
import n from "./categories.js";
|
|
2
|
+
import { Choices as t } from "./choices.js";
|
|
3
|
+
import { Categories as n } from "./categories.js";
|
|
4
4
|
import r from "react";
|
|
5
5
|
import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
|
|
6
6
|
import * as a from "@pie-lib/render-ui";
|
|
@@ -257,4 +257,4 @@ var k = O(l, "UiLayout") || O(F.UiLayout, "UiLayout"), A = O(c, "PreviewPrompt")
|
|
|
257
257
|
flexDirection: "column"
|
|
258
258
|
})), W = h(j)(({ theme: e }) => ({ paddingBottom: e.spacing(2) }));
|
|
259
259
|
//#endregion
|
|
260
|
-
export { B as default };
|
|
260
|
+
export { z as Categorize, B as default };
|
package/dist/delivery/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var u = l(a, "EnableAudioAutoplayImage") || l(p.EnableAudioAutoplayImage, "Enabl
|
|
|
55
55
|
isComplete() {
|
|
56
56
|
let { autoplayAudioEnabled: e, choices: t, completeAudioEnabled: n, hasUnplacedChoices: r, possibleResponses: i, responseAreasToBeFilled: a } = this._model || {}, o = this;
|
|
57
57
|
if (e && n && !this.audioComplete && o) {
|
|
58
|
-
let e = o.querySelector("audio"), t = e && e.closest("
|
|
58
|
+
let e = o.querySelector("audio"), t = e && e.closest(".preview-prompt");
|
|
59
59
|
if (e && t) return !1;
|
|
60
60
|
}
|
|
61
61
|
if (!this._session || !this._session.answers) return !1;
|
|
@@ -104,7 +104,7 @@ var u = l(a, "EnableAudioAutoplayImage") || l(p.EnableAudioAutoplayImage, "Enabl
|
|
|
104
104
|
e.forEach((e) => {
|
|
105
105
|
if (e.type === "childList") {
|
|
106
106
|
if (this._audioInitialized) return;
|
|
107
|
-
let e = this.querySelector("audio"), n = e && e.closest("
|
|
107
|
+
let e = this.querySelector("audio"), n = e && e.closest(".preview-prompt");
|
|
108
108
|
if (!this._model || !this._model.autoplayAudioEnabled || e && !n || !e) return;
|
|
109
109
|
let r = this._createAudioInfoToast(), i = this.querySelector("#main-container"), a = () => {
|
|
110
110
|
this.querySelector("#play-audio-info") && (e.play(), i.removeChild(r)), document.removeEventListener("click", a);
|