@pie-element/categorize 13.4.0-beta.7 → 14.0.0-next.20261002094057

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 (215) hide show
  1. package/author.js +2 -0
  2. package/configure.js +2 -0
  3. package/controller.js +1 -0
  4. package/dist/author/defaults.d.ts +222 -0
  5. package/dist/author/defaults.js +168 -0
  6. package/dist/author/design/builder.d.ts +10 -0
  7. package/dist/author/design/builder.js +24 -0
  8. package/dist/author/design/buttons.d.ts +28 -0
  9. package/dist/author/design/buttons.js +36 -0
  10. package/dist/author/design/categories/RowLabel.d.ts +23 -0
  11. package/dist/author/design/categories/RowLabel.js +47 -0
  12. package/dist/author/design/categories/alternateResponses.d.ts +31 -0
  13. package/dist/author/design/categories/alternateResponses.js +62 -0
  14. package/dist/author/design/categories/category.d.ts +44 -0
  15. package/dist/author/design/categories/category.js +98 -0
  16. package/dist/author/design/categories/choice-preview.d.ts +25 -0
  17. package/dist/author/design/categories/choice-preview.js +60 -0
  18. package/dist/author/design/categories/droppable-placeholder.d.ts +11 -0
  19. package/dist/author/design/categories/droppable-placeholder.js +71 -0
  20. package/dist/author/design/categories/index.d.ts +41 -0
  21. package/dist/author/design/categories/index.js +146 -0
  22. package/dist/author/design/choices/choice.d.ts +11 -0
  23. package/dist/author/design/choices/choice.js +129 -0
  24. package/dist/author/design/choices/config.d.ts +21 -0
  25. package/dist/author/design/choices/config.js +33 -0
  26. package/dist/author/design/choices/index.d.ts +41 -0
  27. package/dist/author/design/choices/index.js +110 -0
  28. package/dist/author/design/header.d.ts +24 -0
  29. package/dist/author/design/header.js +49 -0
  30. package/dist/author/design/index.d.ts +52 -0
  31. package/dist/author/design/index.js +427 -0
  32. package/dist/author/design/input-header.d.ts +39 -0
  33. package/dist/author/design/input-header.js +69 -0
  34. package/dist/author/design/utils.d.ts +9 -0
  35. package/dist/author/design/utils.js +7 -0
  36. package/dist/author/index.d.ts +50 -0
  37. package/dist/author/index.js +87 -0
  38. package/dist/author/main.d.ts +23 -0
  39. package/dist/author/main.js +30 -0
  40. package/dist/author/utils.d.ts +16 -0
  41. package/dist/author/utils.js +17 -0
  42. package/dist/browser/alert-dialog-DjezK_ch.js +11690 -0
  43. package/dist/browser/alert-dialog-DjezK_ch.js.map +1 -0
  44. package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
  45. package/dist/browser/author/index.js +35706 -0
  46. package/dist/browser/author/index.js.map +1 -0
  47. package/dist/browser/controller/index.js +372 -0
  48. package/dist/browser/controller/index.js.map +1 -0
  49. package/dist/browser/delivery/index.js +1220 -0
  50. package/dist/browser/delivery/index.js.map +1 -0
  51. package/dist/browser/dist-Denz71xw.js +1973 -0
  52. package/dist/browser/dist-Denz71xw.js.map +1 -0
  53. package/dist/browser/editor-runtime/alert-dialog-DegUZr32.js +11690 -0
  54. package/dist/browser/editor-runtime/alert-dialog-DegUZr32.js.map +1 -0
  55. package/dist/browser/editor-runtime/assets/Symbola-4c507403.woff2 +0 -0
  56. package/dist/browser/editor-runtime/author/index.js +19297 -0
  57. package/dist/browser/editor-runtime/author/index.js.map +1 -0
  58. package/dist/browser/editor-runtime/controller/index.js +372 -0
  59. package/dist/browser/editor-runtime/controller/index.js.map +1 -0
  60. package/dist/browser/editor-runtime/delivery/index.js +1220 -0
  61. package/dist/browser/editor-runtime/delivery/index.js.map +1 -0
  62. package/dist/browser/editor-runtime/dist-BiRlv37L.js +1973 -0
  63. package/dist/browser/editor-runtime/dist-BiRlv37L.js.map +1 -0
  64. package/dist/browser/editor-runtime/rolldown-runtime-CHQKHQ89.js +32 -0
  65. package/dist/browser/rolldown-runtime-CWhphoD1.js +32 -0
  66. package/dist/controller/defaults.d.ts +33 -0
  67. package/dist/controller/defaults.js +27 -0
  68. package/dist/controller/index.d.ts +62 -0
  69. package/dist/controller/index.js +168 -0
  70. package/dist/controller/utils.d.ts +20 -0
  71. package/dist/controller/utils.js +35 -0
  72. package/dist/delivery/categorize/__tests__/categories.test.d.ts +1 -0
  73. package/dist/delivery/categorize/__tests__/category.test.d.ts +1 -0
  74. package/dist/delivery/categorize/__tests__/choice.test.d.ts +1 -0
  75. package/dist/delivery/categorize/__tests__/choices.test.d.ts +1 -0
  76. package/dist/delivery/categorize/__tests__/droppable-placeholder.test.d.ts +1 -0
  77. package/dist/delivery/categorize/__tests__/grid-content.test.d.ts +1 -0
  78. package/dist/delivery/categorize/__tests__/index.test.d.ts +1 -0
  79. package/dist/delivery/categorize/__tests__/keyboard-coordinates.test.d.ts +1 -0
  80. package/dist/delivery/categorize/categories.d.ts +37 -0
  81. package/dist/delivery/categorize/categories.js +72 -0
  82. package/dist/delivery/categorize/category.d.ts +31 -0
  83. package/dist/delivery/categorize/category.js +55 -0
  84. package/dist/delivery/categorize/choice.d.ts +28 -0
  85. package/dist/delivery/categorize/choice.js +114 -0
  86. package/dist/delivery/categorize/choices.d.ts +42 -0
  87. package/dist/delivery/categorize/choices.js +58 -0
  88. package/dist/delivery/categorize/droppable-placeholder.d.ts +36 -0
  89. package/dist/delivery/categorize/droppable-placeholder.js +77 -0
  90. package/dist/delivery/categorize/grid-content.d.ts +25 -0
  91. package/dist/delivery/categorize/grid-content.js +39 -0
  92. package/dist/delivery/categorize/index.d.ts +70 -0
  93. package/dist/delivery/categorize/index.js +323 -0
  94. package/dist/delivery/categorize/keyboard-coordinates.d.ts +22 -0
  95. package/dist/delivery/categorize/keyboard-coordinates.js +49 -0
  96. package/dist/delivery/index.d.ts +27 -0
  97. package/dist/delivery/index.js +154 -0
  98. package/dist/index.d.ts +1 -0
  99. package/dist/index.iife.d.ts +8 -0
  100. package/dist/index.iife.js +152 -0
  101. package/dist/index.js +2 -0
  102. package/dist/runtime-support.d.ts +12 -0
  103. package/dist/runtime-support.js +12 -0
  104. package/package.json +96 -23
  105. package/CHANGELOG.json +0 -1637
  106. package/CHANGELOG.md +0 -2591
  107. package/LICENSE.md +0 -5
  108. package/README.md +0 -5
  109. package/configure/CHANGELOG.json +0 -1202
  110. package/configure/CHANGELOG.md +0 -2170
  111. package/configure/lib/__tests__/main.test.js +0 -100
  112. package/configure/lib/__tests__/utils.js +0 -39
  113. package/configure/lib/defaults.js +0 -220
  114. package/configure/lib/defaults.js.map +0 -1
  115. package/configure/lib/design/__tests__/builder.test.js +0 -34
  116. package/configure/lib/design/__tests__/buttons.test.js +0 -36
  117. package/configure/lib/design/__tests__/header.test.js +0 -37
  118. package/configure/lib/design/__tests__/index.test.js +0 -269
  119. package/configure/lib/design/__tests__/input-header.test.js +0 -41
  120. package/configure/lib/design/builder.js +0 -55
  121. package/configure/lib/design/builder.js.map +0 -1
  122. package/configure/lib/design/buttons.js +0 -59
  123. package/configure/lib/design/buttons.js.map +0 -1
  124. package/configure/lib/design/categories/RowLabel.js +0 -66
  125. package/configure/lib/design/categories/RowLabel.js.map +0 -1
  126. package/configure/lib/design/categories/__tests__/alternateResponses.test.js +0 -93
  127. package/configure/lib/design/categories/__tests__/category.test.js +0 -65
  128. package/configure/lib/design/categories/__tests__/choice-preview.test.js +0 -52
  129. package/configure/lib/design/categories/__tests__/droppable-placeholder.test.js +0 -63
  130. package/configure/lib/design/categories/__tests__/index.test.js +0 -91
  131. package/configure/lib/design/categories/alternateResponses.js +0 -116
  132. package/configure/lib/design/categories/alternateResponses.js.map +0 -1
  133. package/configure/lib/design/categories/category.js +0 -153
  134. package/configure/lib/design/categories/category.js.map +0 -1
  135. package/configure/lib/design/categories/choice-preview.js +0 -79
  136. package/configure/lib/design/categories/choice-preview.js.map +0 -1
  137. package/configure/lib/design/categories/droppable-placeholder.js +0 -93
  138. package/configure/lib/design/categories/droppable-placeholder.js.map +0 -1
  139. package/configure/lib/design/categories/index.js +0 -256
  140. package/configure/lib/design/categories/index.js.map +0 -1
  141. package/configure/lib/design/choices/__tests__/choice.test.js +0 -62
  142. package/configure/lib/design/choices/__tests__/config.test.js +0 -66
  143. package/configure/lib/design/choices/__tests__/index.test.js +0 -70
  144. package/configure/lib/design/choices/choice.js +0 -187
  145. package/configure/lib/design/choices/choice.js.map +0 -1
  146. package/configure/lib/design/choices/config.js +0 -58
  147. package/configure/lib/design/choices/config.js.map +0 -1
  148. package/configure/lib/design/choices/index.js +0 -197
  149. package/configure/lib/design/choices/index.js.map +0 -1
  150. package/configure/lib/design/header.js +0 -71
  151. package/configure/lib/design/header.js.map +0 -1
  152. package/configure/lib/design/index.js +0 -741
  153. package/configure/lib/design/index.js.map +0 -1
  154. package/configure/lib/design/input-header.js +0 -105
  155. package/configure/lib/design/input-header.js.map +0 -1
  156. package/configure/lib/design/utils.js +0 -12
  157. package/configure/lib/design/utils.js.map +0 -1
  158. package/configure/lib/index.js +0 -148
  159. package/configure/lib/index.js.map +0 -1
  160. package/configure/lib/main.js +0 -44
  161. package/configure/lib/main.js.map +0 -1
  162. package/configure/lib/utils.js +0 -43
  163. package/configure/lib/utils.js.map +0 -1
  164. package/configure/package.json +0 -32
  165. package/controller/CHANGELOG.json +0 -452
  166. package/controller/CHANGELOG.md +0 -1424
  167. package/controller/lib/__tests__/index.test.js +0 -526
  168. package/controller/lib/defaults.js +0 -31
  169. package/controller/lib/defaults.js.map +0 -1
  170. package/controller/lib/index.js +0 -506
  171. package/controller/lib/index.js.map +0 -1
  172. package/controller/lib/utils.js +0 -69
  173. package/controller/lib/utils.js.map +0 -1
  174. package/controller/package.json +0 -18
  175. package/docs/config-schema.json +0 -2897
  176. package/docs/config-schema.json.md +0 -2138
  177. package/docs/demo/.pie/.configure/package.json +0 -10
  178. package/docs/demo/.pie/.configure/yarn.lock +0 -2122
  179. package/docs/demo/.pie/.controllers/package.json +0 -10
  180. package/docs/demo/.pie/.controllers/yarn.lock +0 -110
  181. package/docs/demo/.pie/info.entry.js +0 -89
  182. package/docs/demo/.pie/info.webpack.config.js +0 -119
  183. package/docs/demo/.pie/package.json +0 -10
  184. package/docs/demo/.pie/yarn.lock +0 -2137
  185. package/docs/demo/config.js +0 -8
  186. package/docs/demo/generate.js +0 -357
  187. package/docs/demo/index.html +0 -1
  188. package/docs/demo/pie.manifest.json +0 -11
  189. package/docs/demo/session.js +0 -12
  190. package/docs/pie-schema.json +0 -1784
  191. package/docs/pie-schema.json.md +0 -1046
  192. package/lib/__tests__/index.test.js +0 -197
  193. package/lib/categorize/__tests__/categories.test.js +0 -138
  194. package/lib/categorize/__tests__/category.test.js +0 -137
  195. package/lib/categorize/__tests__/choice.test.js +0 -88
  196. package/lib/categorize/__tests__/choices.test.js +0 -118
  197. package/lib/categorize/__tests__/droppable-placeholder.test.js +0 -96
  198. package/lib/categorize/__tests__/grid-content.test.js +0 -48
  199. package/lib/categorize/__tests__/index.test.js +0 -250
  200. package/lib/categorize/categories.js +0 -135
  201. package/lib/categorize/categories.js.map +0 -1
  202. package/lib/categorize/category.js +0 -67
  203. package/lib/categorize/category.js.map +0 -1
  204. package/lib/categorize/choice.js +0 -140
  205. package/lib/categorize/choice.js.map +0 -1
  206. package/lib/categorize/choices.js +0 -99
  207. package/lib/categorize/choices.js.map +0 -1
  208. package/lib/categorize/droppable-placeholder.js +0 -84
  209. package/lib/categorize/droppable-placeholder.js.map +0 -1
  210. package/lib/categorize/grid-content.js +0 -55
  211. package/lib/categorize/grid-content.js.map +0 -1
  212. package/lib/categorize/index.js +0 -450
  213. package/lib/categorize/index.js.map +0 -1
  214. package/lib/index.js +0 -316
  215. package/lib/index.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ //#region src/controller/defaults.ts
2
+ var e = {
3
+ alternates: [],
4
+ categories: [],
5
+ categoriesPerRow: 2,
6
+ choices: [],
7
+ choicesLabel: "",
8
+ choicesPosition: "below",
9
+ correctResponse: [],
10
+ feedbackEnabled: !1,
11
+ lockChoiceOrder: !0,
12
+ maxAnswerChoices: 6,
13
+ maxChoicesPerCategory: 0,
14
+ partialScoring: !0,
15
+ prompt: "",
16
+ promptEnabled: !0,
17
+ rationale: "",
18
+ rationaleEnabled: !0,
19
+ rowLabels: [""],
20
+ studentInstructionsEnabled: !0,
21
+ teacherInstructions: "",
22
+ teacherInstructionsEnabled: !0,
23
+ toolbarEditorPosition: "bottom",
24
+ minRowHeight: "80px"
25
+ };
26
+ //#endregion
27
+ export { e as default };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/controller/src/index.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import { score } from '@pie-lib/categorize';
10
+ export { score };
11
+ export declare const getPartialScore: (correctResponse: any, builtCategories: any) => number;
12
+ export declare const getTotalScore: (question: any, session: any, env: any) => number;
13
+ export declare const getCorrectness: (question: any, session: any, env: any) => Promise<unknown>;
14
+ export declare const createDefaultModel: (model?: {}) => Promise<unknown>;
15
+ export declare const normalize: (question: any) => any;
16
+ /**
17
+ *
18
+ * @param {*} question
19
+ * @param {*} session
20
+ * @param {*} env
21
+ * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
22
+ */
23
+ export declare const model: (question: any, session: any, env: any, updateSession: any) => Promise<{
24
+ allowMultiplePlacementsEnabled?: any;
25
+ categories: any;
26
+ categoriesPerRow: any;
27
+ maxChoicesPerCategory: any;
28
+ correctness: unknown;
29
+ choices: any;
30
+ choicesLabel: any;
31
+ choicesPosition: any;
32
+ disabled: boolean;
33
+ feedback: string | undefined;
34
+ lockChoiceOrder: boolean;
35
+ prompt: any;
36
+ rowLabels: any;
37
+ note: any;
38
+ env: any;
39
+ showNote: any;
40
+ correctResponse: any;
41
+ language: any;
42
+ extraCSSRules: any;
43
+ fontSizeFactor: any;
44
+ minRowHeight: any;
45
+ autoplayAudioEnabled: any;
46
+ completeAudioEnabled: any;
47
+ customAudioButton: any;
48
+ possibleResponses: any[];
49
+ responseAreasToBeFilled: any;
50
+ hasUnplacedChoices: boolean;
51
+ }>;
52
+ /**
53
+ * Generates detailed trace log for scoring evaluation
54
+ * @param {Object} model - the question model
55
+ * @param {Object} session - the student session
56
+ * @param {Object} env - the environment
57
+ * @returns {Array} traceLog - array of trace messages
58
+ */
59
+ export declare const getLogTrace: (model: any, session: any, env: any) => string[];
60
+ export declare const outcome: (question: any, session: any, env: any) => Promise<unknown>;
61
+ export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
62
+ export declare const validate: (model?: {}, config?: {}) => {};
@@ -0,0 +1,168 @@
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
+ //#region src/controller/index.ts
9
+ var { translator: p } = s, m = (e, t) => {
10
+ let { placements: n, score: r } = t.reduce((e, { choices: t = [] }) => ({
11
+ placements: e.placements + t.length,
12
+ score: e.score + t.filter((e) => e.correct).length
13
+ }), {
14
+ placements: 0,
15
+ score: 0
16
+ }), { maxScore: i } = e.reduce((e, { choices: t }) => ({ maxScore: e.maxScore + t.length }), { maxScore: 0 }), a = (r - (n > i ? n - i : 0)) / i;
17
+ return a < 0 ? 0 : parseFloat(a.toFixed(2));
18
+ }, h = (e) => e.map((e) => e.alternateResponses).filter((e) => e), g = (e, t, n) => {
19
+ if (!t || Object.keys(t).length === 0) return 0;
20
+ let { categories: r, choices: i } = e || {}, { correctResponse: o } = e || {}, { answers: s } = t || {};
21
+ s ||= [], o ||= [];
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
+ if (n.mode === "evaluate") {
26
+ let i = g(e, t, n);
27
+ r(i === 1 ? "correct" : i === 0 ? "incorrect" : "partially-correct");
28
+ } else r(void 0);
29
+ }), v = (t = {}) => new Promise((n) => {
30
+ n({
31
+ ...e,
32
+ ...t
33
+ });
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
+ let t = (e.choices || []).filter((e) => e !== "null");
40
+ return {
41
+ ...e,
42
+ choices: t
43
+ };
44
+ });
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,
72
+ env: r,
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 }
86
+ };
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)).`);
93
+ else {
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).`);
96
+ }
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.");
98
+ else if (d) {
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) {
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);
101
+ if (r.push(`Partial scoring calculation: ${e} correct placements, ${t} incorrect placements.`), l > n) {
102
+ let e = l - n;
103
+ r.push(`${e} extra placement(s) beyond required amount will be deducted from score.`);
104
+ }
105
+ }
106
+ } else r.push("Score calculated using all-or-nothing scoring."), r.push("Student must get all categories completely correct to receive full credit.");
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) || !t.answers) r({
111
+ score: 0,
112
+ empty: !0,
113
+ traceLog: ["Student did not place any choices into categories. Score is 0."]
114
+ });
115
+ else {
116
+ let i = x(e, t, n);
117
+ r({
118
+ score: g(e, t, n),
119
+ empty: !1,
120
+ traceLog: i
121
+ });
122
+ }
123
+ }) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")), C = (e, t) => new Promise((n) => {
124
+ let { mode: r, role: i } = t || {};
125
+ if (r !== "evaluate" && i === "instructor") {
126
+ let { correctResponse: t } = e;
127
+ n({
128
+ answers: t,
129
+ id: 1
130
+ });
131
+ } else return n(null);
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 = {}, _ = {};
134
+ [
135
+ "teacherInstructions",
136
+ "prompt",
137
+ "rationale"
138
+ ].forEach((n) => {
139
+ t[n]?.required && !T(e[n]) && (h[n] = "This field is required.");
140
+ }), (i || []).forEach((e) => {
141
+ let { id: t, label: n } = e;
142
+ w(n).length > p && (_[t] = `Category labels should be no more than ${p} characters long.`);
143
+ }), (m || []).forEach((e, t) => {
144
+ let { id: n, content: r } = e;
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.";
146
+ });
147
+ let v = (i || []).length, y = (a || []).length;
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) {
149
+ let e = !1;
150
+ (o || []).forEach((t) => {
151
+ let { choices: n = [], alternateResponses: r = [] } = t;
152
+ n.length ? e = !0 : r.forEach((t) => {
153
+ (t || []).length && (e = !0);
154
+ });
155
+ });
156
+ let t = -1, i = "";
157
+ (o || []).forEach((e) => {
158
+ let { choices: a = [], alternateResponses: o = [], category: s } = e;
159
+ t === -1 && (t = r(a, o), t === -1 && (t = n(o)), i = s);
160
+ }), t > -1 && (h.duplicateAlternate = {
161
+ index: t,
162
+ category: i
163
+ }), e || (h.associationError = "At least one token should be assigned to at least one category.");
164
+ }
165
+ return c(g) || (h.choicesErrors = g), c(_) || (h.categoriesErrors = _), h;
166
+ };
167
+ //#endregion
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 };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/controller/src/utils.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export declare const multiplePlacements: {
10
+ enabled: string;
11
+ disabled: string;
12
+ perChoice: string;
13
+ };
14
+ export declare const isCorrectResponseDuplicated: (choices: any, alternate: any) => any;
15
+ export declare const isAlternateDuplicated: (alternate: any) => number;
16
+ export declare const getCompleteResponseDetails: (correctResponse: any, alternates: any, allChoices: any) => {
17
+ responseAreasToBeFilled: any;
18
+ possibleResponses: any[];
19
+ hasUnplacedChoices: boolean;
20
+ };
@@ -0,0 +1,35 @@
1
+ //#region src/controller/utils.ts
2
+ var e = {
3
+ enabled: "Yes",
4
+ disabled: "No",
5
+ perChoice: "Set Per Choice"
6
+ }, t = (e, t) => {
7
+ if (e.length < 1 || t.length < 1) return -1;
8
+ let n = JSON.stringify(e.sort());
9
+ return t.reduce((e, t) => t.length > 0 ? [...e, JSON.stringify(t.sort())] : e, []).findIndex((e) => e.length && e === n);
10
+ }, n = (e) => {
11
+ if (e.length <= 1) return -1;
12
+ let t = /* @__PURE__ */ new Set(), n = e.reduce((e, t) => t.length > 0 ? [...e, JSON.stringify(t.sort())] : e, []);
13
+ for (let e = 0; e < n.length; e++) {
14
+ if (t.has(n[e]) && n[e]) return e;
15
+ t.add(n[e]);
16
+ }
17
+ return -1;
18
+ }, r = (e, t, n) => {
19
+ let r = e.map((e) => e.choices), i = [r.flat()], a = r.filter((e) => e.length).length;
20
+ if (t.length) {
21
+ let e = t[0]?.length || 0;
22
+ [...Array(e).keys()].forEach((e) => {
23
+ let n = t.map((t) => t[e]), r = n.filter((e) => e?.length).length;
24
+ i.push(n.flat()), r < a && (a = r);
25
+ });
26
+ }
27
+ let o = i.some((e) => !n.every((t) => e.includes(t?.id)));
28
+ return {
29
+ responseAreasToBeFilled: a,
30
+ possibleResponses: i,
31
+ hasUnplacedChoices: o
32
+ };
33
+ };
34
+ //#endregion
35
+ export { r as getCompleteResponseDetails, n as isAlternateDuplicated, t as isCorrectResponseDuplicated, e as multiplePlacements };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/categorize/categories.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import { CategoryType } from './category.js';
12
+ export { CategoryType };
13
+ export declare class Categories extends React.Component {
14
+ static propTypes: {
15
+ categories: PropTypes.Requireable<(PropTypes.InferProps<{
16
+ id: PropTypes.Validator<string>;
17
+ categoryId: PropTypes.Requireable<string>;
18
+ }> | null | undefined)[]>;
19
+ model: PropTypes.Requireable<PropTypes.InferProps<{
20
+ categoriesPerRow: PropTypes.Requireable<number>;
21
+ }>>;
22
+ disabled: PropTypes.Requireable<boolean>;
23
+ onDropChoice: PropTypes.Validator<(...args: any[]) => any>;
24
+ onRemoveChoice: PropTypes.Validator<(...args: any[]) => any>;
25
+ rowLabels: PropTypes.Requireable<any[]>;
26
+ selectedItem: PropTypes.Requireable<object>;
27
+ onSelectClick: PropTypes.Requireable<(...args: any[]) => any>;
28
+ onPlacementClick: PropTypes.Requireable<(...args: any[]) => any>;
29
+ };
30
+ static defaultProps: {
31
+ model: {
32
+ categoriesPerRow: number;
33
+ };
34
+ };
35
+ render(): React.JSX.Element;
36
+ }
37
+ export default Categories;
@@ -0,0 +1,72 @@
1
+ import { GridContent as e } from "./grid-content.js";
2
+ import { Category as t, CategoryType as n } from "./category.js";
3
+ import r from "react";
4
+ import { color as i } from "@pie-lib/render-ui";
5
+ import a from "prop-types";
6
+ import { styled as o } from "@mui/material/styles";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
+ //#region src/delivery/categorize/categories.tsx
9
+ var l = class extends r.Component {
10
+ static propTypes = {
11
+ categories: a.arrayOf(a.shape(n)),
12
+ model: a.shape({ categoriesPerRow: a.number }),
13
+ disabled: a.bool,
14
+ onDropChoice: a.func.isRequired,
15
+ onRemoveChoice: a.func.isRequired,
16
+ rowLabels: a.array,
17
+ selectedItem: a.object,
18
+ onSelectClick: a.func,
19
+ onPlacementClick: a.func
20
+ };
21
+ static defaultProps = { model: { categoriesPerRow: 1 } };
22
+ render() {
23
+ let { categories: n, model: r, disabled: i, onDropChoice: a, onRemoveChoice: o, rowLabels: l, selectedItem: p, onSelectClick: m, onPlacementClick: h } = this.props, { categoriesPerRow: g, minRowHeight: _ } = r, v = [], y = n || [];
24
+ for (let e = 0; e < y.length; e += g) v.push(y.slice(e, e + g));
25
+ let b = (e) => {
26
+ let t = !1;
27
+ return (e || []).forEach((e) => {
28
+ typeof e == "string" && e.trim() !== "" && e.trim() !== "<div></div>" && (t = !0);
29
+ }), t;
30
+ };
31
+ return /* @__PURE__ */ s(e, {
32
+ columns: g,
33
+ rows: Math.ceil(n.length / g) * 2,
34
+ extraStyle: { flex: 1 },
35
+ children: v.map((e, n) => {
36
+ let r = [];
37
+ return e.forEach((e, g) => {
38
+ r.push(/* @__PURE__ */ c("div", {
39
+ style: { display: "flex" },
40
+ children: [g === 0 && b(l) ? /* @__PURE__ */ s(d, { dangerouslySetInnerHTML: { __html: l[n] || "" } }, n) : null, /* @__PURE__ */ c(f, { children: [/* @__PURE__ */ s(u, { dangerouslySetInnerHTML: { __html: e.label } }, `category-label-${n}-${g}`), /* @__PURE__ */ s(t, {
41
+ minRowHeight: _,
42
+ onDropChoice: (t) => a(e.id, t),
43
+ onRemoveChoice: o,
44
+ disabled: i,
45
+ selectedItem: p,
46
+ onSelectClick: m,
47
+ onPlacementClick: h,
48
+ ...e
49
+ }, `category-element-${n}-${g}`)] })]
50
+ }));
51
+ }), r = r.concat(Array(g - e.length).fill(/* @__PURE__ */ s("div", {})).map((e, t) => /* @__PURE__ */ s("div", {}, `fill-space-final-${t}`))), r;
52
+ })
53
+ });
54
+ }
55
+ }, u = o("div")(({ theme: e }) => ({
56
+ color: i.text(),
57
+ backgroundColor: i.background(),
58
+ textAlign: "center",
59
+ paddingTop: e.spacing(1)
60
+ })), d = o("div")({
61
+ alignItems: "center",
62
+ display: "flex",
63
+ justifyContent: "center",
64
+ flex: .5,
65
+ marginRight: "12px"
66
+ }), f = o("div")({
67
+ display: "flex",
68
+ flex: "2",
69
+ flexDirection: "column"
70
+ });
71
+ //#endregion
72
+ export { l as Categories, l as default, n as CategoryType };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/categorize/category.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare const CategoryType: {
12
+ id: PropTypes.Validator<string>;
13
+ categoryId: PropTypes.Requireable<string>;
14
+ };
15
+ export declare class Category extends React.Component {
16
+ static propTypes: {
17
+ className: PropTypes.Requireable<string>;
18
+ disabled: PropTypes.Requireable<boolean>;
19
+ onDropChoice: PropTypes.Requireable<(...args: any[]) => any>;
20
+ onRemoveChoice: PropTypes.Requireable<(...args: any[]) => any>;
21
+ minRowHeight: PropTypes.Requireable<string>;
22
+ selectedItem: PropTypes.Requireable<object>;
23
+ onSelectClick: PropTypes.Requireable<(...args: any[]) => any>;
24
+ onPlacementClick: PropTypes.Requireable<(...args: any[]) => any>;
25
+ id: PropTypes.Validator<string>;
26
+ categoryId: PropTypes.Requireable<string>;
27
+ };
28
+ static defaultProps: {};
29
+ render(): React.JSX.Element;
30
+ }
31
+ export default Category;
@@ -0,0 +1,55 @@
1
+ import e from "./choice.js";
2
+ import t from "./droppable-placeholder.js";
3
+ import n from "react";
4
+ import r from "prop-types";
5
+ import { styled as i } from "@mui/material/styles";
6
+ import { jsx as a } from "react/jsx-runtime";
7
+ //#region src/delivery/categorize/category.tsx
8
+ var o = {
9
+ id: r.string.isRequired,
10
+ categoryId: r.string
11
+ }, s = class extends n.Component {
12
+ static propTypes = {
13
+ ...o,
14
+ className: r.string,
15
+ disabled: r.bool,
16
+ onDropChoice: r.func,
17
+ onRemoveChoice: r.func,
18
+ minRowHeight: r.string,
19
+ selectedItem: r.object,
20
+ onSelectClick: r.func,
21
+ onPlacementClick: r.func
22
+ };
23
+ static defaultProps = {};
24
+ render() {
25
+ let { className: n, choices: r = [], disabled: i, onDropChoice: o, onRemoveChoice: s, id: l, correct: u, minRowHeight: d, selectedItem: f, onSelectClick: p, onPlacementClick: m } = this.props;
26
+ return /* @__PURE__ */ a(c, {
27
+ className: n,
28
+ id: l,
29
+ children: /* @__PURE__ */ a(t, {
30
+ id: l,
31
+ onDropChoice: o,
32
+ disabled: i,
33
+ correct: u,
34
+ minRowHeight: d,
35
+ selectedItem: f,
36
+ onPlacementClick: m,
37
+ children: r.map((t, n) => /* @__PURE__ */ a(e, {
38
+ onRemoveChoice: s,
39
+ disabled: i,
40
+ choiceIndex: n,
41
+ categoryId: l,
42
+ selectedItem: f,
43
+ onSelectClick: p,
44
+ ...t
45
+ }, n))
46
+ })
47
+ });
48
+ }
49
+ }, c = i("div")(({ theme: e }) => ({
50
+ display: "flex",
51
+ flexDirection: "column",
52
+ flex: 2
53
+ }));
54
+ //#endregion
55
+ export { s as Category, s as default, o as CategoryType };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/categorize/choice.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare const ChoiceType: {
12
+ content: PropTypes.Validator<string>;
13
+ id: PropTypes.Requireable<string>;
14
+ };
15
+ export declare class Layout extends React.Component {
16
+ static propTypes: {
17
+ disabled: PropTypes.Requireable<boolean>;
18
+ correct: PropTypes.Requireable<boolean>;
19
+ isDragging: PropTypes.Requireable<boolean>;
20
+ isSelected: PropTypes.Requireable<boolean>;
21
+ content: PropTypes.Validator<string>;
22
+ id: PropTypes.Requireable<string>;
23
+ };
24
+ static defaultProps: {};
25
+ render(): React.JSX.Element;
26
+ }
27
+ declare const _default: (props: any) => React.JSX.Element;
28
+ export default _default;