@pie-element/charting 13.0.4-next.20261011174919 → 13.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/charting-config.d.ts +19 -4
- package/dist/author/configure.d.ts +39 -16
- package/dist/author/configure.js +76 -87
- package/dist/author/correct-response.d.ts +18 -1
- package/dist/author/defaults.d.ts +60 -58
- package/dist/author/index.d.ts +15 -38
- package/dist/author/index.js +12 -4
- package/dist/browser/author/index.js +22 -27
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/editor-runtime/author/index.js +22 -27
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/controller/index.js.map +1 -1
- package/dist/controller/defaults.d.ts +14 -13
- package/dist/controller/index.d.ts +113 -11
- package/dist/index.d.ts +1 -0
- package/dist/schemas/configuration.schema.json +571 -0
- package/dist/schemas/model.schema.json +594 -0
- package/dist/schemas/session.schema.json +86 -0
- package/dist/types.d.ts +333 -0
- package/package.json +19 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/defaults.ts","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/index.ts"],"sourcesContent":["// @ts-nocheck\n\n/**\n * NOTE: There's no functionality described for graphTitle,\n * rationale, scoringType, studentInstructions, teacherInstructions\n * so there's no implementation (they are only added in model)\n */\n\nexport default {\n addCategoryEnabled: true,\n changeAddCategoryEnabled: false,\n changeEditableEnabled: false,\n changeInteractiveEnabled: false,\n chartType: 'lineCross',\n correctAnswer: {},\n data: [],\n domain: {},\n graph: { width: 480, height: 480 },\n prompt: '',\n promptEnabled: true,\n range: { label: '', max: 1, min: 0, labelStep: 1 },\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'all or nothing',\n studentInstructionsEnabled: true,\n studentNewCategoryDefaultLabel: 'New Category',\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n title: '',\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\nimport debug from 'debug';\nimport { isEmpty, isEqual, pick } from '@pie-element/shared-lodash';\nimport defaults from './defaults.js';\n\nimport { partialScoring } from '@pie-element/shared-controller-utils';\n\nconst log = debug('@pie-element:graphing:controller');\n\nconst lowerCase = (string) => (string || '').toLowerCase();\n\nexport const checkLabelsEquality = (givenAnswerLabel, correctAnswerLabel) =>\n lowerCase(givenAnswerLabel) === lowerCase(correctAnswerLabel);\n\nexport const setCorrectness = (answers, partialScoring) =>\n answers\n ? answers.map((answer) => ({\n ...answer,\n correctness: {\n value: partialScoring ? 'incorrect' : 'correct',\n label: partialScoring ? 'incorrect' : 'correct',\n },\n }))\n : [];\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\nexport const getScore = (question, session, env = {}) => {\n const { correctAnswer, data: initialData = [], scoringType } = question;\n let correctResponses = [];\n\n const isPartialScoring = partialScoring.enabled(\n { partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType },\n env,\n );\n\n const { data: correctAnswers = [] } = correctAnswer || {};\n const defaultAnswers = filterCategories(initialData);\n\n let answers = setCorrectness((session && session.answer) || defaultAnswers, isPartialScoring);\n\n let result = 0;\n\n if (isPartialScoring) {\n // if score type is \"partial scoring\"\n // maxScore is calculated based on the correct response\n // score is calculated based on the given response\n let maxScore = 0;\n let score = 0;\n\n const scoreForLabelAndValueEditable = (answer, corrAnswer) => {\n const { value, label, index } = answer;\n const valueIsCorrect = value === corrAnswer.value;\n const labelIsCorrect = checkLabelsEquality(label, corrAnswer.label);\n maxScore += 2;\n\n if (valueIsCorrect) {\n score += 1;\n answer.correctness.value = 'correct';\n }\n\n if (labelIsCorrect) {\n score += 1;\n answer.correctness.label = 'correct';\n }\n\n if (valueIsCorrect && labelIsCorrect) {\n correctResponses.push({ label: label, index: index });\n }\n };\n\n // if given answer has more categories than the correct answers, the \"extra\" will be ignored\n correctAnswers.forEach((corrAnswer, index) => {\n const defaultAnswer = defaultAnswers[index];\n const answer = answers[index];\n\n // if there is a corresponding category at the same position in the given answer\n if (answer) {\n // if there is a corresponding category at the same position in the default answer\n if (defaultAnswer) {\n // if category's label (in default answer) was not editable\n // it means that this category values only one point (only the value can be changed)\n if (!defaultAnswer.editable && answer.interactive) {\n maxScore += 1;\n\n if (answer.value === corrAnswer.value) {\n score += 1;\n answer.correctness.value = 'correct';\n correctResponses.push({ label: answer.label, index: index });\n }\n answer.correctness.label = 'correct';\n\n // if category's label (in default answer) was editable\n // it means that this category values 2 points (both label and value can be changed)\n } else if (defaultAnswer.editable && answer.interactive) {\n scoreForLabelAndValueEditable(answer, corrAnswer);\n } else if (!answer.interactive) {\n answer.correctness.value = 'correct';\n answer.correctness.label = 'correct';\n correctResponses.push({ label: answer.label, index: index });\n }\n } else {\n // if there is not a corresponding category at the same position in the default answer\n scoreForLabelAndValueEditable(answer, corrAnswer);\n }\n } else {\n // if there is not a corresponding category at the same position in the given answer\n // it means that the given answer has less categories than the correct answer\n maxScore += 2;\n }\n });\n\n result = maxScore ? score / maxScore : 0;\n } else {\n // all-or-nothing scoring: overall score is 1 only if lengths and all values/labels match\n result = correctAnswers.length === answers.length ? 1 : 0;\n\n // regardless of overall result, mark each answer individually for user feedback\n answers = answers.map((answer, index) => {\n const correctAnswer = correctAnswers[index];\n const valueIsCorrect = correctAnswer ? answer.value === correctAnswer.value : false;\n const labelIsCorrect = correctAnswer ? lowerCase(answer.label) === lowerCase(correctAnswer.label) : false;\n\n if (!valueIsCorrect || !labelIsCorrect) {\n result = 0;\n }\n\n if (valueIsCorrect && labelIsCorrect) {\n correctResponses.push({ label: answer.label, index });\n }\n\n return {\n ...answer,\n correctness: {\n value: valueIsCorrect ? 'correct' : 'incorrect',\n label: labelIsCorrect ? 'correct' : 'incorrect',\n },\n };\n });\n }\n\n const score = {\n score: parseFloat(result.toFixed(2)),\n answers,\n };\n\n if (env.extraProps && env.extraProps.correctResponseEnabled) {\n score.correctResponses = correctResponses;\n }\n\n return score;\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\n const { correctAnswer, data: initialData = [], scoringType } = model || {};\n const { data: correctAnswers = [] } = correctAnswer || {};\n const studentAnswers = (session && session.answer) || [];\n\n const isPartialScoring = partialScoring.enabled(\n { partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType },\n env\n );\n\n const defaultAnswers = filterCategories(initialData);\n const answers = studentAnswers.length > 0 ? filterCategories(studentAnswers) : defaultAnswers;\n\n if (!studentAnswers.length) {\n traceLog.push(`Student did not modify the chart. Initial chart is scored.`);\n }\n\n correctAnswers.forEach((correct, index) => {\n const initial = defaultAnswers[index];\n const student = answers[index];\n\n if (!student) {\n traceLog.push(`Category ${index + 1}: missing (expected value '${correct.value}', label '${correct.label}').`);\n return;\n }\n\n const valueCorrect = student.value === correct.value;\n const labelCorrect = checkLabelsEquality(student.label, correct.label);\n\n if (!student.interactive) {\n traceLog.push(`Category ${index + 1}: non-interactive category treated as correct.`);\n return;\n }\n\n if (studentAnswers.length > 0) {\n const valueChanged = initial ? student.value !== initial.value : true;\n const labelChanged = initial ? !checkLabelsEquality(student.label, initial.label) : true;\n\n if (!valueChanged && !labelChanged) {\n if (valueCorrect && labelCorrect) {\n traceLog.push(`Category ${index + 1}: unchanged from initial value and correct.`);\n } else {\n traceLog.push(`Category ${index + 1}: unchanged from initial value but incorrect.`);\n }\n return;\n }\n\n const parts = [];\n if (valueChanged) {\n parts.push(`value ${valueCorrect ? 'correct' : 'incorrect'}`);\n }\n if (labelChanged) {\n parts.push(`label ${labelCorrect ? 'correct' : 'incorrect'}`);\n }\n traceLog.push(`Category ${index + 1}: modified - ${parts.join(', ')}.`);\n } else {\n if (valueCorrect && labelCorrect) {\n traceLog.push(`Category ${index + 1}: initial values are correct.`);\n } else if (valueCorrect) {\n traceLog.push(`Category ${index + 1}: initial value correct, label incorrect.`);\n } else if (labelCorrect) {\n traceLog.push(`Category ${index + 1}: initial value incorrect, label correct.`);\n } else {\n traceLog.push(`Category ${index + 1}: initial value and label incorrect.`);\n }\n }\n });\n\n if (answers.length > correctAnswers.length) {\n const extra = answers.length - correctAnswers.length;\n traceLog.push(`${extra} extra category(ies) provided beyond expected number.`);\n }\n\n if (isPartialScoring) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push('Student receives credit for each correct value and label independently.');\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n traceLog.push('Student must match all category values and labels exactly for full credit.');\n }\n\n const scoreObject = getScore(model, session, env);\n traceLog.push(`Score: ${scoreObject.score}.`);\n\n return traceLog;\n};\n\n\n// eslint-disable-next-line no-unused-vars\nexport const filterCategories = (categories) => (categories ? categories.map(({ deletable, ...rest }) => rest) : []);\n\nexport function model(question, session, env) {\n return new Promise((resolve) => {\n const normalizedQuestion = normalize(question);\n const {\n addCategoryEnabled,\n chartType,\n data,\n domain,\n graph,\n prompt,\n promptEnabled,\n range,\n rationale,\n title,\n rationaleEnabled,\n teacherInstructions,\n teacherInstructionsEnabled,\n correctAnswer,\n scoringType,\n studentNewCategoryDefaultLabel,\n language,\n extraCSSRules,\n } = normalizedQuestion;\n\n const correctInfo = { correctness: 'incorrect', score: '0%' };\n\n const base = {\n addCategoryEnabled,\n chartType,\n data: filterCategories(data),\n domain,\n graph,\n prompt: promptEnabled ? prompt : null,\n range,\n rationale,\n title,\n size: graph,\n showToggle: false,\n correctness: correctInfo,\n disabled: env.mode !== 'gather',\n scoringType,\n studentNewCategoryDefaultLabel,\n language,\n env,\n extraCSSRules,\n };\n\n const scoreObject = getScore(normalizedQuestion, session, env);\n const answers = filterCategories(scoreObject.answers);\n\n if (env.mode === 'view') {\n // eslint-disable-next-line no-unused-vars\n base.correctedAnswer = answers.map(({ correctness, ...rest }) => {\n return { ...rest, interactive: false };\n });\n\n base.addCategoryEnabled = false;\n }\n\n if (env.mode === 'evaluate') {\n base.correctedAnswer = answers;\n base.correctAnswer = correctAnswer;\n base.showToggle = !!correctAnswer?.data?.length && scoreObject.score !== 1;\n base.addCategoryEnabled = false;\n base.showKeyLegend = true;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n base.rationale = rationaleEnabled ? rationale : null;\n base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n log('base: ', base);\n resolve(base);\n });\n}\n\nexport function outcome(model, session, env) {\n return new Promise((resolve) => {\n const traceLog = getLogTrace(model, session, env);\n const scoreObject = getScore(model, session, env);\n \n const result = {\n score: scoreObject.score,\n empty: !session || isEmpty(session),\n traceLog\n };\n \n if (env.extraProps && env.extraProps.correctResponseEnabled) {\n result.extraProps = { correctResponse: scoreObject.correctResponses };\n }\n \n resolve(result);\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { correctAnswer } = question;\n\n let answers = correctAnswer && correctAnswer.data;\n\n // for IBX preview mode\n if (env.mode === 'gather') {\n const { data } = question;\n\n answers = ((correctAnswer && correctAnswer.data) || []).map((answer, index) => {\n return {\n ...data[index],\n ...answer,\n };\n });\n }\n\n resolve({\n answer: answers,\n id: '1',\n });\n } else {\n return resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { correctAnswer, data } = model || {};\n const { data: correctData } = correctAnswer || {};\n const categories = correctData || [];\n\n const errors = {};\n const correctAnswerErrors = {};\n const categoryErrors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n categories.forEach((category, index) => {\n const { label } = category;\n\n if (!getInnerText(label)) {\n categoryErrors[index] = 'Content should not be empty. ';\n } else {\n const identicalAnswer = categories.some((c, i) => c.label === label && index !== i);\n\n if (identicalAnswer) {\n categoryErrors[index] = 'Category names should be unique. ';\n }\n }\n });\n\n if (categories.length < 1 || categories.length > 20) {\n correctAnswerErrors.categoriesError = 'The correct answer should include between 1 and 20 categories.';\n } else if (\n isEqual(\n data.map((category) => pick(category, 'value', 'label')),\n correctData.map((category) => pick(category, 'value', 'label')),\n )\n ) {\n correctAnswerErrors.identicalError = 'Correct answer should not be identical to the chart’s initial state';\n }\n\n if (!isEmpty(categoryErrors)) {\n errors.categoryErrors = categoryErrors;\n }\n\n if (!isEmpty(correctAnswerErrors)) {\n errors.correctAnswerErrors = correctAnswerErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;mCAQA,IAAe;CACb,oBAAoB;CACpB,0BAA0B;CAC1B,uBAAuB;CACvB,0BAA0B;CAC1B,WAAW;CACX,eAAe,CAAC;CAChB,MAAM,CAAC;CACP,QAAQ,CAAC;CACT,OAAO;EAAE,OAAO;EAAK,QAAQ;CAAI;CACjC,QAAQ;CACR,eAAe;CACf,OAAO;EAAE,OAAO;EAAI,KAAK;EAAG,KAAK;EAAG,WAAW;CAAE;CACjD,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,4BAA4B;CAC5B,gCAAgC;CAChC,qBAAqB;CACrB,4BAA4B;CAC5B,OAAO;AACT,GC5BI,IAAI,OAAO,gBA8CX,IAAoB,kBA9CY,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,EAuCwB,CAAE,EAAE,eAAe,EAAE,CAAC;AAC9C,SAAS,EAAE,GAA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,IAAQ,CAAC,GAAG,IAAS,CAAC,MAAM;CACnD,IAAM,EAAE,kBAAe,YAAS,KAAS,CAAC,GACpC,EAAE,MAAM,MAAgB,KAAiB,CAAC,GAC1C,IAAa,KAAe,CAAC,GAE7B,IAAS,CAAC,GACV,IAAsB,CAAC,GACvB,IAAiB,CAAC;CAyCxB,OAvCA;EAAC;EAAuB;EAAU;CAAW,CAAC,CAAC,SAAS,MAAU;EAChE,AAAI,EAAO,EAAM,EAAE,YAAY,CAAC,EAAW,EAAM,EAAM,MACrD,EAAO,KAAS;CAEpB,CAAC,GAED,EAAW,SAAS,GAAU,MAAU;EACtC,IAAM,EAAE,aAAU;EAElB,AAAK,EAAa,CAAK,IAGG,EAAW,MAAM,GAAG,MAAM,EAAE,UAAU,KAAS,MAAU,CAE7E,MACF,EAAe,KAAS,uCAL1B,EAAe,KAAS;CAQ5B,CAAC,GAEG,EAAW,SAAS,KAAK,EAAW,SAAS,KAC/C,EAAoB,kBAAkB,mEAEtC,EACE,EAAK,KAAK,MAAa,EAAK,GAAU,SAAS,OAAO,CAAC,GACvD,EAAY,KAAK,MAAa,EAAK,GAAU,SAAS,OAAO,CAAC,CAChE,MAEA,EAAoB,iBAAiB,wEAGlC,EAAQ,CAAc,MACzB,EAAO,iBAAiB,IAGrB,EAAQ,CAAmB,MAC9B,EAAO,sBAAsB,IAGxB;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/defaults.ts","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/index.ts"],"sourcesContent":["import type { ChartingCategory, ChartingCorrectAnswer, ChartingDomain, ChartingModel } from '../types.js';\n\n/**\n * NOTE: There's no functionality described for graphTitle,\n * rationale, scoringType, studentInstructions, teacherInstructions\n * so there's no implementation (they are only added in model)\n */\n\nexport default {\n addCategoryEnabled: true,\n changeAddCategoryEnabled: false,\n changeEditableEnabled: false,\n changeInteractiveEnabled: false,\n chartType: 'lineCross',\n correctAnswer: {} as ChartingCorrectAnswer,\n data: [] as ChartingCategory[],\n domain: {} as ChartingDomain,\n graph: { width: 480, height: 480 },\n prompt: '',\n promptEnabled: true,\n range: { label: '', max: 1, min: 0, labelStep: 1 },\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'all or nothing',\n studentInstructionsEnabled: true,\n studentNewCategoryDefaultLabel: 'New Category',\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n title: '',\n} satisfies Omit<ChartingModel, '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","import debug from 'debug';\nimport { isEmpty, isEqual, pick } from '@pie-element/shared-lodash';\nimport type { ExtraCSSRules, PieEnvironment } from '@pie-element/shared-types';\nimport defaults from './defaults.js';\n\nimport { partialScoring } from '@pie-element/shared-controller-utils';\nimport type {\n ChartingCategory,\n ChartingCategoryCorrectness,\n ChartingConfiguration,\n ChartingCorrectAnswer,\n ChartingModel,\n ChartingSession,\n} from '../types.js';\n\n/** The environment, plus the extra properties a host may ask the outcome for */\nexport type ChartingEnvironment = PieEnvironment & { extraProps?: { correctResponseEnabled?: boolean } };\n\n/** A category marked correct or incorrect */\nexport type ScoredCategory = ChartingCategory & { correctness: ChartingCategoryCorrectness };\n\n/** A category whose value and label both match the correct answer */\nexport type ChartingCorrectResponse = { label: string; index?: number };\n\nexport type ChartingScore = {\n score: number;\n answers: ScoredCategory[];\n correctResponses?: ChartingCorrectResponse[];\n};\n\nexport type ChartingValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n /** Category errors of the correct answer, keyed by category position */\n categoryErrors?: Record<number, string>;\n correctAnswerErrors?: {\n categoriesError?: string;\n identicalError?: string;\n };\n};\n\n/** What `model()` returns for the delivery view */\nexport type ChartingViewModel = {\n addCategoryEnabled?: boolean;\n chartType?: ChartingModel['chartType'];\n data: Omit<ChartingCategory, 'deletable'>[];\n domain?: ChartingModel['domain'];\n graph?: ChartingModel['graph'];\n prompt?: string | null;\n range?: ChartingModel['range'];\n rationale?: string | null;\n title?: string;\n size?: ChartingModel['graph'];\n showToggle: boolean;\n correctness: { correctness: string; score: string };\n disabled: boolean;\n scoringType?: ChartingModel['scoringType'];\n studentNewCategoryDefaultLabel?: string;\n language?: string;\n env: ChartingEnvironment;\n extraCSSRules?: ExtraCSSRules;\n correctedAnswer?: Omit<ChartingCategory, 'deletable'>[];\n correctAnswer?: ChartingCorrectAnswer;\n showKeyLegend?: boolean;\n teacherInstructions?: string | null;\n};\n\ntype ChartingOutcome = {\n score: number;\n empty: boolean;\n traceLog: string[];\n extraProps?: { correctResponse?: ChartingCorrectResponse[] };\n};\n\nconst log = debug('@pie-element:graphing:controller');\n\nconst lowerCase = (string?: string) => (string || '').toLowerCase();\n\nexport const checkLabelsEquality = (givenAnswerLabel?: string, correctAnswerLabel?: string) =>\n lowerCase(givenAnswerLabel) === lowerCase(correctAnswerLabel);\n\nexport const setCorrectness = (answers: ChartingCategory[] | undefined, partialScoring: boolean): ScoredCategory[] =>\n answers\n ? answers.map((answer) => ({\n ...answer,\n correctness: {\n value: partialScoring ? 'incorrect' : 'correct',\n label: partialScoring ? 'incorrect' : 'correct',\n },\n }))\n : [];\n\nexport const normalize = (question: ChartingModel) => ({ ...defaults, ...question });\n\nexport const getScore = (\n question: ChartingModel,\n session: ChartingSession | null | undefined,\n env: Partial<ChartingEnvironment> = {},\n): ChartingScore => {\n const { correctAnswer, data: initialData = [], scoringType } = question;\n const correctResponses: ChartingCorrectResponse[] = [];\n\n const isPartialScoring = partialScoring.enabled(\n { partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType },\n env,\n );\n\n const { data: correctAnswers = [] } = correctAnswer || {};\n const defaultAnswers = filterCategories(initialData);\n\n let answers = setCorrectness((session && session.answer) || defaultAnswers, isPartialScoring);\n\n let result = 0;\n\n if (isPartialScoring) {\n // if score type is \"partial scoring\"\n // maxScore is calculated based on the correct response\n // score is calculated based on the given response\n let maxScore = 0;\n let score = 0;\n\n const scoreForLabelAndValueEditable = (answer: ScoredCategory, corrAnswer: ChartingCategory) => {\n const { value, label, index } = answer;\n const valueIsCorrect = value === corrAnswer.value;\n const labelIsCorrect = checkLabelsEquality(label, corrAnswer.label);\n maxScore += 2;\n\n if (valueIsCorrect) {\n score += 1;\n answer.correctness.value = 'correct';\n }\n\n if (labelIsCorrect) {\n score += 1;\n answer.correctness.label = 'correct';\n }\n\n if (valueIsCorrect && labelIsCorrect) {\n correctResponses.push({ label: label, index: index });\n }\n };\n\n // if given answer has more categories than the correct answers, the \"extra\" will be ignored\n correctAnswers.forEach((corrAnswer, index) => {\n const defaultAnswer = defaultAnswers[index];\n const answer = answers[index];\n\n // if there is a corresponding category at the same position in the given answer\n if (answer) {\n // if there is a corresponding category at the same position in the default answer\n if (defaultAnswer) {\n // if category's label (in default answer) was not editable\n // it means that this category values only one point (only the value can be changed)\n if (!defaultAnswer.editable && answer.interactive) {\n maxScore += 1;\n\n if (answer.value === corrAnswer.value) {\n score += 1;\n answer.correctness.value = 'correct';\n correctResponses.push({ label: answer.label, index: index });\n }\n answer.correctness.label = 'correct';\n\n // if category's label (in default answer) was editable\n // it means that this category values 2 points (both label and value can be changed)\n } else if (defaultAnswer.editable && answer.interactive) {\n scoreForLabelAndValueEditable(answer, corrAnswer);\n } else if (!answer.interactive) {\n answer.correctness.value = 'correct';\n answer.correctness.label = 'correct';\n correctResponses.push({ label: answer.label, index: index });\n }\n } else {\n // if there is not a corresponding category at the same position in the default answer\n scoreForLabelAndValueEditable(answer, corrAnswer);\n }\n } else {\n // if there is not a corresponding category at the same position in the given answer\n // it means that the given answer has less categories than the correct answer\n maxScore += 2;\n }\n });\n\n result = maxScore ? score / maxScore : 0;\n } else {\n // all-or-nothing scoring: overall score is 1 only if lengths and all values/labels match\n result = correctAnswers.length === answers.length ? 1 : 0;\n\n // regardless of overall result, mark each answer individually for user feedback\n answers = answers.map((answer, index): ScoredCategory => {\n const correctAnswer = correctAnswers[index];\n const valueIsCorrect = correctAnswer ? answer.value === correctAnswer.value : false;\n const labelIsCorrect = correctAnswer ? lowerCase(answer.label) === lowerCase(correctAnswer.label) : false;\n\n if (!valueIsCorrect || !labelIsCorrect) {\n result = 0;\n }\n\n if (valueIsCorrect && labelIsCorrect) {\n correctResponses.push({ label: answer.label, index });\n }\n\n return {\n ...answer,\n correctness: {\n value: valueIsCorrect ? 'correct' : 'incorrect',\n label: labelIsCorrect ? 'correct' : 'incorrect',\n },\n };\n });\n }\n\n const score: ChartingScore = {\n score: parseFloat(result.toFixed(2)),\n answers,\n };\n\n if (env.extraProps && env.extraProps.correctResponseEnabled) {\n score.correctResponses = correctResponses;\n }\n\n return score;\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: ChartingModel,\n session: ChartingSession | null | undefined,\n env: ChartingEnvironment,\n): string[] => {\n const traceLog: string[] = [];\n\n const { correctAnswer, data: initialData = [], scoringType } = model || {};\n const { data: correctAnswers = [] } = correctAnswer || {};\n const studentAnswers = (session && session.answer) || [];\n\n const isPartialScoring = partialScoring.enabled(\n { partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType },\n env\n );\n\n const defaultAnswers = filterCategories(initialData);\n const answers = studentAnswers.length > 0 ? filterCategories(studentAnswers) : defaultAnswers;\n\n if (!studentAnswers.length) {\n traceLog.push(`Student did not modify the chart. Initial chart is scored.`);\n }\n\n correctAnswers.forEach((correct, index) => {\n const initial = defaultAnswers[index];\n const student = answers[index];\n\n if (!student) {\n traceLog.push(`Category ${index + 1}: missing (expected value '${correct.value}', label '${correct.label}').`);\n return;\n }\n\n const valueCorrect = student.value === correct.value;\n const labelCorrect = checkLabelsEquality(student.label, correct.label);\n\n if (!student.interactive) {\n traceLog.push(`Category ${index + 1}: non-interactive category treated as correct.`);\n return;\n }\n\n if (studentAnswers.length > 0) {\n const valueChanged = initial ? student.value !== initial.value : true;\n const labelChanged = initial ? !checkLabelsEquality(student.label, initial.label) : true;\n\n if (!valueChanged && !labelChanged) {\n if (valueCorrect && labelCorrect) {\n traceLog.push(`Category ${index + 1}: unchanged from initial value and correct.`);\n } else {\n traceLog.push(`Category ${index + 1}: unchanged from initial value but incorrect.`);\n }\n return;\n }\n\n const parts: string[] = [];\n if (valueChanged) {\n parts.push(`value ${valueCorrect ? 'correct' : 'incorrect'}`);\n }\n if (labelChanged) {\n parts.push(`label ${labelCorrect ? 'correct' : 'incorrect'}`);\n }\n traceLog.push(`Category ${index + 1}: modified - ${parts.join(', ')}.`);\n } else {\n if (valueCorrect && labelCorrect) {\n traceLog.push(`Category ${index + 1}: initial values are correct.`);\n } else if (valueCorrect) {\n traceLog.push(`Category ${index + 1}: initial value correct, label incorrect.`);\n } else if (labelCorrect) {\n traceLog.push(`Category ${index + 1}: initial value incorrect, label correct.`);\n } else {\n traceLog.push(`Category ${index + 1}: initial value and label incorrect.`);\n }\n }\n });\n\n if (answers.length > correctAnswers.length) {\n const extra = answers.length - correctAnswers.length;\n traceLog.push(`${extra} extra category(ies) provided beyond expected number.`);\n }\n\n if (isPartialScoring) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push('Student receives credit for each correct value and label independently.');\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n traceLog.push('Student must match all category values and labels exactly for full credit.');\n }\n\n const scoreObject = getScore(model, session, env);\n traceLog.push(`Score: ${scoreObject.score}.`);\n\n return traceLog;\n};\n\n\n// eslint-disable-next-line no-unused-vars\nexport const filterCategories = <T extends ChartingCategory>(categories?: T[]): Omit<T, 'deletable'>[] =>\n categories ? categories.map(({ deletable, ...rest }) => rest) : [];\n\nexport function model(\n question: ChartingModel,\n session: ChartingSession | null | undefined,\n env: ChartingEnvironment,\n): Promise<ChartingViewModel> {\n return new Promise((resolve) => {\n const normalizedQuestion = normalize(question);\n const {\n addCategoryEnabled,\n chartType,\n data,\n domain,\n graph,\n prompt,\n promptEnabled,\n range,\n rationale,\n title,\n rationaleEnabled,\n teacherInstructions,\n teacherInstructionsEnabled,\n correctAnswer,\n scoringType,\n studentNewCategoryDefaultLabel,\n language,\n extraCSSRules,\n } = normalizedQuestion;\n\n const correctInfo = { correctness: 'incorrect', score: '0%' };\n\n const base: ChartingViewModel = {\n addCategoryEnabled,\n chartType,\n data: filterCategories(data),\n domain,\n graph,\n prompt: promptEnabled ? prompt : null,\n range,\n rationale,\n title,\n size: graph,\n showToggle: false,\n correctness: correctInfo,\n disabled: env.mode !== 'gather',\n scoringType,\n studentNewCategoryDefaultLabel,\n language,\n env,\n extraCSSRules,\n };\n\n const scoreObject = getScore(normalizedQuestion, session, env);\n const answers = filterCategories(scoreObject.answers);\n\n if (env.mode === 'view') {\n // eslint-disable-next-line no-unused-vars\n base.correctedAnswer = answers.map(({ correctness, ...rest }) => {\n return { ...rest, interactive: false };\n });\n\n base.addCategoryEnabled = false;\n }\n\n if (env.mode === 'evaluate') {\n base.correctedAnswer = answers;\n base.correctAnswer = correctAnswer;\n base.showToggle = !!correctAnswer?.data?.length && scoreObject.score !== 1;\n base.addCategoryEnabled = false;\n base.showKeyLegend = true;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n base.rationale = rationaleEnabled ? rationale : null;\n base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n log('base: ', base);\n resolve(base);\n });\n}\n\nexport function outcome(\n model: ChartingModel,\n session: ChartingSession | null | undefined,\n env: ChartingEnvironment,\n): Promise<ChartingOutcome> {\n return new Promise((resolve) => {\n const traceLog = getLogTrace(model, session, env);\n const scoreObject = getScore(model, session, env);\n \n const result: ChartingOutcome = {\n score: scoreObject.score,\n empty: !session || isEmpty(session),\n traceLog\n };\n \n if (env.extraProps && env.extraProps.correctResponseEnabled) {\n result.extraProps = { correctResponse: scoreObject.correctResponses };\n }\n \n resolve(result);\n });\n}\n\nexport const createCorrectResponseSession = (\n question: ChartingModel,\n env: ChartingEnvironment,\n): Promise<ChartingSession | null> => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { correctAnswer } = question;\n\n let answers = correctAnswer && correctAnswer.data;\n\n // for IBX preview mode\n if (env.mode === 'gather') {\n const { data } = question;\n\n answers = ((correctAnswer && correctAnswer.data) || []).map((answer, index) => {\n // Throws when the model has no `data`, as it did untyped.\n return {\n ...(data as ChartingCategory[])[index],\n ...answer,\n };\n });\n }\n\n resolve({\n answer: answers,\n id: '1',\n });\n } else {\n return resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html?: string) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html?: string) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (\n model: Partial<ChartingModel> = {},\n config: ChartingConfiguration = {},\n): ChartingValidationErrors => {\n const { correctAnswer, data } = model || {};\n const { data: correctData } = correctAnswer || {};\n const categories = correctData || [];\n\n const errors: ChartingValidationErrors = {};\n const correctAnswerErrors: NonNullable<ChartingValidationErrors['correctAnswerErrors']> = {};\n const categoryErrors: Record<number, string> = {};\n\n (['teacherInstructions', 'prompt', 'rationale'] as const).forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n categories.forEach((category, index) => {\n const { label } = category;\n\n if (!getInnerText(label)) {\n categoryErrors[index] = 'Content should not be empty. ';\n } else {\n const identicalAnswer = categories.some((c, i) => c.label === label && index !== i);\n\n if (identicalAnswer) {\n categoryErrors[index] = 'Category names should be unique. ';\n }\n }\n });\n\n if (categories.length < 1 || categories.length > 20) {\n correctAnswerErrors.categoriesError = 'The correct answer should include between 1 and 20 categories.';\n } else if (\n isEqual(\n // `data.map` throws when the model has no `data`, as it did untyped.\n (data as ChartingCategory[]).map((category) => pick(category, 'value', 'label')),\n (correctData as ChartingCategory[]).map((category) => pick(category, 'value', 'label')),\n )\n ) {\n correctAnswerErrors.identicalError = 'Correct answer should not be identical to the chart’s initial state';\n }\n\n if (!isEmpty(categoryErrors)) {\n errors.categoryErrors = categoryErrors;\n }\n\n if (!isEmpty(correctAnswerErrors)) {\n errors.correctAnswerErrors = correctAnswerErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;mCAQA,IAAe;CACb,oBAAoB;CACpB,0BAA0B;CAC1B,uBAAuB;CACvB,0BAA0B;CAC1B,WAAW;CACX,eAAe,CAAC;CAChB,MAAM,CAAC;CACP,QAAQ,CAAC;CACT,OAAO;EAAE,OAAO;EAAK,QAAQ;CAAI;CACjC,QAAQ;CACR,eAAe;CACf,OAAO;EAAE,OAAO;EAAI,KAAK;EAAG,KAAK;EAAG,WAAW;CAAE;CACjD,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,4BAA4B;CAC5B,gCAAgC;CAChC,qBAAqB;CACrB,4BAA4B;CAC5B,OAAO;AACT,GC5BI,IAAI,OAAO,gBA8CX,IAAoB,kBA9CY,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,EAuCwB,CAAE,EAAE,eAAe,EAAE,CAAC;AAC9C,SAAS,EAAE,GAAG,GAAG,GAAG;CACnB,OAAO,GAAG,mBAAmB,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,OAAO,KAAK,aAAa;AAC7F;;;ACyBA,IAAM,KAAA,GAAA,EAAA,QAAA,CAAY,kCAAkC,GAE9C,KAAa,OAAqB,KAAU,GAAA,CAAI,YAAY,GAErD,KAAuB,GAA2B,MAC7D,EAAU,CAAgB,MAAM,EAAU,CAAkB,GAEjD,KAAkB,GAAyC,MACtE,IACI,EAAQ,KAAK,OAAY;CACvB,GAAG;CACH,aAAa;EACX,OAAO,IAAiB,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,EAAW,SAAS,GAAU,MAAU;EACtC,IAAM,EAAE,aAAU;EAElB,AAAK,EAAa,CAAK,IAGG,EAAW,MAAM,GAAG,MAAM,EAAE,UAAU,KAAS,MAAU,CAE7E,MACF,EAAe,KAAS,uCAL1B,EAAe,KAAS;CAQ5B,CAAC,GAEG,EAAW,SAAS,KAAK,EAAW,SAAS,KAC/C,EAAoB,kBAAkB,mEAEtC,EAEG,EAA4B,KAAK,MAAa,EAAK,GAAU,SAAS,OAAO,CAAC,GAC9E,EAAmC,KAAK,MAAa,EAAK,GAAU,SAAS,OAAO,CAAC,CACxF,MAEA,EAAoB,iBAAiB,wEAGlC,EAAQ,CAAc,MACzB,EAAO,iBAAiB,IAGrB,EAAQ,CAAmB,MAC9B,EAAO,sBAAsB,IAGxB;AACT"}
|
|
@@ -1911,15 +1911,12 @@ var Xn = class extends K.Component {
|
|
|
1911
1911
|
}), er = (e) => typeof e == "string" ? {
|
|
1912
1912
|
label: e,
|
|
1913
1913
|
value: e
|
|
1914
|
-
} : e, tr =
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
isConfigProperty: n
|
|
1921
|
-
};
|
|
1922
|
-
}, nr = (e, t, n = !1) => ({
|
|
1914
|
+
} : e, tr = (e, t, n = !1) => ({
|
|
1915
|
+
type: "radio",
|
|
1916
|
+
label: e,
|
|
1917
|
+
choices: t && t.map((e) => er(e)),
|
|
1918
|
+
isConfigProperty: n
|
|
1919
|
+
}), nr = (e, t, n = !1) => ({
|
|
1923
1920
|
type: "dropdown",
|
|
1924
1921
|
label: e,
|
|
1925
1922
|
choices: t,
|
|
@@ -2770,15 +2767,6 @@ var Dr = class e extends CustomEvent {
|
|
|
2770
2767
|
E.DotPlot(),
|
|
2771
2768
|
E.LinePlot()
|
|
2772
2769
|
], ui = class extends K.Component {
|
|
2773
|
-
static propTypes = {
|
|
2774
|
-
onModelChanged: Z.default.func,
|
|
2775
|
-
onConfigurationChanged: Z.default.func,
|
|
2776
|
-
imageSupport: Z.default.object,
|
|
2777
|
-
uploadSoundSupport: Z.default.object,
|
|
2778
|
-
model: Z.default.object.isRequired,
|
|
2779
|
-
configuration: Z.default.object.isRequired,
|
|
2780
|
-
chartingOptions: Z.default.object
|
|
2781
|
-
};
|
|
2782
2770
|
constructor(e) {
|
|
2783
2771
|
super(e);
|
|
2784
2772
|
let { range: t = {}, graph: n } = e.model || {}, r = { range: Qr(t, n.height, !0) }, i = { range: $r(t.step || 1) };
|
|
@@ -2807,10 +2795,10 @@ var Dr = class e extends CustomEvent {
|
|
|
2807
2795
|
let { model: t, onModelChanged: n } = this.props, { gridValues: r, labelValues: i } = this.state, a = {
|
|
2808
2796
|
...t,
|
|
2809
2797
|
...e
|
|
2810
|
-
}, { graph: o, range: s } = a, c =
|
|
2811
|
-
|
|
2812
|
-
gridValues:
|
|
2813
|
-
labelValues:
|
|
2798
|
+
}, { graph: o, range: s } = a, c = ei(s, o.height, r.range, i.range), l = { range: c.gridValues }, u = { range: c.labelValues };
|
|
2799
|
+
this.setState({
|
|
2800
|
+
gridValues: l,
|
|
2801
|
+
labelValues: u
|
|
2814
2802
|
}), n(a);
|
|
2815
2803
|
};
|
|
2816
2804
|
render() {
|
|
@@ -2896,7 +2884,6 @@ var Dr = class e extends CustomEvent {
|
|
|
2896
2884
|
gridValues: V,
|
|
2897
2885
|
labelValues: re,
|
|
2898
2886
|
chartDimensions: l,
|
|
2899
|
-
charts: li,
|
|
2900
2887
|
studentNewCategoryDefaultLabel: I,
|
|
2901
2888
|
availableChartTypes: T,
|
|
2902
2889
|
chartTypeLabel: D
|
|
@@ -3126,6 +3113,9 @@ var Dr = class e extends CustomEvent {
|
|
|
3126
3113
|
}
|
|
3127
3114
|
}
|
|
3128
3115
|
}, fi = (0, Je.default)("pie-elements:graphing:configure"), pi = class e extends HTMLElement {
|
|
3116
|
+
_root;
|
|
3117
|
+
_model;
|
|
3118
|
+
_configuration;
|
|
3129
3119
|
static createDefaultModel = (e = {}) => ({
|
|
3130
3120
|
...di.model,
|
|
3131
3121
|
...e
|
|
@@ -3141,10 +3131,15 @@ var Dr = class e extends CustomEvent {
|
|
|
3141
3131
|
...di.configuration,
|
|
3142
3132
|
...e
|
|
3143
3133
|
};
|
|
3144
|
-
this._configuration = t, t?.language?.enabled
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3134
|
+
if (this._configuration = t, t?.language?.enabled) t?.languageChoices?.options?.length && (this._model.language = t?.languageChoices.options[0].value);
|
|
3135
|
+
else if (t.language.settings && this._model.language) {
|
|
3136
|
+
let e = this._model.language, n = t.languageChoices;
|
|
3137
|
+
t.language.enabled = !0, (!n.options || !n.options.length) && (n.options = []), n.options.find((t) => t.value === e) || n.options.push({
|
|
3138
|
+
value: e,
|
|
3139
|
+
label: e
|
|
3140
|
+
});
|
|
3141
|
+
} else delete this._model.language;
|
|
3142
|
+
this._render();
|
|
3148
3143
|
}
|
|
3149
3144
|
onModelChanged(e) {
|
|
3150
3145
|
this._model = e, this._render(), fi("[onModelChanged]: ", this._model), this.dispatchEvent(new Dr(this._model));
|