@qti-components/delivery 0.1.0-next.12 → 0.1.0-next.13
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/lifecycle/item-lifecycle.d.ts +6 -5
- package/dist/lifecycle/item-lifecycle.js +13 -5
- package/dist/lifecycle/item-lifecycle.js.map +1 -1
- package/dist/lifecycle/item-rules.d.ts +2 -1
- package/dist/lifecycle/item-rules.js +6 -3
- package/dist/lifecycle/item-rules.js.map +1 -1
- package/dist/lifecycle/item-session.d.ts +2 -1
- package/dist/lifecycle/item-session.js +6 -3
- package/dist/lifecycle/item-session.js.map +1 -1
- package/dist/lifecycle/part-submission.d.ts +1 -1
- package/dist/lifecycle/part-submission.js +1 -1
- package/dist/lifecycle/part-submission.js.map +1 -1
- package/package.json +1 -1
|
@@ -87,13 +87,14 @@ export interface ItemLifecycleInput {
|
|
|
87
87
|
/**
|
|
88
88
|
* Whether another attempt is allowed (implementation guide §4.4.2.1): a non-adaptive item until it
|
|
89
89
|
* has used `max-attempts` (0 is unlimited); an adaptive item, which ignores `max-attempts`, until its
|
|
90
|
-
* response processing set `completionStatus` to `completed`.
|
|
90
|
+
* response processing set `completionStatus` to `completed`. In a part with simultaneous submission
|
|
91
|
+
* every item has "one and only one attempt" (§4.1), used when the part is submitted.
|
|
91
92
|
*/
|
|
92
|
-
export declare function hasAttemptsLeft({ sessionControl: { maxAttempts }, adaptive, numAttempts, completionStatus }: Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'>): boolean;
|
|
93
|
+
export declare function hasAttemptsLeft({ sessionControl: { maxAttempts }, adaptive, numAttempts, completionStatus, submissionMode }: Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'> & Partial<Pick<ItemLifecycleInput, 'submissionMode'>>): boolean;
|
|
93
94
|
/** The guards of one item session, from its session control, its facts, its part and its variables. */
|
|
94
95
|
export declare function itemLifecycleGuards(input: ItemLifecycleInput): ItemLifecycleGuards;
|
|
95
96
|
/** What a version 1 state, or a test restored from one, tells about an item session. */
|
|
96
|
-
export interface ItemLifecycleSeedInput extends Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'
|
|
97
|
+
export interface ItemLifecycleSeedInput extends Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'>, Partial<Pick<ItemLifecycleInput, 'submissionMode'>> {
|
|
97
98
|
/** The item is on screen: the current item, or one of the section on screen with `navigate="section"`. */
|
|
98
99
|
presented: boolean;
|
|
99
100
|
/** The item comes before the current one in a linear part: the candidate has left it for good. */
|
|
@@ -102,7 +103,7 @@ export interface ItemLifecycleSeedInput extends Pick<ItemLifecycleInput, 'sessio
|
|
|
102
103
|
/**
|
|
103
104
|
* The lifecycle state of an item session that has none stored: a version 1 state, or a test restored
|
|
104
105
|
* or assigned from one (`plans/delivery-state.md`). Closed when no attempt is left or a linear part
|
|
105
|
-
* has passed it; interacting when it is on screen; initial before its
|
|
106
|
-
* suspended. Never `modalFeedback`, `review` or `solution`: a version 1 state cannot tell them apart.
|
|
106
|
+
* with individual submission has passed it; interacting when it is on screen; initial before its
|
|
107
|
+
* first ended attempt (in a simultaneous part: never opened); else suspended. Never `modalFeedback`, `review` or `solution`: a version 1 state cannot tell them apart.
|
|
107
108
|
*/
|
|
108
109
|
export declare function seedItemLifecycle(input: ItemLifecycleSeedInput): ItemLifecycleState;
|
|
@@ -121,9 +121,12 @@ export function transition(state, event, guards) {
|
|
|
121
121
|
/**
|
|
122
122
|
* Whether another attempt is allowed (implementation guide §4.4.2.1): a non-adaptive item until it
|
|
123
123
|
* has used `max-attempts` (0 is unlimited); an adaptive item, which ignores `max-attempts`, until its
|
|
124
|
-
* response processing set `completionStatus` to `completed`.
|
|
124
|
+
* response processing set `completionStatus` to `completed`. In a part with simultaneous submission
|
|
125
|
+
* every item has "one and only one attempt" (§4.1), used when the part is submitted.
|
|
125
126
|
*/
|
|
126
|
-
export function hasAttemptsLeft({ sessionControl: { maxAttempts }, adaptive, numAttempts, completionStatus }) {
|
|
127
|
+
export function hasAttemptsLeft({ sessionControl: { maxAttempts }, adaptive, numAttempts, completionStatus, submissionMode }) {
|
|
128
|
+
if (submissionMode === 'simultaneous')
|
|
129
|
+
return numAttempts === 0;
|
|
127
130
|
if (adaptive)
|
|
128
131
|
return completionStatus !== 'completed';
|
|
129
132
|
return maxAttempts === 0 || numAttempts < maxAttempts;
|
|
@@ -144,12 +147,17 @@ export function itemLifecycleGuards(input) {
|
|
|
144
147
|
/**
|
|
145
148
|
* The lifecycle state of an item session that has none stored: a version 1 state, or a test restored
|
|
146
149
|
* or assigned from one (`plans/delivery-state.md`). Closed when no attempt is left or a linear part
|
|
147
|
-
* has passed it; interacting when it is on screen; initial before its
|
|
148
|
-
* suspended. Never `modalFeedback`, `review` or `solution`: a version 1 state cannot tell them apart.
|
|
150
|
+
* with individual submission has passed it; interacting when it is on screen; initial before its
|
|
151
|
+
* first ended attempt (in a simultaneous part: never opened); else suspended. Never `modalFeedback`, `review` or `solution`: a version 1 state cannot tell them apart.
|
|
149
152
|
*/
|
|
150
153
|
export function seedItemLifecycle(input) {
|
|
151
|
-
|
|
154
|
+
// In a simultaneous part sessions pass between interacting and suspended only (§2.8.2): passing an
|
|
155
|
+
// item in a linear one does not close it; submitting the part does.
|
|
156
|
+
const closedByPassing = input.passed && input.submissionMode !== 'simultaneous';
|
|
157
|
+
if (!hasAttemptsLeft(input) || closedByPassing)
|
|
152
158
|
return 'closed';
|
|
159
|
+
if (input.passed)
|
|
160
|
+
return input.completionStatus === 'not_attempted' ? 'initial' : 'suspended';
|
|
153
161
|
if (input.presented)
|
|
154
162
|
return 'interacting';
|
|
155
163
|
return input.numAttempts === 0 ? 'initial' : 'suspended';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-lifecycle.js","sourceRoot":"","sources":["../../src/lifecycle/item-lifecycle.ts"],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AE,EAC/B,QAAQ,EACR,WAAW,EACX,gBAAgB,EAC6E;IAC7F,IAAI,QAAQ;QAAE,OAAO,gBAAgB,KAAK,WAAW,CAAC;IACtD,OAAO,WAAW,KAAK,CAAC,IAAI,WAAW,GAAG,WAAW,CAAC;AACxD,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,mBAAmB,CAAC,KAAyB;IAC3D,OAAO;QACL,YAAY,EAAE,eAAe,CAAC,KAAK,CAAC;QACpC,wFAAwF;QACxF,oBAAoB,EAAE,KAAK,CAAC,cAAc,KAAK,YAAY;QAC3D,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,6FAA6F;QAC7F,SAAS,EAAE,KAAK,CAAC,cAAc,KAAK,WAAW,IAAI,CAAC,KAAK,CAAC,IAAI;QAC9D,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW;QAC7C,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY;KAChD,CAAC;AACJ,CAAC;AAWD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IAC7D,IAAI,KAAK,CAAC,SAAS;QAAE,OAAO,aAAa,CAAC;IAC1C,OAAO,KAAK,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;AAC3D,CAAC","sourcesContent":["import type { SessionControl, TestPartModel } from '../model/test-model.js';\n\n/**\n * The item session lifecycle (QTI 3 info model §2.2.1, Figure 2.1) as one finite state machine per\n * item instance: every item session is in exactly one of these states, and only the transitions in\n * `ITEM_LIFECYCLE` happen. Each rule of item session control is a guard on one of them.\n *\n * ```mermaid\n * stateDiagram-v2\n * [*] --> initial\n * initial --> interacting: beginAttempt [attemptsLeft]\n * initial --> closed: endItemSession\n * interacting --> closed: endAttempt [individualSubmission, no attemptsLeft]\n * interacting --> modalFeedback: endAttempt [individualSubmission, attemptsLeft, modalFeedback]\n * interacting --> interacting: endAttempt [individualSubmission, attemptsLeft]\n * interacting --> suspended: endCandidateSession\n * interacting --> closed: endItemSession\n * modalFeedback --> interacting: beginAttempt [attemptsLeft]\n * modalFeedback --> suspended: endCandidateSession\n * modalFeedback --> closed: endItemSession\n * suspended --> interacting: beginCandidateSession [mayResume]\n * suspended --> closed: endItemSession\n * closed --> review: beginReview [allowReview]\n * review --> closed: endReview\n * closed --> solution: beginSolution [showSolution]\n * solution --> closed: endSolution\n * ```\n *\n * What QTI ties to the states: interactions are enabled in `interacting` only; in `closed` and\n * `review` the responses show but are fixed; in `solution` the correct responses show instead. An\n * item that goes from `initial` straight to `closed` keeps NULL responses.\n *\n * The text of §2.2.1 names six states; `modalFeedback` comes from its figure (Figure 2.1, as this\n * plan reads it): the item after an attempt whose response processing set modal feedback, with\n * attempts left (\"modal feedback is shown to the candidate directly following response\n * processing\", §2.6). The candidate reads it before trying again.\n *\n * Experimental (0.x): roadmap 1 phase T3; see `plans/delivery-state.md`.\n */\nexport const ITEM_LIFECYCLE_STATES = [\n 'initial',\n 'interacting',\n 'modalFeedback',\n 'suspended',\n 'closed',\n 'review',\n 'solution'\n] as const;\n\nexport type ItemLifecycleState = (typeof ITEM_LIFECYCLE_STATES)[number];\n\n/**\n * What happens to an item session, in QTI's words (info model §2.2.1). The delivery's commands\n * (`navigate`, `beginAttempt`, `endAttempt`, `endTestPart`, `timeUp`) are turned into these, per item.\n */\nexport const ITEM_LIFECYCLE_EVENTS = [\n 'beginAttempt',\n 'endAttempt',\n 'endCandidateSession',\n 'beginCandidateSession',\n 'endItemSession',\n 'beginReview',\n 'endReview',\n 'beginSolution',\n 'endSolution'\n] as const;\n\nexport type ItemLifecycleEvent = (typeof ITEM_LIFECYCLE_EVENTS)[number];\n\n/** The conditions a transition can depend on; `itemLifecycleGuards` reads them for one item. */\nexport const ITEM_LIFECYCLE_GUARDS = [\n 'attemptsLeft',\n 'individualSubmission',\n 'modalFeedback',\n 'mayResume',\n 'allowReview',\n 'showSolution'\n] as const;\n\nexport type ItemLifecycleGuard = (typeof ITEM_LIFECYCLE_GUARDS)[number];\n\nexport type ItemLifecycleGuards = Readonly<Record<ItemLifecycleGuard, boolean>>;\n\n/** One way out of a state: taken when every `when` guard holds and no `unless` guard does. */\nexport interface ItemLifecycleBranch {\n readonly to: ItemLifecycleState;\n readonly when?: readonly ItemLifecycleGuard[];\n readonly unless?: readonly ItemLifecycleGuard[];\n}\n\n/** A state with no guard, or branches tried in order, the first that holds taken. */\nexport type ItemLifecycleTarget = ItemLifecycleState | readonly ItemLifecycleBranch[];\n\n/** The transition table: a pair it does not list is refused. */\nexport const ITEM_LIFECYCLE: Readonly<\n Record<ItemLifecycleState, Readonly<Partial<Record<ItemLifecycleEvent, ItemLifecycleTarget>>>>\n> = {\n initial: {\n beginAttempt: [{ to: 'interacting', when: ['attemptsLeft'] }],\n endItemSession: 'closed'\n },\n interacting: {\n // The guards are read after response processing, with the ended attempt counted.\n endAttempt: [\n { to: 'closed', when: ['individualSubmission'], unless: ['attemptsLeft'] },\n { to: 'modalFeedback', when: ['individualSubmission', 'attemptsLeft', 'modalFeedback'] },\n { to: 'interacting', when: ['individualSubmission', 'attemptsLeft'] }\n ],\n endCandidateSession: 'suspended',\n endItemSession: 'closed'\n },\n modalFeedback: {\n beginAttempt: [{ to: 'interacting', when: ['attemptsLeft'] }],\n endCandidateSession: 'suspended',\n endItemSession: 'closed'\n },\n suspended: {\n beginCandidateSession: [{ to: 'interacting', when: ['mayResume'] }],\n endItemSession: 'closed'\n },\n closed: {\n beginReview: [{ to: 'review', when: ['allowReview'] }],\n beginSolution: [{ to: 'solution', when: ['showSolution'] }]\n },\n review: {\n endReview: 'closed'\n },\n solution: {\n endSolution: 'closed'\n }\n};\n\n/**\n * The state an item session goes to on `event`, or null when the table refuses it: the pair is not\n * listed, or no branch's guards hold. Pure: the same state, event and guards give the same answer\n * on every runtime.\n */\nexport function transition(\n state: ItemLifecycleState,\n event: ItemLifecycleEvent,\n guards: ItemLifecycleGuards\n): ItemLifecycleState | null {\n const target = ITEM_LIFECYCLE[state][event];\n if (target === undefined) return null;\n if (typeof target === 'string') return target;\n const branch = target.find(\n ({ when = [], unless = [] }) => when.every(guard => guards[guard]) && !unless.some(guard => guards[guard])\n );\n return branch?.to ?? null;\n}\n\n/** What the guards of one item session are read from. */\nexport interface ItemLifecycleInput {\n /** The item-ref's resolved session control (`ItemRefModel.sessionControl`). */\n sessionControl: Pick<SessionControl, 'maxAttempts' | 'allowReview' | 'showSolution'>;\n /** From the item's facts (`ItemFacts.adaptive`). */\n adaptive: boolean;\n navigationMode: TestPartModel['navigationMode'];\n submissionMode: TestPartModel['submissionMode'];\n /**\n * The attempts the candidate has ended. QTI's `numAttempts` counts an attempt as it begins; this\n * delivery counts it when it ends, and T3d keeps that (`plans/delivery-state.md`).\n */\n numAttempts: number;\n /** The item's `completionStatus` (`not_attempted`, `unknown`, `incomplete`, `completed`). */\n completionStatus: string | null;\n /** The candidate has moved on from the item; in a linear part there is no way back. */\n left: boolean;\n /** The last response processing set modal feedback to show. */\n modalFeedback: boolean;\n}\n\n/**\n * Whether another attempt is allowed (implementation guide §4.4.2.1): a non-adaptive item until it\n * has used `max-attempts` (0 is unlimited); an adaptive item, which ignores `max-attempts`, until its\n * response processing set `completionStatus` to `completed`.\n */\nexport function hasAttemptsLeft({\n sessionControl: { maxAttempts },\n adaptive,\n numAttempts,\n completionStatus\n}: Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'>): boolean {\n if (adaptive) return completionStatus !== 'completed';\n return maxAttempts === 0 || numAttempts < maxAttempts;\n}\n\n/** The guards of one item session, from its session control, its facts, its part and its variables. */\nexport function itemLifecycleGuards(input: ItemLifecycleInput): ItemLifecycleGuards {\n return {\n attemptsLeft: hasAttemptsLeft(input),\n // In a simultaneous part every response is processed when the part is submitted (§4.1).\n individualSubmission: input.submissionMode === 'individual',\n modalFeedback: input.modalFeedback,\n // A linear part restricts the candidate to each item in turn: once left, never again (§4.1).\n mayResume: input.navigationMode === 'nonlinear' || !input.left,\n allowReview: input.sessionControl.allowReview,\n showSolution: input.sessionControl.showSolution\n };\n}\n\n/** What a version 1 state, or a test restored from one, tells about an item session. */\nexport interface ItemLifecycleSeedInput\n extends Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'> {\n /** The item is on screen: the current item, or one of the section on screen with `navigate=\"section\"`. */\n presented: boolean;\n /** The item comes before the current one in a linear part: the candidate has left it for good. */\n passed: boolean;\n}\n\n/**\n * The lifecycle state of an item session that has none stored: a version 1 state, or a test restored\n * or assigned from one (`plans/delivery-state.md`). Closed when no attempt is left or a linear part\n * has passed it; interacting when it is on screen; initial before its first ended attempt; else\n * suspended. Never `modalFeedback`, `review` or `solution`: a version 1 state cannot tell them apart.\n */\nexport function seedItemLifecycle(input: ItemLifecycleSeedInput): ItemLifecycleState {\n if (!hasAttemptsLeft(input) || input.passed) return 'closed';\n if (input.presented) return 'interacting';\n return input.numAttempts === 0 ? 'initial' : 'suspended';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"item-lifecycle.js","sourceRoot":"","sources":["../../src/lifecycle/item-lifecycle.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS;IACT,aAAa;IACb,eAAe;IACf,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,UAAU;CACF,CAAC;AAIX;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,cAAc;IACd,YAAY;IACZ,qBAAqB;IACrB,uBAAuB;IACvB,gBAAgB;IAChB,aAAa;IACb,WAAW;IACX,eAAe;IACf,aAAa;CACL,CAAC;AAIX,gGAAgG;AAChG,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,cAAc;I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D,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,6FAA6F;QAC7F,SAAS,EAAE,KAAK,CAAC,cAAc,KAAK,WAAW,IAAI,CAAC,KAAK,CAAC,IAAI;QAC9D,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW;QAC7C,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY;KAChD,CAAC;AACJ,CAAC;AAYD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,mGAAmG;IACnG,oEAAoE;IACpE,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,cAAc,KAAK,cAAc,CAAC;IAChF,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,eAAe;QAAE,OAAO,QAAQ,CAAC;IAChE,IAAI,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC,gBAAgB,KAAK,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAC9F,IAAI,KAAK,CAAC,SAAS;QAAE,OAAO,aAAa,CAAC;IAC1C,OAAO,KAAK,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;AAC3D,CAAC","sourcesContent":["import type { SessionControl, TestPartModel } from '../model/test-model.js';\n\n/**\n * The item session lifecycle (QTI 3 info model §2.2.1, Figure 2.1) as one finite state machine per\n * item instance: every item session is in exactly one of these states, and only the transitions in\n * `ITEM_LIFECYCLE` happen. Each rule of item session control is a guard on one of them.\n *\n * ```mermaid\n * stateDiagram-v2\n * [*] --> initial\n * initial --> interacting: beginAttempt [attemptsLeft]\n * initial --> closed: endItemSession\n * interacting --> closed: endAttempt [individualSubmission, no attemptsLeft]\n * interacting --> modalFeedback: endAttempt [individualSubmission, attemptsLeft, modalFeedback]\n * interacting --> interacting: endAttempt [individualSubmission, attemptsLeft]\n * interacting --> suspended: endCandidateSession\n * interacting --> closed: endItemSession\n * modalFeedback --> interacting: beginAttempt [attemptsLeft]\n * modalFeedback --> suspended: endCandidateSession\n * modalFeedback --> closed: endItemSession\n * suspended --> interacting: beginCandidateSession [mayResume]\n * suspended --> closed: endItemSession\n * closed --> review: beginReview [allowReview]\n * review --> closed: endReview\n * closed --> solution: beginSolution [showSolution]\n * solution --> closed: endSolution\n * ```\n *\n * What QTI ties to the states: interactions are enabled in `interacting` only; in `closed` and\n * `review` the responses show but are fixed; in `solution` the correct responses show instead. An\n * item that goes from `initial` straight to `closed` keeps NULL responses.\n *\n * The text of §2.2.1 names six states; `modalFeedback` comes from its figure (Figure 2.1, as this\n * plan reads it): the item after an attempt whose response processing set modal feedback, with\n * attempts left (\"modal feedback is shown to the candidate directly following response\n * processing\", §2.6). The candidate reads it before trying again.\n *\n * Experimental (0.x): roadmap 1 phase T3; see `plans/delivery-state.md`.\n */\nexport const ITEM_LIFECYCLE_STATES = [\n 'initial',\n 'interacting',\n 'modalFeedback',\n 'suspended',\n 'closed',\n 'review',\n 'solution'\n] as const;\n\nexport type ItemLifecycleState = (typeof ITEM_LIFECYCLE_STATES)[number];\n\n/**\n * What happens to an item session, in QTI's words (info model §2.2.1). The delivery's commands\n * (`navigate`, `beginAttempt`, `endAttempt`, `endTestPart`, `timeUp`) are turned into these, per item.\n */\nexport const ITEM_LIFECYCLE_EVENTS = [\n 'beginAttempt',\n 'endAttempt',\n 'endCandidateSession',\n 'beginCandidateSession',\n 'endItemSession',\n 'beginReview',\n 'endReview',\n 'beginSolution',\n 'endSolution'\n] as const;\n\nexport type ItemLifecycleEvent = (typeof ITEM_LIFECYCLE_EVENTS)[number];\n\n/** The conditions a transition can depend on; `itemLifecycleGuards` reads them for one item. */\nexport const ITEM_LIFECYCLE_GUARDS = [\n 'attemptsLeft',\n 'individualSubmission',\n 'modalFeedback',\n 'mayResume',\n 'allowReview',\n 'showSolution'\n] as const;\n\nexport type ItemLifecycleGuard = (typeof ITEM_LIFECYCLE_GUARDS)[number];\n\nexport type ItemLifecycleGuards = Readonly<Record<ItemLifecycleGuard, boolean>>;\n\n/** One way out of a state: taken when every `when` guard holds and no `unless` guard does. */\nexport interface ItemLifecycleBranch {\n readonly to: ItemLifecycleState;\n readonly when?: readonly ItemLifecycleGuard[];\n readonly unless?: readonly ItemLifecycleGuard[];\n}\n\n/** A state with no guard, or branches tried in order, the first that holds taken. */\nexport type ItemLifecycleTarget = ItemLifecycleState | readonly ItemLifecycleBranch[];\n\n/** The transition table: a pair it does not list is refused. */\nexport const ITEM_LIFECYCLE: Readonly<\n Record<ItemLifecycleState, Readonly<Partial<Record<ItemLifecycleEvent, ItemLifecycleTarget>>>>\n> = {\n initial: {\n beginAttempt: [{ to: 'interacting', when: ['attemptsLeft'] }],\n endItemSession: 'closed'\n },\n interacting: {\n // The guards are read after response processing, with the ended attempt counted.\n endAttempt: [\n { to: 'closed', when: ['individualSubmission'], unless: ['attemptsLeft'] },\n { to: 'modalFeedback', when: ['individualSubmission', 'attemptsLeft', 'modalFeedback'] },\n { to: 'interacting', when: ['individualSubmission', 'attemptsLeft'] }\n ],\n endCandidateSession: 'suspended',\n endItemSession: 'closed'\n },\n modalFeedback: {\n beginAttempt: [{ to: 'interacting', when: ['attemptsLeft'] }],\n endCandidateSession: 'suspended',\n endItemSession: 'closed'\n },\n suspended: {\n beginCandidateSession: [{ to: 'interacting', when: ['mayResume'] }],\n endItemSession: 'closed'\n },\n closed: {\n beginReview: [{ to: 'review', when: ['allowReview'] }],\n beginSolution: [{ to: 'solution', when: ['showSolution'] }]\n },\n review: {\n endReview: 'closed'\n },\n solution: {\n endSolution: 'closed'\n }\n};\n\n/**\n * The state an item session goes to on `event`, or null when the table refuses it: the pair is not\n * listed, or no branch's guards hold. Pure: the same state, event and guards give the same answer\n * on every runtime.\n */\nexport function transition(\n state: ItemLifecycleState,\n event: ItemLifecycleEvent,\n guards: ItemLifecycleGuards\n): ItemLifecycleState | null {\n const target = ITEM_LIFECYCLE[state][event];\n if (target === undefined) return null;\n if (typeof target === 'string') return target;\n const branch = target.find(\n ({ when = [], unless = [] }) => when.every(guard => guards[guard]) && !unless.some(guard => guards[guard])\n );\n return branch?.to ?? null;\n}\n\n/** What the guards of one item session are read from. */\nexport interface ItemLifecycleInput {\n /** The item-ref's resolved session control (`ItemRefModel.sessionControl`). */\n sessionControl: Pick<SessionControl, 'maxAttempts' | 'allowReview' | 'showSolution'>;\n /** From the item's facts (`ItemFacts.adaptive`). */\n adaptive: boolean;\n navigationMode: TestPartModel['navigationMode'];\n submissionMode: TestPartModel['submissionMode'];\n /**\n * The attempts the candidate has ended. QTI's `numAttempts` counts an attempt as it begins; this\n * delivery counts it when it ends, and T3d keeps that (`plans/delivery-state.md`).\n */\n numAttempts: number;\n /** The item's `completionStatus` (`not_attempted`, `unknown`, `incomplete`, `completed`). */\n completionStatus: string | null;\n /** The candidate has moved on from the item; in a linear part there is no way back. */\n left: boolean;\n /** The last response processing set modal feedback to show. */\n modalFeedback: boolean;\n}\n\n/**\n * Whether another attempt is allowed (implementation guide §4.4.2.1): a non-adaptive item until it\n * has used `max-attempts` (0 is unlimited); an adaptive item, which ignores `max-attempts`, until its\n * response processing set `completionStatus` to `completed`. In a part with simultaneous submission\n * every item has \"one and only one attempt\" (§4.1), used when the part is submitted.\n */\nexport function hasAttemptsLeft({\n sessionControl: { maxAttempts },\n adaptive,\n numAttempts,\n completionStatus,\n submissionMode\n}: Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'> &\n Partial<Pick<ItemLifecycleInput, 'submissionMode'>>): boolean {\n if (submissionMode === 'simultaneous') return numAttempts === 0;\n if (adaptive) return completionStatus !== 'completed';\n return maxAttempts === 0 || numAttempts < maxAttempts;\n}\n\n/** The guards of one item session, from its session control, its facts, its part and its variables. */\nexport function itemLifecycleGuards(input: ItemLifecycleInput): ItemLifecycleGuards {\n return {\n attemptsLeft: hasAttemptsLeft(input),\n // In a simultaneous part every response is processed when the part is submitted (§4.1).\n individualSubmission: input.submissionMode === 'individual',\n modalFeedback: input.modalFeedback,\n // A linear part restricts the candidate to each item in turn: once left, never again (§4.1).\n mayResume: input.navigationMode === 'nonlinear' || !input.left,\n allowReview: input.sessionControl.allowReview,\n showSolution: input.sessionControl.showSolution\n };\n}\n\n/** What a version 1 state, or a test restored from one, tells about an item session. */\nexport interface ItemLifecycleSeedInput\n extends Pick<ItemLifecycleInput, 'sessionControl' | 'adaptive' | 'numAttempts' | 'completionStatus'>,\n Partial<Pick<ItemLifecycleInput, 'submissionMode'>> {\n /** The item is on screen: the current item, or one of the section on screen with `navigate=\"section\"`. */\n presented: boolean;\n /** The item comes before the current one in a linear part: the candidate has left it for good. */\n passed: boolean;\n}\n\n/**\n * The lifecycle state of an item session that has none stored: a version 1 state, or a test restored\n * or assigned from one (`plans/delivery-state.md`). Closed when no attempt is left or a linear part\n * with individual submission has passed it; interacting when it is on screen; initial before its\n * first ended attempt (in a simultaneous part: never opened); else suspended. Never `modalFeedback`, `review` or `solution`: a version 1 state cannot tell them apart.\n */\nexport function seedItemLifecycle(input: ItemLifecycleSeedInput): ItemLifecycleState {\n // In a simultaneous part sessions pass between interacting and suspended only (§2.8.2): passing an\n // item in a linear one does not close it; submitting the part does.\n const closedByPassing = input.passed && input.submissionMode !== 'simultaneous';\n if (!hasAttemptsLeft(input) || closedByPassing) return 'closed';\n if (input.passed) return input.completionStatus === 'not_attempted' ? 'initial' : 'suspended';\n if (input.presented) return 'interacting';\n return input.numAttempts === 0 ? 'initial' : 'suspended';\n}\n"]}
|
|
@@ -39,7 +39,8 @@ export interface ItemRules {
|
|
|
39
39
|
/**
|
|
40
40
|
* Feedback, modal and integrated, may show: always while attempts are left, after the last
|
|
41
41
|
* attempt only with `show-feedback`. In `review`, an adaptive item with `allow-review` shows its
|
|
42
|
-
* feedback whatever `show-feedback` says (§7.19, `allow-review`).
|
|
42
|
+
* feedback whatever `show-feedback` says (§7.19, `allow-review`). In a part with simultaneous
|
|
43
|
+
* submission none shows during the test (§4.1); once the part is submitted, `show-feedback` decides.
|
|
43
44
|
*/
|
|
44
45
|
readonly mayShowFeedback: boolean;
|
|
45
46
|
/**
|
|
@@ -6,16 +6,19 @@ export function itemRules(input) {
|
|
|
6
6
|
const individual = guards.individualSubmission;
|
|
7
7
|
const maySkip = !individual || sessionControl.allowSkipping || !input.skipped;
|
|
8
8
|
const maySubmit = maySkip && (!individual || !sessionControl.validateResponses || input.valid);
|
|
9
|
+
const done = state === 'closed' || state === 'review' || state === 'solution';
|
|
9
10
|
return {
|
|
10
11
|
attemptsLeft: guards.attemptsLeft,
|
|
11
12
|
attemptsUsed: !guards.attemptsLeft,
|
|
12
13
|
interactive: state === 'interacting',
|
|
13
|
-
done
|
|
14
|
+
done,
|
|
14
15
|
mayEndAttempt: maySubmit && transition(state, 'endAttempt', guards) !== null,
|
|
15
16
|
maySubmit,
|
|
16
17
|
maySkip,
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
// In a simultaneous part "feedback cannot be seen during the test" (§4.1): nothing until the
|
|
19
|
+
// part is submitted, then what `show-feedback` allows.
|
|
20
|
+
mayShowFeedback: (individual && guards.attemptsLeft) ||
|
|
21
|
+
(sessionControl.showFeedback && (individual || done)) ||
|
|
19
22
|
(state === 'review' && adaptive && sessionControl.allowReview),
|
|
20
23
|
mayBeginReview: transition(state, 'beginReview', guards) !== null,
|
|
21
24
|
mayBeginSolution: transition(state, 'beginSolution', guards) !== null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-rules.js","sourceRoot":"","sources":["../../src/lifecycle/item-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"item-rules.js","sourceRoot":"","sources":["../../src/lifecycle/item-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAgFtE,mGAAmG;AACnG,MAAM,U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a;KACnE,CAAC;AACJ,CAAC;AA0BD,8CAA8C;AAC9C,MAAM,UAAU,eAAe,CAAC,EAC9B,cAAc,EACd,cAAc,EACd,KAAK,EACL,KAAK,EACL,OAAO,EACc;IACrB,MAAM,MAAM,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,KAAK,CAAC;IAC3C,MAAM,WAAW,GAAG,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;IAC1G,OAAO;QACL,SAAS,EAAE,MAAM,IAAI,KAAK,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC;QAC7E,aAAa,EAAE,MAAM,IAAI,KAAK,GAAG,CAAC,IAAI,cAAc,KAAK,WAAW;KACrE,CAAC;AACJ,CAAC","sourcesContent":["import { itemLifecycleGuards, transition } from './item-lifecycle.js';\n\nimport type { SessionControl, TestPartModel } from '../model/test-model.js';\nimport type { ItemLifecycleInput, ItemLifecycleState } from './item-lifecycle.js';\n\n/**\n * What one item session may do now, answered from its lifecycle state, its session control and its\n * responses. Every reader of attempts, skipping, feedback, review or the solution asks here instead\n * of working the rule out itself (roadmap 1, T3b).\n *\n * The answers follow QTI 3 (`qti-item-session-control`, info model §7.19; implementation guide\n * §4.1 and §4.4.2) and nothing else: whether the last attempt was optimal decides none of them\n * (decided 2026-11-27, `plans/host-api.md`).\n *\n * Experimental (0.x).\n */\nexport interface ItemRules {\n /**\n * Another attempt is allowed: `max-attempts` not reached (0 is unlimited), or, for an adaptive\n * item, which ignores `max-attempts`, `completionStatus` not `completed`.\n */\n readonly attemptsLeft: boolean;\n /** No further attempt is allowed: the negation of `attemptsLeft`. */\n readonly attemptsUsed: boolean;\n /** The responses can change: only while `interacting`. In every other state they are fixed or not shown. */\n readonly interactive: boolean;\n /** The item session is over: `closed`, or in `review` or `solution`, which come back to `closed`. */\n readonly done: boolean;\n /**\n * The candidate may end the attempt now: the item is `interacting` in a part with individual\n * submission, and `maySubmit` holds.\n */\n readonly mayEndAttempt: boolean;\n /**\n * The responses may be submitted as they are: `allow-skipping=\"false\"` refuses an item with no\n * response, `validate-responses` an invalid one. Two separate rules, both for individual\n * submission only (§7.19).\n */\n readonly maySubmit: boolean;\n /** Submitting no response is allowed: `allow-skipping`, or a response given, or simultaneous submission. */\n readonly maySkip: boolean;\n /**\n * Feedback, modal and integrated, may show: always while attempts are left, after the last\n * attempt only with `show-feedback`. In `review`, an adaptive item with `allow-review` shows its\n * feedback whatever `show-feedback` says (§7.19, `allow-review`). In a part with simultaneous\n * submission none shows during the test (§4.1); once the part is submitted, `show-feedback` decides.\n */\n readonly mayShowFeedback: boolean;\n /**\n * The item session may enter `review` now: it is `closed`, with `allow-review`. False in `review`\n * itself; whether review shows is the state.\n */\n readonly mayBeginReview: boolean;\n /**\n * The item session may enter `solution`, which shows the correct responses: it is `closed`, with\n * `show-solution`. False in `solution` itself; whether the solution shows is the state.\n */\n readonly mayBeginSolution: boolean;\n /**\n * The candidate may set a comment on the item now: `allow-comment`, while `interacting`. The\n * comment is not assessed; QTI leaves capturing it to the delivery (§7.19, `allow-comment`).\n */\n readonly mayComment: boolean;\n}\n\n/** What the rules of one item session are read from: its lifecycle input, its state and its responses. */\nexport interface ItemRulesInput extends Omit<ItemLifecycleInput, 'sessionControl'> {\n /** The item-ref's resolved session control (`ItemRefModel.sessionControl`). */\n sessionControl: SessionControl;\n /** The item session's lifecycle state. */\n state: ItemLifecycleState;\n /**\n * The candidate gave no response: every response variable holds its default or NULL. False for an\n * item with no response variables, which \"by definition cannot be skipped\" (§7.19).\n */\n skipped: boolean;\n /** Every interaction's response satisfies its constraints (the item's `valid`). */\n valid: boolean;\n}\n\n/** The rules of one item session. Pure: the same input gives the same answers on every runtime. */\nexport function itemRules(input: ItemRulesInput): ItemRules {\n const { state, sessionControl, adaptive } = input;\n const guards = itemLifecycleGuards(input);\n const individual = guards.individualSubmission;\n const maySkip = !individual || sessionControl.allowSkipping || !input.skipped;\n const maySubmit = maySkip && (!individual || !sessionControl.validateResponses || input.valid);\n const done = state === 'closed' || state === 'review' || state === 'solution';\n return {\n attemptsLeft: guards.attemptsLeft,\n attemptsUsed: !guards.attemptsLeft,\n interactive: state === 'interacting',\n done,\n mayEndAttempt: maySubmit && transition(state, 'endAttempt', guards) !== null,\n maySubmit,\n maySkip,\n // In a simultaneous part \"feedback cannot be seen during the test\" (§4.1): nothing until the\n // part is submitted, then what `show-feedback` allows.\n mayShowFeedback:\n (individual && guards.attemptsLeft) ||\n (sessionControl.showFeedback && (individual || done)) ||\n (state === 'review' && adaptive && sessionControl.allowReview),\n mayBeginReview: transition(state, 'beginReview', guards) !== null,\n mayBeginSolution: transition(state, 'beginSolution', guards) !== null,\n mayComment: sessionControl.allowComment && state === 'interacting'\n };\n}\n\n/** Where the candidate is in a part, for its navigation answers. */\nexport interface NavigationRulesInput {\n navigationMode: TestPartModel['navigationMode'];\n submissionMode: TestPartModel['submissionMode'];\n /** The current item's position among the part's items in order, from 0; -1 when none is current. */\n index: number;\n /** The number of items in the part. */\n count: number;\n /** The rules of the current item. */\n current: Pick<ItemRules, 'maySubmit' | 'interactive'>;\n}\n\n/** Whether the candidate may move to the next or the previous item of a part. */\nexport interface NavigationRules {\n /**\n * There is a next item and, in a linear part with individual submission, the current item may be\n * left: Next ends an attempt that was not ended and closes the item (decided 2026-11-27), so its\n * responses must be ones the candidate may submit.\n */\n readonly mayGoNext: boolean;\n /** There is a previous item, in a nonlinear part: a linear part never goes back (§4.1). */\n readonly mayGoPrevious: boolean;\n}\n\n/** The navigation answers of a part. Pure. */\nexport function navigationRules({\n navigationMode,\n submissionMode,\n index,\n count,\n current\n}: NavigationRulesInput): NavigationRules {\n const onItem = index >= 0 && index < count;\n const endsAttempt = navigationMode === 'linear' && submissionMode === 'individual' && current.interactive;\n return {\n mayGoNext: onItem && index < count - 1 && (!endsAttempt || current.maySubmit),\n mayGoPrevious: onItem && index > 0 && navigationMode === 'nonlinear'\n };\n}\n"]}
|
|
@@ -10,11 +10,12 @@ export interface ItemSession {
|
|
|
10
10
|
/** What a delivery knows about an item session at an update. */
|
|
11
11
|
export interface ItemSessionFacts extends ItemLifecycleSeedInput, Pick<ItemLifecycleInput, 'navigationMode' | 'submissionMode'> {
|
|
12
12
|
sessionControl: ItemLifecycleInput['sessionControl'];
|
|
13
|
+
submissionMode: ItemLifecycleInput['submissionMode'];
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* The session after the candidate moved (or a state was restored), through the lifecycle table: an
|
|
16
17
|
* item put on screen begins its attempt or resumes, one taken off screen is suspended, and one a
|
|
17
|
-
* linear part has passed is closed. A session not seen before, or whose attempts changed outside
|
|
18
|
+
* linear part with individual submission has passed is closed. A session not seen before, or whose attempts changed outside
|
|
18
19
|
* `endItemAttempt` (a restored or assigned state) or whose item turned out adaptive (its facts came
|
|
19
20
|
* later), is seeded again with `seedItemLifecycle`.
|
|
20
21
|
*/
|
|
@@ -6,7 +6,7 @@ const OVER = ['closed', 'review', 'solution'];
|
|
|
6
6
|
/**
|
|
7
7
|
* The session after the candidate moved (or a state was restored), through the lifecycle table: an
|
|
8
8
|
* item put on screen begins its attempt or resumes, one taken off screen is suspended, and one a
|
|
9
|
-
* linear part has passed is closed. A session not seen before, or whose attempts changed outside
|
|
9
|
+
* linear part with individual submission has passed is closed. A session not seen before, or whose attempts changed outside
|
|
10
10
|
* `endItemAttempt` (a restored or assigned state) or whose item turned out adaptive (its facts came
|
|
11
11
|
* later), is seeded again with `seedItemLifecycle`.
|
|
12
12
|
*/
|
|
@@ -17,11 +17,14 @@ export function followItemSession(previous, facts) {
|
|
|
17
17
|
}
|
|
18
18
|
const guards = guardsFor(facts);
|
|
19
19
|
let state = previous.state;
|
|
20
|
-
|
|
20
|
+
// In a simultaneous part sessions pass between interacting and suspended only (§2.8.2): a passed
|
|
21
|
+
// item is suspended like any item off screen, and closes when the part is submitted.
|
|
22
|
+
const closes = facts.passed && facts.submissionMode !== 'simultaneous';
|
|
23
|
+
if (closes) {
|
|
21
24
|
if (!OVER.includes(state))
|
|
22
25
|
state = transition(state, 'endItemSession', guards) ?? state;
|
|
23
26
|
}
|
|
24
|
-
else if (facts.presented) {
|
|
27
|
+
else if (facts.presented && !facts.passed) {
|
|
25
28
|
if (state === 'initial')
|
|
26
29
|
state = transition(state, 'beginAttempt', guards) ?? state;
|
|
27
30
|
else if (state === 'suspended')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-session.js","sourceRoot":"","sources":["../../src/lifecycle/item-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"item-session.js","sourceRoot":"","sources":["../../src/lifecycle/item-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAqBzF,MAAM,SAAS,GAAG,CAAC,KAAuB,EAAE,EAAE;AAC5C,uGAAuG;AACvG,mBAAmB,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AAE9E,MAAM,IAAI,GAAkC,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAiC,EAAE,KAAuB;IAC1F,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,KAAK,WAAW,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACxF,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IACpE,CAAC;I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C,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IAC5F,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,aAAa,EAAE,YAAY,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AACtH,CAAC","sourcesContent":["import { itemLifecycleGuards, seedItemLifecycle, transition } from './item-lifecycle.js';\n\nimport type { ItemLifecycleInput, ItemLifecycleSeedInput, ItemLifecycleState } from './item-lifecycle.js';\n\n/** One item session as a delivery keeps it between updates: its state, and the attempts it was last seen with. */\nexport interface ItemSession {\n readonly state: ItemLifecycleState;\n /** The ended attempts when `state` was last set; a different count means the state came from elsewhere. */\n readonly numAttempts: number;\n /** Whether the item was adaptive when `state` was last set; its facts may arrive after the first update. */\n readonly adaptive: boolean;\n}\n\n/** What a delivery knows about an item session at an update. */\nexport interface ItemSessionFacts\n extends ItemLifecycleSeedInput,\n Pick<ItemLifecycleInput, 'navigationMode' | 'submissionMode'> {\n sessionControl: ItemLifecycleInput['sessionControl'];\n submissionMode: ItemLifecycleInput['submissionMode'];\n}\n\nconst guardsFor = (facts: ItemSessionFacts) =>\n // Modal feedback does not stop a session yet: nothing reports it, so `modalFeedback` is never entered.\n itemLifecycleGuards({ ...facts, left: facts.passed, modalFeedback: false });\n\nconst OVER: readonly ItemLifecycleState[] = ['closed', 'review', 'solution'];\n\n/**\n * The session after the candidate moved (or a state was restored), through the lifecycle table: an\n * item put on screen begins its attempt or resumes, one taken off screen is suspended, and one a\n * linear part with individual submission has passed is closed. A session not seen before, or whose attempts changed outside\n * `endItemAttempt` (a restored or assigned state) or whose item turned out adaptive (its facts came\n * later), is seeded again with `seedItemLifecycle`.\n */\nexport function followItemSession(previous: ItemSession | undefined, facts: ItemSessionFacts): ItemSession {\n const { numAttempts, adaptive } = facts;\n if (!previous || previous.numAttempts !== numAttempts || previous.adaptive !== adaptive) {\n return { state: seedItemLifecycle(facts), numAttempts, adaptive };\n }\n const guards = guardsFor(facts);\n let state = previous.state;\n // In a simultaneous part sessions pass between interacting and suspended only (§2.8.2): a passed\n // item is suspended like any item off screen, and closes when the part is submitted.\n const closes = facts.passed && facts.submissionMode !== 'simultaneous';\n if (closes) {\n if (!OVER.includes(state)) state = transition(state, 'endItemSession', guards) ?? state;\n } else if (facts.presented && !facts.passed) {\n if (state === 'initial') state = transition(state, 'beginAttempt', guards) ?? state;\n else if (state === 'suspended') state = transition(state, 'beginCandidateSession', guards) ?? state;\n } else if (state === 'interacting' || state === 'modalFeedback') {\n state = transition(state, 'endCandidateSession', guards) ?? state;\n }\n return { state, numAttempts, adaptive };\n}\n\n/**\n * The session after an attempt ended, `facts.numAttempts` counting it. An interacting session goes\n * through the table's `endAttempt`; one in any other state had its attempt ended before this delivery\n * saw it begin, so it is seeded as an item on screen.\n */\nexport function endItemAttempt(previous: ItemSession | undefined, facts: ItemSessionFacts): ItemSession {\n const { numAttempts, adaptive } = facts;\n if (previous?.state !== 'interacting') {\n return { state: seedItemLifecycle({ ...facts, presented: true }), numAttempts, adaptive };\n }\n return { state: transition('interacting', 'endAttempt', guardsFor(facts)) ?? 'interacting', numAttempts, adaptive };\n}\n"]}
|
|
@@ -29,6 +29,6 @@ export interface PartSubmission {
|
|
|
29
29
|
*
|
|
30
30
|
* Returns null for a part with individual submission: its items are submitted one by one.
|
|
31
31
|
*
|
|
32
|
-
* Experimental (0.x): roadmap 1 phase T6; see `plans/
|
|
32
|
+
* Experimental (0.x): roadmap 1 phase T6; see `plans/host-api.md` → "A simultaneous part is a paper exam".
|
|
33
33
|
*/
|
|
34
34
|
export declare function submitTestPart(items: readonly PartSubmissionItem[]): PartSubmission | null;
|
|
@@ -12,7 +12,7 @@ const OVER = new Set(['closed', 'review', 'solution']);
|
|
|
12
12
|
*
|
|
13
13
|
* Returns null for a part with individual submission: its items are submitted one by one.
|
|
14
14
|
*
|
|
15
|
-
* Experimental (0.x): roadmap 1 phase T6; see `plans/
|
|
15
|
+
* Experimental (0.x): roadmap 1 phase T6; see `plans/host-api.md` → "A simultaneous part is a paper exam".
|
|
16
16
|
*/
|
|
17
17
|
export function submitTestPart(items) {
|
|
18
18
|
if (items.some(({ facts }) => facts.submissionMode !== 'simultaneous'))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"part-submission.js","sourceRoot":"","sources":["../../src/lifecycle/part-submission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAqBzF,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,KAAoC;IACjE,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,KAAK,cAAc,CAAC;QAAE,OAAO,IAAI,CAAC;IACpF,MAAM,QAAQ,GAA+B,EAAE,CAAC;IAChD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAC3B,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;YACtF,SAAS;QACX,CAAC;QACD,oGAAoG;QACpG,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,gBAAgB,KAAK,eAAe,CAAC;QACjF,MAAM,MAAM,GAAG,mBAAmB,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3F,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI;YACJ,OAAO,EAAE;gBACP,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,CAAC,IAAI,QAAQ;gBAC9D,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjD,QAAQ;aACT;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import { seedItemLifecycle, transition, itemLifecycleGuards } from './item-lifecycle.js';\n\nimport type { Effect } from '../state/commands.js';\nimport type { ItemInstanceId } from '../state/delivery-state.js';\nimport type { ItemSession, ItemSessionFacts } from './item-session.js';\n\n/** One item session of the part being submitted: its instance, its session so far, and its facts now. */\nexport interface PartSubmissionItem {\n readonly item: ItemInstanceId;\n /** The session as the delivery kept it; null when it has none yet (a restored state). */\n readonly previous: ItemSession | null;\n readonly facts: ItemSessionFacts;\n}\n\n/** The part's item sessions after the submission, in the order given, and what the runtime has to run. */\nexport interface PartSubmission {\n readonly sessions: { readonly item: ItemInstanceId; readonly session: ItemSession }[];\n /** `runOutcomeProcessing` once, after the items. */\n readonly effects: Effect[];\n}\n\nconst OVER = new Set(['closed', 'review', 'solution']);\n\n/**\n * Submits a part with simultaneous submission as a whole (QTI 3 info model §2.8.2, implementation\n * guide §4.1): \"response processing cannot take place until the test part is complete\", and then\n * the candidate's responses \"are all submitted together\". Each item the candidate opened has its one\n * and only attempt counted and its session closes. Its responses were already processed in the\n * background while the part ran, without ending the attempt (the paper-exam model, decided\n * 2026-12-01), so nothing is processed again here. An item never opened (`completionStatus`\n * `not_attempted`) is closed with its NULL responses and counts no attempt, as a skipped item is. A\n * session already over is left as it is. Outcome processing runs once, after the items (§2.9).\n *\n * Returns null for a part with individual submission: its items are submitted one by one.\n *\n * Experimental (0.x): roadmap 1 phase T6; see `plans/
|
|
1
|
+
{"version":3,"file":"part-submission.js","sourceRoot":"","sources":["../../src/lifecycle/part-submission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAqBzF,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,KAAoC;IACjE,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,KAAK,cAAc,CAAC;QAAE,OAAO,IAAI,CAAC;IACpF,MAAM,QAAQ,GAA+B,EAAE,CAAC;IAChD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAC3B,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;YACtF,SAAS;QACX,CAAC;QACD,oGAAoG;QACpG,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,gBAAgB,KAAK,eAAe,CAAC;QACjF,MAAM,MAAM,GAAG,mBAAmB,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3F,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI;YACJ,OAAO,EAAE;gBACP,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,CAAC,IAAI,QAAQ;gBAC9D,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjD,QAAQ;aACT;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import { seedItemLifecycle, transition, itemLifecycleGuards } from './item-lifecycle.js';\n\nimport type { Effect } from '../state/commands.js';\nimport type { ItemInstanceId } from '../state/delivery-state.js';\nimport type { ItemSession, ItemSessionFacts } from './item-session.js';\n\n/** One item session of the part being submitted: its instance, its session so far, and its facts now. */\nexport interface PartSubmissionItem {\n readonly item: ItemInstanceId;\n /** The session as the delivery kept it; null when it has none yet (a restored state). */\n readonly previous: ItemSession | null;\n readonly facts: ItemSessionFacts;\n}\n\n/** The part's item sessions after the submission, in the order given, and what the runtime has to run. */\nexport interface PartSubmission {\n readonly sessions: { readonly item: ItemInstanceId; readonly session: ItemSession }[];\n /** `runOutcomeProcessing` once, after the items. */\n readonly effects: Effect[];\n}\n\nconst OVER = new Set(['closed', 'review', 'solution']);\n\n/**\n * Submits a part with simultaneous submission as a whole (QTI 3 info model §2.8.2, implementation\n * guide §4.1): \"response processing cannot take place until the test part is complete\", and then\n * the candidate's responses \"are all submitted together\". Each item the candidate opened has its one\n * and only attempt counted and its session closes. Its responses were already processed in the\n * background while the part ran, without ending the attempt (the paper-exam model, decided\n * 2026-12-01), so nothing is processed again here. An item never opened (`completionStatus`\n * `not_attempted`) is closed with its NULL responses and counts no attempt, as a skipped item is. A\n * session already over is left as it is. Outcome processing runs once, after the items (§2.9).\n *\n * Returns null for a part with individual submission: its items are submitted one by one.\n *\n * Experimental (0.x): roadmap 1 phase T6; see `plans/host-api.md` → \"A simultaneous part is a paper exam\".\n */\nexport function submitTestPart(items: readonly PartSubmissionItem[]): PartSubmission | null {\n if (items.some(({ facts }) => facts.submissionMode !== 'simultaneous')) return null;\n const sessions: PartSubmission['sessions'] = [];\n const effects: Effect[] = [];\n for (const { item, previous, facts } of items) {\n const { adaptive } = facts;\n const state = previous?.state ?? seedItemLifecycle(facts);\n if (OVER.has(state)) {\n sessions.push({ item, session: { state, numAttempts: facts.numAttempts, adaptive } });\n continue;\n }\n // A restored session not on screen seeds as `initial`; `completionStatus` still says it was opened.\n const opened = state !== 'initial' || facts.completionStatus !== 'not_attempted';\n const guards = itemLifecycleGuards({ ...facts, left: facts.passed, modalFeedback: false });\n sessions.push({\n item,\n session: {\n state: transition(state, 'endItemSession', guards) ?? 'closed',\n numAttempts: facts.numAttempts + (opened ? 1 : 0),\n adaptive\n }\n });\n }\n effects.push({ type: 'runOutcomeProcessing' });\n return { sessions, effects };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qti-components/delivery",
|
|
3
3
|
"description": "The QTI 3 delivery engine: test model, item session lifecycle, sequencing and session state, with no browser globals",
|
|
4
|
-
"version": "0.1.0-next.
|
|
4
|
+
"version": "0.1.0-next.13",
|
|
5
5
|
"author": "",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"qti",
|