@pie-element/multiple-choice 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 +60 -58
- package/dist/author/index.d.ts +19 -11
- package/dist/author/index.js +6 -1
- package/dist/author/main.d.ts +30 -19
- package/dist/author/main.js +121 -133
- package/dist/author/utils.d.ts +2 -1
- package/dist/browser/author/index.js +15 -23
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +9 -8
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/editor-runtime/author/index.js +15 -23
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/controller/index.js +9 -8
- package/dist/browser/editor-runtime/controller/index.js.map +1 -1
- package/dist/controller/defaults.d.ts +13 -13
- package/dist/controller/index.d.ts +103 -32
- package/dist/controller/index.js +9 -8
- package/dist/controller/utils.d.ts +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/schemas/configuration.schema.json +447 -0
- package/dist/schemas/model.schema.json +567 -0
- package/dist/schemas/session.schema.json +30 -0
- package/dist/types.d.ts +243 -0
- package/package.json +18 -14
|
@@ -77,13 +77,13 @@ function p(e, t, n) {
|
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region src/controller/index.ts
|
|
79
79
|
var m = (e, t, n) => (r) => {
|
|
80
|
-
let
|
|
80
|
+
let i = t?.role, a = t?.mode, o = {
|
|
81
81
|
label: r.label,
|
|
82
82
|
value: r.value
|
|
83
83
|
};
|
|
84
84
|
if (i === "instructor" && (a === "view" || a === "evaluate") ? o.rationale = e.rationaleEnabled ? r.rationale : null : o.rationale = null, a === "evaluate" && (o.correct = !!r.correct, e.feedbackEnabled)) {
|
|
85
85
|
let e = r.feedback && r.feedback.type || "none";
|
|
86
|
-
e === "default" ? o.feedback = n[r.correct ? "correct" : "incorrect"] : e === "custom" && (o.feedback = r.feedback
|
|
86
|
+
e === "default" ? o.feedback = n[r.correct ? "correct" : "incorrect"] : e === "custom" && (o.feedback = r.feedback?.value);
|
|
87
87
|
}
|
|
88
88
|
return o;
|
|
89
89
|
};
|
|
@@ -107,7 +107,8 @@ async function _(e, t, n, i) {
|
|
|
107
107
|
incorrect: "Incorrect"
|
|
108
108
|
}, a.defaultFeedback), s = (a.choices || []).map(m(a, n, o));
|
|
109
109
|
d(a, t, n) || (s = await u(s, t, i, "value"));
|
|
110
|
-
let c =
|
|
110
|
+
let { role: c, mode: l } = n;
|
|
111
|
+
return {
|
|
111
112
|
disabled: n.mode !== "gather",
|
|
112
113
|
mode: n.mode,
|
|
113
114
|
prompt: a.promptEnabled ? a.prompt : null,
|
|
@@ -132,13 +133,13 @@ async function _(e, t, n, i) {
|
|
|
132
133
|
keyboardEventsEnabled: a.keyboardEventsEnabled,
|
|
133
134
|
autoplayAudioEnabled: a.autoplayAudioEnabled,
|
|
134
135
|
completeAudioEnabled: a.completeAudioEnabled,
|
|
135
|
-
customAudioButton: a.customAudioButton
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
customAudioButton: a.customAudioButton,
|
|
137
|
+
teacherInstructions: c === "instructor" && (l === "view" || l === "evaluate") && a.teacherInstructionsEnabled ? a.teacherInstructions : null
|
|
138
|
+
};
|
|
138
139
|
}
|
|
139
140
|
var v = (e, n) => {
|
|
140
141
|
if (!n || t(n)) return 0;
|
|
141
|
-
let r = n
|
|
142
|
+
let r = n?.value || [], i = (e.choices || []).filter((e) => e.correct), a = r.reduce((e, t) => e + +!!i.find((e) => e.value === t), 0);
|
|
142
143
|
i.length < r.length && (a -= r.length - i.length, a < 0 && (a = 0));
|
|
143
144
|
let o = i.length ? a / i.length : 0;
|
|
144
145
|
return parseFloat(o.toFixed(2));
|
|
@@ -191,7 +192,7 @@ var x = (e, t) => new Promise((n) => {
|
|
|
191
192
|
r && (u = !0, d++), S(a) ? o.slice(t + 1).some((e) => e.label === a) && (s[i] = "Content should be unique.") : s[i] = "Content should not be empty.", n.rationale?.required && !S(l) && (c[i] = "This field is required.");
|
|
192
193
|
});
|
|
193
194
|
let f = (r || []).length;
|
|
194
|
-
if (f < i ? l.answerChoices = `There should be at least ${i} choices defined.` : f > a && (l.answerChoices = `No more than ${a} choices should be defined.`), !u) l.correctResponse = "No correct response defined.";
|
|
195
|
+
if (f < i ? l.answerChoices = `There should be at least ${i} choices defined.` : a !== void 0 && f > a && (l.answerChoices = `No more than ${a} choices should be defined.`), !u) l.correctResponse = "No correct response defined.";
|
|
195
196
|
else {
|
|
196
197
|
let { maxSelections: t, choiceMode: n } = e;
|
|
197
198
|
n !== "radio" && t != null && d > t && (l.correctResponse = `The number of correct answers (${d}) exceeds max selections (${t}). Students won't be able to select all correct answers.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/utils.ts","../../../src/controller/defaults.ts","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/index.ts"],"sourcesContent":["// @ts-nocheck\n\nimport { isEqual } from '@pie-element/shared-lodash';\n\nexport const getCorrectResponse = (choices) =>\n choices\n .filter((c) => c.correct)\n .map((c) => c.value)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n let correctResponse = getCorrectResponse(question.choices);\n return session && isEqual((session.value || []).sort(), correctResponse);\n};\n","// @ts-nocheck\n\nexport default {\n choiceMode: 'checkbox',\n choicePrefix: 'letters',\n choices: [],\n choicesLayout: 'vertical',\n feedbackEnabled: false,\n gridColumns: 2,\n lockChoiceOrder: true,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n selectedAnswerBackgroundColor: 'initial',\n selectedAnswerStrokeColor: 'initial',\n selectedAnswerStrokeWidth: 'initial',\n hoverAnswerBackgroundColor: 'initial',\n hoverAnswerStrokeColor: 'initial',\n hoverAnswerStrokeWidth: 'initial',\n keyboardEventsEnabled: false,\n};\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\n/* eslint-disable no-console */\nimport { isEmpty } from '@pie-element/shared-lodash';\nimport { isResponseCorrect } from './utils.js';\nimport defaults from './defaults.js';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-element/shared-controller-utils';\n\nconst prepareChoice = (model, env, defaultFeedback) => (choice) => {\n const { role, mode } = env || {};\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = (question) => {\n const { verticalMode, choicesLayout, ...questionProps } = question || {};\n\n return {\n ...defaults,\n ...questionProps,\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel\n choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout,\n };\n};\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\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n let choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'value');\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n fontSizeFactor: normalizedQuestion.fontSizeFactor,\n isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,\n selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',\n selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',\n selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',\n hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',\n hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',\n hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',\n minSelections: normalizedQuestion.minSelections,\n maxSelections: normalizedQuestion.maxSelections,\n keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,\n autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,\n completeAudioEnabled: normalizedQuestion.completeAudioEnabled,\n customAudioButton: normalizedQuestion.customAudioButton,\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport const getScore = (config, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session.value || [];\n const correctChoices = (config.choices || []).filter((ch) => ch.correct);\n\n let score = selectedChoices.reduce(\n (acc, selectedChoice) => acc + (correctChoices.find((ch) => ch.value === selectedChoice) ? 1 : 0),\n 0,\n );\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\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 selected = session?.value || [];\n \n const questionType = model.choiceMode === 'radio' ? 'multiple-choice (radio)' : 'multiple-select (checkbox)';\n traceLog.push(`Question type: ${questionType}.`);\n \n if (selected.length) {\n traceLog.push(`Student selected ${selected.length} answer(s): ${selected.join(', ')}.`);\n } else {\n traceLog.push('Student did not select any answers.');\n }\n\n const correctChoices = (model.choices || []).filter((c) => c.correct);\n const correctValues = correctChoices.map((c) => c.value);\n traceLog.push(`${correctChoices.length} correct answer(s) are defined for this question.`);\n \n if (selected.length) {\n const correctSelected = selected.filter((v) => correctValues.includes(v));\n const incorrectSelected = selected.filter((v) => !correctValues.includes(v));\n traceLog.push(\n `Student selected ${correctSelected.length} correct and ${incorrectSelected.length} incorrect answer(s).`\n );\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const scoringMethod = partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring';\n traceLog.push(`Score calculated using ${scoringMethod}.`);\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 = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true, traceLog: ['Student did not select any answers. Score is 0.'] });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n\n resolve({ \n score: partialScoringEnabled ? score : score === 1 ? 1 : 0, \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 || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter((c) => c.correct).map((c) => c.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 { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const choicesErrors = {};\n const rationaleErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n let hasCorrectResponse = false;\n let correctCount = 0;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label, rationale } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n correctCount++;\n }\n\n if (!getContent(label)) {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n\n if (config.rationale?.required && !getContent(rationale)) {\n rationaleErrors[value] = 'This field is required.';\n }\n });\n\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponse = 'No correct response defined.';\n } else {\n const { maxSelections, choiceMode } = model;\n\n if (choiceMode !== 'radio' && maxSelections != null && correctCount > maxSelections) {\n errors.correctResponse = `The number of correct answers (${correctCount}) exceeds max selections (${maxSelections}). Students won't be able to select all correct answers.`;\n }\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choices = choicesErrors;\n }\n\n if (!isEmpty(rationaleErrors)) {\n errors.rationale = rationaleErrors;\n }\n\n return errors;\n};\n"],"mappings":";;AAIA,IAAa,KAAsB,MACjC,EACG,QAAQ,MAAM,EAAE,OAAO,CAAC,CACxB,KAAK,MAAM,EAAE,KAAK,CAAC,CACnB,KAAK,GAEG,KAAqB,GAAU,MAAY;CACtD,IAAI,IAAkB,EAAmB,EAAS,OAAO;CACzD,OAAO,KAAW,GAAS,EAAQ,SAAS,CAAC,EAAA,CAAG,KAAK,GAAG,CAAe;AACzE,GCXA,IAAe;CACb,YAAY;CACZ,cAAc;CACd,SAAS,CAAC;CACV,eAAe;CACf,iBAAiB;CACjB,aAAa;CACb,iBAAiB;CACjB,gBAAgB;CAChB,QAAQ;CACR,eAAe;CACf,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,4BAA4B;CAC5B,qBAAqB;CACrB,4BAA4B;CAC5B,uBAAuB;CACvB,+BAA+B;CAC/B,2BAA2B;CAC3B,2BAA2B;CAC3B,4BAA4B;CAC5B,wBAAwB;CACxB,wBAAwB;CACxB,uBAAuB;AACzB,GC1BI,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,a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,CAAK,IAGK,EAAgB,MAAM,IAAQ,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,UAAU,CAE7E,MACF,EAAc,KAAS,+BALzB,EAAc,KAAS,gCASrB,EAAO,WAAW,YAAY,CAAC,EAAW,CAAS,MACrD,EAAgB,KAAS;CAE7B,CAAC;CAED,IAAM,KAAe,KAAW,CAAC,EAAA,CAAG;CAQpC,IANI,IAAc,IAChB,EAAO,gBAAgB,4BAA4B,EAAiB,qBAC3D,IAAc,MACvB,EAAO,gBAAgB,gBAAgB,EAAiB,+BAGtD,CAAC,GACH,EAAO,kBAAkB;MACpB;EACL,IAAM,EAAE,kBAAe,kBAAe;EAEtC,AAAI,MAAe,WAAW,KAAiB,QAAQ,IAAe,MACpE,EAAO,kBAAkB,kCAAkC,EAAa,4BAA4B,EAAc;CAEtH;CAUA,OARK,EAAQ,CAAa,MACxB,EAAO,UAAU,IAGd,EAAQ,CAAe,MAC1B,EAAO,YAAY,IAGd;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/utils.ts","../../../src/controller/defaults.ts","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/index.ts"],"sourcesContent":["import { isEqual } from '@pie-element/shared-lodash';\nimport type { Choice, MultipleChoiceModel, MultipleChoiceSession } from '../types.js';\n\nexport const getCorrectResponse = (choices: Choice[]) =>\n choices\n .filter((c) => c.correct)\n .map((c) => c.value)\n .sort();\n\nexport const isResponseCorrect = (question: MultipleChoiceModel, session: MultipleChoiceSession | undefined) => {\n let correctResponse = getCorrectResponse(question.choices);\n return session && isEqual((session.value || []).sort(), correctResponse);\n};\n","import type { MultipleChoiceModel } from '../types.js';\n\nexport default {\n choiceMode: 'checkbox',\n choicePrefix: 'letters',\n choices: [],\n choicesLayout: 'vertical',\n feedbackEnabled: false,\n gridColumns: 2,\n lockChoiceOrder: true,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n selectedAnswerBackgroundColor: 'initial',\n selectedAnswerStrokeColor: 'initial',\n selectedAnswerStrokeWidth: 'initial',\n hoverAnswerBackgroundColor: 'initial',\n hoverAnswerStrokeColor: 'initial',\n hoverAnswerStrokeWidth: 'initial',\n keyboardEventsEnabled: false,\n} satisfies Omit<MultipleChoiceModel, 'id' | 'element'>;\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","/* eslint-disable no-console */\nimport { isEmpty } from '@pie-element/shared-lodash';\nimport type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';\nimport { isResponseCorrect } from './utils.js';\nimport defaults from './defaults.js';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-element/shared-controller-utils';\nimport type {\n Choice,\n MultipleChoiceConfiguration,\n MultipleChoiceModel,\n MultipleChoiceSession,\n} from '../types.js';\n\ntype DefaultFeedback = { correct: string; incorrect: string };\n\n/** A choice as the delivery view receives it. */\ntype ChoiceView = {\n label: string;\n value: string;\n rationale?: string | null;\n correct?: boolean;\n feedback?: string;\n};\n\n/** Errors `validate()` reports, keyed by field; `choices` and `rationale` are keyed by choice value. */\nexport type MultipleChoiceValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n answerChoices?: string;\n correctResponse?: string;\n choices?: Record<string, string>;\n rationale?: Record<string, string>;\n};\n\nconst prepareChoice =\n (model: MultipleChoiceModel, env: PieEnvironment | undefined, defaultFeedback: DefaultFeedback) =>\n (choice: Choice): ChoiceView => {\n const role = env?.role;\n const mode = env?.mode;\n const out: ChoiceView = {\n label: choice.label,\n value: choice.value,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback?.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model: Partial<MultipleChoiceModel> = {}) {\n return new Promise<Partial<MultipleChoiceModel>>((resolve) => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = (question: MultipleChoiceModel) => {\n const { verticalMode, choicesLayout, ...questionProps } = question || {};\n\n return {\n ...defaults,\n ...questionProps,\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel\n choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout,\n };\n};\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: MultipleChoiceModel,\n session: MultipleChoiceSession | undefined,\n env: PieEnvironment,\n updateSession?: PieUpdateSession,\n) {\n const normalizedQuestion = normalize(question);\n\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n let choices: ChoiceView[] | undefined = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'value');\n }\n\n const { role, mode } = env;\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n fontSizeFactor: normalizedQuestion.fontSizeFactor,\n isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,\n selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',\n selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',\n selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',\n hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',\n hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',\n hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',\n minSelections: normalizedQuestion.minSelections,\n maxSelections: normalizedQuestion.maxSelections,\n keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,\n autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,\n completeAudioEnabled: normalizedQuestion.completeAudioEnabled,\n customAudioButton: normalizedQuestion.customAudioButton,\n teacherInstructions:\n role === 'instructor' && (mode === 'view' || mode === 'evaluate') && normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null,\n };\n\n return out;\n}\n\nexport const getScore = (config: MultipleChoiceModel, session: MultipleChoiceSession | undefined) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session?.value || [];\n const correctChoices = (config.choices || []).filter((ch) => ch.correct);\n\n let score = selectedChoices.reduce(\n (acc, selectedChoice) => acc + (correctChoices.find((ch) => ch.value === selectedChoice) ? 1 : 0),\n 0,\n );\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\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: MultipleChoiceModel,\n session: MultipleChoiceSession | undefined,\n env: PieEnvironment,\n) => {\n const traceLog: string[] = [];\n const selected = session?.value || [];\n \n const questionType = model.choiceMode === 'radio' ? 'multiple-choice (radio)' : 'multiple-select (checkbox)';\n traceLog.push(`Question type: ${questionType}.`);\n \n if (selected.length) {\n traceLog.push(`Student selected ${selected.length} answer(s): ${selected.join(', ')}.`);\n } else {\n traceLog.push('Student did not select any answers.');\n }\n\n const correctChoices = (model.choices || []).filter((c) => c.correct);\n const correctValues = correctChoices.map((c) => c.value);\n traceLog.push(`${correctChoices.length} correct answer(s) are defined for this question.`);\n \n if (selected.length) {\n const correctSelected = selected.filter((v) => correctValues.includes(v));\n const incorrectSelected = selected.filter((v) => !correctValues.includes(v));\n traceLog.push(\n `Student selected ${correctSelected.length} correct and ${incorrectSelected.length} incorrect answer(s).`\n );\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const scoringMethod = partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring';\n traceLog.push(`Score calculated using ${scoringMethod}.`);\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 = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model: MultipleChoiceModel, session: MultipleChoiceSession | undefined, env: PieEnvironment) {\n return new Promise<{ score: number; empty: boolean; traceLog: string[] }>((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true, traceLog: ['Student did not select any answers. Score is 0.'] });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n\n resolve({ \n score: partialScoringEnabled ? score : score === 1 ? 1 : 0, \n empty: false, \n traceLog \n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question: MultipleChoiceModel, env: PieEnvironment) => {\n return new Promise<MultipleChoiceSession | null>((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter((c) => c.correct).map((c) => c.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<MultipleChoiceModel> = {},\n config: MultipleChoiceConfiguration = {},\n): MultipleChoiceValidationErrors => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const choicesErrors: Record<string, string> = {};\n const rationaleErrors: Record<string, string> = {};\n const errors: MultipleChoiceValidationErrors = {};\n\n (['teacherInstructions', 'prompt'] as const).forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n let hasCorrectResponse = false;\n let correctCount = 0;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label, rationale } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n correctCount++;\n }\n\n if (!getContent(label)) {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n\n if (config.rationale?.required && !getContent(rationale)) {\n rationaleErrors[value] = 'This field is required.';\n }\n });\n\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (maxAnswerChoices !== undefined && nbOfChoices > maxAnswerChoices) {\n errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponse = 'No correct response defined.';\n } else {\n const { maxSelections, choiceMode } = model;\n\n if (choiceMode !== 'radio' && maxSelections != null && correctCount > maxSelections) {\n errors.correctResponse = `The number of correct answers (${correctCount}) exceeds max selections (${maxSelections}). Students won't be able to select all correct answers.`;\n }\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choices = choicesErrors;\n }\n\n if (!isEmpty(rationaleErrors)) {\n errors.rationale = rationaleErrors;\n }\n\n return errors;\n};\n"],"mappings":";;AAGA,IAAa,KAAsB,MACjC,EACG,QAAQ,MAAM,EAAE,OAAO,CAAC,CACxB,KAAK,MAAM,EAAE,KAAK,CAAC,CACnB,KAAK,GAEG,KAAqB,GAA+B,MAA+C;CAC9G,IAAI,IAAkB,EAAmB,EAAS,OAAO;CACzD,OAAO,KAAW,GAAS,EAAQ,SAAS,CAAC,EAAA,CAAG,KAAK,GAAG,CAAe;AACzE,GCVA,IAAe;CACb,YAAY;CACZ,cAAc;CACd,SAAS,CAAC;CACV,eAAe;CACf,iBAAiB;CACjB,aAAa;CACb,iBAAiB;CACjB,gBAAgB;CAChB,QAAQ;CACR,eAAe;CACf,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,4BAA4B;CAC5B,qBAAqB;CACrB,4BAA4B;CAC5B,uBAAuB;CACvB,+BAA+B;CAC/B,2BAA2B;CAC3B,2BAA2B;CAC3B,4BAA4B;CAC5B,wBAAwB;CACxB,wBAAwB;CACxB,uBAAuB;AACzB,GC1BI,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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,CAAC;CAED,IAAM,KAAe,KAAW,CAAC,EAAA,CAAG;CAQpC,IANI,IAAc,IAChB,EAAO,gBAAgB,4BAA4B,EAAiB,qBAC3D,MAAqB,KAAA,KAAa,IAAc,MACzD,EAAO,gBAAgB,gBAAgB,EAAiB,+BAGtD,CAAC,GACH,EAAO,kBAAkB;MACpB;EACL,IAAM,EAAE,kBAAe,kBAAe;EAEtC,AAAI,MAAe,WAAW,KAAiB,QAAQ,IAAe,MACpE,EAAO,kBAAkB,kCAAkC,EAAa,4BAA4B,EAAc;CAEtH;CAUA,OARK,EAAQ,CAAa,MACxB,EAAO,UAAU,IAGd,EAAQ,CAAe,MAC1B,EAAO,YAAY,IAGd;AACT"}
|
|
@@ -17626,7 +17626,8 @@ var pS = Ve, mS = pS.default, hS = mS && typeof mS == "object" ? mS : pS, gS = f
|
|
|
17626
17626
|
toolbarOpts: V.default.object,
|
|
17627
17627
|
uploadSoundSupport: V.default.object,
|
|
17628
17628
|
maxImageWidth: V.default.number,
|
|
17629
|
-
maxImageHeight: V.default.number
|
|
17629
|
+
maxImageHeight: V.default.number,
|
|
17630
|
+
mathMlOptions: V.default.object
|
|
17630
17631
|
};
|
|
17631
17632
|
static defaultProps = {
|
|
17632
17633
|
index: -1,
|
|
@@ -18579,15 +18580,12 @@ var lw = class extends R.Component {
|
|
|
18579
18580
|
}), pw = (e) => typeof e == "string" ? {
|
|
18580
18581
|
label: e,
|
|
18581
18582
|
value: e
|
|
18582
|
-
} : e, mw =
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
isConfigProperty: n
|
|
18589
|
-
};
|
|
18590
|
-
}, hw = (e, t, n = !1) => ({
|
|
18583
|
+
} : e, mw = (e, t, n = !1) => ({
|
|
18584
|
+
type: "radio",
|
|
18585
|
+
label: e,
|
|
18586
|
+
choices: t && t.map((e) => pw(e)),
|
|
18587
|
+
isConfigProperty: n
|
|
18588
|
+
}), hw = (e, t, n = !1) => ({
|
|
18591
18589
|
type: "dropdown",
|
|
18592
18590
|
label: e,
|
|
18593
18591
|
choices: t,
|
|
@@ -18664,7 +18662,7 @@ var Sw = Ve, Cw = Sw.default, ww = Cw && typeof Cw == "object" ? Cw : Sw, Tw = x
|
|
|
18664
18662
|
color: e.palette.error.main,
|
|
18665
18663
|
paddingTop: e.spacing(1)
|
|
18666
18664
|
})), Hw = (e) => {
|
|
18667
|
-
let { model: t, configuration: n, onPromptChanged: r, onChoiceChanged: i, onRemoveChoice: a, onAddChoice: o, imageSupport: s, uploadSoundSupport: c, onChangeModel: l, onConfigurationChanged: u, onTeacherInstructionsChanged: d } = e, { addChoiceButton: f = {}, contentDimensions: p = {}, feedback: m = {}, deleteChoice: h = {}, choiceMode: g = {}, choicePrefix: _ = {}, partialScoring: v = {}, lockChoiceOrder: y = {}, teacherInstructions: b = {}, studentInstructions: x = {}, rationale: S = {}, scoringType: C = {}, sequentialChoiceLabels: ee = {}, settingsPanelDisabled: w, choicesLayout: T, spellCheck: te = {}, gridColumns: ne, maxImageWidth: E = {}, maxImageHeight: D = {}, prompt: O = {}, withRubric: k = {}, mathMlOptions: A = {}, language: j = {}, languageChoices: re = {} } = n || {}, { maxAnswerChoices: ie } = n || {}, { limitChoicesNumber: ae, teacherInstructionsEnabled: oe, rationaleEnabled: M, feedbackEnabled: N, promptEnabled: se, spellCheckEnabled: ce, choices: le, errors: P, toolbarEditorPosition: ue, extraCSSRules: de } = t || {}, { answerChoices: fe, choices: pe, correctResponse: me, prompt: he, rationale: ge, teacherInstructions: _e } = P || {}, ve = le?.length ? Array.from({ length: le.length }, (e, t) => `${t + 1}`) : [], { baseInputConfiguration: ye = {} } = n, be = { position: ue === "top" ? "top" : "bottom" };
|
|
18665
|
+
let { model: t, configuration: n, onPromptChanged: r, onChoiceChanged: i, onRemoveChoice: a, onAddChoice: o, imageSupport: s, uploadSoundSupport: c, onChangeModel: l, onConfigurationChanged: u, onTeacherInstructionsChanged: d } = e, { addChoiceButton: f = {}, contentDimensions: p = {}, feedback: m = {}, deleteChoice: h = {}, choiceMode: g = {}, choicePrefix: _ = {}, partialScoring: v = {}, lockChoiceOrder: y = {}, teacherInstructions: b = {}, studentInstructions: x = {}, rationale: S = {}, scoringType: C = {}, sequentialChoiceLabels: ee = {}, settingsPanelDisabled: w, choicesLayout: T = {}, spellCheck: te = {}, gridColumns: ne = {}, maxImageWidth: E = {}, maxImageHeight: D = {}, prompt: O = {}, withRubric: k = {}, mathMlOptions: A = {}, language: j = {}, languageChoices: re = {} } = n || {}, { maxAnswerChoices: ie } = n || {}, { limitChoicesNumber: ae, teacherInstructionsEnabled: oe, rationaleEnabled: M, feedbackEnabled: N, promptEnabled: se, spellCheckEnabled: ce, choices: le, errors: P, toolbarEditorPosition: ue, extraCSSRules: de } = t || {}, { answerChoices: fe, choices: pe, correctResponse: me, prompt: he, rationale: ge, teacherInstructions: _e } = P || {}, ve = le?.length ? Array.from({ length: le.length }, (e, t) => `${t + 1}`) : [], { baseInputConfiguration: ye = {} } = n, be = { position: ue === "top" ? "top" : "bottom" };
|
|
18668
18666
|
ae && (ie = Mw);
|
|
18669
18667
|
let F = (e = {}) => ({
|
|
18670
18668
|
...ye,
|
|
@@ -18822,17 +18820,6 @@ var Sw = Ve, Cw = Sw.default, ww = Cw && typeof Cw == "object" ? Cw : Sw, Tw = x
|
|
|
18822
18820
|
]
|
|
18823
18821
|
});
|
|
18824
18822
|
}, Uw = class extends R.Component {
|
|
18825
|
-
static propTypes = {
|
|
18826
|
-
model: V.default.object.isRequired,
|
|
18827
|
-
configuration: V.default.object.isRequired,
|
|
18828
|
-
disableSidePanel: V.default.bool,
|
|
18829
|
-
onModelChanged: V.default.func.isRequired,
|
|
18830
|
-
onConfigurationChanged: V.default.func.isRequired,
|
|
18831
|
-
imageSupport: V.default.shape({
|
|
18832
|
-
add: V.default.func.isRequired,
|
|
18833
|
-
delete: V.default.func.isRequired
|
|
18834
|
-
})
|
|
18835
|
-
};
|
|
18836
18823
|
state = { showWarning: !1 };
|
|
18837
18824
|
onRemoveChoice = (e) => {
|
|
18838
18825
|
let { model: t, configuration: n, onModelChanged: r } = this.props, { minAnswerChoices: i } = n || {};
|
|
@@ -19066,6 +19053,11 @@ var Sw = Ve, Cw = Sw.default, ww = Cw && typeof Cw == "object" ? Cw : Sw, Tw = x
|
|
|
19066
19053
|
}
|
|
19067
19054
|
};
|
|
19068
19055
|
}, Jw = class e extends HTMLElement {
|
|
19056
|
+
_root;
|
|
19057
|
+
_reactContainer;
|
|
19058
|
+
_model;
|
|
19059
|
+
_configuration;
|
|
19060
|
+
_disableSidePanel;
|
|
19069
19061
|
static createDefaultModel = (e = {}) => {
|
|
19070
19062
|
let t = NC.normalizeChoices({
|
|
19071
19063
|
...Ww.model,
|
|
@@ -19087,7 +19079,7 @@ var Sw = Ve, Cw = Sw.default, ww = Cw && typeof Cw == "object" ? Cw : Sw, Tw = x
|
|
|
19087
19079
|
...Ww.configuration,
|
|
19088
19080
|
...t.configuration
|
|
19089
19081
|
};
|
|
19090
|
-
this._configuration = n, n?.language?.enabled ? n?.languageChoices?.options?.length && (this._model.language = n?.languageChoices.options[0].value) : n.language.settings && this._model.language ? (
|
|
19082
|
+
this._configuration = n, n?.language?.enabled ? n?.languageChoices?.options?.length && (this._model.language = n?.languageChoices.options[0].value) : n.language.settings && this._model.language ? (n.language.enabled = !0, (!n.languageChoices.options || !n.languageChoices.options.length) && (n.languageChoices.options = []), n.languageChoices.options.find((e) => e.value === this._model.language) || n.languageChoices.options.push({
|
|
19091
19083
|
value: this._model.language,
|
|
19092
19084
|
label: this._model.language
|
|
19093
19085
|
})) : delete this._model.language, this._render();
|