@citolab/qti-components 10.0.0-next.3 → 10.0.0-next.30

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.
Files changed (94) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +4334 -2688
  3. package/dist/base.d.ts +39 -13
  4. package/dist/base.js +14 -1
  5. package/dist/{chunk-D3BYGEQU.js → chunk-2ZT47EUK.js} +117 -92
  6. package/dist/chunk-2ZT47EUK.js.map +1 -0
  7. package/dist/{chunk-RU6332MD.js → chunk-566LB3G2.js} +4 -4
  8. package/dist/{chunk-MI7774NV.js → chunk-5BP2A7BI.js} +2 -2
  9. package/dist/{chunk-OQDBARD5.js → chunk-5KNTKBP6.js} +2 -2
  10. package/dist/chunk-7ISPUOJG.js +209 -0
  11. package/dist/chunk-7ISPUOJG.js.map +1 -0
  12. package/dist/{chunk-GBZNFSFY.js → chunk-ADTCTKXS.js} +2 -2
  13. package/dist/{chunk-FD4AB6TM.js → chunk-BBP7QV32.js} +2 -2
  14. package/dist/{chunk-LFVPS7KB.js → chunk-CFTWXYBO.js} +2 -2
  15. package/dist/{chunk-35WWWFS6.js → chunk-DAESCCLR.js} +2 -2
  16. package/dist/chunk-DJ7PB252.js +7 -0
  17. package/dist/chunk-DJ7PB252.js.map +1 -0
  18. package/dist/{chunk-6U3YPHXU.js → chunk-GAPMCYR5.js} +277 -154
  19. package/dist/chunk-GAPMCYR5.js.map +1 -0
  20. package/dist/{chunk-TDWJ6WZA.js → chunk-GPC53O7P.js} +166 -10
  21. package/dist/chunk-GPC53O7P.js.map +1 -0
  22. package/dist/{chunk-6K3QWJHH.js → chunk-LPYZVKHX.js} +48 -7
  23. package/dist/chunk-LPYZVKHX.js.map +1 -0
  24. package/dist/{chunk-TLAVOBEM.js → chunk-O2XRZPKA.js} +356 -62
  25. package/dist/chunk-O2XRZPKA.js.map +1 -0
  26. package/dist/chunk-PZ5AY32C.js +10 -0
  27. package/dist/chunk-PZ5AY32C.js.map +1 -0
  28. package/dist/{chunk-RSMYGGQK.js → chunk-TZCOXFPB.js} +1590 -610
  29. package/dist/chunk-TZCOXFPB.js.map +1 -0
  30. package/dist/chunk-UCXLDQYA.js +56 -0
  31. package/dist/chunk-UCXLDQYA.js.map +1 -0
  32. package/dist/chunk-WWY2H2YO.js +7 -0
  33. package/dist/chunk-WWY2H2YO.js.map +1 -0
  34. package/dist/{chunk-SIE3E4FG.js → chunk-YRR6D6UP.js} +753 -2095
  35. package/dist/chunk-YRR6D6UP.js.map +1 -0
  36. package/dist/computed.types.d-BPzPFX3Z.d.ts +91 -0
  37. package/dist/{config.context.d-BvU9r-Mg.d.ts → config.context.d-Dm11aAuw.d.ts} +21 -3
  38. package/dist/corrections.d.ts +137 -24
  39. package/dist/corrections.js +12 -12
  40. package/dist/corrections.js.map +1 -1
  41. package/dist/elements.d.ts +66 -73
  42. package/dist/elements.js +9 -6
  43. package/dist/index.d.ts +21 -17
  44. package/dist/index.js +50 -61
  45. package/dist/interactions.d.ts +98 -19
  46. package/dist/interactions.js +8 -3
  47. package/dist/item.css +1948 -1946
  48. package/dist/item.d.ts +8 -6
  49. package/dist/item.js +6 -5
  50. package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
  51. package/dist/loader.d.ts +5 -3
  52. package/dist/loader.js +3 -2
  53. package/dist/processing.d.ts +19 -7
  54. package/dist/processing.js +4 -3
  55. package/dist/public-events.d-3dGip9pd.d.ts +105 -0
  56. package/dist/qti-components-jsx.d.ts +1725 -1777
  57. package/dist/{qti-condition-expression.d-VJH6cWxf.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
  58. package/dist/{qti-expression.d-BPxEp8HU.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
  59. package/dist/{qti-feedback.d-wMYNVkkj.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +8 -1
  60. package/dist/{qti-item.d-DgC1AQbY.d.ts → qti-item.d-CxP6KtCH.d.ts} +3 -2
  61. package/dist/{qti-rule-base.d-Bdzg8eGH.d.ts → qti-rule-base.d-CeKP0Ooi.d.ts} +2 -2
  62. package/dist/qti-test-state-ybQ6ausy.d.ts +81 -0
  63. package/dist/qti-test-state.d-CjvdranT.d.ts +61 -0
  64. package/dist/{qti-test.d-86TlaMlI.d.ts → qti-test.d-BbtCG7A-.d.ts} +91 -487
  65. package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-m0EFv9no.d.ts} +221 -73
  66. package/dist/{qti-transform-test.d-BL7GGFJj.d.ts → qti-transform-test.d-CtNaWJr8.d.ts} +9 -0
  67. package/dist/{interaction.d-g6XG0T0Z.d.ts → record.d-N1Bq7e1f.d.ts} +67 -4
  68. package/dist/{session.context.d-D5080LVx.d.ts → session.context.d-9gRdGK4T.d.ts} +7 -1
  69. package/dist/test-plugin-api.d.ts +143 -0
  70. package/dist/test-plugin-api.js +21 -0
  71. package/dist/test-plugin-api.js.map +1 -0
  72. package/dist/test.d.ts +72 -57
  73. package/dist/test.js +22 -48
  74. package/dist/transformers.d.ts +1 -1
  75. package/dist/transformers.js +2 -1
  76. package/dist/{item.types.d-B55QkJ92.d.ts → variables.d-DWHlTszN.d.ts} +8 -24
  77. package/package.json +16 -11
  78. package/dist/chunk-6K3QWJHH.js.map +0 -1
  79. package/dist/chunk-6U3YPHXU.js.map +0 -1
  80. package/dist/chunk-D3BYGEQU.js.map +0 -1
  81. package/dist/chunk-RSMYGGQK.js.map +0 -1
  82. package/dist/chunk-SIE3E4FG.js.map +0 -1
  83. package/dist/chunk-TDWJ6WZA.js.map +0 -1
  84. package/dist/chunk-TLAVOBEM.js.map +0 -1
  85. package/dist/chunk-ZP6QQYSU.js +0 -7
  86. package/dist/chunk-ZP6QQYSU.js.map +0 -1
  87. package/dist/computed.types.d-gJrBeUMG.d.ts +0 -42
  88. /package/dist/{chunk-RU6332MD.js.map → chunk-566LB3G2.js.map} +0 -0
  89. /package/dist/{chunk-MI7774NV.js.map → chunk-5BP2A7BI.js.map} +0 -0
  90. /package/dist/{chunk-OQDBARD5.js.map → chunk-5KNTKBP6.js.map} +0 -0
  91. /package/dist/{chunk-GBZNFSFY.js.map → chunk-ADTCTKXS.js.map} +0 -0
  92. /package/dist/{chunk-FD4AB6TM.js.map → chunk-BBP7QV32.js.map} +0 -0
  93. /package/dist/{chunk-LFVPS7KB.js.map → chunk-CFTWXYBO.js.map} +0 -0
  94. /package/dist/{chunk-35WWWFS6.js.map → chunk-DAESCCLR.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../qti-elements/src/components/qti-assessment-item/qti-assessment-item.ts","../../qti-elements/src/components/qti-assessment-stimulus/qti-assessment-stimulus.ts","../../qti-elements/src/components/qti-assessment-stimulus/qti-assessment-stimulus.styles.ts","../../qti-elements/src/components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref.ts","../../qti-elements/src/components/qti-companion-materials-info/qti-companion-materials-info.ts","../../qti-elements/src/components/qti-content-body/qti-content-body.ts","../../qti-elements/src/components/qti-context-declaration/qti-context-declaration.ts","../../qti-elements/src/components/qti-custom-operator/qti-custom-operator.ts","../../qti-elements/src/components/qti-feedback-block/qti-feedback-block.ts","../../qti-elements/src/internal/feedback-events.ts","../../qti-elements/src/components/qti-feedback-inline/qti-feedback-inline.ts","../../qti-elements/src/components/qti-item-body/qti-item-body.ts","../../qti-elements/src/components/qti-item-body/qti-item-body.styles.ts","../../qti-elements/src/components/qti-modal-feedback/qti-modal-feedback.ts","../../qti-elements/src/components/qti-outcome-declaration/qti-outcome-declaration.ts","../../qti-elements/src/components/qti-response-declaration/qti-response-declaration.ts","../../qti-elements/src/components/qti-response-processing/qti-response-processing.ts","../../qti-elements/src/internal/template-strings.ts","../../qti-elements/src/components/qti-rubric-block/qti-rubric-block.ts","../../qti-elements/src/components/qti-stylesheet/qti-stylesheet.ts","../../qti-elements/src/components/qti-template-constraint/qti-template-constraint.ts","../../qti-elements/src/components/qti-template-declaration/qti-template-declaration.ts","../../qti-elements/src/components/qti-template-processing/qti-template-processing.ts","../../qti-elements/src/elements.ts"],"sourcesContent":["import { provide } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { itemContext, itemContextVariables } from '@qti-components/base';\n\nimport { dispatchPublic } from '../../public-events';\n\nimport type { PropertyValues } from 'lit';\nimport type { QtiTemplateProcessing } from '../qti-template-processing/qti-template-processing.js';\nimport type { InteractionChangedDetails, OutcomeEntry, SetOutcomesDetails } from '../../internal/event-types.ts';\nimport type { ResponseInteraction } from '@qti-components/base';\nimport type { RegisteredInteraction } from '@qti-components/base';\nimport type { VariableDeclaration, VariableValue } from '@qti-components/base';\nimport type { OutcomeVariable, ResponseVariable, TemplateVariable } from '@qti-components/base';\nimport type QtiRegisterVariable from '../../internal/events/qti-register-variable.ts';\nimport type { ItemContext } from '@qti-components/base';\n\n/**\n * @summary The qti-assessment-item element contains all the other QTI 3 item structures.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.dltnnj87l0yj\n *\n * @dependency qti-feedback\n * @dependency qti-responseprocessing\n *\n * @event qti-item-context-updated - Emitted when through a user action the itemContext is updated,\n * typically on interaction with the interactions, or calling response processing.\n */\n\n/**\n * What the item needs of its response processing: start a run for an attempt. The result comes\n * back as an event.\n */\ninterface ResponseProcessor {\n processResponse(options: { numAttempts: number }): void;\n}\n\nexport class QtiAssessmentItem extends LitElement {\n #itemTitle: string | undefined;\n #templateProcessing: QtiTemplateProcessing | null = null;\n\n @property({ type: String }) identifier: string = '';\n @property({ type: String }) adaptive: 'true' | 'false' = 'false';\n /*\n * `attribute` spelled out: Lit derives `timedependent` from the property\n * name, while QTI writes `time-dependent`. Without it the attribute never\n * reached the property, so an item declaring `time-dependent=\"true\"` still\n * reported false to `test-navigation`, which reads this to build the computed\n * item context.\n */\n @property({ type: String, attribute: 'time-dependent' }) timeDependent: 'true' | 'false' | null = null;\n\n @property({ type: String })\n override get title(): string {\n return this.#itemTitle;\n }\n override set title(value: string) {\n this.#itemTitle = value;\n this.removeAttribute('title');\n this.setAttribute('data-title', value);\n }\n\n /**\n * Locks the item, for example once it is submitted. Published in the item context, which the\n * interactions inside follow, so the item keeps no list of them to set it on.\n */\n @property({ type: Boolean }) disabled: boolean;\n\n /**\n * Shows the item for reading only. Published in the item context, which the interactions inside\n * follow, so the item keeps no list of them to set it on.\n */\n @property({ type: Boolean }) readonly: boolean;\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n const readonlyChanged = changed.has('readonly') && (this.readonly ?? false) !== (this._context.readonly ?? false);\n const disabledChanged = changed.has('disabled') && (this.disabled ?? false) !== (this._context.disabled ?? false);\n if (readonlyChanged || disabledChanged) {\n this._context = {\n ...this._context,\n ...(readonlyChanged ? { readonly: !!this.readonly } : {}),\n ...(disabledChanged ? { disabled: !!this.disabled } : {})\n };\n }\n }\n\n @provide({ context: itemContext })\n private _context: ItemContext = {\n variables: itemContextVariables\n };\n\n /**\n * Sets the identifier for the assessment item reference if this item is in a test.\n *\n * @param identifier - The identifier for the assessment item reference.\n */\n public set assessmentItemRefId(identifier: string) {\n this._context = { ...this._context, identifier };\n }\n\n public get assessmentItemRefId(): string {\n return this._context.identifier;\n }\n\n /**\n * The item's whole context, declarations included, for reading. `variables` is the trimmed view\n * for hosts; the test needs the declarations too, and used to reach for the private field.\n */\n public get itemContext(): Readonly<ItemContext> {\n return this._context;\n }\n\n public get variables(): VariableValue<string | string[] | null>[] {\n return this._context.variables.map(v => ({\n identifier: v.identifier,\n value: v.value,\n type: v.type,\n // add externalscored, a fixed prop to the test, so the testcontext can read and decide how to score this item\n ...(v.type === 'outcome' && v.identifier === 'SCORE'\n ? { externalScored: (v as OutcomeVariable).externalScored }\n : {})\n }));\n }\n\n public set variables(value: VariableValue<string | string[] | null>[]) {\n if (!Array.isArray(value) || value.some(v => !('identifier' in v))) {\n console.warn('variables property should be an array of VariableDeclaration');\n return;\n }\n const previous = this._context.variables;\n // Recognised by their declaration, or by their own type: a template declaration registers after\n // its first render, so a test restoring on connect can get here before it has.\n const restoredTemplates = value.filter(\n v =>\n v.value !== null &&\n v.value !== undefined &&\n (v.type === 'template' ||\n previous.some(declared => declared.identifier === v.identifier && declared.type === 'template'))\n );\n restoredTemplates.forEach(v =>\n this.#restoredTemplateValues.set(v.identifier, v.value as Readonly<string | string[]>)\n );\n const templatesChanged = restoredTemplates.some(\n v =>\n JSON.stringify(previous.find(declared => declared.identifier === v.identifier)?.value) !==\n JSON.stringify(v.value)\n );\n\n this._context = {\n ...this._context,\n variables: this._context.variables.map(variable => {\n const matchingValue = value.find(v => v.identifier === variable.identifier);\n if (matchingValue) {\n return {\n ...variable,\n ...matchingValue,\n interpolationTable: (variable as OutcomeVariable).interpolationTable,\n matchTable: (variable as OutcomeVariable).matchTable\n };\n }\n return variable;\n })\n };\n\n // Restored after the first processing run: correct responses still follow the values it drew.\n if (this.#templatesProcessed && templatesChanged) {\n this.#runTemplateProcessing();\n }\n\n // The interactions take the answers over from the context, some of them a moment from now, and\n // a different answer can mean a different verdict. Look once they have.\n void this.updateComplete.then(() => this.#revalidate());\n if (this.isConnected) this.#beginFirstAttempt();\n }\n\n public get state(): ItemContext['state'] {\n return this._context.state;\n }\n\n public set state(value: ItemContext['state']) {\n this._context = {\n ...this._context,\n state: value ? { ...value } : undefined\n };\n }\n\n #initialContext: Readonly<ItemContext> = { ...this._context, variables: this._context.variables };\n /**\n * Template values handed in through `variables` — drawn in an earlier visit or session. Template\n * processing keeps them instead of drawing again, so the candidate sees the question they\n * answered, and still runs, so correct responses are derived from them.\n */\n #restoredTemplateValues = new Map<string, Readonly<string | string[]>>();\n #templatesProcessed = false;\n /** Registered candidate-input interactions. Correction packages may extend their presentation behavior. */\n protected interactionElements: RegisteredInteraction[] = [];\n\n /** @deprecated use variables property instead */\n set responses(myResponses: ResponseInteraction[]) {\n if (myResponses) {\n for (const response of myResponses) {\n const responseVariable = this.getResponse(response.responseIdentifier);\n if (responseVariable) {\n this.updateResponseVariable(response.responseIdentifier, response.response);\n }\n\n const interaction: RegisteredInteraction | undefined = this.interactionElements.find(\n i => i.getAttribute('response-identifier') === response.responseIdentifier\n );\n if (interaction) {\n interaction.response = response.response;\n }\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n override connectedCallback(): void {\n this.#attachEventListeners();\n super.connectedCallback();\n this.updateComplete.then(() => {\n // The verdict goes in first, so whoever hears the item connect reads it with the rest.\n this.validate(false);\n this.#beginFirstAttempt();\n dispatchPublic(this, 'qc-item-rendered', this);\n // Internal plumbing: the test and the item container listen for this name.\n this.dispatchEvent(\n new CustomEvent<QtiAssessmentItem>('qti-assessment-item-connected', {\n bubbles: true,\n composed: true,\n detail: this\n })\n );\n this.#processTemplates();\n });\n }\n\n override disconnectedCallback(): void {\n this.#removeEventListeners();\n super.disconnectedCallback();\n }\n\n #attachEventListeners() {\n this.addEventListener('qti-register-variable', this.#handleRegisterVariable);\n this.addEventListener('qti-register-interaction', this.#handleRegisterInteraction);\n this.addEventListener('end-attempt', this.#handleEndAttempt);\n this.addEventListener('qc-item-set-outcomes', this.#handleSetOutcomes);\n this.addEventListener('qti-set-template-value', this.#handleSetTemplateValue);\n this.addEventListener('qti-set-correct-response', this.#handleSetCorrectResponse);\n this.addEventListener('qti-interaction-response', this.#handleUpdateResponseVariable);\n }\n\n #removeEventListeners() {\n this.removeEventListener('qti-register-variable', this.#handleRegisterVariable);\n this.removeEventListener('qti-register-interaction', this.#handleRegisterInteraction);\n this.removeEventListener('end-attempt', this.#handleEndAttempt);\n this.removeEventListener('qc-item-set-outcomes', this.#handleSetOutcomes);\n this.removeEventListener('qti-set-template-value', this.#handleSetTemplateValue);\n this.removeEventListener('qti-set-correct-response', this.#handleSetCorrectResponse);\n this.removeEventListener('qti-interaction-response', this.#handleUpdateResponseVariable);\n }\n\n #handleRegisterVariable = (e: QtiRegisterVariable) => {\n e.stopImmediatePropagation();\n const { variable } = e.detail;\n const restored = variable.type === 'template' ? this.#restoredTemplateValues.get(variable.identifier) : undefined;\n const registered = restored !== undefined ? { ...variable, value: restored } : variable;\n this._context = { ...this._context, variables: [...this._context.variables, registered] };\n this.#initialContext = this._context;\n e.stopPropagation();\n };\n\n #handleRegisterInteraction = (e: CustomEvent<{ interaction: string; interactionElement: RegisteredInteraction }>) => {\n e.stopImmediatePropagation();\n this.interactionElements.push(e.detail.interactionElement);\n };\n\n #handleEndAttempt = (e: CustomEvent<{ responseIdentifier: string; countAttempt: boolean }>) => {\n e.stopImmediatePropagation();\n const { responseIdentifier, countAttempt } = e.detail;\n this.validate();\n this.updateResponseVariable(responseIdentifier, 'true');\n this.#processResponse(countAttempt, true, responseIdentifier);\n };\n\n /**\n * Applies the outcomes of a processing run, ours or a backend's, in one update, with the\n * interactions' validity.\n *\n * completionStatus is response processing's to set (QTI info model §2.2.2). When an attempt of a\n * non-adaptive item ends and processing left it `unknown`, the item marks it `completed`: the\n * attempt is done. TAO does the same, and the 1EdTech results-reporting reference results expect\n * it. An adaptive item is completed only by its own processing.\n */\n #handleSetOutcomes = (e: CustomEvent<SetOutcomesDetails>) => {\n e.stopImmediatePropagation();\n const { outcomes = [], responseProcessed = false } = e.detail ?? {};\n const completion: OutcomeEntry[] = [];\n if (responseProcessed && this.adaptive === 'false') {\n const sent = outcomes.find(o => o.identifier === 'completionStatus')?.value;\n if ((sent ?? this.getVariable('completionStatus')?.value) === 'unknown') {\n completion.push({ identifier: 'completionStatus', value: 'completed' });\n }\n }\n this.#applyOutcomes([...outcomes, ...completion], this.#checkValidity(false));\n\n if (responseProcessed) {\n // `responseProcessed` marks this as the end of an attempt (vs. a plain\n // selection, which fires the same event without the flag). Lets listeners\n // react only when an attempt actually ends.\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext; responseProcessed: boolean }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context, responseProcessed: true }\n })\n );\n }\n };\n\n #handleSetTemplateValue = (e: CustomEvent<{ templateIdentifier: string; value: string | string[] | null }>) => {\n e.stopImmediatePropagation();\n const { templateIdentifier, value } = e.detail;\n if (!this.#restoredTemplateValues.has(templateIdentifier)) {\n this.updateTemplateVariable(templateIdentifier, value ?? undefined);\n }\n e.stopPropagation();\n };\n\n #handleSetCorrectResponse = (e: CustomEvent<{ responseIdentifier: string; value: string | string[] | null }>) => {\n e.stopImmediatePropagation();\n const { responseIdentifier, value } = e.detail;\n this.updateCorrectResponse(responseIdentifier, value ?? undefined);\n e.stopPropagation();\n };\n\n #handleUpdateResponseVariable = (e: CustomEvent<ResponseInteraction>) => {\n e.stopImmediatePropagation();\n\n const { responseIdentifier, response, state } = e.detail;\n this.updateResponseVariable(responseIdentifier, response);\n if (state !== undefined) {\n this._context = {\n ...this._context,\n state: {\n ...(this._context.state || {}),\n [responseIdentifier]: state\n }\n };\n }\n\n // The interaction has updated its own validity by now; publish the verdict with the answer.\n this.validate(false);\n\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n };\n\n async #processTemplates(): Promise<void> {\n const templateDeclarations = Array.from(this.querySelectorAll<LitElement>('qti-template-declaration'));\n if (templateDeclarations.length > 0) {\n await Promise.all(templateDeclarations.map(declaration => declaration.updateComplete));\n await Promise.resolve();\n }\n\n this.#templateProcessing = this.querySelector<QtiTemplateProcessing>('qti-template-processing');\n this.#templatesProcessed = true;\n // Run template processing before first presentation\n this.#runTemplateProcessing();\n }\n\n #runTemplateProcessing(): void {\n if (!this.#templateProcessing) return;\n this.#templateProcessing.process();\n this.#initialContext = { ...this._context, variables: this._context.variables };\n }\n\n /**\n * Scores the attempt. The item does not score itself: its response processing does, like a\n * backend, and sends the outcomes back in `qc-item-set-outcomes`, which the item applies in one\n * update. The item keeps the attempt count (QTI info model §2.2.2: the delivery engine maintains\n * numAttempts) and hands the new count to the run, whose rules may read it. Without response\n * processing the item only counts the attempt. A run that throws still counts the attempt and applies\n * no outcomes.\n *\n * @returns whether the item has response processing.\n */\n public processResponse(countNumAttempts = true, reportValidityAfterScoring = true): boolean {\n return this.#processResponse(countNumAttempts, reportValidityAfterScoring);\n }\n\n #processResponse(countNumAttempts: boolean, reportValidity: boolean, endedBy?: string): boolean {\n this.#checkValidity(reportValidity);\n this.#resetOtherEndAttempts(endedBy);\n\n const numAttempts = +this.getVariable('numAttempts')?.value + (countNumAttempts ? 1 : 0);\n const processor = this.querySelector<HTMLElement & Partial<ResponseProcessor>>('qti-response-processing');\n if (typeof processor?.processResponse === 'function') {\n try {\n processor.processResponse({ numAttempts });\n } catch (error) {\n // The attempt started, so it counts (QTI info model §2.2.2), as in TAO and Amp-up; the\n // outcomes of a run that failed are not applied.\n this.#applyOutcomes([{ identifier: 'numAttempts', value: String(numAttempts) }]);\n throw error;\n }\n return true;\n }\n dispatchPublic(this, 'qc-item-set-outcomes', {\n outcomes: [{ identifier: 'numAttempts', value: String(numAttempts) }],\n responseProcessed: true\n });\n return false;\n }\n\n /**\n * QTI info model §2.4.5: when an attempt ends any other way than through an end-attempt\n * interaction, that interaction's response is `false`.\n */\n #resetOtherEndAttempts(endedBy: string | undefined): void {\n const others = Array.from(this.querySelectorAll('qti-end-attempt-interaction'), el =>\n el.getAttribute('response-identifier')\n ).filter(id => id && id !== endedBy);\n if (others.length === 0) return;\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v => (others.includes(v.identifier) ? { ...v, value: 'false' } : v))\n };\n }\n\n public resetResponses() {\n this._context = this.#initialContext;\n if (this.isConnected) this.#beginFirstAttempt();\n }\n\n /**\n * QTI info model §2.2.2: completionStatus is `not_attempted` until the first attempt starts, then\n * `unknown`. The attempt starts when the candidate gets the item, so an item on screen is never\n * `not_attempted` — also not after a reset or a restore that says so.\n */\n #beginFirstAttempt(): void {\n if (this.getVariable('completionStatus')?.value !== 'not_attempted') return;\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v =>\n v.identifier === 'completionStatus' ? { ...v, value: 'unknown' } : v\n )\n };\n }\n\n protected getResponse(identifier: string): Readonly<ResponseVariable> {\n return this.getVariable(identifier) as ResponseVariable;\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n\n protected getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this._context.variables.find(v => v.identifier === identifier) || null;\n }\n\n /** Extension point for presentation packages reacting to a candidate response change. */\n protected afterResponseVariableUpdated(): void {}\n\n // saving privates here: ------------------------------------------------------------------------------\n\n /**\n * Updates the response variable with the specified identifier to the given value.\n *\n * @protected\n *\n * This method is intended for internal use within the class and subclasses.\n * It should not be called externally by third parties.\n *\n * @param identifier - The identifier of the response variable to update.\n * @param value - The new value for the response variable.\n */\n public updateResponseVariable(identifier: string, value: string | string[] | undefined) {\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v => (v.identifier !== identifier ? v : { ...v, value: value }))\n };\n\n this.afterResponseVariableUpdated();\n\n dispatchPublic(this, 'qc-item-response-changed', {\n item: this.identifier,\n responseIdentifier: identifier,\n response: Array.isArray(value) ? [...value] : value\n });\n\n // A different answer can mean a different verdict.\n this.validate(false);\n }\n\n /**\n * Updates the template variable with the specified identifier to the given value.\n */\n public updateTemplateVariable(identifier: string, value: string | string[] | undefined) {\n const templateVariable = this._context.variables.find(v => v.identifier === identifier && v.type === 'template') as\n | TemplateVariable\n | undefined;\n\n if (!templateVariable) {\n console.warn(`Can not set qti-template-identifier: ${identifier}, it is not available`);\n return;\n }\n\n const normalizedValue =\n templateVariable.cardinality === 'single'\n ? Array.isArray(value)\n ? value[0]\n : (value ?? null)\n : value === undefined || value === null\n ? null\n : Array.isArray(value)\n ? value\n : [value];\n\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v =>\n v.identifier !== identifier\n ? v\n : {\n ...v,\n value: normalizedValue\n }\n )\n };\n\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n }\n\n /**\n * Updates the correct response for the specified response variable.\n */\n public updateCorrectResponse(identifier: string, value: string | string[] | undefined) {\n const responseVariable = this.getResponse(identifier);\n\n if (!responseVariable) {\n console.warn(`Can not set correct response for identifier: ${identifier}, it is not available`);\n return;\n }\n\n const normalizedValue =\n responseVariable.cardinality === 'single'\n ? Array.isArray(value)\n ? value[0]\n : (value ?? null)\n : value === undefined || value === null\n ? null\n : Array.isArray(value)\n ? value\n : [value];\n\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v =>\n v.identifier !== identifier\n ? v\n : {\n ...v,\n correctResponse: normalizedValue\n }\n )\n };\n\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n }\n\n public setOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n this.updateOutcomeVariable(identifier, value);\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n }\n\n /**\n * Updates the outcome variable with the specified identifier to the given value.\n *\n * @protected\n *\n * This method is intended for internal use within the class and subclasses.\n * It should not be called externally by third parties.\n *\n * @param identifier - The identifier of the response variable to update.\n * @param value - The new value for the response variable.\n */\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n this.#applyOutcomes([{ identifier, value }]);\n }\n\n /**\n * Publishes the outcomes (and the validity) in one update, then a `qc-item-outcome-changed` per\n * outcome with its final value and one `qc-item-outcomes-changed` with all of them.\n * An identifier the item does not declare is skipped with a warning; a later entry for the same\n * identifier wins.\n */\n #applyOutcomes(outcomes: readonly OutcomeEntry[], valid?: boolean) {\n const values = new Map<string, OutcomeEntry['value']>();\n for (const { identifier, value } of outcomes) {\n const variable = this.getVariable(identifier);\n if (!variable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n continue;\n }\n values.set(identifier, variable.cardinality === 'single' ? value : Array.isArray(value) ? value : [value]);\n }\n const validChanged = valid !== undefined && valid !== this._context.valid;\n if (values.size === 0 && !validChanged) return;\n\n this._context = {\n ...this._context,\n ...(validChanged ? { valid } : {}),\n variables: this._context.variables.map(v =>\n values.has(v.identifier) ? { ...v, value: values.get(v.identifier) as string | string[] | null } : v\n )\n };\n\n if (values.size > 0) {\n for (const [outcomeIdentifier, value] of values) {\n dispatchPublic(this, 'qc-item-outcome-changed', {\n item: this.identifier,\n outcomeIdentifier,\n value: value as string | string[]\n });\n }\n dispatchPublic(this, 'qc-item-outcomes-changed', {\n item: this.identifier,\n outcomes: [...values].map(([identifier, value]) => ({ identifier, value }))\n });\n }\n }\n\n public validate(reportValidity = true): boolean {\n const isValid = this.#checkValidity(reportValidity);\n this.#publishValidity(isValid);\n return isValid;\n }\n\n #checkValidity(reportValidity: boolean): boolean {\n const isValid = this.interactionElements.every(interactionElement => interactionElement.validate());\n if (reportValidity) {\n this.reportValidity();\n }\n return isValid;\n }\n\n /** Puts the verdict in the item context, where the test and anything else can read it. */\n #publishValidity(valid: boolean): void {\n if (this._context.valid !== valid) {\n this._context = { ...this._context, valid };\n }\n }\n\n /**\n * Checks again after something the interactions' validity depends on changed without them saying\n * so (an answer handed in through `variables`), and tells the test if the verdict moved.\n */\n #revalidate(): void {\n const before = this._context.valid;\n this.validate(false);\n if (this._context.valid !== before) {\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n }\n }\n\n public reportValidity() {\n for (const interactionElement of this.interactionElements) {\n interactionElement.reportValidity();\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item': QtiAssessmentItem;\n }\n}\n\ndeclare module '../../public-events' {\n interface PublicItemEventMap {\n /** The item rendered: its interactions are in the DOM and its validity is known. */\n 'qc-item-rendered': CustomEvent<QtiAssessmentItem>;\n }\n}\n","import { html, LitElement } from 'lit';\n\nimport styles from './qti-assessment-stimulus.styles';\n\nimport type { CSSResultGroup } from 'lit';\n\n/**\n * @summary Root of a shared stimulus, placed as a whole wherever the stimulus is rendered.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/info#Root_AssessmentStimulus\n * @status stable\n * @since 4.0\n *\n * Generates no box of its own (`display: contents`), so the stimulus lays out as if only its\n * `qti-stimulus-body` were placed. It is kept in the DOM because it carries the stimulus'\n * `xml:lang` (transformed to `lang`): the content inherits its language from here, which is what\n * text-to-speech and screen readers use to pick a voice.\n *\n * Its QTI `title` is removed on connect: it names the stimulus for authors browsing a repository,\n * and as an HTML `title` it would show as a tooltip over the whole passage and be announced by\n * screen readers.\n *\n * @slot - stimulus content: `qti-stylesheet`, `qti-stimulus-body` and `qti-catalog-info` (hidden).\n */\nexport class QtiAssessmentStimulus extends LitElement {\n static override styles: CSSResultGroup = styles;\n\n override connectedCallback() {\n super.connectedCallback();\n this.removeAttribute('title');\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-stimulus': QtiAssessmentStimulus;\n }\n}\n","import { css } from 'lit';\n\nexport default css`\n :host {\n display: contents;\n }\n\n ::slotted(qti-catalog-info) {\n display: none;\n }\n`;\n","import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { qtiTransformItem } from '@qti-components/transformers';\n\nimport type { QtiAssessmentItem } from '../qti-assessment-item/qti-assessment-item';\n\nexport class QtiAssessmentStimulusRefConnectedEvent extends Event {\n public static eventName = 'qti-assessment-stimulus-ref-connected';\n constructor(\n public element: QtiAssessmentStimulusRef,\n public item: QtiAssessmentItem\n ) {\n super(QtiAssessmentStimulusRefConnectedEvent.eventName, { bubbles: true, composed: true, cancelable: true });\n }\n}\n\n/**\n * Represents a custom element for referencing an assessment stimulus.\n */\n\nexport class QtiAssessmentStimulusRef extends LitElement {\n @property({ type: String }) identifier = '';\n @property({ type: String }) href = '';\n\n /**\n * Lifecycle method called when the element is connected to the DOM.\n * First checks if there's a data-stimulus-idref element. If found, loads the stimulus directly.\n * If not found, delegates to the delivery platform via an event.\n */\n public override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n // VERY important to wait for updateComplete to ensure that the stimulusRef is connected after item\n // for the test-navigation to correctly process everything in order\n await this.updateComplete;\n\n const item = this.closest<QtiAssessmentItem>('qti-assessment-item');\n\n const event = new QtiAssessmentStimulusRefConnectedEvent(this, item);\n this.dispatchEvent(event);\n\n const stimulusRef = item?.querySelector(`[data-stimulus-idref=\"${this.identifier}\"]`);\n if (!event.defaultPrevented && stimulusRef) {\n await this.updateStimulusRef(stimulusRef);\n }\n }\n\n /**\n * Loads and appends the stimulus to the specified element.\n * @param stimulusRef - The element to which the stimulus will be appended.\n */\n public async updateStimulusRef(stimulusRef: Element) {\n const stimulus = await qtiTransformItem()\n .load(this.href)\n .then(api => api.htmlDoc());\n // Place the whole qti-assessment-stimulus, not just its body: its `lang` is what the stimulus\n // content inherits its language from.\n const root = stimulus?.querySelector('qti-assessment-stimulus');\n if (root) {\n stimulusRef.innerHTML = '';\n stimulusRef.append(root);\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-stimulus-ref': QtiAssessmentStimulusRef;\n }\n}\n","import { LitElement } from 'lit';\n\nexport class QtiCompanionMaterialsInfo extends LitElement {\n // static override styles = css`\n // slot {\n // display: hidden;\n // }\n // `;\n // override render() {\n // return html` <slot></slot> `;\n // }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-companion-materials-info': QtiCompanionMaterialsInfo;\n }\n}\n","import { consume } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { itemContext } from '@qti-components/base';\n\nimport type { ItemContext, TemplateVariable } from '@qti-components/base';\n\nexport class QtiContentBody extends LitElement {\n @consume({ context: itemContext, subscribe: true })\n @state()\n protected context?: ItemContext;\n\n override render() {\n return html`<slot @slotchange=${this.#expandMathVariables}></slot>`;\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.updateComplete.then(() => this.#expandMathVariables());\n }\n\n protected override updated(changedProperties: Map<string | number | symbol, unknown>): void {\n if (changedProperties.has('context')) {\n this.#expandMathVariables();\n }\n }\n\n #expandMathVariables(): void {\n const mathVariables = new Map<string, string>();\n const templateVariables = (this.context?.variables ?? []).filter(variable => variable.type === 'template');\n\n for (const variable of templateVariables) {\n const templateVariable = variable as TemplateVariable;\n if (\n templateVariable.mathVariable !== true ||\n templateVariable.value === null ||\n templateVariable.value === undefined\n ) {\n continue;\n }\n\n mathVariables.set(templateVariable.identifier, this.#stringifyValue(templateVariable.value));\n }\n\n if (mathVariables.size === 0) {\n return;\n }\n\n const mathIdentifiers = Array.from(this.querySelectorAll('*')).filter(\n element => element.localName.toLowerCase() === 'mi' || element.localName.toLowerCase() === 'mn'\n );\n\n for (const element of mathIdentifiers) {\n const identifier = element.getAttribute('data-qti-math-variable-source') ?? element.textContent?.trim() ?? '';\n const value = mathVariables.get(identifier);\n\n if (!value) {\n continue;\n }\n\n if (element.localName.toLowerCase() === 'mn') {\n element.textContent = value;\n element.setAttribute('data-qti-math-variable-source', identifier);\n continue;\n }\n\n const replacement = document.createElement('mn');\n replacement.textContent = value;\n replacement.setAttribute('data-qti-math-variable-source', identifier);\n element.replaceWith(replacement);\n }\n }\n\n #stringifyValue(value: string | readonly string[] | number | boolean | null): string {\n if (Array.isArray(value)) {\n return value.join(' ');\n }\n\n return value?.toString() ?? '';\n }\n}\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-content-body': QtiContentBody;\n }\n}\n","import { css, LitElement, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\n/**\n * @summary The qti-context-declaration element declares context variables for an item.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.qti-context-declaration\n */\n\nexport class QtiContextDeclaration extends LitElement {\n @property({ type: String }) identifier: string = '';\n @property({ type: String }) cardinality: 'single' | 'multiple' | 'ordered' | 'record' = 'record';\n\n static override styles = [\n css`\n :host {\n display: none;\n }\n `\n ];\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-context-declaration': QtiContextDeclaration;\n }\n}\n","import { consume } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { getCustomOperator, itemContext } from '@qti-components/base';\n\nimport type { CustomOperatorValue, ResponseVariable } from '@qti-components/base';\nimport type { Calculate } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\n/**\n * https://www.imsglobal.org/spec/qti/v3p0/impl#h.fi29q8dubjgw\n *\n * A custom operator is outside the QTI vocabulary, so what it does is supplied\n * by the delivery engine rather than by the item. Two ways to supply it:\n *\n * `definition` names an operator the host registered with\n * `registerCustomOperator`, or one of the built-ins (`Trim`, `ToAscii`,\n * `ParseCommaDecimal` under the `depcp:`, `questify:` and `qade:` prefixes).\n * The operator is handed the calculated values of the child expressions:\n *\n * ```xml\n * <qti-custom-operator definition=\"depcp:Trim\">\n * <qti-variable identifier=\"RESPONSE\"/>\n * </qti-custom-operator>\n * ```\n *\n * `class=\"js.org\"` instead runs inline JavaScript out of a CDATA section:\n *\n * ```xml\n * <qti-custom-operator class=\"js.org\">\n * <qti-base-value base-type=\"string\"><![CDATA[\n * console.log(context.variables);\n * return 'B'\n * ]]></qti-base-value>\n * </qti-custom-operator>\n * ```\n *\n * `definition` is checked first; the two do not interact.\n */\n\nexport class QtiCustomOperator extends LitElement implements Calculate {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n #operatorFunction: Function;\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n private _context?: ItemContext;\n\n override render() {\n return html`<slot @slotchange=${this.handleSlotChange}></slot>`;\n }\n\n handleSlotChange() {\n // expecting <[!CDATA[ ... ]]> is converted into <!-- ... --> with qti-transform: cDataToComment\n const commentNode = Array.from(this.firstElementChild?.childNodes ?? []).find(\n node => node.nodeType === Node.COMMENT_NODE\n );\n try {\n this.#operatorFunction = new Function('context', 'fn', 'item', commentNode?.textContent ?? '');\n } catch (e) {\n console.error('custom-operator contains invalid javascript code', e);\n }\n }\n\n public calculate() {\n const definition = this.getAttribute('definition');\n if (definition) {\n return this.#applyDefinedOperator(definition);\n }\n\n const fn = {\n variable: (responseIdentifier: string) =>\n this._context?.variables.find(v => v.identifier === responseIdentifier)?.value ?? '',\n correct: (responseIdentifier: string) =>\n (this._context?.variables.find(v => v.identifier === responseIdentifier) as ResponseVariable)\n ?.correctResponse ?? ''\n };\n const item = {\n getVariable: (variableIdentifier: string) =>\n this._context?.variables.find(v => v.identifier === variableIdentifier),\n updateOutcomeVariable: (outcomeIdentifier: string, value: string | string[]) => {\n this.dispatchEvent(\n new CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>('qti-set-outcome-value', {\n bubbles: true,\n composed: true,\n detail: {\n outcomeIdentifier,\n value\n }\n })\n );\n }\n };\n\n return this.#operatorFunction(this._context, fn, item);\n }\n\n /**\n * An operator the host registered, or a built-in. An unknown `definition` is\n * NULL rather than an error: the item names an operator this engine does not\n * provide, which the surrounding expression can still test with\n * `qti-is-null`.\n */\n #applyDefinedOperator(definition: string) {\n const operator = getCustomOperator(definition);\n if (!operator) {\n console.warn(`qti-custom-operator: no operator registered for definition \"${definition}\"`);\n return null;\n }\n\n const values = Array.from(this.children).map(child => {\n const calculate = (child as Partial<Calculate>).calculate;\n return typeof calculate === 'function' ? (calculate.call(child) as CustomOperatorValue) : null;\n });\n\n return operator(values);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-custom-operator': QtiCustomOperator;\n }\n}\n","import { css, html } from 'lit';\n\nimport { QtiFeedback } from '@qti-components/base';\n\nimport { dispatchFeedback } from '../../internal/feedback-events';\n\n/**\n * Block feedback: shown or hidden by the outcome it is bound to.\n *\n * @slot - The feedback content.\n *\n * @csspart feedback - The feedback box.\n */\nexport class QtiFeedbackBlock extends QtiFeedback {\n static override styles = css`\n :host {\n display: block;\n }\n .on {\n display: block;\n }\n .off {\n display: none;\n }\n `;\n\n override render() {\n return html` <slot part=\"feedback\" class=\"feedback ${this.showStatus}\"></slot> `;\n }\n\n /** `qc-feedback-show`: a listener that calls `preventDefault()` keeps this hidden and shows it itself. */\n protected override feedbackShowing(): boolean {\n return dispatchFeedback(this, 'qc-feedback-show', 'block', this.identifier);\n }\n\n protected override feedbackHiding(): boolean {\n return dispatchFeedback(this, 'qc-feedback-hide', 'block', this.identifier);\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.checkShowFeedback(this.outcomeIdentifier);\n }\n}\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-feedback-block': QtiFeedbackBlock;\n }\n}\n","import { dispatchPublic } from '../public-events';\n\nimport type { FeedbackEventDetail } from '../public-events';\n\ninterface FeedbackElement extends Element {\n outcomeIdentifier: string;\n}\n\n/**\n * Send `qc-feedback-show` or `qc-feedback-hide` from a feedback element, just before it shows or\n * hides. Both are cancelable; this returns `false` when the host cancels, i.e. takes over.\n */\nexport function dispatchFeedback(\n element: FeedbackElement,\n name: 'qc-feedback-show' | 'qc-feedback-hide',\n kind: FeedbackEventDetail['kind'],\n identifier: string\n): boolean {\n const itemIdentifier = element.closest('qti-assessment-item')?.getAttribute('identifier') ?? undefined;\n const detail: FeedbackEventDetail = {\n kind,\n identifier,\n outcomeIdentifier: element.outcomeIdentifier,\n element,\n ...(itemIdentifier ? { itemIdentifier } : {})\n };\n return dispatchPublic(element, name, detail, true);\n}\n","import { css, html } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { QtiFeedback } from '@qti-components/base';\n\nimport { dispatchFeedback } from '../../internal/feedback-events';\n\n/**\n * Inline feedback: shown or hidden by the outcome it is bound to.\n *\n * @slot - The feedback content.\n *\n * @csspart feedback - The feedback box.\n */\nexport class QtiFeedbackInline extends QtiFeedback {\n static override styles = css`\n .on {\n display: inline-block;\n }\n .off {\n display: none;\n }\n `;\n\n override render = () => html` <slot part=\"feedback\" class=\"${ifDefined(this.showStatus)}\"></slot> `;\n\n /** `qc-feedback-show`: a listener that calls `preventDefault()` keeps this hidden and shows it itself. */\n protected override feedbackShowing(): boolean {\n return dispatchFeedback(this, 'qc-feedback-show', 'inline', this.identifier);\n }\n\n protected override feedbackHiding(): boolean {\n return dispatchFeedback(this, 'qc-feedback-hide', 'inline', this.identifier);\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.checkShowFeedback(this.outcomeIdentifier);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-feedback-inline': QtiFeedbackInline;\n }\n}\n","import { html, LitElement } from 'lit';\n\nimport styles from './qti-item-body.styles';\n\nimport type { CSSResultGroup } from 'lit';\n\n/**\n * @summary The qti-item-body node contains the text, graphics, media objects and interactions that describe the item's content and information about how it is structured.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.sphpo6lu6zqi\n * @status stable\n * @since 4.0\n *\n * @slot - item body content.\n * @slot qti-rubric-block - the qti rubric block is placed above the item\n *\n * @csspart rubrics - The rubric-block slot (was `qti-rubric-blocks`).\n */\n\nexport class QtiItemBody extends LitElement {\n static override styles: CSSResultGroup = styles;\n\n override render() {\n return html`<slot part=\"rubrics qti-rubric-blocks\" name=\"qti-rubric-block\"></slot><slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-item-body': QtiItemBody;\n }\n}\n","import { css } from 'lit';\n\nexport default css`\n :host {\n display: block;\n }\n`;\n","import { css, html } from 'lit';\n\nimport { QtiFeedback } from '@qti-components/base';\n\nimport { dispatchFeedback } from '../../internal/feedback-events';\n\n/**\n * Modal feedback: a dialog opened by the outcome it is bound to.\n *\n * @slot - The feedback content.\n *\n * @csspart feedback - The feedback box (the dialog).\n */\nexport class QtiModalFeedback extends QtiFeedback {\n static override styles = css`\n .cito-dialog {\n background: var(--qti-bg);\n border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);\n border-radius: var(--qti-border-radius);\n padding: var(--qti-padding-box);\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1000;\n width: auto;\n max-width: 90%;\n }\n\n .button {\n border-radius: var(--qti-border-radius);\n padding: var(--qti-padding-box);\n background-color: var(--qti-bg-active);\n border: var(--qti-border-active);\n cursor: pointer;\n position: relative;\n display: inline-block;\n }\n\n /* Inlined from --qti-disabled-bg / --qti-disabled-color, which this button was the only reader\n of anywhere in the repo. They were named as a global disabled vocabulary but no interaction\n ever used them: the theme's disabled treatment is cursor only (see the note in qti-mixins.css). */\n .button:disabled {\n background-color: transparent;\n color: var(--qti-fg);\n cursor: not-allowed;\n }\n\n .button:focus {\n outline: var(--qti-focus-border-width) solid var(--qti-focus-color);\n }\n `;\n\n override render() {\n return html`\n <dialog class=\"cito-dialog\" part=\"feedback\" ?open=\"${this.showStatus === 'on'}\">\n <slot></slot>\n <div style=\"margin-top: var(--qti-gap); text-align: center;\">\n <button class=\"button close-button\" @click=\"${this.closeFeedback}\">Close</button>\n </div>\n </dialog>\n `;\n }\n\n openFeedback() {\n const dialog = this.shadowRoot?.querySelector('dialog') as HTMLDialogElement | null;\n if (dialog && !dialog.open) {\n dialog.showModal();\n }\n }\n\n closeFeedback() {\n const dialog = this.shadowRoot?.querySelector('dialog') as HTMLDialogElement | null;\n if (dialog && dialog.open) {\n dialog.close();\n this.showStatus = 'off';\n }\n }\n\n /** `qc-feedback-show`: a listener that calls `preventDefault()` keeps this hidden and shows it itself. */\n protected override feedbackShowing(): boolean {\n return dispatchFeedback(this, 'qc-feedback-show', 'modal', this.identifier);\n }\n\n protected override feedbackHiding(): boolean {\n return dispatchFeedback(this, 'qc-feedback-hide', 'modal', this.identifier);\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.showStatus === 'on') {\n this.openFeedback();\n }\n }\n\n protected override updated(changedProperties: Map<string | number | symbol, unknown>): void {\n if (changedProperties.has('showStatus')) {\n if (this.showStatus === 'on') {\n this.openFeedback();\n } else {\n this.closeFeedback();\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-modal-feedback': QtiModalFeedback;\n }\n}\n","import { consume } from '@lit/context';\nimport { css, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { itemContext } from '@qti-components/base';\nimport { QtiVariableDeclaration } from '@qti-components/base';\n\nimport type { BaseType, Cardinality } from '@qti-components/base';\nimport type { InterpolationTableEntry, OutcomeVariable } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\nexport class QtiOutcomeDeclaration extends QtiVariableDeclaration {\n @property({ type: String, attribute: 'base-type' }) baseType: BaseType;\n @property({ type: String, attribute: 'external-scored' }) externalScored: 'human' | 'externalMachine' | null = null;\n @property({ type: String }) identifier: string;\n @property({ type: String }) cardinality: Cardinality;\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n public itemContext?: ItemContext;\n\n static override styles = [\n css`\n :host {\n display: none;\n }\n `\n ];\n\n override render() {\n const value = this.itemContext?.variables.find(v => v.identifier === this.identifier)?.value;\n return html`${JSON.stringify(value, null, 2)}`;\n }\n\n /**\n * The entries of a `qti-interpolation-table`, in document order.\n *\n * Order is load-bearing: each entry's `source-value` is the lower bound of a\n * range, and the lookup takes the first entry whose bound the source value\n * clears. A Map keyed by source value cannot express that.\n */\n get interpolationTable(): InterpolationTableEntry[] | null {\n const table = this.querySelector('qti-interpolation-table');\n if (!table) return null;\n\n const entries: InterpolationTableEntry[] = [];\n for (const entry of table.querySelectorAll('qti-interpolation-table-entry')) {\n const sourceValue = parseFloat(entry.getAttribute('source-value'));\n const targetValue = parseFloat(entry.getAttribute('target-value'));\n if (Number.isNaN(sourceValue) || Number.isNaN(targetValue)) {\n console.error('source-value or target-value is missing or not a number in qti-interpolation-table-entry');\n continue;\n }\n entries.push({\n sourceValue,\n targetValue,\n // The spec's default is true: the bound itself is in range unless the\n // entry says otherwise.\n includeBoundary: entry.getAttribute('include-boundary') !== 'false'\n });\n }\n return entries;\n }\n\n /**\n * A qti-match-table maps a source value onto a target exactly, with no\n * boundaries and no interpolation. Targets keep their authored spelling\n * because a match table is not restricted to numeric outcomes.\n */\n get matchTable(): Map<number, string> | null {\n const table = this.querySelector('qti-match-table');\n if (!table) return null;\n\n const entries = new Map<number, string>();\n for (const entry of table.querySelectorAll('qti-match-table-entry')) {\n const sourceValue = parseFloat(entry.getAttribute('source-value'));\n const targetValue = entry.getAttribute('target-value');\n if (Number.isNaN(sourceValue) || targetValue === null) {\n console.error('source-value or target-value is missing or invalid in qti-match-table-entry');\n continue;\n }\n entries.set(sourceValue, targetValue);\n }\n return entries;\n }\n\n public override connectedCallback() {\n super.connectedCallback();\n\n const defaultValue = this.defaultValues(this.cardinality);\n\n const outcomeVariable: OutcomeVariable = {\n identifier: this.identifier,\n cardinality: this.cardinality,\n baseType: this.baseType,\n defaultValue: defaultValue,\n type: 'outcome',\n value: null,\n interpolationTable: this.interpolationTable,\n matchTable: this.matchTable,\n externalScored: this.externalScored\n };\n // At runtime, outcome variables are instantiated as part of an item session.\n // Their values may be initialized with a default value and/or set during response processing.\n // If no default value is given in the declaration then the outcome variable is initialized to NULL unless the outcome is of a numeric type (integer or float) in which case it is initialized to 0.\n outcomeVariable.value = defaultValue;\n if (\n (outcomeVariable.value === null || outcomeVariable.value == undefined) &&\n (outcomeVariable.baseType === 'integer' || outcomeVariable.baseType === 'float')\n ) {\n outcomeVariable.value = '0';\n }\n this.dispatchEvent(\n new CustomEvent('qti-register-variable', {\n bubbles: true,\n composed: true,\n detail: { variable: outcomeVariable }\n })\n );\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-outcome-declaration': QtiOutcomeDeclaration;\n }\n}\n","import { consume } from '@lit/context';\nimport { css, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { itemContext } from '@qti-components/base';\nimport { QtiVariableDeclaration, readRecordFieldValues } from '@qti-components/base';\n\nimport type { QtiAreaMapping } from '@qti-components/base';\nimport type { BaseType, Cardinality } from '@qti-components/base';\nimport type { RecordValue, ResponseVariable } from '@qti-components/base';\nimport type { QtiMapping } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\nexport class QtiResponseDeclaration extends QtiVariableDeclaration {\n @property({ type: String, attribute: 'base-type' }) baseType: BaseType;\n\n @property({ type: String }) identifier: string;\n\n @property({ type: String }) cardinality: Cardinality;\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n public itemContext?: ItemContext;\n\n static override styles = [\n css`\n :host {\n display: none;\n }\n `\n ];\n\n override render() {\n const value = this.itemContext?.variables.find(v => v.identifier === this.identifier)?.value;\n return html`${JSON.stringify(value, null, 2)}`;\n }\n\n public override connectedCallback() {\n super.connectedCallback();\n // A record value is its field map; the variable types only spell out string | string[].\n const defaultValue =\n this.cardinality === 'record'\n ? (this.#recordDefaultValue as unknown as string | string[] | null)\n : this.defaultValues(this.cardinality);\n const { correctResponse, fieldBaseTypes } = this.#readCorrectResponse();\n\n const responseVariable: ResponseVariable = {\n baseType: this.baseType,\n identifier: this.identifier,\n correctResponse,\n ...(fieldBaseTypes ? { fieldBaseTypes } : {}),\n cardinality: this.cardinality || 'single',\n mapping: this.#mapping,\n defaultValue,\n areaMapping: this.#areaMapping,\n value: null,\n type: 'response',\n candidateResponse: null\n };\n responseVariable.value = defaultValue;\n\n this.dispatchEvent(\n new CustomEvent('qti-register-variable', {\n bubbles: true,\n composed: true,\n detail: { variable: responseVariable }\n })\n );\n }\n\n /**\n * The correct response, and for `record` cardinality the declared base type of each field.\n *\n * A record's correct response is a field map, `{ time: '4.0', point: '460 245' }`, read from\n * `qti-value field-identifier=\"…\" base-type=\"…\"`. The field base types are kept beside it, since\n * the record declaration itself has no `base-type` to say how a field is to be compared.\n */\n #readCorrectResponse(): { correctResponse: string | string[]; fieldBaseTypes?: ResponseVariable['fieldBaseTypes'] } {\n if (this.cardinality !== 'record') {\n return { correctResponse: this.#correctResponse };\n }\n const correctResponse = this.querySelector('qti-correct-response');\n if (!correctResponse) {\n return { correctResponse: undefined };\n }\n const values = Array.from(correctResponse.querySelectorAll('qti-value'));\n const { value, baseTypes } = readRecordFieldValues(values);\n values.forEach(element => element.remove());\n return {\n // The variable types hold string | string[]; a record is stored as its field map.\n correctResponse: (Object.keys(value).length ? value : undefined) as unknown as string | string[],\n fieldBaseTypes: baseTypes\n };\n }\n\n /** A record's `qti-default-value`, as a field map like its correct response. */\n get #recordDefaultValue(): RecordValue | null {\n const values = this.querySelectorAll('qti-default-value > qti-value');\n if (values.length === 0) return null;\n const { value } = readRecordFieldValues(values);\n return Object.keys(value).length ? value : null;\n }\n\n get #correctResponse(): string | string[] {\n let result: string | string[];\n const correctResponse = this.querySelector('qti-correct-response');\n if (correctResponse) {\n const values = correctResponse.querySelectorAll('qti-value');\n if (this.cardinality === 'single' && values.length > 0) {\n result = values[0].textContent.trim();\n values[0].remove();\n } else if (this.cardinality !== 'single') {\n result = [];\n for (let i = 0; i < values.length; i++) {\n result.push(values[i].textContent.trim());\n values[i].remove();\n }\n }\n }\n return result;\n }\n\n get #mapping(): QtiMapping {\n const mappingElement = this.querySelector('qti-mapping');\n const lowerBound = parseFloat(mappingElement?.getAttribute('lower-bound'));\n const uppperBound = parseFloat(mappingElement?.getAttribute('upper-bound'));\n const mappingValue = {\n defaultValue: Number(mappingElement?.getAttribute('default-value')) || 0,\n lowerBound: isNaN(lowerBound) ? null : lowerBound,\n upperBound: isNaN(uppperBound) ? null : uppperBound,\n mapEntries: Array.from(mappingElement?.querySelectorAll('qti-map-entry') || []).map(el => ({\n mapKey: el.getAttribute('map-key') || '',\n mappedValue: Number(el.getAttribute('mapped-value')) || 0,\n caseSensitive: el.hasAttribute('case-sensitive') ? el.getAttribute('case-sensitive') !== 'false' : false\n }))\n };\n return mappingValue;\n }\n\n get #areaMapping(): QtiAreaMapping {\n const areaMappingElement = this.querySelector('qti-area-mapping') as HTMLElement;\n\n const defaultValue = Number(areaMappingElement?.getAttribute('default-value')) || 0;\n const lowerBound = parseFloat(areaMappingElement?.getAttribute('lower-bound'));\n const uppperBound = parseFloat(areaMappingElement?.getAttribute('upper-bound'));\n\n const areaMapEntries = Array.from(areaMappingElement?.querySelectorAll('qti-area-map-entry') || []).map(\n (el: HTMLElement) => ({\n shape: (el.getAttribute('shape') as 'default' | 'circle' | 'rect' | 'ellipse' | 'poly') || 'default',\n coords: el.getAttribute('coords') || '',\n mappedValue: Number(el.getAttribute('mapped-value')) || 0,\n defaultValue: Number(el.getAttribute('default-value')) || 0\n })\n );\n\n return {\n defaultValue,\n lowerBound: isNaN(lowerBound) ? null : lowerBound,\n upperBound: isNaN(uppperBound) ? null : uppperBound,\n areaMapEntries\n };\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-response-declaration': QtiResponseDeclaration;\n }\n}\n","import { ContextConsumer, ContextProvider } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\n\nimport { itemContext, QtiExitResponseSignal, type QtiRuleBase } from '@qti-components/base';\n\nimport { mapResponse, mapResponsePoint, matchCorrect } from '../../internal/template-strings';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ItemContext, OutcomeVariable } from '@qti-components/base';\nimport type { PropertyValueMap } from 'lit';\n\ntype OutcomeValue = string | string[] | null | undefined;\n\n/** The response processing templates we substitute for, keyed by the file name in `template`. */\nconst responseProcessingTemplates: Record<string, string> = {\n map_response: mapResponse,\n map_response_point: mapResponsePoint,\n match_correct: matchCorrect\n};\n\n/**\n * Response processing as the item's own backend: it reads the item context, runs its rules once and\n * sends the outcomes and the attempt count back in one `qc-item-set-outcomes`. The item applies\n * them; a host that scores elsewhere sends the same event instead.\n */\nexport class QtiResponseProcessing extends LitElement {\n static override styles = [\n css`\n :host {\n display: none;\n }\n `\n ];\n\n /**\n * The rules inside read and write this element's copy of the item context, never the item's. It\n * is provided under the same `itemContext`: the nearest provider wins, so every expression in\n * here gets the copy without knowing about it.\n */\n #provider = new ContextProvider(this, { context: itemContext });\n #copy?: ItemContext;\n\n constructor() {\n super();\n new ContextConsumer(this, {\n context: itemContext,\n subscribe: true,\n // Every variable its own object, so a write changes the copy and not the item's context.\n callback: context => {\n this.#copy = { ...context, variables: context.variables.map(v => ({ ...v })) };\n this.#provider.setValue(this.#copy);\n }\n });\n // Every rule that sets an outcome sits in here: the write lands in the copy, so a later rule\n // reads it, and never reaches the item (or the test above it, whose outcome processing listens\n // for the same name).\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: OutcomeValue }>) => {\n e.stopImmediatePropagation();\n const variable = this.#copy?.variables.find(v => v.identifier === e.detail.outcomeIdentifier);\n if (!variable) {\n console.warn(`Can not set qti-outcome-identifier: ${e.detail.outcomeIdentifier}, it is not available`);\n return;\n }\n const { value } = e.detail;\n variable.value = variable.cardinality === 'single' ? value : Array.isArray(value) ? value : [value];\n }\n );\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /**\n * Scores the attempt on the copy: sets `numAttempts` to the count the item hands over, resets a\n * non-adaptive item's outcomes to their defaults (QTI info model §2.5), runs the rules and sends\n * every outcome and `numAttempts` in one `qc-item-set-outcomes`. The item applies them and publishes, which gives this element a\n * fresh copy. A rule that throws ends the run and the error propagates; nothing is sent, and the\n * run's writes stay in the copy until the item's next update.\n */\n public processResponse({ numAttempts }: { numAttempts: number }): void {\n const copy = this.#copy;\n if (!copy) return;\n const reset = this.closest('qti-assessment-item')?.getAttribute('adaptive') !== 'true';\n for (const variable of copy.variables) {\n if (variable.identifier === 'numAttempts') variable.value = String(numAttempts);\n // completionStatus is built in: it has no default to reset to, and keeps its value (as in TAO).\n if (variable.type === 'outcome' && reset && variable.identifier !== 'completionStatus') {\n variable.value = defaultValueOf(variable as OutcomeVariable);\n }\n }\n\n this.#runRules();\n\n dispatchPublic(this, 'qc-item-set-outcomes', {\n outcomes: copy.variables\n .filter(v => v.type === 'outcome' || v.identifier === 'numAttempts')\n .map(({ identifier, value }) => ({ identifier, value })),\n responseProcessed: true\n });\n }\n\n #runRules() {\n const rules = [...this.children] as unknown as QtiRuleBase[];\n try {\n for (const rule of rules) {\n rule.process();\n }\n } catch (error) {\n // `qti-exit-response` ends the attempt's processing from wherever it\n // sits, however deeply nested. Reaching here is the rule doing its job,\n // so the run simply stops; anything else is a real failure and rethrows.\n if (!(error instanceof QtiExitResponseSignal)) throw error;\n }\n }\n\n public override firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {\n const template = this.getAttribute('template');\n if (!template) return;\n\n const templateName = template.split('/').pop()!.replace('.xml', '');\n const rules = responseProcessingTemplates[templateName];\n // Leave an unknown template's authored children alone; there is nothing to substitute.\n if (!rules) return;\n\n // Parsed through this element's own `innerHTML` rather than a fragment created off `document`:\n // the HTML fragment parsing algorithm takes its custom element registry from the context\n // element, so the rules are upgraded with the registry this element lives in. A fragment from\n // `document.createRange()` is parsed against the global registry, which leaves every rule an\n // unupgraded HTMLElement when the item was rendered into a scoped registry.\n this.innerHTML = rules;\n }\n}\n\n/** The declared default; a numeric outcome without one starts at 0. */\nfunction defaultValueOf(variable: OutcomeVariable): OutcomeValue {\n const value = ('defaultValue' in variable ? variable.defaultValue : null) ?? null;\n if (value === null && (variable.baseType === 'integer' || variable.baseType === 'float')) return '0';\n return value;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-response-processing': QtiResponseProcessing;\n }\n}\n","export const matchCorrect = `<qti-response-condition>\n <qti-response-if>\n <qti-match>\n <qti-variable identifier=\"RESPONSE\"></qti-variable>\n <qti-correct identifier=\"RESPONSE\"></qti-correct>\n </qti-match>\n <qti-set-outcome-value identifier=\"SCORE\">\n <qti-base-value base-type=\"float\">1</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier=\"SCORE\">\n <qti-base-value base-type=\"float\">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-else>\n</qti-response-condition>`;\n\nexport const mapResponse = `<qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier=\"RESPONSE\"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier=\"SCORE\">\n <qti-base-value base-type=\"float\">0.0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier=\"SCORE\">\n <qti-map-response identifier=\"RESPONSE\"> </qti-map-response>\n </qti-set-outcome-value>\n </qti-response-else>\n</qti-response-condition>`;\n\nexport const mapResponsePoint = `<qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier=\"RESPONSE\"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier=\"SCORE\">\n <qti-base-value base-type=\"float\">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier=\"SCORE\">\n <qti-map-response-point identifier=\"RESPONSE\"></qti-map-response-point>\n </qti-set-outcome-value>\n </qti-response-else>\n</qti-response-condition>`;\n","import { LitElement, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { watch } from '@qti-components/utilities';\n\nimport { dispatchPublic } from '../../public-events';\n\nexport class QtiRubricBlock extends LitElement {\n @property({ type: String }) override id: string; // =\"qtiAspectInhoudRubricBlock\"\n\n @property({ type: String }) use: 'instructions' | 'scoring' | 'navigation'; // = \"scoring\"\n\n @property({ type: String }) view: 'author' | 'candidate' | 'proctor' | 'scorer' | 'testConstructor' | 'tutor';\n\n @property({ type: String, attribute: 'class' }) classNames: string;\n @watch('classNames', { waitUntilFirstUpdate: true })\n handleclassNamesChange() {\n const classNames = this.classNames.split(' ');\n classNames.forEach((className: string) => {\n switch (className) {\n case 'qti-rubric-discretionary-placement':\n {\n const notCancelled = dispatchPublic(this, 'qc-item-rubric-placement', { className, element: this }, true);\n if (!notCancelled) return;\n this.setAttribute('slot', 'qti-rubric-block');\n }\n break;\n case 'qti-rubric-inline':\n this.setAttribute('slot', '');\n break;\n default:\n break;\n }\n });\n }\n\n static override styles = css`\n :host {\n display: block;\n }\n `;\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-rubric-block': QtiRubricBlock;\n }\n}\n","import { LitElement } from 'lit';\n\nimport type { PropertyValueMap } from 'lit';\n\nexport class QtiStylesheet extends LitElement {\n #styleElement: HTMLStyleElement | null = null;\n\n protected override firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {\n super.firstUpdated(_changedProperties);\n\n const link = this.getAttribute('href');\n\n if (link !== null) {\n // Fetch the stylesheet content\n fetch(link)\n .then(response => response.text())\n .then(cssContent => {\n // Minify the CSS content by removing whitespace and comments\n const minifiedCss = this.#minifyCss(cssContent);\n\n // Create a <style> element with @scope surrounding the minified CSS\n this.#styleElement = document.createElement('style');\n this.#styleElement.media = 'screen';\n this.#styleElement.textContent = `@scope {${minifiedCss}}`;\n\n // Append the style element to the parent element of this component\n if (this.parentElement) {\n this.parentElement.appendChild(this.#styleElement);\n } else {\n console.warn('No parent element to append the scoped stylesheet to.');\n }\n })\n .catch(error => {\n console.error('Failed to load stylesheet:', error);\n });\n }\n\n if (this.textContent !== null && this.textContent.trim() !== '') {\n // Minify the inline CSS content\n const minifiedCss = this.#minifyCss(this.textContent);\n\n // Directly create a <style> element with the @scope surrounding the minified inline styles\n this.#styleElement = document.createElement('style');\n this.#styleElement.media = 'screen';\n this.#styleElement.textContent = `@scope {${minifiedCss}}`;\n\n // Append the style element to the parent element of this component\n if (this.parentElement) {\n this.parentElement.appendChild(this.#styleElement);\n } else {\n console.warn('No parent element to append the scoped stylesheet to.');\n }\n }\n }\n\n #minifyCss(cssContent: string): string {\n // Remove comments, whitespace, and newline characters\n return cssContent\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove comments\n .replace(/\\s+/g, ' ') // Collapse whitespace\n .replace(/\\s*([{}:;])\\s*/g, '$1') // Remove spaces around {}, :, ;\n .trim(); // Trim leading/trailing whitespace\n }\n\n override disconnectedCallback() {\n if (this.#styleElement) {\n try {\n this.#styleElement.remove();\n } catch (error) {\n console.error('Could not remove stylesheet:', error);\n }\n }\n super.disconnectedCallback();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-stylesheet': QtiStylesheet;\n }\n}\n","import { LitElement, html } from 'lit';\n\nimport type { QtiExpression } from '@qti-components/base';\nimport type { QtiRuleBase } from '@qti-components/base';\n\n/**\n * @summary The qti-template-constraint element is a processing rule available only in Template Processing.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.template-constraint\n *\n * It terminates Template Processing and re-runs it from the beginning if the condition\n * specified in the template constraint is not satisfied. This can be used to iterate\n * the Template Processing with different randomly-generated values until a predetermined\n * condition is satisfied.\n */\n\nexport class QtiTemplateConstraint extends LitElement implements QtiRuleBase {\n override render() {\n return html`<slot></slot>`;\n }\n\n /**\n * Evaluates the constraint condition\n * @returns true if constraint is satisfied, false if template processing should restart\n */\n public calculate(): boolean {\n const expressions = [...this.children] as QtiExpression<boolean>[];\n\n if (expressions.length !== 1) {\n console.error('qti-template-constraint must have exactly one child expression');\n return true; // Don't restart on error\n }\n\n try {\n const result = expressions[0].calculate();\n return Boolean(result);\n } catch (error) {\n console.error('Error evaluating template constraint:', error);\n return true; // Don't restart on error\n }\n }\n\n /**\n * Template constraints don't have sub-rules like conditions\n */\n public getSubRules(): QtiRuleBase[] {\n return [];\n }\n\n /**\n * Process the template constraint\n * @returns true if constraint is satisfied, false if template processing should restart\n */\n public process(): boolean {\n const constraintSatisfied = this.calculate();\n\n if (!constraintSatisfied) {\n console.debug('Template constraint not satisfied, restarting template processing');\n }\n\n return constraintSatisfied;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-template-constraint': QtiTemplateConstraint;\n }\n}\n","import { css, LitElement, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport type { TemplateVariable } from '@qti-components/base';\nimport type { BaseType } from '@qti-components/base';\n\n/**\n * @summary The qti-template-declaration element declares template variables for item cloning.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.template-declaration\n */\n\nexport class QtiTemplateDeclaration extends LitElement {\n @property({ type: String }) identifier: string = '';\n @property({ type: String }) cardinality: 'single' | 'multiple' | 'ordered' | 'record' = 'single';\n @property({ type: String, attribute: 'base-type' }) baseType: BaseType = 'string';\n @property({ type: Boolean, attribute: 'math-variable' }) mathVariable: boolean = false;\n @property({ type: Boolean, attribute: 'param-variable' }) paramVariable: boolean = false;\n\n #defaultValue: any = null;\n\n static override styles = [\n css`\n :host {\n display: none;\n }\n `\n ];\n\n override render() {\n return html`<slot></slot>`;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.updateComplete.then(() => {\n this.#processDefaultValue();\n this.#registerTemplateVariable();\n });\n }\n\n /**\n * Process qti-default-value to extract the default value\n */\n #processDefaultValue(): void {\n const defaultValueElement = this.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return;\n }\n\n // For now, just get the text content - this could be enhanced to handle expressions\n const textContent = defaultValueElement.textContent?.trim() || '';\n this.#defaultValue = this.#convertValue(textContent);\n }\n\n /**\n * Convert string value based on base-type\n */\n #convertValue(value: string): any {\n if (!value) return null;\n\n switch (this.baseType) {\n case 'integer':\n return parseInt(value, 10);\n case 'float':\n case 'duration':\n return parseFloat(value);\n case 'boolean':\n return value.toLowerCase() === 'true';\n case 'string':\n default:\n return value;\n }\n }\n\n /**\n * Register this template variable with the assessment item\n */\n #registerTemplateVariable(): void {\n const templateVariable: TemplateVariable = {\n identifier: this.identifier,\n cardinality: this.cardinality,\n baseType: this.baseType,\n defaultValue: this.#defaultValue,\n value: this.#defaultValue,\n type: 'template',\n mathVariable: this.mathVariable,\n paramVariable: this.paramVariable\n };\n\n // Dispatch event to register the variable\n\n // value must string or string[]\n const variable = { ...templateVariable, value: this.#defaultValue?.toString() || '' };\n this.dispatchEvent(\n new CustomEvent('qti-register-variable', {\n bubbles: true,\n composed: true,\n detail: { variable }\n })\n );\n }\n\n /**\n * Get the template variable definition\n */\n public getTemplateVariable(): TemplateVariable {\n return {\n identifier: this.identifier,\n cardinality: this.cardinality,\n baseType: this.baseType,\n value: this.#defaultValue,\n type: 'template',\n mathVariable: this.mathVariable,\n paramVariable: this.paramVariable\n };\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-template-declaration': QtiTemplateDeclaration;\n }\n}\n","import { css, html, LitElement } from 'lit';\n\nimport type { QtiRuleBase } from '@qti-components/base';\nimport type { QtiTemplateConstraint } from '../qti-template-constraint/qti-template-constraint';\nimport type { PropertyValueMap } from 'lit';\n\n/**\n * @summary The qti-template-processing element contains template processing rules.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.template-processing\n */\n\nexport class QtiTemplateProcessing extends LitElement {\n static override styles = [\n css`\n :host {\n display: none;\n }\n `\n ];\n\n #maxIterations = 100; // Prevent infinite loops in template constraints\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /**\n * Process template rules to set template variable values\n */\n public process(): void {\n const assessmentItem = this.closest('qti-assessment-item');\n if (!assessmentItem) {\n console.warn('qti-template-processing must be inside qti-assessment-item');\n return;\n }\n\n let iterations = 0;\n let shouldReprocess = false;\n\n do {\n shouldReprocess = false;\n iterations++;\n\n if (iterations > this.#maxIterations) {\n console.error('Template processing exceeded maximum iterations. Possible infinite loop.');\n break;\n }\n\n try {\n const rules = [...this.children] as unknown as (Element & QtiRuleBase)[];\n for (const rule of rules) {\n // Check if this is a template constraint that failed\n if (rule.tagName.toLowerCase() === 'qti-template-constraint') {\n const constraintResult = (rule as QtiTemplateConstraint).calculate();\n if (constraintResult === false) {\n // Template constraint failed, restart processing\n shouldReprocess = true;\n break;\n }\n } else {\n rule.process();\n }\n }\n } catch (error) {\n console.error('Error during template processing:', error);\n break;\n }\n } while (shouldReprocess);\n\n // Dispatch event that template processing is complete\n this.dispatchEvent(\n new CustomEvent('qti-template-processing-complete', {\n bubbles: true,\n composed: true,\n detail: { iterations }\n })\n );\n }\n\n public override firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {\n // Template processing doesn't typically use external templates like response processing\n // But we could add support for common template processing patterns here if needed\n if (this.getAttribute('template')) {\n console.info('Template processing with external template not yet implemented');\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-template-processing': QtiTemplateProcessing;\n }\n}\n","import { QtiAssessmentItem } from './components/qti-assessment-item/qti-assessment-item';\nimport { QtiAssessmentStimulus } from './components/qti-assessment-stimulus/qti-assessment-stimulus';\nimport { QtiAssessmentStimulusRef } from './components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref';\nimport { QtiCompanionMaterialsInfo } from './components/qti-companion-materials-info/qti-companion-materials-info';\nimport { QtiContentBody } from './components/qti-content-body/qti-content-body';\nimport { QtiContextDeclaration } from './components/qti-context-declaration/qti-context-declaration';\nimport { QtiCustomOperator } from './components/qti-custom-operator/qti-custom-operator';\nimport { QtiFeedbackBlock } from './components/qti-feedback-block/qti-feedback-block';\nimport { QtiFeedbackInline } from './components/qti-feedback-inline/qti-feedback-inline';\nimport { QtiItemBody } from './components/qti-item-body/qti-item-body';\nimport { QtiModalFeedback } from './components/qti-modal-feedback/qti-modal-feedback';\nimport { QtiOutcomeDeclaration } from './components/qti-outcome-declaration/qti-outcome-declaration';\nimport { QtiResponseDeclaration } from './components/qti-response-declaration/qti-response-declaration';\nimport { QtiResponseProcessing } from './components/qti-response-processing/qti-response-processing';\nimport { QtiRubricBlock } from './components/qti-rubric-block/qti-rubric-block';\nimport { QtiStylesheet } from './components/qti-stylesheet/qti-stylesheet';\nimport { QtiTemplateConstraint } from './components/qti-template-constraint/qti-template-constraint';\nimport { QtiTemplateDeclaration } from './components/qti-template-declaration/qti-template-declaration';\nimport { QtiTemplateProcessing } from './components/qti-template-processing/qti-template-processing';\n\nexport {\n QtiAssessmentItem,\n QtiAssessmentStimulus,\n QtiAssessmentStimulusRef,\n QtiCompanionMaterialsInfo,\n QtiContentBody,\n QtiContextDeclaration,\n QtiCustomOperator,\n QtiFeedbackBlock,\n QtiFeedbackInline,\n QtiItemBody,\n QtiModalFeedback,\n QtiOutcomeDeclaration,\n QtiResponseDeclaration,\n QtiResponseProcessing,\n QtiRubricBlock,\n QtiStylesheet,\n QtiTemplateConstraint,\n QtiTemplateDeclaration,\n QtiTemplateProcessing\n};\n\nexport const qtiContentElements = [\n { tag: 'qti-assessment-item', ctor: QtiAssessmentItem },\n { tag: 'qti-assessment-stimulus', ctor: QtiAssessmentStimulus },\n { tag: 'qti-assessment-stimulus-ref', ctor: QtiAssessmentStimulusRef },\n { tag: 'qti-companion-materials-info', ctor: QtiCompanionMaterialsInfo },\n { tag: 'qti-content-body', ctor: QtiContentBody },\n { tag: 'qti-context-declaration', ctor: QtiContextDeclaration },\n { tag: 'qti-custom-operator', ctor: QtiCustomOperator },\n { tag: 'qti-feedback-block', ctor: QtiFeedbackBlock },\n { tag: 'qti-feedback-inline', ctor: QtiFeedbackInline },\n { tag: 'qti-item-body', ctor: QtiItemBody },\n { tag: 'qti-modal-feedback', ctor: QtiModalFeedback },\n { tag: 'qti-outcome-declaration', ctor: QtiOutcomeDeclaration },\n { tag: 'qti-response-declaration', ctor: QtiResponseDeclaration },\n { tag: 'qti-response-processing', ctor: QtiResponseProcessing },\n { tag: 'qti-rubric-block', ctor: QtiRubricBlock },\n { tag: 'qti-stylesheet', ctor: QtiStylesheet },\n { tag: 'qti-template-constraint', ctor: QtiTemplateConstraint },\n { tag: 'qti-template-declaration', ctor: QtiTemplateDeclaration },\n { tag: 'qti-template-processing', ctor: QtiTemplateProcessing }\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,YAAY,YAAY;AACjC,SAAS,gBAAgB;;;;;;;AAmCnB,IAAO,oBAAP,cAAiC,WAAU;EAAjD,cA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D,EAAE,KAAK,iBAAiB,MAAM,YAAW;EACzC,EAAE,KAAK,sBAAsB,MAAM,iBAAgB;EACnD,EAAE,KAAK,2BAA2B,MAAM,sBAAqB;EAC7D,EAAE,KAAK,4BAA4B,MAAM,uBAAsB;EAC/D,EAAE,KAAK,2BAA2B,MAAM,sBAAqB;EAC7D,EAAE,KAAK,oBAAoB,MAAM,eAAc;EAC/C,EAAE,KAAK,kBAAkB,MAAM,cAAa;EAC5C,EAAE,KAAK,2BAA2B,MAAM,sBAAqB;EAC7D,EAAE,KAAK,4BAA4B,MAAM,uBAAsB;EAC/D,EAAE,KAAK,2BAA2B,MAAM,sBAAqB;;","names":["state","html","LitElement","LitElement","html","LitElement","property","LitElement","__decorate","property","LitElement","LitElement","html","LitElement","html","__decorate","css","LitElement","html","property","__decorate","consume","LitElement","html","state","LitElement","html","__decorate","consume","state","css","html","css","html","css","html","html","css","html","LitElement","css","LitElement","html","css","html","css","html","consume","css","html","property","state","css","html","__decorate","property","consume","state","consume","css","html","property","state","css","html","__decorate","property","consume","state","css","html","LitElement","LitElement","css","html","LitElement","css","html","property","LitElement","css","html","__decorate","property","LitElement","LitElement","html","css","LitElement","html","property","__decorate","css","html","LitElement"]}
@@ -106,7 +106,8 @@ var itemContextVariables = [
106
106
  identifier: "completionStatus",
107
107
  cardinality: "single",
108
108
  baseType: "string",
109
- value: "unknown",
109
+ // QTI info model §2.2.2; the item makes it `unknown` once it is presented.
110
+ value: "not_attempted",
110
111
  type: "outcome"
111
112
  },
112
113
  {
@@ -201,6 +202,35 @@ var validationMessage = css3`
201
202
  }
202
203
  `;
203
204
 
205
+ // ../qti-base/dist/utils/state-aliases.js
206
+ var STATE_ALIASES = {
207
+ chip: ["drag"],
208
+ drop: ["droppable"],
209
+ lifted: ["dragging"],
210
+ used: ["placeholder"],
211
+ "return-target": ["return-anchor"],
212
+ "drag-over": ["hover"],
213
+ "candidate-partial": ["candidate-partially-correct"]
214
+ };
215
+ function setState(states, name, on, oldNames) {
216
+ if (!states)
217
+ return;
218
+ const names = [name, ...oldNames ?? STATE_ALIASES[name] ?? []];
219
+ for (const n of names) {
220
+ if (on)
221
+ states.add(n);
222
+ else
223
+ states.delete(n);
224
+ }
225
+ }
226
+ function hasState(states, name) {
227
+ if (!states)
228
+ return false;
229
+ if (states.has(name))
230
+ return true;
231
+ return (STATE_ALIASES[name] ?? []).some((n) => states.has(n));
232
+ }
233
+
204
234
  // ../qti-base/dist/abstract/interaction.js
205
235
  import { ContextConsumer, consume, provide } from "@lit/context";
206
236
  import { LitElement } from "lit";
@@ -320,11 +350,40 @@ var Interaction = class extends LitElement {
320
350
  set value(val) {
321
351
  this.response = val ? JSON.parse(val) : null;
322
352
  }
323
- reportValidity() {
353
+ /** Forget that a submit has reported: a reset or a new attempt waits for a submit again. */
354
+ resetValidityReport() {
355
+ this._validityReported = false;
356
+ this.clearInlineValidationMessage();
357
+ }
358
+ /**
359
+ * Show the validity state, in the configured mode.
360
+ *
361
+ * When it shows depends on what asked: a `change` (the candidate picked or dropped something)
362
+ * reports what they just did wrong, too many, at once; too few is not an error until they say they
363
+ * are done, so a `submit` (the item's end attempt, a form's submit) is what first shows it. After
364
+ * that first submit, changes report in full, so the message clears the moment the minimum is met
365
+ * and comes back if it is lost again. The validity itself is always set: a form with a
366
+ * below-minimum interaction cannot submit either way.
367
+ */
368
+ reportValidity(options) {
369
+ const trigger = options?.trigger ?? "submit";
370
+ if (trigger === "submit")
371
+ this.validate?.();
324
372
  const isValid = this._internals.validity.valid;
325
373
  const mode = this.validationDisplayMode;
374
+ if (trigger === "submit")
375
+ this._validityReported = true;
376
+ if (trigger === "change" && !this._validityReported && this._validityKind === "min") {
377
+ this.clearInlineValidationMessage();
378
+ return isValid;
379
+ }
326
380
  if (mode === "native" || mode === "both") {
327
- this._internals.reportValidity();
381
+ this._reportingNatively = true;
382
+ try {
383
+ this._internals.reportValidity();
384
+ } finally {
385
+ this._reportingNatively = false;
386
+ }
328
387
  }
329
388
  if (mode === "inline" || mode === "both") {
330
389
  this.updateInlineValidationMessage();
@@ -371,6 +430,7 @@ var Interaction = class extends LitElement {
371
430
  setInteractionValidity(isValid, validityMessage = "", anchor, options) {
372
431
  const validityAnchor = anchor ?? this;
373
432
  this._internals.setValidity(isValid ? {} : { customError: true }, validityMessage, validityAnchor);
433
+ this._validityKind = isValid ? void 0 : options?.kind ?? "other";
374
434
  if (options?.suppressInline !== true && (this.validationDisplayMode === "inline" || this.validationDisplayMode === "both")) {
375
435
  this.updateInlineValidationMessage();
376
436
  }
@@ -400,9 +460,11 @@ var Interaction = class extends LitElement {
400
460
  return this.shadowRoot?.querySelector("#validation-message");
401
461
  }
402
462
  reset() {
463
+ this.resetValidityReport();
403
464
  this.response = null;
404
465
  }
405
466
  formResetCallback() {
467
+ this.resetValidityReport();
406
468
  this.reset();
407
469
  }
408
470
  connectedCallback() {
@@ -432,6 +494,24 @@ var Interaction = class extends LitElement {
432
494
  }
433
495
  }));
434
496
  }
497
+ /**
498
+ * `disabled` and `readonly` are states as well as attributes (qti-theme CONTRACT.md §3): a theme
499
+ * reads `:state(disabled)` on the host the way it reads it on a choice. The attribute stays
500
+ * reflected, so `[disabled]` keeps matching.
501
+ */
502
+ update(changed) {
503
+ const first = !this.hasUpdated;
504
+ super.update(changed);
505
+ if (first) {
506
+ const run = () => this.isConnected && this.validate();
507
+ void this.updateComplete.then(run);
508
+ requestAnimationFrame(() => requestAnimationFrame(run));
509
+ }
510
+ if (changed.has("disabled"))
511
+ setState(this._internals.states, "disabled", this.disabled);
512
+ if (changed.has("readonly"))
513
+ setState(this._internals.states, "readonly", this.readonly);
514
+ }
435
515
  constructor() {
436
516
  super();
437
517
  this.#itemContext = new ContextConsumer(this, {
@@ -444,7 +524,17 @@ var Interaction = class extends LitElement {
444
524
  this._interactionContext = { choiceRole: null, draggablesSelector: null };
445
525
  this.disabled = false;
446
526
  this.readonly = false;
527
+ this._validityReported = false;
528
+ this._reportingNatively = false;
447
529
  this._internals = this.attachInternals();
530
+ this.addEventListener("invalid", () => {
531
+ if (this._reportingNatively)
532
+ return;
533
+ this._validityReported = true;
534
+ if (this.validationDisplayMode === "inline" || this.validationDisplayMode === "both") {
535
+ this.updateInlineValidationMessage();
536
+ }
537
+ });
448
538
  this.addEventListener("qti-interaction-response", (e) => {
449
539
  this.#lastResponse = JSON.stringify(e.detail?.response ?? null);
450
540
  });
@@ -803,6 +893,7 @@ var QtiFeedback = class extends LitElement4 {
803
893
  subscribe: true,
804
894
  callback: (context) => this.#followItem(context)
805
895
  });
896
+ this.#hostShows = false;
806
897
  }
807
898
  /**
808
899
  * The item's variables. Feedback follows them itself: every time the item publishes a new context
@@ -844,12 +935,38 @@ var QtiFeedback = class extends LitElement4 {
844
935
  }
845
936
  this.#showFeedback(isFound);
846
937
  }
938
+ /** The host cancelled the show: it has this feedback, and is not asked again until the condition has gone. */
939
+ #hostShows;
847
940
  #showFeedback(value) {
848
- if (!this.#sessionControlAllowsFeedback()) {
849
- this.showStatus = "off";
850
- return;
941
+ const next = this.#sessionControlAllowsFeedback() && this.#conditionHolds(value) ? "on" : "off";
942
+ if (next === "on") {
943
+ if (this.showStatus === "on" || this.#hostShows)
944
+ return;
945
+ if (!this.feedbackShowing()) {
946
+ this.#hostShows = true;
947
+ this.showStatus = "off";
948
+ return;
949
+ }
950
+ } else {
951
+ this.#hostShows = false;
952
+ if (this.showStatus === "on" && !this.feedbackHiding())
953
+ return;
851
954
  }
852
- this.showStatus = value && this.showHide === "show" || !value && this.showHide === "hide" ? "on" : "off";
955
+ this.showStatus = next;
956
+ }
957
+ #conditionHolds(value) {
958
+ return value && this.showHide === "show" || !value && this.showHide === "hide";
959
+ }
960
+ /**
961
+ * Called when this feedback is about to show. Return `false` to keep it hidden: the host shows the
962
+ * content itself. The elements dispatch `qc-feedback-show` here.
963
+ */
964
+ feedbackShowing() {
965
+ return true;
966
+ }
967
+ /** Called when this feedback is about to hide. Return `false` to keep it showing: the host hides it itself. */
968
+ feedbackHiding() {
969
+ return true;
853
970
  }
854
971
  /**
855
972
  * The QTI `show-feedback` constraint governs exactly one state: after the end of
@@ -870,11 +987,11 @@ var QtiFeedback = class extends LitElement4 {
870
987
  if (!this._computedContext)
871
988
  return true;
872
989
  const activeItem = this._computedContext.testParts?.find((tp) => tp.active)?.sections.flatMap((s) => s.items).find((i) => i.active);
873
- if (!activeItem || activeItem.showFeedback)
990
+ if (!activeItem || activeItem.sessionControl?.showFeedback)
874
991
  return true;
875
992
  if (activeItem.adaptive)
876
993
  return activeItem.completionStatus !== "completed";
877
- const maxAttempts = activeItem.maxAttempts ?? 1;
994
+ const maxAttempts = activeItem.sessionControl?.maxAttempts ?? 1;
878
995
  if (maxAttempts <= 0)
879
996
  return true;
880
997
  const numAttempts = Number(this._context?.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
@@ -984,6 +1101,39 @@ function responseAttributeConverter(opts) {
984
1101
  };
985
1102
  }
986
1103
 
1104
+ // ../qti-base/dist/lib/record.js
1105
+ var isRecordValue = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
1106
+ var readRecordFieldValues = (valueElements) => {
1107
+ const value = {};
1108
+ const baseTypes = {};
1109
+ for (const element of valueElements) {
1110
+ const fieldIdentifier = element.getAttribute("field-identifier");
1111
+ if (!fieldIdentifier)
1112
+ continue;
1113
+ value[fieldIdentifier] = element.textContent?.trim() ?? "";
1114
+ const baseType = element.getAttribute("base-type");
1115
+ if (baseType)
1116
+ baseTypes[fieldIdentifier] = baseType;
1117
+ }
1118
+ return { value, baseTypes };
1119
+ };
1120
+ var NUMBER = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
1121
+ var inferRecordFieldBaseType = (value) => {
1122
+ if (typeof value === "number")
1123
+ return Number.isInteger(value) ? "integer" : "float";
1124
+ if (typeof value === "boolean")
1125
+ return "boolean";
1126
+ if (typeof value !== "string")
1127
+ return "string";
1128
+ const text = value.trim();
1129
+ if (NUMBER.test(text))
1130
+ return "float";
1131
+ const parts = text.split(/\s+/);
1132
+ if (parts.length === 2 && parts.every((part) => NUMBER.test(part)))
1133
+ return "point";
1134
+ return "string";
1135
+ };
1136
+
987
1137
  // ../qti-base/dist/lib/qti-rule-base.js
988
1138
  import { LitElement as LitElement5 } from "lit";
989
1139
  var QtiRuleElement = class extends LitElement5 {
@@ -1219,6 +1369,9 @@ export {
1219
1369
  boxSizing,
1220
1370
  dropRegion,
1221
1371
  validationMessage,
1372
+ STATE_ALIASES,
1373
+ setState,
1374
+ hasState,
1222
1375
  Interaction,
1223
1376
  QtiVariableDeclaration,
1224
1377
  QtiExpression,
@@ -1236,6 +1389,9 @@ export {
1236
1389
  parsePoint,
1237
1390
  serializePoint,
1238
1391
  responseAttributeConverter,
1392
+ isRecordValue,
1393
+ readRecordFieldValues,
1394
+ inferRecordFieldBaseType,
1239
1395
  QtiRuleElement,
1240
1396
  QtiExitResponseSignal,
1241
1397
  QtiExitTestSignal,
@@ -1244,4 +1400,4 @@ export {
1244
1400
  getCustomOperator,
1245
1401
  ScoringHelper
1246
1402
  };
1247
- //# sourceMappingURL=chunk-TDWJ6WZA.js.map
1403
+ //# sourceMappingURL=chunk-GPC53O7P.js.map