@pie-element/categorize 14.0.4-next.20261011174919 → 14.0.4
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 +67 -65
- package/dist/author/index.d.ts +57 -30
- package/dist/author/index.js +14 -5
- package/dist/author/main.d.ts +20 -11
- package/dist/author/main.js +6 -16
- package/dist/author/utils.d.ts +7 -6
- package/dist/browser/author/index.js +20 -23
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +14 -14
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/editor-runtime/author/index.js +20 -23
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/controller/index.js +14 -14
- package/dist/browser/editor-runtime/controller/index.js.map +1 -1
- package/dist/controller/defaults.d.ts +14 -13
- package/dist/controller/index.d.ts +109 -33
- package/dist/controller/index.js +14 -14
- package/dist/controller/utils.d.ts +9 -8
- package/dist/index.d.ts +1 -0
- package/dist/schemas/configuration.schema.json +463 -0
- package/dist/schemas/model.schema.json +610 -0
- package/dist/schemas/session.schema.json +71 -0
- package/dist/types.d.ts +266 -0
- package/package.json +22 -18
|
@@ -224,12 +224,10 @@ var C = {
|
|
|
224
224
|
score: 0
|
|
225
225
|
}), { maxScore: i } = e.reduce((e, { choices: t }) => ({ maxScore: e.maxScore + t.length }), { maxScore: 0 }), a = (r - (n > i ? n - i : 0)) / i;
|
|
226
226
|
return a < 0 ? 0 : parseFloat(a.toFixed(2));
|
|
227
|
-
}, A = (e) => e.map((e) => e.alternateResponses).filter((e) => e), j = (e, t, n) => {
|
|
227
|
+
}, A = (e) => e.map((e) => e.alternateResponses).filter((e) => !!e), j = (e, t, n) => {
|
|
228
228
|
if (!t || Object.keys(t).length === 0) return 0;
|
|
229
|
-
let { categories: r, choices: a } = e || {},
|
|
230
|
-
|
|
231
|
-
let { categories: c, correct: l } = i(r, a, s, o), u = A(o);
|
|
232
|
-
return x.enabled(e, n) && !u.length ? k(o, c) : +!!l;
|
|
229
|
+
let { categories: r, choices: a } = e || {}, o = (e || {}).correctResponse || [], { categories: s, correct: c } = i(r, a, t.answers || [], o), l = A(o);
|
|
230
|
+
return x.enabled(e, n) && !l.length ? k(o, s) : +!!c;
|
|
233
231
|
}, M = (e, t, n) => new Promise((r) => {
|
|
234
232
|
if (n.mode === "evaluate") {
|
|
235
233
|
let i = j(e, t, n);
|
|
@@ -244,7 +242,7 @@ var C = {
|
|
|
244
242
|
...C,
|
|
245
243
|
...e
|
|
246
244
|
}), F = async (e, t, n, r) => {
|
|
247
|
-
let i = P(e), a = await M(i, t, n),
|
|
245
|
+
let i = P(e), a = await M(i, t, n), o = n?.mode, s = n?.role, { categories: c, categoriesPerRow: l, choicesLabel: u, choicesPosition: d, correctResponse: p, feedback: m, feedbackEnabled: h, promptEnabled: g, prompt: _, rowLabels: v, rationaleEnabled: x, rationale: S, teacherInstructionsEnabled: C, teacherInstructions: T, language: E, maxChoicesPerCategory: k, extraCSSRules: j, minRowHeight: N, fontSizeFactor: F, autoplayAudioEnabled: I, completeAudioEnabled: L, customAudioButton: R } = i, z = i.choices, { note: B } = i, V, H = b(i, t, n), U = p.map((e) => {
|
|
248
246
|
let t = (e.choices || []).filter((e) => e !== "null");
|
|
249
247
|
return {
|
|
250
248
|
...e,
|
|
@@ -264,7 +262,8 @@ var C = {
|
|
|
264
262
|
categoryCount: t
|
|
265
263
|
};
|
|
266
264
|
}), B ||= O.t("common:commonCorrectAnswerWithAlternates", { lng: E });
|
|
267
|
-
let G = A(U), { responseAreasToBeFilled:
|
|
265
|
+
let G = A(U), K = s === "instructor" && (o === "view" || o === "evaluate"), { responseAreasToBeFilled: q, possibleResponses: J, hasUnplacedChoices: Y } = D(U, i.allowAlternateEnabled ? G : [], i.choices);
|
|
266
|
+
return {
|
|
268
267
|
categories: c || [],
|
|
269
268
|
categoriesPerRow: l || 2,
|
|
270
269
|
maxChoicesPerCategory: k,
|
|
@@ -288,12 +287,13 @@ var C = {
|
|
|
288
287
|
autoplayAudioEnabled: I,
|
|
289
288
|
completeAudioEnabled: L,
|
|
290
289
|
customAudioButton: R,
|
|
291
|
-
possibleResponses:
|
|
292
|
-
responseAreasToBeFilled:
|
|
293
|
-
hasUnplacedChoices:
|
|
294
|
-
...e.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: W }
|
|
290
|
+
possibleResponses: J,
|
|
291
|
+
responseAreasToBeFilled: q,
|
|
292
|
+
hasUnplacedChoices: Y,
|
|
293
|
+
...e.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: W },
|
|
294
|
+
rationale: K && x ? S : null,
|
|
295
|
+
teacherInstructions: K && C ? T : null
|
|
295
296
|
};
|
|
296
|
-
return s === "instructor" && (o === "view" || o === "evaluate") ? (Y.rationale = x ? S : null, Y.teacherInstructions = C ? T : null) : (Y.rationale = null, Y.teacherInstructions = null), Y;
|
|
297
297
|
}, I = (e, t, n) => {
|
|
298
298
|
let r = [], { answers: a } = t || {}, { categories: o, choices: s, correctResponse: c } = e || {}, l = a.reduce((e, t) => e + (t.choices?.length || 0), 0), u = A(c).length > 0, d = x.enabled(e, n), f = (l > 0 ? i(o, s, a, c) : null)?.categories || [];
|
|
299
299
|
if (l > 0 ? (r.push(`Student placed ${l} choice(s) into categories.`), (o || []).forEach((e) => {
|
|
@@ -330,7 +330,7 @@ var C = {
|
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
}) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")), R = (e, t) => new Promise((n) => {
|
|
333
|
-
let
|
|
333
|
+
let r = t?.mode, i = t?.role;
|
|
334
334
|
if (r !== "evaluate" && i === "instructor") {
|
|
335
335
|
let { correctResponse: t } = e;
|
|
336
336
|
n({
|
|
@@ -354,7 +354,7 @@ var C = {
|
|
|
354
354
|
z(r).length > u && (m[n] = `Tokens should be no more than ${u} characters long.`), B(r) ? f.slice(t + 1).some((e) => e.content === r) && (m[n] = "Tokens content should be unique.") : m[n] = "Tokens should not be empty.";
|
|
355
355
|
});
|
|
356
356
|
let g = (n || []).length, _ = (i || []).length;
|
|
357
|
-
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) {
|
|
357
|
+
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 !== void 0 && _ > o && (p.choicesError = `No more than ${o} choices should be defined.`), _ && g) {
|
|
358
358
|
let e = !1;
|
|
359
359
|
(a || []).forEach((t) => {
|
|
360
360
|
let { choices: n = [], alternateResponses: r = [] } = t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../lib-react/categorize/dist/scoring.js","../../../../../../shared/feedback/dist/index.js","../../../../../../shared/controller-utils/dist/index.js","../../../../src/controller/defaults.ts","../../../../src/controller/utils.ts","../../../../src/controller/index.ts"],"sourcesContent":["import e from \"debug\";\n//#region src/scoring.ts\nvar t = e(\"@pie-lib:categorize:scoring\"), n = (e) => !e || !e.weighting ? [] : e.weighting.enabled && e.weighting && e.weighting.rules || [], r = (e, n) => {\n\tif (t(\"partial? \", e), !(!e || !e.enabled)) {\n\t\tlet t = e.rules.find((e) => e.category === n);\n\t\treturn t && t.rules || [];\n\t}\n}, i = (e, i) => new Promise((a) => {\n\tt(\"categories: \", e, \"scoring: \", i);\n\tlet o = n(i), s = e.map((e) => ({\n\t\t...o.find((t) => t.category === e.id) || { points: 1 },\n\t\tcategory: e.id\n\t}));\n\tt(\"weights: \", s);\n\tlet c = e.reduce((e, t) => {\n\t\tlet n = s.find((e) => e.category === t.id);\n\t\treturn e += n.points;\n\t}, 0);\n\tt(\"total: \", c);\n\tlet l = e.map((e) => {\n\t\tlet n = s.find((t) => t.category === e.id).points;\n\t\tif (t(\"category: \", e), e.correct === !0) return {\n\t\t\tcategory: e.id,\n\t\t\tscore: n,\n\t\t\tpoints: n\n\t\t};\n\t\t{\n\t\t\tlet a = r(i.partial, e.id);\n\t\t\tif (t(\"partial rules for category: \", a), a) {\n\t\t\t\tlet r = (e.choices || []).filter((e) => e.correct).length;\n\t\t\t\tt(\"correctCount: \", r);\n\t\t\t\tlet i = a.find((e) => e.count === r);\n\t\t\t\tt(\"rule: \", i), i ||= {\n\t\t\t\t\tpercent: 0,\n\t\t\t\t\tcount: r\n\t\t\t\t};\n\t\t\t\tlet o = n * (i.percent / 100);\n\t\t\t\treturn {\n\t\t\t\t\tcategory: e.id,\n\t\t\t\t\tscore: o,\n\t\t\t\t\tpoints: n,\n\t\t\t\t\tpartial: {\n\t\t\t\t\t\tcorrectChoices: r,\n\t\t\t\t\t\trule: i\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t} else return {\n\t\t\t\tcategory: e.id,\n\t\t\t\tscore: 0,\n\t\t\t\tpoints: n\n\t\t\t};\n\t\t}\n\t}), u = l.reduce((e, t) => e += t.score, 0);\n\tt(\"weightedScore: \", u), a({\n\t\tscore: parseFloat((u / c).toFixed(2), 10),\n\t\tdetails: {\n\t\t\tweighted: {\n\t\t\t\ttotal: c,\n\t\t\t\tscore: u\n\t\t\t},\n\t\t\tcategories: l\n\t\t}\n\t});\n});\n//#endregion\nexport { i as score };\n","//#region src/defaults.ts\nvar e = {\n\tcorrect: {\n\t\ttype: \"default\",\n\t\tdefault: \"Correct\",\n\t\tcustom: \"Correct\"\n\t},\n\tincorrect: {\n\t\ttype: \"default\",\n\t\tdefault: \"Incorrect\",\n\t\tcustom: \"Incorrect\"\n\t},\n\tpartial: {\n\t\ttype: \"default\",\n\t\tdefault: \"Nearly\",\n\t\tcustom: \"Nearly\"\n\t},\n\tunanswered: {\n\t\ttype: \"default\",\n\t\tdefault: \"You have not entered a response\",\n\t\tcustom: \"You have not entered a response\"\n\t}\n};\n//#endregion\n//#region src/utils.ts\nfunction t(e) {\n\treturn e === \"partially-correct\" ? \"partial\" : e;\n}\n//#endregion\n//#region src/index.ts\nfunction n(n, r) {\n\tlet i = {\n\t\t...e,\n\t\t...r\n\t}, a = t(n), o = e[a] || {}, s = i[a] || o;\n\treturn {\n\t\tconfig: s,\n\t\tfallback: o[s.type || \"default\"]\n\t};\n}\nfunction r(e, t = {}) {\n\treturn new Promise((r) => {\n\t\tlet { config: a, fallback: o } = n(e, t);\n\t\ti(a, o).then(r);\n\t});\n}\nfunction i(e, t) {\n\treturn new Promise((n) => {\n\t\tif (!e || e.type === \"none\") {\n\t\t\tn(void 0);\n\t\t\treturn;\n\t\t}\n\t\tn(e[e.type] || t);\n\t});\n}\nfunction a(e, t = {}) {\n\tlet { config: r, fallback: i } = n(e, t);\n\treturn o(r, i);\n}\nfunction o(e, t) {\n\tif (!(!e || e.type === \"none\")) return e[e.type] || t;\n}\n//#endregion\nexport { e as defaultFeedback, o as getActualFeedback, a as getActualFeedbackForCorrectness, i as getFeedback, r as getFeedbackForCorrectness, t as normalizeCorrectness };\n","//#region \\0rolldown/runtime.js\nvar e = Object.defineProperty, t = (t, n) => {\n\tlet r = {};\n\tfor (var i in t) e(r, i, {\n\t\tget: t[i],\n\t\tenumerable: !0\n\t});\n\treturn n || e(r, Symbol.toStringTag, { value: \"Module\" }), r;\n};\n//#endregion\n//#region src/persistence.ts\nfunction n(e) {\n\treturn Array.isArray(e) ? e.filter((e) => e != null) : [];\n}\nfunction r(e) {\n\tlet t = [...e];\n\tfor (let e = t.length - 1; e > 0; e--) {\n\t\tlet n = Math.floor(Math.random() * (e + 1));\n\t\t[t[e], t[n]] = [t[n], t[e]];\n\t}\n\treturn t;\n}\nfunction i(e) {\n\treturn e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == \"object\" && Object.keys(e).length === 0;\n}\nasync function a(e, t, a, o = \"value\") {\n\tlet s = n(t?.data?.shuffledValues ?? t?.shuffledValues ?? []);\n\tif (!t) {\n\t\tconsole.warn(\"Unable to save shuffled choices because there's no session.\");\n\t\treturn;\n\t}\n\tif (!i(s)) return n(s.map((t) => e.find((e) => e[o] === t)));\n\tlet c = r(e);\n\tif (a && typeof a == \"function\") try {\n\t\tlet e = n(c.map((e) => e[o]));\n\t\ti(e) ? console.error(`shuffledValues is an empty array - refusing to call updateSession. shuffledChoices: ${JSON.stringify(c)}, key: ${o}`) : await a(t.id, t.element, { shuffledValues: e });\n\t} catch (e) {\n\t\tconsole.warn(\"Unable to save shuffled order for choices\"), console.error(e);\n\t}\n\telse console.warn(\"Unable to save shuffled choices, shuffle will happen every time.\");\n\treturn c;\n}\nfunction o(e, t, n) {\n\treturn !!(e.lockChoiceOrder || n?.[\"@pie-element\"]?.lockChoiceOrder);\n}\n//#endregion\n//#region src/partial-scoring.ts\nvar s = /* @__PURE__ */ t({ enabled: () => c });\nfunction c(e, t, n) {\n\treturn e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n != \"boolean\" || n;\n}\n//#endregion\nexport { a as getShuffledChoices, o as lockChoices, s as partialScoring };\n","// @ts-nocheck\n\nexport default {\n alternates: [],\n categories: [],\n categoriesPerRow: 2,\n choices: [],\n choicesLabel: '',\n choicesPosition: 'below',\n correctResponse: [],\n feedbackEnabled: false,\n lockChoiceOrder: true,\n maxAnswerChoices: 6,\n maxChoicesPerCategory: 0,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n rowLabels: [''],\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n minRowHeight: '80px',\n};\n","// @ts-nocheck\n\n// used in configure too, for consistency modify it there too\nexport const multiplePlacements = { enabled: 'Yes', disabled: 'No', perChoice: 'Set Per Choice' };\n\n// used to validate the config\nexport const isCorrectResponseDuplicated = (choices, alternate) => {\n if (choices.length < 1 || alternate.length < 1) {\n return -1;\n }\n\n const stringChoices = JSON.stringify(choices.sort());\n const stringAlternate = alternate.reduce(\n (total, current) => (current.length > 0 ? [...total, JSON.stringify(current.sort())] : total),\n [],\n );\n const foundIndexDuplicate = stringAlternate.findIndex((alternate) => alternate.length && alternate === stringChoices);\n\n return foundIndexDuplicate;\n};\n\nexport const isAlternateDuplicated = (alternate) => {\n if (alternate.length <= 1) {\n return -1;\n }\n\n const elementSet = new Set();\n const stringAlternate = alternate.reduce(\n (total, current) => (current.length > 0 ? [...total, JSON.stringify(current.sort())] : total),\n [],\n );\n\n for (let i = 0; i < stringAlternate.length; i++) {\n if (elementSet.has(stringAlternate[i]) && stringAlternate[i]) {\n return i;\n }\n\n elementSet.add(stringAlternate[i]);\n }\n\n return -1;\n};\n\n// calculate the minimum number of populated response areas (categories) in the correct answer or alternates\n// and create an array with the possible responses ids\nexport const getCompleteResponseDetails = (correctResponse, alternates, allChoices) => {\n const choicesPerCategory = correctResponse.map((category) => category.choices);\n const possibleResponses = [choicesPerCategory.flat()];\n let responseAreasToBeFilled = choicesPerCategory.filter((choices) => choices.length).length;\n\n if (alternates.length) {\n const alternatesPerChoice = alternates[0]?.length || 0; // number of alternates\n\n [...Array(alternatesPerChoice).keys()].forEach((index) => {\n const alternatesPerResponse = alternates.map((alternate) => alternate[index]);\n const filledCategories = alternatesPerResponse.filter((category) => category?.length).length;\n possibleResponses.push(alternatesPerResponse.flat());\n\n if (filledCategories < responseAreasToBeFilled) {\n responseAreasToBeFilled = filledCategories;\n }\n });\n }\n\n // check if any correct answer have any unplaced answer choices\n const hasUnplacedChoices = possibleResponses.some(\n (response) => !allChoices.every((val) => response.includes(val?.id)),\n );\n\n return { responseAreasToBeFilled, possibleResponses, hasUnplacedChoices };\n};\n","// @ts-nocheck\n\nimport { isEmpty } from '@pie-element/shared-lodash';\nimport { buildState, score } from '@pie-lib/categorize';\nimport { getFeedbackForCorrectness } from '@pie-element/shared-feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\nimport defaults from './defaults.js';\nimport { getCompleteResponseDetails, isAlternateDuplicated, isCorrectResponseDuplicated, multiplePlacements } from './utils.js';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\nexport const getPartialScore = (correctResponse, builtCategories) => {\n // in the resulted best scenario we make a sum with all the correct responses\n // and all the placements\n const { placements, score } = builtCategories.reduce(\n (acc, { choices = [] }) => ({\n placements: acc.placements + choices.length,\n score: acc.score + choices.filter((ch) => ch.correct).length,\n }),\n { placements: 0, score: 0 },\n );\n\n // in the correct response, we make a sum of the max possible score\n const { maxScore } = correctResponse.reduce(\n (acc, { choices }) => ({\n maxScore: acc.maxScore + choices.length,\n }),\n { maxScore: 0 },\n );\n\n // if there are any extra placements, we subtract from the obtained score\n const extraPlacements = placements > maxScore ? placements - maxScore : 0;\n const totalScore = (score - extraPlacements) / maxScore;\n\n return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));\n};\n\nconst getAlternates = (correctResponse) =>\n correctResponse.map((c) => c.alternateResponses).filter((alternate) => alternate);\n\nexport const getTotalScore = (question, session, env) => {\n if (!session) {\n return 0;\n }\n\n if (Object.keys(session).length === 0) {\n return 0;\n }\n const { categories, choices } = question || {};\n let { correctResponse } = question || {};\n let { answers } = session || {};\n answers = answers || [];\n correctResponse = correctResponse || [];\n\n // this function is used in pie-ui/categorize as well, in order to get the best scenario\n // so we get the best scenario and calculate the score\n const { categories: builtCategories, correct } = buildState(categories, choices, answers, correctResponse);\n\n const alternates = getAlternates(correctResponse);\n const enabled = partialScoring.enabled(question, env);\n\n // if there are any alternates, there will be no partial scoring!\n if (enabled && !alternates.length) {\n // we apply partial scoring\n return getPartialScore(correctResponse, builtCategories);\n }\n\n // else we apply dichotomous\n return correct ? 1 : 0;\n};\n\nexport const getCorrectness = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode === 'evaluate') {\n const score = getTotalScore(question, session, env);\n if (score === 1) {\n resolve('correct');\n } else if (score === 0) {\n resolve('incorrect');\n } else {\n resolve('partially-correct');\n }\n } else {\n resolve(undefined);\n }\n });\n};\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport const model = async (question, session, env, updateSession) => {\n const normalizedQuestion = normalize(question);\n const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);\n\n const { mode, role } = env || {};\n\n const {\n categories,\n categoriesPerRow,\n choicesLabel,\n choicesPosition,\n correctResponse,\n feedback,\n feedbackEnabled,\n promptEnabled,\n prompt,\n rowLabels,\n rationaleEnabled,\n rationale,\n teacherInstructionsEnabled,\n teacherInstructions,\n language,\n maxChoicesPerCategory,\n extraCSSRules,\n minRowHeight,\n fontSizeFactor,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n } = normalizedQuestion;\n let { choices, note } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n const filteredCorrectResponse = correctResponse.map((response) => {\n const filteredChoices = (response.choices || []).filter((choice) => choice !== 'null');\n return { ...response, choices: filteredChoices };\n });\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(answerCorrectness, feedback);\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n const resolvedAllowMultiple = (() => {\n if (question.allowMultiplePlacementsEnabled != null) {\n return question.allowMultiplePlacementsEnabled;\n }\n // Derive from correct response: if any choice id appears in more than one category, reuse is required\n const allChoiceIds = (correctResponse || []).flatMap((cr) => cr.choices || []);\n const isExclusive = allChoiceIds.length === new Set(allChoiceIds).size;\n return isExclusive ? multiplePlacements.disabled : multiplePlacements.enabled;\n })();\n\n choices = (choices || []).map((c) => {\n let categoryCount;\n if (resolvedAllowMultiple === multiplePlacements.enabled) {\n categoryCount = 0;\n } else if (resolvedAllowMultiple === multiplePlacements.disabled) {\n categoryCount = 1;\n } else {\n // perChoice — use the value set on each choice individually\n categoryCount = c.categoryCount || 0;\n }\n return { ...c, categoryCount };\n });\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: language });\n }\n\n const alternates = getAlternates(filteredCorrectResponse);\n const { responseAreasToBeFilled, possibleResponses, hasUnplacedChoices } = getCompleteResponseDetails(\n filteredCorrectResponse,\n normalizedQuestion.allowAlternateEnabled ? alternates : [],\n normalizedQuestion.choices,\n );\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n maxChoicesPerCategory,\n correctness: answerCorrectness,\n choices: choices || [],\n choicesLabel: choicesLabel || '',\n choicesPosition,\n disabled: mode !== 'gather',\n feedback: fb,\n lockChoiceOrder,\n prompt: promptEnabled ? prompt : null,\n rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,\n language,\n extraCSSRules,\n fontSizeFactor,\n minRowHeight: minRowHeight,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n possibleResponses,\n responseAreasToBeFilled,\n hasUnplacedChoices,\n ...(question.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: resolvedAllowMultiple }),\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n return out;\n};\n\n /**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (model, session, env) => {\n const traceLog = [];\n const { answers } = session || {};\n const { categories, choices, correctResponse } = model || {};\n\n const draggedChoices = answers.reduce(\n (sum, a) => sum + (a.choices?.length || 0),\n 0\n );\n\n const alternates = getAlternates(correctResponse);\n const hasAlternates = alternates.length > 0;\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n const builtState =\n draggedChoices > 0\n ? buildState(categories, choices, answers, correctResponse)\n : null;\n\n const builtCategories = builtState?.categories || [];\n \n if (draggedChoices > 0) {\n traceLog.push(`Student placed ${draggedChoices} choice(s) into categories.`);\n \n (categories || []).forEach((category) => {\n const categoryId = category.id;\n const builtCategory = builtCategories.find(c => c.id === categoryId);\n const studentChoices = builtCategory ? builtCategory.choices || [] : [];\n const correctResponseForCategory = (correctResponse || []).find(cr => cr.category === categoryId);\n const expectedChoices = correctResponseForCategory ? correctResponseForCategory.choices || [] : [];\n \n if (expectedChoices.length > 0) {\n if (studentChoices.length === 0) {\n traceLog.push(`Category ${categoryId}: student left empty (should contain ${expectedChoices.length} choice(s)).`);\n } else {\n const correctCount = studentChoices.filter(choice => choice.correct).length;\n const incorrectCount = studentChoices.length - correctCount;\n \n if (correctCount > 0 && incorrectCount === 0) {\n traceLog.push(`Category ${categoryId}: student placed ${correctCount} correct choice(s).`);\n } else if (correctCount === 0 && incorrectCount > 0) {\n traceLog.push(`Category ${categoryId}: student placed ${incorrectCount} incorrect choice(s).`);\n } else {\n traceLog.push(`Category ${categoryId}: student placed ${correctCount} correct and ${incorrectCount} incorrect choice(s).`);\n }\n }\n }\n });\n } else {\n traceLog.push('Student did not place any choices into categories.');\n }\n\n if (hasAlternates) {\n traceLog.push('Alternate response combinations are accepted for this question.');\n }\n\n if (hasAlternates) {\n traceLog.push('Score calculated using all-or-nothing scoring (alternate responses disable partial scoring).');\n traceLog.push('Student must get all categories completely correct to receive full credit.');\n } else if (partialScoringEnabled) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push('Student receives credit for each correct placement, with deductions for incorrect placements beyond required amount.');\n \n if (draggedChoices > 0) {\n const totalCorrect = builtCategories.reduce((sum, cat) => \n sum + (cat.choices || []).filter(choice => choice.correct).length, 0);\n const totalIncorrect = draggedChoices - totalCorrect;\n const maxPossible = (correctResponse || []).reduce((sum, cat) => \n sum + (cat.choices || []).length, 0);\n \n traceLog.push(`Partial scoring calculation: ${totalCorrect} correct placements, ${totalIncorrect} incorrect placements.`);\n \n if (draggedChoices > maxPossible) {\n const extraPlacements = draggedChoices - maxPossible;\n traceLog.push(`${extraPlacements} extra placement(s) beyond required amount will be deducted from score.`);\n }\n }\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n traceLog.push('Student must get all categories completely correct to receive full credit.');\n }\n\n const score = getTotalScore(model, session, env);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\nexport const outcome = (question, session, env) => {\n if (env.mode !== 'evaluate') {\n return Promise.reject(new Error('Can not call outcome when mode is not evaluate'));\n } else {\n return new Promise((resolve) => {\n // A player sends an untouched item's session as `{ id, element }`, without `answers`.\n if (!session || isEmpty(session) || !session.answers) {\n resolve({\n score: 0,\n empty: true,\n traceLog: ['Student did not place any choices into categories. Score is 0.'],\n });\n } else {\n const traceLog = getLogTrace(question, session, env);\n const score = getTotalScore(question, session, env);\n \n resolve({\n score,\n empty: false,\n traceLog,\n });\n }\n });\n }\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n const { mode, role } = env || {};\n\n if (mode !== 'evaluate' && role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({ answers: correctResponse, id: 1 });\n } else {\n return resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { categories, choices, correctResponse, maxAnswerChoices } = model;\n const {\n minChoices = 1,\n minCategories = 1,\n maxCategories = 12,\n maxLengthPerChoice = 300,\n maxLengthPerCategory = 150,\n } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const errors = {};\n const choicesErrors = {};\n const categoriesErrors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n (categories || []).forEach((category) => {\n const { id, label } = category;\n\n if (getInnerText(label).length > maxLengthPerCategory) {\n categoriesErrors[id] = `Category labels should be no more than ${maxLengthPerCategory} characters long.`;\n }\n });\n\n (reversedChoices || []).forEach((choice, index) => {\n const { id, content } = choice;\n\n if (getInnerText(content).length > maxLengthPerChoice) {\n choicesErrors[id] = `Tokens should be no more than ${maxLengthPerChoice} characters long.`;\n }\n\n if (!getContent(content)) {\n choicesErrors[id] = 'Tokens should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.content === content);\n\n if (identicalAnswer) {\n choicesErrors[id] = 'Tokens content should be unique.';\n }\n }\n });\n\n const nbOfCategories = (categories || []).length;\n const nbOfChoices = (choices || []).length;\n\n if (nbOfCategories > maxCategories) {\n errors.categoriesError = `No more than ${maxCategories} categories should be defined.`;\n } else if (nbOfCategories < minCategories) {\n errors.categoriesError = `There should be at least ${minCategories} category defined.`;\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.choicesError = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (nbOfChoices && nbOfCategories) {\n let hasAssociations = false;\n\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [] } = response;\n\n if (choices.length) {\n hasAssociations = true;\n } else {\n alternateResponses.forEach((alternate) => {\n if ((alternate || []).length) {\n hasAssociations = true;\n }\n });\n }\n });\n\n let duplicateAlternateIndex = -1;\n let duplicateCategory = '';\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [], category } = response;\n\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isCorrectResponseDuplicated(choices, alternateResponses);\n\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isAlternateDuplicated(alternateResponses);\n }\n\n duplicateCategory = category;\n }\n });\n\n if (duplicateAlternateIndex > -1) {\n errors.duplicateAlternate = { index: duplicateAlternateIndex, category: duplicateCategory };\n }\n\n if (!hasAssociations) {\n errors.associationError = 'At least one token should be assigned to at least one category.';\n }\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n if (!isEmpty(categoriesErrors)) {\n errors.categoriesErrors = categoriesErrors;\n }\n\n return errors;\n};\n"],"mappings":";;AAEA,IAAI,KAAA,IAAA,wBAAA,EAAA,CAAA,QAAA,CAAM,6BAA6B,GAAG,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,IAAI,EAAE,UAAU,WAAW,EAAE,aAAa,EAAE,UAAU,SAAS,CAAC,GAAG,KAAK,GAAG,MAAM;CAC3J,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU;EAC3C,IAAI,IAAI,EAAE,MAAM,MAAM,MAAM,EAAE,aAAa,CAAC;EAC5C,OAAO,KAAK,EAAE,SAAS,CAAC;CACzB;AACD,GAAG,KAAK,GAAG,MAAM,IAAI,SAAS,MAAM;CACnC,EAAE,gBAAgB,GAAG,aAAa,CAAC;CACnC,IAAI,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,OAAO;EAC/B,GAAG,EAAE,MAAM,MAAM,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;EACrD,UAAU,EAAE;CACb,EAAE;CACF,EAAE,aAAa,CAAC;CAChB,IAAI,IAAI,EAAE,QAAQ,GAAG,MAAM;EAC1B,IAAI,IAAI,EAAE,MAAM,MAAM,EAAE,aAAa,EAAE,EAAE;EACzC,OAAO,KAAK,EAAE;CACf,GAAG,CAAC;CACJ,EAAE,WAAW,CAAC;CACd,IAAI,IA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,CAAC;CAED,IAAM,KAAkB,KAAc,CAAC,EAAA,CAAG,QACpC,KAAe,KAAW,CAAC,EAAA,CAAG;CAcpC,IAZI,IAAiB,IACnB,EAAO,kBAAkB,gBAAgB,EAAc,kCAC9C,IAAiB,MAC1B,EAAO,kBAAkB,4BAA4B,EAAc,sBAGjE,IAAc,IAChB,EAAO,eAAe,4BAA4B,EAAW,qBACpD,IAAc,MACvB,EAAO,eAAe,gBAAgB,EAAiB,+BAGrD,KAAe,GAAgB;EACjC,IAAI,IAAkB;EAEtB,CAAC,KAAmB,CAAC,EAAA,CAAG,SAAS,MAAa;GAC5C,IAAM,EAAE,aAAU,CAAC,GAAG,wBAAqB,CAAC,MAAM;GAElD,AAAI,EAAQ,SACV,IAAkB,KAElB,EAAmB,SAAS,MAAc;IACxC,CAAK,KAAa,CAAC,EAAA,CAAG,WACpB,IAAkB;GAEtB,CAAC;EAEL,CAAC;EAED,IAAI,IAA0B,IAC1B,IAAoB;EAmBxB,CAlBC,KAAmB,CAAC,EAAA,CAAG,SAAS,MAAa;GAC5C,IAAM,EAAE,aAAU,CAAC,GAAG,wBAAqB,CAAC,GAAG,gBAAa;GAE5D,AAAI,MAA4B,OAC9B,IAA0B,EAA4B,GAAS,CAAkB,GAE7E,MAA4B,OAC9B,IAA0B,EAAsB,CAAkB,IAGpE,IAAoB;EAExB,CAAC,GAEG,IAA0B,OAC5B,EAAO,qBAAqB;GAAE,OAAO;GAAyB,UAAU;EAAkB,IAGvF,MACH,EAAO,mBAAmB;CAE9B;CAUA,OARK,EAAQ,CAAa,MACxB,EAAO,gBAAgB,IAGpB,EAAQ,CAAgB,MAC3B,EAAO,mBAAmB,IAGrB;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../lib-react/categorize/dist/scoring.js","../../../../../../shared/feedback/dist/index.js","../../../../../../shared/controller-utils/dist/index.js","../../../../src/controller/defaults.ts","../../../../src/controller/utils.ts","../../../../src/controller/index.ts"],"sourcesContent":["import e from \"debug\";\n//#region src/scoring.ts\nvar t = e(\"@pie-lib:categorize:scoring\"), n = (e) => !e || !e.weighting ? [] : e.weighting.enabled && e.weighting && e.weighting.rules || [], r = (e, n) => {\n\tif (t(\"partial? \", e), !(!e || !e.enabled)) {\n\t\tlet t = e.rules.find((e) => e.category === n);\n\t\treturn t && t.rules || [];\n\t}\n}, i = (e, i) => new Promise((a) => {\n\tt(\"categories: \", e, \"scoring: \", i);\n\tlet o = n(i), s = e.map((e) => ({\n\t\t...o.find((t) => t.category === e.id) || { points: 1 },\n\t\tcategory: e.id\n\t}));\n\tt(\"weights: \", s);\n\tlet c = e.reduce((e, t) => {\n\t\tlet n = s.find((e) => e.category === t.id);\n\t\treturn e += n.points;\n\t}, 0);\n\tt(\"total: \", c);\n\tlet l = e.map((e) => {\n\t\tlet n = s.find((t) => t.category === e.id).points;\n\t\tif (t(\"category: \", e), e.correct === !0) return {\n\t\t\tcategory: e.id,\n\t\t\tscore: n,\n\t\t\tpoints: n\n\t\t};\n\t\t{\n\t\t\tlet a = r(i.partial, e.id);\n\t\t\tif (t(\"partial rules for category: \", a), a) {\n\t\t\t\tlet r = (e.choices || []).filter((e) => e.correct).length;\n\t\t\t\tt(\"correctCount: \", r);\n\t\t\t\tlet i = a.find((e) => e.count === r);\n\t\t\t\tt(\"rule: \", i), i ||= {\n\t\t\t\t\tpercent: 0,\n\t\t\t\t\tcount: r\n\t\t\t\t};\n\t\t\t\tlet o = n * (i.percent / 100);\n\t\t\t\treturn {\n\t\t\t\t\tcategory: e.id,\n\t\t\t\t\tscore: o,\n\t\t\t\t\tpoints: n,\n\t\t\t\t\tpartial: {\n\t\t\t\t\t\tcorrectChoices: r,\n\t\t\t\t\t\trule: i\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t} else return {\n\t\t\t\tcategory: e.id,\n\t\t\t\tscore: 0,\n\t\t\t\tpoints: n\n\t\t\t};\n\t\t}\n\t}), u = l.reduce((e, t) => e += t.score, 0);\n\tt(\"weightedScore: \", u), a({\n\t\tscore: parseFloat((u / c).toFixed(2), 10),\n\t\tdetails: {\n\t\t\tweighted: {\n\t\t\t\ttotal: c,\n\t\t\t\tscore: u\n\t\t\t},\n\t\t\tcategories: l\n\t\t}\n\t});\n});\n//#endregion\nexport { i as score };\n","//#region src/defaults.ts\nvar e = {\n\tcorrect: {\n\t\ttype: \"default\",\n\t\tdefault: \"Correct\",\n\t\tcustom: \"Correct\"\n\t},\n\tincorrect: {\n\t\ttype: \"default\",\n\t\tdefault: \"Incorrect\",\n\t\tcustom: \"Incorrect\"\n\t},\n\tpartial: {\n\t\ttype: \"default\",\n\t\tdefault: \"Nearly\",\n\t\tcustom: \"Nearly\"\n\t},\n\tunanswered: {\n\t\ttype: \"default\",\n\t\tdefault: \"You have not entered a response\",\n\t\tcustom: \"You have not entered a response\"\n\t}\n};\n//#endregion\n//#region src/utils.ts\nfunction t(e) {\n\treturn e === \"partially-correct\" ? \"partial\" : e;\n}\n//#endregion\n//#region src/index.ts\nfunction n(n, r) {\n\tlet i = {\n\t\t...e,\n\t\t...r\n\t}, a = t(n), o = e[a] || {}, s = i[a] || o;\n\treturn {\n\t\tconfig: s,\n\t\tfallback: o[s.type || \"default\"]\n\t};\n}\nfunction r(e, t = {}) {\n\treturn new Promise((r) => {\n\t\tlet { config: a, fallback: o } = n(e, t);\n\t\ti(a, o).then(r);\n\t});\n}\nfunction i(e, t) {\n\treturn new Promise((n) => {\n\t\tif (!e || e.type === \"none\") {\n\t\t\tn(void 0);\n\t\t\treturn;\n\t\t}\n\t\tn(e[e.type] || t);\n\t});\n}\nfunction a(e, t = {}) {\n\tlet { config: r, fallback: i } = n(e, t);\n\treturn o(r, i);\n}\nfunction o(e, t) {\n\tif (!(!e || e.type === \"none\")) return e[e.type] || t;\n}\n//#endregion\nexport { e as defaultFeedback, o as getActualFeedback, a as getActualFeedbackForCorrectness, i as getFeedback, r as getFeedbackForCorrectness, t as normalizeCorrectness };\n","//#region \\0rolldown/runtime.js\nvar e = Object.defineProperty, t = (t, n) => {\n\tlet r = {};\n\tfor (var i in t) e(r, i, {\n\t\tget: t[i],\n\t\tenumerable: !0\n\t});\n\treturn n || e(r, Symbol.toStringTag, { value: \"Module\" }), r;\n};\n//#endregion\n//#region src/persistence.ts\nfunction n(e) {\n\treturn Array.isArray(e) ? e.filter((e) => e != null) : [];\n}\nfunction r(e) {\n\tlet t = [...e];\n\tfor (let e = t.length - 1; e > 0; e--) {\n\t\tlet n = Math.floor(Math.random() * (e + 1));\n\t\t[t[e], t[n]] = [t[n], t[e]];\n\t}\n\treturn t;\n}\nfunction i(e) {\n\treturn e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == \"object\" && Object.keys(e).length === 0;\n}\nasync function a(e, t, a, o = \"value\") {\n\tlet s = n(t?.data?.shuffledValues ?? t?.shuffledValues ?? []);\n\tif (!t) {\n\t\tconsole.warn(\"Unable to save shuffled choices because there's no session.\");\n\t\treturn;\n\t}\n\tif (!i(s)) return n(s.map((t) => e.find((e) => e[o] === t)));\n\tlet c = r(e);\n\tif (a && typeof a == \"function\") try {\n\t\tlet e = n(c.map((e) => e[o]));\n\t\ti(e) ? console.error(`shuffledValues is an empty array - refusing to call updateSession. shuffledChoices: ${JSON.stringify(c)}, key: ${o}`) : await a(t.id, t.element, { shuffledValues: e });\n\t} catch (e) {\n\t\tconsole.warn(\"Unable to save shuffled order for choices\"), console.error(e);\n\t}\n\telse console.warn(\"Unable to save shuffled choices, shuffle will happen every time.\");\n\treturn c;\n}\nfunction o(e, t, n) {\n\treturn !!(e.lockChoiceOrder || n?.[\"@pie-element\"]?.lockChoiceOrder);\n}\n//#endregion\n//#region src/partial-scoring.ts\nvar s = /* @__PURE__ */ t({ enabled: () => c });\nfunction c(e, t, n) {\n\treturn e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n != \"boolean\" || n;\n}\n//#endregion\nexport { a as getShuffledChoices, o as lockChoices, s as partialScoring };\n","import type { CategorizeModel, Category, CategoryChoice, CategoryCorrectResponse } from '../types.js';\n\nexport default {\n alternates: [] as unknown[],\n categories: [] as Category[],\n categoriesPerRow: 2,\n choices: [] as CategoryChoice[],\n choicesLabel: '',\n choicesPosition: 'below',\n correctResponse: [] as CategoryCorrectResponse[],\n feedbackEnabled: false,\n lockChoiceOrder: true,\n maxAnswerChoices: 6,\n maxChoicesPerCategory: 0,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n rowLabels: [''],\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n minRowHeight: '80px',\n} satisfies Omit<CategorizeModel, 'id' | 'element'>;\n","import type { CategoryChoice, CategoryCorrectResponse, MultiplePlacements } from '../types.js';\n\n// used in configure too, for consistency modify it there too\nexport const multiplePlacements = { enabled: 'Yes', disabled: 'No', perChoice: 'Set Per Choice' } as const satisfies Record<\n string,\n MultiplePlacements\n>;\n\n// used to validate the config\nexport const isCorrectResponseDuplicated = (choices: string[], alternate: string[][]) => {\n if (choices.length < 1 || alternate.length < 1) {\n return -1;\n }\n\n const stringChoices = JSON.stringify(choices.sort());\n const stringAlternate = alternate.reduce<string[]>(\n (total, current) => (current.length > 0 ? [...total, JSON.stringify(current.sort())] : total),\n [],\n );\n const foundIndexDuplicate = stringAlternate.findIndex((alternate) => alternate.length && alternate === stringChoices);\n\n return foundIndexDuplicate;\n};\n\nexport const isAlternateDuplicated = (alternate: string[][]) => {\n if (alternate.length <= 1) {\n return -1;\n }\n\n const elementSet = new Set<string>();\n const stringAlternate = alternate.reduce<string[]>(\n (total, current) => (current.length > 0 ? [...total, JSON.stringify(current.sort())] : total),\n [],\n );\n\n for (let i = 0; i < stringAlternate.length; i++) {\n if (elementSet.has(stringAlternate[i]) && stringAlternate[i]) {\n return i;\n }\n\n elementSet.add(stringAlternate[i]);\n }\n\n return -1;\n};\n\n// calculate the minimum number of populated response areas (categories) in the correct answer or alternates\n// and create an array with the possible responses ids\nexport const getCompleteResponseDetails = (\n correctResponse: CategoryCorrectResponse[],\n alternates: string[][][],\n allChoices: CategoryChoice[],\n) => {\n const choicesPerCategory = correctResponse.map((category) => category.choices);\n const possibleResponses = [choicesPerCategory.flat()];\n let responseAreasToBeFilled = choicesPerCategory.filter((choices) => choices.length).length;\n\n if (alternates.length) {\n const alternatesPerChoice = alternates[0]?.length || 0; // number of alternates\n\n [...Array(alternatesPerChoice).keys()].forEach((index) => {\n const alternatesPerResponse = alternates.map((alternate) => alternate[index]);\n const filledCategories = alternatesPerResponse.filter((category) => category?.length).length;\n possibleResponses.push(alternatesPerResponse.flat());\n\n if (filledCategories < responseAreasToBeFilled) {\n responseAreasToBeFilled = filledCategories;\n }\n });\n }\n\n // check if any correct answer have any unplaced answer choices\n const hasUnplacedChoices = possibleResponses.some(\n (response) => !allChoices.every((val) => response.includes(val?.id)),\n );\n\n return { responseAreasToBeFilled, possibleResponses, hasUnplacedChoices };\n};\n","import { isEmpty } from '@pie-element/shared-lodash';\nimport { buildState, score } from '@pie-lib/categorize';\nimport { getFeedbackForCorrectness, type Feedback } from '@pie-element/shared-feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';\nimport Translator from '@pie-lib/translator';\nimport type {\n CategorizeAnswer,\n CategorizeConfiguration,\n CategorizeModel,\n CategorizeSession,\n Category,\n CategoryChoice,\n CategoryCorrectResponse,\n MultiplePlacements,\n} from '../types.js';\n\nconst { translator } = Translator;\nimport defaults from './defaults.js';\nimport { getCompleteResponseDetails, isAlternateDuplicated, isCorrectResponseDuplicated, multiplePlacements } from './utils.js';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\ntype Correctness = 'correct' | 'incorrect' | 'partially-correct';\n\n/** A choice as `buildState` returns it inside a category. */\ntype BuiltChoice = CategoryChoice & { correct?: boolean };\n\n/** A category as `buildState` returns it, holding the choices the learner placed in it. */\ntype BuiltCategory = Omit<Category, 'choices'> & { choices?: BuiltChoice[] };\n\ntype BuiltState = { categories: BuiltCategory[]; correct: boolean };\n\n/** The session shape the shared choice utilities take; ours may carry a numeric id. */\ntype SharedSession = Parameters<typeof getShuffledChoices>[1];\n\n/** Errors `validate()` reports, keyed by field; `choicesErrors` and `categoriesErrors` are keyed by id. */\nexport type CategorizeValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n categoriesError?: string;\n choicesError?: string;\n duplicateAlternate?: { index: number; category: string };\n associationError?: string;\n choicesErrors?: Record<string, string>;\n categoriesErrors?: Record<string, string>;\n};\n\nexport const getPartialScore = (correctResponse: CategoryCorrectResponse[], builtCategories: BuiltCategory[]) => {\n // in the resulted best scenario we make a sum with all the correct responses\n // and all the placements\n const { placements, score } = builtCategories.reduce(\n (acc, { choices = [] }) => ({\n placements: acc.placements + choices.length,\n score: acc.score + choices.filter((ch) => ch.correct).length,\n }),\n { placements: 0, score: 0 },\n );\n\n // in the correct response, we make a sum of the max possible score\n const { maxScore } = correctResponse.reduce(\n (acc, { choices }) => ({\n maxScore: acc.maxScore + choices.length,\n }),\n { maxScore: 0 },\n );\n\n // if there are any extra placements, we subtract from the obtained score\n const extraPlacements = placements > maxScore ? placements - maxScore : 0;\n const totalScore = (score - extraPlacements) / maxScore;\n\n return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));\n};\n\nconst getAlternates = (correctResponse: CategoryCorrectResponse[]) =>\n correctResponse.map((c) => c.alternateResponses).filter((alternate): alternate is string[][] => !!alternate);\n\nexport const getTotalScore = (\n question: CategorizeModel,\n session: CategorizeSession | undefined,\n env: PieEnvironment | undefined,\n) => {\n if (!session) {\n return 0;\n }\n\n if (Object.keys(session).length === 0) {\n return 0;\n }\n const { categories, choices } = question || ({} as Partial<CategorizeModel>);\n const correctResponse = (question || ({} as Partial<CategorizeModel>)).correctResponse || [];\n const answers = session.answers || [];\n\n // this function is used in pie-ui/categorize as well, in order to get the best scenario\n // so we get the best scenario and calculate the score\n const { categories: builtCategories, correct }: BuiltState = buildState(categories, choices, answers, correctResponse);\n\n const alternates = getAlternates(correctResponse);\n const enabled = partialScoring.enabled(question, env);\n\n // if there are any alternates, there will be no partial scoring!\n if (enabled && !alternates.length) {\n // we apply partial scoring\n return getPartialScore(correctResponse, builtCategories);\n }\n\n // else we apply dichotomous\n return correct ? 1 : 0;\n};\n\nexport const getCorrectness = (\n question: CategorizeModel,\n session: CategorizeSession | undefined,\n env: PieEnvironment,\n) => {\n return new Promise<Correctness | undefined>((resolve) => {\n if (env.mode === 'evaluate') {\n const score = getTotalScore(question, session, env);\n if (score === 1) {\n resolve('correct');\n } else if (score === 0) {\n resolve('incorrect');\n } else {\n resolve('partially-correct');\n }\n } else {\n resolve(undefined);\n }\n });\n};\n\nexport const createDefaultModel = (model: Partial<CategorizeModel> = {}) =>\n new Promise<Partial<CategorizeModel>>((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nexport const normalize = (question: CategorizeModel) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport const model = async (\n question: CategorizeModel,\n session: CategorizeSession | undefined,\n env: PieEnvironment,\n updateSession?: PieUpdateSession,\n) => {\n const normalizedQuestion = normalize(question);\n const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);\n\n const mode = env?.mode;\n const role = env?.role;\n\n const {\n categories,\n categoriesPerRow,\n choicesLabel,\n choicesPosition,\n correctResponse,\n feedback,\n feedbackEnabled,\n promptEnabled,\n prompt,\n rowLabels,\n rationaleEnabled,\n rationale,\n teacherInstructionsEnabled,\n teacherInstructions,\n language,\n maxChoicesPerCategory,\n extraCSSRules,\n minRowHeight,\n fontSizeFactor,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n } = normalizedQuestion;\n let choices: CategoryChoice[] | undefined = normalizedQuestion.choices;\n let { note } = normalizedQuestion;\n let fb: string | undefined;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session as SharedSession, env);\n\n const filteredCorrectResponse = correctResponse.map((response) => {\n const filteredChoices = (response.choices || []).filter((choice) => choice !== 'null');\n return { ...response, choices: filteredChoices };\n });\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(answerCorrectness as Correctness, feedback as Partial<Feedback> | undefined);\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session as SharedSession, updateSession, 'id');\n }\n\n const resolvedAllowMultiple = ((): MultiplePlacements => {\n if (question.allowMultiplePlacementsEnabled != null) {\n return question.allowMultiplePlacementsEnabled;\n }\n // Derive from correct response: if any choice id appears in more than one category, reuse is required\n const allChoiceIds = (correctResponse || []).flatMap((cr) => cr.choices || []);\n const isExclusive = allChoiceIds.length === new Set(allChoiceIds).size;\n return isExclusive ? multiplePlacements.disabled : multiplePlacements.enabled;\n })();\n\n choices = (choices || []).map((c) => {\n let categoryCount: number;\n if (resolvedAllowMultiple === multiplePlacements.enabled) {\n categoryCount = 0;\n } else if (resolvedAllowMultiple === multiplePlacements.disabled) {\n categoryCount = 1;\n } else {\n // perChoice — use the value set on each choice individually\n categoryCount = c.categoryCount || 0;\n }\n return { ...c, categoryCount };\n });\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: language });\n }\n\n const alternates = getAlternates(filteredCorrectResponse);\n const showInstructorContent = role === 'instructor' && (mode === 'view' || mode === 'evaluate');\n const { responseAreasToBeFilled, possibleResponses, hasUnplacedChoices } = getCompleteResponseDetails(\n filteredCorrectResponse,\n normalizedQuestion.allowAlternateEnabled ? alternates : [],\n normalizedQuestion.choices,\n );\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n maxChoicesPerCategory,\n correctness: answerCorrectness,\n choices: choices || [],\n choicesLabel: choicesLabel || '',\n choicesPosition,\n disabled: mode !== 'gather',\n feedback: fb,\n lockChoiceOrder,\n prompt: promptEnabled ? prompt : null,\n rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,\n language,\n extraCSSRules,\n fontSizeFactor,\n minRowHeight: minRowHeight,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n possibleResponses,\n responseAreasToBeFilled,\n hasUnplacedChoices,\n ...(question.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: resolvedAllowMultiple }),\n rationale: showInstructorContent && rationaleEnabled ? rationale : null,\n teacherInstructions: showInstructorContent && teacherInstructionsEnabled ? teacherInstructions : null,\n };\n\n return out;\n};\n\n /**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (model: CategorizeModel, session: CategorizeSession | undefined, env: PieEnvironment) => {\n const traceLog: string[] = [];\n const { answers } = session || ({} as CategorizeSession);\n const { categories, choices, correctResponse } = model || ({} as Partial<CategorizeModel>);\n\n const draggedChoices = (answers as CategorizeAnswer[]).reduce(\n (sum, a) => sum + (a.choices?.length || 0),\n 0\n );\n\n const alternates = getAlternates(correctResponse as CategoryCorrectResponse[]);\n const hasAlternates = alternates.length > 0;\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n const builtState: BuiltState | null =\n draggedChoices > 0\n ? buildState(categories, choices, answers, correctResponse)\n : null;\n\n const builtCategories = builtState?.categories || [];\n \n if (draggedChoices > 0) {\n traceLog.push(`Student placed ${draggedChoices} choice(s) into categories.`);\n \n (categories || []).forEach((category) => {\n const categoryId = category.id;\n const builtCategory = builtCategories.find(c => c.id === categoryId);\n const studentChoices = builtCategory ? builtCategory.choices || [] : [];\n const correctResponseForCategory = (correctResponse || []).find(cr => cr.category === categoryId);\n const expectedChoices = correctResponseForCategory ? correctResponseForCategory.choices || [] : [];\n \n if (expectedChoices.length > 0) {\n if (studentChoices.length === 0) {\n traceLog.push(`Category ${categoryId}: student left empty (should contain ${expectedChoices.length} choice(s)).`);\n } else {\n const correctCount = studentChoices.filter(choice => choice.correct).length;\n const incorrectCount = studentChoices.length - correctCount;\n \n if (correctCount > 0 && incorrectCount === 0) {\n traceLog.push(`Category ${categoryId}: student placed ${correctCount} correct choice(s).`);\n } else if (correctCount === 0 && incorrectCount > 0) {\n traceLog.push(`Category ${categoryId}: student placed ${incorrectCount} incorrect choice(s).`);\n } else {\n traceLog.push(`Category ${categoryId}: student placed ${correctCount} correct and ${incorrectCount} incorrect choice(s).`);\n }\n }\n }\n });\n } else {\n traceLog.push('Student did not place any choices into categories.');\n }\n\n if (hasAlternates) {\n traceLog.push('Alternate response combinations are accepted for this question.');\n }\n\n if (hasAlternates) {\n traceLog.push('Score calculated using all-or-nothing scoring (alternate responses disable partial scoring).');\n traceLog.push('Student must get all categories completely correct to receive full credit.');\n } else if (partialScoringEnabled) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push('Student receives credit for each correct placement, with deductions for incorrect placements beyond required amount.');\n \n if (draggedChoices > 0) {\n const totalCorrect = builtCategories.reduce((sum, cat) => \n sum + (cat.choices || []).filter(choice => choice.correct).length, 0);\n const totalIncorrect = draggedChoices - totalCorrect;\n const maxPossible = (correctResponse || []).reduce((sum, cat) => \n sum + (cat.choices || []).length, 0);\n \n traceLog.push(`Partial scoring calculation: ${totalCorrect} correct placements, ${totalIncorrect} incorrect placements.`);\n \n if (draggedChoices > maxPossible) {\n const extraPlacements = draggedChoices - maxPossible;\n traceLog.push(`${extraPlacements} extra placement(s) beyond required amount will be deducted from score.`);\n }\n }\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n traceLog.push('Student must get all categories completely correct to receive full credit.');\n }\n\n const score = getTotalScore(model, session, env);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\nexport const outcome = (question: CategorizeModel, session: CategorizeSession | undefined, env: PieEnvironment) => {\n if (env.mode !== 'evaluate') {\n return Promise.reject(new Error('Can not call outcome when mode is not evaluate'));\n } else {\n return new Promise<{ score: number; empty: boolean; traceLog: string[] }>((resolve) => {\n // A player sends an untouched item's session as `{ id, element }`, without `answers`.\n if (!session || isEmpty(session) || !session.answers) {\n resolve({\n score: 0,\n empty: true,\n traceLog: ['Student did not place any choices into categories. Score is 0.'],\n });\n } else {\n const traceLog = getLogTrace(question, session, env);\n const score = getTotalScore(question, session, env);\n \n resolve({\n score,\n empty: false,\n traceLog,\n });\n }\n });\n }\n};\n\nexport const createCorrectResponseSession = (question: CategorizeModel, env: PieEnvironment) => {\n return new Promise<CategorizeSession | null>((resolve) => {\n const mode = env?.mode;\n const role = env?.role;\n\n if (mode !== 'evaluate' && role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({ answers: correctResponse, id: 1 });\n } else {\n return resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html: string | undefined) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html: string | undefined) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (\n model: Partial<CategorizeModel> = {},\n config: CategorizeConfiguration = {},\n): CategorizeValidationErrors => {\n const { categories, choices, correctResponse, maxAnswerChoices } = model;\n const {\n minChoices = 1,\n minCategories = 1,\n maxCategories = 12,\n maxLengthPerChoice = 300,\n maxLengthPerCategory = 150,\n } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const errors: CategorizeValidationErrors = {};\n const choicesErrors: Record<string, string> = {};\n const categoriesErrors: Record<string, string> = {};\n\n (['teacherInstructions', 'prompt', 'rationale'] as const).forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n (categories || []).forEach((category) => {\n const { id, label } = category;\n\n if (getInnerText(label).length > maxLengthPerCategory) {\n categoriesErrors[id] = `Category labels should be no more than ${maxLengthPerCategory} characters long.`;\n }\n });\n\n (reversedChoices || []).forEach((choice, index) => {\n const { id, content } = choice;\n\n if (getInnerText(content).length > maxLengthPerChoice) {\n choicesErrors[id] = `Tokens should be no more than ${maxLengthPerChoice} characters long.`;\n }\n\n if (!getContent(content)) {\n choicesErrors[id] = 'Tokens should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.content === content);\n\n if (identicalAnswer) {\n choicesErrors[id] = 'Tokens content should be unique.';\n }\n }\n });\n\n const nbOfCategories = (categories || []).length;\n const nbOfChoices = (choices || []).length;\n\n if (nbOfCategories > maxCategories) {\n errors.categoriesError = `No more than ${maxCategories} categories should be defined.`;\n } else if (nbOfCategories < minCategories) {\n errors.categoriesError = `There should be at least ${minCategories} category defined.`;\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} choices defined.`;\n } else if (maxAnswerChoices !== undefined && nbOfChoices > maxAnswerChoices) {\n errors.choicesError = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (nbOfChoices && nbOfCategories) {\n let hasAssociations = false;\n\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [] } = response;\n\n if (choices.length) {\n hasAssociations = true;\n } else {\n alternateResponses.forEach((alternate) => {\n if ((alternate || []).length) {\n hasAssociations = true;\n }\n });\n }\n });\n\n let duplicateAlternateIndex = -1;\n let duplicateCategory = '';\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [], category } = response;\n\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isCorrectResponseDuplicated(choices, alternateResponses);\n\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isAlternateDuplicated(alternateResponses);\n }\n\n duplicateCategory = category;\n }\n });\n\n if (duplicateAlternateIndex > -1) {\n errors.duplicateAlternate = { index: duplicateAlternateIndex, category: duplicateCategory };\n }\n\n if (!hasAssociations) {\n errors.associationError = 'At least one token should be assigned to at least one category.';\n }\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n if (!isEmp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AAC,EAAA,CAAG,SAAS,MAAa;GAC5C,IAAM,EAAE,aAAU,CAAC,GAAG,wBAAqB,CAAC,MAAM;GAElD,AAAI,EAAQ,SACV,IAAkB,KAElB,EAAmB,SAAS,MAAc;IACxC,CAAK,KAAa,CAAC,EAAA,CAAG,WACpB,IAAkB;GAEtB,CAAC;EAEL,CAAC;EAED,IAAI,IAA0B,IAC1B,IAAoB;EAmBxB,CAlBC,KAAmB,CAAC,EAAA,CAAG,SAAS,MAAa;GAC5C,IAAM,EAAE,aAAU,CAAC,GAAG,wBAAqB,CAAC,GAAG,gBAAa;GAE5D,AAAI,MAA4B,OAC9B,IAA0B,EAA4B,GAAS,CAAkB,GAE7E,MAA4B,OAC9B,IAA0B,EAAsB,CAAkB,IAGpE,IAAoB;EAExB,CAAC,GAEG,IAA0B,OAC5B,EAAO,qBAAqB;GAAE,OAAO;GAAyB,UAAU;EAAkB,IAGvF,MACH,EAAO,mBAAmB;CAE9B;CAUA,OARK,EAAQ,CAAa,MACxB,EAAO,gBAAgB,IAGpB,EAAQ,CAAgB,MAC3B,EAAO,mBAAmB,IAGrB;AACT"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
import type { Category, CategoryChoice, CategoryCorrectResponse } from '../types.js';
|
|
1
2
|
declare const _default: {
|
|
2
|
-
alternates:
|
|
3
|
-
categories:
|
|
3
|
+
alternates: unknown[];
|
|
4
|
+
categories: Category[];
|
|
4
5
|
categoriesPerRow: number;
|
|
5
|
-
choices:
|
|
6
|
+
choices: CategoryChoice[];
|
|
6
7
|
choicesLabel: string;
|
|
7
|
-
choicesPosition:
|
|
8
|
-
correctResponse:
|
|
9
|
-
feedbackEnabled:
|
|
10
|
-
lockChoiceOrder:
|
|
8
|
+
choicesPosition: "below";
|
|
9
|
+
correctResponse: CategoryCorrectResponse[];
|
|
10
|
+
feedbackEnabled: false;
|
|
11
|
+
lockChoiceOrder: true;
|
|
11
12
|
maxAnswerChoices: number;
|
|
12
13
|
maxChoicesPerCategory: number;
|
|
13
|
-
partialScoring:
|
|
14
|
+
partialScoring: true;
|
|
14
15
|
prompt: string;
|
|
15
|
-
promptEnabled:
|
|
16
|
+
promptEnabled: true;
|
|
16
17
|
rationale: string;
|
|
17
|
-
rationaleEnabled:
|
|
18
|
+
rationaleEnabled: true;
|
|
18
19
|
rowLabels: string[];
|
|
19
|
-
studentInstructionsEnabled:
|
|
20
|
+
studentInstructionsEnabled: true;
|
|
20
21
|
teacherInstructions: string;
|
|
21
|
-
teacherInstructionsEnabled:
|
|
22
|
-
toolbarEditorPosition:
|
|
22
|
+
teacherInstructionsEnabled: true;
|
|
23
|
+
toolbarEditorPosition: "bottom";
|
|
23
24
|
minRowHeight: string;
|
|
24
25
|
};
|
|
25
26
|
export default _default;
|
|
@@ -1,10 +1,76 @@
|
|
|
1
1
|
import { score } from '@pie-lib/categorize';
|
|
2
|
+
import type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';
|
|
3
|
+
import type { CategorizeConfiguration, CategorizeModel, CategorizeSession, Category, CategoryChoice, CategoryCorrectResponse, MultiplePlacements } from '../types.js';
|
|
2
4
|
export { score };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type Correctness = 'correct' | 'incorrect' | 'partially-correct';
|
|
6
|
+
/** A choice as `buildState` returns it inside a category. */
|
|
7
|
+
type BuiltChoice = CategoryChoice & {
|
|
8
|
+
correct?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/** A category as `buildState` returns it, holding the choices the learner placed in it. */
|
|
11
|
+
type BuiltCategory = Omit<Category, 'choices'> & {
|
|
12
|
+
choices?: BuiltChoice[];
|
|
13
|
+
};
|
|
14
|
+
/** Errors `validate()` reports, keyed by field; `choicesErrors` and `categoriesErrors` are keyed by id. */
|
|
15
|
+
export type CategorizeValidationErrors = {
|
|
16
|
+
teacherInstructions?: string;
|
|
17
|
+
prompt?: string;
|
|
18
|
+
rationale?: string;
|
|
19
|
+
categoriesError?: string;
|
|
20
|
+
choicesError?: string;
|
|
21
|
+
duplicateAlternate?: {
|
|
22
|
+
index: number;
|
|
23
|
+
category: string;
|
|
24
|
+
};
|
|
25
|
+
associationError?: string;
|
|
26
|
+
choicesErrors?: Record<string, string>;
|
|
27
|
+
categoriesErrors?: Record<string, string>;
|
|
28
|
+
};
|
|
29
|
+
export declare const getPartialScore: (correctResponse: CategoryCorrectResponse[], builtCategories: BuiltCategory[]) => number;
|
|
30
|
+
export declare const getTotalScore: (question: CategorizeModel, session: CategorizeSession | undefined, env: PieEnvironment | undefined) => number;
|
|
31
|
+
export declare const getCorrectness: (question: CategorizeModel, session: CategorizeSession | undefined, env: PieEnvironment) => Promise<Correctness | undefined>;
|
|
32
|
+
export declare const createDefaultModel: (model?: Partial<CategorizeModel>) => Promise<Partial<CategorizeModel>>;
|
|
33
|
+
export declare const normalize: (question: CategorizeModel) => {
|
|
34
|
+
allowAlternateEnabled?: boolean;
|
|
35
|
+
allowMaxChoicesPerCategory?: boolean;
|
|
36
|
+
allowMultiplePlacementsEnabled?: MultiplePlacements;
|
|
37
|
+
alternates: unknown[];
|
|
38
|
+
choices: CategoryChoice[];
|
|
39
|
+
categoriesPerRow: number;
|
|
40
|
+
choicesPosition: "above" | "below" | "left" | "right";
|
|
41
|
+
choicesLabel: string;
|
|
42
|
+
lockChoiceOrder: boolean;
|
|
43
|
+
prompt: string;
|
|
44
|
+
promptEnabled: boolean;
|
|
45
|
+
categories: Category[];
|
|
46
|
+
correctResponse: CategoryCorrectResponse[];
|
|
47
|
+
feedback?: import("../types.js").CategorizeFeedback;
|
|
48
|
+
maxChoicesPerCategory: number;
|
|
49
|
+
rationale: string;
|
|
50
|
+
partialScoring: boolean;
|
|
51
|
+
feedbackEnabled: boolean;
|
|
52
|
+
rationaleEnabled: boolean;
|
|
53
|
+
spellCheckEnabled?: boolean;
|
|
54
|
+
studentInstructionsEnabled: boolean;
|
|
55
|
+
teacherInstructions: string;
|
|
56
|
+
teacherInstructionsEnabled: boolean;
|
|
57
|
+
note?: string;
|
|
58
|
+
toolbarEditorPosition: "bottom" | "top";
|
|
59
|
+
rubricEnabled?: boolean;
|
|
60
|
+
scoringType?: "auto" | "rubric";
|
|
61
|
+
language?: string;
|
|
62
|
+
maxAnswerChoices: number;
|
|
63
|
+
rowLabels: string[];
|
|
64
|
+
minRowHeight: string;
|
|
65
|
+
fontSizeFactor?: number;
|
|
66
|
+
autoplayAudioEnabled?: boolean;
|
|
67
|
+
completeAudioEnabled?: boolean;
|
|
68
|
+
customAudioButton?: import("@pie-element/shared-types").CustomAudioButton;
|
|
69
|
+
extraCSSRules?: import("@pie-element/shared-types").ExtraCSSRules;
|
|
70
|
+
id: string;
|
|
71
|
+
element: string;
|
|
72
|
+
accessibilityCatalogs?: import("@pie-element/shared-types").AccessibilityCatalog[];
|
|
73
|
+
};
|
|
8
74
|
/**
|
|
9
75
|
*
|
|
10
76
|
* @param {*} question
|
|
@@ -12,33 +78,39 @@ export declare const normalize: (question: any) => any;
|
|
|
12
78
|
* @param {*} env
|
|
13
79
|
* @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
|
|
14
80
|
*/
|
|
15
|
-
export declare const model: (question:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
81
|
+
export declare const model: (question: CategorizeModel, session: CategorizeSession | undefined, env: PieEnvironment, updateSession?: PieUpdateSession) => Promise<{
|
|
82
|
+
rationale: string | null;
|
|
83
|
+
teacherInstructions: string | null;
|
|
84
|
+
allowMultiplePlacementsEnabled?: MultiplePlacements | undefined;
|
|
85
|
+
categories: Category[];
|
|
86
|
+
categoriesPerRow: number;
|
|
87
|
+
maxChoicesPerCategory: number;
|
|
88
|
+
correctness: Correctness | undefined;
|
|
89
|
+
choices: CategoryChoice[];
|
|
90
|
+
choicesLabel: string;
|
|
91
|
+
choicesPosition: "above" | "below" | "left" | "right";
|
|
24
92
|
disabled: boolean;
|
|
25
93
|
feedback: string | undefined;
|
|
26
94
|
lockChoiceOrder: boolean;
|
|
27
|
-
prompt:
|
|
28
|
-
rowLabels:
|
|
29
|
-
note:
|
|
30
|
-
env:
|
|
31
|
-
showNote:
|
|
32
|
-
correctResponse:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
95
|
+
prompt: string | null;
|
|
96
|
+
rowLabels: string[];
|
|
97
|
+
note: string;
|
|
98
|
+
env: PieEnvironment;
|
|
99
|
+
showNote: boolean;
|
|
100
|
+
correctResponse: {
|
|
101
|
+
choices: string[];
|
|
102
|
+
category: string;
|
|
103
|
+
alternateResponses?: string[][];
|
|
104
|
+
}[] | undefined;
|
|
105
|
+
language: string | undefined;
|
|
106
|
+
extraCSSRules: import("@pie-element/shared-types").ExtraCSSRules | undefined;
|
|
107
|
+
fontSizeFactor: number | undefined;
|
|
108
|
+
minRowHeight: string;
|
|
109
|
+
autoplayAudioEnabled: boolean | undefined;
|
|
110
|
+
completeAudioEnabled: boolean | undefined;
|
|
111
|
+
customAudioButton: import("@pie-element/shared-types").CustomAudioButton | undefined;
|
|
112
|
+
possibleResponses: string[][];
|
|
113
|
+
responseAreasToBeFilled: number;
|
|
42
114
|
hasUnplacedChoices: boolean;
|
|
43
115
|
}>;
|
|
44
116
|
/**
|
|
@@ -48,7 +120,11 @@ export declare const model: (question: any, session: any, env: any, updateSessio
|
|
|
48
120
|
* @param {Object} env - the environment
|
|
49
121
|
* @returns {Array} traceLog - array of trace messages
|
|
50
122
|
*/
|
|
51
|
-
export declare const getLogTrace: (model:
|
|
52
|
-
export declare const outcome: (question:
|
|
53
|
-
|
|
54
|
-
|
|
123
|
+
export declare const getLogTrace: (model: CategorizeModel, session: CategorizeSession | undefined, env: PieEnvironment) => string[];
|
|
124
|
+
export declare const outcome: (question: CategorizeModel, session: CategorizeSession | undefined, env: PieEnvironment) => Promise<{
|
|
125
|
+
score: number;
|
|
126
|
+
empty: boolean;
|
|
127
|
+
traceLog: string[];
|
|
128
|
+
}>;
|
|
129
|
+
export declare const createCorrectResponseSession: (question: CategorizeModel, env: PieEnvironment) => Promise<CategorizeSession | null>;
|
|
130
|
+
export declare const validate: (model?: Partial<CategorizeModel>, config?: CategorizeConfiguration) => CategorizeValidationErrors;
|
package/dist/controller/index.js
CHANGED
|
@@ -15,12 +15,10 @@ var { translator: p } = s, m = (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
|
-
}, h = (e) => e.map((e) => e.alternateResponses).filter((e) => e), g = (e, t, n) => {
|
|
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: i } = e || {},
|
|
21
|
-
|
|
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;
|
|
20
|
+
let { categories: r, choices: i } = e || {}, o = (e || {}).correctResponse || [], { categories: s, correct: c } = a(r, i, t.answers || [], o), l = h(o);
|
|
21
|
+
return f.enabled(e, n) && !l.length ? m(o, s) : +!!c;
|
|
24
22
|
}, _ = (e, t, n) => new Promise((r) => {
|
|
25
23
|
if (n.mode === "evaluate") {
|
|
26
24
|
let i = g(e, t, n);
|
|
@@ -35,7 +33,7 @@ var { translator: p } = s, m = (e, t) => {
|
|
|
35
33
|
...e,
|
|
36
34
|
...t
|
|
37
35
|
}), b = async (e, n, r, a) => {
|
|
38
|
-
let o = y(e), s = await _(o, n, r),
|
|
36
|
+
let o = y(e), s = await _(o, n, r), c = r?.mode, f = r?.role, { 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, z = o.choices, { note: B } = o, V, H = d(o, n, r), U = x.map((e) => {
|
|
39
37
|
let t = (e.choices || []).filter((e) => e !== "null");
|
|
40
38
|
return {
|
|
41
39
|
...e,
|
|
@@ -55,7 +53,8 @@ var { translator: p } = s, m = (e, t) => {
|
|
|
55
53
|
categoryCount: t
|
|
56
54
|
};
|
|
57
55
|
}), B ||= p.t("common:commonCorrectAnswerWithAlternates", { lng: j });
|
|
58
|
-
let G = h(U), { responseAreasToBeFilled:
|
|
56
|
+
let G = h(U), K = f === "instructor" && (c === "view" || c === "evaluate"), { responseAreasToBeFilled: q, possibleResponses: J, hasUnplacedChoices: Y } = t(U, o.allowAlternateEnabled ? G : [], o.choices);
|
|
57
|
+
return {
|
|
59
58
|
categories: m || [],
|
|
60
59
|
categoriesPerRow: g || 2,
|
|
61
60
|
maxChoicesPerCategory: M,
|
|
@@ -79,12 +78,13 @@ var { translator: p } = s, m = (e, t) => {
|
|
|
79
78
|
autoplayAudioEnabled: I,
|
|
80
79
|
completeAudioEnabled: L,
|
|
81
80
|
customAudioButton: R,
|
|
82
|
-
possibleResponses:
|
|
83
|
-
responseAreasToBeFilled:
|
|
84
|
-
hasUnplacedChoices:
|
|
85
|
-
...e.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: W }
|
|
81
|
+
possibleResponses: J,
|
|
82
|
+
responseAreasToBeFilled: q,
|
|
83
|
+
hasUnplacedChoices: Y,
|
|
84
|
+
...e.allowMultiplePlacementsEnabled == null && { allowMultiplePlacementsEnabled: W },
|
|
85
|
+
rationale: K && D ? O : null,
|
|
86
|
+
teacherInstructions: K && k ? A : null
|
|
86
87
|
};
|
|
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
88
|
}, x = (e, t, n) => {
|
|
89
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
90
|
if (l > 0 ? (r.push(`Student placed ${l} choice(s) into categories.`), (o || []).forEach((e) => {
|
|
@@ -121,7 +121,7 @@ var { translator: p } = s, m = (e, t) => {
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
}) : Promise.reject(/* @__PURE__ */ Error("Can not call outcome when mode is not evaluate")), C = (e, t) => new Promise((n) => {
|
|
124
|
-
let
|
|
124
|
+
let r = t?.mode, i = t?.role;
|
|
125
125
|
if (r !== "evaluate" && i === "instructor") {
|
|
126
126
|
let { correctResponse: t } = e;
|
|
127
127
|
n({
|
|
@@ -145,7 +145,7 @@ var { translator: p } = s, m = (e, t) => {
|
|
|
145
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
146
|
});
|
|
147
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) {
|
|
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.` : s !== void 0 && y > s && (h.choicesError = `No more than ${s} choices should be defined.`), y && v) {
|
|
149
149
|
let e = !1;
|
|
150
150
|
(o || []).forEach((t) => {
|
|
151
151
|
let { choices: n = [], alternateResponses: r = [] } = t;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type { CategoryChoice, CategoryCorrectResponse } from '../types.js';
|
|
1
2
|
export declare const multiplePlacements: {
|
|
2
|
-
enabled:
|
|
3
|
-
disabled:
|
|
4
|
-
perChoice:
|
|
3
|
+
readonly enabled: "Yes";
|
|
4
|
+
readonly disabled: "No";
|
|
5
|
+
readonly perChoice: "Set Per Choice";
|
|
5
6
|
};
|
|
6
|
-
export declare const isCorrectResponseDuplicated: (choices:
|
|
7
|
-
export declare const isAlternateDuplicated: (alternate:
|
|
8
|
-
export declare const getCompleteResponseDetails: (correctResponse:
|
|
9
|
-
responseAreasToBeFilled:
|
|
10
|
-
possibleResponses:
|
|
7
|
+
export declare const isCorrectResponseDuplicated: (choices: string[], alternate: string[][]) => number;
|
|
8
|
+
export declare const isAlternateDuplicated: (alternate: string[][]) => number;
|
|
9
|
+
export declare const getCompleteResponseDetails: (correctResponse: CategoryCorrectResponse[], alternates: string[][][], allChoices: CategoryChoice[]) => {
|
|
10
|
+
responseAreasToBeFilled: number;
|
|
11
|
+
possibleResponses: string[][];
|
|
11
12
|
hasUnplacedChoices: boolean;
|
|
12
13
|
};
|
package/dist/index.d.ts
CHANGED