@pie-element/inline-dropdown 11.0.4-next.20261011174919 → 11.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 +56 -55
- package/dist/author/index.d.ts +18 -29
- package/dist/author/index.js +6 -1
- package/dist/author/inline-dropdown-toolbar.d.ts +3 -0
- package/dist/author/inline-dropdown-toolbar.js +4 -1
- package/dist/author/main.d.ts +58 -34
- package/dist/author/main.js +86 -102
- package/dist/browser/author/index.js +65 -75
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +5 -3
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/editor-runtime/author/index.js +65 -75
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/controller/index.js +5 -3
- package/dist/browser/editor-runtime/controller/index.js.map +1 -1
- package/dist/controller/defaults.d.ts +9 -9
- package/dist/controller/index.d.ts +66 -17
- package/dist/controller/index.js +5 -3
- package/dist/controller/utils.d.ts +2 -4
- package/dist/index.d.ts +1 -0
- package/dist/schemas/configuration.schema.json +414 -0
- package/dist/schemas/model.schema.json +453 -0
- package/dist/schemas/session.schema.json +43 -0
- package/dist/types.d.ts +164 -0
- package/package.json +20 -16
|
@@ -137,7 +137,7 @@ var v = (t, n) => {
|
|
|
137
137
|
}, y = (e, t, n) => {
|
|
138
138
|
let r = [], { value: i = {} } = t || {}, a = m(e), o = Object.keys(a), s = o.length;
|
|
139
139
|
if (r.push(`${s} dropdown response area(s) defined in this question.`), i && Object.keys(i).length > 0) {
|
|
140
|
-
let e = Object.entries(i).filter(([
|
|
140
|
+
let e = Object.entries(i).filter(([, e]) => e && e.trim()).length;
|
|
141
141
|
r.push(`Student selected options in ${e} out of ${s} dropdown(s).`), o.forEach((e) => {
|
|
142
142
|
let t = i && i[e] || "", n = a[e] || [];
|
|
143
143
|
t.trim() ? r.push(`Dropdown ${parseInt(e) + 1}: student selected '${t}' (correct options: [${n.map((e) => `'${e}'`).join(", ")}]).`) : r.push(`Dropdown ${parseInt(e) + 1}: no selection made (correct options: [${n.map((e) => `'${e}'`).join(", ")}]).`);
|
|
@@ -186,8 +186,10 @@ var x = (e, t) => new Promise((n) => {
|
|
|
186
186
|
t[n]?.required && !S(e[n]) && (o[n] = "This field is required.");
|
|
187
187
|
});
|
|
188
188
|
let s = ((n || "").match(/\{\{(\d+)\}\}/g) || []).length;
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
i !== void 0 && s > i ? o.responseAreasError = `No more than ${i} response areas should be defined.` : s < 1 && (o.responseAreasError = "There should be defined at least 1 response area.");
|
|
190
|
+
let c = r;
|
|
191
|
+
return (Object.keys(c) || []).forEach((e) => {
|
|
192
|
+
c[e] && a !== void 0 && c[e].length > a && (o.responseAreaChoicesError = `No more than ${a} choices per response area should be defined.`);
|
|
191
193
|
}), o;
|
|
192
194
|
};
|
|
193
195
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../shared/controller-utils/dist/index.js","../../../src/controller/defaults.ts","../../../src/controller/utils.ts","../../../src/controller/index.ts"],"sourcesContent":["//#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 alternateResponse: {},\n choiceRationaleEnabled: true,\n choices: {},\n disabled: false,\n displayType: 'block',\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n shuffle: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n};\n","// @ts-nocheck\n\nimport { forEach } from '@pie-element/shared-lodash';\n\nexport const getAllCorrectResponses = ({ choices, alternateResponse }) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers = {};\n\n forEach(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n","// @ts-nocheck\n\nimport { isEmpty, map, reduce } from '@pie-element/shared-lodash';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport defaults from './defaults.js';\n\nimport { getAllCorrectResponses } from './utils.js';\n\nconst getFeedback = (correct) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\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 async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n const shuffledValues = {};\n const keys = Object.keys(choices);\n\n const us = (part) => (id, element, update) => {\n return new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues;\n resolve();\n });\n };\n\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n const storedValues = session?.shuffledValues?.[key];\n\n choices[key] = await getShuffledChoices(\n choices[key],\n // the shuffledValues structure was updated to an object like { choice_key: [] }\n // and we need to override shuffledValues if it's not an array\n { shuffledValues: Array.isArray(storedValues) ? storedValues : [] },\n us(key),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (session && updateSession && typeof updateSession === 'function') {\n updateSession(session.id, session.element, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n }\n\n let teacherInstructions = null;\n let rationale = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n return out;\n}\n\nexport const getScore = (config, session) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\n\n return parseFloat(str);\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 { value = {} } = session || {};\n const allCorrectResponses = getAllCorrectResponses(model);\n const responseAreaKeys = Object.keys(allCorrectResponses);\n const totalAreas = responseAreaKeys.length;\n \n traceLog.push(`${totalAreas} dropdown response area(s) defined in this question.`);\n \n if (value && Object.keys(value).length > 0) {\n const selectedAreas = Object.entries(value).filter(([key, val]) => val && val.trim()).length;\n traceLog.push(`Student selected options in ${selectedAreas} out of ${totalAreas} dropdown(s).`);\n \n responseAreaKeys.forEach((areaKey) => {\n const studentSelection = (value && value[areaKey]) || '';\n const correctOptions = allCorrectResponses[areaKey] || [];\n \n if (studentSelection.trim()) {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: student selected '${studentSelection}' (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n } else {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: no selection made (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n }\n });\n } else {\n traceLog.push('Student did not make any selections in the dropdowns.');\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n traceLog.push(\n `Scoring method: ${\n partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'\n }.`\n );\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n traceLog: ['Student did not make any selections in the dropdowns. Score is 0.'] \n });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n traceLog\n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\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 { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors = {};\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 nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be defined at least 1 response area.';\n }\n\n (Object.keys(choices) || []).forEach((choiceKey) => {\n if (choices[choiceKey] && choices[choiceKey].length > maxResponseAreaChoices) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"mappings":";;AACA,IAAI,IAAI,OAAO,gBAAgB,KAAK,GAAG,MAAM;CAC5C,IAAI,IAAI,CAAC;CACT,KAAK,IAAI,KAAK,GAAG,EAAE,GAAG,GAAG;EACxB,KAAK,EAAE;EACP,YAAY,CAAC;CACd,CAAC;CACD,OAAO,KAAK,EAAE,GAAG,OAAO,aAAa,EAAE,OAAO,SAAS,CAAC,GAAG;AAC5D;AAGA,SAAS,EAAE,GAAG;CACb,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,CAAC;AACzD;AACA,SAAS,EAAE,GAAG;CACb,IAAI,IAAI,CAAC,GAAG,CAAC;CACb,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK;EACtC,IAAI,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;EAC1C,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE;CAC3B;CACA,OAAO;AACR;AACA,SAAS,EAAE,GAAG;CACb,OAAO,KAAK,OAAO,CAAC,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,WAAW,IAAI,OAAO,KAAK,YAAY,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW;AAC/G;AACA,eAAe,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS;CACtC,IAAI,IAAI,EAAE,GAAG,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,CAAC;CAC5D,IAAI,CAAC,GAAG;EACP,QAAQ,KAAK,6DAA6D;EAC1E;CACD;CACA,IA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I,QAAQ,sCAAsC,EAAE,GAE7E,KAAY,IAAQ,CAAC,GAAG,IAAS,CAAC,MAAM;CACnD,IAAM,EAAE,WAAQ,eAAY,GACtB,EAAE,qBAAkB,8BAA2B,GAC/C,IAAS,CAAC;CAEhB;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,MAAsB,KAAU,GAAA,CAAI,MAAM,gBAAgB,KAAK,CAAC,EAAA,CAAG;CAczE,OAZI,IAAoB,IACtB,EAAO,qBAAqB,gBAAgB,EAAiB,sCACpD,IAAoB,MAC7B,EAAO,qBAAqB,uDAG7B,OAAO,KAAK,CAAO,KAAK,CAAC,EAAA,CAAG,SAAS,MAAc;EAClD,AAAI,EAAQ,MAAc,EAAQ,EAAU,CAAC,SAAS,MACpD,EAAO,2BAA2B,gBAAgB,EAAuB;CAE7E,CAAC,GAEM;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../shared/controller-utils/dist/index.js","../../../src/controller/defaults.ts","../../../src/controller/utils.ts","../../../src/controller/index.ts"],"sourcesContent":["//#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 { InlineDropdownModel } from '../types.js';\n\nexport default {\n alternateResponse: {},\n choiceRationaleEnabled: true,\n choices: {},\n disabled: false,\n displayType: 'block',\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n shuffle: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n} satisfies Omit<InlineDropdownModel, 'id' | 'element'>;\n","import { forEach } from '@pie-element/shared-lodash';\nimport type { Choice, InlineDropdownModel } from '../types.js';\n\nexport const getAllCorrectResponses = ({\n choices,\n alternateResponse,\n}: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers: Record<string, string[]> = {};\n\n forEach<Choice[]>(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n","import { isEmpty, map, reduce } from '@pie-element/shared-lodash';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';\nimport defaults from './defaults.js';\n\nimport { getAllCorrectResponses } from './utils.js';\nimport type {\n Choice,\n Choices,\n InlineDropdownConfiguration,\n InlineDropdownModel,\n InlineDropdownSession,\n} from '../types.js';\n\n/** Errors `validate()` reports, keyed by field. */\nexport type InlineDropdownValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n responseAreasError?: string;\n responseAreaChoicesError?: string;\n};\n\n/** A choice as the controller hands it to the delivery: rationales are `null` unless the instructor sees them */\ntype DeliveryChoice = Omit<Choice, 'rationale'> & { rationale?: string | null };\n\nconst getFeedback = (correct: unknown) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question: InlineDropdownModel) => ({ ...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 async function model(\n question: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: PieEnvironment,\n updateSession?: PieUpdateSession,\n) {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce<Choice[], Record<string, DeliveryChoice[] | undefined>>(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback: Record<string, string> = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce<string[], { correctResponses: number; feedback: Record<string, string> }>(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n // `lockChoices` ignores the session, so the per-area `shuffledValues` shape does not matter to it.\n const lockChoiceOrder = lockChoices(normalizedQuestion, session as Parameters<typeof lockChoices>[1], env);\n\n if (!lockChoiceOrder) {\n const shuffledValues: Record<string, string[]> = {};\n const keys = Object.keys(choices);\n\n const us =\n (part: string): PieUpdateSession =>\n (_id, _element, update) => {\n return new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues as string[];\n resolve();\n });\n };\n\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n const storedValues = (session?.shuffledValues as Record<string, string[]> | undefined)?.[key];\n\n choices[key] = await getShuffledChoices(\n choices[key] as DeliveryChoice[],\n // the shuffledValues structure was updated to an object like { choice_key: [] }\n // and we need to override shuffledValues if it's not an array\n { shuffledValues: Array.isArray(storedValues) ? storedValues : [] },\n us(key),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (session && updateSession && typeof updateSession === 'function') {\n updateSession(session.id as string, session.element as string, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n }\n\n let teacherInstructions: string | null | undefined = null;\n let rationale: string | null | undefined = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce<Record<string, DeliveryChoice[]>>((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n return out;\n}\n\nexport const getScore = (\n config: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>,\n session: InlineDropdownSession | null | undefined,\n) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce<string[], number>(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\n\n return parseFloat(str);\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 = (\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment>,\n) => {\n const traceLog: string[] = [];\n const { value = {} } = session || {};\n const allCorrectResponses = getAllCorrectResponses(model);\n const responseAreaKeys = Object.keys(allCorrectResponses);\n const totalAreas = responseAreaKeys.length;\n \n traceLog.push(`${totalAreas} dropdown response area(s) defined in this question.`);\n \n if (value && Object.keys(value).length > 0) {\n const selectedAreas = Object.entries(value).filter(([, val]) => val && val.trim()).length;\n traceLog.push(`Student selected options in ${selectedAreas} out of ${totalAreas} dropdown(s).`);\n \n responseAreaKeys.forEach((areaKey) => {\n const studentSelection = (value && value[areaKey]) || '';\n const correctOptions = allCorrectResponses[areaKey] || [];\n \n if (studentSelection.trim()) {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: student selected '${studentSelection}' (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n } else {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: no selection made (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n }\n });\n } else {\n traceLog.push('Student did not make any selections in the dropdowns.');\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n traceLog.push(\n `Scoring method: ${\n partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'\n }.`\n );\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment> = {},\n) {\n return new Promise<{ score: number; empty: boolean; traceLog: string[] }>((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n traceLog: ['Student did not make any selections in the dropdowns. Score is 0.'] \n });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n traceLog\n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question: InlineDropdownModel, env: PieEnvironment) => {\n return new Promise<InlineDropdownSession | null>((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value: Record<string, string> = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\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<InlineDropdownModel> = {},\n config: InlineDropdownConfiguration = {},\n) => {\n const { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors: InlineDropdownValidationErrors = {};\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 nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (maxResponseAreas !== undefined && nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be defined at least 1 response area.';\n }\n\n // `Object.keys` throws when the model has no `choices`.\n const allChoices = choices as Choices;\n\n (Object.keys(allChoices) || []).forEach((choiceKey) => {\n if (\n allChoices[choiceKey] &&\n maxResponseAreaChoices !== undefined &&\n allChoices[choiceKey].length > maxResponseAreaChoices\n ) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"mappings":";;AACA,IAAI,IAAI,OAAO,gBAAgB,KAAK,GAAG,MAAM;CAC5C,IAAI,IAAI,CAAC;CACT,KAAK,IAAI,KAAK,GAAG,EAAE,GAAG,GAAG;EACxB,KAAK,EAAE;EACP,YAAY,CAAC;CACd,CAAC;CACD,OAAO,KAAK,EAAE,GAAG,OAAO,aAAa,EAAE,OAAO,SAAS,CAAC,GAAG;AAC5D;AAGA,SAAS,EAAE,GAAG;CACb,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,CAAC;AACzD;AACA,SAAS,EAAE,GAAG;CACb,IAAI,IAAI,CAAC,GAAG,CAAC;CACb,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK;EACtC,IAAI,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;EAC1C,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE;CAC3B;CACA,OAAO;AACR;AACA,SAAS,EAAE,GAAG;CACb,OAAO,KAAK,OAAO,CAAC,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,WAAW,IAAI,OAAO,KAAK,YAAY,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW;AAC/G;AACA,eAAe,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS;CACtC,IAAI,IAAI,EAAE,GAAG,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,CAAC;CAC5D,IAAI,CAAC,GAAG;EACP,QAAQ,KAAK,6DAA6D;EAC1E;CACD;CACA,IAAI,CAAC,E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AAsC,CAAC,GACvC,IAAsC,CAAC,MACpC;CACH,IAAM,EAAE,WAAQ,eAAY,GACtB,EAAE,qBAAkB,8BAA2B,GAC/C,IAAyC,CAAC;CAEhD;EAAE;EAAuB;EAAU;CAAW,CAAC,CAAW,SAAS,MAAU;EAC3E,AAAI,EAAO,EAAM,EAAE,YAAY,CAAC,EAAW,EAAM,EAAM,MACrD,EAAO,KAAS;CAEpB,CAAC;CAED,IAAM,MAAsB,KAAU,GAAA,CAAI,MAAM,gBAAgB,KAAK,CAAC,EAAA,CAAG;CAEzE,AAAI,MAAqB,KAAA,KAAa,IAAoB,IACxD,EAAO,qBAAqB,gBAAgB,EAAiB,sCACpD,IAAoB,MAC7B,EAAO,qBAAqB;CAI9B,IAAM,IAAa;CAYnB,QAVC,OAAO,KAAK,CAAU,KAAK,CAAC,EAAA,CAAG,SAAS,MAAc;EACrD,AACE,EAAW,MACX,MAA2B,KAAA,KAC3B,EAAW,EAAU,CAAC,SAAS,MAE/B,EAAO,2BAA2B,gBAAgB,EAAuB;CAE7E,CAAC,GAEM;AACT"}
|
|
@@ -19142,15 +19142,12 @@ var Ow = class extends R.Component {
|
|
|
19142
19142
|
}), Mw = (e) => typeof e == "string" ? {
|
|
19143
19143
|
label: e,
|
|
19144
19144
|
value: e
|
|
19145
|
-
} : e, Nw =
|
|
19146
|
-
|
|
19147
|
-
|
|
19148
|
-
|
|
19149
|
-
|
|
19150
|
-
|
|
19151
|
-
isConfigProperty: n
|
|
19152
|
-
};
|
|
19153
|
-
}, Pw = (e, t, n = !1) => ({
|
|
19145
|
+
} : e, Nw = (e, t, n = !1) => ({
|
|
19146
|
+
type: "radio",
|
|
19147
|
+
label: e,
|
|
19148
|
+
choices: t && t.map((e) => Mw(e)),
|
|
19149
|
+
isConfigProperty: n
|
|
19150
|
+
}), Pw = (e, t, n = !1) => ({
|
|
19154
19151
|
type: "dropdown",
|
|
19155
19152
|
label: e,
|
|
19156
19153
|
choices: t,
|
|
@@ -19305,7 +19302,10 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19305
19302
|
onSelectChoice: V.default.func.isRequired,
|
|
19306
19303
|
onToolbarDone: V.default.func.isRequired,
|
|
19307
19304
|
editor: V.default.object,
|
|
19308
|
-
spellCheck: V.default.bool
|
|
19305
|
+
spellCheck: V.default.bool,
|
|
19306
|
+
mathMlOptions: V.default.object,
|
|
19307
|
+
baseInputConfiguration: V.default.object,
|
|
19308
|
+
responseAreaInputConfiguration: V.default.object
|
|
19309
19309
|
};
|
|
19310
19310
|
clickedInside = !1;
|
|
19311
19311
|
preventDone = !1;
|
|
@@ -19499,21 +19499,6 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19499
19499
|
let t = document.createElement("div");
|
|
19500
19500
|
return t.innerHTML = (e || "").trim(), t;
|
|
19501
19501
|
}, wT = class extends R.Component {
|
|
19502
|
-
static propTypes = {
|
|
19503
|
-
configuration: V.default.object.isRequired,
|
|
19504
|
-
model: V.default.object.isRequired,
|
|
19505
|
-
disableSidePanel: V.default.bool,
|
|
19506
|
-
onModelChanged: V.default.func.isRequired,
|
|
19507
|
-
onConfigurationChanged: V.default.func.isRequired,
|
|
19508
|
-
imageSupport: V.default.shape({
|
|
19509
|
-
add: V.default.func.isRequired,
|
|
19510
|
-
delete: V.default.func.isRequired
|
|
19511
|
-
}),
|
|
19512
|
-
uploadSoundSupport: V.default.shape({
|
|
19513
|
-
add: V.default.func.isRequired,
|
|
19514
|
-
delete: V.default.func.isRequired
|
|
19515
|
-
})
|
|
19516
|
-
};
|
|
19517
19502
|
state = { warning: { open: !1 } };
|
|
19518
19503
|
componentDidMount() {
|
|
19519
19504
|
let { model: { choices: e } } = this.props;
|
|
@@ -19561,7 +19546,7 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19561
19546
|
} });
|
|
19562
19547
|
};
|
|
19563
19548
|
validateResponseAreaClose = (e, t, n, r, i) => {
|
|
19564
|
-
let
|
|
19549
|
+
let a = this.state.respAreaChoices, o = e.attrs.index, s = a[o] || [];
|
|
19565
19550
|
if (!(s.length < 2 || !s.find((e) => e.correct))) {
|
|
19566
19551
|
r();
|
|
19567
19552
|
return;
|
|
@@ -19571,21 +19556,21 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19571
19556
|
}, i);
|
|
19572
19557
|
};
|
|
19573
19558
|
onChange = (e) => {
|
|
19574
|
-
let
|
|
19559
|
+
let t = this.state.respAreaChoices, n = CT(e), r = n.querySelectorAll("[data-type=\"inline_dropdown\"]"), i = {};
|
|
19575
19560
|
r.forEach((e) => {
|
|
19576
19561
|
i[e.dataset.index] = e.dataset.value || "";
|
|
19577
19562
|
});
|
|
19578
19563
|
let a = ct(t, (e, n, r) => (ht(i[r]) || (e[r] = t[r]), e), {}), o = {};
|
|
19579
19564
|
r.forEach((e, t) => {
|
|
19580
19565
|
let n = a[e.dataset.index];
|
|
19581
|
-
n && (o[t] = n), e.dataset.index = t
|
|
19566
|
+
n && (o[t] = n), e.dataset.index = `${t}`;
|
|
19582
19567
|
}), this.onModelChange({
|
|
19583
19568
|
choices: ot(o),
|
|
19584
19569
|
slateMarkup: n.innerHTML
|
|
19585
19570
|
});
|
|
19586
19571
|
};
|
|
19587
19572
|
onAddChoice = (e, t, n) => {
|
|
19588
|
-
let
|
|
19573
|
+
let r = this.state.respAreaChoices, { maxResponseAreaChoices: i } = this.props.configuration, a = (e) => this.setState({ warning: {
|
|
19589
19574
|
open: !0,
|
|
19590
19575
|
text: e,
|
|
19591
19576
|
onClose: void 0,
|
|
@@ -19613,18 +19598,18 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19613
19598
|
this.onModelChange({ choices: ot(r) });
|
|
19614
19599
|
};
|
|
19615
19600
|
onRemoveChoice = (e, t) => {
|
|
19616
|
-
let
|
|
19601
|
+
let n = this.state.respAreaChoices;
|
|
19617
19602
|
n[e].splice(t, 1), this.onModelChange({ choices: ot(n) });
|
|
19618
19603
|
};
|
|
19619
19604
|
onSelectChoice = (e, t) => {
|
|
19620
|
-
let
|
|
19605
|
+
let n = this.state.respAreaChoices;
|
|
19621
19606
|
n[e] = n[e].map((e, n) => ({
|
|
19622
19607
|
...e,
|
|
19623
19608
|
correct: n === t
|
|
19624
19609
|
})), this.onModelChange({ choices: ot(n) });
|
|
19625
19610
|
};
|
|
19626
19611
|
render() {
|
|
19627
|
-
let { warning: e } = this.state, { model: t, configuration: n, onConfigurationChanged: r, imageSupport: i, uploadSoundSupport: a } = this.props, { baseInputConfiguration: o = {}, choiceRationale: s = {}, contentDimensions: c = {}, lockChoiceOrder: l = {}, maxResponseAreas: u, maxImageWidth: d = {}, maxImageHeight: f = {}, partialScoring: p = {}, prompt: m = {}, rationale: h = {}, settingsPanelDisabled: g, spellCheck: _ = {}, teacherInstructions: v = {}, template: y = {}, withRubric: b = {}, mathMlOptions: x = {}, language: S = {}, languageChoices: C = {}, responseAreaInputConfiguration: w = {} } = n || {}, { choiceRationaleEnabled: T, choices: E, errors: D,
|
|
19612
|
+
let { warning: e } = this.state, { model: t, configuration: n, onConfigurationChanged: r, imageSupport: i, uploadSoundSupport: a } = this.props, { baseInputConfiguration: o = {}, choiceRationale: s = {}, contentDimensions: c = {}, lockChoiceOrder: l = {}, maxResponseAreas: u, maxImageWidth: d = {}, maxImageHeight: f = {}, partialScoring: p = {}, prompt: m = {}, rationale: h = {}, settingsPanelDisabled: g, spellCheck: _ = {}, teacherInstructions: v = {}, template: y = {}, withRubric: b = {}, mathMlOptions: x = {}, language: S = {}, languageChoices: C = {}, responseAreaInputConfiguration: w = {} } = n || {}, { choiceRationaleEnabled: T, choices: E, errors: D, promptEnabled: ee, rationaleEnabled: O, spellCheckEnabled: k, teacherInstructionsEnabled: A, toolbarEditorPosition: j } = t || {}, { prompt: te, rationale: ne, responseAreasError: re, responseAreaChoicesError: ie, teacherInstructions: ae } = D || {}, oe = d && d.prompt, se = f && f.prompt, ce = () => (Object.keys(E) || []).map((e, t) => /* @__PURE__ */ z(vT, { children: /* @__PURE__ */ B(sx, {
|
|
19628
19613
|
slotProps: { transition: { timeout: {
|
|
19629
19614
|
enter: 225,
|
|
19630
19615
|
exit: 195
|
|
@@ -19637,31 +19622,31 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19637
19622
|
})
|
|
19638
19623
|
}), /* @__PURE__ */ z(yT, { children: (E[e] || []).map((t) => /* @__PURE__ */ B(R.Fragment, { children: [/* @__PURE__ */ z(_T, { dangerouslySetInnerHTML: { __html: `${h.label} for ${t.label} (${t.correct ? "correct" : "incorrect"})` } }), /* @__PURE__ */ z(hT, { children: /* @__PURE__ */ z(Jb, {
|
|
19639
19624
|
markup: t.rationale || "",
|
|
19640
|
-
spellCheck:
|
|
19641
|
-
pluginProps:
|
|
19625
|
+
spellCheck: k,
|
|
19626
|
+
pluginProps: pe(h?.inputConfiguration),
|
|
19642
19627
|
onChange: (n) => this.onChoiceRationaleChanged(e, {
|
|
19643
19628
|
...t,
|
|
19644
19629
|
rationale: n
|
|
19645
19630
|
}),
|
|
19646
19631
|
imageSupport: i,
|
|
19647
|
-
maxImageWidth: d && d.rationale ||
|
|
19648
|
-
maxImageHeight: f && f.rationale ||
|
|
19632
|
+
maxImageWidth: d && d.rationale || oe,
|
|
19633
|
+
maxImageHeight: f && f.rationale || se,
|
|
19649
19634
|
uploadSoundSupport: a,
|
|
19650
19635
|
mathMlOptions: x
|
|
19651
19636
|
}) })] }, t.label)) })]
|
|
19652
|
-
}) }, e)),
|
|
19637
|
+
}) }, e)), le = { position: j === "top" ? "top" : "bottom" }, ue = Kw(n), de = {
|
|
19653
19638
|
partialScoring: p.settings && dT(p.label),
|
|
19654
19639
|
lockChoiceOrder: l.settings && dT(l.label),
|
|
19655
19640
|
"language.enabled": S.settings && dT(S.label, !0),
|
|
19656
19641
|
language: S.settings && S.enabled && pT(C.label, C.options)
|
|
19657
|
-
},
|
|
19642
|
+
}, fe = {
|
|
19658
19643
|
teacherInstructionsEnabled: v.settings && dT(v.label),
|
|
19659
19644
|
rationaleEnabled: h.settings && dT(h.label),
|
|
19660
19645
|
choiceRationaleEnabled: s.settings && dT(s.label),
|
|
19661
19646
|
promptEnabled: m.settings && dT(m.label),
|
|
19662
19647
|
spellCheckEnabled: _.settings && dT(_.label),
|
|
19663
19648
|
rubricEnabled: b?.settings && dT(b?.label)
|
|
19664
|
-
},
|
|
19649
|
+
}, pe = (e = {}) => ({
|
|
19665
19650
|
...o,
|
|
19666
19651
|
...e
|
|
19667
19652
|
});
|
|
@@ -19678,30 +19663,30 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19678
19663
|
onChangeModel: (e) => this.onModelChange(e),
|
|
19679
19664
|
onChangeConfiguration: (e) => r(e, !0),
|
|
19680
19665
|
groups: {
|
|
19681
|
-
Settings:
|
|
19682
|
-
Properties:
|
|
19666
|
+
Settings: de,
|
|
19667
|
+
Properties: fe
|
|
19683
19668
|
}
|
|
19684
19669
|
}),
|
|
19685
19670
|
children: [
|
|
19686
|
-
|
|
19671
|
+
A && /* @__PURE__ */ B(mT, {
|
|
19687
19672
|
label: v.label,
|
|
19688
19673
|
children: [/* @__PURE__ */ z(Jb, {
|
|
19689
19674
|
markup: t.teacherInstructions || "",
|
|
19690
19675
|
onChange: this.onTeacherInstructionsChanged,
|
|
19691
19676
|
imageSupport: i,
|
|
19692
19677
|
nonEmpty: !1,
|
|
19693
|
-
error:
|
|
19694
|
-
toolbarOpts:
|
|
19695
|
-
pluginProps:
|
|
19696
|
-
spellCheck:
|
|
19697
|
-
maxImageWidth: d && d.teacherInstructions ||
|
|
19698
|
-
maxImageHeight: f && f.teacherInstructions ||
|
|
19678
|
+
error: ae,
|
|
19679
|
+
toolbarOpts: le,
|
|
19680
|
+
pluginProps: pe(v?.inputConfiguration),
|
|
19681
|
+
spellCheck: k,
|
|
19682
|
+
maxImageWidth: d && d.teacherInstructions || oe,
|
|
19683
|
+
maxImageHeight: f && f.teacherInstructions || se,
|
|
19699
19684
|
uploadSoundSupport: a,
|
|
19700
19685
|
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
19701
19686
|
mathMlOptions: x
|
|
19702
|
-
}),
|
|
19687
|
+
}), ae && /* @__PURE__ */ z(ST, { children: ae })]
|
|
19703
19688
|
}),
|
|
19704
|
-
|
|
19689
|
+
ee && /* @__PURE__ */ B(mT, {
|
|
19705
19690
|
label: m.label,
|
|
19706
19691
|
children: [/* @__PURE__ */ z(Jb, {
|
|
19707
19692
|
markup: t.prompt,
|
|
@@ -19709,16 +19694,16 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19709
19694
|
imageSupport: i,
|
|
19710
19695
|
nonEmpty: !1,
|
|
19711
19696
|
disableUnderline: !0,
|
|
19712
|
-
error:
|
|
19713
|
-
toolbarOpts:
|
|
19714
|
-
pluginProps:
|
|
19715
|
-
spellCheck:
|
|
19716
|
-
maxImageWidth:
|
|
19717
|
-
maxImageHeight:
|
|
19697
|
+
error: te,
|
|
19698
|
+
toolbarOpts: le,
|
|
19699
|
+
pluginProps: pe(m?.inputConfiguration),
|
|
19700
|
+
spellCheck: k,
|
|
19701
|
+
maxImageWidth: oe,
|
|
19702
|
+
maxImageHeight: se,
|
|
19718
19703
|
uploadSoundSupport: a,
|
|
19719
19704
|
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
19720
19705
|
mathMlOptions: x
|
|
19721
|
-
}),
|
|
19706
|
+
}), te && /* @__PURE__ */ z(ST, { children: te })]
|
|
19722
19707
|
}),
|
|
19723
19708
|
/* @__PURE__ */ B(bT, { children: [/* @__PURE__ */ z(gT, {
|
|
19724
19709
|
component: "div",
|
|
@@ -19727,17 +19712,17 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19727
19712
|
disableFocusListener: !0,
|
|
19728
19713
|
disableTouchListener: !0,
|
|
19729
19714
|
placement: "right",
|
|
19730
|
-
title:
|
|
19715
|
+
title: ue,
|
|
19731
19716
|
children: /* @__PURE__ */ z(Gw, {
|
|
19732
19717
|
fontSize: "small",
|
|
19733
19718
|
color: "primary"
|
|
19734
19719
|
})
|
|
19735
19720
|
})] }),
|
|
19736
19721
|
/* @__PURE__ */ z(uT, {
|
|
19737
|
-
responseAreasError:
|
|
19738
|
-
responseAreaChoicesError:
|
|
19722
|
+
responseAreasError: re,
|
|
19723
|
+
responseAreaChoicesError: ie,
|
|
19739
19724
|
editableHtmlProps: {
|
|
19740
|
-
pluginProps:
|
|
19725
|
+
pluginProps: pe(y?.inputConfiguration),
|
|
19741
19726
|
activePlugins: qr,
|
|
19742
19727
|
toolbarOpts: { position: "top" },
|
|
19743
19728
|
extraCSSRules: {
|
|
@@ -19752,7 +19737,7 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19752
19737
|
this.validateResponseAreaClose(e, t, n, r, i);
|
|
19753
19738
|
},
|
|
19754
19739
|
respAreaToolbar: (e, t, n) => {
|
|
19755
|
-
let [r, i] = e,
|
|
19740
|
+
let [r, i] = e, s = this.state.respAreaChoices;
|
|
19756
19741
|
return (e) => /* @__PURE__ */ z(sT, {
|
|
19757
19742
|
...e,
|
|
19758
19743
|
onAddChoice: this.onAddChoice,
|
|
@@ -19763,7 +19748,7 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19763
19748
|
editor: t,
|
|
19764
19749
|
onToolbarDone: n,
|
|
19765
19750
|
choices: s[r.attrs.index],
|
|
19766
|
-
spellCheck:
|
|
19751
|
+
spellCheck: k,
|
|
19767
19752
|
uploadSoundSupport: a,
|
|
19768
19753
|
mathMlOptions: x,
|
|
19769
19754
|
baseInputConfiguration: o,
|
|
@@ -19771,36 +19756,36 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19771
19756
|
});
|
|
19772
19757
|
}
|
|
19773
19758
|
},
|
|
19774
|
-
spellCheck:
|
|
19759
|
+
spellCheck: k,
|
|
19775
19760
|
markup: t.slateMarkup || "",
|
|
19776
19761
|
onChange: this.onChange,
|
|
19777
19762
|
imageSupport: i,
|
|
19778
19763
|
disableImageAlignmentButtons: !0,
|
|
19779
19764
|
disabled: !1,
|
|
19780
19765
|
highlightShape: !1,
|
|
19781
|
-
error:
|
|
19766
|
+
error: re,
|
|
19782
19767
|
uploadSoundSupport: a,
|
|
19783
19768
|
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
19784
19769
|
mathMlOptions: x
|
|
19785
19770
|
}
|
|
19786
19771
|
}),
|
|
19787
|
-
T &&
|
|
19788
|
-
|
|
19772
|
+
T && ce(),
|
|
19773
|
+
O && /* @__PURE__ */ B(mT, {
|
|
19789
19774
|
label: h.label,
|
|
19790
19775
|
children: [/* @__PURE__ */ z(Jb, {
|
|
19791
19776
|
markup: t.rationale || "",
|
|
19792
19777
|
onChange: this.onRationaleChanged,
|
|
19793
19778
|
imageSupport: i,
|
|
19794
|
-
error:
|
|
19795
|
-
toolbarOpts:
|
|
19796
|
-
pluginProps:
|
|
19797
|
-
spellCheck:
|
|
19798
|
-
maxImageWidth: d && d.rationale ||
|
|
19799
|
-
maxImageHeight: f && f.rationale ||
|
|
19779
|
+
error: ne,
|
|
19780
|
+
toolbarOpts: le,
|
|
19781
|
+
pluginProps: pe(h?.inputConfiguration),
|
|
19782
|
+
spellCheck: k,
|
|
19783
|
+
maxImageWidth: d && d.rationale || oe,
|
|
19784
|
+
maxImageHeight: f && f.rationale || se,
|
|
19800
19785
|
uploadSoundSupport: a,
|
|
19801
19786
|
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
19802
19787
|
mathMlOptions: x
|
|
19803
|
-
}),
|
|
19788
|
+
}), ne && /* @__PURE__ */ z(ST, { children: ne })]
|
|
19804
19789
|
}),
|
|
19805
19790
|
/* @__PURE__ */ z(MS, {
|
|
19806
19791
|
open: e.open,
|
|
@@ -19960,6 +19945,10 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19960
19945
|
};
|
|
19961
19946
|
return n.replace(MT, (e, t) => r(t));
|
|
19962
19947
|
}, PT = (0, En.default)("multiple-choice:configure"), FT = class e extends HTMLElement {
|
|
19948
|
+
_root;
|
|
19949
|
+
_model;
|
|
19950
|
+
_configuration;
|
|
19951
|
+
_disableSidePanel;
|
|
19963
19952
|
static prepareModel = (e = {}) => {
|
|
19964
19953
|
let t = {
|
|
19965
19954
|
...TT.model,
|
|
@@ -19978,7 +19967,8 @@ var Vw = ve, Hw = Vw.default, Uw = Hw && typeof Hw == "object" ? Hw : Vw, Ww = B
|
|
|
19978
19967
|
this._model = e.prepareModel(t), this._render();
|
|
19979
19968
|
}
|
|
19980
19969
|
set configuration(e) {
|
|
19981
|
-
|
|
19970
|
+
let t = at(e, TT.configuration);
|
|
19971
|
+
this._configuration = t, e.language?.enabled ? e.languageChoices?.options?.length && (this._model.language = e.languageChoices.options[0].value) : e.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({
|
|
19982
19972
|
value: this._model.language,
|
|
19983
19973
|
label: this._model.language
|
|
19984
19974
|
})) : delete this._model.language, this._render();
|