@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-navigation.js","sourceRoot":"","sources":["../../../src/components/test-navigation/test-navigation.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,I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;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oDACd;AAI3B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACX;AAKjC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDAClB;AAI5B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;uDACK;AAEiB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;sDAAwB","sourcesContent":["import { ContextConsumer, consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\nimport {\n buildTestModel,\n endItemAttempt,\n followItemSession,\n itemRefsInOrder,\n readItemFacts,\n seedItemLifecycle\n} from '@qti-components/delivery';\nimport { configContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\nimport { sessionContext } from '@qti-components/base';\nimport { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';\n\nimport { assessOptimality, deriveComputedContext } from '../../internal/derive-computed-context';\nimport { itemFactsContext } from '../../internal/item-facts.context';\nimport { attemptsOf, itemSessionFacts } from '../../internal/item-session-facts';\nimport { renderedMarkup } from '../../internal/rendered-markup';\nimport { testHostContext } from '../../internal/test-host.context';\nimport { listenPublic } from '../../public-events';\nimport { itemsInOrder } from '../../computed-tree';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiContext } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { ItemSession, ItemSessionFacts, TestModel } from '@qti-components/delivery';\nimport type { ItemOptimality } from '../../internal/derive-computed-context';\nimport type { ItemFactsByRef } from '../../internal/item-facts.context';\nimport type { LinearNextRefusal, TestHost } from '../../internal/test-host.context';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\n/** A new object each time: a host that mutates the one it read must not change anyone else's. */\nconst newQtiContext = (): QtiContext => ({\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n});\n\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier: string | undefined = undefined;\n\n /**\n * Your own per-item fields, by item-ref `identifier`: each `computedContext` item carries them as\n * given under `data`, without the identifier, and so does every view of it a plugin derives. They\n * never replace a field the test, the item or the candidate's state gives, whatever its name; a\n * template reads `activeItem.data.<field>`. To mark an item as scored by hand, set\n * `external-scored` on its `SCORE` declaration in `postLoadTransformCallback`.\n */\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n /**\n * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the\n * enclosing test's: reading returns it, writing replaces it, so a host that has always set the\n * shuffle seed here keeps working. Removed in the next major.\n *\n * Written before the navigation is inside a test, it waits and is handed over on connect.\n */\n public get qtiContext(): QtiContext {\n return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());\n }\n\n public set qtiContext(value: QtiContext) {\n if (!this.#warnedQtiContext) {\n this.#warnedQtiContext = true;\n console.warn(\n '[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major ' +\n 'release. Set `qtiContext` on `<qti-test>` instead; it is the same value.'\n );\n }\n this.#writeQtiContext(value);\n }\n\n #pendingQtiContext?: QtiContext;\n #warnedQtiContext = false;\n\n /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */\n #writeQtiContext(value: QtiContext): void {\n const owner = this.#owner();\n if (owner) owner.qtiContext = value;\n else this.#pendingQtiContext = value;\n }\n\n /**\n * The `qti-test` this navigation is in, found through context so it works across shadow roots.\n * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.\n */\n #testHost = new ContextConsumer(this, {\n context: testHostContext,\n subscribe: true,\n callback: host => {\n if (host && this.#pendingQtiContext) {\n host.qtiContext = this.#pendingQtiContext;\n this.#pendingQtiContext = undefined;\n }\n if (host) this.#registerLinearNext(host);\n }\n });\n\n /** The `qti-test` this navigation answers Next for in a linear part. */\n #linearNextHost?: TestHost;\n\n #registerLinearNext(host: TestHost): void {\n if (this.#linearNextHost && this.#linearNextHost !== host) this.#linearNextHost.beforeLinearNext = null;\n this.#linearNextHost = host;\n host.beforeLinearNext = this.#beforeLinearNext;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.#linearNextHost) this.#linearNextHost.beforeLinearNext = this.#beforeLinearNext;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.#linearNextHost?.beforeLinearNext === this.#beforeLinearNext) this.#linearNextHost.beforeLinearNext = null;\n }\n\n /**\n * Next in a linear individual part leaves the item for good (implementation guide §4.1), so it\n * submits what the candidate gave (decided 2026-11-27): refused while the session control refuses\n * those responses (`rules.maySubmit`), else the attempt is ended when one is open: none ended yet,\n * or the responses changed since the last. Called by the navigation mixin while the item is still\n * rendered; the item is closed when the navigation moves past it.\n */\n #beforeLinearNext = (itemRefId: string): LinearNextRefusal | null => {\n const part = this.#model?.testParts.find(testPart =>\n itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId)\n );\n if (part?.navigationMode !== 'linear' || part.submissionMode !== 'individual') return null;\n const session = this.#sessions.get(itemRefId);\n const rules = this.computedItemFor(itemRefId)?.rules;\n if (session?.state !== 'interacting' || !rules) return null;\n if (!rules.maySubmit) {\n return { reason: rules.maySkip ? 'validate-responses' : 'allow-skipping', itemId: itemRefId };\n }\n if (session.numAttempts === 0 || this.#changed.has(itemRefId)) {\n this.#assessmentItemFor(itemRefId)?.processResponse(\n true,\n this.configContext?.reportValidityAfterScoring === true\n );\n }\n return null;\n };\n\n /** The item-refs whose responses changed since their last ended attempt. */\n #changed = new Set<string>();\n\n #itemRefIdOf(element: EventTarget | undefined): string | undefined {\n const item = (element as HTMLElement | undefined)?.closest?.('qti-assessment-item');\n if (!item) return undefined;\n return [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])].find(\n itemRef => itemRef.assessmentItem === item\n )?.identifier;\n }\n\n #owner(): { qtiContext: QtiContext } | null {\n return this.#testHost.value ?? null;\n }\n\n @state()\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n /** Read from each item's XML when `qti-test` fetches it; see `itemFactsContext`. */\n @state()\n @consume({ context: itemFactsContext, subscribe: true })\n protected _itemFacts?: ItemFactsByRef;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n #testElement: QtiAssessmentTest;\n\n /**\n * Whether each item's last *ended attempt* reached the optimal outcome, keyed\n * by item-ref id. Written from #handleItemContextUpdated when processResponse\n * ends an attempt — never on a plain selection. Mirrors how inline feedback\n * only re-evaluates when an attempt is processed, so a freshly-picked answer\n * doesn't flip `done` until the candidate ends the attempt.\n */\n #optimality = new Map<string, ItemOptimality>();\n\n /**\n * Each item session's lifecycle state, by item-ref identifier, changed only through the lifecycle\n * table (`followItemSession` as the candidate moves, `endItemAttempt` when an attempt ends). It\n * lives here until `DeliveryState` holds it (roadmap 1, T3d); a session whose attempts change\n * outside an ended attempt (a restored or assigned state) is seeded again.\n */\n #sessions = new Map<string, ItemSession>();\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));\n\n listenItemPublic(this, 'qc-item-response-changed', this.#handleInteractionChanged.bind(this));\n this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));\n\n listenPublic(this, 'qc-test-end-attempt', this.#handleTestEndAttempt.bind(this));\n listenPublic(this, 'qc-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));\n listenPublic(this, 'qc-test-update-comment', this.#handleUpdateComment.bind(this));\n }\n\n /**\n * Sets the candidate's comment on an item when its session allows it (`rules.mayComment`:\n * `allow-comment`, while interacting; decided 2026-11-27, carried, not rendered).\n */\n #handleUpdateComment(event: CustomEvent<{ itemId: string; comment: string | null }>) {\n const { itemId, comment = null } = event.detail ?? ({} as { itemId?: string; comment?: string | null });\n const host = this.#testHost.value;\n if (!itemId || !host) return;\n if (comment !== null && typeof comment !== 'string') {\n console.warn(`[qti-test] Ignoring a comment for \"${itemId}\" that is not a string.`);\n return;\n }\n if (!this.computedItemFor(itemId)?.rules?.mayComment) {\n console.warn(\n `[qti-test] Ignoring a comment for \"${itemId}\": its allow-comment is false, or it is not interacting.`\n );\n return;\n }\n host.updateItemComment(itemId, comment);\n }\n\n /**\n * Latch whether an item reached its optimal outcome whenever it has just ended\n * an attempt. processResponse — fired by test-end-attempt, autoscore, or an\n * in-item end-attempt interaction — flags its context update with\n * `responseProcessed`; a plain selection updates the context without it, so\n * `done` can't flip until the candidate actually ends the attempt.\n */\n #handleItemContextUpdated(event: CustomEvent<{ itemContext: ItemContext; responseProcessed?: boolean }>) {\n if (!event.detail?.responseProcessed) return;\n const itemContext = event.detail.itemContext;\n if (!itemContext?.identifier) return;\n this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n this.#changed.delete(itemContext.identifier);\n this.#endAttempt(itemContext);\n\n const computedItem = this.computedItemFor(itemContext.identifier);\n this.afterAttemptEnded(\n (event.composedPath()[0] as HTMLElement)?.closest<QtiAssessmentItem>('qti-assessment-item'),\n computedItem,\n this.#doneAfterAttempt(itemContext, computedItem)\n );\n }\n\n /**\n * Moves the item's session on for its ended attempt. With `auto-score-items` every change is\n * scored as an attempt, so the count is not the candidate's: it is taken, and the state stays.\n */\n #endAttempt(itemContext: ItemContext): void {\n const facts = this.#sessionFacts().get(itemContext.identifier);\n if (!facts) return;\n const ended: ItemSessionFacts = { ...facts, ...attemptsOf(itemContext) };\n const previous = this.#sessions.get(itemContext.identifier);\n this.#sessions.set(\n itemContext.identifier,\n this.autoScoreItems\n ? {\n state: previous?.state ?? followItemSession(undefined, ended).state,\n numAttempts: ended.numAttempts,\n adaptive: ended.adaptive\n }\n : endItemAttempt(previous, ended)\n );\n }\n\n /**\n * Whether the item session is over after the attempt that just ended: its new state, or, before\n * the test model is known, the state an item on screen with these attempts is in.\n */\n #doneAfterAttempt(itemContext: ItemContext, computedItem: ComputedItem | undefined): boolean {\n const state =\n this.#sessions.get(itemContext.identifier)?.state ??\n (computedItem?.sessionControl\n ? seedItemLifecycle({\n sessionControl: computedItem.sessionControl,\n adaptive: computedItem.adaptive ?? false,\n ...attemptsOf(itemContext),\n presented: true,\n passed: false\n })\n : 'interacting');\n return state === 'closed' || state === 'review' || state === 'solution';\n }\n\n /** The facts of every item session now: the model, the item facts, the contexts and the items on screen. */\n #sessionFacts(): Map<string, ItemSessionFacts> {\n if (!this.#model) return new Map();\n const presented = new Set(\n [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])]\n .filter(itemRef => itemRef.assessmentItem)\n .map(itemRef => itemRef.identifier)\n );\n return itemSessionFacts(this.#model, this.#itemFacts(), this._testContext?.items, {\n current: this._sessionContext?.navItemRefId,\n presented\n });\n }\n\n /**\n * The item facts `qti-test` read from each fetched item, and, for an item rendered without them\n * (handed to its ref directly), the facts read from the rendered item.\n */\n #itemFacts(): ItemFactsByRef | undefined {\n const missing = [\n ...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])\n ].filter(\n itemRef =>\n itemRef.assessmentItem?.localName === 'qti-assessment-item' && !this._itemFacts?.has(itemRef.identifier)\n );\n if (!missing.length) return this._itemFacts;\n const facts = new Map(this._itemFacts ?? []);\n for (const itemRef of missing) facts.set(itemRef.identifier, readItemFacts(renderedMarkup(itemRef.assessmentItem)));\n return facts;\n }\n\n /** Moves every item session on for where the candidate is now. */\n #followSessions(): void {\n for (const [identifier, facts] of this.#sessionFacts()) {\n this.#sessions.set(identifier, followItemSession(this.#sessions.get(identifier), facts));\n }\n }\n\n /**\n * Extension point for presentation packages reacting to an ended attempt. `done` is the item\n * session's after this attempt (closed: its attempts used, whatever the score), settled here\n * because the computed context only catches up on the next update.\n */\n protected afterAttemptEnded(\n _assessmentItem: QtiAssessmentItem | undefined,\n _computedItem: ComputedItem | undefined,\n _done: boolean\n ): void {}\n\n /** The computed-context entry for an item, from the session-control cascade. */\n protected computedItemFor(identifier: string): ComputedItem | undefined {\n return this.computedContext?.testParts.flatMap(itemsInOrder).find(i => i.instance === identifier);\n }\n\n /** The assessment item for an item-ref id, if it has been rendered. */\n #assessmentItemFor(identifier: string | undefined): QtiAssessmentItem | undefined {\n if (!identifier) return undefined;\n const itemRef = this.#testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(identifier)}\"]`\n );\n return itemRef?.assessmentItem ?? undefined;\n }\n\n /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */\n #itemElement = (identifier: string): HTMLElement | null => this.#assessmentItemFor(identifier) ?? null;\n\n /** The currently active assessment item, exposed for optional presentation extensions. */\n protected get activeAssessmentItem(): QtiAssessmentItem | undefined {\n if (!this.#testElement || !this._sessionContext?.navItemRefId) return undefined;\n return this.#testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n )?.assessmentItem;\n }\n\n /**\n * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or\n * given an `item`), or else the item on screen.\n */\n #handleTestEndAttempt(event: CustomEvent<{ itemId?: string } | undefined>) {\n const itemId = event.detail?.itemId;\n const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;\n if (!qtiAssessmentItemEl) return;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n #handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);\n if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n #handleInteractionChanged(_event: CustomEvent) {\n const itemRefId = this.#itemRefIdOf(_event.composedPath()[0]);\n if (itemRefId) this.#changed.add(itemRefId);\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest<QtiAssessmentItem>(\n 'qti-assessment-item'\n );\n // Autoscoring resolves the item from the event's own path, so a change\n // raised outside an assessment item has nothing to score.\n if (!assessmentItem) return;\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n #handleTestConnected(event: CustomEvent) {\n this.#testElement = event.detail as QtiAssessmentTest;\n // A fresh test invalidates the per-test optimality latches and item sessions.\n this.#optimality.clear();\n this.#sessions.clear();\n this.#changed.clear();\n // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this.#testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n });\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this.#extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n });\n }\n });\n\n // The structure and the session-control cascade come from the test's markup, not from upgraded\n // properties, so they do not depend on registration or render timing.\n this.#model = buildTestModel(renderedMarkup(this.#testElement));\n this.computedContext = this.#derive();\n }\n\n /** The test's structure and resolved session control, read from its markup when it is connected. */\n #model?: TestModel;\n\n /** `computedContext`, derived anew from its inputs (`deriveComputedContext`), never from the previous one. */\n #derive(): ComputedContext {\n this.#seedOptimality();\n this.#followSessions();\n return deriveComputedContext({\n model: this.#model,\n itemFacts: this.#itemFacts(),\n testContext: this._testContext,\n sessionContext: this._sessionContext,\n infoItemCategory: this.configContext?.infoItemCategory,\n itemData: this.initContext,\n optimality: this.#optimality,\n lifecycle: new Map([...this.#sessions].map(([identifier, session]) => [identifier, session.state])),\n itemElement: this.#itemElement\n });\n }\n\n /**\n * On a restored session no attempt is ended this run, so the latch is seeded once from the\n * persisted context, which still holds the submitted response. A later change of the answer\n * leaves the seeded value alone.\n */\n #seedOptimality(): void {\n for (const itemContext of this._testContext?.items ?? []) {\n if (!itemContext.identifier || this.#optimality.has(itemContext.identifier)) continue;\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n if (numAttempts > 0) this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n }\n }\n\n /**\n * Extract default values from a qti-context-declaration element\n */\n #extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\n }\n\n /* On every change of the candidate's state, the context is derived again. */\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.#model) return;\n this.computedContext = this.#derive();\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n this.#lockUsedItems();\n }\n\n /** The items this navigation disabled because their attempts are used, so it releases only those. */\n #lockedItems = new WeakSet<QtiAssessmentItem>();\n\n /**\n * Disables every rendered item whose session is over (`rules.done`: closed, its attempts used or\n * a completed adaptive item), so the candidate cannot change the answer once the last attempt is\n * ended (QTI info model §2.2.1). Runs after every update: an item rendered later (another item, a\n * section on screen, a restored state) is locked as it arrives, and one whose attempts are back to\n * zero (a new state) is released.\n *\n * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a\n * host or view that disables or makes an item read-only itself keeps it so.\n */\n #lockUsedItems(): void {\n if (!this.#testElement || !this.computedContext) return;\n // In a simultaneous part every item has one attempt, processed when the part ends (QTI info model\n // §2.8.2), so the candidate may change the answer until then: TAO keeps such an item open too.\n const items = new Map(\n this.computedContext.testParts.flatMap(part =>\n part.submissionMode === 'simultaneous' ? [] : itemsInOrder(part).map(item => [item.instance, item] as const)\n )\n );\n for (const itemRef of this.#testElement.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')) {\n const element = itemRef.assessmentItem;\n if (!element) continue;\n // The session is over (closed, or in review or solution). With `auto-score-items` every change\n // is scored as an attempt, so the count is not the candidate's and locks nothing.\n const used = !this.autoScoreItems && items.get(itemRef.identifier)?.rules?.done === true;\n if (used && !element.disabled) {\n element.disabled = true;\n this.#lockedItems.add(element);\n } else if (!used && this.#lockedItems.has(element)) {\n this.#lockedItems.delete(element);\n element.disabled = false;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-navigation': TestNavigation;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test-navigation.js","sourceRoot":"","sources":["../../../src/components/test-navigation/test-navigation.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,OAAO,EACR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAA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C,EAAE,CAAC;gBACnD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAClC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED,8BAA8B,CAAC,OAA0B;QACvD,KAAK,MAAM,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAChD,6BAA6B,CAC9B,EAAE,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,QAAQ;gBAAE,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzD,CAAC;IACH,CAAC;CACF;AAxzB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAA4C;AAUhE;IADN,KAAK,EAAE;mDAC8D;AA6N/D;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;qDACZ;AAI/B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oDACd;AAI3B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACX;AAKjC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDAClB;AAI5B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;uDACK;AAEiB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;sDAAwB","sourcesContent":["import { ContextConsumer, consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\nimport {\n buildTestModel,\n closedByTimeUp,\n endItemAttempt,\n followItemSession,\n followTiming,\n itemRefsInOrder,\n readItemFacts,\n seedItemLifecycle,\n sectionsInOrder,\n submitTestPart,\n timeLimitRules,\n timeUps\n} from '@qti-components/delivery';\nimport { configContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\nimport { sessionContext } from '@qti-components/base';\nimport { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';\n\nimport { assessOptimality, deriveComputedContext } from '../../internal/derive-computed-context';\nimport { itemFactsContext } from '../../internal/item-facts.context';\nimport { attemptsOf, itemSessionFacts } from '../../internal/item-session-facts';\nimport { renderedMarkup } from '../../internal/rendered-markup';\nimport { emptyTiming, qtiTestTiming } from '../../internal/test-timing';\nimport { testHostContext } from '../../internal/test-host.context';\nimport { dispatchPublic, listenPublic } from '../../public-events';\nimport { itemsInOrder } from '../../computed-tree';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiContext } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type {\n ItemSession,\n ItemSessionFacts,\n TestModel,\n TimeLimitAnswers,\n TimeUp,\n TimingState\n} from '@qti-components/delivery';\nimport type { ItemOptimality } from '../../internal/derive-computed-context';\nimport type { ItemFactsByRef } from '../../internal/item-facts.context';\nimport type { LinearNextRefusal, TestHost } from '../../internal/test-host.context';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\n/** A new object each time: a host that mutates the one it read must not change anyone else's. */\nconst newQtiContext = (): QtiContext => ({\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n});\n\n/** Whether any level of the test declares `qti-time-limits`: only then is time kept (impl. guide §4.3). */\nconst hasTimeLimits = (model: TestModel): boolean =>\n Boolean(model.timeLimits) ||\n model.testParts.some(\n part =>\n part.timeLimits ||\n sectionsInOrder(part.sections).some(section => section.timeLimits) ||\n itemRefsInOrder(part.sections).some(item => item.timeLimits)\n );\n\n/** How often the time left is updated; `config.timingSaveInterval` counts in these ticks. */\nconst TICK_MS = 1000;\n/** Every how many seconds the time spent is saved when `config.timingSaveInterval` is not set. */\nconst DEFAULT_SAVE_INTERVAL = 10;\n\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier: string | undefined = undefined;\n\n /**\n * Your own per-item fields, by item-ref `identifier`: each `computedContext` item carries them as\n * given under `data`, without the identifier, and so does every view of it a plugin derives. They\n * never replace a field the test, the item or the candidate's state gives, whatever its name; a\n * template reads `activeItem.data.<field>`. To mark an item as scored by hand, set\n * `external-scored` on its `SCORE` declaration in `postLoadTransformCallback`.\n */\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n /**\n * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the\n * enclosing test's: reading returns it, writing replaces it, so a host that has always set the\n * shuffle seed here keeps working. Removed in the next major.\n *\n * Written before the navigation is inside a test, it waits and is handed over on connect.\n */\n public get qtiContext(): QtiContext {\n return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());\n }\n\n public set qtiContext(value: QtiContext) {\n if (!this.#warnedQtiContext) {\n this.#warnedQtiContext = true;\n console.warn(\n '[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major ' +\n 'release. Set `qtiContext` on `<qti-test>` instead; it is the same value.'\n );\n }\n this.#writeQtiContext(value);\n }\n\n #pendingQtiContext?: QtiContext;\n #warnedQtiContext = false;\n\n /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */\n #writeQtiContext(value: QtiContext): void {\n const owner = this.#owner();\n if (owner) owner.qtiContext = value;\n else this.#pendingQtiContext = value;\n }\n\n /**\n * The `qti-test` this navigation is in, found through context so it works across shadow roots.\n * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.\n */\n #testHost = new ContextConsumer(this, {\n context: testHostContext,\n subscribe: true,\n callback: host => {\n if (host && this.#pendingQtiContext) {\n host.qtiContext = this.#pendingQtiContext;\n this.#pendingQtiContext = undefined;\n }\n if (host) this.#registerLinearNext(host);\n }\n });\n\n /** The `qti-test` this navigation answers Next for in a linear part. */\n #linearNextHost?: TestHost;\n\n #registerLinearNext(host: TestHost): void {\n if (this.#linearNextHost && this.#linearNextHost !== host) {\n this.#linearNextHost.beforeLinearNext = null;\n this.#linearNextHost.submitTestParts = null;\n }\n this.#linearNextHost = host;\n host.beforeLinearNext = this.#beforeLinearNext;\n host.submitTestParts = this.#submitTestParts;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.#linearNextHost) {\n this.#linearNextHost.beforeLinearNext = this.#beforeLinearNext;\n this.#linearNextHost.submitTestParts = this.#submitTestParts;\n }\n if (this.#model && hasTimeLimits(this.#model)) this.#startTicking();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.#linearNextHost?.beforeLinearNext === this.#beforeLinearNext) this.#linearNextHost.beforeLinearNext = null;\n if (this.#linearNextHost?.submitTestParts === this.#submitTestParts) this.#linearNextHost.submitTestParts = null;\n this.#stopTicking();\n }\n\n /**\n * While a time limit is in force: the time left is updated every second, and the time spent is\n * saved (`qc-test-state-changed`) every `config.timingSaveInterval` seconds (10 by default; 0:\n * never on the tick) and when the page is hidden. With `config.pauseWhenHidden` the time stops\n * while the page is hidden. The tick only checks and\n * repaints: the time itself is read from the clock (roadmap 1 T5), so a tick the browser delays\n * in a background tab loses nothing; the check runs again as soon as the page is visible.\n */\n #ticker: ReturnType<typeof setInterval> | null = null;\n #ticks = 0;\n\n #startTicking(): void {\n if (this.#ticker !== null) return;\n this.#ticks = 0;\n this.#ticker = setInterval(this.#tick, TICK_MS);\n addEventListener('pagehide', this.#save);\n document.addEventListener('visibilitychange', this.#onVisibilityChange);\n }\n\n #stopTicking(): void {\n if (this.#ticker === null) return;\n clearInterval(this.#ticker);\n this.#ticker = null;\n removeEventListener('pagehide', this.#save);\n document.removeEventListener('visibilitychange', this.#onVisibilityChange);\n }\n\n #tick = (): void => {\n this.requestUpdate();\n const every = this.configContext?.timingSaveInterval ?? DEFAULT_SAVE_INTERVAL;\n if (every > 0 && ++this.#ticks >= every) {\n this.#ticks = 0;\n this.#save();\n }\n };\n\n #save = (): void => this.#testHost.value?.saveTiming();\n\n #onVisibilityChange = (): void => {\n if (document.visibilityState === 'hidden') {\n // Stop the stopwatches now, not at the next render, which a hidden page may never get.\n if (this.configContext?.pauseWhenHidden) this.#followTiming();\n this.#save();\n } else this.requestUpdate();\n };\n\n /** The candidate session runs: always while the page is open, unless hidden with `pauseWhenHidden`. */\n #running(): boolean {\n return !(this.configContext?.pauseWhenHidden && document.visibilityState === 'hidden');\n }\n\n /** The `submission-mode` of the test part that holds the item-ref; undefined before the model is known. */\n #submissionModeOf(itemRefId: string | undefined): 'individual' | 'simultaneous' | undefined {\n if (!itemRefId) return undefined;\n return this.#model?.testParts.find(testPart =>\n itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId)\n )?.submissionMode;\n }\n\n /**\n * Submits every test part with simultaneous submission that is not submitted yet, as a paper exam\n * is handed in (QTI 3 info model §2.8.2; decided 2026-12-01, `plans/host-api.md`): each item the\n * candidate opened gets its one attempt (`numAttempts` 1) and, when it is not adaptive,\n * `completionStatus` `completed`; every session closes (`submitTestPart`). The responses were\n * scored in the background as they changed, so nothing is processed again here. The caller runs\n * the test's outcome processing after it (`submit()`). Sends `qc-test-part-submitted` per part.\n */\n #submitTestParts = (): void => {\n const host = this.#testHost.value;\n if (!this.#model || !host) return;\n const facts = this.#sessionFacts();\n for (const testPart of this.#model.testParts) {\n if (testPart.submissionMode !== 'simultaneous') continue;\n const items = itemRefsInOrder(testPart.sections).flatMap(({ identifier }) => {\n const itemFacts = facts.get(identifier);\n return itemFacts\n ? [{ item: identifier, previous: this.#sessions.get(identifier) ?? null, facts: itemFacts }]\n : [];\n });\n const submission = submitTestPart(items);\n if (!submission) continue;\n const submitted: string[] = [];\n for (const { item, session } of submission.sessions) {\n const before = facts.get(item)!;\n this.#sessions.set(item, session);\n if (session.numAttempts === before.numAttempts) continue;\n submitted.push(item);\n host.updateItemVariables(item, [\n { identifier: 'numAttempts', value: String(session.numAttempts) },\n ...(session.adaptive ? [] : [{ identifier: 'completionStatus', value: 'completed' }])\n ]);\n }\n if (submitted.length === 0) continue;\n dispatchPublic(host, 'qc-test-part-submitted', { testPart: testPart.identifier, items: submitted });\n }\n this.requestUpdate();\n };\n\n /**\n * Next in a linear individual part leaves the item for good (implementation guide §4.1), so it\n * submits what the candidate gave (decided 2026-11-27): refused while the session control refuses\n * those responses (`rules.maySubmit`), else the attempt is ended when one is open: none ended yet,\n * or the responses changed since the last. Called by the navigation mixin while the item is still\n * rendered; the item is closed when the navigation moves past it.\n */\n #beforeLinearNext = (itemRefId: string): LinearNextRefusal | null => {\n const part = this.#model?.testParts.find(testPart =>\n itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId)\n );\n if (part?.navigationMode !== 'linear' || part.submissionMode !== 'individual') return null;\n const session = this.#sessions.get(itemRefId);\n const rules = this.computedItemFor(itemRefId)?.rules;\n if (session?.state !== 'interacting' || !rules) return null;\n if (!rules.maySubmit) {\n return { reason: rules.maySkip ? 'validate-responses' : 'allow-skipping', itemId: itemRefId };\n }\n if (session.numAttempts === 0 || this.#changed.has(itemRefId)) {\n this.#assessmentItemFor(itemRefId)?.processResponse(\n true,\n this.configContext?.reportValidityAfterScoring === true\n );\n }\n return null;\n };\n\n /** The item-refs whose responses changed since their last ended attempt. */\n #changed = new Set<string>();\n\n #itemRefIdOf(element: EventTarget | undefined): string | undefined {\n const item = (element as HTMLElement | undefined)?.closest?.('qti-assessment-item');\n if (!item) return undefined;\n return [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])].find(\n itemRef => itemRef.assessmentItem === item\n )?.identifier;\n }\n\n #owner(): { qtiContext: QtiContext } | null {\n return this.#testHost.value ?? null;\n }\n\n @state()\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n /** Read from each item's XML when `qti-test` fetches it; see `itemFactsContext`. */\n @state()\n @consume({ context: itemFactsContext, subscribe: true })\n protected _itemFacts?: ItemFactsByRef;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n #testElement: QtiAssessmentTest;\n\n /**\n * Whether each item's last *ended attempt* reached the optimal outcome, keyed\n * by item-ref id. Written from #handleItemContextUpdated when processResponse\n * ends an attempt — never on a plain selection. Mirrors how inline feedback\n * only re-evaluates when an attempt is processed, so a freshly-picked answer\n * doesn't flip `done` until the candidate ends the attempt.\n */\n #optimality = new Map<string, ItemOptimality>();\n\n /**\n * Each item session's lifecycle state, by item-ref identifier, changed only through the lifecycle\n * table (`followItemSession` as the candidate moves, `endItemAttempt` when an attempt ends). It\n * lives here until `DeliveryState` holds it (roadmap 1, T3d); a session whose attempts change\n * outside an ended attempt (a restored or assigned state) is seeded again.\n */\n #sessions = new Map<string, ItemSession>();\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));\n\n listenItemPublic(this, 'qc-item-response-changed', this.#handleInteractionChanged.bind(this));\n this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));\n\n listenPublic(this, 'qc-test-end-attempt', this.#handleTestEndAttempt.bind(this));\n listenPublic(this, 'qc-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));\n listenPublic(this, 'qc-test-update-comment', this.#handleUpdateComment.bind(this));\n }\n\n /**\n * Sets the candidate's comment on an item when its session allows it (`rules.mayComment`:\n * `allow-comment`, while interacting; decided 2026-11-27, carried, not rendered).\n */\n #handleUpdateComment(event: CustomEvent<{ itemId: string; comment: string | null }>) {\n const { itemId, comment = null } = event.detail ?? ({} as { itemId?: string; comment?: string | null });\n const host = this.#testHost.value;\n if (!itemId || !host) return;\n if (comment !== null && typeof comment !== 'string') {\n console.warn(`[qti-test] Ignoring a comment for \"${itemId}\" that is not a string.`);\n return;\n }\n if (!this.computedItemFor(itemId)?.rules?.mayComment) {\n console.warn(\n `[qti-test] Ignoring a comment for \"${itemId}\": its allow-comment is false, or it is not interacting.`\n );\n return;\n }\n host.updateItemComment(itemId, comment);\n }\n\n /**\n * Latch whether an item reached its optimal outcome whenever it has just ended\n * an attempt. processResponse — fired by test-end-attempt, autoscore, or an\n * in-item end-attempt interaction — flags its context update with\n * `responseProcessed`; a plain selection updates the context without it, so\n * `done` can't flip until the candidate actually ends the attempt.\n */\n #handleItemContextUpdated(event: CustomEvent<{ itemContext: ItemContext; responseProcessed?: boolean }>) {\n if (!event.detail?.responseProcessed) return;\n const itemContext = event.detail.itemContext;\n if (!itemContext?.identifier) return;\n this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n this.#changed.delete(itemContext.identifier);\n this.#endAttempt(itemContext);\n\n const computedItem = this.computedItemFor(itemContext.identifier);\n this.afterAttemptEnded(\n (event.composedPath()[0] as HTMLElement)?.closest<QtiAssessmentItem>('qti-assessment-item'),\n computedItem,\n this.#doneAfterAttempt(itemContext, computedItem)\n );\n }\n\n /**\n * Moves the item's session on for its ended attempt. With `auto-score-items` every change is\n * scored as an attempt, so the count is not the candidate's: it is taken, and the state stays.\n */\n #endAttempt(itemContext: ItemContext): void {\n const facts = this.#sessionFacts().get(itemContext.identifier);\n if (!facts) return;\n const ended: ItemSessionFacts = { ...facts, ...attemptsOf(itemContext) };\n const previous = this.#sessions.get(itemContext.identifier);\n this.#sessions.set(\n itemContext.identifier,\n this.autoScoreItems\n ? {\n state: previous?.state ?? followItemSession(undefined, ended).state,\n numAttempts: ended.numAttempts,\n adaptive: ended.adaptive\n }\n : endItemAttempt(previous, ended)\n );\n }\n\n /**\n * Whether the item session is over after the attempt that just ended: its new state, or, before\n * the test model is known, the state an item on screen with these attempts is in.\n */\n #doneAfterAttempt(itemContext: ItemContext, computedItem: ComputedItem | undefined): boolean {\n const state =\n this.#sessions.get(itemContext.identifier)?.state ??\n (computedItem?.sessionControl\n ? seedItemLifecycle({\n sessionControl: computedItem.sessionControl,\n adaptive: computedItem.adaptive ?? false,\n ...attemptsOf(itemContext),\n presented: true,\n passed: false\n })\n : 'interacting');\n return state === 'closed' || state === 'review' || state === 'solution';\n }\n\n /** The facts of every item session now: the model, the item facts, the contexts and the items on screen. */\n #sessionFacts(): Map<string, ItemSessionFacts> {\n if (!this.#model) return new Map();\n const presented = new Set(\n [...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])]\n .filter(itemRef => itemRef.assessmentItem)\n .map(itemRef => itemRef.identifier)\n );\n return itemSessionFacts(this.#model, this.#itemFacts(), this._testContext?.items, {\n current: this._sessionContext?.navItemRefId,\n presented,\n timeUp: this.#timedUp\n });\n }\n\n /**\n * The item facts `qti-test` read from each fetched item, and, for an item rendered without them\n * (handed to its ref directly), the facts read from the rendered item.\n */\n #itemFacts(): ItemFactsByRef | undefined {\n const missing = [\n ...(this.#testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref') ?? [])\n ].filter(\n itemRef =>\n itemRef.assessmentItem?.localName === 'qti-assessment-item' && !this._itemFacts?.has(itemRef.identifier)\n );\n if (!missing.length) return this._itemFacts;\n const facts = new Map(this._itemFacts ?? []);\n for (const itemRef of missing) facts.set(itemRef.identifier, readItemFacts(renderedMarkup(itemRef.assessmentItem)));\n return facts;\n }\n\n /** Moves every item session on for where the candidate is now. */\n #followSessions(): void {\n for (const [identifier, facts] of this.#sessionFacts()) {\n this.#sessions.set(identifier, followItemSession(this.#sessions.get(identifier), facts));\n }\n }\n\n /**\n * Extension point for presentation packages reacting to an ended attempt. `done` is the item\n * session's after this attempt (closed: its attempts used, whatever the score), settled here\n * because the computed context only catches up on the next update.\n */\n protected afterAttemptEnded(\n _assessmentItem: QtiAssessmentItem | undefined,\n _computedItem: ComputedItem | undefined,\n _done: boolean\n ): void {}\n\n /** The computed-context entry for an item, from the session-control cascade. */\n protected computedItemFor(identifier: string): ComputedItem | undefined {\n return this.computedContext?.testParts.flatMap(itemsInOrder).find(i => i.instance === identifier);\n }\n\n /** The assessment item for an item-ref id, if it has been rendered. */\n #assessmentItemFor(identifier: string | undefined): QtiAssessmentItem | undefined {\n if (!identifier) return undefined;\n const itemRef = this.#testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(identifier)}\"]`\n );\n return itemRef?.assessmentItem ?? undefined;\n }\n\n /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */\n #itemElement = (identifier: string): HTMLElement | null => this.#assessmentItemFor(identifier) ?? null;\n\n /** The currently active assessment item, exposed for optional presentation extensions. */\n protected get activeAssessmentItem(): QtiAssessmentItem | undefined {\n if (!this.#testElement || !this._sessionContext?.navItemRefId) return undefined;\n return this.#testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n )?.assessmentItem;\n }\n\n /**\n * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or\n * given an `item`), or else the item on screen.\n */\n #handleTestEndAttempt(event: CustomEvent<{ itemId?: string } | undefined>) {\n const itemId = event.detail?.itemId;\n const itemRefId = itemId ?? this._sessionContext?.navItemRefId ?? undefined;\n if (itemRefId && this.#timedUp.has(itemRefId)) {\n // Its time is up: a response given now is not accepted (QTI 3 info model §7.40).\n console.warn(`qc-test-end-attempt refused: the time of ${itemRefId} is up.`);\n return;\n }\n const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;\n if (!qtiAssessmentItemEl) return;\n if (this.#submissionModeOf(itemRefId) === 'simultaneous') {\n console.warn(\n `[qti-test] Ignoring an end attempt for \"${itemRefId}\": its test part has simultaneous submission, so its attempt ends when the part is submitted.`\n );\n return;\n }\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n #handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);\n if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n #handleInteractionChanged(_event: CustomEvent) {\n const itemRefId = this.#itemRefIdOf(_event.composedPath()[0]);\n if (itemRefId) this.#changed.add(itemRefId);\n // A part with simultaneous submission is a paper exam (decided 2026-12-01): every change is\n // scored in the background, without ending the attempt, so a saved state always holds the\n // scores. `auto-score-items` adds nothing there. An item whose `SCORE` is `external-scored` is\n // left alone, as `auto-score-items` left it: a run would reset the score a scorer gave.\n if (this.#submissionModeOf(itemRefId) === 'simultaneous') {\n const computedItem = this.computedItemFor(itemRefId!);\n if (computedItem?.rules?.done || computedItem?.externalScored) return;\n this.#assessmentItemFor(itemRefId)?.scoreResponse();\n return;\n }\n // Its time is up: a change is not scored (QTI 3 info model §7.40).\n if (this.autoScoreItems && !(itemRefId && this.#timedUp.has(itemRefId))) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest<QtiAssessmentItem>(\n 'qti-assessment-item'\n );\n // Autoscoring resolves the item from the event's own path, so a change\n // raised outside an assessment item has nothing to score.\n if (!assessmentItem) return;\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n #handleTestConnected(event: CustomEvent) {\n this.#testElement = event.detail as QtiAssessmentTest;\n // A fresh test invalidates the per-test optimality latches and item sessions.\n this.#optimality.clear();\n this.#sessions.clear();\n this.#changed.clear();\n this.#timedUp.clear();\n this.#timeUpsSent.clear();\n this.#pendingTimeUp = null;\n // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this.#testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n });\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this.#extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n });\n }\n });\n\n // The structure and the session-control cascade come from the test's markup, not from upgraded\n // properties, so they do not depend on registration or render timing.\n this.#model = buildTestModel(renderedMarkup(this.#testElement));\n this.#stopTicking();\n const host = this.#testHost.value;\n if (hasTimeLimits(this.#model)) {\n // A restored state brought its timing; a first start begins with none spent.\n if (host && !host.timing) host.updateTiming(emptyTiming());\n this.#startTicking();\n } else {\n host?.updateTiming(null);\n }\n this.computedContext = this.#derive();\n }\n\n /** The test's structure and resolved session control, read from its markup when it is connected. */\n #model?: TestModel;\n\n /** `computedContext`, derived anew from its inputs (`deriveComputedContext`), never from the previous one. */\n #derive(): ComputedContext {\n this.#seedOptimality();\n this.#followSessions();\n const timeLimits = this.#followTiming();\n return deriveComputedContext({\n model: this.#model,\n itemFacts: this.#itemFacts(),\n testContext: this._testContext,\n sessionContext: this._sessionContext,\n infoItemCategory: this.configContext?.infoItemCategory,\n itemData: this.initContext,\n optimality: this.#optimality,\n lifecycle: new Map([...this.#sessions].map(([identifier, session]) => [identifier, session.state])),\n itemElement: this.#itemElement,\n timeLimits\n });\n }\n\n /**\n * The test's timing after following the candidate, at the clock's time now: the test, the\n * current item's part and sections run, and each item's duration while it is interacting\n * (`followTiming`). Written back to the test for its state when a stopwatch started or stopped.\n * Returns the time limits against it (`timeLimitRules`), or nothing for a test without limits.\n */\n #followTiming(): TimeLimitAnswers | undefined {\n const host = this.#testHost.value;\n const model = this.#model;\n if (!host?.timing || !model) return undefined;\n const now = host.clock.now();\n const order = model.testParts.flatMap(part => itemRefsInOrder(part.sections).map(item => item.identifier));\n const record: TimingState = {\n current: this._sessionContext?.navItemRefId ?? null,\n timing: { test: host.timing.test, testParts: host.timing.testParts, sections: host.timing.sections },\n items: Object.fromEntries(\n order.map(id => [\n id,\n {\n // The model names a with-replacement clone by its instance, so the instance is its item-ref here.\n itemRefIdentifier: id,\n lifecycle: this.#sessions.get(id)?.state ?? 'initial',\n duration: host.timing!.items[id] ?? { spent: 0, since: null }\n }\n ])\n )\n };\n const followed = followTiming(record, model, { now, running: this.#running() });\n const timing = qtiTestTiming(followed);\n if (JSON.stringify(timing) !== JSON.stringify(host.timing)) host.updateTiming(timing);\n const answers = timeLimitRules(model, { ...followed, order }, now);\n this.#noteTimeUp(closedByTimeUp(model, { order, items: followed.items }, answers), timeUps(model, answers));\n return answers;\n }\n\n /** The item-refs whose time is up: their sessions are closed (`ItemSessionFacts.timeUp`) and never open again. */\n #timedUp = new Set<string>();\n /** The levels `qc-test-time-up` was sent for while this page lives, as `scope:identifier`. */\n #timeUpsSent = new Set<string>();\n /** A time-up found by the last derive, acted on once the update is through (`#applyTimeUp`). */\n #pendingTimeUp: { closed: string[]; timeUps: TimeUp[] } | null = null;\n\n #noteTimeUp(closed: string[], ups: TimeUp[]): void {\n const newlyClosed = closed.filter(id => !this.#timedUp.has(id));\n const unsent = ups.filter(up => !this.#timeUpsSent.has(`${up.scope}:${up.identifier}`));\n if (newlyClosed.length || unsent.length) this.#pendingTimeUp = { closed: newlyClosed, timeUps: unsent };\n }\n\n /**\n * Ends what a time-up ends (QTI 3 info model §7.40, §2.2.2.2 \"running out of time\"), after the update\n * that found it: the attempt of an item on screen in an individual part is scored as it stands (as\n * Next does in a linear part: when none was scored yet or the responses changed since), then every\n * session under the level closes (the next derive follows `#timedUp`), and `qc-test-time-up` is sent\n * once per level. A stored state whose time was up scores nothing again: its attempt was counted.\n */\n #applyTimeUp(): void {\n const pending = this.#pendingTimeUp;\n if (!pending) return;\n this.#pendingTimeUp = null;\n const toScore = pending.closed.filter(id => this.#scoresAtTimeUp(id));\n for (const id of pending.closed) this.#timedUp.add(id);\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true;\n for (const id of toScore) this.#assessmentItemFor(id)?.processResponse(true, reportValidityAfterScoring);\n for (const up of pending.timeUps) {\n this.#timeUpsSent.add(`${up.scope}:${up.identifier}`);\n dispatchPublic(this, 'qc-test-time-up', up);\n }\n if (pending.closed.length) this.requestUpdate();\n }\n\n /** Whether the attempt of an item whose time ran out is scored: on screen, interacting, in an individual part, not scored as it stands. */\n #scoresAtTimeUp(itemRefId: string): boolean {\n const part = this.#model?.testParts.find(testPart =>\n itemRefsInOrder(testPart.sections).some(item => item.identifier === itemRefId)\n );\n const session = this.#sessions.get(itemRefId);\n return (\n part?.submissionMode === 'individual' &&\n session?.state === 'interacting' &&\n Boolean(this.#assessmentItemFor(itemRefId)) &&\n (session.numAttempts === 0 || this.#changed.has(itemRefId))\n );\n }\n\n /**\n * On a restored session no attempt is ended this run, so the latch is seeded once from the\n * persisted context, which still holds the submitted response. A later change of the answer\n * leaves the seeded value alone.\n */\n #seedOptimality(): void {\n for (const itemContext of this._testContext?.items ?? []) {\n if (!itemContext.identifier || this.#optimality.has(itemContext.identifier)) continue;\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n if (numAttempts > 0) this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n }\n }\n\n /**\n * Extract default values from a qti-context-declaration element\n */\n #extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\n }\n\n /* On every change of the candidate's state, the context is derived again. */\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.#model) return;\n this.computedContext = this.#derive();\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n this.#applyTimeUp();\n this.#lockUsedItems();\n this.#scoreOnFirstPresentation();\n }\n\n /** The rendered items already scored on arrival, so each is scored once per rendering. */\n #scoredOnArrival = new WeakSet<QtiAssessmentItem>();\n\n /**\n * In a part with simultaneous submission, scores every item once in the background when it is\n * first shown (decided 2026-12-03). An item the candidate opens and leaves blank gets the outcomes\n * its response processing gives no answer, as it would on paper, not only their defaults; a\n * restored item is scored again from its restored responses, which gives the same scores. Skipped,\n * like every background score, for a closed item and one whose `SCORE` is `external-scored`.\n */\n #scoreOnFirstPresentation(): void {\n if (!this.#testElement || !this.computedContext) return;\n for (const itemRef of this.#testElement.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')) {\n const element = itemRef.assessmentItem;\n if (!element || this.#scoredOnArrival.has(element)) continue;\n if (this.#submissionModeOf(itemRef.identifier) !== 'simultaneous') continue;\n const computedItem = this.computedItemFor(itemRef.identifier);\n if (!computedItem || computedItem.rules?.done || computedItem.externalScored) continue;\n if (element.scoreResponse()) this.#scoredOnArrival.add(element);\n }\n }\n\n /** The items this navigation disabled because their attempts are used, so it releases only those. */\n #lockedItems = new WeakSet<QtiAssessmentItem>();\n\n /**\n * Disables every rendered item whose session is over (`rules.done`: closed, its attempts used or\n * a completed adaptive item), so the candidate cannot change the answer once the last attempt is\n * ended (QTI info model §2.2.1). Runs after every update: an item rendered later (another item, a\n * section on screen, a restored state) is locked as it arrives, and one whose attempts are back to\n * zero (a new state) is released. In a part with simultaneous submission every session closes\n * when the part is submitted, so its items lock then.\n *\n * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a\n * host or view that disables or makes an item read-only itself keeps it so.\n */\n #lockUsedItems(): void {\n if (!this.#testElement || !this.computedContext) return;\n const items = new Map(\n this.computedContext.testParts.flatMap(part =>\n itemsInOrder(part).map(\n item => [item.instance, { item, simultaneous: part.submissionMode === 'simultaneous' }] as const\n )\n )\n );\n for (const itemRef of this.#testElement.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')) {\n const element = itemRef.assessmentItem;\n if (!element) continue;\n const entry = items.get(itemRef.identifier);\n // A simultaneous part ends attempts only when it is submitted, so its end-attempt\n // interactions are off (decided 2026-12-01).\n if (entry?.simultaneous) this.#disableEndAttemptInteractions(element);\n // The session is over (closed, or in review or solution). With `auto-score-items` every change\n // is scored as an attempt, so the count is not the candidate's and locks nothing; in a\n // simultaneous part it is built in and never counts, so the session decides. A session whose\n // time is up is over in any part, also a simultaneous one (QTI 3 info model §7.40).\n const used =\n this.#timedUp.has(itemRef.identifier) ||\n ((entry?.simultaneous || !this.autoScoreItems) && entry?.item.rules?.done === true);\n if (used && !element.disabled) {\n element.disabled = true;\n this.#lockedItems.add(element);\n } else if (!used && this.#lockedItems.has(element)) {\n this.#lockedItems.delete(element);\n element.disabled = false;\n }\n }\n }\n\n #disableEndAttemptInteractions(element: QtiAssessmentItem): void {\n for (const interaction of element.querySelectorAll<HTMLElement & { disabled: boolean }>(\n 'qti-end-attempt-interaction'\n )) {\n if (!interaction.disabled) interaction.disabled = true;\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-navigation': TestNavigation;\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComputedContext, ItemContext } from '@qti-components/base';
|
|
2
2
|
import type { SessionContext, TestContext } from '@qti-components/base';
|
|
3
|
-
import type { ItemLifecycleState, TestModel } from '@qti-components/delivery';
|
|
3
|
+
import type { ItemLifecycleState, TestModel, TimeLimitAnswers } from '@qti-components/delivery';
|
|
4
4
|
import type { ItemFactsByRef } from './item-facts.context';
|
|
5
5
|
/**
|
|
6
6
|
* Whether an item's ended attempt reached the best achievable outcome:
|
|
@@ -41,6 +41,11 @@ export interface ComputedContextInputs {
|
|
|
41
41
|
readonly lifecycle?: ReadonlyMap<string, ItemLifecycleState>;
|
|
42
42
|
/** `computedContext.itemElement`, passed through. */
|
|
43
43
|
readonly itemElement?: ComputedContext['itemElement'];
|
|
44
|
+
/**
|
|
45
|
+
* The time limits against the time spent at this update (`timeLimitRules`), kept by
|
|
46
|
+
* `test-navigation`; each level that declares `qti-time-limits` gets its answer as `time`.
|
|
47
|
+
*/
|
|
48
|
+
readonly timeLimits?: TimeLimitAnswers;
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
* `computedContext`, derived from its inputs alone: built anew on every call, never from the previous
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { itemRefsInOrder, itemRules, parseItemInstanceId, seedItemLifecycle } from '@qti-components/delivery';
|
|
2
|
+
/** `{ time }` when the level has an answer, else nothing, so a level without limits has no key. */
|
|
3
|
+
const timeOf = (answer) => answer ? { time: { ...answer } } : {};
|
|
2
4
|
/**
|
|
3
5
|
* `computedContext`, derived from its inputs alone: built anew on every call, never from the previous
|
|
4
6
|
* context, and never changing an input. The same inputs give an equal context.
|
|
@@ -22,6 +24,7 @@ export function deriveComputedContext(inputs) {
|
|
|
22
24
|
active: sessionContext?.navSectionId === section.identifier,
|
|
23
25
|
// A section that only holds subsections is completed when theirs are.
|
|
24
26
|
completed: itemRefsInOrder(section.content).every(item => variableValue(itemContextFor(inputs, item.identifier), 'completionStatus') === 'completed'),
|
|
27
|
+
...timeOf(inputs.timeLimits?.sections[section.identifier]),
|
|
25
28
|
content: section.content.map(child => child.kind === 'section'
|
|
26
29
|
? deriveSection(testPart, child)
|
|
27
30
|
: deriveItem(inputs, testPart, child, itemIndexes.get(child.identifier) ?? null))
|
|
@@ -32,8 +35,10 @@ export function deriveComputedContext(inputs) {
|
|
|
32
35
|
title: model.title,
|
|
33
36
|
view: sessionContext?.view,
|
|
34
37
|
plugins: sessionContext?.plugins ?? {},
|
|
38
|
+
...timeOf(inputs.timeLimits?.test),
|
|
35
39
|
testParts: model.testParts.map(testPart => ({
|
|
36
40
|
active: sessionContext?.navPartId === testPart.identifier,
|
|
41
|
+
...timeOf(inputs.timeLimits?.testParts[testPart.identifier]),
|
|
37
42
|
identifier: testPart.identifier,
|
|
38
43
|
navigationMode: testPart.navigationMode,
|
|
39
44
|
submissionMode: testPart.submissionMode,
|
|
@@ -88,6 +93,7 @@ function deriveItem(inputs, testPart, item, index) {
|
|
|
88
93
|
...session,
|
|
89
94
|
// The session's: closed, or in review or solution. Never the score (roadmap 1, T3b2b).
|
|
90
95
|
done: session.rules.done,
|
|
96
|
+
...timeOf(inputs.timeLimits?.items[instance]),
|
|
91
97
|
data: hostData(inputs.itemData, instance)
|
|
92
98
|
};
|
|
93
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-computed-context.js","sourceRoot":"","sources":["../../src/internal/derive-computed-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA2D9G;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA6B;IACjE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,WAAW,GAAG,sBAAsB,CACxC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAC/D,MAAM,CAAC,gBAAgB,CACxB,CAAC;IACF,MAAM,aAAa,GAAG,CAAC,QAAuB,EAAE,OAAqB,EAAmB,EAAE,CAAC,CAAC;QAC1F,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM,EAAE,cAAc,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU;QAC3D,sEAAsE;QACtE,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAC/C,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC,KAAK,WAAW,CACnG;QACD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CACnC,KAAK,CAAC,IAAI,KAAK,SAAS;YACtB,CAAC,CAAC,aAAa,C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AQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;QACnE,OAAO,QAAQ,KAAK,MAAM,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;AAC7C,CAAC;AAED,8EAA8E;AAC9E,SAAS,eAAe,CAAC,SAAmC,EAAE,UAAkB;IAC9E,MAAM,GAAG,GAAG,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,EAAE,KAAK,CAAC;IACrE,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC","sourcesContent":["import { itemRefsInOrder, itemRules, parseItemInstanceId, seedItemLifecycle } from '@qti-components/delivery';\n\nimport type {\n ComputedContext,\n ComputedItem,\n ComputedSection,\n ItemContext,\n ResponseVariable\n} from '@qti-components/base';\nimport type { SessionContext, TestContext } from '@qti-components/base';\nimport type {\n ItemFacts,\n ItemLifecycleState,\n ItemRefModel,\n SectionModel,\n TestModel,\n TestPartModel\n} from '@qti-components/delivery';\nimport type { ItemFactsByRef } from './item-facts.context';\n\n/**\n * Whether an item's ended attempt reached the best achievable outcome:\n * 'optimal' (nothing to improve), 'suboptimal' (a better attempt is possible),\n * or 'unscored' (no machine-judgeable optimal value — see `assessOptimality`).\n */\nexport type ItemOptimality = 'optimal' | 'suboptimal' | 'unscored';\n\n/** Everything `computedContext` is derived from. Nothing here is the previous `computedContext`. */\nexport interface ComputedContextInputs {\n /** The test's structure and resolved session control, from its XML (`buildTestModel`). */\n readonly model: TestModel;\n /** The facts of every item fetched so far, by item instance (the rendered item-ref identifier). */\n readonly itemFacts?: ItemFactsByRef;\n /** The candidate's responses and outcomes, per item. */\n readonly testContext?: Readonly<TestContext>;\n /** Where the candidate is, the view and the plugin state. */\n readonly sessionContext?: Readonly<SessionContext>;\n /** `config.infoItemCategory`: items with it are not numbered. */\n readonly infoItemCategory?: string;\n /**\n * The host's per-item fields (`initContext`), matched on the item instance: each item gets them\n * under `data`, never at its top level.\n */\n readonly itemData?: readonly { identifier: string; [key: string]: unknown }[];\n /**\n * The optimality of each item's last ended attempt, by item instance (see `ItemOptimality`).\n * Kept by `test-navigation`, since it is not in the contexts: it is written when an attempt ends,\n * never on a plain change of the answer.\n */\n readonly optimality: ReadonlyMap<string, ItemOptimality>;\n /**\n * The lifecycle state of each item session, by item instance, kept by `test-navigation`\n * (`followItemSession`, `endItemAttempt`). An item it does not list is seeded from its attempts.\n */\n readonly lifecycle?: ReadonlyMap<string, ItemLifecycleState>;\n /** `computedContext.itemElement`, passed through. */\n readonly itemElement?: ComputedContext['itemElement'];\n}\n\n/**\n * `computedContext`, derived from its inputs alone: built anew on every call, never from the previous\n * context, and never changing an input. The same inputs give an equal context.\n *\n * The tree of the test (roadmap 1, T2d): test parts, sections nested as the test nests them, each\n * section's item-refs and subsections in document order. In the model a `with-replacement` clone is\n * an item-ref of its own whose identifier is its instance (`item-3#2`); here it keeps that as\n * `instance`, under the identifier of the item-ref it copies.\n *\n * Roadmap 1, T2c. `DeliveryState` is not live at runtime yet, so the candidate's state comes from\n * `testContext` and `sessionContext`; T3 and T8 move it into `DeliveryState`, and add their fields here.\n */\nexport function deriveComputedContext(inputs: ComputedContextInputs): ComputedContext {\n const { model, sessionContext, itemElement } = inputs;\n const itemIndexes = indexesInDocumentOrder(\n model.testParts.flatMap(part => itemRefsInOrder(part.sections)),\n inputs.infoItemCategory\n );\n const deriveSection = (testPart: TestPartModel, section: SectionModel): ComputedSection => ({\n kind: 'section',\n identifier: section.identifier,\n title: section.title,\n visible: section.visible,\n active: sessionContext?.navSectionId === section.identifier,\n // A section that only holds subsections is completed when theirs are.\n completed: itemRefsInOrder(section.content).every(\n item => variableValue(itemContextFor(inputs, item.identifier), 'completionStatus') === 'completed'\n ),\n content: section.content.map(child =>\n child.kind === 'section'\n ? deriveSection(testPart, child)\n : deriveItem(inputs, testPart, child, itemIndexes.get(child.identifier) ?? null)\n )\n });\n return {\n itemElement,\n identifier: model.identifier,\n title: model.title,\n view: sessionContext?.view,\n plugins: sessionContext?.plugins ?? {},\n testParts: model.testParts.map(testPart => ({\n active: sessionContext?.navPartId === testPart.identifier,\n identifier: testPart.identifier,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n sections: testPart.sections.map(section => deriveSection(testPart, section))\n }))\n };\n}\n\nfunction deriveItem(\n inputs: ComputedContextInputs,\n testPart: TestPartModel,\n item: ItemRefModel,\n index: number | null\n): ComputedItem {\n // The model names an item-ref by its instance: a clone's identifier there is `item-3#2`.\n const instance = item.identifier;\n const itemContext = itemContextFor(inputs, instance);\n // Only the fields an item context holds: a host that restores `testContext` with fields of its\n // own sets nothing here. Its fields for an item belong in `itemData`, which lands under `data`.\n const computedItem = {\n kind: 'item' as const,\n instance,\n active: false,\n ...factsFor(inputs.itemFacts, instance),\n identifier: parseItemInstanceId(instance).itemRefIdentifier,\n categories: [...item.categories],\n href: item.href,\n sessionControl: { ...item.sessionControl },\n variables: itemContext?.variables ?? [],\n ...(itemContext?.state === undefined ? {} : { state: itemContext.state }),\n ...(itemContext?.comment === undefined ? {} : { comment: itemContext.comment }),\n ...(itemContext?.readonly === undefined ? {} : { readonly: itemContext.readonly }),\n ...(itemContext?.disabled === undefined ? {} : { disabled: itemContext.disabled })\n } as Omit<ComputedItem, 'index' | 'data'>;\n\n const rawScore = variableValue(computedItem, 'SCORE');\n const score = rawScore === undefined || rawScore === null ? null : parseFloat(rawScore.toString());\n const rawMaxScore = variableValue(computedItem, 'MAXSCORE');\n const maxScore = rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(rawMaxScore.toString());\n const completionStatus = variableValue(computedItem, 'completionStatus') as string;\n const response = variableValue(computedItem, 'RESPONSE') || '';\n const numAttempts = Number(variableValue(computedItem, 'numAttempts')) || 0;\n\n const latched = inputs.optimality.get(instance);\n const session = lifecycleOf(inputs, testPart, item, itemContext, { numAttempts, completionStatus });\n\n return {\n ...computedItem,\n completionStatus,\n numAttempts,\n score,\n response,\n index,\n active: inputs.sessionContext?.navItemRefId === instance,\n // Published by the item. One that is not on screen has nothing to be invalid.\n valid: itemContext?.valid ?? true,\n isDefaultResponse: isDefaultResponse(itemContext),\n maxScore,\n // Information only, from the last *ended* attempt (the latch); it decides nothing.\n optimal: latched === 'optimal',\n ...session,\n // The session's: closed, or in review or solution. Never the score (roadmap 1, T3b2b).\n done: session.rules.done,\n data: hostData(inputs.itemData, instance)\n } as ComputedItem;\n}\n\n/** The item session's lifecycle state and what it may do now (`itemRules`), computed: host data never sets it. */\nfunction lifecycleOf(\n inputs: ComputedContextInputs,\n testPart: TestPartModel,\n item: ItemRefModel,\n itemContext: ItemContext | undefined,\n { numAttempts, completionStatus }: { numAttempts: number; completionStatus: string | undefined }\n): Pick<ComputedItem, 'lifecycle' | 'rules'> {\n const session = {\n sessionControl: item.sessionControl,\n adaptive: inputs.itemFacts?.get(item.identifier)?.adaptive ?? false,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n numAttempts,\n completionStatus: completionStatus ?? null\n };\n const lifecycle =\n inputs.lifecycle?.get(item.identifier) ??\n seedItemLifecycle({\n ...session,\n presented: inputs.sessionContext?.navItemRefId === item.identifier,\n passed: false\n });\n const rules = itemRules({\n ...session,\n state: lifecycle,\n // Only resuming reads it, and no answer asks about resuming.\n left: false,\n modalFeedback: false,\n skipped: isSkipped(itemContext),\n valid: itemContext?.valid ?? true\n });\n return { lifecycle, rules };\n}\n\n/** The host's fields for an item (`initContext`), without the identifier that matched them; `{}` when none. */\nfunction hostData(itemData: ComputedContextInputs['itemData'], identifier: string): ComputedItem['data'] {\n const entry = itemData?.find(data => data.identifier === identifier);\n if (!entry) return {};\n return Object.fromEntries(Object.entries(entry).filter(([key]) => key !== 'identifier'));\n}\n\nfunction itemContextFor(inputs: ComputedContextInputs, identifier: string): ItemContext | undefined {\n return inputs.testContext?.items?.find(item => item.identifier === identifier);\n}\n\nfunction variableValue(item: { variables?: ItemContext['variables'] } | undefined, identifier: string) {\n return item?.variables?.find(variable => variable.identifier === identifier)?.value;\n}\n\n/** An item's facts as `computedContext` carries them; nothing until the item is fetched. */\nfunction factsFor(\n itemFacts: ItemFactsByRef | undefined,\n identifier: string\n): Partial<Omit<ItemFacts, 'identifier'>> & { assessmentItemIdentifier?: string } {\n const facts = itemFacts?.get(identifier);\n if (!facts) return {};\n const { identifier: assessmentItemIdentifier, ...rest } = facts;\n return { ...rest, assessmentItemIdentifier };\n}\n\n/** Item numbers in document order, skipping info items; null for an info item. */\nfunction indexesInDocumentOrder(items: ItemRefModel[], infoItemCategory: string | undefined) {\n let index = 1;\n return new Map(\n items.map(item => [item.identifier, item.categories.includes(infoItemCategory) ? null : index++] as const)\n );\n}\n\n/**\n * No response given (QTI info model §7.19, `allow-skipping`): every response variable holds its\n * default or NULL. An item with no response variables \"by definition cannot be skipped\"; one not\n * fetched yet has given none.\n */\nfunction isSkipped(itemContext: ItemContext | undefined): boolean {\n if (!itemContext) return true;\n const responses = itemContext.variables?.filter(\n v => v.type === 'response' && v.identifier !== 'numAttempts' && v.identifier !== 'duration'\n );\n return Boolean(responses?.length) && isDefaultResponse(itemContext);\n}\n\n/** Every response still holds its default (or the base type's empty value): nothing answered. */\nfunction isDefaultResponse(itemContext: ItemContext | undefined): boolean {\n const responseVariables =\n itemContext?.variables?.filter(v => v.type === 'response' && v.identifier !== 'numAttempts') || [];\n return responseVariables.every(v => {\n if (v.value === undefined || v.value === null) return true;\n let fallbackValue: string;\n switch (v.baseType) {\n case 'integer':\n case 'float':\n case 'duration':\n fallbackValue = '0';\n break;\n case 'boolean':\n fallbackValue = 'false';\n break;\n default:\n fallbackValue = '';\n break;\n }\n const defaultValue = v.defaultValue ?? fallbackValue;\n if (Array.isArray(v.value)) {\n const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];\n return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);\n }\n return v.value === defaultValue;\n });\n}\n\n/**\n * Decide whether an item's submission is as good as it can get — i.e. the\n * candidate reached the *optimal* outcome, so there's no reason to make them\n * try again. 'optimal' means best achievable, 'suboptimal' means a better\n * attempt is still possible, 'unscored' means there's nothing to judge against.\n * (\"optimal\" is the spec's own word — a qti-correct-response is defined as\n * \"the (or an) optimal value\".)\n *\n * Two signals, in order of authority:\n * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).\n * This correctly handles partial-credit / qti-mapping items, where an exact\n * response match would under- or over-judge.\n * 2. The declared qti-correct-response, for items that aren't scored (no\n * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping\n * variables like numAttempts can be typed 'response' but never declare a\n * correctResponse, so we filter on a declared correctResponse.\n *\n * Items with neither a comparable score nor a correctResponse (essays, info\n * items, etc.) are 'unscored' — there's no optimal value to require, so one\n * attempt is enough.\n */\nexport function assessOptimality(item: ItemContext): ItemOptimality {\n const variables = item.variables ?? [];\n\n const score = numericVariable(variables, 'SCORE');\n const maxScore = numericVariable(variables, 'MAXSCORE');\n if (score !== null && maxScore !== null) {\n return score >= maxScore ? 'optimal' : 'suboptimal';\n }\n\n const responseVars = variables.filter(\n (v): v is ResponseVariable =>\n v.type === 'response' &&\n (v as ResponseVariable).correctResponse !== undefined &&\n (v as ResponseVariable).correctResponse !== null\n );\n if (responseVars.length === 0) return 'unscored';\n const allMatch = responseVars.every(v => {\n const expected = v.correctResponse;\n const actual = v.value;\n if (actual === undefined || actual === null) return false;\n if (Array.isArray(expected) && Array.isArray(actual)) {\n return expected.length === actual.length && expected.every(e => actual.includes(e));\n }\n if (Array.isArray(expected) || Array.isArray(actual)) return false;\n return expected === actual;\n });\n return allMatch ? 'optimal' : 'suboptimal';\n}\n\n/** Read a single numeric outcome value, or null when absent / non-numeric. */\nfunction numericVariable(variables: ItemContext['variables'], identifier: string): number | null {\n const raw = variables?.find(v => v.identifier === identifier)?.value;\n if (raw === undefined || raw === null || Array.isArray(raw)) return null;\n const parsed = parseFloat(raw.toString());\n return Number.isNaN(parsed) ? null : parsed;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"derive-computed-context.js","sourceRoot":"","sources":["../../src/internal/derive-computed-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAkE9G,mGAAmG;AACnG,MAAM,MAAM,GAAG,CAAC,MAAkC,EAA6B,EAAE,CAC/E,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA6B;IACjE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,WAAW,GAAG,sBAAsB,CACxC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAC/D,MAAM,CAAC,gBAAgB,CACxB,CAAC;IACF,MAAM,aAAa,GAAG,CAAC,QAAuB,EAAE,OAAqB,EAAmB,EAAE,CAAC,CAAC;QAC1F,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,OAAO,CAAC,UAAU;QA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AAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,EAAE,KAAK,CAAC;IACrE,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC","sourcesContent":["import { itemRefsInOrder, itemRules, parseItemInstanceId, seedItemLifecycle } from '@qti-components/delivery';\n\nimport type {\n ComputedContext,\n ComputedItem,\n ComputedSection,\n ItemContext,\n ResponseVariable\n} from '@qti-components/base';\nimport type { SessionContext, TestContext } from '@qti-components/base';\nimport type {\n ItemFacts,\n ItemLifecycleState,\n ItemRefModel,\n SectionModel,\n TestModel,\n TestPartModel,\n TimeLimitAnswers,\n TimeLimitState\n} from '@qti-components/delivery';\nimport type { ItemFactsByRef } from './item-facts.context';\n\n/**\n * Whether an item's ended attempt reached the best achievable outcome:\n * 'optimal' (nothing to improve), 'suboptimal' (a better attempt is possible),\n * or 'unscored' (no machine-judgeable optimal value — see `assessOptimality`).\n */\nexport type ItemOptimality = 'optimal' | 'suboptimal' | 'unscored';\n\n/** Everything `computedContext` is derived from. Nothing here is the previous `computedContext`. */\nexport interface ComputedContextInputs {\n /** The test's structure and resolved session control, from its XML (`buildTestModel`). */\n readonly model: TestModel;\n /** The facts of every item fetched so far, by item instance (the rendered item-ref identifier). */\n readonly itemFacts?: ItemFactsByRef;\n /** The candidate's responses and outcomes, per item. */\n readonly testContext?: Readonly<TestContext>;\n /** Where the candidate is, the view and the plugin state. */\n readonly sessionContext?: Readonly<SessionContext>;\n /** `config.infoItemCategory`: items with it are not numbered. */\n readonly infoItemCategory?: string;\n /**\n * The host's per-item fields (`initContext`), matched on the item instance: each item gets them\n * under `data`, never at its top level.\n */\n readonly itemData?: readonly { identifier: string; [key: string]: unknown }[];\n /**\n * The optimality of each item's last ended attempt, by item instance (see `ItemOptimality`).\n * Kept by `test-navigation`, since it is not in the contexts: it is written when an attempt ends,\n * never on a plain change of the answer.\n */\n readonly optimality: ReadonlyMap<string, ItemOptimality>;\n /**\n * The lifecycle state of each item session, by item instance, kept by `test-navigation`\n * (`followItemSession`, `endItemAttempt`). An item it does not list is seeded from its attempts.\n */\n readonly lifecycle?: ReadonlyMap<string, ItemLifecycleState>;\n /** `computedContext.itemElement`, passed through. */\n readonly itemElement?: ComputedContext['itemElement'];\n /**\n * The time limits against the time spent at this update (`timeLimitRules`), kept by\n * `test-navigation`; each level that declares `qti-time-limits` gets its answer as `time`.\n */\n readonly timeLimits?: TimeLimitAnswers;\n}\n\n/** `{ time }` when the level has an answer, else nothing, so a level without limits has no key. */\nconst timeOf = (answer: TimeLimitState | undefined): { time?: TimeLimitState } =>\n answer ? { time: { ...answer } } : {};\n\n/**\n * `computedContext`, derived from its inputs alone: built anew on every call, never from the previous\n * context, and never changing an input. The same inputs give an equal context.\n *\n * The tree of the test (roadmap 1, T2d): test parts, sections nested as the test nests them, each\n * section's item-refs and subsections in document order. In the model a `with-replacement` clone is\n * an item-ref of its own whose identifier is its instance (`item-3#2`); here it keeps that as\n * `instance`, under the identifier of the item-ref it copies.\n *\n * Roadmap 1, T2c. `DeliveryState` is not live at runtime yet, so the candidate's state comes from\n * `testContext` and `sessionContext`; T3 and T8 move it into `DeliveryState`, and add their fields here.\n */\nexport function deriveComputedContext(inputs: ComputedContextInputs): ComputedContext {\n const { model, sessionContext, itemElement } = inputs;\n const itemIndexes = indexesInDocumentOrder(\n model.testParts.flatMap(part => itemRefsInOrder(part.sections)),\n inputs.infoItemCategory\n );\n const deriveSection = (testPart: TestPartModel, section: SectionModel): ComputedSection => ({\n kind: 'section',\n identifier: section.identifier,\n title: section.title,\n visible: section.visible,\n active: sessionContext?.navSectionId === section.identifier,\n // A section that only holds subsections is completed when theirs are.\n completed: itemRefsInOrder(section.content).every(\n item => variableValue(itemContextFor(inputs, item.identifier), 'completionStatus') === 'completed'\n ),\n ...timeOf(inputs.timeLimits?.sections[section.identifier]),\n content: section.content.map(child =>\n child.kind === 'section'\n ? deriveSection(testPart, child)\n : deriveItem(inputs, testPart, child, itemIndexes.get(child.identifier) ?? null)\n )\n });\n return {\n itemElement,\n identifier: model.identifier,\n title: model.title,\n view: sessionContext?.view,\n plugins: sessionContext?.plugins ?? {},\n ...timeOf(inputs.timeLimits?.test),\n testParts: model.testParts.map(testPart => ({\n active: sessionContext?.navPartId === testPart.identifier,\n ...timeOf(inputs.timeLimits?.testParts[testPart.identifier]),\n identifier: testPart.identifier,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n sections: testPart.sections.map(section => deriveSection(testPart, section))\n }))\n };\n}\n\nfunction deriveItem(\n inputs: ComputedContextInputs,\n testPart: TestPartModel,\n item: ItemRefModel,\n index: number | null\n): ComputedItem {\n // The model names an item-ref by its instance: a clone's identifier there is `item-3#2`.\n const instance = item.identifier;\n const itemContext = itemContextFor(inputs, instance);\n // Only the fields an item context holds: a host that restores `testContext` with fields of its\n // own sets nothing here. Its fields for an item belong in `itemData`, which lands under `data`.\n const computedItem = {\n kind: 'item' as const,\n instance,\n active: false,\n ...factsFor(inputs.itemFacts, instance),\n identifier: parseItemInstanceId(instance).itemRefIdentifier,\n categories: [...item.categories],\n href: item.href,\n sessionControl: { ...item.sessionControl },\n variables: itemContext?.variables ?? [],\n ...(itemContext?.state === undefined ? {} : { state: itemContext.state }),\n ...(itemContext?.comment === undefined ? {} : { comment: itemContext.comment }),\n ...(itemContext?.readonly === undefined ? {} : { readonly: itemContext.readonly }),\n ...(itemContext?.disabled === undefined ? {} : { disabled: itemContext.disabled })\n } as Omit<ComputedItem, 'index' | 'data'>;\n\n const rawScore = variableValue(computedItem, 'SCORE');\n const score = rawScore === undefined || rawScore === null ? null : parseFloat(rawScore.toString());\n const rawMaxScore = variableValue(computedItem, 'MAXSCORE');\n const maxScore = rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(rawMaxScore.toString());\n const completionStatus = variableValue(computedItem, 'completionStatus') as string;\n const response = variableValue(computedItem, 'RESPONSE') || '';\n const numAttempts = Number(variableValue(computedItem, 'numAttempts')) || 0;\n\n const latched = inputs.optimality.get(instance);\n const session = lifecycleOf(inputs, testPart, item, itemContext, { numAttempts, completionStatus });\n\n return {\n ...computedItem,\n completionStatus,\n numAttempts,\n score,\n response,\n index,\n active: inputs.sessionContext?.navItemRefId === instance,\n // Published by the item. One that is not on screen has nothing to be invalid.\n valid: itemContext?.valid ?? true,\n isDefaultResponse: isDefaultResponse(itemContext),\n maxScore,\n // Information only, from the last *ended* attempt (the latch); it decides nothing.\n optimal: latched === 'optimal',\n ...session,\n // The session's: closed, or in review or solution. Never the score (roadmap 1, T3b2b).\n done: session.rules.done,\n ...timeOf(inputs.timeLimits?.items[instance]),\n data: hostData(inputs.itemData, instance)\n } as ComputedItem;\n}\n\n/** The item session's lifecycle state and what it may do now (`itemRules`), computed: host data never sets it. */\nfunction lifecycleOf(\n inputs: ComputedContextInputs,\n testPart: TestPartModel,\n item: ItemRefModel,\n itemContext: ItemContext | undefined,\n { numAttempts, completionStatus }: { numAttempts: number; completionStatus: string | undefined }\n): Pick<ComputedItem, 'lifecycle' | 'rules'> {\n const session = {\n sessionControl: item.sessionControl,\n adaptive: inputs.itemFacts?.get(item.identifier)?.adaptive ?? false,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n numAttempts,\n completionStatus: completionStatus ?? null\n };\n const lifecycle =\n inputs.lifecycle?.get(item.identifier) ??\n seedItemLifecycle({\n ...session,\n presented: inputs.sessionContext?.navItemRefId === item.identifier,\n passed: false\n });\n const rules = itemRules({\n ...session,\n state: lifecycle,\n // Only resuming reads it, and no answer asks about resuming.\n left: false,\n modalFeedback: false,\n skipped: isSkipped(itemContext),\n valid: itemContext?.valid ?? true\n });\n return { lifecycle, rules };\n}\n\n/** The host's fields for an item (`initContext`), without the identifier that matched them; `{}` when none. */\nfunction hostData(itemData: ComputedContextInputs['itemData'], identifier: string): ComputedItem['data'] {\n const entry = itemData?.find(data => data.identifier === identifier);\n if (!entry) return {};\n return Object.fromEntries(Object.entries(entry).filter(([key]) => key !== 'identifier'));\n}\n\nfunction itemContextFor(inputs: ComputedContextInputs, identifier: string): ItemContext | undefined {\n return inputs.testContext?.items?.find(item => item.identifier === identifier);\n}\n\nfunction variableValue(item: { variables?: ItemContext['variables'] } | undefined, identifier: string) {\n return item?.variables?.find(variable => variable.identifier === identifier)?.value;\n}\n\n/** An item's facts as `computedContext` carries them; nothing until the item is fetched. */\nfunction factsFor(\n itemFacts: ItemFactsByRef | undefined,\n identifier: string\n): Partial<Omit<ItemFacts, 'identifier'>> & { assessmentItemIdentifier?: string } {\n const facts = itemFacts?.get(identifier);\n if (!facts) return {};\n const { identifier: assessmentItemIdentifier, ...rest } = facts;\n return { ...rest, assessmentItemIdentifier };\n}\n\n/** Item numbers in document order, skipping info items; null for an info item. */\nfunction indexesInDocumentOrder(items: ItemRefModel[], infoItemCategory: string | undefined) {\n let index = 1;\n return new Map(\n items.map(item => [item.identifier, item.categories.includes(infoItemCategory) ? null : index++] as const)\n );\n}\n\n/**\n * No response given (QTI info model §7.19, `allow-skipping`): every response variable holds its\n * default or NULL. An item with no response variables \"by definition cannot be skipped\"; one not\n * fetched yet has given none.\n */\nfunction isSkipped(itemContext: ItemContext | undefined): boolean {\n if (!itemContext) return true;\n const responses = itemContext.variables?.filter(\n v => v.type === 'response' && v.identifier !== 'numAttempts' && v.identifier !== 'duration'\n );\n return Boolean(responses?.length) && isDefaultResponse(itemContext);\n}\n\n/** Every response still holds its default (or the base type's empty value): nothing answered. */\nfunction isDefaultResponse(itemContext: ItemContext | undefined): boolean {\n const responseVariables =\n itemContext?.variables?.filter(v => v.type === 'response' && v.identifier !== 'numAttempts') || [];\n return responseVariables.every(v => {\n if (v.value === undefined || v.value === null) return true;\n let fallbackValue: string;\n switch (v.baseType) {\n case 'integer':\n case 'float':\n case 'duration':\n fallbackValue = '0';\n break;\n case 'boolean':\n fallbackValue = 'false';\n break;\n default:\n fallbackValue = '';\n break;\n }\n const defaultValue = v.defaultValue ?? fallbackValue;\n if (Array.isArray(v.value)) {\n const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];\n return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);\n }\n return v.value === defaultValue;\n });\n}\n\n/**\n * Decide whether an item's submission is as good as it can get — i.e. the\n * candidate reached the *optimal* outcome, so there's no reason to make them\n * try again. 'optimal' means best achievable, 'suboptimal' means a better\n * attempt is still possible, 'unscored' means there's nothing to judge against.\n * (\"optimal\" is the spec's own word — a qti-correct-response is defined as\n * \"the (or an) optimal value\".)\n *\n * Two signals, in order of authority:\n * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).\n * This correctly handles partial-credit / qti-mapping items, where an exact\n * response match would under- or over-judge.\n * 2. The declared qti-correct-response, for items that aren't scored (no\n * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping\n * variables like numAttempts can be typed 'response' but never declare a\n * correctResponse, so we filter on a declared correctResponse.\n *\n * Items with neither a comparable score nor a correctResponse (essays, info\n * items, etc.) are 'unscored' — there's no optimal value to require, so one\n * attempt is enough.\n */\nexport function assessOptimality(item: ItemContext): ItemOptimality {\n const variables = item.variables ?? [];\n\n const score = numericVariable(variables, 'SCORE');\n const maxScore = numericVariable(variables, 'MAXSCORE');\n if (score !== null && maxScore !== null) {\n return score >= maxScore ? 'optimal' : 'suboptimal';\n }\n\n const responseVars = variables.filter(\n (v): v is ResponseVariable =>\n v.type === 'response' &&\n (v as ResponseVariable).correctResponse !== undefined &&\n (v as ResponseVariable).correctResponse !== null\n );\n if (responseVars.length === 0) return 'unscored';\n const allMatch = responseVars.every(v => {\n const expected = v.correctResponse;\n const actual = v.value;\n if (actual === undefined || actual === null) return false;\n if (Array.isArray(expected) && Array.isArray(actual)) {\n return expected.length === actual.length && expected.every(e => actual.includes(e));\n }\n if (Array.isArray(expected) || Array.isArray(actual)) return false;\n return expected === actual;\n });\n return allMatch ? 'optimal' : 'suboptimal';\n}\n\n/** Read a single numeric outcome value, or null when absent / non-numeric. */\nfunction numericVariable(variables: ItemContext['variables'], identifier: string): number | null {\n const raw = variables?.find(v => v.identifier === identifier)?.value;\n if (raw === undefined || raw === null || Array.isArray(raw)) return null;\n const parsed = parseFloat(raw.toString());\n return Number.isNaN(parsed) ? null : parsed;\n}\n"]}
|
|
@@ -7,12 +7,15 @@ export interface ItemSessionPosition {
|
|
|
7
7
|
readonly current: string | null | undefined;
|
|
8
8
|
/** The item-refs whose items are on screen. */
|
|
9
9
|
readonly presented: ReadonlySet<string>;
|
|
10
|
+
/** The item-refs whose time is up (`closedByTimeUp`): their sessions end. */
|
|
11
|
+
readonly timeUp?: ReadonlySet<string>;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* What the delivery knows about each item session at an update, by item-ref identifier: its session
|
|
13
15
|
* control and part, its attempts and `completionStatus` from its context, whether it is on screen,
|
|
14
|
-
*
|
|
16
|
+
* whether a linear part has passed it (it comes before the current item there), and whether its time
|
|
17
|
+
* is up. Pure.
|
|
15
18
|
*/
|
|
16
|
-
export declare function itemSessionFacts(model: TestModel, itemFacts: ItemFactsByRef | undefined, items: readonly ItemContext[] | undefined, { current, presented }: ItemSessionPosition): Map<string, ItemSessionFacts>;
|
|
19
|
+
export declare function itemSessionFacts(model: TestModel, itemFacts: ItemFactsByRef | undefined, items: readonly ItemContext[] | undefined, { current, presented, timeUp }: ItemSessionPosition): Map<string, ItemSessionFacts>;
|
|
17
20
|
/** The ended attempts and `completionStatus` an item context holds. */
|
|
18
21
|
export declare function attemptsOf(context: ItemContext | undefined): Pick<ItemSessionFacts, 'numAttempts' | 'completionStatus'>;
|
|
@@ -2,9 +2,10 @@ import { itemRefsInOrder } from '@qti-components/delivery';
|
|
|
2
2
|
/**
|
|
3
3
|
* What the delivery knows about each item session at an update, by item-ref identifier: its session
|
|
4
4
|
* control and part, its attempts and `completionStatus` from its context, whether it is on screen,
|
|
5
|
-
*
|
|
5
|
+
* whether a linear part has passed it (it comes before the current item there), and whether its time
|
|
6
|
+
* is up. Pure.
|
|
6
7
|
*/
|
|
7
|
-
export function itemSessionFacts(model, itemFacts, items, { current, presented }) {
|
|
8
|
+
export function itemSessionFacts(model, itemFacts, items, { current, presented, timeUp }) {
|
|
8
9
|
const facts = new Map();
|
|
9
10
|
for (const testPart of model.testParts) {
|
|
10
11
|
const order = itemRefsInOrder(testPart.sections);
|
|
@@ -18,7 +19,8 @@ export function itemSessionFacts(model, itemFacts, items, { current, presented }
|
|
|
18
19
|
navigationMode: testPart.navigationMode,
|
|
19
20
|
submissionMode: testPart.submissionMode,
|
|
20
21
|
presented: presented.has(item.identifier),
|
|
21
|
-
passed: testPart.navigationMode === 'linear' && currentIndex >= 0 && index < currentIndex
|
|
22
|
+
passed: testPart.navigationMode === 'linear' && currentIndex >= 0 && index < currentIndex,
|
|
23
|
+
timeUp: timeUp?.has(item.identifier) ?? false
|
|
22
24
|
});
|
|
23
25
|
});
|
|
24
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-session-facts.js","sourceRoot":"","sources":["../../src/internal/item-session-facts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"item-session-facts.js","sourceRoot":"","sources":["../../src/internal/item-session-facts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAgB3D;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAgB,EAChB,SAAqC,EACrC,KAAyC,EACzC,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAuB;IAEnD,MAAM,KAAK,GAAG,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AI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,EAAE,KAAK,CAAC;IACxG,MAAM,gBAAgB,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACnD,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC;QAC9C,gBAAgB,EAAE,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;KACjF,CAAC;AACJ,CAAC","sourcesContent":["import { itemRefsInOrder } from '@qti-components/delivery';\n\nimport type { ItemContext } from '@qti-components/base';\nimport type { ItemSessionFacts, TestModel } from '@qti-components/delivery';\nimport type { ItemFactsByRef } from './item-facts.context';\n\n/** Where the candidate is, for the facts of every item session. */\nexport interface ItemSessionPosition {\n /** The current item-ref (`sessionContext.navItemRefId`); null or undefined when none is. */\n readonly current: string | null | undefined;\n /** The item-refs whose items are on screen. */\n readonly presented: ReadonlySet<string>;\n /** The item-refs whose time is up (`closedByTimeUp`): their sessions end. */\n readonly timeUp?: ReadonlySet<string>;\n}\n\n/**\n * What the delivery knows about each item session at an update, by item-ref identifier: its session\n * control and part, its attempts and `completionStatus` from its context, whether it is on screen,\n * whether a linear part has passed it (it comes before the current item there), and whether its time\n * is up. Pure.\n */\nexport function itemSessionFacts(\n model: TestModel,\n itemFacts: ItemFactsByRef | undefined,\n items: readonly ItemContext[] | undefined,\n { current, presented, timeUp }: ItemSessionPosition\n): Map<string, ItemSessionFacts> {\n const facts = new Map<string, ItemSessionFacts>();\n for (const testPart of model.testParts) {\n const order = itemRefsInOrder(testPart.sections);\n const currentIndex = order.findIndex(item => item.identifier === current);\n order.forEach((item, index) => {\n const context = items?.find(candidate => candidate.identifier === item.identifier);\n facts.set(item.identifier, {\n ...attemptsOf(context),\n sessionControl: item.sessionControl,\n adaptive: itemFacts?.get(item.identifier)?.adaptive ?? false,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n presented: presented.has(item.identifier),\n passed: testPart.navigationMode === 'linear' && currentIndex >= 0 && index < currentIndex,\n timeUp: timeUp?.has(item.identifier) ?? false\n });\n });\n }\n return facts;\n}\n\n/** The ended attempts and `completionStatus` an item context holds. */\nexport function attemptsOf(\n context: ItemContext | undefined\n): Pick<ItemSessionFacts, 'numAttempts' | 'completionStatus'> {\n const value = (identifier: string) => context?.variables?.find(v => v.identifier === identifier)?.value;\n const completionStatus = value('completionStatus');\n return {\n numAttempts: Number(value('numAttempts')) || 0,\n completionStatus: typeof completionStatus === 'string' ? completionStatus : null\n };\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { QtiContext } from '@qti-components/base';
|
|
2
|
+
import type { Clock } from '@qti-components/delivery';
|
|
3
|
+
import type { QtiTestTiming } from '../types/qti-test-state';
|
|
2
4
|
import type { transformTestApi } from '@qti-components/transformers';
|
|
3
5
|
import type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';
|
|
4
6
|
/**
|
|
@@ -27,8 +29,27 @@ export interface TestHost extends HTMLElement {
|
|
|
27
29
|
* be left yet.
|
|
28
30
|
*/
|
|
29
31
|
beforeLinearNext?: ((itemRefId: string) => LinearNextRefusal | null) | null;
|
|
32
|
+
/**
|
|
33
|
+
* Set by `test-navigation`, which keeps the item sessions: asked by `submit()` before the test's
|
|
34
|
+
* outcome processing to submit every test part with simultaneous submission not yet submitted
|
|
35
|
+
* (roadmap 1, T6). T5 (a part's time limit) and T7 (leaving a part) submit through it too.
|
|
36
|
+
*/
|
|
37
|
+
submitTestParts?: (() => void) | null;
|
|
38
|
+
/** Sets values on one item-ref, in the test context and on the item if it is on screen (`qti-test`'s method). */
|
|
39
|
+
updateItemVariables(itemRefId: string, values: readonly {
|
|
40
|
+
identifier: string;
|
|
41
|
+
value: string | string[] | null;
|
|
42
|
+
}[]): void;
|
|
30
43
|
/** Sets the candidate's comment on an item-ref; null clears it. `test-navigation` checks `rules.mayComment` first. */
|
|
31
44
|
updateItemComment(itemRefId: string, comment: string | null): void;
|
|
45
|
+
/** `qtiTest.clock`: where the time limits read the time (roadmap 1 T5). */
|
|
46
|
+
readonly clock: Clock;
|
|
47
|
+
/** The time spent, kept by the test for its state; null for a test without `qti-time-limits`. */
|
|
48
|
+
readonly timing: QtiTestTiming | null;
|
|
49
|
+
/** Written by `test-navigation` as it follows the candidate. */
|
|
50
|
+
updateTiming(timing: QtiTestTiming | null): void;
|
|
51
|
+
/** Sends `qc-test-state-changed` with the time spent now, even when nothing else changed. */
|
|
52
|
+
saveTiming(): void;
|
|
32
53
|
}
|
|
33
54
|
/** Why Next may not leave an item yet: its responses are ones its session control refuses. */
|
|
34
55
|
export interface LinearNextRefusal {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-host.context.js","sourceRoot":"","sources":["../../src/internal/test-host.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"test-host.context.js","sourceRoot":"","sources":["../../src/internal/test-host.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmE7C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAW,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nimport type { QtiContext } from '@qti-components/base';\nimport type { Clock } from '@qti-components/delivery';\nimport type { QtiTestTiming } from '../types/qti-test-state';\nimport type { transformTestApi } from '@qti-components/transformers';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\n\n/**\n * Defined here, and re-exported by the navigation mixin under the same name, so this file imports\n * nothing from the mixin: the mixin imports the components that consume this context, and a type\n * import counts as a dependency for madge.\n */\nexport type PostLoadTestTransformCallback = (\n transformer: transformTestApi,\n testElement: QtiAssessmentTest\n) => transformTestApi | Promise<transformTestApi>;\n\n/**\n * What the components inside a test need from the `qti-test` that contains them: the things a host\n * put on it, and the element to query. Provided by `qti-test` about itself.\n *\n * It is context and not `closest('qti-test')` because a request crosses shadow roots and `closest`\n * stops at the first one, so a navigation or container a host renders inside its own component\n * would never find its test. Internal on purpose: not exported from the package, and not API.\n */\nexport interface TestHost extends HTMLElement {\n /** The test's URL; `test-container` loads it. The context is re-sent whenever it changes. */\n src: string | null;\n qtiContext: QtiContext;\n postLoadTestTransformCallback: PostLoadTestTransformCallback | null;\n /**\n * Set by `test-navigation`, which keeps the item sessions: asked by the navigation mixin before a\n * Next in a linear part leaves `itemRefId`, while that item is still rendered. It ends the item's\n * attempt when one is open (roadmap 1, T3b2b) and answers null, or answers why the item may not\n * be left yet.\n */\n beforeLinearNext?: ((itemRefId: string) => LinearNextRefusal | null) | null;\n /**\n * Set by `test-navigation`, which keeps the item sessions: asked by `submit()` before the test's\n * outcome processing to submit every test part with simultaneous submission not yet submitted\n * (roadmap 1, T6). T5 (a part's time limit) and T7 (leaving a part) submit through it too.\n */\n submitTestParts?: (() => void) | null;\n /** Sets values on one item-ref, in the test context and on the item if it is on screen (`qti-test`'s method). */\n updateItemVariables(\n itemRefId: string,\n values: readonly { identifier: string; value: string | string[] | null }[]\n ): void;\n /** Sets the candidate's comment on an item-ref; null clears it. `test-navigation` checks `rules.mayComment` first. */\n updateItemComment(itemRefId: string, comment: string | null): void;\n /** `qtiTest.clock`: where the time limits read the time (roadmap 1 T5). */\n readonly clock: Clock;\n /** The time spent, kept by the test for its state; null for a test without `qti-time-limits`. */\n readonly timing: QtiTestTiming | null;\n /** Written by `test-navigation` as it follows the candidate. */\n updateTiming(timing: QtiTestTiming | null): void;\n /** Sends `qc-test-state-changed` with the time spent now, even when nothing else changed. */\n saveTiming(): void;\n}\n\n/** Why Next may not leave an item yet: its responses are ones its session control refuses. */\nexport interface LinearNextRefusal {\n reason: 'allow-skipping' | 'validate-responses';\n itemId: string;\n}\n\nexport const testHostContext = createContext<TestHost>(Symbol('testHost'));\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StoredTiming } from '@qti-components/delivery';
|
|
2
|
+
import type { QtiTestTiming } from '../types/qti-test-state';
|
|
3
|
+
/** `QtiTestTiming`, as the `delivery` timing functions read it: each item's stopwatch as its `duration`. */
|
|
4
|
+
export declare const storedTiming: ({ test, testParts, sections, items }: QtiTestTiming) => StoredTiming;
|
|
5
|
+
/** Back from the `delivery` shape to the one `QtiTestState` stores, as plain JSON (no shared objects). */
|
|
6
|
+
export declare const qtiTestTiming: ({ timing, items }: StoredTiming) => QtiTestTiming;
|
|
7
|
+
/** A timing where nothing has run yet. */
|
|
8
|
+
export declare const emptyTiming: () => QtiTestTiming;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** `QtiTestTiming`, as the `delivery` timing functions read it: each item's stopwatch as its `duration`. */
|
|
2
|
+
export const storedTiming = ({ test, testParts, sections, items }) => ({
|
|
3
|
+
timing: { test, testParts, sections },
|
|
4
|
+
items: Object.fromEntries(Object.entries(items).map(([id, duration]) => [id, { duration }]))
|
|
5
|
+
});
|
|
6
|
+
/** Back from the `delivery` shape to the one `QtiTestState` stores, as plain JSON (no shared objects). */
|
|
7
|
+
export const qtiTestTiming = ({ timing, items }) => JSON.parse(JSON.stringify({
|
|
8
|
+
...timing,
|
|
9
|
+
items: Object.fromEntries(Object.entries(items).map(([id, { duration }]) => [id, duration]))
|
|
10
|
+
}));
|
|
11
|
+
/** A timing where nothing has run yet. */
|
|
12
|
+
export const emptyTiming = () => ({
|
|
13
|
+
test: { spent: 0, since: null },
|
|
14
|
+
testParts: {},
|
|
15
|
+
sections: {},
|
|
16
|
+
items: {}
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=test-timing.js.map
|