@qti-components/test 2.0.0-next.27 → 2.0.0-next.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +3 -8
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
- package/dist/components/test-end-attempt/test-end-attempt.js +6 -4
- package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
- package/dist/components/test-navigation/test-navigation.js +23 -7
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/components/test-next/test-next.js +4 -4
- package/dist/components/test-next/test-next.js.map +1 -1
- package/dist/components/test-prev/test-prev.js +4 -4
- package/dist/components/test-prev/test-prev.js.map +1 -1
- package/dist/computed-tree.d.ts +20 -0
- package/dist/computed-tree.js +22 -0
- package/dist/computed-tree.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/delivery-state-conversion.d.ts +15 -5
- package/dist/internal/delivery-state-conversion.js +36 -9
- package/dist/internal/delivery-state-conversion.js.map +1 -1
- package/dist/internal/derive-computed-context.d.ts +12 -4
- package/dist/internal/derive-computed-context.js +30 -21
- package/dist/internal/derive-computed-context.js.map +1 -1
- package/dist/internal/test-host.context.d.ts +2 -0
- package/dist/internal/test-host.context.js.map +1 -1
- package/dist/mixins/test-base.d.ts +2 -0
- package/dist/mixins/test-base.js +16 -0
- package/dist/mixins/test-base.js.map +1 -1
- package/dist/mixins/test-state.mixin.js +3 -1
- package/dist/mixins/test-state.mixin.js.map +1 -1
- package/dist/plugin-api.d.ts +1 -1
- package/dist/plugin-api.js +1 -1
- package/dist/plugin-api.js.map +1 -1
- package/dist/public-events.d.ts +9 -0
- package/dist/public-events.js +1 -0
- package/dist/public-events.js.map +1 -1
- package/dist/state-from-contexts.d.ts +1 -0
- package/dist/state-from-contexts.js +2 -1
- package/dist/state-from-contexts.js.map +1 -1
- package/dist/types/qti-test-state.d.ts +5 -0
- package/dist/types/qti-test-state.js.map +1 -1
- package/package.json +3 -3
- package/dist/items-in-order.d.ts +0 -9
- package/dist/items-in-order.js +0 -15
- package/dist/items-in-order.js.map +0 -1
|
@@ -11,6 +11,7 @@ import { prepareTemplate } from '@heximal/templates';
|
|
|
11
11
|
import { computedContext } from '@qti-components/base';
|
|
12
12
|
import { testHostContext } from '../../internal/test-host.context';
|
|
13
13
|
import { dispatchPublic } from '../../public-events';
|
|
14
|
+
import { itemsInOrder } from '../../computed-tree';
|
|
14
15
|
// Converter function to interpret "true" and "false" as booleans
|
|
15
16
|
const stringToBooleanConverter = {
|
|
16
17
|
fromAttribute(value) {
|
|
@@ -103,14 +104,8 @@ export class QtiAssessmentItemRef extends LitElement {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
#computedItem() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const item = section.items.find(i => i.identifier === this.identifier);
|
|
109
|
-
if (item)
|
|
110
|
-
return item;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return undefined;
|
|
107
|
+
// This element's identifier is the item instance: a clone's is `item-3#2`.
|
|
108
|
+
return this.computedContext?.testParts.flatMap(itemsInOrder).find(i => i.instance === this.identifier);
|
|
114
109
|
}
|
|
115
110
|
/**
|
|
116
111
|
* The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qti-assessment-item-ref.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB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E,wBAAwB,EAAE,CAAC;mDAAiB;AACtD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAe;AAKhC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6DACX;AA0B5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACN;AAc7B;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sDACzB","sourcesContent":["import { LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TemplateFunction } from '@heximal/templates';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * The model a `<template item-ref>` is rendered with.\n *\n * Only what this element already knows: the item's parsed document and the\n * attributes off the item-ref itself. `itemRef` is the escape hatch — a\n * template that needs anything else (a click handler, a value from the host\n * app) reaches it through a property on the element, which the host is free to\n * set.\n */\nexport interface ItemRefTemplateModel {\n /** The item's parsed document, i.e. what the element renders by default. */\n xmlDoc: DocumentFragment;\n identifier?: string;\n href?: string;\n category?: string;\n /**\n * This item's entry in the computed context, the same object the stamps\n * iterate as `item`: `index` (1-based, null for info items), `score`,\n * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.\n */\n item?: ComputedItem;\n /** The element being rendered. */\n itemRef: QtiAssessmentItemRef;\n}\n\n// @customElement('qti-assessment-item-ref')\nexport class QtiAssessmentItemRef extends LitElement {\n @property({ type: String }) category?: string;\n @property({ type: String }) identifier?: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) required?: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed?: boolean;\n @property({ type: String }) href?: string;\n\n // Only read by a <template item-ref>; subscribing re-renders it as scores come in\n @state()\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n /**\n * The `<qti-weight>` children of this ref, keyed by identifier — what\n * `qti-test-variables`' `weight-identifier` resolves against.\n *\n * Read on access rather than cached: the test document is rendered into this\n * element's light DOM, so the weights are not in place at construction time,\n * and outcome processing runs long after they are.\n */\n get weights(): Map<string, number> {\n const weights = new Map<string, number>();\n for (const weight of this.querySelectorAll(':scope > qti-weight')) {\n const identifier = weight.getAttribute('identifier');\n if (!identifier) continue;\n const value = Number(weight.getAttribute('value'));\n if (Number.isNaN(value)) {\n console.warn(`qti-weight \"${identifier}\" has a non-numeric value, ignoring it`);\n continue;\n }\n weights.set(identifier, value);\n }\n return weights;\n }\n\n @property({ type: Object, attribute: false })\n xmlDoc: DocumentFragment | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n get assessmentItem(): QtiAssessmentItem | null {\n return this.renderRoot?.querySelector('qti-assessment-item');\n }\n\n myTemplate: TemplateFunction | null = null;\n\n /** The `qti-test` this ref belongs to, wherever it renders: light DOM, or any depth of shadow roots. */\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n // A context consumer keeps its last value when it is moved somewhere with no provider, and\n // `closest()` never did: a ref moved out of a test must not keep that test's template.\n this.testHost = undefined;\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n\n /*\n Optional per-item template, used to render extra things around an item —\n a bookmark, an index number, a score badge. Put it in the light DOM of\n your qti-test, and every item-ref in the test renders with it:\n\n <qti-test>\n <template item-ref>\n <div class=\"badge\">{{ identifier }}</div>\n {{ xmlDoc }}\n </template>\n …\n </qti-test>\n\n The template is the WHOLE render, so it has to place {{ xmlDoc }} itself;\n leaving it out renders the chrome and no item. Without a template the\n element renders the item on its own, exactly as before.\n\n Resolved once, on connect: one template serves every item, and everything\n that varies per item comes through the model (see ItemRefTemplateModel).\n */\n const templateElement = this.testHost?.querySelector<HTMLTemplateElement>('template[item-ref]');\n this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;\n this.requestUpdate();\n\n await this.updateComplete;\n\n dispatchPublic(this, 'qc-item-ref-connected', {\n identifier: this.identifier,\n href: this.href,\n category: this.category\n });\n }\n\n #computedItem(): ComputedItem | undefined {\n for (const testPart of this.computedContext?.testParts ?? []) {\n for (const section of testPart.sections) {\n const item = section.items.find(i => i.identifier === this.identifier);\n if (item) return item;\n }\n }\n return undefined;\n }\n\n /**\n * The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned\n * once per document and template, not per render: re-renders from\n * computed-context changes then hand Lit the same fragment, which it leaves\n * alone, instead of rebuilding the item (and reloading its PCIs, which\n * changes the context again).\n */\n #rendered: { source: DocumentFragment; template: TemplateFunction | null; doc: DocumentFragment } | null = null;\n\n override render() {\n // Item refs connect before loading, and navigation clears their documents.\n if (!this.xmlDoc) {\n this.#rendered = null;\n return nothing;\n }\n\n if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {\n this.#rendered = {\n source: this.xmlDoc,\n template: this.myTemplate,\n doc: this.xmlDoc.cloneNode(true) as DocumentFragment\n };\n }\n const xmlDoc = this.#rendered.doc;\n if (!this.myTemplate) return xmlDoc;\n\n const model: ItemRefTemplateModel = {\n xmlDoc,\n identifier: this.identifier,\n href: this.href,\n category: this.category,\n item: this.#computedItem(),\n itemRef: this\n };\n return this.myTemplate(model);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item-ref': QtiAssessmentItemRef;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"qti-assessment-item-ref.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOnD,iEAAiE;AACjE,MAAM,wBAAwB,GAAG;IAC/B,aAAa,CAAC,KAAa;QACzB,OAAO,KAAK,KAAK,MAAM,CAAC;IAC1B,CAAC;IACD,WAAW,CAAC,KAAc;QACxB,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAClC,CAAC;CACF,CAAC;AA2BF,4CAA4C;AAC5C,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAApD;;QAoCE,WAAM,GAA4B,IAAI,CAAC;QAUvC,eAAU,GAA4B,IAAI,CAAC;QAsD3C;;;;;;WAMG;QACH,cAAS,GAAkG,IAAI,CAAC;IA6BlH,CAAC;IA5HC;;;;;;;OAOG;IACH,IAAI,OAAO;QACT,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC1C,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAClE,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CA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Q,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAqB;AACkB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;sDAAoB;AACnB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;mDAAiB;AACtD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAe;AAKhC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6DACX;AA0B5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACN;AAc7B;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sDACzB","sourcesContent":["import { LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { dispatchPublic } from '../../public-events';\nimport { itemsInOrder } from '../../computed-tree';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TemplateFunction } from '@heximal/templates';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * The model a `<template item-ref>` is rendered with.\n *\n * Only what this element already knows: the item's parsed document and the\n * attributes off the item-ref itself. `itemRef` is the escape hatch — a\n * template that needs anything else (a click handler, a value from the host\n * app) reaches it through a property on the element, which the host is free to\n * set.\n */\nexport interface ItemRefTemplateModel {\n /** The item's parsed document, i.e. what the element renders by default. */\n xmlDoc: DocumentFragment;\n identifier?: string;\n href?: string;\n category?: string;\n /**\n * This item's entry in the computed context, the same object the stamps\n * iterate as `item`: `index` (1-based, null for info items), `score`,\n * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.\n */\n item?: ComputedItem;\n /** The element being rendered. */\n itemRef: QtiAssessmentItemRef;\n}\n\n// @customElement('qti-assessment-item-ref')\nexport class QtiAssessmentItemRef extends LitElement {\n @property({ type: String }) category?: string;\n @property({ type: String }) identifier?: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) required?: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed?: boolean;\n @property({ type: String }) href?: string;\n\n // Only read by a <template item-ref>; subscribing re-renders it as scores come in\n @state()\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n /**\n * The `<qti-weight>` children of this ref, keyed by identifier — what\n * `qti-test-variables`' `weight-identifier` resolves against.\n *\n * Read on access rather than cached: the test document is rendered into this\n * element's light DOM, so the weights are not in place at construction time,\n * and outcome processing runs long after they are.\n */\n get weights(): Map<string, number> {\n const weights = new Map<string, number>();\n for (const weight of this.querySelectorAll(':scope > qti-weight')) {\n const identifier = weight.getAttribute('identifier');\n if (!identifier) continue;\n const value = Number(weight.getAttribute('value'));\n if (Number.isNaN(value)) {\n console.warn(`qti-weight \"${identifier}\" has a non-numeric value, ignoring it`);\n continue;\n }\n weights.set(identifier, value);\n }\n return weights;\n }\n\n @property({ type: Object, attribute: false })\n xmlDoc: DocumentFragment | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n get assessmentItem(): QtiAssessmentItem | null {\n return this.renderRoot?.querySelector('qti-assessment-item');\n }\n\n myTemplate: TemplateFunction | null = null;\n\n /** The `qti-test` this ref belongs to, wherever it renders: light DOM, or any depth of shadow roots. */\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n // A context consumer keeps its last value when it is moved somewhere with no provider, and\n // `closest()` never did: a ref moved out of a test must not keep that test's template.\n this.testHost = undefined;\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n\n /*\n Optional per-item template, used to render extra things around an item —\n a bookmark, an index number, a score badge. Put it in the light DOM of\n your qti-test, and every item-ref in the test renders with it:\n\n <qti-test>\n <template item-ref>\n <div class=\"badge\">{{ identifier }}</div>\n {{ xmlDoc }}\n </template>\n …\n </qti-test>\n\n The template is the WHOLE render, so it has to place {{ xmlDoc }} itself;\n leaving it out renders the chrome and no item. Without a template the\n element renders the item on its own, exactly as before.\n\n Resolved once, on connect: one template serves every item, and everything\n that varies per item comes through the model (see ItemRefTemplateModel).\n */\n const templateElement = this.testHost?.querySelector<HTMLTemplateElement>('template[item-ref]');\n this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;\n this.requestUpdate();\n\n await this.updateComplete;\n\n dispatchPublic(this, 'qc-item-ref-connected', {\n identifier: this.identifier,\n href: this.href,\n category: this.category\n });\n }\n\n #computedItem(): ComputedItem | undefined {\n // This element's identifier is the item instance: a clone's is `item-3#2`.\n return this.computedContext?.testParts.flatMap(itemsInOrder).find(i => i.instance === this.identifier);\n }\n\n /**\n * The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned\n * once per document and template, not per render: re-renders from\n * computed-context changes then hand Lit the same fragment, which it leaves\n * alone, instead of rebuilding the item (and reloading its PCIs, which\n * changes the context again).\n */\n #rendered: { source: DocumentFragment; template: TemplateFunction | null; doc: DocumentFragment } | null = null;\n\n override render() {\n // Item refs connect before loading, and navigation clears their documents.\n if (!this.xmlDoc) {\n this.#rendered = null;\n return nothing;\n }\n\n if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {\n this.#rendered = {\n source: this.xmlDoc,\n template: this.myTemplate,\n doc: this.xmlDoc.cloneNode(true) as DocumentFragment\n };\n }\n const xmlDoc = this.#rendered.doc;\n if (!this.myTemplate) return xmlDoc;\n\n const model: ItemRefTemplateModel = {\n xmlDoc,\n identifier: this.identifier,\n href: this.href,\n category: this.category,\n item: this.#computedItem(),\n itemRef: this\n };\n return this.myTemplate(model);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item-ref': QtiAssessmentItemRef;\n }\n}\n"]}
|
|
@@ -11,6 +11,7 @@ import { computedContext } from '@qti-components/base';
|
|
|
11
11
|
import { watch } from '@qti-components/utilities';
|
|
12
12
|
import * as styles from '../styles';
|
|
13
13
|
import { dispatchPublic } from '../../public-events';
|
|
14
|
+
import { activeTestPart, itemsInOrder } from '../../computed-tree';
|
|
14
15
|
/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */
|
|
15
16
|
const itemRefOf = (element) => {
|
|
16
17
|
const itemRef = element.closest('qti-assessment-item-ref');
|
|
@@ -74,13 +75,14 @@ export class TestEndAttempt extends LitElement {
|
|
|
74
75
|
checkDisabled() {
|
|
75
76
|
const testParts = this.computedContext?.testParts;
|
|
76
77
|
const ownItem = this.#ownItem;
|
|
77
|
-
const testPart =
|
|
78
|
+
const testPart = activeTestPart(this.computedContext);
|
|
78
79
|
if (!testParts || (!ownItem && !testPart))
|
|
79
80
|
return;
|
|
80
|
-
// Its own item wherever it is in the test, or else the item
|
|
81
|
+
// Its own item (an instance: a clone is `item-3#2`) wherever it is in the test, or else the item
|
|
82
|
+
// on screen in the active part.
|
|
81
83
|
const activeItem = ownItem
|
|
82
|
-
? testParts.flatMap(
|
|
83
|
-
: testPart
|
|
84
|
+
? testParts.flatMap(itemsInOrder).find(i => i.instance === ownItem)
|
|
85
|
+
: itemsInOrder(testPart).find(item => item.active);
|
|
84
86
|
if (!activeItem) {
|
|
85
87
|
this._internalDisabled = false;
|
|
86
88
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInE,2HAA2H;AAC3H,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAsB,EAAE;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC3D,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,SAAS,C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SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAEJ;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAe;AAG8B;IAAxE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;qDAAuB;AAG/F;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB;AAuDH;;;GAGG;AACH,SAAS,kBAAkB,CAAC,IAAkB;IAC5C,MAAM,EAAE,WAAW,GAAG,CAAC,EAAE,aAAa,GAAG,IAAI,EAAE,iBAAiB,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;IACvG,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ;QAChC,CAAC,CAAC,IAAI,CAAC,gBAAgB,KAAK,WAAW;QACvC,CAAC,CAAC,WAAW,KAAK,CAAC,IAAI,WAAW,GAAG,WAAW,CAAC;IACnD,MAAM,OAAO,GAAG,aAAa,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;IACzD,OAAO,YAAY,IAAI,OAAO,IAAI,CAAC,CAAC,iBAAiB,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AACjF,CAAC","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { activeTestPart, itemsInOrder } from '../../computed-tree';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A button that ends the attempt of an item: its response is processed, `numAttempts` goes up and\n * feedback is shown as the item's session control allows. It dispatches `qc-test-end-attempt`,\n * which `<test-navigation>` handles.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it ends the attempt of the item on\n * screen, or in the `<template item-ref>`, where each item gets its own and it ends the attempt of\n * that item: with `<qti-test navigate=\"section\">` every item of the section is on screen, each with\n * its own button. Give it an `item` (an item-ref identifier) to end the attempt of that item instead,\n * wherever the button sits.\n *\n * It is `disabled` by its item's session (`computedContext` item `rules`): when the item is not\n * interacting (its attempts used, a completed adaptive item, or passed in a linear part), when no\n * attempt is left, or while its responses may not be submitted (`allow-skipping=\"false\"` with no\n * answer, `validate-responses` with an invalid one). The score never disables it: a right answer\n * leaves the attempts `max-attempts` gives (decided 2026-11-27). In a simultaneous part it ends the\n * item's attempt as before, until part submission processes the responses (roadmap 1, T6).\n *\n * @slot - The label.\n * @attr require-answer - Also disabled while the response is invalid or still the default, whatever the item's session control says.\n * @attr item - The item-ref identifier whose attempt this button ends; without it, the item it is stamped into, or else the one on screen.\n * @attr disabled - Reflected: the item's attempt cannot be ended.\n */\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @property({ reflect: true }) item?: string;\n\n /** Ends no attempt until the response is valid and not the default, whatever the item's `allow-skipping` says. */\n @property({ type: Boolean, reflect: true, attribute: 'require-answer' }) requireAnswer = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = styles.button;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n // An item of its own goes along, so the navigation ends that item's attempt and not the\n // one on screen; without one, the navigation takes the item on screen, as before.\n const itemId = this.#ownItem;\n dispatchPublic(this, 'qc-test-end-attempt', itemId ? { itemId } : {});\n }\n });\n }\n\n /** The item named by `item`, or else the item-ref it is stamped into. */\n get #ownItem(): string | undefined {\n return this.item || itemRefOf(this);\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testParts = this.computedContext?.testParts;\n const ownItem = this.#ownItem;\n const testPart = activeTestPart(this.computedContext);\n if (!testParts || (!ownItem && !testPart)) return;\n // Its own item (an instance: a clone is `item-3#2`) wherever it is in the test, or else the item\n // on screen in the active part.\n const activeItem = ownItem\n ? testParts.flatMap(itemsInOrder).find(i => i.instance === ownItem)\n : itemsInOrder(testPart).find(item => item.active);\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const rules = activeItem.rules;\n // `interactive && attemptsLeft` is `mayEndAttempt` in a part with individual submission; it also\n // covers a simultaneous part, kept until T6, and `auto-score-items`, whose sessions stay open.\n const mayEnd = rules ? rules.interactive && rules.attemptsLeft && rules.maySubmit : fromSessionControl(activeItem);\n const answered = activeItem.valid !== false && !activeItem.isDefaultResponse;\n this._internalDisabled = !mayEnd || (this.requireAnswer && !answered);\n }\n\n override render() {\n return styles.control;\n }\n}\n\n/**\n * For a computed item without `rules` (a context a host built): the same QTI rules from its session\n * control, attempts and responses (`qti-item-session-control`, info model §7.19).\n */\nfunction fromSessionControl(item: ComputedItem): boolean {\n const { maxAttempts = 1, allowSkipping = true, validateResponses = false } = item.sessionControl ?? {};\n const numAttempts = item.numAttempts || 0;\n const attemptsLeft = item.adaptive\n ? item.completionStatus !== 'completed'\n : maxAttempts === 0 || numAttempts < maxAttempts;\n const maySkip = allowSkipping || !item.isDefaultResponse;\n return attemptsLeft && maySkip && (!validateResponses || item.valid !== false);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
|
|
@@ -19,6 +19,7 @@ import { attemptsOf, itemSessionFacts } from '../../internal/item-session-facts'
|
|
|
19
19
|
import { renderedMarkup } from '../../internal/rendered-markup';
|
|
20
20
|
import { testHostContext } from '../../internal/test-host.context';
|
|
21
21
|
import { listenPublic } from '../../public-events';
|
|
22
|
+
import { itemsInOrder } from '../../computed-tree';
|
|
22
23
|
/** A new object each time: a host that mutates the one it read must not change anyone else's. */
|
|
23
24
|
const newQtiContext = () => ({
|
|
24
25
|
QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }
|
|
@@ -189,6 +190,26 @@ export class TestNavigation extends LitElement {
|
|
|
189
190
|
this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));
|
|
190
191
|
listenPublic(this, 'qc-test-end-attempt', this.#handleTestEndAttempt.bind(this));
|
|
191
192
|
listenPublic(this, 'qc-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));
|
|
193
|
+
listenPublic(this, 'qc-test-update-comment', this.#handleUpdateComment.bind(this));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Sets the candidate's comment on an item when its session allows it (`rules.mayComment`:
|
|
197
|
+
* `allow-comment`, while interacting; decided 2026-11-27, carried, not rendered).
|
|
198
|
+
*/
|
|
199
|
+
#handleUpdateComment(event) {
|
|
200
|
+
const { itemId, comment = null } = event.detail ?? {};
|
|
201
|
+
const host = this.#testHost.value;
|
|
202
|
+
if (!itemId || !host)
|
|
203
|
+
return;
|
|
204
|
+
if (comment !== null && typeof comment !== 'string') {
|
|
205
|
+
console.warn(`[qti-test] Ignoring a comment for "${itemId}" that is not a string.`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (!this.computedItemFor(itemId)?.rules?.mayComment) {
|
|
209
|
+
console.warn(`[qti-test] Ignoring a comment for "${itemId}": its allow-comment is false, or it is not interacting.`);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
host.updateItemComment(itemId, comment);
|
|
192
213
|
}
|
|
193
214
|
/**
|
|
194
215
|
* Latch whether an item reached its optimal outcome whenever it has just ended
|
|
@@ -285,10 +306,7 @@ export class TestNavigation extends LitElement {
|
|
|
285
306
|
afterAttemptEnded(_assessmentItem, _computedItem, _done) { }
|
|
286
307
|
/** The computed-context entry for an item, from the session-control cascade. */
|
|
287
308
|
computedItemFor(identifier) {
|
|
288
|
-
return this.computedContext?.testParts
|
|
289
|
-
?.flatMap(part => part.sections)
|
|
290
|
-
.flatMap(section => section.items)
|
|
291
|
-
.find(i => i.identifier === identifier);
|
|
309
|
+
return this.computedContext?.testParts.flatMap(itemsInOrder).find(i => i.instance === identifier);
|
|
292
310
|
}
|
|
293
311
|
/** The assessment item for an item-ref id, if it has been rendered. */
|
|
294
312
|
#assessmentItemFor(identifier) {
|
|
@@ -487,9 +505,7 @@ export class TestNavigation extends LitElement {
|
|
|
487
505
|
return;
|
|
488
506
|
// In a simultaneous part every item has one attempt, processed when the part ends (QTI info model
|
|
489
507
|
// §2.8.2), so the candidate may change the answer until then: TAO keeps such an item open too.
|
|
490
|
-
const items = new Map(this.computedContext.testParts.flatMap(part => part.submissionMode === 'simultaneous'
|
|
491
|
-
? []
|
|
492
|
-
: part.sections.flatMap(section => section.items.map(item => [item.identifier, item]))));
|
|
508
|
+
const items = new Map(this.computedContext.testParts.flatMap(part => part.submissionMode === 'simultaneous' ? [] : itemsInOrder(part).map(item => [item.instance, item])));
|
|
493
509
|
for (const itemRef of this.#testElement.querySelectorAll('qti-assessment-item-ref')) {
|
|
494
510
|
const element = itemRef.assessmentItem;
|
|
495
511
|
if (!element)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-navigation.js","sourceRoot":"","sources":["../../../src/components/test-navigation/test-navigation.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE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CAAC,QAAQ,GAAG,IAAI,CAAC;gBACxB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACjC,CAAC;iBAAM,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAClC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAxhB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAA4C;AAUhE;IADN,KAAK,EAAE;mDAC8D;AAiH/D;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;qDACZ;AAI/B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oDACd;AAI3B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACX;AAKjC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDAClB;AAI5B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;uDACK;AAEiB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;sDAAwB","sourcesContent":["import { ContextConsumer, consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\nimport {\n buildTestModel,\n endItemAttempt,\n followItemSession,\n itemRefsInOrder,\n readItemFacts,\n seedItemLifecycle\n} from '@qti-components/delivery';\nimport { configContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\nimport { sessionContext } from '@qti-components/base';\nimport { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';\n\nimport { assessOptimality, deriveComputedContext } from '../../internal/derive-computed-context';\nimport { itemFactsContext } from '../../internal/item-facts.context';\nimport { attemptsOf, itemSessionFacts } from '../../internal/item-session-facts';\nimport { renderedMarkup } from '../../internal/rendered-markup';\nimport { testHostContext } from '../../internal/test-host.context';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiContext } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { ItemSession, ItemSessionFacts, TestModel } from '@qti-components/delivery';\nimport type { ItemOptimality } from '../../internal/derive-computed-context';\nimport type { ItemFactsByRef } from '../../internal/item-facts.context';\nimport type { LinearNextRefusal, TestHost } from '../../internal/test-host.context';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\n/** A new object each time: a host that mutates the one it read must not change anyone else's. */\nconst newQtiContext = (): QtiContext => ({\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n});\n\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier: string | undefined = undefined;\n\n /**\n * Your own per-item fields, by item-ref `identifier`: each `computedContext` item carries them as\n * given under `data`, without the identifier, and so does every view of it a plugin derives. They\n * never replace a field the test, the item or the candidate's state gives, whatever its name; a\n * template reads `activeItem.data.<field>`. To mark an item as scored by hand, set\n * `external-scored` on its `SCORE` declaration in `postLoadTransformCallback`.\n */\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n /**\n * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the\n * enclosing test's: reading returns it, writing replaces it, so a host that has always set the\n * shuffle seed here keeps working. Removed in the next major.\n *\n * Written before the navigation is inside a test, it waits and is handed over on connect.\n */\n public get qtiContext(): QtiContext {\n return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());\n }\n\n public set qtiContext(value: QtiContext) {\n if (!this.#warnedQtiContext) {\n this.#warnedQtiContext = true;\n console.warn(\n '[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major ' +\n 'release. Set `qtiContext` on `<qti-test>` instead; it is the same value.'\n );\n }\n this.#writeQtiContext(value);\n }\n\n #pendingQtiContext?: QtiContext;\n #warnedQtiContext = false;\n\n /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */\n #writeQtiContext(value: QtiContext): void {\n const owner = this.#owner();\n if (owner) owner.qtiContext = value;\n else this.#pendingQtiContext = value;\n }\n\n /**\n * The `qti-test` this navigation is in, found through context so it works across shadow roots.\n * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.\n */\n #testHost = new ContextConsumer(this, {\n context: testHostContext,\n subscribe: true,\n callback: host => {\n if (host && this.#pendingQtiContext) {\n host.qtiContext = this.#pendingQtiContext;\n this.#pendingQtiContext = undefined;\n }\n if (host) this.#registerLinearNext(host);\n }\n });\n\n /** The `qti-test` this navigation answers Next for in a linear part. */\n #linearNextHost?: TestHost;\n\n #registerLinearNext(host: TestHost): void {\n if (this.#linearNextHost && this.#linearNextHost !== host) this.#linearNextHost.beforeLinearNext = null;\n this.#linearNextHost = host;\n host.beforeLinearNext = this.#beforeLinearNext;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.#linearNextHost) this.#linearNextHost.beforeLinearNext = this.#beforeLinearNext;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.#linearNextHost?.beforeLinearNext === this.#beforeLinearNext) this.#linearNextHost.beforeLinearNext = null;\n }\n\n /**\n * Next in a linear individual part leaves the item for good (implementation guide §4.1), so it\n * submits what the candidate gave (decided 2026-11-27): refused while the session control refuses\n * those responses (`rules.maySubmit`), else the attempt is ended when one is open: none ended yet,\n * or the responses changed since the last. Called by the navigation mixin while the item is still\n * rendered; the item is closed when the navigation moves past it.\n */\n #beforeLinearNext = (itemRefId: string): LinearNextRefusal | null => {\n const part = this.#model?.testParts.find(testPart =>\n itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId)\n );\n if (part?.navigationMode !== 'linear' || part.submissionMode !== 'individual') return null;\n const session = this.#sessions.get(itemRefId);\n const rules = this.computedItemFor(itemRefId)?.rules;\n if (session?.state !== 'interacting' || !rules) return null;\n if (!rules.maySubmit) {\n return { reason: rules.maySkip ? 'validate-responses' : 'allow-skipping', itemId: itemRefId };\n }\n if (session.numAttempts === 0 || this.#changed.has(itemRefId)) {\n this.#assessmentItemFor(itemRefId)?.processResponse(\n true,\n this.configContext?.reportValidityAfterScoring === true\n );\n }\n return null;\n };\n\n /** The item-refs whose responses changed since their last ended attempt. */\n #changed = new Set<string>();\n\n #itemRefIdOf(element: EventTarget | undefined): string | undefined {\n const item = (element as HTMLElement | undefined)?.closest?.('qti-assessment-item');\n if (!item) return undefined;\n return [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])].find(\n itemRef => itemRef.assessmentItem === item\n )?.identifier;\n }\n\n #owner(): { qtiContext: QtiContext } | null {\n return this.#testHost.value ?? null;\n }\n\n @state()\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n /** Read from each item's XML when `qti-test` fetches it; see `itemFactsContext`. */\n @state()\n @consume({ context: itemFactsContext, subscribe: true })\n protected _itemFacts?: ItemFactsByRef;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n #testElement: QtiAssessmentTest;\n\n /**\n * Whether each item's last *ended attempt* reached the optimal outcome, keyed\n * by item-ref id. Written from #handleItemContextUpdated when processResponse\n * ends an attempt — never on a plain selection. Mirrors how inline feedback\n * only re-evaluates when an attempt is processed, so a freshly-picked answer\n * doesn't flip `done` until the candidate ends the attempt.\n */\n #optimality = new Map<string, ItemOptimality>();\n\n /**\n * Each item session's lifecycle state, by item-ref identifier, changed only through the lifecycle\n * table (`followItemSession` as the candidate moves, `endItemAttempt` when an attempt ends). It\n * lives here until `DeliveryState` holds it (roadmap 1, T3d); a session whose attempts change\n * outside an ended attempt (a restored or assigned state) is seeded again.\n */\n #sessions = new Map<string, ItemSession>();\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));\n\n listenItemPublic(this, 'qc-item-response-changed', this.#handleInteractionChanged.bind(this));\n this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));\n\n listenPublic(this, 'qc-test-end-attempt', this.#handleTestEndAttempt.bind(this));\n listenPublic(this, 'qc-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));\n }\n\n /**\n * Latch whether an item reached its optimal outcome whenever it has just ended\n * an attempt. processResponse — fired by test-end-attempt, autoscore, or an\n * in-item end-attempt interaction — flags its context update with\n * `responseProcessed`; a plain selection updates the context without it, so\n * `done` can't flip until the candidate actually ends the attempt.\n */\n #handleItemContextUpdated(event: CustomEvent<{ itemContext: ItemContext; responseProcessed?: boolean }>) {\n if (!event.detail?.responseProcessed) return;\n const itemContext = event.detail.itemContext;\n if (!itemContext?.identifier) return;\n this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n this.#changed.delete(itemContext.identifier);\n this.#endAttempt(itemContext);\n\n const computedItem = this.computedItemFor(itemContext.identifier);\n this.afterAttemptEnded(\n (event.composedPath()[0] as HTMLElement)?.closest<QtiAssessmentItem>('qti-assessment-item'),\n computedItem,\n this.#doneAfterAttempt(itemContext, computedItem)\n );\n }\n\n /**\n * Moves the item's session on for its ended attempt. With `auto-score-items` every change is\n * scored as an attempt, so the count is not the candidate's: it is taken, and the state stays.\n */\n #endAttempt(itemContext: ItemContext): void {\n const facts = this.#sessionFacts().get(itemContext.identifier);\n if (!facts) return;\n const ended: ItemSessionFacts = { ...facts, ...attemptsOf(itemContext) };\n const previous = this.#sessions.get(itemContext.identifier);\n this.#sessions.set(\n itemContext.identifier,\n this.autoScoreItems\n ? {\n state: previous?.state ?? followItemSession(undefined, ended).state,\n numAttempts: ended.numAttempts,\n adaptive: ended.adaptive\n }\n : endItemAttempt(previous, ended)\n );\n }\n\n /**\n * Whether the item session is over after the attempt that just ended: its new state, or, before\n * the test model is known, the state an item on screen with these attempts is in.\n */\n #doneAfterAttempt(itemContext: ItemContext, computedItem: ComputedItem | undefined): boolean {\n const state =\n this.#sessions.get(itemContext.identifier)?.state ??\n (computedItem?.sessionControl\n ? seedItemLifecycle({\n sessionControl: computedItem.sessionControl,\n adaptive: computedItem.adaptive ?? false,\n ...attemptsOf(itemContext),\n presented: true,\n passed: false\n })\n : 'interacting');\n return state === 'closed' || state === 'review' || state === 'solution';\n }\n\n /** The facts of every item session now: the model, the item facts, the contexts and the items on screen. */\n #sessionFacts(): Map<string, ItemSessionFacts> {\n if (!this.#model) return new Map();\n const presented = new Set(\n [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])]\n .filter(itemRef => itemRef.assessmentItem)\n .map(itemRef => itemRef.identifier)\n );\n return itemSessionFacts(this.#model, this.#itemFacts(), this._testContext?.items, {\n current: this._sessionContext?.navItemRefId,\n presented\n });\n }\n\n /**\n * The item facts `qti-test` read from each fetched item, and, for an item rendered without them\n * (handed to its ref directly), the facts read from the rendered item.\n */\n #itemFacts(): ItemFactsByRef | undefined {\n const missing = [\n ...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])\n ].filter(\n itemRef =>\n itemRef.assessmentItem?.localName === 'qti-assessment-item' && !this._itemFacts?.has(itemRef.identifier)\n );\n if (!missing.length) return this._itemFacts;\n const facts = new Map(this._itemFacts ?? []);\n for (const itemRef of missing) facts.set(itemRef.identifier, readItemFacts(renderedMarkup(itemRef.assessmentItem)));\n return facts;\n }\n\n /** Moves every item session on for where the candidate is now. */\n #followSessions(): void {\n for (const [identifier, facts] of this.#sessionFacts()) {\n this.#sessions.set(identifier, followItemSession(this.#sessions.get(identifier), facts));\n }\n }\n\n /**\n * Extension point for presentation packages reacting to an ended attempt. `done` is the item\n * session's after this attempt (closed: its attempts used, whatever the score), settled here\n * because the computed context only catches up on the next update.\n */\n protected afterAttemptEnded(\n _assessmentItem: QtiAssessmentItem | undefined,\n _computedItem: ComputedItem | undefined,\n _done: boolean\n ): void {}\n\n /** The computed-context entry for an item, from the session-control cascade. */\n protected computedItemFor(identifier: string): ComputedItem | undefined {\n return this.computedContext?.testParts\n ?.flatMap(part => part.sections)\n .flatMap(section => section.items)\n .find(i => i.identifier === identifier);\n }\n\n /** The assessment item for an item-ref id, if it has been rendered. */\n #assessmentItemFor(identifier: string | undefined): QtiAssessmentItem | undefined {\n if (!identifier) return undefined;\n const itemRef = this.#testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(identifier)}\"]`\n );\n return itemRef?.assessmentItem ?? undefined;\n }\n\n /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */\n #itemElement = (identifier: string): HTMLElement | null => this.#assessmentItemFor(identifier) ?? null;\n\n /** The currently active assessment item, exposed for optional presentation extensions. */\n protected get activeAssessmentItem(): QtiAssessmentItem | undefined {\n if (!this.#testElement || !this._sessionContext?.navItemRefId) return undefined;\n return this.#testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n )?.assessmentItem;\n }\n\n /**\n * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or\n * given an `item`), or else the item on screen.\n */\n #handleTestEndAttempt(event: CustomEvent<{ itemId?: string } | undefined>) {\n const itemId = event.detail?.itemId;\n const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;\n if (!qtiAssessmentItemEl) return;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n #handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);\n if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n #handleInteractionChanged(_event: CustomEvent) {\n const itemRefId = this.#itemRefIdOf(_event.composedPath()[0]);\n if (itemRefId) this.#changed.add(itemRefId);\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest<QtiAssessmentItem>(\n 'qti-assessment-item'\n );\n // Autoscoring resolves the item from the event's own path, so a change\n // raised outside an assessment item has nothing to score.\n if (!assessmentItem) return;\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n #handleTestConnected(event: CustomEvent) {\n this.#testElement = event.detail as QtiAssessmentTest;\n // A fresh test invalidates the per-test optimality latches and item sessions.\n this.#optimality.clear();\n this.#sessions.clear();\n this.#changed.clear();\n // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this.#testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n });\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this.#extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n });\n }\n });\n\n // The structure and the session-control cascade come from the test's markup, not from upgraded\n // properties, so they do not depend on registration or render timing.\n this.#model = buildTestModel(renderedMarkup(this.#testElement));\n this.computedContext = this.#derive();\n }\n\n /** The test's structure and resolved session control, read from its markup when it is connected. */\n #model?: TestModel;\n\n /** `computedContext`, derived anew from its inputs (`deriveComputedContext`), never from the previous one. */\n #derive(): ComputedContext {\n this.#seedOptimality();\n this.#followSessions();\n return deriveComputedContext({\n model: this.#model,\n itemFacts: this.#itemFacts(),\n testContext: this._testContext,\n sessionContext: this._sessionContext,\n infoItemCategory: this.configContext?.infoItemCategory,\n itemData: this.initContext,\n optimality: this.#optimality,\n lifecycle: new Map([...this.#sessions].map(([identifier, session]) => [identifier, session.state])),\n itemElement: this.#itemElement\n });\n }\n\n /**\n * On a restored session no attempt is ended this run, so the latch is seeded once from the\n * persisted context, which still holds the submitted response. A later change of the answer\n * leaves the seeded value alone.\n */\n #seedOptimality(): void {\n for (const itemContext of this._testContext?.items ?? []) {\n if (!itemContext.identifier || this.#optimality.has(itemContext.identifier)) continue;\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n if (numAttempts > 0) this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n }\n }\n\n /**\n * Extract default values from a qti-context-declaration element\n */\n #extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\n }\n\n /* On every change of the candidate's state, the context is derived again. */\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.#model) return;\n this.computedContext = this.#derive();\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n this.#lockUsedItems();\n }\n\n /** The items this navigation disabled because their attempts are used, so it releases only those. */\n #lockedItems = new WeakSet<QtiAssessmentItem>();\n\n /**\n * Disables every rendered item whose session is over (`rules.done`: closed, its attempts used or\n * a completed adaptive item), so the candidate cannot change the answer once the last attempt is\n * ended (QTI info model §2.2.1). Runs after every update: an item rendered later (another item, a\n * section on screen, a restored state) is locked as it arrives, and one whose attempts are back to\n * zero (a new state) is released.\n *\n * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a\n * host or view that disables or makes an item read-only itself keeps it so.\n */\n #lockUsedItems(): void {\n if (!this.#testElement || !this.computedContext) return;\n // In a simultaneous part every item has one attempt, processed when the part ends (QTI info model\n // §2.8.2), so the candidate may change the answer until then: TAO keeps such an item open too.\n const items = new Map(\n this.computedContext.testParts.flatMap(part =>\n part.submissionMode === 'simultaneous'\n ? []\n : part.sections.flatMap(section => section.items.map(item => [item.identifier, item] as const))\n )\n );\n for (const itemRef of this.#testElement.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')) {\n const element = itemRef.assessmentItem;\n if (!element) continue;\n // The session is over (closed, or in review or solution). With `auto-score-items` every change\n // is scored as an attempt, so the count is not the candidate's and locks nothing.\n const used = !this.autoScoreItems && items.get(itemRef.identifier)?.rules?.done === true;\n if (used && !element.disabled) {\n element.disabled = true;\n this.#lockedItems.add(element);\n } else if (!used && this.#lockedItems.has(element)) {\n this.#lockedItems.delete(element);\n element.disabled = false;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-navigation': TestNavigation;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test-navigation.js","sourceRoot":"","sources":["../../../src/components/test-navigation/test-navigation.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MA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3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;sDAAwB","sourcesContent":["import { ContextConsumer, consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\nimport {\n buildTestModel,\n endItemAttempt,\n followItemSession,\n itemRefsInOrder,\n readItemFacts,\n seedItemLifecycle\n} from '@qti-components/delivery';\nimport { configContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\nimport { sessionContext } from '@qti-components/base';\nimport { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';\n\nimport { assessOptimality, deriveComputedContext } from '../../internal/derive-computed-context';\nimport { itemFactsContext } from '../../internal/item-facts.context';\nimport { attemptsOf, itemSessionFacts } from '../../internal/item-session-facts';\nimport { renderedMarkup } from '../../internal/rendered-markup';\nimport { testHostContext } from '../../internal/test-host.context';\nimport { listenPublic } from '../../public-events';\nimport { itemsInOrder } from '../../computed-tree';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiContext } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { ItemSession, ItemSessionFacts, TestModel } from '@qti-components/delivery';\nimport type { ItemOptimality } from '../../internal/derive-computed-context';\nimport type { ItemFactsByRef } from '../../internal/item-facts.context';\nimport type { LinearNextRefusal, TestHost } from '../../internal/test-host.context';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\n/** A new object each time: a host that mutates the one it read must not change anyone else's. */\nconst newQtiContext = (): QtiContext => ({\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n});\n\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier: string | undefined = undefined;\n\n /**\n * Your own per-item fields, by item-ref `identifier`: each `computedContext` item carries them as\n * given under `data`, without the identifier, and so does every view of it a plugin derives. They\n * never replace a field the test, the item or the candidate's state gives, whatever its name; a\n * template reads `activeItem.data.<field>`. To mark an item as scored by hand, set\n * `external-scored` on its `SCORE` declaration in `postLoadTransformCallback`.\n */\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n /**\n * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the\n * enclosing test's: reading returns it, writing replaces it, so a host that has always set the\n * shuffle seed here keeps working. Removed in the next major.\n *\n * Written before the navigation is inside a test, it waits and is handed over on connect.\n */\n public get qtiContext(): QtiContext {\n return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());\n }\n\n public set qtiContext(value: QtiContext) {\n if (!this.#warnedQtiContext) {\n this.#warnedQtiContext = true;\n console.warn(\n '[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major ' +\n 'release. Set `qtiContext` on `<qti-test>` instead; it is the same value.'\n );\n }\n this.#writeQtiContext(value);\n }\n\n #pendingQtiContext?: QtiContext;\n #warnedQtiContext = false;\n\n /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */\n #writeQtiContext(value: QtiContext): void {\n const owner = this.#owner();\n if (owner) owner.qtiContext = value;\n else this.#pendingQtiContext = value;\n }\n\n /**\n * The `qti-test` this navigation is in, found through context so it works across shadow roots.\n * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.\n */\n #testHost = new ContextConsumer(this, {\n context: testHostContext,\n subscribe: true,\n callback: host => {\n if (host && this.#pendingQtiContext) {\n host.qtiContext = this.#pendingQtiContext;\n this.#pendingQtiContext = undefined;\n }\n if (host) this.#registerLinearNext(host);\n }\n });\n\n /** The `qti-test` this navigation answers Next for in a linear part. */\n #linearNextHost?: TestHost;\n\n #registerLinearNext(host: TestHost): void {\n if (this.#linearNextHost && this.#linearNextHost !== host) this.#linearNextHost.beforeLinearNext = null;\n this.#linearNextHost = host;\n host.beforeLinearNext = this.#beforeLinearNext;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.#linearNextHost) this.#linearNextHost.beforeLinearNext = this.#beforeLinearNext;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.#linearNextHost?.beforeLinearNext === this.#beforeLinearNext) this.#linearNextHost.beforeLinearNext = null;\n }\n\n /**\n * Next in a linear individual part leaves the item for good (implementation guide §4.1), so it\n * submits what the candidate gave (decided 2026-11-27): refused while the session control refuses\n * those responses (`rules.maySubmit`), else the attempt is ended when one is open: none ended yet,\n * or the responses changed since the last. Called by the navigation mixin while the item is still\n * rendered; the item is closed when the navigation moves past it.\n */\n #beforeLinearNext = (itemRefId: string): LinearNextRefusal | null => {\n const part = this.#model?.testParts.find(testPart =>\n itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId)\n );\n if (part?.navigationMode !== 'linear' || part.submissionMode !== 'individual') return null;\n const session = this.#sessions.get(itemRefId);\n const rules = this.computedItemFor(itemRefId)?.rules;\n if (session?.state !== 'interacting' || !rules) return null;\n if (!rules.maySubmit) {\n return { reason: rules.maySkip ? 'validate-responses' : 'allow-skipping', itemId: itemRefId };\n }\n if (session.numAttempts === 0 || this.#changed.has(itemRefId)) {\n this.#assessmentItemFor(itemRefId)?.processResponse(\n true,\n this.configContext?.reportValidityAfterScoring === true\n );\n }\n return null;\n };\n\n /** The item-refs whose responses changed since their last ended attempt. */\n #changed = new Set<string>();\n\n #itemRefIdOf(element: EventTarget | undefined): string | undefined {\n const item = (element as HTMLElement | undefined)?.closest?.('qti-assessment-item');\n if (!item) return undefined;\n return [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])].find(\n itemRef => itemRef.assessmentItem === item\n )?.identifier;\n }\n\n #owner(): { qtiContext: QtiContext } | null {\n return this.#testHost.value ?? null;\n }\n\n @state()\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n /** Read from each item's XML when `qti-test` fetches it; see `itemFactsContext`. */\n @state()\n @consume({ context: itemFactsContext, subscribe: true })\n protected _itemFacts?: ItemFactsByRef;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n #testElement: QtiAssessmentTest;\n\n /**\n * Whether each item's last *ended attempt* reached the optimal outcome, keyed\n * by item-ref id. Written from #handleItemContextUpdated when processResponse\n * ends an attempt — never on a plain selection. Mirrors how inline feedback\n * only re-evaluates when an attempt is processed, so a freshly-picked answer\n * doesn't flip `done` until the candidate ends the attempt.\n */\n #optimality = new Map<string, ItemOptimality>();\n\n /**\n * Each item session's lifecycle state, by item-ref identifier, changed only through the lifecycle\n * table (`followItemSession` as the candidate moves, `endItemAttempt` when an attempt ends). It\n * lives here until `DeliveryState` holds it (roadmap 1, T3d); a session whose attempts change\n * outside an ended attempt (a restored or assigned state) is seeded again.\n */\n #sessions = new Map<string, ItemSession>();\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));\n\n listenItemPublic(this, 'qc-item-response-changed', this.#handleInteractionChanged.bind(this));\n this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));\n\n listenPublic(this, 'qc-test-end-attempt', this.#handleTestEndAttempt.bind(this));\n listenPublic(this, 'qc-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));\n listenPublic(this, 'qc-test-update-comment', this.#handleUpdateComment.bind(this));\n }\n\n /**\n * Sets the candidate's comment on an item when its session allows it (`rules.mayComment`:\n * `allow-comment`, while interacting; decided 2026-11-27, carried, not rendered).\n */\n #handleUpdateComment(event: CustomEvent<{ itemId: string; comment: string | null }>) {\n const { itemId, comment = null } = event.detail ?? ({} as { itemId?: string; comment?: string | null });\n const host = this.#testHost.value;\n if (!itemId || !host) return;\n if (comment !== null && typeof comment !== 'string') {\n console.warn(`[qti-test] Ignoring a comment for \"${itemId}\" that is not a string.`);\n return;\n }\n if (!this.computedItemFor(itemId)?.rules?.mayComment) {\n console.warn(\n `[qti-test] Ignoring a comment for \"${itemId}\": its allow-comment is false, or it is not interacting.`\n );\n return;\n }\n host.updateItemComment(itemId, comment);\n }\n\n /**\n * Latch whether an item reached its optimal outcome whenever it has just ended\n * an attempt. processResponse — fired by test-end-attempt, autoscore, or an\n * in-item end-attempt interaction — flags its context update with\n * `responseProcessed`; a plain selection updates the context without it, so\n * `done` can't flip until the candidate actually ends the attempt.\n */\n #handleItemContextUpdated(event: CustomEvent<{ itemContext: ItemContext; responseProcessed?: boolean }>) {\n if (!event.detail?.responseProcessed) return;\n const itemContext = event.detail.itemContext;\n if (!itemContext?.identifier) return;\n this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n this.#changed.delete(itemContext.identifier);\n this.#endAttempt(itemContext);\n\n const computedItem = this.computedItemFor(itemContext.identifier);\n this.afterAttemptEnded(\n (event.composedPath()[0] as HTMLElement)?.closest<QtiAssessmentItem>('qti-assessment-item'),\n computedItem,\n this.#doneAfterAttempt(itemContext, computedItem)\n );\n }\n\n /**\n * Moves the item's session on for its ended attempt. With `auto-score-items` every change is\n * scored as an attempt, so the count is not the candidate's: it is taken, and the state stays.\n */\n #endAttempt(itemContext: ItemContext): void {\n const facts = this.#sessionFacts().get(itemContext.identifier);\n if (!facts) return;\n const ended: ItemSessionFacts = { ...facts, ...attemptsOf(itemContext) };\n const previous = this.#sessions.get(itemContext.identifier);\n this.#sessions.set(\n itemContext.identifier,\n this.autoScoreItems\n ? {\n state: previous?.state ?? followItemSession(undefined, ended).state,\n numAttempts: ended.numAttempts,\n adaptive: ended.adaptive\n }\n : endItemAttempt(previous, ended)\n );\n }\n\n /**\n * Whether the item session is over after the attempt that just ended: its new state, or, before\n * the test model is known, the state an item on screen with these attempts is in.\n */\n #doneAfterAttempt(itemContext: ItemContext, computedItem: ComputedItem | undefined): boolean {\n const state =\n this.#sessions.get(itemContext.identifier)?.state ??\n (computedItem?.sessionControl\n ? seedItemLifecycle({\n sessionControl: computedItem.sessionControl,\n adaptive: computedItem.adaptive ?? false,\n ...attemptsOf(itemContext),\n presented: true,\n passed: false\n })\n : 'interacting');\n return state === 'closed' || state === 'review' || state === 'solution';\n }\n\n /** The facts of every item session now: the model, the item facts, the contexts and the items on screen. */\n #sessionFacts(): Map<string, ItemSessionFacts> {\n if (!this.#model) return new Map();\n const presented = new Set(\n [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])]\n .filter(itemRef => itemRef.assessmentItem)\n .map(itemRef => itemRef.identifier)\n );\n return itemSessionFacts(this.#model, this.#itemFacts(), this._testContext?.items, {\n current: this._sessionContext?.navItemRefId,\n presented\n });\n }\n\n /**\n * The item facts `qti-test` read from each fetched item, and, for an item rendered without them\n * (handed to its ref directly), the facts read from the rendered item.\n */\n #itemFacts(): ItemFactsByRef | undefined {\n const missing = [\n ...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])\n ].filter(\n itemRef =>\n itemRef.assessmentItem?.localName === 'qti-assessment-item' && !this._itemFacts?.has(itemRef.identifier)\n );\n if (!missing.length) return this._itemFacts;\n const facts = new Map(this._itemFacts ?? []);\n for (const itemRef of missing) facts.set(itemRef.identifier, readItemFacts(renderedMarkup(itemRef.assessmentItem)));\n return facts;\n }\n\n /** Moves every item session on for where the candidate is now. */\n #followSessions(): void {\n for (const [identifier, facts] of this.#sessionFacts()) {\n this.#sessions.set(identifier, followItemSession(this.#sessions.get(identifier), facts));\n }\n }\n\n /**\n * Extension point for presentation packages reacting to an ended attempt. `done` is the item\n * session's after this attempt (closed: its attempts used, whatever the score), settled here\n * because the computed context only catches up on the next update.\n */\n protected afterAttemptEnded(\n _assessmentItem: QtiAssessmentItem | undefined,\n _computedItem: ComputedItem | undefined,\n _done: boolean\n ): void {}\n\n /** The computed-context entry for an item, from the session-control cascade. */\n protected computedItemFor(identifier: string): ComputedItem | undefined {\n return this.computedContext?.testParts.flatMap(itemsInOrder).find(i => i.instance === identifier);\n }\n\n /** The assessment item for an item-ref id, if it has been rendered. */\n #assessmentItemFor(identifier: string | undefined): QtiAssessmentItem | undefined {\n if (!identifier) return undefined;\n const itemRef = this.#testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(identifier)}\"]`\n );\n return itemRef?.assessmentItem ?? undefined;\n }\n\n /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */\n #itemElement = (identifier: string): HTMLElement | null => this.#assessmentItemFor(identifier) ?? null;\n\n /** The currently active assessment item, exposed for optional presentation extensions. */\n protected get activeAssessmentItem(): QtiAssessmentItem | undefined {\n if (!this.#testElement || !this._sessionContext?.navItemRefId) return undefined;\n return this.#testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n )?.assessmentItem;\n }\n\n /**\n * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or\n * given an `item`), or else the item on screen.\n */\n #handleTestEndAttempt(event: CustomEvent<{ itemId?: string } | undefined>) {\n const itemId = event.detail?.itemId;\n const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;\n if (!qtiAssessmentItemEl) return;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n #handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);\n if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n #handleInteractionChanged(_event: CustomEvent) {\n const itemRefId = this.#itemRefIdOf(_event.composedPath()[0]);\n if (itemRefId) this.#changed.add(itemRefId);\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest<QtiAssessmentItem>(\n 'qti-assessment-item'\n );\n // Autoscoring resolves the item from the event's own path, so a change\n // raised outside an assessment item has nothing to score.\n if (!assessmentItem) return;\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n #handleTestConnected(event: CustomEvent) {\n this.#testElement = event.detail as QtiAssessmentTest;\n // A fresh test invalidates the per-test optimality latches and item sessions.\n this.#optimality.clear();\n this.#sessions.clear();\n this.#changed.clear();\n // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this.#testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n });\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this.#extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n });\n }\n });\n\n // The structure and the session-control cascade come from the test's markup, not from upgraded\n // properties, so they do not depend on registration or render timing.\n this.#model = buildTestModel(renderedMarkup(this.#testElement));\n this.computedContext = this.#derive();\n }\n\n /** The test's structure and resolved session control, read from its markup when it is connected. */\n #model?: TestModel;\n\n /** `computedContext`, derived anew from its inputs (`deriveComputedContext`), never from the previous one. */\n #derive(): ComputedContext {\n this.#seedOptimality();\n this.#followSessions();\n return deriveComputedContext({\n model: this.#model,\n itemFacts: this.#itemFacts(),\n testContext: this._testContext,\n sessionContext: this._sessionContext,\n infoItemCategory: this.configContext?.infoItemCategory,\n itemData: this.initContext,\n optimality: this.#optimality,\n lifecycle: new Map([...this.#sessions].map(([identifier, session]) => [identifier, session.state])),\n itemElement: this.#itemElement\n });\n }\n\n /**\n * On a restored session no attempt is ended this run, so the latch is seeded once from the\n * persisted context, which still holds the submitted response. A later change of the answer\n * leaves the seeded value alone.\n */\n #seedOptimality(): void {\n for (const itemContext of this._testContext?.items ?? []) {\n if (!itemContext.identifier || this.#optimality.has(itemContext.identifier)) continue;\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n if (numAttempts > 0) this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n }\n }\n\n /**\n * Extract default values from a qti-context-declaration element\n */\n #extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\n }\n\n /* On every change of the candidate's state, the context is derived again. */\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.#model) return;\n this.computedContext = this.#derive();\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n this.#lockUsedItems();\n }\n\n /** The items this navigation disabled because their attempts are used, so it releases only those. */\n #lockedItems = new WeakSet<QtiAssessmentItem>();\n\n /**\n * Disables every rendered item whose session is over (`rules.done`: closed, its attempts used or\n * a completed adaptive item), so the candidate cannot change the answer once the last attempt is\n * ended (QTI info model §2.2.1). Runs after every update: an item rendered later (another item, a\n * section on screen, a restored state) is locked as it arrives, and one whose attempts are back to\n * zero (a new state) is released.\n *\n * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a\n * host or view that disables or makes an item read-only itself keeps it so.\n */\n #lockUsedItems(): void {\n if (!this.#testElement || !this.computedContext) return;\n // In a simultaneous part every item has one attempt, processed when the part ends (QTI info model\n // §2.8.2), so the candidate may change the answer until then: TAO keeps such an item open too.\n const items = new Map(\n this.computedContext.testParts.flatMap(part =>\n part.submissionMode === 'simultaneous' ? [] : itemsInOrder(part).map(item => [item.instance, item] as const)\n )\n );\n for (const itemRef of this.#testElement.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')) {\n const element = itemRef.assessmentItem;\n if (!element) continue;\n // The session is over (closed, or in review or solution). With `auto-score-items` every change\n // is scored as an attempt, so the count is not the candidate's and locks nothing.\n const used = !this.autoScoreItems && items.get(itemRef.identifier)?.rules?.done === true;\n if (used && !element.disabled) {\n element.disabled = true;\n this.#lockedItems.add(element);\n } else if (!used && this.#lockedItems.has(element)) {\n this.#lockedItems.delete(element);\n element.disabled = false;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-navigation': TestNavigation;\n }\n}\n"]}
|
|
@@ -12,7 +12,7 @@ import { computedContext } from '@qti-components/base';
|
|
|
12
12
|
import { navigationRules } from '@qti-components/delivery';
|
|
13
13
|
import * as styles from '../styles';
|
|
14
14
|
import { dispatchPublic } from '../../public-events';
|
|
15
|
-
import { itemsInOrder } from '../../
|
|
15
|
+
import { activeTestPart, itemsInOrder } from '../../computed-tree';
|
|
16
16
|
/**
|
|
17
17
|
* Represents a custom element for navigating to the next test item.
|
|
18
18
|
*
|
|
@@ -44,7 +44,7 @@ export class TestNext extends LitElement {
|
|
|
44
44
|
this.addEventListener('click', e => {
|
|
45
45
|
e.preventDefault();
|
|
46
46
|
if (!this._internalDisabled)
|
|
47
|
-
this._requestItem(this.sectionItems[this.itemIndex + 1].
|
|
47
|
+
this._requestItem(this.sectionItems[this.itemIndex + 1].instance);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
connectedCallback() {
|
|
@@ -54,7 +54,7 @@ export class TestNext extends LitElement {
|
|
|
54
54
|
willUpdate(_changedProperties) {
|
|
55
55
|
if (!this.computedContext)
|
|
56
56
|
return;
|
|
57
|
-
const testPart = this.computedContext
|
|
57
|
+
const testPart = activeTestPart(this.computedContext);
|
|
58
58
|
if (!testPart)
|
|
59
59
|
return;
|
|
60
60
|
this.sectionItems = itemsInOrder(testPart);
|
|
@@ -62,7 +62,7 @@ export class TestNext extends LitElement {
|
|
|
62
62
|
this.checkDisabled();
|
|
63
63
|
}
|
|
64
64
|
checkDisabled() {
|
|
65
|
-
const testPart = this.computedContext
|
|
65
|
+
const testPart = activeTestPart(this.computedContext);
|
|
66
66
|
if (!testPart)
|
|
67
67
|
return;
|
|
68
68
|
const current = this.sectionItems?.[this.itemIndex]?.rules;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-next.js","sourceRoot":"","sources":["../../../src/components/test-next/test-next.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"test-next.js","sourceRoot":"","sources":["../../../src/components/test-next/test-next.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInE;;;;;;;;;;;;;GAaG;AAEH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAWtC,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB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AAC,CAAC;QACtD,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC;QAC3D,8FAA8F;QAC9F,4FAA4F;QAC5F,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC;YACpC,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,KAAK,EAAE,IAAI,CAAC,SAAS;YACrB,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;YACrC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,KAAK,EAAE;SAC/F,CAAC,CAAC;QACH,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC;IAC/D,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAnEM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGtB;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACZ;AAM3C;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\nimport { navigationRules } from '@qti-components/delivery';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { activeTestPart, itemsInOrder } from '../../computed-tree';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the next test item.\n *\n * @remarks\n * Disabled on the last item of the part, and, in a linear part with individual submission, while\n * the current item's answer may not be submitted (`allow-skipping=\"false\"` with no answer,\n * `validate-responses` with an invalid one). In that part Next ends the attempt the candidate did not\n * end and leaves the item for good (implementation guide §4.1); the score never holds it back.\n *\n * @example\n * ```html\n * <test-next></test-next>\n * ```\n */\n\nexport class TestNext extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = [styles.button, styles.buttonPrimary];\n #internals: ElementInternals;\n\n constructor() {\n super();\n\n this.#internals = this.attachInternals();\n this.#internals.role = 'button';\n this.#internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex + 1].instance);\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.checkDisabled();\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = activeTestPart(this.computedContext);\n if (!testPart) return;\n this.sectionItems = itemsInOrder(testPart);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = activeTestPart(this.computedContext);\n if (!testPart) return;\n const current = this.sectionItems?.[this.itemIndex]?.rules;\n // In a linear individual part Next ends the attempt and leaves the item for good, so it waits\n // while the item's responses may not be submitted (`allow-skipping`, `validate-responses`).\n const { mayGoNext } = navigationRules({\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n index: this.itemIndex,\n count: this.sectionItems?.length ?? 0,\n current: { maySubmit: current?.maySubmit ?? true, interactive: current?.interactive ?? false }\n });\n this._internalDisabled = !this.computedContext || !mayGoNext;\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'qc-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-next': TestNext;\n }\n}\n"]}
|
|
@@ -12,7 +12,7 @@ import { computedContext } from '@qti-components/base';
|
|
|
12
12
|
import { navigationRules } from '@qti-components/delivery';
|
|
13
13
|
import * as styles from '../styles';
|
|
14
14
|
import { dispatchPublic } from '../../public-events';
|
|
15
|
-
import { itemsInOrder } from '../../
|
|
15
|
+
import { activeTestPart, itemsInOrder } from '../../computed-tree';
|
|
16
16
|
/**
|
|
17
17
|
* Represents a custom element for navigating to the previous test item.
|
|
18
18
|
*
|
|
@@ -37,13 +37,13 @@ export class TestPrev extends LitElement {
|
|
|
37
37
|
this.addEventListener('click', e => {
|
|
38
38
|
e.preventDefault();
|
|
39
39
|
if (!this._internalDisabled)
|
|
40
|
-
this._requestItem(this.sectionItems[this.itemIndex - 1].
|
|
40
|
+
this._requestItem(this.sectionItems[this.itemIndex - 1].instance);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
willUpdate(_changedProperties) {
|
|
44
44
|
if (!this.computedContext)
|
|
45
45
|
return;
|
|
46
|
-
const testPart = this.computedContext
|
|
46
|
+
const testPart = activeTestPart(this.computedContext);
|
|
47
47
|
if (!testPart)
|
|
48
48
|
return;
|
|
49
49
|
this.sectionItems = itemsInOrder(testPart);
|
|
@@ -51,7 +51,7 @@ export class TestPrev extends LitElement {
|
|
|
51
51
|
this.checkDisabled();
|
|
52
52
|
}
|
|
53
53
|
checkDisabled() {
|
|
54
|
-
const testPart = this.computedContext
|
|
54
|
+
const testPart = activeTestPart(this.computedContext);
|
|
55
55
|
// A linear part never goes back (implementation guide §4.1).
|
|
56
56
|
const { mayGoPrevious } = navigationRules({
|
|
57
57
|
navigationMode: testPart?.navigationMode ?? 'nonlinear',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-prev.js","sourceRoot":"","sources":["../../../src/components/test-prev/test-prev.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"test-prev.js","sourceRoot":"","sources":["../../../src/components/test-prev/test-prev.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIn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c,IAAI,YAAY;YACxD,KAAK,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;YACrC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE;SACjD,CAAC,CAAC;QACH,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,aAAa,CAAC;IACnE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAtDM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGxB;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACd;AAMzC;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\nimport { navigationRules } from '@qti-components/delivery';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { activeTestPart, itemsInOrder } from '../../computed-tree';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n\nexport class TestPrev extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = styles.button;\n\n constructor() {\n super();\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex - 1].instance);\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = activeTestPart(this.computedContext);\n if (!testPart) return;\n this.sectionItems = itemsInOrder(testPart);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = activeTestPart(this.computedContext);\n // A linear part never goes back (implementation guide §4.1).\n const { mayGoPrevious } = navigationRules({\n navigationMode: testPart?.navigationMode ?? 'nonlinear',\n submissionMode: testPart?.submissionMode ?? 'individual',\n index: this.itemIndex ?? -1,\n count: this.sectionItems?.length ?? 0,\n current: { maySubmit: true, interactive: false }\n });\n this._internalDisabled = !this.computedContext || !mayGoPrevious;\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'qc-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-prev': TestPrev;\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComputedContext, ComputedItem, ComputedSection, ComputedTestPart } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* Every item of a test part once, in the order the candidate takes them: the test's document order,
|
|
4
|
+
* through nested sections, interleaved item-refs and subsections included, info items included.
|
|
5
|
+
*/
|
|
6
|
+
export declare const itemsInOrder: (testPart: ComputedTestPart) => ComputedItem[];
|
|
7
|
+
/** Every section of a test part once, nested ones included, a section before its subsections. */
|
|
8
|
+
export declare const sectionsInOrder: (testPart: ComputedTestPart) => ComputedSection[];
|
|
9
|
+
/** The test part the candidate is in, or undefined (no context yet, or before the test starts). */
|
|
10
|
+
export declare const activeTestPart: (context: ComputedContext | undefined) => ComputedTestPart | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The section the candidate is in: the closest one around the active item, or the section shown.
|
|
13
|
+
* Looked for in every test part, as `active` is set from where the candidate is.
|
|
14
|
+
*/
|
|
15
|
+
export declare const activeSection: (context: ComputedContext | undefined) => ComputedSection | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The item the candidate is on, or undefined (`navigate="section"` shows a section, not one item).
|
|
18
|
+
* Looked for in every test part, as `active` is set from where the candidate is.
|
|
19
|
+
*/
|
|
20
|
+
export declare const activeItem: (context: ComputedContext | undefined) => ComputedItem | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const items = (content) => content.flatMap(node => (node.kind === 'item' ? [node] : items(node.content)));
|
|
2
|
+
const sections = (content) => content.flatMap(node => (node.kind === 'section' ? [node, ...sections(node.content)] : []));
|
|
3
|
+
/**
|
|
4
|
+
* Every item of a test part once, in the order the candidate takes them: the test's document order,
|
|
5
|
+
* through nested sections, interleaved item-refs and subsections included, info items included.
|
|
6
|
+
*/
|
|
7
|
+
export const itemsInOrder = (testPart) => items(testPart.sections);
|
|
8
|
+
/** Every section of a test part once, nested ones included, a section before its subsections. */
|
|
9
|
+
export const sectionsInOrder = (testPart) => sections(testPart.sections);
|
|
10
|
+
/** The test part the candidate is in, or undefined (no context yet, or before the test starts). */
|
|
11
|
+
export const activeTestPart = (context) => context?.testParts.find(testPart => testPart.active);
|
|
12
|
+
/**
|
|
13
|
+
* The section the candidate is in: the closest one around the active item, or the section shown.
|
|
14
|
+
* Looked for in every test part, as `active` is set from where the candidate is.
|
|
15
|
+
*/
|
|
16
|
+
export const activeSection = (context) => context?.testParts.flatMap(sectionsInOrder).find(section => section.active);
|
|
17
|
+
/**
|
|
18
|
+
* The item the candidate is on, or undefined (`navigate="section"` shows a section, not one item).
|
|
19
|
+
* Looked for in every test part, as `active` is set from where the candidate is.
|
|
20
|
+
*/
|
|
21
|
+
export const activeItem = (context) => context?.testParts.flatMap(itemsInOrder).find(item => item.active);
|
|
22
|
+
//# sourceMappingURL=computed-tree.js.map
|