@pie-element/charting 12.1.2-next.1 → 12.1.2-next.11
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.js +4 -4
- package/dist/author/configure.js +3 -3
- package/dist/author/correct-response.js +4 -4
- package/dist/author/index.d.ts +1 -0
- package/dist/author/index.js +5 -2
- package/dist/author/utils.js +1 -1
- package/dist/browser/author/index.js +2245 -301
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/{chart-AvFvbpGV.js → chart-CqKCTwCe.js} +29051 -27671
- package/dist/browser/chart-CqKCTwCe.js.map +1 -0
- package/dist/browser/controller/index.js +3 -3
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/delivery/index.js +104 -86
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/browser/{dist-CA-Ok7CW.js → dist-D6aoYeoC.js} +6 -2
- package/dist/browser/{dist-CA-Ok7CW.js.map → dist-D6aoYeoC.js.map} +1 -1
- package/dist/controller/index.js +1 -1
- package/dist/delivery/index.d.ts +3 -0
- package/dist/delivery/index.js +25 -7
- package/dist/delivery/main.js +1 -1
- package/dist/index.iife.js +111 -107
- package/package.json +17 -18
- package/dist/browser/chart-AvFvbpGV.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as e, o as t, s as n, t as r, v as i } from "../dist-
|
|
1
|
+
import { S as e, o as t, s as n, t as r, v as i } from "../dist-D6aoYeoC.js";
|
|
2
2
|
//#region src/controller/defaults.ts
|
|
3
3
|
var a = /* @__PURE__ */ e(i(), 1), o = {
|
|
4
4
|
addCategoryEnabled: !0,
|
|
@@ -38,7 +38,7 @@ var a = /* @__PURE__ */ e(i(), 1), o = {
|
|
|
38
38
|
return t || s(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
39
39
|
})({ enabled: () => l });
|
|
40
40
|
function l(e, t, n) {
|
|
41
|
-
return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n
|
|
41
|
+
return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n != "boolean" || n;
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/controller/index.ts
|
|
@@ -103,7 +103,7 @@ var u = (0, a.default)("@pie-element:graphing:controller"), d = (e) => (e || "")
|
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
if (l.length > 0) {
|
|
106
|
-
let e = n
|
|
106
|
+
let e = !n || i.value !== n.value, s = !n || !f(i.label, n.label);
|
|
107
107
|
if (!e && !s) {
|
|
108
108
|
a && o ? r.push(`Category ${t + 1}: unchanged from initial value and correct.`) : r.push(`Category ${t + 1}: unchanged from initial value but incorrect.`);
|
|
109
109
|
return;
|
|
@@ -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 * @synced-from pie-elements/packages/charting/controller/src/defaults.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\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 : !1;\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}`) : t.id && t.element && 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.role ?? \"student\") === \"instructor\");\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 : !0;\n}\n//#endregion\nexport { a as getShuffledChoices, o as lockChoices, s as partialScoring };\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/charting/controller/src/index.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\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":";;mCAgBA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,GCpCI,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,GAuC0B,EAAE,eAAe,EAAE,CAAC;AAC9C,SAAS,EAAE,GAAG,GAAG,GAAG;CACnB,OAAO,GAAG,mBAAmB,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,OAAO,KAAK,YAAY,IAAI,CAAC;AACjG;;;AClCA,IAAM,KAAA,GAAA,EAAA,SAAY,kCAAkC,GAE9C,KAAa,OAAY,KAAU,IAAI,YAA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A;EAAC;EAAuB;EAAU;CAAW,EAAE,SAAS,MAAU;EAChE,AAAI,EAAO,IAAQ,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":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/charting/controller/src/defaults.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\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}`) : t.id && t.element && 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.role ?? \"student\") === \"instructor\");\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 * @synced-from pie-elements/packages/charting/controller/src/index.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\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":";;mCAgBA,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,GCpCI,IAAI,OAAO,gBA8CX,IAAoB,kBA9CY,GAAG,MAAM;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+
import { B as n, M as r, Q as i, S as a, U as o, V as s, b as c, g as l, j as u, k as d, n as f, o as p, s as m, t as h, v as g, x as _, y as v } from "../chart-CqKCTwCe.js";
|
|
3
3
|
import y, { useRef as b } from "react";
|
|
4
4
|
import { createRoot as x } from "react-dom/client";
|
|
5
5
|
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
6
6
|
//#region ../../lib-react/icons/dist/correct-response-icon.js
|
|
7
|
-
var w = /* @__PURE__ */ e(
|
|
7
|
+
var w = /* @__PURE__ */ e(i(), 1), T = ({ bgFill: e, fgFill: t }) => /* @__PURE__ */ C("svg", {
|
|
8
8
|
preserveAspectRatio: "xMinYMin meet",
|
|
9
9
|
version: "1.1",
|
|
10
10
|
viewBox: "-283 359 34 35",
|
|
@@ -75,7 +75,7 @@ E.propTypes = {
|
|
|
75
75
|
fgFill: w.default.string.isRequired,
|
|
76
76
|
borderFill: w.default.string.isRequired
|
|
77
77
|
};
|
|
78
|
-
var D =
|
|
78
|
+
var D = o("div")(({ size: e }) => ({
|
|
79
79
|
width: e || "25px",
|
|
80
80
|
height: e || "25px"
|
|
81
81
|
})), O = ({ open: e, size: t }) => /* @__PURE__ */ S(D, {
|
|
@@ -95,44 +95,44 @@ O.propTypes = {
|
|
|
95
95
|
}, O.defaultProps = { open: !1 };
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region ../../lib-react/charting/dist/key-legend.js
|
|
98
|
-
var ee =
|
|
99
|
-
backgroundColor:
|
|
98
|
+
var ee = o("div")(({ theme: e }) => ({
|
|
99
|
+
backgroundColor: s.defaults.WHITE,
|
|
100
100
|
padding: e.spacing(2),
|
|
101
101
|
width: "355px",
|
|
102
102
|
boxShadow: "inset 0px 1px 5px 0px #9297A6",
|
|
103
103
|
display: "flex",
|
|
104
104
|
flexDirection: "column",
|
|
105
105
|
gap: "16px"
|
|
106
|
-
})), k =
|
|
106
|
+
})), k = o("div")(() => ({
|
|
107
107
|
display: "flex",
|
|
108
108
|
alignItems: "center",
|
|
109
109
|
gap: "12px"
|
|
110
|
-
})),
|
|
110
|
+
})), A = o("div")(({ theme: e }) => ({
|
|
111
111
|
fontSize: e.typography.h6.fontSize,
|
|
112
112
|
fontWeight: "700"
|
|
113
|
-
})),
|
|
114
|
-
backgroundColor:
|
|
113
|
+
})), te = o("div")(() => ({ marginLeft: "2px" })), j = o(l)(({ theme: e }) => ({
|
|
114
|
+
backgroundColor: s.correct(),
|
|
115
115
|
borderRadius: e.spacing(2),
|
|
116
|
-
color:
|
|
117
|
-
})),
|
|
118
|
-
backgroundColor:
|
|
116
|
+
color: s.defaults.WHITE
|
|
117
|
+
})), M = o(m)(({ theme: e }) => ({
|
|
118
|
+
backgroundColor: s.incorrectWithIcon(),
|
|
119
119
|
borderRadius: e.spacing(2),
|
|
120
|
-
color:
|
|
121
|
-
})),
|
|
120
|
+
color: s.defaults.WHITE
|
|
121
|
+
})), ne = o("div")(() => ({
|
|
122
122
|
marginLeft: "3px",
|
|
123
123
|
display: "flex",
|
|
124
124
|
alignItems: "center",
|
|
125
125
|
gap: "12px"
|
|
126
|
-
})), { translator:
|
|
127
|
-
/* @__PURE__ */ S(
|
|
128
|
-
/* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(
|
|
129
|
-
/* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(
|
|
130
|
-
/* @__PURE__ */ C(
|
|
126
|
+
})), { translator: N } = f, P = ({ language: e }) => /* @__PURE__ */ C(ee, { children: [
|
|
127
|
+
/* @__PURE__ */ S(A, { children: "Key" }),
|
|
128
|
+
/* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(M, {}), /* @__PURE__ */ S("div", { children: N.t("charting.keyLegend.incorrectAnswer", { lng: e }) })] }),
|
|
129
|
+
/* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(j, {}), /* @__PURE__ */ S("div", { children: N.t("charting.keyLegend.correctAnswer", { lng: e }) })] }),
|
|
130
|
+
/* @__PURE__ */ C(ne, { children: [/* @__PURE__ */ S(j, { fontSize: "small" }), /* @__PURE__ */ S(te, { children: N.t("charting.keyLegend.correctKeyAnswer", { lng: e }) })] })
|
|
131
131
|
] });
|
|
132
|
-
|
|
132
|
+
P.propTypes = { language: w.default.string };
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region ../../lib-react/correct-answer-toggle/dist/expander.js
|
|
135
|
-
var
|
|
135
|
+
var F = "height ease-in 300ms, opacity ease-in 300ms", re = o("div")(() => ({
|
|
136
136
|
position: "relative",
|
|
137
137
|
height: 0,
|
|
138
138
|
overflow: "hidden",
|
|
@@ -140,7 +140,7 @@ var N = "height ease-in 300ms, opacity ease-in 300ms", ae = a("div")(() => ({
|
|
|
140
140
|
visibility: "hidden",
|
|
141
141
|
width: 0,
|
|
142
142
|
"&.enter": {
|
|
143
|
-
transition:
|
|
143
|
+
transition: F,
|
|
144
144
|
opacity: 1,
|
|
145
145
|
height: "auto",
|
|
146
146
|
width: "auto",
|
|
@@ -154,7 +154,7 @@ var N = "height ease-in 300ms, opacity ease-in 300ms", ae = a("div")(() => ({
|
|
|
154
154
|
minHeight: "25px"
|
|
155
155
|
},
|
|
156
156
|
"&.exit": {
|
|
157
|
-
transition:
|
|
157
|
+
transition: F,
|
|
158
158
|
opacity: 0,
|
|
159
159
|
height: 0,
|
|
160
160
|
visibility: "visible",
|
|
@@ -166,9 +166,9 @@ var N = "height ease-in 300ms, opacity ease-in 300ms", ae = a("div")(() => ({
|
|
|
166
166
|
height: 0,
|
|
167
167
|
width: 0
|
|
168
168
|
}
|
|
169
|
-
})),
|
|
170
|
-
let { show: t, children:
|
|
171
|
-
return /* @__PURE__ */ S(
|
|
169
|
+
})), I = (e) => {
|
|
170
|
+
let { show: t, children: r, className: i } = e, a = b(null);
|
|
171
|
+
return /* @__PURE__ */ S(n, {
|
|
172
172
|
nodeRef: a,
|
|
173
173
|
in: t,
|
|
174
174
|
appear: !0,
|
|
@@ -180,49 +180,49 @@ var N = "height ease-in 300ms, opacity ease-in 300ms", ae = a("div")(() => ({
|
|
|
180
180
|
exit: "exit",
|
|
181
181
|
exitDone: "exit-done"
|
|
182
182
|
},
|
|
183
|
-
children: /* @__PURE__ */ S(
|
|
183
|
+
children: /* @__PURE__ */ S(re, {
|
|
184
184
|
ref: a,
|
|
185
|
-
className:
|
|
186
|
-
children:
|
|
185
|
+
className: i,
|
|
186
|
+
children: r
|
|
187
187
|
})
|
|
188
188
|
});
|
|
189
189
|
};
|
|
190
|
-
|
|
190
|
+
I.propTypes = {
|
|
191
191
|
show: w.default.bool.isRequired,
|
|
192
192
|
className: w.default.string,
|
|
193
193
|
children: w.default.oneOfType([w.default.arrayOf(w.default.node), w.default.node]).isRequired
|
|
194
194
|
};
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region ../../lib-react/correct-answer-toggle/dist/index.js
|
|
197
|
-
function
|
|
197
|
+
function L(e) {
|
|
198
198
|
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
return !e ||
|
|
200
|
+
function R(e, t) {
|
|
201
|
+
return !e || L(e) ? e : L(e.default) ? e.default : t && L(e[t]) ? e[t] : t && L(e[t]?.default) ? e[t].default : e;
|
|
202
202
|
}
|
|
203
|
-
var
|
|
203
|
+
var ie = R(_, "Readable") || R(ae.Readable, "Readable"), z = g, B = z.default, ae = B && typeof B == "object" ? B : z, { translator: V } = f, oe = {
|
|
204
204
|
WebkitTouchCallout: "none",
|
|
205
205
|
WebkitUserSelect: "none",
|
|
206
206
|
KhtmlUserSelect: "none",
|
|
207
207
|
MozUserSelect: "none",
|
|
208
208
|
msUserSelect: "none",
|
|
209
209
|
userSelect: "none"
|
|
210
|
-
}, se =
|
|
210
|
+
}, se = o("div")(() => ({
|
|
211
211
|
width: "100%",
|
|
212
212
|
cursor: "pointer"
|
|
213
|
-
})), ce =
|
|
213
|
+
})), ce = o("div")(() => ({
|
|
214
214
|
margin: "0 auto",
|
|
215
215
|
textAlign: "center",
|
|
216
216
|
display: "flex"
|
|
217
|
-
})), le =
|
|
217
|
+
})), le = o("div")(() => ({
|
|
218
218
|
width: "fit-content",
|
|
219
219
|
minWidth: "140px",
|
|
220
220
|
alignSelf: "center",
|
|
221
221
|
verticalAlign: "middle",
|
|
222
|
-
color: `var(--correct-answer-toggle-label-color, ${
|
|
222
|
+
color: `var(--correct-answer-toggle-label-color, ${s.text()})`,
|
|
223
223
|
fontWeight: "normal",
|
|
224
|
-
...
|
|
225
|
-
})), H =
|
|
224
|
+
...oe
|
|
225
|
+
})), H = o("div")(() => ({
|
|
226
226
|
position: "absolute",
|
|
227
227
|
width: "25px",
|
|
228
228
|
"&.enter": { opacity: "0" },
|
|
@@ -235,7 +235,7 @@ var L = I(v, "Readable") || I(oe.Readable, "Readable"), R = l, z = R.default, oe
|
|
|
235
235
|
opacity: "0",
|
|
236
236
|
transition: "opacity 0.3s ease-in"
|
|
237
237
|
}
|
|
238
|
-
})), U =
|
|
238
|
+
})), U = o("div")(() => ({
|
|
239
239
|
width: "25px",
|
|
240
240
|
marginRight: "5px",
|
|
241
241
|
display: "flex",
|
|
@@ -259,8 +259,8 @@ var L = I(v, "Readable") || I(oe.Readable, "Readable"), R = l, z = R.default, oe
|
|
|
259
259
|
constructor(t) {
|
|
260
260
|
super(t), this.state = { show: t.show }, this.openIconRef = y.createRef(), this.closedIconRef = y.createRef(), e.defaultProps = {
|
|
261
261
|
...e.defaultProps,
|
|
262
|
-
showMessage:
|
|
263
|
-
hideMessage:
|
|
262
|
+
showMessage: V.t("common:showCorrectAnswer", { lng: t.language }),
|
|
263
|
+
hideMessage: V.t("common:hideCorrectAnswer", { lng: t.language })
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
onClick() {
|
|
@@ -272,20 +272,20 @@ var L = I(v, "Readable") || I(oe.Readable, "Readable"), R = l, z = R.default, oe
|
|
|
272
272
|
UNSAFE_componentWillReceiveProps(t) {
|
|
273
273
|
this.setState({ show: t.show }), t.language !== this.props?.language && (e.defaultProps = {
|
|
274
274
|
...e.defaultProps,
|
|
275
|
-
showMessage:
|
|
276
|
-
hideMessage:
|
|
275
|
+
showMessage: V.t("common:showCorrectAnswer", { lng: t.language }),
|
|
276
|
+
hideMessage: V.t("common:hideCorrectAnswer", { lng: t.language })
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
279
|
render() {
|
|
280
|
-
let { className: e, toggled: t, hideMessage:
|
|
280
|
+
let { className: e, toggled: t, hideMessage: r, showMessage: i } = this.props;
|
|
281
281
|
return /* @__PURE__ */ S(se, {
|
|
282
282
|
className: e,
|
|
283
|
-
children: /* @__PURE__ */ S(
|
|
283
|
+
children: /* @__PURE__ */ S(I, {
|
|
284
284
|
show: this.state.show,
|
|
285
285
|
children: /* @__PURE__ */ C(ce, {
|
|
286
286
|
onClick: this.onClick.bind(this),
|
|
287
287
|
onTouchEnd: this.onTouch.bind(this),
|
|
288
|
-
children: [/* @__PURE__ */ C(U, { children: [/* @__PURE__ */ S(
|
|
288
|
+
children: [/* @__PURE__ */ C(U, { children: [/* @__PURE__ */ S(n, {
|
|
289
289
|
nodeRef: this.openIconRef,
|
|
290
290
|
timeout: 400,
|
|
291
291
|
in: t,
|
|
@@ -300,7 +300,7 @@ var L = I(v, "Readable") || I(oe.Readable, "Readable"), R = l, z = R.default, oe
|
|
|
300
300
|
ref: this.openIconRef,
|
|
301
301
|
children: /* @__PURE__ */ S(O, { open: t }, "correct-open")
|
|
302
302
|
})
|
|
303
|
-
}), /* @__PURE__ */ S(
|
|
303
|
+
}), /* @__PURE__ */ S(n, {
|
|
304
304
|
nodeRef: this.closedIconRef,
|
|
305
305
|
timeout: 5e3,
|
|
306
306
|
in: !t,
|
|
@@ -315,11 +315,11 @@ var L = I(v, "Readable") || I(oe.Readable, "Readable"), R = l, z = R.default, oe
|
|
|
315
315
|
ref: this.closedIconRef,
|
|
316
316
|
children: /* @__PURE__ */ S(O, { open: t }, "correct-closed")
|
|
317
317
|
})
|
|
318
|
-
})] }), /* @__PURE__ */ S(
|
|
318
|
+
})] }), /* @__PURE__ */ S(ie, {
|
|
319
319
|
false: !0,
|
|
320
320
|
children: /* @__PURE__ */ S(le, {
|
|
321
321
|
"aria-hidden": !this.state.show,
|
|
322
|
-
children: t ?
|
|
322
|
+
children: t ? r : i
|
|
323
323
|
})
|
|
324
324
|
})]
|
|
325
325
|
})
|
|
@@ -335,15 +335,15 @@ function W(e) {
|
|
|
335
335
|
function G(e, t) {
|
|
336
336
|
return !e || W(e) ? e : W(e.default) ? e.default : t && W(e[t]) ? e[t] : t && W(e[t]?.default) ? e[t].default : e;
|
|
337
337
|
}
|
|
338
|
-
var de = G(
|
|
339
|
-
color:
|
|
340
|
-
backgroundColor:
|
|
338
|
+
var de = G(d, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(a, "PreviewPrompt") || G(X.PreviewPrompt, "PreviewPrompt"), q = G(u, "Collapsible") || G(X.Collapsible, "Collapsible"), J = g, Y = J.default, X = Y && typeof Y == "object" ? Y : J, fe = o(de)({
|
|
339
|
+
color: s.text(),
|
|
340
|
+
backgroundColor: s.background(),
|
|
341
341
|
overflowX: "scroll",
|
|
342
342
|
overflowY: "hidden"
|
|
343
|
-
}), Z =
|
|
343
|
+
}), Z = o(h)(({ theme: e }) => ({
|
|
344
344
|
marginTop: e.spacing(2),
|
|
345
345
|
marginBottom: e.spacing(2)
|
|
346
|
-
})), pe =
|
|
346
|
+
})), pe = o(q)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), Q = class extends y.Component {
|
|
347
347
|
static propTypes = {
|
|
348
348
|
model: w.default.object.isRequired,
|
|
349
349
|
onAnswersChange: w.default.func,
|
|
@@ -361,7 +361,7 @@ var de = G(n, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(c, "PreviewPrompt"
|
|
|
361
361
|
changeData = (e) => this.setState({ categories: e }, () => this.props.onAnswersChange(e));
|
|
362
362
|
toggleCorrect = (e) => this.setState({ showingCorrect: e });
|
|
363
363
|
render() {
|
|
364
|
-
let { categories: e, showingCorrect: t } = this.state, { model: n } = this.props, { teacherInstructions: r, prompt: i, chartType: a, size: o, domain:
|
|
364
|
+
let { categories: e, showingCorrect: t } = this.state, { model: n } = this.props, { teacherInstructions: r, prompt: i, chartType: a, size: o, domain: s, range: l, title: u, addCategoryEnabled: d, studentNewCategoryDefaultLabel: f, showToggle: m, rationale: h, correctAnswer: g, language: _, env: y, showKeyLegend: b } = n, { correctedAnswer: x, extraCSSRules: w } = n, T = (g?.data || []).map((e) => ({
|
|
365
365
|
...e,
|
|
366
366
|
interactive: !1,
|
|
367
367
|
editable: !1
|
|
@@ -370,11 +370,11 @@ var de = G(n, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(c, "PreviewPrompt"
|
|
|
370
370
|
...e,
|
|
371
371
|
editable: !1
|
|
372
372
|
})));
|
|
373
|
-
let D = n.rationale && (
|
|
373
|
+
let D = n.rationale && (c(n.rationale) || v(n.rationale));
|
|
374
374
|
return /* @__PURE__ */ C(fe, {
|
|
375
375
|
extraCSSRules: w,
|
|
376
376
|
children: [
|
|
377
|
-
n.teacherInstructions && (
|
|
377
|
+
n.teacherInstructions && (c(n.teacherInstructions) || v(n.teacherInstructions)) && /* @__PURE__ */ S(pe, {
|
|
378
378
|
labels: {
|
|
379
379
|
hidden: "Show Teacher Instructions",
|
|
380
380
|
visible: "Hide Teacher Instructions"
|
|
@@ -389,51 +389,51 @@ var de = G(n, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(c, "PreviewPrompt"
|
|
|
389
389
|
show: m,
|
|
390
390
|
toggled: t,
|
|
391
391
|
onToggle: this.toggleCorrect,
|
|
392
|
-
language:
|
|
392
|
+
language: _
|
|
393
393
|
}),
|
|
394
394
|
t && m ? /* @__PURE__ */ S(Z, {
|
|
395
395
|
chartType: a,
|
|
396
396
|
size: o,
|
|
397
|
-
domain:
|
|
397
|
+
domain: s,
|
|
398
398
|
range: l,
|
|
399
399
|
charts: [
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
400
|
+
p.Bar(),
|
|
401
|
+
p.Histogram(),
|
|
402
|
+
p.LineDot(),
|
|
403
|
+
p.LineCross(),
|
|
404
|
+
p.DotPlot(),
|
|
405
|
+
p.LinePlot()
|
|
406
406
|
],
|
|
407
407
|
data: T || e,
|
|
408
408
|
title: u,
|
|
409
409
|
onDataChange: this.changeData,
|
|
410
410
|
addCategoryEnabled: !1,
|
|
411
|
-
categoryDefaultLabel:
|
|
412
|
-
language:
|
|
411
|
+
categoryDefaultLabel: f,
|
|
412
|
+
language: _,
|
|
413
413
|
labelsPlaceholders: {}
|
|
414
414
|
}) : /* @__PURE__ */ S(Z, {
|
|
415
415
|
chartType: a,
|
|
416
416
|
size: o,
|
|
417
|
-
domain:
|
|
417
|
+
domain: s,
|
|
418
418
|
range: l,
|
|
419
419
|
charts: [
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
420
|
+
p.Bar(),
|
|
421
|
+
p.Histogram(),
|
|
422
|
+
p.LineDot(),
|
|
423
|
+
p.LineCross(),
|
|
424
|
+
p.DotPlot(),
|
|
425
|
+
p.LinePlot()
|
|
426
426
|
],
|
|
427
427
|
data: x || e,
|
|
428
428
|
title: u,
|
|
429
429
|
onDataChange: this.changeData,
|
|
430
430
|
addCategoryEnabled: d,
|
|
431
|
-
categoryDefaultLabel:
|
|
432
|
-
language:
|
|
431
|
+
categoryDefaultLabel: f,
|
|
432
|
+
language: _,
|
|
433
433
|
labelsPlaceholders: {},
|
|
434
434
|
correctData: m ? T : void 0
|
|
435
435
|
}),
|
|
436
|
-
!t && b && /* @__PURE__ */ S(
|
|
436
|
+
!t && b && /* @__PURE__ */ S(P, { language: _ }),
|
|
437
437
|
D && /* @__PURE__ */ S(q, {
|
|
438
438
|
labels: {
|
|
439
439
|
hidden: "Show Rationale",
|
|
@@ -475,7 +475,26 @@ var de = G(n, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(c, "PreviewPrompt"
|
|
|
475
475
|
}
|
|
476
476
|
}, he = class extends HTMLElement {
|
|
477
477
|
constructor() {
|
|
478
|
-
super(), this._root = null;
|
|
478
|
+
super(), this._root = null, this._mathObserver = null, this._mathRenderPending = !1;
|
|
479
|
+
}
|
|
480
|
+
_scheduleMathRender = () => {
|
|
481
|
+
this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
|
|
482
|
+
this._mathObserver && this._mathObserver.disconnect(), r(this), this._mathRenderPending = !1, setTimeout(() => {
|
|
483
|
+
this._mathObserver && this._mathObserver.observe(this, {
|
|
484
|
+
childList: !0,
|
|
485
|
+
subtree: !0
|
|
486
|
+
});
|
|
487
|
+
}, 50);
|
|
488
|
+
}));
|
|
489
|
+
};
|
|
490
|
+
_initMathObserver() {
|
|
491
|
+
this._mathObserver || (this._mathObserver = new MutationObserver(this._scheduleMathRender), this._mathObserver.observe(this, {
|
|
492
|
+
childList: !0,
|
|
493
|
+
subtree: !0
|
|
494
|
+
}));
|
|
495
|
+
}
|
|
496
|
+
_disconnectMathObserver() {
|
|
497
|
+
this._mathObserver &&= (this._mathObserver.disconnect(), null);
|
|
479
498
|
}
|
|
480
499
|
set model(e) {
|
|
481
500
|
this._model = e, this._session && this.isComplete(this._session.answer) ? this.dispatchEvent(new $(this.tagName.toLowerCase(), !0, !!this._model)) : this.dispatchEvent(new $(this.tagName.toLowerCase(), !1, !!this._model)), this._render();
|
|
@@ -487,7 +506,7 @@ var de = G(n, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(c, "PreviewPrompt"
|
|
|
487
506
|
return this._session;
|
|
488
507
|
}
|
|
489
508
|
connectedCallback() {
|
|
490
|
-
this._render();
|
|
509
|
+
this._initMathObserver(), this._render();
|
|
491
510
|
}
|
|
492
511
|
isComplete = (e) => Array.isArray(e) && e.length > 0;
|
|
493
512
|
changeAnswers = (e) => {
|
|
@@ -495,6 +514,7 @@ var de = G(n, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(c, "PreviewPrompt"
|
|
|
495
514
|
};
|
|
496
515
|
_render() {
|
|
497
516
|
if (!this._model || !this._session) return;
|
|
517
|
+
this._initMathObserver();
|
|
498
518
|
let e = {
|
|
499
519
|
...this._model,
|
|
500
520
|
data: this._model.data ? [...this._model.data] : this._model.data
|
|
@@ -503,12 +523,10 @@ var de = G(n, "UiLayout") || G(X.UiLayout, "UiLayout"), K = G(c, "PreviewPrompt"
|
|
|
503
523
|
categories: this._session.answer,
|
|
504
524
|
onAnswersChange: this.changeAnswers
|
|
505
525
|
});
|
|
506
|
-
this._root ||= x(this), this._root.render(t)
|
|
507
|
-
o(this);
|
|
508
|
-
});
|
|
526
|
+
this._root ||= x(this), this._root.render(t);
|
|
509
527
|
}
|
|
510
528
|
disconnectedCallback() {
|
|
511
|
-
this._root
|
|
529
|
+
this._disconnectMathObserver(), this._root &&= (this._root.unmount(), null);
|
|
512
530
|
}
|
|
513
531
|
};
|
|
514
532
|
//#endregion
|