@pie-element/select-text 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.
@@ -101,7 +101,7 @@ var f = {
101
101
  return r.length > 0 ? "partially-correct" : "incorrect";
102
102
  }, _ = (e, t) => (t || []).filter((t) => e.findIndex((e) => e.correct && m(e, t)) !== -1), v = (e, t, r) => {
103
103
  if (!t || n(t)) return 0;
104
- let i = _(e.tokens, t.selectedTokens).length, a = (e.tokens || []).filter((e) => e.correct === !0), o = i - (t.selectedTokens && t.selectedTokens.length > a.length ? t.selectedTokens && t.selectedTokens.length - i : 0), s = o < 0 ? 0 : o;
104
+ let i = _(e.tokens, t.selectedTokens).length, a = (e.tokens || []).filter((e) => e.correct === !0), o = i - (t.selectedTokens && t.selectedTokens.length > a.length && t.selectedTokens ? t.selectedTokens.length - i : 0), s = o < 0 ? 0 : o;
105
105
  return r.length ? parseFloat((s / r.length).toFixed(2)) : 0;
106
106
  }, y = (e, t, n) => {
107
107
  let r = [], i = t?.selectedTokens || [], a = e?.tokens || [];
@@ -194,7 +194,7 @@ var S = (e) => ({
194
194
  t[n]?.required && !E(e[n]) && (o[n] = "This field is required.");
195
195
  });
196
196
  let c = (n || []).reduce((e, t) => t.correct ? e + 1 : e, 0);
197
- return s < r ? o.tokensError = `There should be at least ${r} tokens defined.` : s > i && (o.tokensError = `No more than ${i} tokens should be defined.`), c < 1 ? o.selectionsError = "There should be at least 1 token selected." : c > a && (o.selectionsError = `No more than ${a} tokens should be selected.`), o;
197
+ return s < r ? o.tokensError = `There should be at least ${r} tokens defined.` : i !== void 0 && s > i && (o.tokensError = `No more than ${i} tokens should be defined.`), c < 1 ? o.selectionsError = "There should be at least 1 token selected." : a !== void 0 && c > a && (o.selectionsError = `No more than ${a} tokens should be selected.`), o;
198
198
  };
199
199
  //#endregion
200
200
  export { T as createCorrectResponseSession, x as createDefaultModel, g as getCorrectness, y as getLogTrace, v as getPartialScore, w as model, C as normalize, S as normalizeSession, b as outcome, D as validate };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../shared/feedback/dist/index.js","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/defaults.ts","../../../src/controller/index.ts"],"sourcesContent":["//#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 feedbackEnabled: false,\n highlightChoices: false,\n maxSelections: 0,\n mode: 'sentence',\n partialScoring: false,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n text: '',\n tokens: [],\n toolbarEditorPosition: 'bottom',\n};\n","// @ts-nocheck\n\nimport debug from 'debug';\nimport { isEmpty } from '@pie-element/shared-lodash';\nimport { getFeedbackForCorrectness } from '@pie-element/shared-feedback';\nimport { partialScoring } from '@pie-element/shared-controller-utils';\nimport defaults from './defaults.js';\n\nconst log = debug('@pie-element:select-text:controller');\n\nconst equalTokens = (token1 = {}, token2 = {}) =>\n (token1?.start === token2?.start && token1?.end === token2?.end) ||\n // this case is used for the cases when the token's start & end were recalculated\n (token1?.start === token2?.oldStart && token1?.end === token2?.oldEnd);\n\nconst normalizeTokens = (tokens = [], selectedTokens = [], evaluateMode = false) =>\n (tokens || []).map((token) => {\n const isCorrect = !!token.correct;\n // search if correct token is missing from session\n const isMissing = isCorrect && !(selectedTokens || []).find((selectedToken) => equalTokens(token, selectedToken));\n\n return {\n ...token,\n correct: evaluateMode ? isCorrect : undefined,\n isMissing: evaluateMode ? isMissing : undefined,\n };\n });\n\nexport const getCorrectness = (tokens, selected) => {\n const correct = tokens.filter((t) => t.correct === true);\n\n if (correct.length === 0) {\n return 'unknown';\n }\n\n const correctSelected = getCorrectSelected(tokens, selected);\n\n if (correctSelected.length === selected.length) {\n if (correctSelected.length === correct.length) {\n return 'correct';\n } else if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n }\n\n if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectSelected = (tokens, selected) =>\n (selected || []).filter((s) => tokens.findIndex((token) => token.correct && equalTokens(token, s)) !== -1);\n\nexport const getPartialScore = (question, session, totalCorrect) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const correctCount = getCorrectSelected(question.tokens, session.selectedTokens).length;\n const correctTokens = (question.tokens || []).filter((t) => t.correct === true);\n const extraSelected = session.selectedTokens ? session.selectedTokens.length > correctTokens.length : 0;\n const incorrectCount = extraSelected ? session.selectedTokens && session.selectedTokens.length - correctCount : 0;\n const count = correctCount - incorrectCount;\n const positiveCount = count < 0 ? 0 : count;\n\n return totalCorrect.length ? parseFloat((positiveCount / totalCorrect.length).toFixed(2)) : 0;\n};\n\n/**\n * Generates detailed trace log for select-text scoring evaluation\n * @param {Object} question - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array<string>} traceLog\n */\nexport const getLogTrace = (question, session, env) => {\n const traceLog = [];\n\n const selectedTokens = session?.selectedTokens || [];\n const tokens = question?.tokens || [];\n\n if (selectedTokens.length === 0) {\n traceLog.push('Student did not select any token.');\n return traceLog;\n }\n\n traceLog.push(`Student selected ${selectedTokens.length} token(s).`);\n\n let totalCorrectTokens = 0;\n let correctSelected = 0;\n let missingCount = 0;\n\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token.correct) {\n totalCorrectTokens++;\n const matched = selectedTokens.some((s) => equalTokens(token, s));\n if (matched) {\n correctSelected++;\n } else {\n missingCount++;\n }\n }\n }\n\n const incorrectSelected = selectedTokens.length - correctSelected;\n\n if (correctSelected > 0) {\n traceLog.push(`${correctSelected} correct token(s) selected.`);\n }\n\n if (incorrectSelected > 0) {\n traceLog.push(`${incorrectSelected} incorrect token(s) selected.`);\n }\n\n if (missingCount > 0) {\n traceLog.push(`${missingCount} required correct token(s) were not selected.`);\n }\n\n const partialScoringEnabled = partialScoring.enabled(question, env, true);\n\n if (partialScoringEnabled) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push(\n 'Score is based on the number of correct minus incorrect selections, divided by the total number of correct tokens.',\n );\n\n if (incorrectSelected > 0 && selectedTokens.length > totalCorrectTokens) {\n traceLog.push(\n 'Extra selected tokens beyond the correct set reduce the score.',\n );\n }\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n traceLog.push(\n 'Student must select all correct tokens and no incorrect tokens to receive full credit.',\n );\n }\n\n const rawScore = getPartialScore(question, session, tokens.filter((t) => t.correct));\n const finalScore = partialScoringEnabled ? rawScore : rawScore === 1 ? 1 : 0;\n\n traceLog.push(`Final score: ${finalScore}.`);\n\n return traceLog;\n};\n\nexport const outcome = (question, session, env) =>\n new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true, logTrace: ['Student did not select any token.'] });\n }\n\n session = normalizeSession(session);\n\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined, logTrace: [] });\n } else {\n const enabled = partialScoring.enabled(question, env, true);\n const totalCorrect = question.tokens.filter((t) => t.correct);\n const score = getPartialScore(question, session, totalCorrect);\n resolve({\n score: enabled ? score : score === 1 ? 1 : 0,\n logTrace: getLogTrace(question, session, env),\n });\n }\n });\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({ ...defaults, ...model });\n });\n}\n\nexport const normalizeSession = (session) => ({ selectedTokens: [], ...session });\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\nexport const model = (question, session, env) => {\n session = session || { selectedToken: [] };\n session.selectedTokens = session.selectedTokens || [];\n const normalizedQuestion = normalize(question);\n\n return new Promise((resolve) => {\n log('[model]', 'normalizedQuestion: ', normalizedQuestion);\n log('[model]', 'session: ', session);\n\n const tokens = normalizeTokens(normalizedQuestion.tokens, session.selectedTokens, env.mode === 'evaluate');\n log('[model] tokens:', tokens);\n\n const correctness =\n env.mode === 'evaluate' ? getCorrectness(normalizedQuestion.tokens, session.selectedTokens) : undefined;\n\n const fb =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? getFeedbackForCorrectness(correctness, normalizedQuestion.feedback)\n : Promise.resolve(undefined);\n\n fb.then((feedback) => {\n const out = {\n tokens,\n highlightChoices: normalizedQuestion.highlightChoices,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n text: normalizedQuestion.text,\n disabled: env.mode !== 'gather',\n maxSelections: normalizedQuestion.maxSelections,\n correctness,\n env,\n feedback,\n incorrect: env.mode === 'evaluate' ? correctness !== 'correct' : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n });\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { tokens } = question;\n const selectedTokens = tokens.filter((t) => t.correct);\n\n resolve({\n id: '1',\n selectedTokens,\n });\n } else {\n 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 { tokens } = model;\n const { minTokens = 2, maxTokens, maxSelections } = config;\n const errors = {};\n const nbOfTokens = (tokens || []).length;\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 const nbOfSelections = (tokens || []).reduce((acc, token) => (token.correct ? acc + 1 : acc), 0);\n\n if (nbOfTokens < minTokens) {\n errors.tokensError = `There should be at least ${minTokens} tokens defined.`;\n } else if (nbOfTokens > maxTokens) {\n errors.tokensError = `No more than ${maxTokens} tokens should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selectionsError = 'There should be at least 1 token selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selectionsError = `No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AAC,GAOG,KAAc,OAAU,KAAQ,GAAA,CAAI,QAAQ,sCAAsC,EAAE,GAE7E,KAAY,IAAQ,CAAC,GAAG,IAAS,CAAC,MAAM;CACnD,IAAM,EAAE,cAAW,GACb,EAAE,eAAY,GAAG,cAAW,qBAAkB,GAC9C,IAAS,CAAC,GACV,KAAc,KAAU,CAAC,EAAA,CAAG;CAElC;EAAC;EAAuB;EAAU;CAAW,CAAC,CAAC,SAAS,MAAU;EAChE,AAAI,EAAO,EAAM,EAAE,YAAY,CAAC,EAAW,EAAM,EAAM,MACrD,EAAO,KAAS;CAEpB,CAAC;CAED,IAAM,KAAkB,KAAU,CAAC,EAAA,CAAG,QAAQ,GAAK,MAAW,EAAM,UAAU,IAAM,IAAI,GAAM,CAAC;CAc/F,OAZI,IAAa,IACf,EAAO,cAAc,4BAA4B,EAAU,oBAClD,IAAa,MACtB,EAAO,cAAc,gBAAgB,EAAU,8BAG7C,IAAiB,IACnB,EAAO,kBAAkB,+CAChB,IAAiB,MAC1B,EAAO,kBAAkB,gBAAgB,EAAc,+BAGlD;AACT"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../shared/feedback/dist/index.js","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/defaults.ts","../../../src/controller/index.ts"],"sourcesContent":["//#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 { SelectTextModel, TextToken } from '../types.js';\n\nexport default {\n feedbackEnabled: false,\n highlightChoices: false,\n maxSelections: 0,\n mode: 'sentence',\n partialScoring: false,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n text: '',\n tokens: [] as TextToken[],\n toolbarEditorPosition: 'bottom',\n} satisfies Omit<SelectTextModel, 'id' | 'element'>;\n","import debug from 'debug';\nimport { isEmpty } from '@pie-element/shared-lodash';\nimport { getFeedbackForCorrectness, type Correctness, type Feedback } from '@pie-element/shared-feedback';\nimport { partialScoring } from '@pie-element/shared-controller-utils';\nimport type { ExtraCSSRules, PieEnvironment } from '@pie-element/shared-types';\nimport defaults from './defaults.js';\nimport type { SelectTextConfiguration, SelectTextModel, SelectTextSession, TextToken } from '../types.js';\n\nconst log = debug('@pie-element:select-text:controller');\n\ntype ResponseCorrectness = 'unknown' | 'correct' | 'partially-correct' | 'incorrect';\n\n/** A token as the delivery view receives it; `correct` and `isMissing` are set in evaluate mode only. */\ntype TokenView = Omit<TextToken, 'correct'> & { correct: boolean | undefined; isMissing: boolean | undefined };\n\n/** The model the delivery view receives. */\ntype ModelView = {\n tokens: TokenView[];\n highlightChoices?: boolean;\n prompt: string | null | undefined;\n text: string;\n disabled: boolean;\n maxSelections?: number;\n correctness: ResponseCorrectness | undefined;\n env: PieEnvironment;\n feedback: string | undefined;\n incorrect: boolean | undefined;\n language?: string;\n extraCSSRules?: ExtraCSSRules;\n rationale?: string | null;\n teacherInstructions?: string | null;\n};\n\ntype Outcome = { score: number | undefined; empty?: boolean; completed?: undefined; logTrace: string[] };\n\n/** Errors `validate()` reports, keyed by field. */\nexport type SelectTextValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n tokensError?: string;\n selectionsError?: string;\n};\n\n/** The session `model()` works on; without a session it starts from one carrying `selectedToken`. */\ntype ModelSession = SelectTextSession & { selectedToken?: TextToken[] };\n\nconst equalTokens = (token1: Partial<TextToken> = {}, token2: Partial<TextToken> = {}) =>\n (token1?.start === token2?.start && token1?.end === token2?.end) ||\n // this case is used for the cases when the token's start & end were recalculated\n (token1?.start === token2?.oldStart && token1?.end === token2?.oldEnd);\n\nconst normalizeTokens = (tokens: TextToken[] = [], selectedTokens: TextToken[] = [], evaluateMode = false): TokenView[] =>\n (tokens || []).map((token) => {\n const isCorrect = !!token.correct;\n // search if correct token is missing from session\n const isMissing = isCorrect && !(selectedTokens || []).find((selectedToken) => equalTokens(token, selectedToken));\n\n return {\n ...token,\n correct: evaluateMode ? isCorrect : undefined,\n isMissing: evaluateMode ? isMissing : undefined,\n };\n });\n\nexport const getCorrectness = (tokens: TextToken[], selected: TextToken[]): ResponseCorrectness => {\n const correct = tokens.filter((t) => t.correct === true);\n\n if (correct.length === 0) {\n return 'unknown';\n }\n\n const correctSelected = getCorrectSelected(tokens, selected);\n\n if (correctSelected.length === selected.length) {\n if (correctSelected.length === correct.length) {\n return 'correct';\n } else if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n }\n\n if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectSelected = (tokens: TextToken[], selected: TextToken[] | undefined) =>\n (selected || []).filter((s) => tokens.findIndex((token) => token.correct && equalTokens(token, s)) !== -1);\n\nexport const getPartialScore = (\n question: SelectTextModel,\n session: SelectTextSession | undefined,\n totalCorrect: TextToken[],\n) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const correctCount = getCorrectSelected(question.tokens, session.selectedTokens).length;\n const correctTokens = (question.tokens || []).filter((t) => t.correct === true);\n const extraSelected = session.selectedTokens ? session.selectedTokens.length > correctTokens.length : 0;\n const incorrectCount = extraSelected && session.selectedTokens ? session.selectedTokens.length - correctCount : 0;\n const count = correctCount - incorrectCount;\n const positiveCount = count < 0 ? 0 : count;\n\n return totalCorrect.length ? parseFloat((positiveCount / totalCorrect.length).toFixed(2)) : 0;\n};\n\n/**\n * Generates detailed trace log for select-text scoring evaluation\n * @param {Object} question - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array<string>} traceLog\n */\nexport const getLogTrace = (question: SelectTextModel, session: SelectTextSession | undefined, env: PieEnvironment) => {\n const traceLog: string[] = [];\n\n const selectedTokens = session?.selectedTokens || [];\n const tokens = question?.tokens || [];\n\n if (selectedTokens.length === 0) {\n traceLog.push('Student did not select any token.');\n return traceLog;\n }\n\n traceLog.push(`Student selected ${selectedTokens.length} token(s).`);\n\n let totalCorrectTokens = 0;\n let correctSelected = 0;\n let missingCount = 0;\n\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token.correct) {\n totalCorrectTokens++;\n const matched = selectedTokens.some((s) => equalTokens(token, s));\n if (matched) {\n correctSelected++;\n } else {\n missingCount++;\n }\n }\n }\n\n const incorrectSelected = selectedTokens.length - correctSelected;\n\n if (correctSelected > 0) {\n traceLog.push(`${correctSelected} correct token(s) selected.`);\n }\n\n if (incorrectSelected > 0) {\n traceLog.push(`${incorrectSelected} incorrect token(s) selected.`);\n }\n\n if (missingCount > 0) {\n traceLog.push(`${missingCount} required correct token(s) were not selected.`);\n }\n\n const partialScoringEnabled = partialScoring.enabled(question, env, true);\n\n if (partialScoringEnabled) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push(\n 'Score is based on the number of correct minus incorrect selections, divided by the total number of correct tokens.',\n );\n\n if (incorrectSelected > 0 && selectedTokens.length > totalCorrectTokens) {\n traceLog.push(\n 'Extra selected tokens beyond the correct set reduce the score.',\n );\n }\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n traceLog.push(\n 'Student must select all correct tokens and no incorrect tokens to receive full credit.',\n );\n }\n\n const rawScore = getPartialScore(question, session, tokens.filter((t) => t.correct));\n const finalScore = partialScoringEnabled ? rawScore : rawScore === 1 ? 1 : 0;\n\n traceLog.push(`Final score: ${finalScore}.`);\n\n return traceLog;\n};\n\nexport const outcome = (question: SelectTextModel, session: SelectTextSession | undefined, env: PieEnvironment) =>\n new Promise<Outcome>((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true, logTrace: ['Student did not select any token.'] });\n }\n\n session = normalizeSession(session);\n\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined, logTrace: [] });\n } else {\n const enabled = partialScoring.enabled(question, env, true);\n const totalCorrect = question.tokens.filter((t) => t.correct);\n const score = getPartialScore(question, session, totalCorrect);\n resolve({\n score: enabled ? score : score === 1 ? 1 : 0,\n logTrace: getLogTrace(question, session, env),\n });\n }\n });\n\nexport function createDefaultModel(model: Partial<SelectTextModel> = {}) {\n return new Promise<Partial<SelectTextModel>>((resolve) => {\n resolve({ ...defaults, ...model });\n });\n}\n\nexport const normalizeSession = (session: SelectTextSession | undefined) => ({\n selectedTokens: [] as TextToken[],\n ...session,\n});\n\nexport const normalize = (question: SelectTextModel) => ({ ...defaults, ...question });\n\nexport const model = (question: SelectTextModel, session: ModelSession | null | undefined, env: PieEnvironment) => {\n session = session || { selectedToken: [] };\n session.selectedTokens = session.selectedTokens || [];\n const normalizedQuestion = normalize(question);\n\n return new Promise<ModelView>((resolve) => {\n log('[model]', 'normalizedQuestion: ', normalizedQuestion);\n log('[model]', 'session: ', session);\n\n const tokens = normalizeTokens(normalizedQuestion.tokens, session.selectedTokens, env.mode === 'evaluate');\n log('[model] tokens:', tokens);\n\n const correctness =\n env.mode === 'evaluate' ? getCorrectness(normalizedQuestion.tokens, session.selectedTokens as TextToken[]) : undefined;\n\n const fb =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? getFeedbackForCorrectness(correctness as Correctness, normalizedQuestion.feedback as Partial<Feedback>)\n : Promise.resolve(undefined);\n\n fb.then((feedback) => {\n const out: ModelView = {\n tokens,\n highlightChoices: normalizedQuestion.highlightChoices,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n text: normalizedQuestion.text,\n disabled: env.mode !== 'gather',\n maxSelections: normalizedQuestion.maxSelections,\n correctness,\n env,\n feedback,\n incorrect: env.mode === 'evaluate' ? correctness !== 'correct' : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n });\n};\n\nexport const createCorrectResponseSession = (question: SelectTextModel, env: PieEnvironment) => {\n return new Promise<SelectTextSession | null>((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { tokens } = question;\n const selectedTokens = tokens.filter((t) => t.correct);\n\n resolve({\n id: '1',\n selectedTokens,\n });\n } else {\n resolve(null);\n }\n });\n};\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<SelectTextModel> = {},\n config: SelectTextConfiguration = {},\n): SelectTextValidationErrors => {\n const { tokens } = model;\n const { minTokens = 2, maxTokens, maxSelections } = config;\n const errors: SelectTextValidationErrors = {};\n const nbOfTokens = (tokens || []).length;\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 const nbOfSelections = (tokens || []).reduce((acc, token) => (token.correct ? acc + 1 : acc), 0);\n\n if (nbOfTokens < minTokens) {\n errors.tokensError = `There should be at least ${minTokens} tokens defined.`;\n } else if (maxTokens !== undefined && nbOfTokens > maxTokens) {\n errors.tokensError = `No more than ${maxTokens} tokens should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selectionsError = 'There should be at least 1 token selected.';\n } else if (maxSelections !== undefined && nbOfSelections > maxSelections) {\n errors.selectionsError = `No more than ${maxSelections} tokens should be selected.`;\n }\n\n return errors;\n};\n"],"mappings":";;;mCACI,IAAI;CACP,SAAS;EACR,MAAM;EACN,SAAS;EACT,QAAQ;CACT;CACA,WAAW;EACV,MAAM;EACN,SAAS;EACT,QAAQ;CACT;CACA,SAAS;EACR,MAAM;EACN,SAAS;EACT,QAAQ;CACT;CACA,YAAY;EACX,MAAM;EACN,SAAS;EACT,QAAQ;CACT;AACD;AAGA,SAAS,EAAE,GAAG;CACb,OAAO,MAAM,sBAAsB,YAAY;AAChD;AAGA,SAAS,EAAE,GAAG,GAAG;CAChB,IAAI,IAAI;EACP,GAAG;EACH,GAAG;CACJ,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,MAAM;CACzC,OAAO;EACN,QAAQ;EACR,UAAU,EAAE,EAAE,QAAQ;CACvB;AACD;AACA,SAAS,EAAE,GAAG,IAAI,CAAC,GAAG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cAAc,gBAAgB,EAAU,8BAG7C,IAAiB,IACnB,EAAO,kBAAkB,+CAChB,MAAkB,KAAA,KAAa,IAAiB,MACzD,EAAO,kBAAkB,gBAAgB,EAAc,+BAGlD;AACT"}
@@ -19985,15 +19985,12 @@ var ST = class extends z.Component {
19985
19985
  }), ET = (e) => typeof e == "string" ? {
19986
19986
  label: e,
19987
19987
  value: e
19988
- } : e, DT = function() {
19989
- let [e, t, n = !1] = Array.prototype.slice.call(arguments);
19990
- return {
19991
- type: "radio",
19992
- label: e,
19993
- choices: t && t.map((e) => ET(e)),
19994
- isConfigProperty: n
19995
- };
19996
- }, OT = (e, t, n = !1) => ({
19988
+ } : e, DT = (e, t, n = !1) => ({
19989
+ type: "radio",
19990
+ label: e,
19991
+ choices: t && t.map((e) => ET(e)),
19992
+ isConfigProperty: n
19993
+ }), OT = (e, t, n = !1) => ({
19997
19994
  type: "dropdown",
19998
19995
  label: e,
19999
19996
  choices: t,
@@ -20113,17 +20110,6 @@ var FT = Ne, IT = FT.default, LT = IT && typeof IT == "object" ? IT : FT, RT = P
20113
20110
  width: "180px",
20114
20111
  margin: `${e.spacing(.5)} auto 0`
20115
20112
  })), oE = (0, sr.default)("@pie-element:select-text:configure"), sE = class extends z.Component {
20116
- static propTypes = {
20117
- model: H.default.object.isRequired,
20118
- configuration: H.default.object.isRequired,
20119
- onModelChanged: H.default.func.isRequired,
20120
- onConfigurationChanged: H.default.func.isRequired,
20121
- imageSupport: H.default.shape({
20122
- add: H.default.func.isRequired,
20123
- delete: H.default.func.isRequired
20124
- }),
20125
- uploadSoundSupport: H.default.object
20126
- };
20127
20113
  static defaultProps = {};
20128
20114
  constructor(e) {
20129
20115
  super(e);
@@ -20517,6 +20503,9 @@ var FT = Ne, IT = FT.default, LT = IT && typeof IT == "object" ? IT : FT, RT = P
20517
20503
  }
20518
20504
  }
20519
20505
  }, mE = class e extends HTMLElement {
20506
+ _root;
20507
+ _model;
20508
+ _configuration;
20520
20509
  static createDefaultModel = (e = {}) => WT({
20521
20510
  ...pE.model,
20522
20511
  ...e
@@ -20532,7 +20521,7 @@ var FT = Ne, IT = FT.default, LT = IT && typeof IT == "object" ? IT : FT, RT = P
20532
20521
  ...pE.configuration,
20533
20522
  ...e
20534
20523
  };
20535
- this._configuration = t, t?.language?.enabled ? t?.languageChoices?.options?.length && (this._model.language = t?.languageChoices.options[0].value) : t.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
20524
+ this._configuration = t, t?.language?.enabled ? t?.languageChoices?.options?.length && (this._model.language = t?.languageChoices.options[0].value) : t.language.settings && this._model.language ? (t.language.enabled = !0, (!t.languageChoices.options || !t.languageChoices.options.length) && (t.languageChoices.options = []), t.languageChoices.options.find((e) => e.value === this._model.language) || t.languageChoices.options.push({
20536
20525
  value: this._model.language,
20537
20526
  label: this._model.language
20538
20527
  })) : delete this._model.language, this.render();
@@ -20541,10 +20530,10 @@ var FT = Ne, IT = FT.default, LT = IT && typeof IT == "object" ? IT : FT, RT = P
20541
20530
  this.render();
20542
20531
  }
20543
20532
  modelChanged(e) {
20544
- this._model = e, this.dispatchEvent(new cE(this._model), !0), this.render();
20533
+ this._model = e, this.dispatchEvent(new cE(this._model)), this.render();
20545
20534
  }
20546
20535
  onConfigurationChanged(e) {
20547
- this._configuration = e, this._model && this.dispatchEvent(new cE(this._model), !1), this.render();
20536
+ this._configuration = e, this._model && this.dispatchEvent(new cE(this._model)), this.render();
20548
20537
  }
20549
20538
  insertImage(e) {
20550
20539
  this.dispatchEvent(new uE(e));