@qti-components/test 2.0.0-next.32 → 2.0.0-next.34
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-test/qti-test.d.ts +1 -0
- package/dist/components/qti-test/qti-test.js +1 -0
- package/dist/components/qti-test/qti-test.js.map +1 -1
- package/dist/components/test-end-attempt/test-end-attempt.d.ts +2 -2
- package/dist/components/test-end-attempt/test-end-attempt.js +10 -3
- package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
- package/dist/components/test-navigation/test-navigation.js +130 -10
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/internal/item-sequencing.d.ts +13 -19
- package/dist/internal/item-sequencing.js +39 -97
- package/dist/internal/item-sequencing.js.map +1 -1
- package/dist/internal/test-host.context.d.ts +11 -0
- package/dist/internal/test-host.context.js.map +1 -1
- package/dist/mixins/test-navigation.mixin.js +29 -20
- package/dist/mixins/test-navigation.mixin.js.map +1 -1
- package/dist/mixins/test-processing.mixin.js +5 -2
- package/dist/mixins/test-processing.mixin.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/package.json +5 -5
|
@@ -59,6 +59,7 @@ declare const QtiTest_base: (abstract new (...args: any[]) => import("../..").IT
|
|
|
59
59
|
* And you can use the `test-prev` and `test-next` elements to navigate through the test.
|
|
60
60
|
*
|
|
61
61
|
* @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
|
|
62
|
+
* @event qc-test-part-submitted - A test part with simultaneous submission was submitted by `submit()`: each item the candidate opened has its one attempt and a closed session. `detail` is `{ testPart, items }` (the item-refs whose attempt ended). Sent before the test's outcome processing.
|
|
62
63
|
* @event qc-test-state-refused - A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
|
|
63
64
|
* @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
|
|
64
65
|
*/
|
|
@@ -61,6 +61,7 @@ import { TestStateMixin } from '../../mixins/test-state.mixin';
|
|
|
61
61
|
* And you can use the `test-prev` and `test-next` elements to navigate through the test.
|
|
62
62
|
*
|
|
63
63
|
* @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
|
|
64
|
+
* @event qc-test-part-submitted - A test part with simultaneous submission was submitted by `submit()`: each item the candidate opened has its one attempt and a closed session. `detail` is `{ testPart, items }` (the item-refs whose attempt ended). Sent before the test's outcome processing.
|
|
64
65
|
* @event qc-test-state-refused - A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
|
|
65
66
|
* @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
|
|
66
67
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qti-test.js","sourceRoot":"","sources":["../../../src/components/qti-test/qti-test.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,cAAc,EA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AAI,eAAe,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACnG,CAAC;IAYkB,OAAO,CAAC,OAAuB;QAChD,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,4FAA4F;QAC5F,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IA0BD;;;OAGG;IACM,KAAK,CAAC,iBAAiB;QAC9B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;CACF;AA7CQ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACM;AAU1B;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;8CACK;AAclC;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;2CAO/B","sourcesContent":["import { ContextProvider, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { configContext, qtiContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { TestNavigationMixin, TestViewMixin } from '../../mixins';\nimport { TestBaseMixin } from '../../mixins/test-base';\nimport { TestProcessingMixin } from '../../mixins/test-processing.mixin';\nimport { TestStateMixin } from '../../mixins/test-state.mixin';\n\nimport type { PropertyValues } from 'lit';\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { IQtiTest } from '../../types/iqti-test';\n\n/**\n * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.\n *\n * This component leverages several mixins to provide functionality for loading, navigating, processing, and displaying QTI test assessments.\n *\n * ### Example Usage\n *\n * Minimal example including navigation:\n *\n * ```html\n * <qti-test src=\"./path/to/assessment.xml\" navigate=\"item\">\n * <test-navigation>\n * <test-container></test-container>\n * <nav class=\"flex\">\n * <test-prev></test-prev>\n * <test-next></test-next>\n * </nav>\n * </test-navigation>\n * </qti-test>\n * ```\n *\n * Use the following file structure\n * A qti-test loads a QTI3.0 assessmenttest.xml file from a package folder.\n *\n * ```plaintext\n * Root/\n * ├── index.html\n * └── /assets/api/examples/\n * ├── assessmenttest.xml\n * └── imsmanifest.xml\n *\n * ```\n *\n * ### Test components\n *\n * Use test components inside the qti-test component for added functionality.\n * ### Test next\n * `<test-next> | TestNext`\n *\n * ### Test prev\n *\n * `<test-prev> | TestPrev`\n * ### Test components\n *\n * You can use normal class names to style the elements.\n * And you can use the `test-prev` and `test-next` elements to navigate through the test.\n *\n * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.\n * @event qc-test-part-submitted - A test part with simultaneous submission was submitted by `submit()`: each item the candidate opened has its one attempt and a closed session. `detail` is `{ testPart, items }` (the item-refs whose attempt ended). Sent before the test's outcome processing.\n * @event qc-test-state-refused - A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.\n * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.\n */\n\nexport class QtiTest extends TestNavigationMixin(\n TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))\n) {\n // TODO: Properly implement IQtiTest interface\n // export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {\n\n /** Tells the components inside that something they read from the test changed (see `src`). */\n #hostProvider: ContextProvider<typeof testHostContext>;\n\n constructor() {\n super();\n // The components inside find their test through this, across shadow roots (see TestHost).\n this.#hostProvider = new ContextProvider(this, { context: testHostContext, initialValue: this });\n }\n\n /**\n * URL of the `assessmentTest` XML. Changing it loads another test into the `test-container`\n * inside. Relative URLs resolve against the page, and the items' `href`s against the test.\n *\n * `test-url` on `test-container` is the deprecated name for this, kept until 11; when both are\n * set, `src` wins.\n */\n @property({ type: String })\n public src: string | null = null;\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // The provided value is this element, whose identity never changes: force the notification.\n if (changed.has('src')) this.#hostProvider.setValue(this, true);\n }\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n /**\n * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so\n * everything inside reads one value: the test-container shuffling the item order, the test\n * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.\n *\n * Pass the same `seed` when resuming a session, or the order comes back different. Replace the\n * object, do not mutate it: an in-place change does not notify the components inside.\n *\n * `test-navigation.qtiContext` is an alias of this.\n */\n @state()\n @provide({ context: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\n\n /**\n * Renders the component's template.\n * Provides a default `<slot>` for content projection.\n */\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(new CustomEvent('qti-test-connected', { detail: this }));\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test': QtiTest;\n }\n}\n"]}
|
|
@@ -15,8 +15,8 @@ import type { ComputedContext } from '@qti-components/base';
|
|
|
15
15
|
* interacting (its attempts used, a completed adaptive item, or passed in a linear part), when no
|
|
16
16
|
* attempt is left, or while its responses may not be submitted (`allow-skipping="false"` with no
|
|
17
17
|
* answer, `validate-responses` with an invalid one). The score never disables it: a right answer
|
|
18
|
-
* leaves the attempts `max-attempts` gives (decided 2026-11-27). In a
|
|
19
|
-
*
|
|
18
|
+
* leaves the attempts `max-attempts` gives (decided 2026-11-27). In a part with simultaneous
|
|
19
|
+
* submission it is always disabled: `submit()` ends every attempt of the part at once (roadmap 1, T6).
|
|
20
20
|
*
|
|
21
21
|
* @slot - The label.
|
|
22
22
|
* @attr require-answer - Also disabled while the response is invalid or still the default, whatever the item's session control says.
|
|
@@ -35,8 +35,8 @@ const itemRefOf = (element) => {
|
|
|
35
35
|
* interacting (its attempts used, a completed adaptive item, or passed in a linear part), when no
|
|
36
36
|
* attempt is left, or while its responses may not be submitted (`allow-skipping="false"` with no
|
|
37
37
|
* answer, `validate-responses` with an invalid one). The score never disables it: a right answer
|
|
38
|
-
* leaves the attempts `max-attempts` gives (decided 2026-11-27). In a
|
|
39
|
-
*
|
|
38
|
+
* leaves the attempts `max-attempts` gives (decided 2026-11-27). In a part with simultaneous
|
|
39
|
+
* submission it is always disabled: `submit()` ends every attempt of the part at once (roadmap 1, T6).
|
|
40
40
|
*
|
|
41
41
|
* @slot - The label.
|
|
42
42
|
* @attr require-answer - Also disabled while the response is invalid or still the default, whatever the item's session control says.
|
|
@@ -87,9 +87,16 @@ export class TestEndAttempt extends LitElement {
|
|
|
87
87
|
this._internalDisabled = false;
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
+
// A part with simultaneous submission ends every attempt when the part is submitted (QTI 3 info
|
|
91
|
+
// model §2.8.2; decided 2026-12-01): nothing ends one before.
|
|
92
|
+
const part = testParts.find(tp => itemsInOrder(tp).includes(activeItem));
|
|
93
|
+
if (part?.submissionMode === 'simultaneous') {
|
|
94
|
+
this._internalDisabled = true;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
90
97
|
const rules = activeItem.rules;
|
|
91
98
|
// `interactive && attemptsLeft` is `mayEndAttempt` in a part with individual submission; it also
|
|
92
|
-
// covers
|
|
99
|
+
// covers `auto-score-items`, whose sessions stay open.
|
|
93
100
|
const mayEnd = rules ? rules.interactive && rules.attemptsLeft && rules.maySubmit : fromSessionControl(activeItem);
|
|
94
101
|
const answered = activeItem.valid !== false && !activeItem.isDefaultResponse;
|
|
95
102
|
this._internalDisabled = !mayEnd || (this.requireAnswer && !answered);
|
|
@@ -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;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,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAc5C,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5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AE,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"]}
|
|
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,E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AA8DH;;;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 part with simultaneous\n * submission it is always disabled: `submit()` ends every attempt of the part at once (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 // A part with simultaneous submission ends every attempt when the part is submitted (QTI 3 info\n // model §2.8.2; decided 2026-12-01): nothing ends one before.\n const part = testParts.find(tp => itemsInOrder(tp).includes(activeItem));\n if (part?.submissionMode === 'simultaneous') {\n this._internalDisabled = true;\n return;\n }\n const rules = activeItem.rules;\n // `interactive && attemptsLeft` is `mayEndAttempt` in a part with individual submission; it also\n // covers `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"]}
|
|
@@ -8,7 +8,7 @@ import { ContextConsumer, consume, provide } from '@lit/context';
|
|
|
8
8
|
import { html, LitElement } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import { computedContext } from '@qti-components/base';
|
|
11
|
-
import { buildTestModel, endItemAttempt, followItemSession, itemRefsInOrder, readItemFacts, seedItemLifecycle } from '@qti-components/delivery';
|
|
11
|
+
import { buildTestModel, endItemAttempt, followItemSession, itemRefsInOrder, readItemFacts, seedItemLifecycle, submitTestPart } from '@qti-components/delivery';
|
|
12
12
|
import { configContext } from '@qti-components/base';
|
|
13
13
|
import { testContext } from '@qti-components/base';
|
|
14
14
|
import { sessionContext } from '@qti-components/base';
|
|
@@ -18,7 +18,7 @@ import { itemFactsContext } from '../../internal/item-facts.context';
|
|
|
18
18
|
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
|
-
import { listenPublic } from '../../public-events';
|
|
21
|
+
import { dispatchPublic, listenPublic } from '../../public-events';
|
|
22
22
|
import { itemsInOrder } from '../../computed-tree';
|
|
23
23
|
/** A new object each time: a host that mutates the one it read must not change anyone else's. */
|
|
24
24
|
const newQtiContext = () => ({
|
|
@@ -61,21 +61,43 @@ export class TestNavigation extends LitElement {
|
|
|
61
61
|
/** The `qti-test` this navigation answers Next for in a linear part. */
|
|
62
62
|
#linearNextHost;
|
|
63
63
|
#registerLinearNext(host) {
|
|
64
|
-
if (this.#linearNextHost && this.#linearNextHost !== host)
|
|
64
|
+
if (this.#linearNextHost && this.#linearNextHost !== host) {
|
|
65
65
|
this.#linearNextHost.beforeLinearNext = null;
|
|
66
|
+
this.#linearNextHost.submitTestParts = null;
|
|
67
|
+
}
|
|
66
68
|
this.#linearNextHost = host;
|
|
67
69
|
host.beforeLinearNext = this.#beforeLinearNext;
|
|
70
|
+
host.submitTestParts = this.#submitTestParts;
|
|
68
71
|
}
|
|
69
72
|
connectedCallback() {
|
|
70
73
|
super.connectedCallback();
|
|
71
|
-
if (this.#linearNextHost)
|
|
74
|
+
if (this.#linearNextHost) {
|
|
72
75
|
this.#linearNextHost.beforeLinearNext = this.#beforeLinearNext;
|
|
76
|
+
this.#linearNextHost.submitTestParts = this.#submitTestParts;
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
disconnectedCallback() {
|
|
75
80
|
super.disconnectedCallback();
|
|
76
81
|
if (this.#linearNextHost?.beforeLinearNext === this.#beforeLinearNext)
|
|
77
82
|
this.#linearNextHost.beforeLinearNext = null;
|
|
83
|
+
if (this.#linearNextHost?.submitTestParts === this.#submitTestParts)
|
|
84
|
+
this.#linearNextHost.submitTestParts = null;
|
|
85
|
+
}
|
|
86
|
+
/** The `submission-mode` of the test part that holds the item-ref; undefined before the model is known. */
|
|
87
|
+
#submissionModeOf(itemRefId) {
|
|
88
|
+
if (!itemRefId)
|
|
89
|
+
return undefined;
|
|
90
|
+
return this.#model?.testParts.find(testPart => itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId))?.submissionMode;
|
|
78
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Submits every test part with simultaneous submission that is not submitted yet, as a paper exam
|
|
94
|
+
* is handed in (QTI 3 info model §2.8.2; decided 2026-12-01, `plans/host-api.md`): each item the
|
|
95
|
+
* candidate opened gets its one attempt (`numAttempts` 1) and, when it is not adaptive,
|
|
96
|
+
* `completionStatus` `completed`; every session closes (`submitTestPart`). The responses were
|
|
97
|
+
* scored in the background as they changed, so nothing is processed again here. The caller runs
|
|
98
|
+
* the test's outcome processing after it (`submit()`). Sends `qc-test-part-submitted` per part.
|
|
99
|
+
*/
|
|
100
|
+
#submitTestParts;
|
|
79
101
|
/**
|
|
80
102
|
* Next in a linear individual part leaves the item for good (implementation guide §4.1), so it
|
|
81
103
|
* submits what the candidate gave (decided 2026-11-27): refused while the session control refuses
|
|
@@ -139,6 +161,49 @@ export class TestNavigation extends LitElement {
|
|
|
139
161
|
this.#registerLinearNext(host);
|
|
140
162
|
}
|
|
141
163
|
});
|
|
164
|
+
/**
|
|
165
|
+
* Submits every test part with simultaneous submission that is not submitted yet, as a paper exam
|
|
166
|
+
* is handed in (QTI 3 info model §2.8.2; decided 2026-12-01, `plans/host-api.md`): each item the
|
|
167
|
+
* candidate opened gets its one attempt (`numAttempts` 1) and, when it is not adaptive,
|
|
168
|
+
* `completionStatus` `completed`; every session closes (`submitTestPart`). The responses were
|
|
169
|
+
* scored in the background as they changed, so nothing is processed again here. The caller runs
|
|
170
|
+
* the test's outcome processing after it (`submit()`). Sends `qc-test-part-submitted` per part.
|
|
171
|
+
*/
|
|
172
|
+
this.#submitTestParts = () => {
|
|
173
|
+
const host = this.#testHost.value;
|
|
174
|
+
if (!this.#model || !host)
|
|
175
|
+
return;
|
|
176
|
+
const facts = this.#sessionFacts();
|
|
177
|
+
for (const testPart of this.#model.testParts) {
|
|
178
|
+
if (testPart.submissionMode !== 'simultaneous')
|
|
179
|
+
continue;
|
|
180
|
+
const items = itemRefsInOrder(testPart.sections).flatMap(({ identifier }) => {
|
|
181
|
+
const itemFacts = facts.get(identifier);
|
|
182
|
+
return itemFacts
|
|
183
|
+
? [{ item: identifier, previous: this.#sessions.get(identifier) ?? null, facts: itemFacts }]
|
|
184
|
+
: [];
|
|
185
|
+
});
|
|
186
|
+
const submission = submitTestPart(items);
|
|
187
|
+
if (!submission)
|
|
188
|
+
continue;
|
|
189
|
+
const submitted = [];
|
|
190
|
+
for (const { item, session } of submission.sessions) {
|
|
191
|
+
const before = facts.get(item);
|
|
192
|
+
this.#sessions.set(item, session);
|
|
193
|
+
if (session.numAttempts === before.numAttempts)
|
|
194
|
+
continue;
|
|
195
|
+
submitted.push(item);
|
|
196
|
+
host.updateItemVariables(item, [
|
|
197
|
+
{ identifier: 'numAttempts', value: String(session.numAttempts) },
|
|
198
|
+
...(session.adaptive ? [] : [{ identifier: 'completionStatus', value: 'completed' }])
|
|
199
|
+
]);
|
|
200
|
+
}
|
|
201
|
+
if (submitted.length === 0)
|
|
202
|
+
continue;
|
|
203
|
+
dispatchPublic(host, 'qc-test-part-submitted', { testPart: testPart.identifier, items: submitted });
|
|
204
|
+
}
|
|
205
|
+
this.requestUpdate();
|
|
206
|
+
};
|
|
142
207
|
/**
|
|
143
208
|
* Next in a linear individual part leaves the item for good (implementation guide §4.1), so it
|
|
144
209
|
* submits what the candidate gave (decided 2026-11-27): refused while the session control refuses
|
|
@@ -183,6 +248,8 @@ export class TestNavigation extends LitElement {
|
|
|
183
248
|
this.#sessions = new Map();
|
|
184
249
|
/** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
|
|
185
250
|
this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
|
|
251
|
+
/** The rendered items already scored on arrival, so each is scored once per rendering. */
|
|
252
|
+
this.#scoredOnArrival = new WeakSet();
|
|
186
253
|
/** The items this navigation disabled because their attempts are used, so it releases only those. */
|
|
187
254
|
this.#lockedItems = new WeakSet();
|
|
188
255
|
listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));
|
|
@@ -332,6 +399,11 @@ export class TestNavigation extends LitElement {
|
|
|
332
399
|
const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;
|
|
333
400
|
if (!qtiAssessmentItemEl)
|
|
334
401
|
return;
|
|
402
|
+
const itemRefId = itemId ?? this._sessionContext?.navItemRefId ?? undefined;
|
|
403
|
+
if (this.#submissionModeOf(itemRefId) === 'simultaneous') {
|
|
404
|
+
console.warn(`[qti-test] Ignoring an end attempt for "${itemRefId}": its test part has simultaneous submission, so its attempt ends when the part is submitted.`);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
335
407
|
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
336
408
|
qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
|
|
337
409
|
}
|
|
@@ -345,6 +417,17 @@ export class TestNavigation extends LitElement {
|
|
|
345
417
|
const itemRefId = this.#itemRefIdOf(_event.composedPath()[0]);
|
|
346
418
|
if (itemRefId)
|
|
347
419
|
this.#changed.add(itemRefId);
|
|
420
|
+
// A part with simultaneous submission is a paper exam (decided 2026-12-01): every change is
|
|
421
|
+
// scored in the background, without ending the attempt, so a saved state always holds the
|
|
422
|
+
// scores. `auto-score-items` adds nothing there. An item whose `SCORE` is `external-scored` is
|
|
423
|
+
// left alone, as `auto-score-items` left it: a run would reset the score a scorer gave.
|
|
424
|
+
if (this.#submissionModeOf(itemRefId) === 'simultaneous') {
|
|
425
|
+
const computedItem = this.computedItemFor(itemRefId);
|
|
426
|
+
if (computedItem?.rules?.done || computedItem?.externalScored)
|
|
427
|
+
return;
|
|
428
|
+
this.#assessmentItemFor(itemRefId)?.scoreResponse();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
348
431
|
if (this.autoScoreItems) {
|
|
349
432
|
const assessmentItem = _event.composedPath()[0].closest('qti-assessment-item');
|
|
350
433
|
// Autoscoring resolves the item from the event's own path, so a change
|
|
@@ -487,6 +570,32 @@ export class TestNavigation extends LitElement {
|
|
|
487
570
|
updated(changedProperties) {
|
|
488
571
|
super.updated(changedProperties);
|
|
489
572
|
this.#lockUsedItems();
|
|
573
|
+
this.#scoreOnFirstPresentation();
|
|
574
|
+
}
|
|
575
|
+
/** The rendered items already scored on arrival, so each is scored once per rendering. */
|
|
576
|
+
#scoredOnArrival;
|
|
577
|
+
/**
|
|
578
|
+
* In a part with simultaneous submission, scores every item once in the background when it is
|
|
579
|
+
* first shown (decided 2026-12-03). An item the candidate opens and leaves blank gets the outcomes
|
|
580
|
+
* its response processing gives no answer, as it would on paper, not only their defaults; a
|
|
581
|
+
* restored item is scored again from its restored responses, which gives the same scores. Skipped,
|
|
582
|
+
* like every background score, for a closed item and one whose `SCORE` is `external-scored`.
|
|
583
|
+
*/
|
|
584
|
+
#scoreOnFirstPresentation() {
|
|
585
|
+
if (!this.#testElement || !this.computedContext)
|
|
586
|
+
return;
|
|
587
|
+
for (const itemRef of this.#testElement.querySelectorAll('qti-assessment-item-ref')) {
|
|
588
|
+
const element = itemRef.assessmentItem;
|
|
589
|
+
if (!element || this.#scoredOnArrival.has(element))
|
|
590
|
+
continue;
|
|
591
|
+
if (this.#submissionModeOf(itemRef.identifier) !== 'simultaneous')
|
|
592
|
+
continue;
|
|
593
|
+
const computedItem = this.computedItemFor(itemRef.identifier);
|
|
594
|
+
if (!computedItem || computedItem.rules?.done || computedItem.externalScored)
|
|
595
|
+
continue;
|
|
596
|
+
if (element.scoreResponse())
|
|
597
|
+
this.#scoredOnArrival.add(element);
|
|
598
|
+
}
|
|
490
599
|
}
|
|
491
600
|
/** The items this navigation disabled because their attempts are used, so it releases only those. */
|
|
492
601
|
#lockedItems;
|
|
@@ -495,7 +604,8 @@ export class TestNavigation extends LitElement {
|
|
|
495
604
|
* a completed adaptive item), so the candidate cannot change the answer once the last attempt is
|
|
496
605
|
* ended (QTI info model §2.2.1). Runs after every update: an item rendered later (another item, a
|
|
497
606
|
* section on screen, a restored state) is locked as it arrives, and one whose attempts are back to
|
|
498
|
-
* zero (a new state) is released.
|
|
607
|
+
* zero (a new state) is released. In a part with simultaneous submission every session closes
|
|
608
|
+
* when the part is submitted, so its items lock then.
|
|
499
609
|
*
|
|
500
610
|
* Only `disabled = true` is ever set here, and only on an item that was not disabled already; a
|
|
501
611
|
* host or view that disables or makes an item read-only itself keeps it so.
|
|
@@ -503,16 +613,20 @@ export class TestNavigation extends LitElement {
|
|
|
503
613
|
#lockUsedItems() {
|
|
504
614
|
if (!this.#testElement || !this.computedContext)
|
|
505
615
|
return;
|
|
506
|
-
|
|
507
|
-
// §2.8.2), so the candidate may change the answer until then: TAO keeps such an item open too.
|
|
508
|
-
const items = new Map(this.computedContext.testParts.flatMap(part => part.submissionMode === 'simultaneous' ? [] : itemsInOrder(part).map(item => [item.instance, item])));
|
|
616
|
+
const items = new Map(this.computedContext.testParts.flatMap(part => itemsInOrder(part).map(item => [item.instance, { item, simultaneous: part.submissionMode === 'simultaneous' }])));
|
|
509
617
|
for (const itemRef of this.#testElement.querySelectorAll('qti-assessment-item-ref')) {
|
|
510
618
|
const element = itemRef.assessmentItem;
|
|
511
619
|
if (!element)
|
|
512
620
|
continue;
|
|
621
|
+
const entry = items.get(itemRef.identifier);
|
|
622
|
+
// A simultaneous part ends attempts only when it is submitted, so its end-attempt
|
|
623
|
+
// interactions are off (decided 2026-12-01).
|
|
624
|
+
if (entry?.simultaneous)
|
|
625
|
+
this.#disableEndAttemptInteractions(element);
|
|
513
626
|
// The session is over (closed, or in review or solution). With `auto-score-items` every change
|
|
514
|
-
// is scored as an attempt, so the count is not the candidate's and locks nothing
|
|
515
|
-
|
|
627
|
+
// is scored as an attempt, so the count is not the candidate's and locks nothing; in a
|
|
628
|
+
// simultaneous part it is built in and never counts, so the session decides.
|
|
629
|
+
const used = (entry?.simultaneous || !this.autoScoreItems) && entry?.item.rules?.done === true;
|
|
516
630
|
if (used && !element.disabled) {
|
|
517
631
|
element.disabled = true;
|
|
518
632
|
this.#lockedItems.add(element);
|
|
@@ -523,6 +637,12 @@ export class TestNavigation extends LitElement {
|
|
|
523
637
|
}
|
|
524
638
|
}
|
|
525
639
|
}
|
|
640
|
+
#disableEndAttemptInteractions(element) {
|
|
641
|
+
for (const interaction of element.querySelectorAll('qti-end-attempt-interaction')) {
|
|
642
|
+
if (!interaction.disabled)
|
|
643
|
+
interaction.disabled = true;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
526
646
|
}
|
|
527
647
|
__decorate([
|
|
528
648
|
property({ type: String })
|