@qti-components/elements 1.9.0 → 1.10.0-next.0

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.
@@ -105,3 +105,9 @@ declare global {
105
105
  'qti-assessment-item': QtiAssessmentItem;
106
106
  }
107
107
  }
108
+ declare module '../../public-events' {
109
+ interface PublicItemEventMap {
110
+ /** The item rendered: its interactions are in the DOM and its validity is known. */
111
+ 'cito-item-rendered': CustomEvent<QtiAssessmentItem>;
112
+ }
113
+ }
@@ -8,6 +8,7 @@ import { provide } from '@lit/context';
8
8
  import { LitElement, html } from 'lit';
9
9
  import { property } from 'lit/decorators.js';
10
10
  import { itemContext, itemContextVariables } from '@qti-components/base';
11
+ import { dispatchPublic } from '../../public-events';
11
12
  /**
12
13
  * @summary The qti-assessment-item element contains all the other QTI 3 item structures.
13
14
  * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.dltnnj87l0yj
@@ -237,6 +238,8 @@ export class QtiAssessmentItem extends LitElement {
237
238
  this.updateComplete.then(() => {
238
239
  // The verdict goes in first, so whoever hears the item connect reads it with the rest.
239
240
  this.validate(false);
241
+ dispatchPublic(this, 'cito-item-rendered', this);
242
+ // Internal plumbing: the test and the item container listen for this name.
240
243
  this.dispatchEvent(new CustomEvent('qti-assessment-item-connected', {
241
244
  bubbles: true,
242
245
  composed: true,
@@ -350,15 +353,11 @@ export class QtiAssessmentItem extends LitElement {
350
353
  variables: this._context.variables.map(v => (v.identifier !== identifier ? v : { ...v, value: value }))
351
354
  };
352
355
  this.afterResponseVariableUpdated();
353
- this.dispatchEvent(new CustomEvent('qti-interaction-changed', {
354
- bubbles: true,
355
- composed: true,
356
- detail: {
357
- item: this.identifier,
358
- responseIdentifier: identifier,
359
- response: Array.isArray(value) ? [...value] : value
360
- }
361
- }));
356
+ dispatchPublic(this, 'cito-item-response-changed', {
357
+ item: this.identifier,
358
+ responseIdentifier: identifier,
359
+ response: Array.isArray(value) ? [...value] : value
360
+ });
362
361
  if (this.adaptive === 'false') {
363
362
  // if adaptive, completionStatus is set by the processing template
364
363
  this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());
@@ -467,15 +466,11 @@ export class QtiAssessmentItem extends LitElement {
467
466
  };
468
467
  })
469
468
  };
470
- this.dispatchEvent(new CustomEvent('qti-outcome-changed', {
471
- bubbles: true,
472
- composed: true,
473
- detail: {
474
- item: this.identifier,
475
- outcomeIdentifier: identifier,
476
- value: this._context.variables.find(v => v.identifier === identifier)?.value
477
- }
478
- }));
469
+ dispatchPublic(this, 'cito-item-outcome-changed', {
470
+ item: this.identifier,
471
+ outcomeIdentifier: identifier,
472
+ value: this._context.variables.find(v => v.identifier === identifier)?.value
473
+ });
479
474
  }
480
475
  validate(reportValidity = true) {
481
476
  const isValid = this.interactionElements.every(interactionElement => interactionElement.validate());
@@ -1 +1 @@
1
- {"version":3,"file":"qti-assessment-item.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item/qti-assessment-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAazE;;;;;;;;;GASG;AAEH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAAjD;;QAEE,wBAAmB,GAAiC,IAAI,CAAC;QAE7B,eAAU,GAAW,EAAE,CAAC;QACxB,aAAQ,GAAqB,OAAO,CAAC;QACjE;;;;;;WAMG;QACsD,kBAAa,GAA4B,IAAI,CAAC;QAsC/F,aAAQ,GAAgB;YAC9B,SAAS,EAAE,oBAAoB;SAChC,CAAC;QAgGF,oBAAe,GAA0B,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAA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AC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAmB;AAMlB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAmB;AAgBvC;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;mDAGhC","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 type { PropertyValues } from 'lit';\nimport type { QtiTemplateProcessing } from '../qti-template-processing/qti-template-processing.js';\nimport type { InteractionChangedDetails, OutcomeChangedDetails } 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 { QtiResponseProcessing } from '../qti-response-processing/qti-response-processing.ts';\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\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 }\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.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('qti-set-outcome-value', this.#handleSetOutcomeValue);\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('qti-set-outcome-value', this.#handleSetOutcomeValue);\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);\n };\n\n #handleSetOutcomeValue = (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n e.stopImmediatePropagation();\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\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 public processResponse(countNumAttempts = true, reportValidityAfterScoring = true): boolean {\n this.validate(reportValidityAfterScoring);\n\n if (countNumAttempts) {\n this.updateOutcomeVariable(\n 'numAttempts',\n (+this._context.variables.find(v => v.identifier === 'numAttempts')?.value + 1).toString()\n );\n }\n\n if (this.adaptive === 'false') {\n this.#resetOutcomeVariablesBeforeResponseProcessing();\n }\n\n const responseProcessor = this.querySelector<QtiResponseProcessing>('qti-response-processing');\n const canProcess = !!(responseProcessor && typeof responseProcessor.process === 'function');\n if (canProcess) {\n responseProcessor.process();\n }\n if (this.adaptive === 'false') {\n // if adaptive, completionStatus is set by the processing template\n this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());\n }\n\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 return canProcess;\n }\n\n public resetResponses() {\n this._context = this.#initialContext;\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 this.dispatchEvent(\n new CustomEvent<InteractionChangedDetails>('qti-interaction-changed', {\n bubbles: true,\n composed: true,\n detail: {\n item: this.identifier,\n responseIdentifier: identifier,\n response: Array.isArray(value) ? [...value] : value\n }\n })\n );\n\n if (this.adaptive === 'false') {\n // if adaptive, completionStatus is set by the processing template\n this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());\n }\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 const outcomeVariable = this.getOutcome(identifier);\n\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : Array.isArray(value) ? value : [value]\n };\n })\n };\n\n this.dispatchEvent(\n new CustomEvent<OutcomeChangedDetails>('qti-outcome-changed', {\n bubbles: true,\n composed: true,\n detail: {\n item: this.identifier,\n outcomeIdentifier: identifier,\n value: this._context.variables.find(v => v.identifier === identifier)?.value\n }\n })\n );\n }\n\n public validate(reportValidity = true): boolean {\n const isValid = this.interactionElements.every(interactionElement => interactionElement.validate());\n this.#publishValidity(isValid);\n\n if (reportValidity) {\n this.reportValidity();\n }\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 #getCompletionStatus(): 'completed' | 'incomplete' | 'not_attempted' | 'unknown' {\n const valid = this.validate(false);\n if (valid === true) return 'completed';\n if (valid === false) return 'incomplete';\n return 'not_attempted';\n }\n\n #resetOutcomeVariablesBeforeResponseProcessing(): void {\n this._context = {\n ...this._context,\n variables: this._context.variables.map(variable => {\n if (variable.type !== 'outcome') {\n return variable;\n }\n\n const hasDefaultValue = 'defaultValue' in variable;\n const declaredDefault = hasDefaultValue ? variable.defaultValue : null;\n\n let value = declaredDefault ?? null;\n if (\n (value === null || value === undefined) &&\n (variable.baseType === 'integer' || variable.baseType === 'float')\n ) {\n value = '0';\n }\n\n return {\n ...variable,\n value\n };\n })\n };\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item': QtiAssessmentItem;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-assessment-item.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item/qti-assessment-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAA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BACX,KAAK;iBACN,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AA1mB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAsC;AAQR;IAAxD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;wDAA+C;AAGvG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAG1B;AAW4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAmB;AAMlB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAmB;AAgBvC;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;mDAGhC","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, OutcomeChangedDetails } 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 { QtiResponseProcessing } from '../qti-response-processing/qti-response-processing.ts';\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\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 }\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 dispatchPublic(this, 'cito-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('qti-set-outcome-value', this.#handleSetOutcomeValue);\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('qti-set-outcome-value', this.#handleSetOutcomeValue);\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);\n };\n\n #handleSetOutcomeValue = (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n e.stopImmediatePropagation();\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\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 public processResponse(countNumAttempts = true, reportValidityAfterScoring = true): boolean {\n this.validate(reportValidityAfterScoring);\n\n if (countNumAttempts) {\n this.updateOutcomeVariable(\n 'numAttempts',\n (+this._context.variables.find(v => v.identifier === 'numAttempts')?.value + 1).toString()\n );\n }\n\n if (this.adaptive === 'false') {\n this.#resetOutcomeVariablesBeforeResponseProcessing();\n }\n\n const responseProcessor = this.querySelector<QtiResponseProcessing>('qti-response-processing');\n const canProcess = !!(responseProcessor && typeof responseProcessor.process === 'function');\n if (canProcess) {\n responseProcessor.process();\n }\n if (this.adaptive === 'false') {\n // if adaptive, completionStatus is set by the processing template\n this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());\n }\n\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 return canProcess;\n }\n\n public resetResponses() {\n this._context = this.#initialContext;\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, 'cito-item-response-changed', {\n item: this.identifier,\n responseIdentifier: identifier,\n response: Array.isArray(value) ? [...value] : value\n });\n\n if (this.adaptive === 'false') {\n // if adaptive, completionStatus is set by the processing template\n this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());\n }\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 const outcomeVariable = this.getOutcome(identifier);\n\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : Array.isArray(value) ? value : [value]\n };\n })\n };\n\n dispatchPublic(this, 'cito-item-outcome-changed', {\n item: this.identifier,\n outcomeIdentifier: identifier,\n value: this._context.variables.find(v => v.identifier === identifier)?.value\n });\n }\n\n public validate(reportValidity = true): boolean {\n const isValid = this.interactionElements.every(interactionElement => interactionElement.validate());\n this.#publishValidity(isValid);\n\n if (reportValidity) {\n this.reportValidity();\n }\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 #getCompletionStatus(): 'completed' | 'incomplete' | 'not_attempted' | 'unknown' {\n const valid = this.validate(false);\n if (valid === true) return 'completed';\n if (valid === false) return 'incomplete';\n return 'not_attempted';\n }\n\n #resetOutcomeVariablesBeforeResponseProcessing(): void {\n this._context = {\n ...this._context,\n variables: this._context.variables.map(variable => {\n if (variable.type !== 'outcome') {\n return variable;\n }\n\n const hasDefaultValue = 'defaultValue' in variable;\n const declaredDefault = hasDefaultValue ? variable.defaultValue : null;\n\n let value = declaredDefault ?? null;\n if (\n (value === null || value === undefined) &&\n (variable.baseType === 'integer' || variable.baseType === 'float')\n ) {\n value = '0';\n }\n\n return {\n ...variable,\n value\n };\n })\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 'cito-item-rendered': CustomEvent<QtiAssessmentItem>;\n }\n}\n"]}
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { LitElement, css, html } from 'lit';
8
8
  import { property } from 'lit/decorators.js';
9
9
  import { watch } from '@qti-components/utilities';
10
+ import { dispatchPublic } from '../../public-events';
10
11
  export class QtiRubricBlock extends LitElement {
11
12
  handleclassNamesChange() {
12
13
  const classNames = this.classNames.split(' ');
@@ -14,13 +15,7 @@ export class QtiRubricBlock extends LitElement {
14
15
  switch (className) {
15
16
  case 'qti-rubric-discretionary-placement':
16
17
  {
17
- const event = new CustomEvent('qti-rubric:discretionary-placement', {
18
- detail: { className, element: this },
19
- bubbles: true,
20
- composed: true,
21
- cancelable: true
22
- });
23
- const notCancelled = this.dispatchEvent(event);
18
+ const notCancelled = dispatchPublic(this, 'cito-item-rubric-placement', { className, element: this }, true);
24
19
  if (!notCancelled)
25
20
  return;
26
21
  this.setAttribute('slot', 'qti-rubric-block');
@@ -1 +1 @@
1
- {"version":3,"file":"qti-rubric-block.js","sourceRoot":"","sources":["../../../src/components/qti-rubric-block/qti-rubric-block.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAS5C,sBAAsB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK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LitElement, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { watch } from '@qti-components/utilities';\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 event = new CustomEvent('qti-rubric:discretionary-placement', {\n detail: { className, element: this },\n bubbles: true,\n composed: true,\n cancelable: true\n });\n const notCancelled = this.dispatchEvent(event);\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"]}
1
+ {"version":3,"file":"qti-rubric-block.js","sourceRoot":"","sources":["../../../src/components/qti-rubric-block/qti-rubric-block.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAS5C,sBAAsB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,UAAU,CAAC,OAAO,CAAC,CAAC,SAAiB,EAAE,EAAE;YACvC,QAAQ,SAAS,EAAE,CAAC;gBAClB,KAAK,oCAAoC;oBACvC,CAAC;wBACC,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,EAAE,4BAA4B,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;wBAC5G,IAAI,CAAC,YAAY;4BAAE,OAAO;wBAC1B,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;oBAChD,CAAC;oBACD,MAAM;gBACR,KAAK,mBAAmB;oBACtB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;oBAC9B,MAAM;gBACR;oBACE,MAAM;YACV,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;;;GAI3B,CAAC;IAEO,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AApCoC;IAApC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAqB;AAEpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAgD;AAE/C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAmF;AAE9D;IAA/C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;kDAAoB;AAEnE;IADC,KAAK,CAAC,YAAY,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;4DAmBnD","sourcesContent":["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, 'cito-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"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import './register';
2
+ export * from './public-events';
2
3
  export * from './components/qti-assessment-item/qti-assessment-item';
3
4
  export * from './components/qti-assessment-stimulus/qti-assessment-stimulus';
4
5
  export * from './components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import './register';
2
+ export * from './public-events';
2
3
  export * from './components/qti-assessment-item/qti-assessment-item';
3
4
  export * from './components/qti-assessment-stimulus/qti-assessment-stimulus';
4
5
  export * from './components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,cAAc,sDAAsD,CAAC;AACrE,cAAc,8DAA8D,CAAC;AAC7E,cAAc,sEAAsE,CAAC;AACrF,cAAc,wEAAwE,CAAC;AACvF,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gEAAgE,CAAC;AAC/E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,gEAAgE,CAAC;AAC/E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,8DAA8D,CAAC","sourcesContent":["import './register';\n\nexport * from './components/qti-assessment-item/qti-assessment-item';\nexport * from './components/qti-assessment-stimulus/qti-assessment-stimulus';\nexport * from './components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref';\nexport * from './components/qti-companion-materials-info/qti-companion-materials-info';\nexport * from './components/qti-custom-operator/qti-custom-operator';\nexport * from './components/qti-feedback-block/qti-feedback-block';\nexport * from './components/qti-feedback-inline/qti-feedback-inline';\nexport * from './components/qti-modal-feedback/qti-modal-feedback';\nexport * from './components/qti-item-body/qti-item-body';\nexport * from './components/qti-content-body/qti-content-body';\nexport * from './components/qti-rubric-block/qti-rubric-block';\nexport * from './components/qti-stylesheet/qti-stylesheet';\nexport * from './components/qti-response-declaration/qti-response-declaration';\nexport * from './components/qti-outcome-declaration/qti-outcome-declaration';\nexport * from './components/qti-response-processing/qti-response-processing';\nexport * from './components/qti-template-declaration/qti-template-declaration';\nexport * from './components/qti-template-processing/qti-template-processing';\nexport * from './components/qti-template-constraint/qti-template-constraint';\nexport * from './components/qti-context-declaration/qti-context-declaration';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,cAAc,iBAAiB,CAAC;AAEhC,cAAc,sDAAsD,CAAC;AACrE,cAAc,8DAA8D,CAAC;AAC7E,cAAc,sEAAsE,CAAC;AACrF,cAAc,wEAAwE,CAAC;AACvF,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gEAAgE,CAAC;AAC/E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,gEAAgE,CAAC;AAC/E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,8DAA8D,CAAC;AAC7E,cAAc,8DAA8D,CAAC","sourcesContent":["import './register';\n\nexport * from './public-events';\n\nexport * from './components/qti-assessment-item/qti-assessment-item';\nexport * from './components/qti-assessment-stimulus/qti-assessment-stimulus';\nexport * from './components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref';\nexport * from './components/qti-companion-materials-info/qti-companion-materials-info';\nexport * from './components/qti-custom-operator/qti-custom-operator';\nexport * from './components/qti-feedback-block/qti-feedback-block';\nexport * from './components/qti-feedback-inline/qti-feedback-inline';\nexport * from './components/qti-modal-feedback/qti-modal-feedback';\nexport * from './components/qti-item-body/qti-item-body';\nexport * from './components/qti-content-body/qti-content-body';\nexport * from './components/qti-rubric-block/qti-rubric-block';\nexport * from './components/qti-stylesheet/qti-stylesheet';\nexport * from './components/qti-response-declaration/qti-response-declaration';\nexport * from './components/qti-outcome-declaration/qti-outcome-declaration';\nexport * from './components/qti-response-processing/qti-response-processing';\nexport * from './components/qti-template-declaration/qti-template-declaration';\nexport * from './components/qti-template-processing/qti-template-processing';\nexport * from './components/qti-template-constraint/qti-template-constraint';\nexport * from './components/qti-context-declaration/qti-context-declaration';\n"]}
@@ -0,0 +1,47 @@
1
+ import type { InteractionChangedDetails, OutcomeChangedDetails } from './internal/event-types';
2
+ /**
3
+ * The public events of the item. The name tells you it is public: everything declared here starts
4
+ * with `cito-`; every other event is internal plumbing and may change in any release.
5
+ *
6
+ * Requests are verbs, notifications are past tense. All bubble and are composed.
7
+ *
8
+ * `deprecated` is the name the event had before it became public. `dispatchPublic` sends and
9
+ * `listenPublic` handles both until the next major, then the field goes.
10
+ */
11
+ export interface PublicEventDeclaration {
12
+ kind: 'request' | 'notification';
13
+ scope: 'test' | 'item';
14
+ /** The name before it was public. Dispatched and handled alongside the new one. */
15
+ deprecated?: string;
16
+ }
17
+ export interface RubricPlacement {
18
+ className: string;
19
+ element: Element;
20
+ }
21
+ export interface PublicItemEventMap {
22
+ 'cito-item-response-changed': CustomEvent<InteractionChangedDetails>;
23
+ 'cito-item-outcome-changed': CustomEvent<OutcomeChangedDetails>;
24
+ /** Cancelable: `preventDefault()` keeps the rubric block where it is. */
25
+ 'cito-item-rubric-placement': CustomEvent<RubricPlacement>;
26
+ }
27
+ export type PublicItemEventName = keyof PublicItemEventMap;
28
+ export declare const PUBLIC_ITEM_EVENTS: Record<PublicItemEventName, PublicEventDeclaration>;
29
+ declare global {
30
+ interface HTMLElementEventMap extends PublicItemEventMap {
31
+ }
32
+ }
33
+ /**
34
+ * Dispatch `name` and its deprecated name with the same `detail` object, new name first. Returns
35
+ * `false` when a listener of either cancelled the event. The detail is always an object.
36
+ * Shared by the item and test tiers; use `dispatchPublic` (item) or the test's own wrapper.
37
+ */
38
+ export declare function dispatchDeclared(target: EventTarget, declarations: Record<string, PublicEventDeclaration>, name: string, detail: unknown, cancelable?: boolean): boolean;
39
+ /**
40
+ * Listen for `name` and its deprecated name. `dispatchDeclared` sends the old name straight after
41
+ * the new one, synchronously, with the same `detail`: that one is skipped, so the handler runs
42
+ * once. A host that sends only the old name is handled too, and warned once per name in the
43
+ * console: only a sender outside our own components gets here without the new name before it.
44
+ */
45
+ export declare function listenDeclared(target: EventTarget, declarations: Record<string, PublicEventDeclaration>, name: string, handler: (e: Event) => void): void;
46
+ export declare function dispatchPublic<K extends PublicItemEventName>(target: EventTarget, name: K, detail: PublicItemEventMap[K] extends CustomEvent<infer D> ? D : never, cancelable?: boolean): boolean;
47
+ export declare function listenPublic<K extends PublicItemEventName>(target: EventTarget, name: K, handler: (e: PublicItemEventMap[K]) => void): void;
@@ -0,0 +1,58 @@
1
+ export const PUBLIC_ITEM_EVENTS = {
2
+ // The old name `qti-assessment-item-connected` stays as internal plumbing: it is sent separately.
3
+ 'cito-item-rendered': { kind: 'notification', scope: 'item' },
4
+ 'cito-item-response-changed': { kind: 'notification', scope: 'item', deprecated: 'qti-interaction-changed' },
5
+ 'cito-item-outcome-changed': { kind: 'notification', scope: 'item', deprecated: 'qti-outcome-changed' },
6
+ 'cito-item-rubric-placement': {
7
+ kind: 'notification',
8
+ scope: 'item',
9
+ deprecated: 'qti-rubric:discretionary-placement'
10
+ }
11
+ };
12
+ /**
13
+ * Dispatch `name` and its deprecated name with the same `detail` object, new name first. Returns
14
+ * `false` when a listener of either cancelled the event. The detail is always an object.
15
+ * Shared by the item and test tiers; use `dispatchPublic` (item) or the test's own wrapper.
16
+ */
17
+ export function dispatchDeclared(target, declarations, name, detail, cancelable = false) {
18
+ const init = { detail: detail ?? {}, bubbles: true, composed: true, cancelable };
19
+ const notCancelled = target.dispatchEvent(new CustomEvent(name, init));
20
+ const { deprecated } = declarations[name];
21
+ if (!deprecated)
22
+ return notCancelled;
23
+ return target.dispatchEvent(new CustomEvent(deprecated, init)) && notCancelled;
24
+ }
25
+ const warned = new Set();
26
+ /**
27
+ * Listen for `name` and its deprecated name. `dispatchDeclared` sends the old name straight after
28
+ * the new one, synchronously, with the same `detail`: that one is skipped, so the handler runs
29
+ * once. A host that sends only the old name is handled too, and warned once per name in the
30
+ * console: only a sender outside our own components gets here without the new name before it.
31
+ */
32
+ export function listenDeclared(target, declarations, name, handler) {
33
+ let justHandled;
34
+ target.addEventListener(name, e => {
35
+ justHandled = e.detail;
36
+ queueMicrotask(() => (justHandled = undefined));
37
+ handler(e);
38
+ });
39
+ const { deprecated } = declarations[name];
40
+ if (deprecated) {
41
+ target.addEventListener(deprecated, e => {
42
+ if (justHandled !== undefined && e.detail === justHandled)
43
+ return;
44
+ if (!warned.has(deprecated)) {
45
+ warned.add(deprecated);
46
+ console.warn(`[qti-components] The event "${deprecated}" is deprecated; dispatch "${name}" instead.`);
47
+ }
48
+ handler(e);
49
+ });
50
+ }
51
+ }
52
+ export function dispatchPublic(target, name, detail, cancelable = false) {
53
+ return dispatchDeclared(target, PUBLIC_ITEM_EVENTS, name, detail, cancelable);
54
+ }
55
+ export function listenPublic(target, name, handler) {
56
+ listenDeclared(target, PUBLIC_ITEM_EVENTS, name, handler);
57
+ }
58
+ //# sourceMappingURL=public-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAkCA,MAAM,CAAC,MAAM,kBAAkB,GAAwD;IACrF,kGAAkG;IAClG,oBAAoB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAC7D,4BAA4B,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE;IAC5G,2BAA2B,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE;IACvG,4BAA4B,EAAE;QAC5B,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,MAAM;QACb,UAAU,EAAE,oCAAoC;KACjD;CACF,CAAC;AAMF;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAmB,EACnB,YAAoD,EACpD,IAAY,EACZ,MAAe,EACf,UAAU,GAAG,KAAK;IAElB,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACjF,MAAM,YAAY,GAAG,MAAM,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AAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,IAAO,EACP,MAAsE,EACtE,UAAU,GAAG,KAAK;IAElB,OAAO,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAA2C;IAE3C,cAAc,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import type { InteractionChangedDetails, OutcomeChangedDetails } from './internal/event-types';\n\n/**\n * The public events of the item. The name tells you it is public: everything declared here starts\n * with `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs, notifications are past tense. All bubble and are composed.\n *\n * `deprecated` is the name the event had before it became public. `dispatchPublic` sends and\n * `listenPublic` handles both until the next major, then the field goes.\n */\nexport interface PublicEventDeclaration {\n kind: 'request' | 'notification';\n scope: 'test' | 'item';\n /** The name before it was public. Dispatched and handled alongside the new one. */\n deprecated?: string;\n}\n\nexport interface RubricPlacement {\n className: string;\n element: Element;\n}\n\nexport interface PublicItemEventMap {\n // `cito-item-rendered` (detail: the `QtiAssessmentItem`) is added by qti-assessment-item.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-item-response-changed': CustomEvent<InteractionChangedDetails>;\n 'cito-item-outcome-changed': CustomEvent<OutcomeChangedDetails>;\n /** Cancelable: `preventDefault()` keeps the rubric block where it is. */\n 'cito-item-rubric-placement': CustomEvent<RubricPlacement>;\n}\n\nexport type PublicItemEventName = keyof PublicItemEventMap;\n\nexport const PUBLIC_ITEM_EVENTS: Record<PublicItemEventName, PublicEventDeclaration> = {\n // The old name `qti-assessment-item-connected` stays as internal plumbing: it is sent separately.\n 'cito-item-rendered': { kind: 'notification', scope: 'item' },\n 'cito-item-response-changed': { kind: 'notification', scope: 'item', deprecated: 'qti-interaction-changed' },\n 'cito-item-outcome-changed': { kind: 'notification', scope: 'item', deprecated: 'qti-outcome-changed' },\n 'cito-item-rubric-placement': {\n kind: 'notification',\n scope: 'item',\n deprecated: 'qti-rubric:discretionary-placement'\n }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicItemEventMap {}\n}\n\n/**\n * Dispatch `name` and its deprecated name with the same `detail` object, new name first. Returns\n * `false` when a listener of either cancelled the event. The detail is always an object.\n * Shared by the item and test tiers; use `dispatchPublic` (item) or the test's own wrapper.\n */\nexport function dispatchDeclared(\n target: EventTarget,\n declarations: Record<string, PublicEventDeclaration>,\n name: string,\n detail: unknown,\n cancelable = false\n): boolean {\n const init = { detail: detail ?? {}, bubbles: true, composed: true, cancelable };\n const notCancelled = target.dispatchEvent(new CustomEvent(name, init));\n const { deprecated } = declarations[name];\n if (!deprecated) return notCancelled;\n return target.dispatchEvent(new CustomEvent(deprecated, init)) && notCancelled;\n}\n\nconst warned = new Set<string>();\n\n/**\n * Listen for `name` and its deprecated name. `dispatchDeclared` sends the old name straight after\n * the new one, synchronously, with the same `detail`: that one is skipped, so the handler runs\n * once. A host that sends only the old name is handled too, and warned once per name in the\n * console: only a sender outside our own components gets here without the new name before it.\n */\nexport function listenDeclared(\n target: EventTarget,\n declarations: Record<string, PublicEventDeclaration>,\n name: string,\n handler: (e: Event) => void\n): void {\n let justHandled: unknown;\n target.addEventListener(name, e => {\n justHandled = (e as CustomEvent).detail;\n queueMicrotask(() => (justHandled = undefined));\n handler(e);\n });\n const { deprecated } = declarations[name];\n if (deprecated) {\n target.addEventListener(deprecated, e => {\n if (justHandled !== undefined && (e as CustomEvent).detail === justHandled) return;\n if (!warned.has(deprecated)) {\n warned.add(deprecated);\n console.warn(`[qti-components] The event \"${deprecated}\" is deprecated; dispatch \"${name}\" instead.`);\n }\n handler(e);\n });\n }\n}\n\nexport function dispatchPublic<K extends PublicItemEventName>(\n target: EventTarget,\n name: K,\n detail: PublicItemEventMap[K] extends CustomEvent<infer D> ? D : never,\n cancelable = false\n): boolean {\n return dispatchDeclared(target, PUBLIC_ITEM_EVENTS, name, detail, cancelable);\n}\n\nexport function listenPublic<K extends PublicItemEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicItemEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_ITEM_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qti-components/elements",
3
3
  "description": "QTI elements utilities",
4
- "version": "1.9.0",
4
+ "version": "1.10.0-next.0",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@qti-components/base": "^2.4.0",
@@ -27,6 +27,10 @@
27
27
  "types": "./dist/elements.d.ts",
28
28
  "import": "./dist/elements.js"
29
29
  },
30
+ "./public-events": {
31
+ "types": "./dist/public-events.d.ts",
32
+ "import": "./dist/public-events.js"
33
+ },
30
34
  "./register": {
31
35
  "types": "./dist/register.d.ts",
32
36
  "import": "./dist/register.js"