@pie-element/inline-dropdown 11.0.8-next.20261110124518 → 11.0.8-next.20261110132055

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.
@@ -43666,7 +43666,7 @@ var PK = ge, FK = PK.default, IK = FK && typeof FK == "object" ? FK : PK, LK = N
43666
43666
  }
43667
43667
  }, kq = Object.freeze({
43668
43668
  name: "@pie-element/inline-dropdown",
43669
- version: "11.0.8-next.20261110124518"
43669
+ version: "11.0.8-next.20261110132055"
43670
43670
  });
43671
43671
  export { Oq as default, kq as piePackage };
43672
43672
 
@@ -46,6 +46,7 @@ var d = /* @__PURE__ */ a({ enabled: () => f });
46
46
  function f(e, t, n) {
47
47
  return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n != "boolean" || n;
48
48
  }
49
+ new Set("af az be bg br bs ca cs cv da de el eo es et eu ff fi fo fr fy gl hr hu hy ia id ie is it jv ka kk kl ku ky lb ln lo lt lu lv mk nb nl nn no oc os pl ps pt rm rn ro ru rw sc se sg sk sl sq sr su sv tg tk tr tt uk uz vi wo".split(" ")), "AT BE CZ DE DK EE ES FI FR GE HU ID IT LT LV NL NO PL PT RO SE SI SK UA ZA".split(" "), "419 BR BZ CU DO GT HN MX NI PA PE PR SV US".split(" ");
49
50
  // src/controller/defaults.ts
50
51
  var p = {
51
52
  alternateResponse: {},
@@ -192,7 +193,7 @@ var x = (e, t) => new Promise((n) => {
192
193
  }), o;
193
194
  }, w = Object.freeze({
194
195
  name: "@pie-element/inline-dropdown",
195
- version: "11.0.8-next.20261110124518"
196
+ version: "11.0.8-next.20261110132055"
196
197
  });
197
198
  export { x as createCorrectResponseSession, y as getLogTrace, v as getScore, _ as model, g as normalize, b as outcome, w as piePackage, C as validate };
198
199
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["defaults","reduce","map","lockChoices","getShuffledChoices","isEmpty","partialScoring","Gn","hn","An","e","t","r","i","n","a","s","o","c","defaults_default","getAllCorrectResponses","correctAnswers","choices","key","respArea","choice","alternateResponse","getFeedback","correct","normalize","question","model","normalizedQuestion","session","area","obj","feedback","env","allCorrectResponses","respAreaLength","correctResponses","result","answer","value","correctChoice","isCorrect","shuffledValues","keys","us","part","update","resolve","storedValues","Cn","updateSession","teacherInstructions","rationale","choicesWillNullRationales","currentValue","acc","_correct","getScore","maxScore","config","correctCount","total","str","getLogTrace","traceLog","responseAreaKeys","totalAreas","selectedAreas","val","studentSelection","areaKey","correctOptions","opt","partialScoringEnabled","score","outcome","createCorrectResponseSession","correctChoices","getContent","html","validate","errors","field","nbOfResponseAreas","markup","maxResponseAreas","allChoices","choiceKey","maxResponseAreaChoices","piePackage","\"name\"","\"version\""],"sources":["../../../../../shared/controller-utils/dist/index.js","../../../src/controller/defaults.ts","../../../src/controller/utils.ts","../../../src/controller/index.ts"],"sourcesContent":["// \\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// 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// 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// src/response-normalizer.ts\nvar l = /[\\u061C\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069\\u0640]/g, u = /[\\uFB50-\\uFDFF\\uFE70-\\uFEFC]+/g, d = /\\p{Nd}/u, f = /(?![0-9])\\p{Nd}/gu, p = /\\u066B/g, m = /\\u066C/g, h = /[\\u0622\\u0623\\u0625\\u0671]/g, g = /[\\u064B-\\u065F\\u0670]/g, _ = /* @__PURE__ */ new Map(), v = (e) => {\n\tlet t = _.get(e);\n\tif (t !== void 0) return t;\n\tlet n = 0;\n\tfor (; d.test(String.fromCodePoint(e - n - 1));) n++;\n\tlet r = n % 10;\n\treturn _.set(e, r), r;\n}, y = (e) => e.replace(f, (e) => String(v(e.codePointAt(0)))), b = {\n\tdecimal: \".\",\n\tgroup: \",\"\n}, x = /* @__PURE__ */ new Map(), S = (e) => {\n\tif (!e) return b;\n\tlet t = x.get(e);\n\tif (t) return t;\n\tlet n = b;\n\ttry {\n\t\tif (Intl.NumberFormat.supportedLocalesOf(e).length > 0) {\n\t\t\tlet t = new Intl.NumberFormat(e, { numberingSystem: \"latn\" }).formatToParts(12345.6);\n\t\t\tn = {\n\t\t\t\tdecimal: t.find((e) => e.type === \"decimal\")?.value ?? \".\",\n\t\t\t\tgroup: t.find((e) => e.type === \"group\")?.value ?? \",\"\n\t\t\t};\n\t\t}\n\t} catch {}\n\treturn x.set(e, n), n;\n}, C = (e, t) => {\n\tlet n = [e?.language, t?.locale];\n\tfor (let e of n) if (typeof e == \"string\" && e.trim()) return e.trim().replace(/_/g, \"-\");\n}, w = /^(tr|az)(-|$)/i, T = (e, t) => {\n\tif (!t || !w.test(t)) return e.toLowerCase();\n\ttry {\n\t\treturn e.toLocaleLowerCase(t);\n\t} catch {\n\t\treturn e.toLowerCase();\n\t}\n}, E = (e, t = {}) => {\n\tlet n = S(t.language), r = (t.ignoreCase ? T(e, t.language) : e).replace(l, \"\").replace(u, (e) => e.normalize(\"NFKC\")).normalize(\"NFC\");\n\treturn r = y(r).replace(p, n.decimal).replace(m, n.group), t.foldLetterVariants && (r = r.replace(g, \"\").replace(h, \"ا\").replace(/\\u0629/g, \"ه\").replace(/\\u0649/g, \"ي\")), t.ignoreAccents && (r = r.normalize(\"NFD\").replace(/[\\u0300-\\u036F]/g, \"\").normalize(\"NFC\")), t.collapseWhitespace && (r = r.replace(/\\s+/g, \" \").trim()), t.ignoreSlashSpacing && (r = r.replace(/\\s*\\/\\s*/g, \"/\")), r;\n};\nexport { C as contentLanguage, T as foldCase, y as foldDigits, a as getShuffledChoices, o as lockChoices, E as normalizeResponse, s as partialScoring };\n","import type { InlineDropdownModel } from '../types.js';\n\nexport default {\n alternateResponse: {},\n choiceRationaleEnabled: true,\n choices: {},\n disabled: false,\n displayType: 'block',\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n shuffle: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n} satisfies Omit<InlineDropdownModel, 'id' | 'element'>;\n","import { forEach } from '@pie-element/shared-lodash';\nimport type { Choice, InlineDropdownModel } from '../types.js';\n\nexport const getAllCorrectResponses = ({\n choices,\n alternateResponse,\n}: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers: Record<string, string[]> = {};\n\n forEach<Choice[]>(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n","import { isEmpty, map, reduce } from '@pie-element/shared-lodash';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';\nimport defaults from './defaults.js';\n\nimport { getAllCorrectResponses } from './utils.js';\nimport type {\n Choice,\n Choices,\n InlineDropdownConfiguration,\n InlineDropdownModel,\n InlineDropdownSession,\n} from '../types.js';\n\n/** Errors `validate()` reports, keyed by field. */\nexport type InlineDropdownValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n responseAreasError?: string;\n responseAreaChoicesError?: string;\n};\n\n/** A choice as the controller hands it to the delivery: rationales are `null` unless the instructor sees them */\ntype DeliveryChoice = Omit<Choice, 'rationale'> & { rationale?: string | null };\n\nconst getFeedback = (correct: unknown) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question: InlineDropdownModel) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(\n question: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: PieEnvironment,\n updateSession?: PieUpdateSession,\n) {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce<Choice[], Record<string, DeliveryChoice[] | undefined>>(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback: Record<string, string> = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce<string[], { correctResponses: number; feedback: Record<string, string> }>(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n // `lockChoices` ignores the session, so the per-area `shuffledValues` shape does not matter to it.\n const lockChoiceOrder = lockChoices(normalizedQuestion, session as Parameters<typeof lockChoices>[1], env);\n\n if (!lockChoiceOrder) {\n const shuffledValues: Record<string, string[]> = {};\n const keys = Object.keys(choices);\n\n const us =\n (part: string): PieUpdateSession =>\n (_id, _element, update) => {\n return new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues as string[];\n resolve();\n });\n };\n\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n const storedValues = (session?.shuffledValues as Record<string, string[]> | undefined)?.[key];\n\n choices[key] = await getShuffledChoices(\n choices[key] as DeliveryChoice[],\n // the shuffledValues structure was updated to an object like { choice_key: [] }\n // and we need to override shuffledValues if it's not an array\n { shuffledValues: Array.isArray(storedValues) ? storedValues : [] },\n us(key),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (session && updateSession && typeof updateSession === 'function') {\n updateSession(session.id as string, session.element as string, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n }\n\n let teacherInstructions: string | null | undefined = null;\n let rationale: string | null | undefined = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce<Record<string, DeliveryChoice[]>>((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n // Which choice is correct reaches the browser only once it may show it; delivery reads the flag\n // for the correct-answer view alone.\n if (env.mode !== 'evaluate' && env.role !== 'instructor') {\n choices = Object.fromEntries(\n Object.entries(choices).map(([key, area]) => [key, (area || []).map(({ correct: _correct, ...choice }) => choice)]),\n );\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n return out;\n}\n\nexport const getScore = (\n config: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>,\n session: InlineDropdownSession | null | undefined,\n) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce<string[], number>(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\n\n return parseFloat(str);\n};\n\n/**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment>,\n) => {\n const traceLog: string[] = [];\n const { value = {} } = session || {};\n const allCorrectResponses = getAllCorrectResponses(model);\n const responseAreaKeys = Object.keys(allCorrectResponses);\n const totalAreas = responseAreaKeys.length;\n \n traceLog.push(`${totalAreas} dropdown response area(s) defined in this question.`);\n \n if (value && Object.keys(value).length > 0) {\n const selectedAreas = Object.entries(value).filter(([, val]) => val && val.trim()).length;\n traceLog.push(`Student selected options in ${selectedAreas} out of ${totalAreas} dropdown(s).`);\n \n responseAreaKeys.forEach((areaKey) => {\n const studentSelection = (value && value[areaKey]) || '';\n const correctOptions = allCorrectResponses[areaKey] || [];\n \n if (studentSelection.trim()) {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: student selected '${studentSelection}' (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n } else {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: no selection made (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n }\n });\n } else {\n traceLog.push('Student did not make any selections in the dropdowns.');\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n traceLog.push(\n `Scoring method: ${\n partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'\n }.`\n );\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment> = {},\n) {\n return new Promise<{ score: number; empty: boolean; traceLog: string[] }>((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n traceLog: ['Student did not make any selections in the dropdowns. Score is 0.'] \n });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n traceLog\n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question: InlineDropdownModel, env: PieEnvironment) => {\n return new Promise<InlineDropdownSession | null>((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value: Record<string, string> = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html: string | undefined) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (\n model: Partial<InlineDropdownModel> = {},\n config: InlineDropdownConfiguration = {},\n) => {\n const { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors: InlineDropdownValidationErrors = {};\n\n (['teacherInstructions', 'prompt', 'rationale'] as const).forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (maxResponseAreas !== undefined && nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be defined at least 1 response area.';\n }\n\n // `Object.keys` throws when the model has no `choices`.\n const allChoices = choices as Choices;\n\n (Object.keys(allChoices) || []).forEach((choiceKey) => {\n if (\n allChoices[choiceKey] &&\n maxResponseAreaChoices !== undefined &&\n allChoices[choiceKey].length > maxResponseAreaChoices\n ) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"mappings":";;AACA,IAAIU,IAAI,OAAO,gBAAgBC,KAAK,GAAG,MAAM;CAC5C,IAAIC,IAAI,CAAC;CACT,KAAK,IAAIC,KAAKF,GAAG,EAAEC,GAAGC,GAAG;EACxB,KAAKF,EAAEE;EACP,YAAY,CAAC;CACd,CAAC;CACD,OAAOC,KAAKJ,EAAEE,GAAG,OAAO,aAAa,EAAE,OAAO,SAAS,CAAC,GAAGA;AAC5D;AAEA,SAASE,EAAE,GAAG;CACb,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,CAAC;AACzD;AACA,SAASF,EAAE,GAAG;CACb,IAAI,IAAI,CAAC,GAAG,CAAC;CACb,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK;EACtC,IAAI,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;EAC1C,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE;CAC3B;CACA,OAAO;AACR;AACA,SAASC,EAAE,GAAG;CACb,OAAO,KAAK,OAAO,CAAC,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,WAAW,IAA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MAAM,gBAAgB,KAAK,CAAC,EAAA,CAAG;CAEzE,AAAIC,MAAqB,KAAA,KAAaF,IAAoBE,IACxD,EAAO,qBAAqB,gBAAgBA,EAAiB,sCACpDF,IAAoB,MAC7B,EAAO,qBAAqB;CAI9B,IAAMG,IAAapE;CAYnB,QAVC,OAAO,KAAKoE,CAAU,KAAK,CAAC,EAAA,CAAG,SAAS,MAAc;EACrD,AACEA,EAAWC,MACXC,MAA2B,KAAA,KAC3BF,EAAWC,EAAU,CAAC,SAASC,MAE/B,EAAO,2BAA2B,gBAAgBA,EAAuB;CAE7E,CAAC,GAEMP;AACT,G"}
1
+ {"version":3,"file":"index.js","names":["defaults","reduce","map","lockChoices","getShuffledChoices","isEmpty","partialScoring","Gn","hn","An","e","t","r","i","n","a","s","o","c","defaults_default","getAllCorrectResponses","correctAnswers","choices","key","respArea","choice","alternateResponse","getFeedback","correct","normalize","question","model","normalizedQuestion","session","area","obj","feedback","env","allCorrectResponses","respAreaLength","correctResponses","result","answer","value","correctChoice","isCorrect","shuffledValues","keys","us","part","update","resolve","storedValues","Cn","updateSession","teacherInstructions","rationale","choicesWillNullRationales","currentValue","acc","_correct","getScore","maxScore","config","correctCount","total","str","getLogTrace","traceLog","responseAreaKeys","totalAreas","selectedAreas","val","studentSelection","areaKey","correctOptions","opt","partialScoringEnabled","score","outcome","createCorrectResponseSession","correctChoices","getContent","html","validate","errors","field","nbOfResponseAreas","markup","maxResponseAreas","allChoices","choiceKey","maxResponseAreaChoices","piePackage","\"name\"","\"version\""],"sources":["../../../../../shared/controller-utils/dist/index.js","../../../src/controller/defaults.ts","../../../src/controller/utils.ts","../../../src/controller/index.ts"],"sourcesContent":["// \\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// 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// 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// ../../../node_modules/.bun/@pie-players+pie-language-tags@1.0.0-beta.9/node_modules/@pie-players/pie-language-tags/dist/index.js\nfunction l(e) {\n\treturn e ? e.trim().replace(/_/g, \"-\") : \"\";\n}\nfunction u(e) {\n\tlet t = l(e).split(/[.@]/)[0];\n\tif (/^[a-z]{2,3}(-|$)/i.test(t)) try {\n\t\treturn Intl.getCanonicalLocales(t)[0];\n\t} catch {\n\t\treturn;\n\t}\n}\n// src/response-normalizer.ts\nvar d = /[\\u061C\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069\\u0640]/g, f = /[\\uFB50-\\uFDFF\\uFE70-\\uFEFC]+/g, p = /\\p{Nd}/u, m = /(?![0-9])\\p{Nd}/gu, h = /\\u066B/g, g = /\\u066C/g, _ = /[0-9]+(?:(?:[.,]|\\{,\\})[0-9]+)*(?:(?:,|\\{,\\})(?=\\\\overline))?/g, v = /[.,]|\\{,\\}/g, y = /(?<!\\\\|&(?:[a-zA-Z][a-zA-Z0-9]*|#[0-9]+|#[xX][0-9a-fA-F]+));/g, b = (e) => {\n\tlet t = e.match(v) ?? [];\n\treturn t.length === 1 && t[0] !== \".\" ? e.replace(v, \".\") : e;\n}, x = new Set(\"af az be bg br bs ca cs cv da de el eo es et eu ff fi fo fr fy gl hr hu hy ia id ie is it jv ka kk kl ku ky lb ln lo lt lu lv mk nb nl nn no oc os pl ps pt rm rn ro ru rw sc se sg sk sl sq sr su sv tg tk tr tt uk uz vi wo\".split(\" \")), S = {\n\tar: [\n\t\t\"DZ\",\n\t\t\"LB\",\n\t\t\"LY\",\n\t\t\"MA\",\n\t\t\"MR\",\n\t\t\"TN\"\n\t],\n\tde: [\"CH\", \"LI\"],\n\ten: \"AT BE CZ DE DK EE ES FI FR GE HU ID IT LT LV NL NO PL PT RO SE SI SK UA ZA\".split(\" \"),\n\tes: \"419 BR BZ CU DO GT HN MX NI PA PE PR SV US\".split(\" \"),\n\tit: [\"CH\"],\n\tkk: [\"CN\"],\n\tku: [\"IQ\"],\n\tms: [\"BN\", \"ID\"],\n\tqu: [\"BO\"],\n\tsw: [\"CD\"]\n}, C = /[\\u0622\\u0623\\u0625\\u0671]/g, w = /[\\u064B-\\u065F\\u0670]/g, T = /* @__PURE__ */ new Map(), E = (e) => {\n\tlet t = T.get(e);\n\tif (t !== void 0) return t;\n\tlet n = 0;\n\tfor (; p.test(String.fromCodePoint(e - n - 1));) n++;\n\tlet r = n % 10;\n\treturn T.set(e, r), r;\n}, D = (e) => e.replace(m, (e) => String(E(e.codePointAt(0)))), O = {\n\tdecimal: \".\",\n\tgroup: \",\"\n}, k = /* @__PURE__ */ new Map(), A = (e) => {\n\tif (!e) return O;\n\tlet t = k.get(e);\n\tif (t) return t;\n\tlet n = O;\n\ttry {\n\t\tif (Intl.NumberFormat.supportedLocalesOf(e).length > 0) {\n\t\t\tlet t = new Intl.NumberFormat(e, { numberingSystem: \"latn\" }).formatToParts(12345.6);\n\t\t\tn = {\n\t\t\t\tdecimal: t.find((e) => e.type === \"decimal\")?.value ?? \".\",\n\t\t\t\tgroup: t.find((e) => e.type === \"group\")?.value ?? \",\"\n\t\t\t};\n\t\t}\n\t} catch {}\n\treturn k.set(e, n), n;\n}, j = (e) => {\n\tif (!e) return !1;\n\ttry {\n\t\tlet { language: t, region: n } = new Intl.Locale(e);\n\t\treturn n ? x.has(t) !== (S[t]?.includes(n) ?? !1) : !1;\n\t} catch {\n\t\treturn !1;\n\t}\n}, M = /* @__PURE__ */ new Set([\n\t\"und\",\n\t\"zxx\",\n\t\"mul\",\n\t\"mis\"\n]), N = (e) => {\n\tlet t = u(e);\n\treturn t && !M.has(t.split(\"-\")[0]) ? t : void 0;\n}, P = (e, t, n) => {\n\tlet r = [e?.language, t?.locale];\n\tfor (let e of r) {\n\t\tlet t = typeof e == \"string\" ? n(e) : void 0;\n\t\tif (t) return t;\n\t}\n}, F = (e, t) => P(e, t, N), I = (e, t) => P(e, t, (e) => N(e.includes(\"_\") ? e.slice(0, e.indexOf(\"_\")) : e)), L = /^(tr|az)(-|$)/i, R = (e, t) => {\n\tif (!t || !L.test(t)) return e.toLowerCase();\n\ttry {\n\t\treturn e.toLocaleLowerCase(t);\n\t} catch {\n\t\treturn e.toLowerCase();\n\t}\n}, z = (e, t = {}) => {\n\tlet n = t.latexNumbers ? O : A(t.language), r = (t.ignoreCase ? R(e, t.language) : e).replace(d, \"\").replace(f, (e) => e.normalize(\"NFKC\")).normalize(\"NFC\");\n\treturn r = D(r), t.latexNumbers && j(t.language) && (r = r.replace(_, b).replace(y, \", \")), r = r.replace(h, n.decimal).replace(g, n.group), t.foldLetterVariants && (r = r.replace(w, \"\").replace(C, \"ا\").replace(/\\u0629/g, \"ه\").replace(/\\u0649/g, \"ي\")), t.ignoreAccents && (r = r.normalize(\"NFD\").replace(/[\\u0300-\\u036F]/g, \"\").normalize(\"NFC\")), t.collapseWhitespace && (r = r.replace(/\\s+/g, \" \").trim()), t.ignoreSlashSpacing && (r = r.replace(/\\s*\\/\\s*/g, \"/\")), r;\n};\nexport { F as contentLanguage, R as foldCase, D as foldDigits, a as getShuffledChoices, o as lockChoices, I as mathContentLanguage, z as normalizeResponse, s as partialScoring };\n","import type { InlineDropdownModel } from '../types.js';\n\nexport default {\n alternateResponse: {},\n choiceRationaleEnabled: true,\n choices: {},\n disabled: false,\n displayType: 'block',\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n shuffle: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n} satisfies Omit<InlineDropdownModel, 'id' | 'element'>;\n","import { forEach } from '@pie-element/shared-lodash';\nimport type { Choice, InlineDropdownModel } from '../types.js';\n\nexport const getAllCorrectResponses = ({\n choices,\n alternateResponse,\n}: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers: Record<string, string[]> = {};\n\n forEach<Choice[]>(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n","import { isEmpty, map, reduce } from '@pie-element/shared-lodash';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';\nimport defaults from './defaults.js';\n\nimport { getAllCorrectResponses } from './utils.js';\nimport type {\n Choice,\n Choices,\n InlineDropdownConfiguration,\n InlineDropdownModel,\n InlineDropdownSession,\n} from '../types.js';\n\n/** Errors `validate()` reports, keyed by field. */\nexport type InlineDropdownValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n responseAreasError?: string;\n responseAreaChoicesError?: string;\n};\n\n/** A choice as the controller hands it to the delivery: rationales are `null` unless the instructor sees them */\ntype DeliveryChoice = Omit<Choice, 'rationale'> & { rationale?: string | null };\n\nconst getFeedback = (correct: unknown) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question: InlineDropdownModel) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(\n question: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: PieEnvironment,\n updateSession?: PieUpdateSession,\n) {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce<Choice[], Record<string, DeliveryChoice[] | undefined>>(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback: Record<string, string> = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce<string[], { correctResponses: number; feedback: Record<string, string> }>(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n // `lockChoices` ignores the session, so the per-area `shuffledValues` shape does not matter to it.\n const lockChoiceOrder = lockChoices(normalizedQuestion, session as Parameters<typeof lockChoices>[1], env);\n\n if (!lockChoiceOrder) {\n const shuffledValues: Record<string, string[]> = {};\n const keys = Object.keys(choices);\n\n const us =\n (part: string): PieUpdateSession =>\n (_id, _element, update) => {\n return new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues as string[];\n resolve();\n });\n };\n\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n const storedValues = (session?.shuffledValues as Record<string, string[]> | undefined)?.[key];\n\n choices[key] = await getShuffledChoices(\n choices[key] as DeliveryChoice[],\n // the shuffledValues structure was updated to an object like { choice_key: [] }\n // and we need to override shuffledValues if it's not an array\n { shuffledValues: Array.isArray(storedValues) ? storedValues : [] },\n us(key),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (session && updateSession && typeof updateSession === 'function') {\n updateSession(session.id as string, session.element as string, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n }\n\n let teacherInstructions: string | null | undefined = null;\n let rationale: string | null | undefined = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce<Record<string, DeliveryChoice[]>>((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n // Which choice is correct reaches the browser only once it may show it; delivery reads the flag\n // for the correct-answer view alone.\n if (env.mode !== 'evaluate' && env.role !== 'instructor') {\n choices = Object.fromEntries(\n Object.entries(choices).map(([key, area]) => [key, (area || []).map(({ correct: _correct, ...choice }) => choice)]),\n );\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n return out;\n}\n\nexport const getScore = (\n config: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>,\n session: InlineDropdownSession | null | undefined,\n) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce<string[], number>(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\n\n return parseFloat(str);\n};\n\n/**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment>,\n) => {\n const traceLog: string[] = [];\n const { value = {} } = session || {};\n const allCorrectResponses = getAllCorrectResponses(model);\n const responseAreaKeys = Object.keys(allCorrectResponses);\n const totalAreas = responseAreaKeys.length;\n \n traceLog.push(`${totalAreas} dropdown response area(s) defined in this question.`);\n \n if (value && Object.keys(value).length > 0) {\n const selectedAreas = Object.entries(value).filter(([, val]) => val && val.trim()).length;\n traceLog.push(`Student selected options in ${selectedAreas} out of ${totalAreas} dropdown(s).`);\n \n responseAreaKeys.forEach((areaKey) => {\n const studentSelection = (value && value[areaKey]) || '';\n const correctOptions = allCorrectResponses[areaKey] || [];\n \n if (studentSelection.trim()) {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: student selected '${studentSelection}' (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n } else {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: no selection made (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n }\n });\n } else {\n traceLog.push('Student did not make any selections in the dropdowns.');\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n traceLog.push(\n `Scoring method: ${\n partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'\n }.`\n );\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment> = {},\n) {\n return new Promise<{ score: number; empty: boolean; traceLog: string[] }>((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n traceLog: ['Student did not make any selections in the dropdowns. Score is 0.'] \n });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n traceLog\n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question: InlineDropdownModel, env: PieEnvironment) => {\n return new Promise<InlineDropdownSession | null>((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value: Record<string, string> = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html: string | undefined) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (\n model: Partial<InlineDropdownModel> = {},\n config: InlineDropdownConfiguration = {},\n) => {\n const { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors: InlineDropdownValidationErrors = {};\n\n (['teacherInstructions', 'prompt', 'rationale'] as const).forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (maxResponseAreas !== undefined && nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be defined at least 1 response area.';\n }\n\n // `Object.keys` throws when the model has no `choices`.\n const allChoices = choices as Choices;\n\n (Object.keys(allChoices) || []).forEach((choiceKey) => {\n if (\n allChoices[choiceKey] &&\n maxResponseAreaChoices !== undefined &&\n allChoices[choiceKey].length > maxResponseAreaChoices\n ) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"mappings":";;AACA,IAAIU,IAAI,OAAO,gBAAgBC,KAAK,GAAG,MAAM;CAC5C,IAAIC,IAAI,CAAC;CACT,KAAK,IAAIC,KAAKF,GAAG,EAAEC,GAAGC,GAAG;EACxB,KAAKF,EAAEE;EACP,YAAY,CAAC;CACd,CAAC;CACD,OAAOC,KAAKJ,EAAEE,GAAG,OAAO,aAAa,EAAE,OAAO,SAAS,CAAC,GAAGA;AAC5D;AAEA,SAASE,EAAE,GAAG;CACb,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,CAAC;AACzD;AACA,SAASF,EAAE,GAAG;CACb,IAAI,IAAI,CAAC,GAAG,CAAC;CACb,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK;EACtC,IAAI,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;EAC1C,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE;CAC3B;CACA,OAAO;AACR;AACA,SAASC,EAAE,GAAG;CACb,OAAO,KAAK,OAAO,CAAC,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,WAAW,IAAI,OAAO,KAAK,YAAY,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW;AAC/G;AACA,eAAeE,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS;CACtC,IAAIC,IAAIF,EAAE,GAAG,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,CAAC;CAC5D,IAAI,CAAC,GAAG;EACP,QAAQ,KAAK,6DAA6D;EAC1E;CACD;CACA,IAAI,CAACD,EAAEG,CAAC,GAAG,OAAOF,EAAEE,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,EAAEC,OAAO,CAAC,CAAC,CAAC;CAC3D,IAAIC,IAAIN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KAC3BF,EAAWC,EAAU,CAAC,SAASC,MAE/B,EAAO,2BAA2B,gBAAgBA,EAAuB;CAE7E,CAAC,GAEMP;AACT,G"}
@@ -1477,7 +1477,7 @@ var kt = d, Z = kt.default, Q = Z && typeof Z == "object" ? Z : kt, At = X(o, "U
1477
1477
  }
1478
1478
  }, Bt = Object.freeze({
1479
1479
  name: "@pie-element/inline-dropdown",
1480
- version: "11.0.8-next.20261110124518"
1480
+ version: "11.0.8-next.20261110132055"
1481
1481
  });
1482
1482
  export { zt as default, Bt as piePackage };
1483
1483
 
@@ -27058,7 +27058,7 @@ var RT = B, zT = RT.default, BT = zT && typeof zT == "object" ? zT : RT, VT = LT
27058
27058
  }
27059
27059
  }, NE = Object.freeze({
27060
27060
  name: "@pie-element/inline-dropdown",
27061
- version: "11.0.8-next.20261110124518"
27061
+ version: "11.0.8-next.20261110132055"
27062
27062
  });
27063
27063
  export { ME as default, NE as piePackage };
27064
27064
 
@@ -46,6 +46,7 @@ var d = /* @__PURE__ */ a({ enabled: () => f });
46
46
  function f(e, t, n) {
47
47
  return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n != "boolean" || n;
48
48
  }
49
+ new Set("af az be bg br bs ca cs cv da de el eo es et eu ff fi fo fr fy gl hr hu hy ia id ie is it jv ka kk kl ku ky lb ln lo lt lu lv mk nb nl nn no oc os pl ps pt rm rn ro ru rw sc se sg sk sl sq sr su sv tg tk tr tt uk uz vi wo".split(" ")), "AT BE CZ DE DK EE ES FI FR GE HU ID IT LT LV NL NO PL PT RO SE SI SK UA ZA".split(" "), "419 BR BZ CU DO GT HN MX NI PA PE PR SV US".split(" ");
49
50
  // src/controller/defaults.ts
50
51
  var p = {
51
52
  alternateResponse: {},
@@ -192,7 +193,7 @@ var x = (e, t) => new Promise((n) => {
192
193
  }), o;
193
194
  }, w = Object.freeze({
194
195
  name: "@pie-element/inline-dropdown",
195
- version: "11.0.8-next.20261110124518"
196
+ version: "11.0.8-next.20261110132055"
196
197
  });
197
198
  export { x as createCorrectResponseSession, y as getLogTrace, v as getScore, _ as model, g as normalize, b as outcome, w as piePackage, C as validate };
198
199
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["defaults","reduce","map","lockChoices","getShuffledChoices","isEmpty","partialScoring","Gn","hn","An","e","t","r","i","n","a","s","o","c","defaults_default","getAllCorrectResponses","correctAnswers","choices","key","respArea","choice","alternateResponse","getFeedback","correct","normalize","question","model","normalizedQuestion","session","area","obj","feedback","env","allCorrectResponses","respAreaLength","correctResponses","result","answer","value","correctChoice","isCorrect","shuffledValues","keys","us","part","update","resolve","storedValues","Cn","updateSession","teacherInstructions","rationale","choicesWillNullRationales","currentValue","acc","_correct","getScore","maxScore","config","correctCount","total","str","getLogTrace","traceLog","responseAreaKeys","totalAreas","selectedAreas","val","studentSelection","areaKey","correctOptions","opt","partialScoringEnabled","score","outcome","createCorrectResponseSession","correctChoices","getContent","html","validate","errors","field","nbOfResponseAreas","markup","maxResponseAreas","allChoices","choiceKey","maxResponseAreaChoices","piePackage","\"name\"","\"version\""],"sources":["../../../../../../shared/controller-utils/dist/index.js","../../../../src/controller/defaults.ts","../../../../src/controller/utils.ts","../../../../src/controller/index.ts"],"sourcesContent":["// \\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// 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// 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// src/response-normalizer.ts\nvar l = /[\\u061C\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069\\u0640]/g, u = /[\\uFB50-\\uFDFF\\uFE70-\\uFEFC]+/g, d = /\\p{Nd}/u, f = /(?![0-9])\\p{Nd}/gu, p = /\\u066B/g, m = /\\u066C/g, h = /[\\u0622\\u0623\\u0625\\u0671]/g, g = /[\\u064B-\\u065F\\u0670]/g, _ = /* @__PURE__ */ new Map(), v = (e) => {\n\tlet t = _.get(e);\n\tif (t !== void 0) return t;\n\tlet n = 0;\n\tfor (; d.test(String.fromCodePoint(e - n - 1));) n++;\n\tlet r = n % 10;\n\treturn _.set(e, r), r;\n}, y = (e) => e.replace(f, (e) => String(v(e.codePointAt(0)))), b = {\n\tdecimal: \".\",\n\tgroup: \",\"\n}, x = /* @__PURE__ */ new Map(), S = (e) => {\n\tif (!e) return b;\n\tlet t = x.get(e);\n\tif (t) return t;\n\tlet n = b;\n\ttry {\n\t\tif (Intl.NumberFormat.supportedLocalesOf(e).length > 0) {\n\t\t\tlet t = new Intl.NumberFormat(e, { numberingSystem: \"latn\" }).formatToParts(12345.6);\n\t\t\tn = {\n\t\t\t\tdecimal: t.find((e) => e.type === \"decimal\")?.value ?? \".\",\n\t\t\t\tgroup: t.find((e) => e.type === \"group\")?.value ?? \",\"\n\t\t\t};\n\t\t}\n\t} catch {}\n\treturn x.set(e, n), n;\n}, C = (e, t) => {\n\tlet n = [e?.language, t?.locale];\n\tfor (let e of n) if (typeof e == \"string\" && e.trim()) return e.trim().replace(/_/g, \"-\");\n}, w = /^(tr|az)(-|$)/i, T = (e, t) => {\n\tif (!t || !w.test(t)) return e.toLowerCase();\n\ttry {\n\t\treturn e.toLocaleLowerCase(t);\n\t} catch {\n\t\treturn e.toLowerCase();\n\t}\n}, E = (e, t = {}) => {\n\tlet n = S(t.language), r = (t.ignoreCase ? T(e, t.language) : e).replace(l, \"\").replace(u, (e) => e.normalize(\"NFKC\")).normalize(\"NFC\");\n\treturn r = y(r).replace(p, n.decimal).replace(m, n.group), t.foldLetterVariants && (r = r.replace(g, \"\").replace(h, \"ا\").replace(/\\u0629/g, \"ه\").replace(/\\u0649/g, \"ي\")), t.ignoreAccents && (r = r.normalize(\"NFD\").replace(/[\\u0300-\\u036F]/g, \"\").normalize(\"NFC\")), t.collapseWhitespace && (r = r.replace(/\\s+/g, \" \").trim()), t.ignoreSlashSpacing && (r = r.replace(/\\s*\\/\\s*/g, \"/\")), r;\n};\nexport { C as contentLanguage, T as foldCase, y as foldDigits, a as getShuffledChoices, o as lockChoices, E as normalizeResponse, s as partialScoring };\n","import type { InlineDropdownModel } from '../types.js';\n\nexport default {\n alternateResponse: {},\n choiceRationaleEnabled: true,\n choices: {},\n disabled: false,\n displayType: 'block',\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n shuffle: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n} satisfies Omit<InlineDropdownModel, 'id' | 'element'>;\n","import { forEach } from '@pie-element/shared-lodash';\nimport type { Choice, InlineDropdownModel } from '../types.js';\n\nexport const getAllCorrectResponses = ({\n choices,\n alternateResponse,\n}: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers: Record<string, string[]> = {};\n\n forEach<Choice[]>(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n","import { isEmpty, map, reduce } from '@pie-element/shared-lodash';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';\nimport defaults from './defaults.js';\n\nimport { getAllCorrectResponses } from './utils.js';\nimport type {\n Choice,\n Choices,\n InlineDropdownConfiguration,\n InlineDropdownModel,\n InlineDropdownSession,\n} from '../types.js';\n\n/** Errors `validate()` reports, keyed by field. */\nexport type InlineDropdownValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n responseAreasError?: string;\n responseAreaChoicesError?: string;\n};\n\n/** A choice as the controller hands it to the delivery: rationales are `null` unless the instructor sees them */\ntype DeliveryChoice = Omit<Choice, 'rationale'> & { rationale?: string | null };\n\nconst getFeedback = (correct: unknown) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question: InlineDropdownModel) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(\n question: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: PieEnvironment,\n updateSession?: PieUpdateSession,\n) {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce<Choice[], Record<string, DeliveryChoice[] | undefined>>(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback: Record<string, string> = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce<string[], { correctResponses: number; feedback: Record<string, string> }>(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n // `lockChoices` ignores the session, so the per-area `shuffledValues` shape does not matter to it.\n const lockChoiceOrder = lockChoices(normalizedQuestion, session as Parameters<typeof lockChoices>[1], env);\n\n if (!lockChoiceOrder) {\n const shuffledValues: Record<string, string[]> = {};\n const keys = Object.keys(choices);\n\n const us =\n (part: string): PieUpdateSession =>\n (_id, _element, update) => {\n return new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues as string[];\n resolve();\n });\n };\n\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n const storedValues = (session?.shuffledValues as Record<string, string[]> | undefined)?.[key];\n\n choices[key] = await getShuffledChoices(\n choices[key] as DeliveryChoice[],\n // the shuffledValues structure was updated to an object like { choice_key: [] }\n // and we need to override shuffledValues if it's not an array\n { shuffledValues: Array.isArray(storedValues) ? storedValues : [] },\n us(key),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (session && updateSession && typeof updateSession === 'function') {\n updateSession(session.id as string, session.element as string, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n }\n\n let teacherInstructions: string | null | undefined = null;\n let rationale: string | null | undefined = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce<Record<string, DeliveryChoice[]>>((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n // Which choice is correct reaches the browser only once it may show it; delivery reads the flag\n // for the correct-answer view alone.\n if (env.mode !== 'evaluate' && env.role !== 'instructor') {\n choices = Object.fromEntries(\n Object.entries(choices).map(([key, area]) => [key, (area || []).map(({ correct: _correct, ...choice }) => choice)]),\n );\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n return out;\n}\n\nexport const getScore = (\n config: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>,\n session: InlineDropdownSession | null | undefined,\n) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce<string[], number>(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\n\n return parseFloat(str);\n};\n\n/**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment>,\n) => {\n const traceLog: string[] = [];\n const { value = {} } = session || {};\n const allCorrectResponses = getAllCorrectResponses(model);\n const responseAreaKeys = Object.keys(allCorrectResponses);\n const totalAreas = responseAreaKeys.length;\n \n traceLog.push(`${totalAreas} dropdown response area(s) defined in this question.`);\n \n if (value && Object.keys(value).length > 0) {\n const selectedAreas = Object.entries(value).filter(([, val]) => val && val.trim()).length;\n traceLog.push(`Student selected options in ${selectedAreas} out of ${totalAreas} dropdown(s).`);\n \n responseAreaKeys.forEach((areaKey) => {\n const studentSelection = (value && value[areaKey]) || '';\n const correctOptions = allCorrectResponses[areaKey] || [];\n \n if (studentSelection.trim()) {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: student selected '${studentSelection}' (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n } else {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: no selection made (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n }\n });\n } else {\n traceLog.push('Student did not make any selections in the dropdowns.');\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n traceLog.push(\n `Scoring method: ${\n partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'\n }.`\n );\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment> = {},\n) {\n return new Promise<{ score: number; empty: boolean; traceLog: string[] }>((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n traceLog: ['Student did not make any selections in the dropdowns. Score is 0.'] \n });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n traceLog\n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question: InlineDropdownModel, env: PieEnvironment) => {\n return new Promise<InlineDropdownSession | null>((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value: Record<string, string> = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html: string | undefined) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (\n model: Partial<InlineDropdownModel> = {},\n config: InlineDropdownConfiguration = {},\n) => {\n const { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors: InlineDropdownValidationErrors = {};\n\n (['teacherInstructions', 'prompt', 'rationale'] as const).forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (maxResponseAreas !== undefined && nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be defined at least 1 response area.';\n }\n\n // `Object.keys` throws when the model has no `choices`.\n const allChoices = choices as Choices;\n\n (Object.keys(allChoices) || []).forEach((choiceKey) => {\n if (\n allChoices[choiceKey] &&\n maxResponseAreaChoices !== undefined &&\n allChoices[choiceKey].length > maxResponseAreaChoices\n ) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"mappings":";;AACA,IAAIU,IAAI,OAAO,gBAAgBC,KAAK,GAAG,MAAM;CAC5C,IAAIC,IAAI,CAAC;CACT,KAAK,IAAIC,KAAKF,GAAG,EAAEC,GAAGC,GAAG;EACxB,KAAKF,EAAEE;EACP,YAAY,CAAC;CACd,CAAC;CACD,OAAOC,KAAKJ,EAAEE,GAAG,OAAO,aAAa,EAAE,OAAO,SAAS,CAAC,GAAGA;AAC5D;AAEA,SAASE,EAAE,GAAG;CACb,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,CAAC;AACzD;AACA,SAASF,EAAE,GAAG;CACb,IAAI,IAAI,CAAC,GAAG,CAAC;CACb,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK;EACtC,IAAI,IAAI,KAAK,MAAM,KA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CsB,IAAyC,CAAC;CAEhD;EAAE;EAAuB;EAAU;CAAW,CAAC,CAAW,SAAS,MAAU;EAC3E,AAAItB,EAAOuB,EAAM,EAAE,YAAY,CAACJ,EAAWnD,EAAMuD,EAAM,MACrD,EAAOA,KAAS;CAEpB,CAAC;CAED,IAAMC,MAAsBC,KAAU,GAAA,CAAI,MAAM,gBAAgB,KAAK,CAAC,EAAA,CAAG;CAEzE,AAAIC,MAAqB,KAAA,KAAaF,IAAoBE,IACxD,EAAO,qBAAqB,gBAAgBA,EAAiB,sCACpDF,IAAoB,MAC7B,EAAO,qBAAqB;CAI9B,IAAMG,IAAapE;CAYnB,QAVC,OAAO,KAAKoE,CAAU,KAAK,CAAC,EAAA,CAAG,SAAS,MAAc;EACrD,AACEA,EAAWC,MACXC,MAA2B,KAAA,KAC3BF,EAAWC,EAAU,CAAC,SAASC,MAE/B,EAAO,2BAA2B,gBAAgBA,EAAuB;CAE7E,CAAC,GAEMP;AACT,G"}
1
+ {"version":3,"file":"index.js","names":["defaults","reduce","map","lockChoices","getShuffledChoices","isEmpty","partialScoring","Gn","hn","An","e","t","r","i","n","a","s","o","c","defaults_default","getAllCorrectResponses","correctAnswers","choices","key","respArea","choice","alternateResponse","getFeedback","correct","normalize","question","model","normalizedQuestion","session","area","obj","feedback","env","allCorrectResponses","respAreaLength","correctResponses","result","answer","value","correctChoice","isCorrect","shuffledValues","keys","us","part","update","resolve","storedValues","Cn","updateSession","teacherInstructions","rationale","choicesWillNullRationales","currentValue","acc","_correct","getScore","maxScore","config","correctCount","total","str","getLogTrace","traceLog","responseAreaKeys","totalAreas","selectedAreas","val","studentSelection","areaKey","correctOptions","opt","partialScoringEnabled","score","outcome","createCorrectResponseSession","correctChoices","getContent","html","validate","errors","field","nbOfResponseAreas","markup","maxResponseAreas","allChoices","choiceKey","maxResponseAreaChoices","piePackage","\"name\"","\"version\""],"sources":["../../../../../../shared/controller-utils/dist/index.js","../../../../src/controller/defaults.ts","../../../../src/controller/utils.ts","../../../../src/controller/index.ts"],"sourcesContent":["// \\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// 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// 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// ../../../node_modules/.bun/@pie-players+pie-language-tags@1.0.0-beta.9/node_modules/@pie-players/pie-language-tags/dist/index.js\nfunction l(e) {\n\treturn e ? e.trim().replace(/_/g, \"-\") : \"\";\n}\nfunction u(e) {\n\tlet t = l(e).split(/[.@]/)[0];\n\tif (/^[a-z]{2,3}(-|$)/i.test(t)) try {\n\t\treturn Intl.getCanonicalLocales(t)[0];\n\t} catch {\n\t\treturn;\n\t}\n}\n// src/response-normalizer.ts\nvar d = /[\\u061C\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069\\u0640]/g, f = /[\\uFB50-\\uFDFF\\uFE70-\\uFEFC]+/g, p = /\\p{Nd}/u, m = /(?![0-9])\\p{Nd}/gu, h = /\\u066B/g, g = /\\u066C/g, _ = /[0-9]+(?:(?:[.,]|\\{,\\})[0-9]+)*(?:(?:,|\\{,\\})(?=\\\\overline))?/g, v = /[.,]|\\{,\\}/g, y = /(?<!\\\\|&(?:[a-zA-Z][a-zA-Z0-9]*|#[0-9]+|#[xX][0-9a-fA-F]+));/g, b = (e) => {\n\tlet t = e.match(v) ?? [];\n\treturn t.length === 1 && t[0] !== \".\" ? e.replace(v, \".\") : e;\n}, x = new Set(\"af az be bg br bs ca cs cv da de el eo es et eu ff fi fo fr fy gl hr hu hy ia id ie is it jv ka kk kl ku ky lb ln lo lt lu lv mk nb nl nn no oc os pl ps pt rm rn ro ru rw sc se sg sk sl sq sr su sv tg tk tr tt uk uz vi wo\".split(\" \")), S = {\n\tar: [\n\t\t\"DZ\",\n\t\t\"LB\",\n\t\t\"LY\",\n\t\t\"MA\",\n\t\t\"MR\",\n\t\t\"TN\"\n\t],\n\tde: [\"CH\", \"LI\"],\n\ten: \"AT BE CZ DE DK EE ES FI FR GE HU ID IT LT LV NL NO PL PT RO SE SI SK UA ZA\".split(\" \"),\n\tes: \"419 BR BZ CU DO GT HN MX NI PA PE PR SV US\".split(\" \"),\n\tit: [\"CH\"],\n\tkk: [\"CN\"],\n\tku: [\"IQ\"],\n\tms: [\"BN\", \"ID\"],\n\tqu: [\"BO\"],\n\tsw: [\"CD\"]\n}, C = /[\\u0622\\u0623\\u0625\\u0671]/g, w = /[\\u064B-\\u065F\\u0670]/g, T = /* @__PURE__ */ new Map(), E = (e) => {\n\tlet t = T.get(e);\n\tif (t !== void 0) return t;\n\tlet n = 0;\n\tfor (; p.test(String.fromCodePoint(e - n - 1));) n++;\n\tlet r = n % 10;\n\treturn T.set(e, r), r;\n}, D = (e) => e.replace(m, (e) => String(E(e.codePointAt(0)))), O = {\n\tdecimal: \".\",\n\tgroup: \",\"\n}, k = /* @__PURE__ */ new Map(), A = (e) => {\n\tif (!e) return O;\n\tlet t = k.get(e);\n\tif (t) return t;\n\tlet n = O;\n\ttry {\n\t\tif (Intl.NumberFormat.supportedLocalesOf(e).length > 0) {\n\t\t\tlet t = new Intl.NumberFormat(e, { numberingSystem: \"latn\" }).formatToParts(12345.6);\n\t\t\tn = {\n\t\t\t\tdecimal: t.find((e) => e.type === \"decimal\")?.value ?? \".\",\n\t\t\t\tgroup: t.find((e) => e.type === \"group\")?.value ?? \",\"\n\t\t\t};\n\t\t}\n\t} catch {}\n\treturn k.set(e, n), n;\n}, j = (e) => {\n\tif (!e) return !1;\n\ttry {\n\t\tlet { language: t, region: n } = new Intl.Locale(e);\n\t\treturn n ? x.has(t) !== (S[t]?.includes(n) ?? !1) : !1;\n\t} catch {\n\t\treturn !1;\n\t}\n}, M = /* @__PURE__ */ new Set([\n\t\"und\",\n\t\"zxx\",\n\t\"mul\",\n\t\"mis\"\n]), N = (e) => {\n\tlet t = u(e);\n\treturn t && !M.has(t.split(\"-\")[0]) ? t : void 0;\n}, P = (e, t, n) => {\n\tlet r = [e?.language, t?.locale];\n\tfor (let e of r) {\n\t\tlet t = typeof e == \"string\" ? n(e) : void 0;\n\t\tif (t) return t;\n\t}\n}, F = (e, t) => P(e, t, N), I = (e, t) => P(e, t, (e) => N(e.includes(\"_\") ? e.slice(0, e.indexOf(\"_\")) : e)), L = /^(tr|az)(-|$)/i, R = (e, t) => {\n\tif (!t || !L.test(t)) return e.toLowerCase();\n\ttry {\n\t\treturn e.toLocaleLowerCase(t);\n\t} catch {\n\t\treturn e.toLowerCase();\n\t}\n}, z = (e, t = {}) => {\n\tlet n = t.latexNumbers ? O : A(t.language), r = (t.ignoreCase ? R(e, t.language) : e).replace(d, \"\").replace(f, (e) => e.normalize(\"NFKC\")).normalize(\"NFC\");\n\treturn r = D(r), t.latexNumbers && j(t.language) && (r = r.replace(_, b).replace(y, \", \")), r = r.replace(h, n.decimal).replace(g, n.group), t.foldLetterVariants && (r = r.replace(w, \"\").replace(C, \"ا\").replace(/\\u0629/g, \"ه\").replace(/\\u0649/g, \"ي\")), t.ignoreAccents && (r = r.normalize(\"NFD\").replace(/[\\u0300-\\u036F]/g, \"\").normalize(\"NFC\")), t.collapseWhitespace && (r = r.replace(/\\s+/g, \" \").trim()), t.ignoreSlashSpacing && (r = r.replace(/\\s*\\/\\s*/g, \"/\")), r;\n};\nexport { F as contentLanguage, R as foldCase, D as foldDigits, a as getShuffledChoices, o as lockChoices, I as mathContentLanguage, z as normalizeResponse, s as partialScoring };\n","import type { InlineDropdownModel } from '../types.js';\n\nexport default {\n alternateResponse: {},\n choiceRationaleEnabled: true,\n choices: {},\n disabled: false,\n displayType: 'block',\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n shuffle: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n} satisfies Omit<InlineDropdownModel, 'id' | 'element'>;\n","import { forEach } from '@pie-element/shared-lodash';\nimport type { Choice, InlineDropdownModel } from '../types.js';\n\nexport const getAllCorrectResponses = ({\n choices,\n alternateResponse,\n}: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers: Record<string, string[]> = {};\n\n forEach<Choice[]>(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n","import { isEmpty, map, reduce } from '@pie-element/shared-lodash';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-element/shared-controller-utils';\nimport type { PieEnvironment, PieUpdateSession } from '@pie-element/shared-types';\nimport defaults from './defaults.js';\n\nimport { getAllCorrectResponses } from './utils.js';\nimport type {\n Choice,\n Choices,\n InlineDropdownConfiguration,\n InlineDropdownModel,\n InlineDropdownSession,\n} from '../types.js';\n\n/** Errors `validate()` reports, keyed by field. */\nexport type InlineDropdownValidationErrors = {\n teacherInstructions?: string;\n prompt?: string;\n rationale?: string;\n responseAreasError?: string;\n responseAreaChoicesError?: string;\n};\n\n/** A choice as the controller hands it to the delivery: rationales are `null` unless the instructor sees them */\ntype DeliveryChoice = Omit<Choice, 'rationale'> & { rationale?: string | null };\n\nconst getFeedback = (correct: unknown) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question: InlineDropdownModel) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(\n question: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: PieEnvironment,\n updateSession?: PieUpdateSession,\n) {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce<Choice[], Record<string, DeliveryChoice[] | undefined>>(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback: Record<string, string> = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce<string[], { correctResponses: number; feedback: Record<string, string> }>(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n // `lockChoices` ignores the session, so the per-area `shuffledValues` shape does not matter to it.\n const lockChoiceOrder = lockChoices(normalizedQuestion, session as Parameters<typeof lockChoices>[1], env);\n\n if (!lockChoiceOrder) {\n const shuffledValues: Record<string, string[]> = {};\n const keys = Object.keys(choices);\n\n const us =\n (part: string): PieUpdateSession =>\n (_id, _element, update) => {\n return new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues as string[];\n resolve();\n });\n };\n\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n const storedValues = (session?.shuffledValues as Record<string, string[]> | undefined)?.[key];\n\n choices[key] = await getShuffledChoices(\n choices[key] as DeliveryChoice[],\n // the shuffledValues structure was updated to an object like { choice_key: [] }\n // and we need to override shuffledValues if it's not an array\n { shuffledValues: Array.isArray(storedValues) ? storedValues : [] },\n us(key),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (session && updateSession && typeof updateSession === 'function') {\n updateSession(session.id as string, session.element as string, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n }\n\n let teacherInstructions: string | null | undefined = null;\n let rationale: string | null | undefined = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce<Record<string, DeliveryChoice[]>>((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n // Which choice is correct reaches the browser only once it may show it; delivery reads the flag\n // for the correct-answer view alone.\n if (env.mode !== 'evaluate' && env.role !== 'instructor') {\n choices = Object.fromEntries(\n Object.entries(choices).map(([key, area]) => [key, (area || []).map(({ correct: _correct, ...choice }) => choice)]),\n );\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n return out;\n}\n\nexport const getScore = (\n config: Partial<Pick<InlineDropdownModel, 'choices' | 'alternateResponse'>>,\n session: InlineDropdownSession | null | undefined,\n) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce<string[], number>(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\n\n return parseFloat(str);\n};\n\n/**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment>,\n) => {\n const traceLog: string[] = [];\n const { value = {} } = session || {};\n const allCorrectResponses = getAllCorrectResponses(model);\n const responseAreaKeys = Object.keys(allCorrectResponses);\n const totalAreas = responseAreaKeys.length;\n \n traceLog.push(`${totalAreas} dropdown response area(s) defined in this question.`);\n \n if (value && Object.keys(value).length > 0) {\n const selectedAreas = Object.entries(value).filter(([, val]) => val && val.trim()).length;\n traceLog.push(`Student selected options in ${selectedAreas} out of ${totalAreas} dropdown(s).`);\n \n responseAreaKeys.forEach((areaKey) => {\n const studentSelection = (value && value[areaKey]) || '';\n const correctOptions = allCorrectResponses[areaKey] || [];\n \n if (studentSelection.trim()) {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: student selected '${studentSelection}' (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n } else {\n traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: no selection made (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);\n }\n });\n } else {\n traceLog.push('Student did not make any selections in the dropdowns.');\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n traceLog.push(\n `Scoring method: ${\n partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'\n }.`\n );\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n}\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(\n model: InlineDropdownModel,\n session: InlineDropdownSession | null | undefined,\n env: Partial<PieEnvironment> = {},\n) {\n return new Promise<{ score: number; empty: boolean; traceLog: string[] }>((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n traceLog: ['Student did not make any selections in the dropdowns. Score is 0.'] \n });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n traceLog\n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question: InlineDropdownModel, env: PieEnvironment) => {\n return new Promise<InlineDropdownSession | null>((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value: Record<string, string> = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html: string | undefined) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (\n model: Partial<InlineDropdownModel> = {},\n config: InlineDropdownConfiguration = {},\n) => {\n const { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors: InlineDropdownValidationErrors = {};\n\n (['teacherInstructions', 'prompt', 'rationale'] as const).forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (maxResponseAreas !== undefined && nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be defined at least 1 response area.';\n }\n\n // `Object.keys` throws when the model has no `choices`.\n const allChoices = choices as Choices;\n\n (Object.keys(allChoices) || []).forEach((choiceKey) => {\n if (\n allChoices[choiceKey] &&\n maxResponseAreaChoices !== undefined &&\n allChoices[choiceKey].length > maxResponseAreaChoices\n ) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"mappings":";;AACA,IAAIU,IAAI,OAAO,gBAAgBC,KAAK,GAAG,MAAM;CAC5C,IAAIC,IAAI,CAAC;CACT,KAAK,IAAIC,KAAKF,GAAG,EAAEC,GAAGC,GAAG;EACxB,KAAKF,EAAEE;EACP,YAAY,CAAC;CACd,CAAC;CACD,OAAOC,KAAKJ,EAAEE,GAAG,OAAO,aAAa,EAAE,OAAO,SAAS,CAAC,GAAGA;AAC5D;AAEA,SAASE,EAAE,GAAG;CACb,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,CAAC;AACzD;AACA,SAASF,EAAE,GAAG;CACb,IAAI,IAAI,CAAC,GAAG,CAAC;CACb,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK;EACtC,IAAI,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;EAC1C,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE;CAC3B;CACA,OAAO;AACR;AACA,SAASC,EAAE,GAAG;CACb,OAAO,KAAK,OAAO,CAAC,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,WAAW,IAAI,OAAO,KAAK,YAAY,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW;AAC/G;AACA,eAAeE,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS;CACtC,IAAIC,IAAIF,EAAE,GAAG,MAAM,kBAAkB,GAAG,k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,KAAaF,IAAoBE,IACxD,EAAO,qBAAqB,gBAAgBA,EAAiB,sCACpDF,IAAoB,MAC7B,EAAO,qBAAqB;CAI9B,IAAMG,IAAapE;CAYnB,QAVC,OAAO,KAAKoE,CAAU,KAAK,CAAC,EAAA,CAAG,SAAS,MAAc;EACrD,AACEA,EAAWC,MACXC,MAA2B,KAAA,KAC3BF,EAAWC,EAAU,CAAC,SAASC,MAE/B,EAAO,2BAA2B,gBAAgBA,EAAuB;CAE7E,CAAC,GAEMP;AACT,G"}
@@ -1477,7 +1477,7 @@ var kt = d, Z = kt.default, Q = Z && typeof Z == "object" ? Z : kt, At = X(o, "U
1477
1477
  }
1478
1478
  }, Bt = Object.freeze({
1479
1479
  name: "@pie-element/inline-dropdown",
1480
- version: "11.0.8-next.20261110124518"
1480
+ version: "11.0.8-next.20261110132055"
1481
1481
  });
1482
1482
  export { zt as default, Bt as piePackage };
1483
1483
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://cdn.jsdelivr.net/npm/@pie-element/inline-dropdown@11.0.8-next.20261110124518/dist/schemas/configuration.schema.json",
3
+ "$id": "https://cdn.jsdelivr.net/npm/@pie-element/inline-dropdown@11.0.8-next.20261110132055/dist/schemas/configuration.schema.json",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "baseInputConfiguration": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://cdn.jsdelivr.net/npm/@pie-element/inline-dropdown@11.0.8-next.20261110124518/dist/schemas/model.schema.json",
3
+ "$id": "https://cdn.jsdelivr.net/npm/@pie-element/inline-dropdown@11.0.8-next.20261110132055/dist/schemas/model.schema.json",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "id": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://cdn.jsdelivr.net/npm/@pie-element/inline-dropdown@11.0.8-next.20261110124518/dist/schemas/session.schema.json",
3
+ "$id": "https://cdn.jsdelivr.net/npm/@pie-element/inline-dropdown@11.0.8-next.20261110132055/dist/schemas/session.schema.json",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "id": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/inline-dropdown",
3
- "version": "11.0.8-next.20261110124518",
3
+ "version": "11.0.8-next.20261110132055",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -13,7 +13,7 @@
13
13
  "@mui/icons-material": "^7.3.4",
14
14
  "@mui/material": "^7.3.4",
15
15
  "@pie-element/shared-configure-events": "0.1.3-next.20261110072702",
16
- "@pie-element/shared-controller-utils": "0.1.5-next.20261110072702",
16
+ "@pie-element/shared-controller-utils": "0.1.5-next.20261110132055",
17
17
  "@pie-element/shared-i18n": "0.1.3-next.20261110124518",
18
18
  "@pie-element/shared-lodash": "0.1.4-next.20261110072702",
19
19
  "@pie-element/shared-math-rendering-mathjax": "0.1.9-next.20261110072702",