@qti-components/test 2.0.0-next.33 → 2.0.0-next.35
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 +320 -13
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/internal/derive-computed-context.d.ts +6 -1
- package/dist/internal/derive-computed-context.js +6 -0
- package/dist/internal/derive-computed-context.js.map +1 -1
- package/dist/internal/item-session-facts.d.ts +5 -2
- package/dist/internal/item-session-facts.js +5 -3
- package/dist/internal/item-session-facts.js.map +1 -1
- package/dist/internal/test-host.context.d.ts +21 -0
- package/dist/internal/test-host.context.js.map +1 -1
- package/dist/internal/test-timing.d.ts +8 -0
- package/dist/internal/test-timing.js +18 -0
- package/dist/internal/test-timing.js.map +1 -0
- package/dist/mixins/test-processing.mixin.js +5 -2
- package/dist/mixins/test-processing.mixin.js.map +1 -1
- package/dist/mixins/test-state.mixin.d.ts +16 -9
- package/dist/mixins/test-state.mixin.js +86 -8
- package/dist/mixins/test-state.mixin.js.map +1 -1
- package/dist/public-events.d.ts +19 -0
- package/dist/public-events.js +4 -0
- package/dist/public-events.js.map +1 -1
- package/dist/types/qti-test-state.d.ts +20 -0
- package/dist/types/qti-test-state.js.map +1 -1
- package/package.json +4 -4
|
@@ -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,MA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QAAG,GAAkB,IAAI,CAAC;QAU1B,kBAAa,GAAkB,EAAE,CAAC;QAEzC;;;;;;;;;WASG;QAGI,eAAU,GAAe;YAC9B,WAAW,EAAE;gBACX,cAAc,EAAE,EAAE;gBAClB,mBAAmB,EAAE,EAAE;gBACvB,qBAAqB,EAAE,SAAS;aACjC;SACF,CAAC;QA1CA,0FAA0F;QAC1F,IAAI,CAAC,aAAa,GAAG,IAAI,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,EAA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Q,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,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"]}
|
|
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;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,MAAM,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U,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;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, closedByTimeUp, endItemAttempt, followItemSession, followTiming, itemRefsInOrder, readItemFacts, seedItemLifecycle, sectionsInOrder, submitTestPart, timeLimitRules, timeUps } 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';
|
|
@@ -17,13 +17,23 @@ import { assessOptimality, deriveComputedContext } from '../../internal/derive-c
|
|
|
17
17
|
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
|
+
import { emptyTiming, qtiTestTiming } from '../../internal/test-timing';
|
|
20
21
|
import { testHostContext } from '../../internal/test-host.context';
|
|
21
|
-
import { listenPublic } from '../../public-events';
|
|
22
|
+
import { dispatchPublic, listenPublic } from '../../public-events';
|
|
22
23
|
import { itemsInOrder } from '../../computed-tree';
|
|
23
24
|
/** A new object each time: a host that mutates the one it read must not change anyone else's. */
|
|
24
25
|
const newQtiContext = () => ({
|
|
25
26
|
QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }
|
|
26
27
|
});
|
|
28
|
+
/** Whether any level of the test declares `qti-time-limits`: only then is time kept (impl. guide §4.3). */
|
|
29
|
+
const hasTimeLimits = (model) => Boolean(model.timeLimits) ||
|
|
30
|
+
model.testParts.some(part => part.timeLimits ||
|
|
31
|
+
sectionsInOrder(part.sections).some(section => section.timeLimits) ||
|
|
32
|
+
itemRefsInOrder(part.sections).some(item => item.timeLimits));
|
|
33
|
+
/** How often the time left is updated; `config.timingSaveInterval` counts in these ticks. */
|
|
34
|
+
const TICK_MS = 1000;
|
|
35
|
+
/** Every how many seconds the time spent is saved when `config.timingSaveInterval` is not set. */
|
|
36
|
+
const DEFAULT_SAVE_INTERVAL = 10;
|
|
27
37
|
export class TestNavigation extends LitElement {
|
|
28
38
|
/**
|
|
29
39
|
* @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
|
|
@@ -61,21 +71,79 @@ export class TestNavigation extends LitElement {
|
|
|
61
71
|
/** The `qti-test` this navigation answers Next for in a linear part. */
|
|
62
72
|
#linearNextHost;
|
|
63
73
|
#registerLinearNext(host) {
|
|
64
|
-
if (this.#linearNextHost && this.#linearNextHost !== host)
|
|
74
|
+
if (this.#linearNextHost && this.#linearNextHost !== host) {
|
|
65
75
|
this.#linearNextHost.beforeLinearNext = null;
|
|
76
|
+
this.#linearNextHost.submitTestParts = null;
|
|
77
|
+
}
|
|
66
78
|
this.#linearNextHost = host;
|
|
67
79
|
host.beforeLinearNext = this.#beforeLinearNext;
|
|
80
|
+
host.submitTestParts = this.#submitTestParts;
|
|
68
81
|
}
|
|
69
82
|
connectedCallback() {
|
|
70
83
|
super.connectedCallback();
|
|
71
|
-
if (this.#linearNextHost)
|
|
84
|
+
if (this.#linearNextHost) {
|
|
72
85
|
this.#linearNextHost.beforeLinearNext = this.#beforeLinearNext;
|
|
86
|
+
this.#linearNextHost.submitTestParts = this.#submitTestParts;
|
|
87
|
+
}
|
|
88
|
+
if (this.#model && hasTimeLimits(this.#model))
|
|
89
|
+
this.#startTicking();
|
|
73
90
|
}
|
|
74
91
|
disconnectedCallback() {
|
|
75
92
|
super.disconnectedCallback();
|
|
76
93
|
if (this.#linearNextHost?.beforeLinearNext === this.#beforeLinearNext)
|
|
77
94
|
this.#linearNextHost.beforeLinearNext = null;
|
|
95
|
+
if (this.#linearNextHost?.submitTestParts === this.#submitTestParts)
|
|
96
|
+
this.#linearNextHost.submitTestParts = null;
|
|
97
|
+
this.#stopTicking();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* While a time limit is in force: the time left is updated every second, and the time spent is
|
|
101
|
+
* saved (`qc-test-state-changed`) every `config.timingSaveInterval` seconds (10 by default; 0:
|
|
102
|
+
* never on the tick) and when the page is hidden. With `config.pauseWhenHidden` the time stops
|
|
103
|
+
* while the page is hidden. The tick only checks and
|
|
104
|
+
* repaints: the time itself is read from the clock (roadmap 1 T5), so a tick the browser delays
|
|
105
|
+
* in a background tab loses nothing; the check runs again as soon as the page is visible.
|
|
106
|
+
*/
|
|
107
|
+
#ticker;
|
|
108
|
+
#ticks;
|
|
109
|
+
#startTicking() {
|
|
110
|
+
if (this.#ticker !== null)
|
|
111
|
+
return;
|
|
112
|
+
this.#ticks = 0;
|
|
113
|
+
this.#ticker = setInterval(this.#tick, TICK_MS);
|
|
114
|
+
addEventListener('pagehide', this.#save);
|
|
115
|
+
document.addEventListener('visibilitychange', this.#onVisibilityChange);
|
|
116
|
+
}
|
|
117
|
+
#stopTicking() {
|
|
118
|
+
if (this.#ticker === null)
|
|
119
|
+
return;
|
|
120
|
+
clearInterval(this.#ticker);
|
|
121
|
+
this.#ticker = null;
|
|
122
|
+
removeEventListener('pagehide', this.#save);
|
|
123
|
+
document.removeEventListener('visibilitychange', this.#onVisibilityChange);
|
|
78
124
|
}
|
|
125
|
+
#tick;
|
|
126
|
+
#save;
|
|
127
|
+
#onVisibilityChange;
|
|
128
|
+
/** The candidate session runs: always while the page is open, unless hidden with `pauseWhenHidden`. */
|
|
129
|
+
#running() {
|
|
130
|
+
return !(this.configContext?.pauseWhenHidden && document.visibilityState === 'hidden');
|
|
131
|
+
}
|
|
132
|
+
/** The `submission-mode` of the test part that holds the item-ref; undefined before the model is known. */
|
|
133
|
+
#submissionModeOf(itemRefId) {
|
|
134
|
+
if (!itemRefId)
|
|
135
|
+
return undefined;
|
|
136
|
+
return this.#model?.testParts.find(testPart => itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId))?.submissionMode;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Submits every test part with simultaneous submission that is not submitted yet, as a paper exam
|
|
140
|
+
* is handed in (QTI 3 info model §2.8.2; decided 2026-12-01, `plans/host-api.md`): each item the
|
|
141
|
+
* candidate opened gets its one attempt (`numAttempts` 1) and, when it is not adaptive,
|
|
142
|
+
* `completionStatus` `completed`; every session closes (`submitTestPart`). The responses were
|
|
143
|
+
* scored in the background as they changed, so nothing is processed again here. The caller runs
|
|
144
|
+
* the test's outcome processing after it (`submit()`). Sends `qc-test-part-submitted` per part.
|
|
145
|
+
*/
|
|
146
|
+
#submitTestParts;
|
|
79
147
|
/**
|
|
80
148
|
* Next in a linear individual part leaves the item for good (implementation guide §4.1), so it
|
|
81
149
|
* submits what the candidate gave (decided 2026-11-27): refused while the session control refuses
|
|
@@ -139,6 +207,78 @@ export class TestNavigation extends LitElement {
|
|
|
139
207
|
this.#registerLinearNext(host);
|
|
140
208
|
}
|
|
141
209
|
});
|
|
210
|
+
/**
|
|
211
|
+
* While a time limit is in force: the time left is updated every second, and the time spent is
|
|
212
|
+
* saved (`qc-test-state-changed`) every `config.timingSaveInterval` seconds (10 by default; 0:
|
|
213
|
+
* never on the tick) and when the page is hidden. With `config.pauseWhenHidden` the time stops
|
|
214
|
+
* while the page is hidden. The tick only checks and
|
|
215
|
+
* repaints: the time itself is read from the clock (roadmap 1 T5), so a tick the browser delays
|
|
216
|
+
* in a background tab loses nothing; the check runs again as soon as the page is visible.
|
|
217
|
+
*/
|
|
218
|
+
this.#ticker = null;
|
|
219
|
+
this.#ticks = 0;
|
|
220
|
+
this.#tick = () => {
|
|
221
|
+
this.requestUpdate();
|
|
222
|
+
const every = this.configContext?.timingSaveInterval ?? DEFAULT_SAVE_INTERVAL;
|
|
223
|
+
if (every > 0 && ++this.#ticks >= every) {
|
|
224
|
+
this.#ticks = 0;
|
|
225
|
+
this.#save();
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
this.#save = () => this.#testHost.value?.saveTiming();
|
|
229
|
+
this.#onVisibilityChange = () => {
|
|
230
|
+
if (document.visibilityState === 'hidden') {
|
|
231
|
+
// Stop the stopwatches now, not at the next render, which a hidden page may never get.
|
|
232
|
+
if (this.configContext?.pauseWhenHidden)
|
|
233
|
+
this.#followTiming();
|
|
234
|
+
this.#save();
|
|
235
|
+
}
|
|
236
|
+
else
|
|
237
|
+
this.requestUpdate();
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Submits every test part with simultaneous submission that is not submitted yet, as a paper exam
|
|
241
|
+
* is handed in (QTI 3 info model §2.8.2; decided 2026-12-01, `plans/host-api.md`): each item the
|
|
242
|
+
* candidate opened gets its one attempt (`numAttempts` 1) and, when it is not adaptive,
|
|
243
|
+
* `completionStatus` `completed`; every session closes (`submitTestPart`). The responses were
|
|
244
|
+
* scored in the background as they changed, so nothing is processed again here. The caller runs
|
|
245
|
+
* the test's outcome processing after it (`submit()`). Sends `qc-test-part-submitted` per part.
|
|
246
|
+
*/
|
|
247
|
+
this.#submitTestParts = () => {
|
|
248
|
+
const host = this.#testHost.value;
|
|
249
|
+
if (!this.#model || !host)
|
|
250
|
+
return;
|
|
251
|
+
const facts = this.#sessionFacts();
|
|
252
|
+
for (const testPart of this.#model.testParts) {
|
|
253
|
+
if (testPart.submissionMode !== 'simultaneous')
|
|
254
|
+
continue;
|
|
255
|
+
const items = itemRefsInOrder(testPart.sections).flatMap(({ identifier }) => {
|
|
256
|
+
const itemFacts = facts.get(identifier);
|
|
257
|
+
return itemFacts
|
|
258
|
+
? [{ item: identifier, previous: this.#sessions.get(identifier) ?? null, facts: itemFacts }]
|
|
259
|
+
: [];
|
|
260
|
+
});
|
|
261
|
+
const submission = submitTestPart(items);
|
|
262
|
+
if (!submission)
|
|
263
|
+
continue;
|
|
264
|
+
const submitted = [];
|
|
265
|
+
for (const { item, session } of submission.sessions) {
|
|
266
|
+
const before = facts.get(item);
|
|
267
|
+
this.#sessions.set(item, session);
|
|
268
|
+
if (session.numAttempts === before.numAttempts)
|
|
269
|
+
continue;
|
|
270
|
+
submitted.push(item);
|
|
271
|
+
host.updateItemVariables(item, [
|
|
272
|
+
{ identifier: 'numAttempts', value: String(session.numAttempts) },
|
|
273
|
+
...(session.adaptive ? [] : [{ identifier: 'completionStatus', value: 'completed' }])
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
if (submitted.length === 0)
|
|
277
|
+
continue;
|
|
278
|
+
dispatchPublic(host, 'qc-test-part-submitted', { testPart: testPart.identifier, items: submitted });
|
|
279
|
+
}
|
|
280
|
+
this.requestUpdate();
|
|
281
|
+
};
|
|
142
282
|
/**
|
|
143
283
|
* Next in a linear individual part leaves the item for good (implementation guide §4.1), so it
|
|
144
284
|
* submits what the candidate gave (decided 2026-11-27): refused while the session control refuses
|
|
@@ -183,6 +323,14 @@ export class TestNavigation extends LitElement {
|
|
|
183
323
|
this.#sessions = new Map();
|
|
184
324
|
/** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
|
|
185
325
|
this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
|
|
326
|
+
/** The item-refs whose time is up: their sessions are closed (`ItemSessionFacts.timeUp`) and never open again. */
|
|
327
|
+
this.#timedUp = new Set();
|
|
328
|
+
/** The levels `qc-test-time-up` was sent for while this page lives, as `scope:identifier`. */
|
|
329
|
+
this.#timeUpsSent = new Set();
|
|
330
|
+
/** A time-up found by the last derive, acted on once the update is through (`#applyTimeUp`). */
|
|
331
|
+
this.#pendingTimeUp = null;
|
|
332
|
+
/** The rendered items already scored on arrival, so each is scored once per rendering. */
|
|
333
|
+
this.#scoredOnArrival = new WeakSet();
|
|
186
334
|
/** The items this navigation disabled because their attempts are used, so it releases only those. */
|
|
187
335
|
this.#lockedItems = new WeakSet();
|
|
188
336
|
listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));
|
|
@@ -274,7 +422,8 @@ export class TestNavigation extends LitElement {
|
|
|
274
422
|
.map(itemRef => itemRef.identifier));
|
|
275
423
|
return itemSessionFacts(this.#model, this.#itemFacts(), this._testContext?.items, {
|
|
276
424
|
current: this._sessionContext?.navItemRefId,
|
|
277
|
-
presented
|
|
425
|
+
presented,
|
|
426
|
+
timeUp: this.#timedUp
|
|
278
427
|
});
|
|
279
428
|
}
|
|
280
429
|
/**
|
|
@@ -329,9 +478,19 @@ export class TestNavigation extends LitElement {
|
|
|
329
478
|
*/
|
|
330
479
|
#handleTestEndAttempt(event) {
|
|
331
480
|
const itemId = event.detail?.itemId;
|
|
481
|
+
const itemRefId = itemId ?? this._sessionContext?.navItemRefId ?? undefined;
|
|
482
|
+
if (itemRefId && this.#timedUp.has(itemRefId)) {
|
|
483
|
+
// Its time is up: a response given now is not accepted (QTI 3 info model §7.40).
|
|
484
|
+
console.warn(`qc-test-end-attempt refused: the time of ${itemRefId} is up.`);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
332
487
|
const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;
|
|
333
488
|
if (!qtiAssessmentItemEl)
|
|
334
489
|
return;
|
|
490
|
+
if (this.#submissionModeOf(itemRefId) === 'simultaneous') {
|
|
491
|
+
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.`);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
335
494
|
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
336
495
|
qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
|
|
337
496
|
}
|
|
@@ -345,7 +504,19 @@ export class TestNavigation extends LitElement {
|
|
|
345
504
|
const itemRefId = this.#itemRefIdOf(_event.composedPath()[0]);
|
|
346
505
|
if (itemRefId)
|
|
347
506
|
this.#changed.add(itemRefId);
|
|
348
|
-
|
|
507
|
+
// A part with simultaneous submission is a paper exam (decided 2026-12-01): every change is
|
|
508
|
+
// scored in the background, without ending the attempt, so a saved state always holds the
|
|
509
|
+
// scores. `auto-score-items` adds nothing there. An item whose `SCORE` is `external-scored` is
|
|
510
|
+
// left alone, as `auto-score-items` left it: a run would reset the score a scorer gave.
|
|
511
|
+
if (this.#submissionModeOf(itemRefId) === 'simultaneous') {
|
|
512
|
+
const computedItem = this.computedItemFor(itemRefId);
|
|
513
|
+
if (computedItem?.rules?.done || computedItem?.externalScored)
|
|
514
|
+
return;
|
|
515
|
+
this.#assessmentItemFor(itemRefId)?.scoreResponse();
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
// Its time is up: a change is not scored (QTI 3 info model §7.40).
|
|
519
|
+
if (this.autoScoreItems && !(itemRefId && this.#timedUp.has(itemRefId))) {
|
|
349
520
|
const assessmentItem = _event.composedPath()[0].closest('qti-assessment-item');
|
|
350
521
|
// Autoscoring resolves the item from the event's own path, so a change
|
|
351
522
|
// raised outside an assessment item has nothing to score.
|
|
@@ -370,6 +541,9 @@ export class TestNavigation extends LitElement {
|
|
|
370
541
|
this.#optimality.clear();
|
|
371
542
|
this.#sessions.clear();
|
|
372
543
|
this.#changed.clear();
|
|
544
|
+
this.#timedUp.clear();
|
|
545
|
+
this.#timeUpsSent.clear();
|
|
546
|
+
this.#pendingTimeUp = null;
|
|
373
547
|
// Set the testIdentifier in qtiContext if not already set
|
|
374
548
|
if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
|
|
375
549
|
const currentContext = this.qtiContext.QTI_CONTEXT || {
|
|
@@ -402,6 +576,17 @@ export class TestNavigation extends LitElement {
|
|
|
402
576
|
// The structure and the session-control cascade come from the test's markup, not from upgraded
|
|
403
577
|
// properties, so they do not depend on registration or render timing.
|
|
404
578
|
this.#model = buildTestModel(renderedMarkup(this.#testElement));
|
|
579
|
+
this.#stopTicking();
|
|
580
|
+
const host = this.#testHost.value;
|
|
581
|
+
if (hasTimeLimits(this.#model)) {
|
|
582
|
+
// A restored state brought its timing; a first start begins with none spent.
|
|
583
|
+
if (host && !host.timing)
|
|
584
|
+
host.updateTiming(emptyTiming());
|
|
585
|
+
this.#startTicking();
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
host?.updateTiming(null);
|
|
589
|
+
}
|
|
405
590
|
this.computedContext = this.#derive();
|
|
406
591
|
}
|
|
407
592
|
/** The test's structure and resolved session control, read from its markup when it is connected. */
|
|
@@ -410,6 +595,7 @@ export class TestNavigation extends LitElement {
|
|
|
410
595
|
#derive() {
|
|
411
596
|
this.#seedOptimality();
|
|
412
597
|
this.#followSessions();
|
|
598
|
+
const timeLimits = this.#followTiming();
|
|
413
599
|
return deriveComputedContext({
|
|
414
600
|
model: this.#model,
|
|
415
601
|
itemFacts: this.#itemFacts(),
|
|
@@ -419,9 +605,90 @@ export class TestNavigation extends LitElement {
|
|
|
419
605
|
itemData: this.initContext,
|
|
420
606
|
optimality: this.#optimality,
|
|
421
607
|
lifecycle: new Map([...this.#sessions].map(([identifier, session]) => [identifier, session.state])),
|
|
422
|
-
itemElement: this.#itemElement
|
|
608
|
+
itemElement: this.#itemElement,
|
|
609
|
+
timeLimits
|
|
423
610
|
});
|
|
424
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* The test's timing after following the candidate, at the clock's time now: the test, the
|
|
614
|
+
* current item's part and sections run, and each item's duration while it is interacting
|
|
615
|
+
* (`followTiming`). Written back to the test for its state when a stopwatch started or stopped.
|
|
616
|
+
* Returns the time limits against it (`timeLimitRules`), or nothing for a test without limits.
|
|
617
|
+
*/
|
|
618
|
+
#followTiming() {
|
|
619
|
+
const host = this.#testHost.value;
|
|
620
|
+
const model = this.#model;
|
|
621
|
+
if (!host?.timing || !model)
|
|
622
|
+
return undefined;
|
|
623
|
+
const now = host.clock.now();
|
|
624
|
+
const order = model.testParts.flatMap(part => itemRefsInOrder(part.sections).map(item => item.identifier));
|
|
625
|
+
const record = {
|
|
626
|
+
current: this._sessionContext?.navItemRefId ?? null,
|
|
627
|
+
timing: { test: host.timing.test, testParts: host.timing.testParts, sections: host.timing.sections },
|
|
628
|
+
items: Object.fromEntries(order.map(id => [
|
|
629
|
+
id,
|
|
630
|
+
{
|
|
631
|
+
// The model names a with-replacement clone by its instance, so the instance is its item-ref here.
|
|
632
|
+
itemRefIdentifier: id,
|
|
633
|
+
lifecycle: this.#sessions.get(id)?.state ?? 'initial',
|
|
634
|
+
duration: host.timing.items[id] ?? { spent: 0, since: null }
|
|
635
|
+
}
|
|
636
|
+
]))
|
|
637
|
+
};
|
|
638
|
+
const followed = followTiming(record, model, { now, running: this.#running() });
|
|
639
|
+
const timing = qtiTestTiming(followed);
|
|
640
|
+
if (JSON.stringify(timing) !== JSON.stringify(host.timing))
|
|
641
|
+
host.updateTiming(timing);
|
|
642
|
+
const answers = timeLimitRules(model, { ...followed, order }, now);
|
|
643
|
+
this.#noteTimeUp(closedByTimeUp(model, { order, items: followed.items }, answers), timeUps(model, answers));
|
|
644
|
+
return answers;
|
|
645
|
+
}
|
|
646
|
+
/** The item-refs whose time is up: their sessions are closed (`ItemSessionFacts.timeUp`) and never open again. */
|
|
647
|
+
#timedUp;
|
|
648
|
+
/** The levels `qc-test-time-up` was sent for while this page lives, as `scope:identifier`. */
|
|
649
|
+
#timeUpsSent;
|
|
650
|
+
/** A time-up found by the last derive, acted on once the update is through (`#applyTimeUp`). */
|
|
651
|
+
#pendingTimeUp;
|
|
652
|
+
#noteTimeUp(closed, ups) {
|
|
653
|
+
const newlyClosed = closed.filter(id => !this.#timedUp.has(id));
|
|
654
|
+
const unsent = ups.filter(up => !this.#timeUpsSent.has(`${up.scope}:${up.identifier}`));
|
|
655
|
+
if (newlyClosed.length || unsent.length)
|
|
656
|
+
this.#pendingTimeUp = { closed: newlyClosed, timeUps: unsent };
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Ends what a time-up ends (QTI 3 info model §7.40, §2.2.2.2 "running out of time"), after the update
|
|
660
|
+
* that found it: the attempt of an item on screen in an individual part is scored as it stands (as
|
|
661
|
+
* Next does in a linear part: when none was scored yet or the responses changed since), then every
|
|
662
|
+
* session under the level closes (the next derive follows `#timedUp`), and `qc-test-time-up` is sent
|
|
663
|
+
* once per level. A stored state whose time was up scores nothing again: its attempt was counted.
|
|
664
|
+
*/
|
|
665
|
+
#applyTimeUp() {
|
|
666
|
+
const pending = this.#pendingTimeUp;
|
|
667
|
+
if (!pending)
|
|
668
|
+
return;
|
|
669
|
+
this.#pendingTimeUp = null;
|
|
670
|
+
const toScore = pending.closed.filter(id => this.#scoresAtTimeUp(id));
|
|
671
|
+
for (const id of pending.closed)
|
|
672
|
+
this.#timedUp.add(id);
|
|
673
|
+
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true;
|
|
674
|
+
for (const id of toScore)
|
|
675
|
+
this.#assessmentItemFor(id)?.processResponse(true, reportValidityAfterScoring);
|
|
676
|
+
for (const up of pending.timeUps) {
|
|
677
|
+
this.#timeUpsSent.add(`${up.scope}:${up.identifier}`);
|
|
678
|
+
dispatchPublic(this, 'qc-test-time-up', up);
|
|
679
|
+
}
|
|
680
|
+
if (pending.closed.length)
|
|
681
|
+
this.requestUpdate();
|
|
682
|
+
}
|
|
683
|
+
/** Whether the attempt of an item whose time ran out is scored: on screen, interacting, in an individual part, not scored as it stands. */
|
|
684
|
+
#scoresAtTimeUp(itemRefId) {
|
|
685
|
+
const part = this.#model?.testParts.find(testPart => itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId));
|
|
686
|
+
const session = this.#sessions.get(itemRefId);
|
|
687
|
+
return (part?.submissionMode === 'individual' &&
|
|
688
|
+
session?.state === 'interacting' &&
|
|
689
|
+
Boolean(this.#assessmentItemFor(itemRefId)) &&
|
|
690
|
+
(session.numAttempts === 0 || this.#changed.has(itemRefId)));
|
|
691
|
+
}
|
|
425
692
|
/**
|
|
426
693
|
* On a restored session no attempt is ended this run, so the latch is seeded once from the
|
|
427
694
|
* persisted context, which still holds the submitted response. A later change of the answer
|
|
@@ -486,7 +753,34 @@ export class TestNavigation extends LitElement {
|
|
|
486
753
|
}
|
|
487
754
|
updated(changedProperties) {
|
|
488
755
|
super.updated(changedProperties);
|
|
756
|
+
this.#applyTimeUp();
|
|
489
757
|
this.#lockUsedItems();
|
|
758
|
+
this.#scoreOnFirstPresentation();
|
|
759
|
+
}
|
|
760
|
+
/** The rendered items already scored on arrival, so each is scored once per rendering. */
|
|
761
|
+
#scoredOnArrival;
|
|
762
|
+
/**
|
|
763
|
+
* In a part with simultaneous submission, scores every item once in the background when it is
|
|
764
|
+
* first shown (decided 2026-12-03). An item the candidate opens and leaves blank gets the outcomes
|
|
765
|
+
* its response processing gives no answer, as it would on paper, not only their defaults; a
|
|
766
|
+
* restored item is scored again from its restored responses, which gives the same scores. Skipped,
|
|
767
|
+
* like every background score, for a closed item and one whose `SCORE` is `external-scored`.
|
|
768
|
+
*/
|
|
769
|
+
#scoreOnFirstPresentation() {
|
|
770
|
+
if (!this.#testElement || !this.computedContext)
|
|
771
|
+
return;
|
|
772
|
+
for (const itemRef of this.#testElement.querySelectorAll('qti-assessment-item-ref')) {
|
|
773
|
+
const element = itemRef.assessmentItem;
|
|
774
|
+
if (!element || this.#scoredOnArrival.has(element))
|
|
775
|
+
continue;
|
|
776
|
+
if (this.#submissionModeOf(itemRef.identifier) !== 'simultaneous')
|
|
777
|
+
continue;
|
|
778
|
+
const computedItem = this.computedItemFor(itemRef.identifier);
|
|
779
|
+
if (!computedItem || computedItem.rules?.done || computedItem.externalScored)
|
|
780
|
+
continue;
|
|
781
|
+
if (element.scoreResponse())
|
|
782
|
+
this.#scoredOnArrival.add(element);
|
|
783
|
+
}
|
|
490
784
|
}
|
|
491
785
|
/** The items this navigation disabled because their attempts are used, so it releases only those. */
|
|
492
786
|
#lockedItems;
|
|
@@ -495,7 +789,8 @@ export class TestNavigation extends LitElement {
|
|
|
495
789
|
* a completed adaptive item), so the candidate cannot change the answer once the last attempt is
|
|
496
790
|
* ended (QTI info model §2.2.1). Runs after every update: an item rendered later (another item, a
|
|
497
791
|
* 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.
|
|
792
|
+
* zero (a new state) is released. In a part with simultaneous submission every session closes
|
|
793
|
+
* when the part is submitted, so its items lock then.
|
|
499
794
|
*
|
|
500
795
|
* Only `disabled = true` is ever set here, and only on an item that was not disabled already; a
|
|
501
796
|
* host or view that disables or makes an item read-only itself keeps it so.
|
|
@@ -503,16 +798,22 @@ export class TestNavigation extends LitElement {
|
|
|
503
798
|
#lockUsedItems() {
|
|
504
799
|
if (!this.#testElement || !this.computedContext)
|
|
505
800
|
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])));
|
|
801
|
+
const items = new Map(this.computedContext.testParts.flatMap(part => itemsInOrder(part).map(item => [item.instance, { item, simultaneous: part.submissionMode === 'simultaneous' }])));
|
|
509
802
|
for (const itemRef of this.#testElement.querySelectorAll('qti-assessment-item-ref')) {
|
|
510
803
|
const element = itemRef.assessmentItem;
|
|
511
804
|
if (!element)
|
|
512
805
|
continue;
|
|
806
|
+
const entry = items.get(itemRef.identifier);
|
|
807
|
+
// A simultaneous part ends attempts only when it is submitted, so its end-attempt
|
|
808
|
+
// interactions are off (decided 2026-12-01).
|
|
809
|
+
if (entry?.simultaneous)
|
|
810
|
+
this.#disableEndAttemptInteractions(element);
|
|
513
811
|
// 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
|
-
|
|
812
|
+
// is scored as an attempt, so the count is not the candidate's and locks nothing; in a
|
|
813
|
+
// simultaneous part it is built in and never counts, so the session decides. A session whose
|
|
814
|
+
// time is up is over in any part, also a simultaneous one (QTI 3 info model §7.40).
|
|
815
|
+
const used = this.#timedUp.has(itemRef.identifier) ||
|
|
816
|
+
((entry?.simultaneous || !this.autoScoreItems) && entry?.item.rules?.done === true);
|
|
516
817
|
if (used && !element.disabled) {
|
|
517
818
|
element.disabled = true;
|
|
518
819
|
this.#lockedItems.add(element);
|
|
@@ -523,6 +824,12 @@ export class TestNavigation extends LitElement {
|
|
|
523
824
|
}
|
|
524
825
|
}
|
|
525
826
|
}
|
|
827
|
+
#disableEndAttemptInteractions(element) {
|
|
828
|
+
for (const interaction of element.querySelectorAll('qti-end-attempt-interaction')) {
|
|
829
|
+
if (!interaction.disabled)
|
|
830
|
+
interaction.disabled = true;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
526
833
|
}
|
|
527
834
|
__decorate([
|
|
528
835
|
property({ type: String })
|