@qti-components/delivery 0.1.0-next.7 → 0.1.0-next.8

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.
@@ -52,11 +52,16 @@ export interface ItemRules {
52
52
  * `show-solution`. False in `solution` itself; whether the solution shows is the state.
53
53
  */
54
54
  readonly mayBeginSolution: boolean;
55
+ /**
56
+ * The candidate may set a comment on the item now: `allow-comment`, while `interacting`. The
57
+ * comment is not assessed; QTI leaves capturing it to the delivery (§7.19, `allow-comment`).
58
+ */
59
+ readonly mayComment: boolean;
55
60
  }
56
61
  /** What the rules of one item session are read from: its lifecycle input, its state and its responses. */
57
62
  export interface ItemRulesInput extends Omit<ItemLifecycleInput, 'sessionControl'> {
58
63
  /** The item-ref's resolved session control (`ItemRefModel.sessionControl`). */
59
- sessionControl: Omit<SessionControl, 'allowComment'>;
64
+ sessionControl: SessionControl;
60
65
  /** The item session's lifecycle state. */
61
66
  state: ItemLifecycleState;
62
67
  /**
@@ -18,7 +18,8 @@ export function itemRules(input) {
18
18
  sessionControl.showFeedback ||
19
19
  (state === 'review' && adaptive && sessionControl.allowReview),
20
20
  mayBeginReview: transition(state, 'beginReview', guards) !== null,
21
- mayBeginSolution: transition(state, 'beginSolution', guards) !== null
21
+ mayBeginSolution: transition(state, 'beginSolution', guards) !== null,
22
+ mayComment: sessionControl.allowComment && state === 'interacting'
22
23
  };
23
24
  }
24
25
  /** The navigation answers of a part. Pure. */
@@ -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;AA0EtE,mGAAmG;AACnG,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAClD,MAAM,MAAM,GAAG,mBAAmB,CAAC,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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`).\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\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: Omit<SessionControl, 'allowComment'>;\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 return {\n attemptsLeft: guards.attemptsLeft,\n attemptsUsed: !guards.attemptsLeft,\n interactive: state === 'interacting',\n done: state === 'closed' || state === 'review' || state === 'solution',\n mayEndAttempt: maySubmit && transition(state, 'endAttempt', guards) !== null,\n maySubmit,\n maySkip,\n mayShowFeedback:\n guards.attemptsLeft ||\n sessionControl.showFeedback ||\n (state === 'review' && adaptive && sessionControl.allowReview),\n mayBeginReview: transition(state, 'beginReview', guards) !== null,\n mayBeginSolution: transition(state, 'beginSolution', guards) !== null\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"]}
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;AA+EtE,mGAAmG;AACnG,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAClD,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,MAAM,CAAC,oBAAoB,CAAC;IAC/C,MAAM,OAAO,GAAG,CAAC,UAAU,IAAI,cAAc,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAC9E,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,cAAc,CAAC,iBAAiB,IAAI,KAAK,CA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esContent":["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`).\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 return {\n attemptsLeft: guards.attemptsLeft,\n attemptsUsed: !guards.attemptsLeft,\n interactive: state === 'interacting',\n done: state === 'closed' || state === 'review' || state === 'solution',\n mayEndAttempt: maySubmit && transition(state, 'endAttempt', guards) !== null,\n maySubmit,\n maySkip,\n mayShowFeedback:\n guards.attemptsLeft ||\n sessionControl.showFeedback ||\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"]}
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.7",
4
+ "version": "0.1.0-next.8",
5
5
  "author": "",
6
6
  "keywords": [
7
7
  "qti",