@pie-qti/assessment-player 1.0.0-beta.1 → 1.0.0-beta.3

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.
@@ -8,7 +8,7 @@
8
8
  * - Apply backend navigation decisions + session state
9
9
  */
10
10
  import { type AssessmentItemDefinitionPlugin, type ItemSession, type PciConfiguration, type PnpProfile, type PlayerSecurityConfig, type QTIRole, type SerializedItemSessionState } from '@pie-qti/item-player';
11
- import type { I18nProvider } from '@pie-qti/i18n';
11
+ import { type I18nProvider } from '@pie-qti/i18n';
12
12
  import type { QtiSectionRuntimeHostContract, QtiSectionToolConfig } from '@pie-qti/section-player';
13
13
  import type { AssessmentRubricBlock, AssessmentSessionState, BackendAdapter, InitSessionRequest, SecureItemRef } from '../integration/api-contract.js';
14
14
  import type { AssessmentResults, ItemResult, NavigationState, TimeLimits, VisibleTestFeedback } from '../types/index.js';
@@ -267,7 +267,8 @@ export declare class AssessmentPlayer {
267
267
  */
268
268
  getI18nProvider(): I18nProvider;
269
269
  /**
270
- * Create a simple fallback i18n provider when none is provided
270
+ * The provider used when the host passes none: English, from the catalog
271
+ * `@pie-qti/i18n` bundles eagerly.
271
272
  */
272
273
  private createDefaultI18nProvider;
273
274
  }
@@ -8,6 +8,7 @@
8
8
  * - Apply backend navigation decisions + session state
9
9
  */
10
10
  import { createAssessmentItemDefinition, } from '@pie-qti/item-player';
11
+ import { DefaultI18nProvider } from '@pie-qti/i18n';
11
12
  import { isShownByIdentifier } from '@pie-qti/qti-common';
12
13
  import { AssessmentSessionCoordinator } from './AssessmentSessionCoordinator.js';
13
14
  import { NavigationManager } from './NavigationManager.js';
@@ -1143,17 +1144,11 @@ export class AssessmentPlayer {
1143
1144
  return this.i18nProvider;
1144
1145
  }
1145
1146
  /**
1146
- * Create a simple fallback i18n provider when none is provided
1147
+ * The provider used when the host passes none: English, from the catalog
1148
+ * `@pie-qti/i18n` bundles eagerly.
1147
1149
  */
1148
1150
  createDefaultI18nProvider() {
1149
- return {
1150
- getLocale: () => 'en-US',
1151
- setLocale: () => { },
1152
- t: (key) => key, // Fallback to key
1153
- plural: (key) => key,
1154
- formatNumber: (value) => value.toString(),
1155
- formatDate: (date) => date.toISOString(),
1156
- };
1151
+ return new DefaultI18nProvider('en-US');
1157
1152
  }
1158
1153
  }
1159
1154
  function cloneData(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"AssessmentPlayer.js","sourceRoot":"","sources":["../../src/core/AssessmentPlayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,8BAA8B,GAS9B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAyB1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA8GhE,MAAM,OAAO,gBAAgB;IACrB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAqC;QAC/D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClE,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAiCD,YAA4B,MAAqC,EAAE,IAAyB;QAAhE,WAAM,GAAN,MAAM,CAA+B;QAxBzD,gBAAW,GAAuB,IAAI,CAAC;QAEvC,UAAK,GAAe,EAAE,CAAC;QACvB,qBAAgB,GAAG,CAAC,CAAC,CAAC;QACb,oBAAe,GAAG,IAAI,GAAG,EAAoC,CAAC;QACvE,uB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Ac;IAC/B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACpD,CAAC;AAED,SAAS,uBAAuB,CAAC,eAA8D;IAC9F,OAAO,eAAe,KAAK,SAAS,IAAI,eAAe,KAAK,aAAa,CAAC;AAC3E,CAAC","sourcesContent":["/**\n * AssessmentPlayer (backend-authoritative)\n *\n * Client responsibilities:\n * - Render items using @pie-qti/item-player\n * - Collect candidate responses\n * - Submit responses to BackendAdapter\n * - Apply backend navigation decisions + session state\n */\n\nimport {\n\tcreateAssessmentItemDefinition,\n\ttype AssessmentItemDefinition,\n\ttype AssessmentItemDefinitionPlugin,\n\ttype ItemSession,\n\ttype PciConfiguration,\n\ttype PnpProfile,\n\ttype PlayerSecurityConfig,\n\ttype QTIRole,\n\ttype SerializedItemSessionState,\n} from '@pie-qti/item-player';\nimport type { I18nProvider } from '@pie-qti/i18n';\nimport { isShownByIdentifier } from '@pie-qti/qti-common';\nimport type { QtiSectionRuntimeHostContract, QtiSectionToolConfig } from '@pie-qti/section-player';\nimport type {\n\tAssessmentRubricBlock,\n\tAssessmentSessionState,\n\tAssessmentScoringResult,\n\tBackendAdapter,\n\tFinalizeAssessmentResponse,\n\tInitSessionRequest,\n\tInitSessionResponse,\n\tSecureAssessment,\n\tSecureItemRef,\n\tSecureSection,\n\tSecureTestPart,\n\tSessionId,\n\tTestFeedbackItem,\n\tTestOutcomeValues,\n} from '../integration/api-contract.js';\nimport type {\n\tAssessmentResults,\n\tItemResult,\n\tNavigationState,\n\tTimeLimits,\n\tVisibleTestFeedback,\n} from '../types/index.js';\nimport { AssessmentSessionCoordinator } from './AssessmentSessionCoordinator.js';\nimport { NavigationManager } from './NavigationManager.js';\nimport {\n\tdeliveredItems,\n\tevaluateTestExpression,\n\tisAdaptiveItemXml,\n\tplainQtiValue,\n\tresolveItemSessionControl,\n\tsectionComponents,\n\ttestOutcomeDeclarations,\n} from './testStructure.js';\nimport { extendTimeLimit, TimeManager } from './TimeManager.js';\n\nexport interface BackendAssessmentPlayerConfig {\n\tbackend: BackendAdapter;\n\tinitSession: InitSessionRequest;\n\trole?: QTIRole;\n\t/**\n\t * @deprecated Ignored. The backend draws selection and ordering at session start; pass an rng to\n\t * `new ReferenceBackendAdapter({ rng })` for deterministic draws.\n\t */\n\trng?: () => number;\n\t/** Definition-lifetime extractor and renderer extensions applied to every item. */\n\tplugins?: readonly AssessmentItemDefinitionPlugin[];\n\t/**\n\t * Shared catalog files the package manifest lists (resource type\n\t * `imsqti_catalog_xmlv3p0`), read by the host that loaded the package. When the\n\t * reference backend parses the assessment test they become package-scope\n\t * catalog sources beneath item-level catalogs (QTI 3.0 §6.3).\n\t */\n\tsharedCatalogs?: ReadonlyArray<{ href?: string; xml?: string }>;\n\t/**\n\t * Optional i18n provider for internationalization.\n\t * If provided, this will be shared across all item players in the assessment.\n\t */\n\ti18nProvider?: I18nProvider;\n\t/**\n\t * Security configuration for URL policy and content restrictions.\n\t * If provided, this will be passed to all item players in the assessment.\n\t */\n\tsecurity?: PlayerSecurityConfig;\n\t/**\n\t * Explicit host trust configuration for Portable Custom Interaction modules.\n\t * Without this resolver, authored PCI code remains disabled.\n\t */\n\tpci?: PciConfiguration;\n\t/**\n\t * Optional host hooks for delegated section rendering.\n\t * Used for section shared-content URL policy and runtime callbacks.\n\t */\n\tsectionHost?: QtiSectionRuntimeHostContract;\n\t/** Optional section-scoped tools rendered by delegated section players. */\n\tsectionTools?: QtiSectionToolConfig[];\n\t/** Optional tools rendered in passage/rubric headers. */\n\tpassageTools?: QtiSectionToolConfig[];\n\t/** Optional tools rendered in item headers. */\n\titemTools?: QtiSectionToolConfig[];\n\t/**\n\t * Demo/reference-only escape hatch. When false (default), rich item-session\n\t * variables stay client-local and are not submitted because template variables\n\t * can contain answer keys. Production backends should own this state server-side.\n\t */\n\tsendItemSessionToBackend?: boolean;\n\t// UI options\n\tshowSections?: boolean;\n\tallowSectionNavigation?: boolean;\n\tshowProgress?: boolean;\n\t// Time management\n\ttimeWarningThreshold?: number;\n\t/**\n\t * Deterministic clock for time-limit tracking. Defaults to Date.now; intended for\n\t * tests and hosts that drive delivery from their own timeline.\n\t */\n\tnow?: () => number;\n\t/**\n\t * QTI 3.0 §6.2 Personal Needs and Preferences profile.\n\t * Extended time (pnp.content.extendedTime) is applied to assessment timeLimits.\n\t * The full profile is passed down to each item player for component-level features\n\t * (color scheme, elimination tool).\n\t */\n\tpnp?: PnpProfile;\n\t// Callbacks\n\tonItemChange?: (itemIndex: number, totalItems: number) => void;\n\tonSectionChange?: (sectionIndex: number, totalSections: number) => void;\n\tonResponseChange?: (responses: Record<string, unknown>) => void;\n\tonComplete?: () => void;\n}\n\ntype FlatItem = {\n\tidentifier: string;\n\titem: SecureItemRef;\n\t/** Innermost enclosing section. */\n\tsection: SecureSection;\n\t/** Enclosing sections, outermost first. */\n\tsections: SecureSection[];\n\ttestPart: SecureTestPart;\n\tindex: number;\n\tsectionIndex: number;\n};\n\ntype CurrentItemView = {\n\tidentifier: string;\n\ttitle?: string;\n\trequired?: boolean;\n\titemXml: string;\n\tdeliveryContext?: SecureItemRef['deliveryContext'];\n};\n\ntype SectionItemRefView = {\n\tidentifier: string;\n\thref?: string;\n\ttitle?: string;\n\titemXml: string;\n\tdeliveryContext?: SecureItemRef['deliveryContext'];\n};\n\nexport interface EffectiveItemTimeLimits {\n\ttimeLimits?: TimeLimits;\n\tsource?: 'item' | 'section' | 'testPart' | 'assessment';\n}\n\nexport class AssessmentPlayer {\n\tpublic static async create(config: BackendAssessmentPlayerConfig): Promise<AssessmentPlayer> {\n\t\tconst init = await config.backend.initSession(config.initSession);\n\t\treturn new AssessmentPlayer(config, init);\n\t}\n\n\tprivate backend: BackendAdapter;\n\tprivate sessionId: SessionId;\n\tprivate assessment: SecureAssessment;\n\tprivate i18nProvider: I18nProvider;\n\n\tprivate navigationManager: NavigationManager;\n\tprivate sessionCoordinator!: AssessmentSessionCoordinator;\n\tprivate timeManager: TimeManager | null = null;\n\n\tprivate items: FlatItem[] = [];\n\tprivate currentItemIndex = -1;\n\tprivate readonly itemDefinitions = new Map<string, AssessmentItemDefinition>();\n\tprivate currentItemSession: ItemSession | null = null;\n\tprivate currentItemSessionUnsubscribe: (() => void) | null = null;\n\t/** Test-level outcomes from the last outcome processing; null until it first runs. */\n\tprivate testOutcomes: TestOutcomeValues | null = null;\n\tprivate finalized = false;\n\t/** Scopes whose time limit expired without late submission, keyed `scope:identifier`. */\n\tprivate readonly lockedScopes = new Set<string>();\n\tprivate legacyFeedback: string | undefined;\n\n\t// Event listeners\n\tprivate itemChangeListeners = new Set<(index: number, total: number) => void>();\n\tprivate sectionChangeListeners = new Set<(index: number, total: number) => void>();\n\tprivate responseChangeListeners = new Set<(responses: Record<string, unknown>) => void>();\n\tprivate completeListeners = new Set<() => void>();\n\tprivate testFeedbackChangeListeners = new Set<() => void>();\n\tprivate timeWarningListeners = new Set<(remainingSeconds: number) => void>();\n\tprivate timeExpiredListeners = new Set<() => void>();\n\tprivate timeTickListeners = new Set<(remainingSeconds: number, elapsedSeconds: number) => void>();\n\n\tprivate constructor(private config: BackendAssessmentPlayerConfig, init: InitSessionResponse) {\n\t\tthis.backend = config.backend;\n\t\tthis.sessionId = init.sessionId;\n\t\tthis.assessment = init.assessment;\n\t\tthis.testOutcomes = init.outcomes ? cloneData(init.outcomes)! : null;\n\t\tthis.i18nProvider = config.i18nProvider ?? this.createDefaultI18nProvider();\n\t\tconst initialState =\n\t\t\tinit.restoredState ??\n\t\t\t({\n\t\t\t\tcurrentItemIdentifier: init.currentItemIdentifier ?? '',\n\t\t\t\tvisitedItems: [],\n\t\t\t\titemResponses: {},\n\t\t\t\titemScores: {},\n\t\t\t\titemSessions: {},\n\t\t\t\ttiming: { startedAt: Date.now(), itemTimes: {}, totalTime: 0 },\n\t\t\t} as AssessmentSessionState);\n\n\t\tthis.items = this.flattenItems(this.assessment);\n\n\t\tconst navigationMode = this.assessment.navigationMode || 'nonlinear';\n\t\tthis.navigationManager = new NavigationManager(navigationMode, this.items.length);\n\n\t\t// Item session control is a UI hint; backend remains authoritative.\n\t\tthis.sessionCoordinator = new AssessmentSessionCoordinator({\n\t\t\tstate: initialState,\n\t\t\titemIdentifiers: this.items.map((q) => q.identifier),\n\t\t\titemSessionControlByItem: Object.fromEntries(\n\t\t\t\tthis.items.map((q) => [q.identifier, resolveItemSessionControl(q.testPart, q.sections, q.item)]),\n\t\t\t),\n\t\t});\n\n\t\tthis.timeManager = new TimeManager({\n\t\t\tassessmentTimeLimits: this.assessment.timeLimits,\n\t\t\twarningThreshold: config.timeWarningThreshold || 60,\n\t\t\tnow: config.now,\n\t\t\textendedTime: config.pnp?.content?.extendedTime,\n\t\t\tonWarning: (remainingSeconds) => this.notifyTimeWarning(remainingSeconds),\n\t\t\tonExpired: () => this.notifyTimeExpired(),\n\t\t\tonScopeExpired: (scope, identifier) => this.handleScopeExpired(scope, identifier),\n\t\t\tonTick: (remainingSeconds, elapsedSeconds) => this.notifyTimeTick(remainingSeconds, elapsedSeconds),\n\t\t});\n\t\tif (init.restoredState?.timing) {\n\t\t\tthis.restoreTimeTracking(init.restoredState.timing);\n\t\t}\n\n\t\t// Restore to backend-provided current item if present\n\t\tconst startId = this.state.currentItemIdentifier;\n\t\tconst idx = startId ? this.items.findIndex((q) => q.identifier === startId) : -1;\n\t\tif (idx >= 0) {\n\t\t\tthis.navigateTo(idx, { restoring: true }).catch(() => {});\n\t\t} else if (this.items.length > 0) {\n\t\t\tthis.navigateTo(0, { restoring: true }).catch(() => {});\n\t\t}\n\t}\n\n\tprivate get state(): AssessmentSessionState {\n\t\treturn this.sessionCoordinator.state;\n\t}\n\n\tprivate set state(state: AssessmentSessionState) {\n\t\tthis.sessionCoordinator.restoreState(state);\n\t}\n\n\tprivate getEffectiveItemTimeLimits(flat: FlatItem): EffectiveItemTimeLimits {\n\t\tconst scopes: Array<{ source: EffectiveItemTimeLimits['source']; limits?: TimeLimits }> = [\n\t\t\t{ source: 'assessment', limits: this.assessment.timeLimits },\n\t\t\t{ source: 'testPart', limits: flat.testPart.timeLimits },\n\t\t\t{ source: 'section', limits: flat.section.timeLimits },\n\t\t\t{ source: 'item', limits: flat.item.timeLimits },\n\t\t];\n\t\tlet source: EffectiveItemTimeLimits['source'];\n\t\tlet minTime: number | undefined;\n\t\tlet maxTime: number | undefined;\n\t\tlet allowLateSubmission: boolean | undefined;\n\t\tfor (const scope of scopes) {\n\t\t\tif (!scope.limits) continue;\n\t\t\tif (scope.limits.minTime !== undefined) {\n\t\t\t\tminTime = minTime === undefined ? scope.limits.minTime : Math.max(minTime, scope.limits.minTime);\n\t\t\t}\n\t\t\tif (scope.limits.maxTime !== undefined) {\n\t\t\t\tconst scopedMaxTime = extendTimeLimit(scope.limits.maxTime, this.config.pnp?.content?.extendedTime);\n\t\t\t\tif (scopedMaxTime !== undefined && (maxTime === undefined || scopedMaxTime < maxTime)) {\n\t\t\t\t\tmaxTime = scopedMaxTime;\n\t\t\t\t\tsource = scope.source;\n\t\t\t\t\tallowLateSubmission = scope.limits.allowLateSubmission;\n\t\t\t\t}\n\t\t\t} else if (scope.limits.allowLateSubmission !== undefined && maxTime === undefined) {\n\t\t\t\tallowLateSubmission = scope.limits.allowLateSubmission;\n\t\t\t\tsource = scope.source;\n\t\t\t}\n\t\t}\n\n\t\tif (maxTime === undefined && minTime === undefined && allowLateSubmission === undefined) {\n\t\t\treturn {};\n\t\t}\n\t\treturn { source, timeLimits: { minTime, maxTime, allowLateSubmission } };\n\t}\n\n\tpublic getCurrentEffectiveTimeLimits(): EffectiveItemTimeLimits {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\treturn q ? this.getEffectiveItemTimeLimits(q) : {};\n\t}\n\n\tprivate getSubmitTimingEvidence(q: FlatItem, elapsedMs: number): import('../integration/api-contract.js').SubmitTimingEvidence | undefined {\n\t\tconst effective = this.getEffectiveItemTimeLimits(q);\n\t\tconst limitSeconds = effective.timeLimits?.maxTime;\n\t\tif (!effective.source || limitSeconds === undefined) return undefined;\n\t\tconst scopeIdentifier = effective.source === 'item'\n\t\t\t? q.identifier\n\t\t\t: effective.source === 'section'\n\t\t\t\t? q.section.identifier\n\t\t\t\t: effective.source === 'testPart'\n\t\t\t\t\t? q.testPart.identifier\n\t\t\t\t\t: undefined;\n\t\tconst tracked = this.timeManager?.getScopeElapsedMs(effective.source, scopeIdentifier);\n\t\tconst scopedElapsedMs = tracked ?? elapsedMs;\n\t\treturn {\n\t\t\tscope: effective.source,\n\t\t\telapsedMs: scopedElapsedMs,\n\t\t\tlimitSeconds,\n\t\t\texpired: scopedElapsedMs >= limitSeconds * 1000,\n\t\t\tallowLateSubmission: effective.timeLimits?.allowLateSubmission,\n\t\t};\n\t}\n\n\tprivate assertMinimumTime(scope: 'assessment' | 'testPart' | 'section' | 'item', q: FlatItem): void {\n\t\tconst limits = scope === 'assessment'\n\t\t\t? this.assessment.timeLimits\n\t\t\t: scope === 'testPart'\n\t\t\t\t? q.testPart.timeLimits\n\t\t\t\t: scope === 'section'\n\t\t\t\t\t? q.section.timeLimits\n\t\t\t\t\t: q.item.timeLimits;\n\t\tif (limits?.minTime === undefined) return;\n\t\tconst identifier = scope === 'testPart'\n\t\t\t? q.testPart.identifier\n\t\t\t: scope === 'section'\n\t\t\t\t? q.section.identifier\n\t\t\t\t: scope === 'item'\n\t\t\t\t\t? q.identifier\n\t\t\t\t\t: undefined;\n\t\tconst elapsedMs = this.timeManager?.getScopeElapsedMs(scope, identifier) ?? 0;\n\t\tif (elapsedMs < limits.minTime * 1000) {\n\t\t\tconst remaining = Math.ceil(limits.minTime - elapsedMs / 1000);\n\t\t\tthrow new Error(`The ${scope} minimum time has not elapsed (${remaining}s remaining).`);\n\t\t}\n\t}\n\n\tprivate assertTransitionMinimum(current: FlatItem, target: FlatItem): void {\n\t\tif (current === target) return;\n\t\tthis.assertMinimumTime('item', current);\n\t\tif (current.section.identifier !== target.section.identifier) this.assertMinimumTime('section', current);\n\t\tif (current.testPart !== target.testPart) this.assertMinimumTime('testPart', current);\n\t}\n\n\tprivate flattenItems(assessment: SecureAssessment): FlatItem[] {\n\t\tconst sectionIndexes = new Map(this.getAllSections().map((section) => [section.id, section.index]));\n\t\treturn deliveredItems(assessment).map(({ item, testPart, sections }, index) => {\n\t\t\tconst section = sections[sections.length - 1];\n\t\t\treturn {\n\t\t\t\tidentifier: item.identifier,\n\t\t\t\titem,\n\t\t\t\tsection,\n\t\t\t\tsections,\n\t\t\t\ttestPart,\n\t\t\t\tindex,\n\t\t\t\tsectionIndex: sectionIndexes.get(section.identifier) ?? 0,\n\t\t\t};\n\t\t});\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Public API used by components\n\t// ---------------------------------------------------------------------------\n\n\tpublic getAllSections(): Array<{ id: string; title?: string; visible: boolean; index: number }> {\n\t\tconst out: Array<{ id: string; title?: string; visible: boolean; index: number }> = [];\n\t\tconst seen = new Set<string>();\n\t\tconst visit = (section: SecureSection): void => {\n\t\t\t// A keepTogether=\"false\" section mixed into its parent's shuffle appears as several fragments.\n\t\t\tif (!seen.has(section.identifier)) {\n\t\t\t\tseen.add(section.identifier);\n\t\t\t\tout.push({ id: section.identifier, title: section.title, visible: section.visible, index: out.length });\n\t\t\t}\n\t\t\tfor (const component of sectionComponents(section)) {\n\t\t\t\tif (component.type === 'section') visit(component.section);\n\t\t\t}\n\t\t};\n\t\tfor (const tp of this.assessment.testParts || []) {\n\t\t\tfor (const section of tp.sections || []) visit(section);\n\t\t}\n\t\treturn out;\n\t}\n\n\tpublic getNavigationState(): NavigationState {\n\t\tconst total = this.items.length;\n\t\tconst canPrevious = this.canPrevious();\n\t\tconst canNext = this.canNext();\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tconst totalSections = this.getAllSections().length;\n\t\treturn {\n\t\t\tcurrentIndex: this.currentItemIndex,\n\t\t\ttotalItems: total,\n\t\t\tcanNext,\n\t\t\tcanPrevious,\n\t\t\tisLoading: false,\n\t\t\tcurrentSection: q\n\t\t\t\t? { id: q.section.identifier, title: q.section.title, index: q.sectionIndex }\n\t\t\t\t: undefined,\n\t\t\ttotalSections,\n\t\t};\n\t}\n\n\tpublic getCurrentItem(): CurrentItemView | null {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return null;\n\t\treturn {\n\t\t\tidentifier: q.item.identifier,\n\t\t\ttitle: q.section.title,\n\t\t\trequired: q.item.required,\n\t\t\titemXml: q.item.itemXml,\n\t\t\tdeliveryContext: q.item.deliveryContext,\n\t\t};\n\t}\n\n\t/**\n\t * The one authoritative live session for the active item.\n\t *\n\t * Section and item renderers receive this exact instance. Serialized item-session\n\t * state is reserved for persistence and restore, never for synchronizing a second\n\t * live player.\n\t */\n\tpublic getCurrentItemSession(): ItemSession | null {\n\t\treturn this.currentItemSession;\n\t}\n\n\tpublic getCurrentSectionItemRefs(): SectionItemRefView[] {\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (!current) return [];\n\n\t\treturn this.items\n\t\t\t.filter((item) => item.section.identifier === current.section.identifier)\n\t\t\t.map((item) => {\n\t\t\t\tconst itemRef = item.item as SecureItemRef & { href?: string; title?: string };\n\t\t\t\treturn {\n\t\t\t\t\tidentifier: itemRef.identifier,\n\t\t\t\t\thref: itemRef.href,\n\t\t\t\t\ttitle: itemRef.title,\n\t\t\t\t\titemXml: itemRef.itemXml,\n\t\t\t\t\tdeliveryContext: cloneData(itemRef.deliveryContext),\n\t\t\t\t};\n\t\t\t});\n\t}\n\n\tpublic getResponsesForItem(itemIdentifier: string): Record<string, unknown> {\n\t\treturn cloneData(this.sessionCoordinator.getResponses(itemIdentifier)) ?? {};\n\t}\n\n\tpublic getCurrentSharedRubricBlocks(): AssessmentRubricBlock[] {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return [];\n\n\t\treturn [\n\t\t\t...(q.testPart.rubricBlocks ?? []),\n\t\t\t...(q.section.rubricBlocks ?? []),\n\t\t].map((block) => ({ ...block, view: [...block.view] }));\n\t}\n\n\tpublic getCurrentRubricBlocks(): AssessmentRubricBlock[] {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return [];\n\t\treturn q.section.rubricBlocks || q.testPart.rubricBlocks || [];\n\t}\n\n\t/**\n\t * Test feedback shown now, test-level first, then each test part's. Nothing shows before outcome\n\t * processing first runs. `during` feedback then shows by its outcome, test-part `during`\n\t * feedback while its part is current; `atEnd` feedback shows once the test, or its test part,\n\t * has ended.\n\t */\n\tpublic getVisibleFeedback(): VisibleTestFeedback[] {\n\t\tconst outcomes = this.testOutcomes;\n\t\tconst parts = this.assessment.testParts ?? [];\n\t\tconst hasStructured =\n\t\t\t(this.assessment.testFeedback?.length ?? 0) > 0 || parts.some((part) => (part.testFeedback?.length ?? 0) > 0);\n\t\tif (!hasStructured) {\n\t\t\treturn this.finalized && this.legacyFeedback\n\t\t\t\t? [{ key: 'testFeedback', identifier: 'testFeedback', content: this.legacyFeedback, access: 'atEnd' }]\n\t\t\t\t: [];\n\t\t}\n\t\tif (!outcomes) return [];\n\n\t\tconst shown: VisibleTestFeedback[] = [];\n\t\tconst add = (items: TestFeedbackItem[] | undefined, ended: boolean, current: boolean, part?: SecureTestPart) => {\n\t\t\titems?.forEach((fb, index) => {\n\t\t\t\tif (fb.access === 'atEnd' ? !ended : !current) return;\n\t\t\t\tif (!isShownByIdentifier(outcomes[fb.outcomeIdentifier] ?? null, fb.identifier, fb.showHide)) return;\n\t\t\t\tshown.push({\n\t\t\t\t\tkey: part ? `part:${part.identifier}:${index}` : `test:${index}`,\n\t\t\t\t\tidentifier: fb.identifier,\n\t\t\t\t\tcontent: fb.content,\n\t\t\t\t\taccess: fb.access,\n\t\t\t\t\t...(part ? { testPartIdentifier: part.identifier } : {}),\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\t\tadd(this.assessment.testFeedback, this.finalized, true);\n\t\tconst currentPart = this.currentTestPartIndex();\n\t\tparts.forEach((part, index) => {\n\t\t\tadd(part.testFeedback, this.finalized || currentPart > index, currentPart === index, part);\n\t\t});\n\t\treturn shown;\n\t}\n\n\tprivate currentTestPartIndex(): number {\n\t\tconst part = this.items[this.currentItemIndex]?.testPart;\n\t\treturn part ? (this.assessment.testParts ?? []).findIndex((p) => p.identifier === part.identifier) : -1;\n\t}\n\n\tprivate setTestOutcomes(outcomes: TestOutcomeValues | undefined): void {\n\t\tif (!outcomes) return;\n\t\tthis.testOutcomes = cloneData(outcomes)!;\n\t\tthis.notifyTestFeedbackChange();\n\t}\n\n\tpublic updateResponse(responseId: string, value: unknown): void {\n\t\tconst active = this.items[this.currentItemIndex];\n\t\tif (!active) return;\n\t\tif (this.currentItemSession) {\n\t\t\tthis.currentItemSession.dispatch({\n\t\t\t\taction: 'setResponse',\n\t\t\t\tresponseIdentifier: responseId,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionCoordinator.updateResponseForItem(active.identifier, responseId, value);\n\t\tthis.notifyResponseChange();\n\t}\n\n\t/**\n\t * Update a response for a specific item.\n\t * Useful when response events are observed outside the current-item renderer and we\n\t * want to be explicit about which item receives the response (some assessments reuse\n\t * the same responseIdentifier like \"RESPONSE\" across items).\n\t */\n\tpublic updateResponseForItem(itemIdentifier: string, responseId: string, value: unknown): void {\n\t\tconst active = this.items[this.currentItemIndex];\n\t\tif (active?.identifier === itemIdentifier && this.currentItemSession) {\n\t\t\tconst liveValue = this.currentItemSession.state().responses[responseId];\n\t\t\tif (!responseValuesEqual(liveValue, value)) {\n\t\t\t\t// Programmatic/host callers still enter through this API. Browser item\n\t\t\t\t// adapters have already dispatched, so their equal value is not applied twice.\n\t\t\t\tthis.currentItemSession.dispatch({\n\t\t\t\t\taction: 'setResponse',\n\t\t\t\t\tresponseIdentifier: responseId,\n\t\t\t\t\tvalue,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst persisted = this.sessionCoordinator.getPersistedItemSession(itemIdentifier);\n\t\tif (persisted && !isWritableItemLifecycle(persisted.lifecycleStatus)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot update responses while item session is ${persisted.lifecycleStatus}`,\n\t\t\t);\n\t\t}\n\n\t\tthis.sessionCoordinator.updateResponseForItem(itemIdentifier, responseId, value);\n\t\tthis.notifyResponseChange();\n\t}\n\n\t/**\n\t * Get current unsaved responses for the active item.\n\t * (Useful for host integrations / web components.)\n\t */\n\tpublic getResponses(): Record<string, unknown> {\n\t\tif (this.currentItemSession) {\n\t\t\treturn cloneData(this.currentItemSession.state().responses) ?? {};\n\t\t}\n\t\treturn this.sessionCoordinator.getActiveResponses();\n\t}\n\n\tpublic saveCurrentItemSession(): SerializedItemSessionState | null {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q || !this.currentItemSession) return null;\n\n\t\tconst currentView = this.currentItemSession.state();\n\t\tconst transition = isWritableItemLifecycle(currentView.lifecycleStatus)\n\t\t\t? this.currentItemSession.dispatch({ action: 'suspendAttempt' })\n\t\t\t: null;\n\t\tconst itemSession = transition?.result?.sessionState ?? this.currentItemSession.serialize();\n\t\tconst responses = cloneData(transition?.current.responses ?? currentView.responses) ?? {};\n\t\tthis.sessionCoordinator.saveItemSession(\n\t\t\tq.identifier,\n\t\t\tresponses,\n\t\t\titemSession,\n\t\t\ttransition?.current.duration ?? currentView.duration,\n\t\t);\n\t\treturn itemSession;\n\t}\n\n\tprivate endItemSessionForSubmit(\n\t\tq: FlatItem,\n\t\tresponses: Record<string, unknown>,\n\t\titemSession?: SerializedItemSessionState,\n\t): SerializedItemSessionState {\n\t\tconst validateResponses = this.sessionCoordinator.mustValidateResponses(q.identifier);\n\t\tconst endAttempt = (session: ItemSession): SerializedItemSessionState => {\n\t\t\tconst result = session.dispatch({ action: 'endAttempt', validateResponses }).result;\n\t\t\tif (result?.validation && !result.validation.valid) {\n\t\t\t\tthrow new Error(result.validation.issues[0]?.message || `Submit failed: invalid response for item ${q.identifier}`);\n\t\t\t}\n\t\t\treturn result?.sessionState ?? session.serialize();\n\t\t};\n\t\tconst active = this.items[this.currentItemIndex];\n\t\tif (\n\t\t\tactive === q &&\n\t\t\tthis.currentItemSession &&\n\t\t\tthis.currentItemSession.state().lifecycleStatus !== 'suspended'\n\t\t) {\n\t\t\treturn endAttempt(this.currentItemSession);\n\t\t}\n\n\t\tconst session = this.getItemDefinition(q).openSession({\n\t\t\trestore: itemSession,\n\t\t\tresponses: itemSession ? undefined : responses,\n\t\t\tactivate: true,\n\t\t});\n\t\ttry {\n\t\t\treturn endAttempt(session);\n\t\t} finally {\n\t\t\tsession.dispose();\n\t\t}\n\t}\n\n\tprivate getItemDefinition(q: FlatItem): AssessmentItemDefinition {\n\t\tconst cached = this.itemDefinitions.get(q.identifier);\n\t\tif (cached) return cached;\n\n\t\tconst definition = createAssessmentItemDefinition({\n\t\t\titemXml: q.item.itemXml,\n\t\t\t// The assessment host chooses the authorized delivery role. Item refs are\n\t\t\t// content records and must not silently widen or narrow session capabilities.\n\t\t\trole: this.config.role ?? 'candidate',\n\t\t\ti18nProvider: this.i18nProvider,\n\t\t\tpnp: this.config.pnp,\n\t\t\tsecurity: this.config.security,\n\t\t\tpci: this.config.pci,\n\t\t\tplugins: this.config.plugins,\n\t\t\tdeliveryContext: q.item.deliveryContext,\n\t\t});\n\t\tthis.itemDefinitions.set(q.identifier, definition);\n\t\treturn definition;\n\t}\n\n\tprivate mirrorSessionResponses(\n\t\titemIdentifier: string,\n\t\tresponses: Readonly<Record<string, unknown>>,\n\t): boolean {\n\t\tconst current = this.sessionCoordinator.getResponses(itemIdentifier);\n\t\tif (responseValuesEqual(current, responses)) return false;\n\n\t\tconst snapshot = cloneResponseRecord(responses);\n\t\tthis.state.itemResponses[itemIdentifier] = snapshot as any;\n\t\tthis.sessionCoordinator.markAnswered(itemIdentifier, snapshot);\n\t\treturn true;\n\t}\n\n\tprivate attachCurrentItemSession(q: FlatItem, session: ItemSession): void {\n\t\tthis.currentItemSession = session;\n\t\tthis.currentItemSessionUnsubscribe = session.subscribe((transition) => {\n\t\t\tif (this.currentItemSession !== session) return;\n\t\t\tif (this.mirrorSessionResponses(q.identifier, transition.current.responses)) {\n\t\t\t\tthis.notifyResponseChange();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate releaseCurrentItemSession(): void {\n\t\tthis.currentItemSessionUnsubscribe?.();\n\t\tthis.currentItemSessionUnsubscribe = null;\n\t\tthis.currentItemSession?.dispose();\n\t\tthis.currentItemSession = null;\n\t}\n\n\t/**\n\t * Get the current session state snapshot (client-side view).\n\t * Note: backend remains authoritative; this is intended for simple save/resume.\n\t */\n\tpublic getState(options: { includeItemSessions?: boolean } = {}): AssessmentSessionState {\n\t\tconst snapshot = this.sessionCoordinator.snapshot(options);\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (options.includeItemSessions && current && this.currentItemSession) {\n\t\t\t// Navigation snapshots may predate edits made after revisiting this item.\n\t\t\t// Serialize the live authority without suspending the learner's attempt.\n\t\t\tsnapshot.itemSessions = {\n\t\t\t\t...snapshot.itemSessions,\n\t\t\t\t[current.identifier]: this.currentItemSession.serialize(),\n\t\t\t};\n\t\t}\n\t\tconst timing = this.timeManager?.getState();\n\t\tif (timing) {\n\t\t\tsnapshot.timing = {\n\t\t\t\tstartedAt: timing.startedAt,\n\t\t\t\titemTimes: { ...timing.itemTimes },\n\t\t\t\tsectionTimes: { ...timing.sectionTimes },\n\t\t\t\ttestPartTimes: { ...timing.testPartTimes },\n\t\t\t\ttotalTime: timing.totalElapsed,\n\t\t\t\tcurrentItemIdentifier: timing.currentItemId,\n\t\t\t\tcurrentSectionIdentifier: timing.currentSectionId,\n\t\t\t\tcurrentTestPartIdentifier: timing.currentTestPartId,\n\t\t\t\tisPaused: timing.isPaused,\n\t\t\t};\n\t\t}\n\t\treturn snapshot;\n\t}\n\n\t/**\n\t * Restore a previously saved session state.\n\t */\n\tpublic async restoreState(state: AssessmentSessionState): Promise<void> {\n\t\tthis.state = state;\n\t\tthis.restoreTimeTracking(state.timing);\n\n\t\t// Restore visited state for UI navigation hints.\n\t\tconst visitedIdx = (state.visitedItems || [])\n\t\t\t.map((id) => this.items.findIndex((q) => q.identifier === id))\n\t\t\t.filter((i) => i >= 0);\n\t\tthis.navigationManager.restoreState(visitedIdx);\n\n\t\tconst currentId = state.currentItemIdentifier;\n\t\tconst idx = currentId ? this.items.findIndex((q) => q.identifier === currentId) : -1;\n\t\tif (idx >= 0) {\n\t\t\tawait this.navigateTo(idx, { restoring: true });\n\t\t} else if (this.items.length > 0) {\n\t\t\tawait this.navigateTo(0, { restoring: true });\n\t\t}\n\t}\n\n\tprivate restoreTimeTracking(timing: AssessmentSessionState['timing']): void {\n\t\tthis.timeManager?.restoreState({\n\t\t\ttotalElapsed: timing.totalTime,\n\t\t\titemTimes: { ...timing.itemTimes },\n\t\t\tsectionTimes: { ...(timing.sectionTimes ?? {}) },\n\t\t\ttestPartTimes: { ...(timing.testPartTimes ?? {}) },\n\t\t\tstartedAt: timing.startedAt,\n\t\t\tcurrentItemId: timing.currentItemIdentifier,\n\t\t\tcurrentSectionId: timing.currentSectionIdentifier,\n\t\t\tcurrentTestPartId: timing.currentTestPartIdentifier,\n\t\t\tisPaused: timing.isPaused === true,\n\t\t});\n\t}\n\n\tpublic async navigateTo(index: number, options: { restoring?: boolean } = {}): Promise<void> {\n\t\tif (index < 0 || index >= this.items.length) throw new Error(`Invalid item index: ${index}`);\n\n\t\t// Enforce navigation rules (UI hints, still backend-authoritative for real deployments).\n\t\tif (!options.restoring && this.currentItemIndex >= 0 && !this.canNavigateByTestPart(index, this.currentItemIndex)) {\n\t\t\tconst currentMode = this.items[this.currentItemIndex]?.testPart.navigationMode ?? this.assessment.navigationMode;\n\t\t\tif (currentMode === 'linear' && index > this.nextUnlockedIndex(this.currentItemIndex)) {\n\t\t\t\tthrow new Error('In linear navigation mode, you can only move to the next question.');\n\t\t\t}\n\t\t\tthrow new Error('Navigation is not allowed.');\n\t\t}\n\t\tconst target = this.items[index];\n\t\tif (!options.restoring && target && this.isItemLocked(target)) {\n\t\t\tthrow new Error('The time limit for this question has expired.');\n\t\t}\n\t\tif (!options.restoring && target && !this.sessionCoordinator.canReview(target.identifier)) {\n\t\t\tthrow new Error('You cannot go back to previous questions in this assessment.');\n\t\t}\n\n\t\tconst currentItem = this.items[this.currentItemIndex];\n\t\tif (!options.restoring && currentItem && target) {\n\t\t\tthis.assertTransitionMinimum(currentItem, target);\n\t\t\tif (currentItem.testPart !== target.testPart\n\t\t\t\t&& (currentItem.testPart.submissionMode ?? this.assessment.submissionMode) === 'simultaneous') {\n\t\t\t\t// Commit this part before leaving it; a failed request keeps the learner\n\t\t\t\t// in the current part so its remaining answers can be retried.\n\t\t\t\tawait this.submitSimultaneousItems(this.items.filter((q) => q.testPart === currentItem.testPart));\n\t\t\t}\n\t\t}\n\t\tif (!options.restoring && this.currentItemIndex === index && this.currentItemSession) {\n\t\t\treturn;\n\t\t}\n\t\tconst currentSessionStatus = currentItem\n\t\t\t? this.currentItemSession?.state().lifecycleStatus ??\n\t\t\t\tthis.state.itemSessions?.[currentItem.identifier]?.lifecycleStatus\n\t\t\t: undefined;\n\t\tif (\n\t\t\t!options.restoring &&\n\t\t\tthis.currentItemIndex >= 0 &&\n\t\t\tthis.currentItemIndex !== index &&\n\t\t\tcurrentSessionStatus !== 'closed'\n\t\t) {\n\t\t\tthis.saveCurrentItemSession();\n\t\t}\n\t\tif (currentItem && this.currentItemIndex !== index) {\n\t\t\tthis.timeManager?.endItem(currentItem.identifier);\n\t\t}\n\n\t\tthis.currentItemIndex = index;\n\t\tconst q = this.items[index]!;\n\t\tthis.state.currentItemIdentifier = q.identifier;\n\t\tthis.timeManager?.activateScopes({\n\t\t\ttestPart: { identifier: q.testPart.identifier, timeLimits: q.testPart.timeLimits },\n\t\t\tsection: { identifier: q.section.identifier, timeLimits: q.section.timeLimits },\n\t\t\titem: { identifier: q.identifier, timeLimits: q.item.timeLimits },\n\t\t});\n\n\t\t// Restore responses into one live session owned by the assessment. The section\n\t\t// composition and item renderer receive this exact object.\n\t\tconst responses = this.sessionCoordinator.activateItem(q.identifier);\n\t\tconst restoredItemSession = this.state.itemSessions?.[q.identifier];\n\t\tconst control = this.sessionCoordinator.getItemSettings(q.identifier);\n\t\tthis.releaseCurrentItemSession();\n\t\tconst session = this.getItemDefinition(q).openSession({\n\t\t\trestore: restoredItemSession,\n\t\t\tresponses: restoredItemSession ? undefined : responses,\n\t\t\tactivate: true,\n\t\t\ttemplateDefaults: restoredItemSession ? undefined : this.evaluateTemplateDefaults(q),\n\t\t\tpresentation: {\n\t\t\t\t// Feedback during an adaptive item's attempts is part of the item, whatever showFeedback says.\n\t\t\t\tshowFeedback: control.showFeedback === true || isAdaptiveItemXml(q.item.itemXml),\n\t\t\t\tshowSolution: control.showSolution === true,\n\t\t\t},\n\t\t});\n\t\tthis.attachCurrentItemSession(q, session);\n\n\t\tthis.notifyItemChange();\n\t\tthis.notifySectionChange();\n\t\tif (currentItem?.testPart.identifier !== q.testPart.identifier) this.notifyTestFeedbackChange();\n\t}\n\n\tpublic async navigateToSection(sectionId: string): Promise<void> {\n\t\tconst idx = this.items.findIndex((q) => q.section.identifier === sectionId);\n\t\tif (idx >= 0) await this.navigateTo(idx);\n\t}\n\n\tpublic async next(): Promise<void> {\n\t\tconst state = this.getNavigationState();\n\t\tif (!state.canNext) return;\n\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (q) {\n\t\t\tconst responses = this.sessionCoordinator.getActiveResponses();\n\t\t\tthis.sessionCoordinator.markAnswered(q.identifier, responses);\n\n\t\t\tconst navAway = this.sessionCoordinator.canNavigateAway(q.identifier, responses);\n\t\t\tif (!navAway.allowed) {\n\t\t\t\tthrow new Error(navAway.reason || 'You must answer this question before continuing.');\n\t\t\t}\n\n\t\t\t// In individual submission mode, submit the current item before moving forward\n\t\t\t// unless its attempts are used up or it is already closed.\n\t\t\tconst lifecycle = this.currentItemSession?.state().lifecycleStatus;\n\t\t\tif (\n\t\t\t\t(q.testPart.submissionMode ?? this.assessment.submissionMode) === 'individual' &&\n\t\t\t\tthis.sessionCoordinator.canSubmit(q.identifier) &&\n\t\t\t\tlifecycle !== 'closed'\n\t\t\t) {\n\t\t\t\tconst before = this.currentItemIndex;\n\t\t\t\tawait this.submitCurrentItem();\n\t\t\t\t// submitCurrentItem may branch/navigate; if it did, we're done.\n\t\t\t\tif (this.currentItemIndex !== before) return;\n\t\t\t}\n\t\t}\n\n\t\tconst nextIndex = this.nextUnlockedIndex(this.currentItemIndex);\n\t\tif (nextIndex < 0) return;\n\t\tawait this.navigateTo(nextIndex);\n\t}\n\n\tpublic async previous(): Promise<void> {\n\t\tconst state = this.getNavigationState();\n\t\tif (!state.canPrevious) return;\n\t\tawait this.navigateTo(this.currentItemIndex - 1);\n\t}\n\n\t/** Submit current item (server-side scoring) */\n\tpublic async submitCurrentItem(): Promise<ItemResult> {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) throw new Error('No current item');\n\t\tthis.assertMinimumTime('item', q);\n\n\t\tconst submittedAt = Date.now();\n\t\tlet itemSession: SerializedItemSessionState | undefined;\n\t\tconst submittedSession = this.currentItemSession;\n\t\tconst preSubmitSession = submittedSession?.serialize();\n\t\tconst responses = this.currentItemSession\n\t\t\t? cloneResponseRecord(this.currentItemSession.state().responses)\n\t\t\t: this.sessionCoordinator.getActiveResponses();\n\t\tlet res: Awaited<ReturnType<BackendAdapter['submitResponses']>>;\n\t\ttry {\n\t\t\tif (submittedSession) {\n\t\t\t\tconst transition = submittedSession.dispatch({\n\t\t\t\t\taction: 'endAttempt',\n\t\t\t\t\tvalidateResponses: this.sessionCoordinator.mustValidateResponses(q.identifier),\n\t\t\t\t});\n\t\t\t\tconst attempt = transition.result;\n\t\t\t\tif (!attempt) throw new Error('Item session did not produce an end-attempt result');\n\t\t\t\tif (attempt.validation && !attempt.validation.valid) {\n\t\t\t\t\tthrow new Error(attempt.validation.issues[0]?.message || 'Submit failed: invalid response');\n\t\t\t\t}\n\t\t\t\titemSession = attempt.sessionState;\n\t\t\t}\n\t\t\tres = await this.backend.submitResponses({\n\t\t\t\tsessionId: this.sessionId,\n\t\t\t\titemIdentifier: q.identifier,\n\t\t\t\tresponses: responses as any,\n\t\t\t\tsubmittedAt,\n\t\t\t\ttimeSpent: itemSession?.duration,\n\t\t\t\ttiming: this.getSubmitTimingEvidence(q, itemSession?.duration ?? 0),\n\t\t\t\titemSession: this.config.sendItemSessionToBackend ? itemSession : undefined,\n\t\t\t\tcomment: this.sessionCoordinator.getItemComment(q.identifier),\n\t\t\t});\n\n\t\t\tif (!res.success || !res.result) {\n\t\t\t\tthrow new Error(res.error || 'Submit failed');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Ending an attempt is a local provisional commit until the backend accepts\n\t\t\t// it. Restore the exact pre-submit lifecycle so a transient failure can be\n\t\t\t// retried without a closed item or a double-counted attempt.\n\t\t\tif (\n\t\t\t\tsubmittedSession &&\n\t\t\t\tpreSubmitSession &&\n\t\t\t\tthis.currentItemSession === submittedSession &&\n\t\t\t\tthis.items[this.currentItemIndex] === q\n\t\t\t) {\n\t\t\t\tthis.releaseCurrentItemSession();\n\t\t\t\tthis.attachCurrentItemSession(\n\t\t\t\t\tq,\n\t\t\t\t\tthis.getItemDefinition(q).openSession({ restore: preSubmitSession }),\n\t\t\t\t);\n\t\t\t\tthis.notifyItemChange();\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (itemSession) {\n\t\t\tthis.sessionCoordinator.setItemSession(q.identifier, itemSession);\n\t\t}\n\n\t\tif (res.updatedState) {\n\t\t\tconst localResponses = cloneData(this.state.itemResponses || {})!;\n\t\t\tlocalResponses[q.identifier] = cloneResponseRecord(responses) as any;\n\t\t\tthis.sessionCoordinator.replaceStatePreservingResponsesAndSessions(\n\t\t\t\tres.updatedState,\n\t\t\t\tlocalResponses,\n\t\t\t\tcloneData(this.state.itemSessions || {})!,\n\t\t\t);\n\t\t} else {\n\t\t\t// Minimal state update when backend doesn't return full state.\n\t\t\tthis.state.itemScores = this.state.itemScores || {};\n\t\t\tthis.state.itemScores[q.identifier] = res.result;\n\t\t\tthis.sessionCoordinator.markVisited(q.identifier);\n\t\t\tthis.state.itemResponses[q.identifier] = responses as any;\n\t\t\tif (itemSession) {\n\t\t\t\tthis.sessionCoordinator.setItemSession(q.identifier, itemSession);\n\t\t\t}\n\t\t}\n\n\t\tthis.setTestOutcomes(res.outcomes);\n\n\t\tconst itemResult: ItemResult = {\n\t\t\titemIdentifier: q.identifier,\n\t\t\tscore: res.result.score,\n\t\t\tmaxScore: res.result.maxScore,\n\t\t\tresponses: { ...responses },\n\t\t};\n\t\tthis.sessionCoordinator.setItemResult(itemResult);\n\n\t\t// Track item session rules (review/attempts) and visited items for navigation hints.\n\t\ttry {\n\t\t\tthis.sessionCoordinator.recordAttempt(q.identifier);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t\tthis.sessionCoordinator.markAnswered(q.identifier, responses);\n\t\tthis.navigationManager.markVisited(this.currentItemIndex);\n\n\t\t// Apply backend branching decision if provided.\n\t\t// Special QTI targets EXIT_TEST / EXIT_TESTPART / EXIT_SECTION trigger finalization.\n\t\tif (res.nextItemIdentifier) {\n\t\t\tconst special = res.nextItemIdentifier;\n\t\t\tif (special === 'EXIT_TEST') {\n\t\t\t\t// Finalize immediately — no further navigation\n\t\t\t\tfor (const l of this.completeListeners) l();\n\t\t\t\tthis.config.onComplete?.();\n\t\t\t} else if (special === 'EXIT_TESTPART' || special === 'EXIT_SECTION') {\n\t\t\t\t// Advance past all remaining items in the current testPart or section\n\t\t\t\tconst currentItem = this.items[this.currentItemIndex];\n\t\t\t\tconst isSection = special === 'EXIT_SECTION';\n\t\t\t\tconst nextIdx = this.items.findIndex((item, i) =>\n\t\t\t\t\ti > this.currentItemIndex &&\n\t\t\t\t\t(isSection\n\t\t\t\t\t\t? item.section.identifier !== currentItem?.section.identifier\n\t\t\t\t\t\t: item.testPart.identifier !== currentItem?.testPart.identifier)\n\t\t\t\t);\n\t\t\t\tif (nextIdx >= 0) {\n\t\t\t\t\tawait this.navigateTo(nextIdx, { restoring: true });\n\t\t\t\t} else {\n\t\t\t\t\t// No further items — signal completion\n\t\t\t\t\tfor (const l of this.completeListeners) l();\n\t\t\t\t\tthis.config.onComplete?.();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst nextIdx = this.items.findIndex((x) => x.identifier === special);\n\t\t\t\tif (nextIdx >= 0) {\n\t\t\t\t\tawait this.navigateTo(nextIdx, { restoring: true });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn itemResult;\n\t}\n\n\tprivate canPrevious(): boolean {\n\t\tif (this.currentItemIndex <= 0) return false;\n\t\tconst prev = this.items[this.currentItemIndex - 1];\n\t\tif (!prev || this.isItemLocked(prev)) return false;\n\t\tif (!this.canNavigateByTestPart(this.currentItemIndex - 1, this.currentItemIndex)) return false;\n\t\treturn this.sessionCoordinator.canReview(prev.identifier);\n\t}\n\n\tprivate canNext(): boolean {\n\t\tif (this.currentItemIndex < 0) return false;\n\t\tconst nextIdx = this.nextUnlockedIndex(this.currentItemIndex);\n\t\tif (nextIdx < 0) return false;\n\t\tif (!this.canNavigateByTestPart(nextIdx, this.currentItemIndex)) return false;\n\t\t// Note: itemSessionControl constraints on leaving current item are enforced in next().\n\t\treturn true;\n\t}\n\n\tprivate canNavigateByTestPart(targetIndex: number, currentIndex: number): boolean {\n\t\tif (targetIndex < 0 || targetIndex >= this.items.length) return false;\n\t\tconst current = this.items[currentIndex];\n\t\tconst target = this.items[targetIndex];\n\t\tif (!current || !target) return false;\n\t\t// Items locked by an expired time limit are passed over.\n\t\tconst nextIndex = this.nextUnlockedIndex(currentIndex);\n\t\tif (current.testPart !== target.testPart) {\n\t\t\t// QTI testParts are delivered in sequence. A candidate may enter the next\n\t\t\t// part, but cannot jump across parts or return to a completed part.\n\t\t\treturn targetIndex === nextIndex;\n\t\t}\n\t\tconst mode = current.testPart.navigationMode ?? this.assessment.navigationMode ?? 'nonlinear';\n\t\treturn mode === 'nonlinear' || targetIndex === currentIndex || targetIndex === nextIndex;\n\t}\n\n\tprivate async submitSimultaneousItems(items: readonly FlatItem[]): Promise<void> {\n\t\tif (items.every((q) => this.sessionCoordinator.hasItemResult(q.identifier))) return;\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tconst submittedItem = current && items.includes(current) ? current : undefined;\n\t\tconst preSubmitSession = submittedItem ? this.currentItemSession?.serialize() : undefined;\n\t\tlet allItemSessions: NonNullable<AssessmentSessionState['itemSessions']> = {};\n\n\t\ttry {\n\t\t\t// Suspending the rendered session gives the UI one non-writable state while\n\t\t\t// backend submission is in flight. Detached sessions perform the provisional\n\t\t\t// end-attempt work for every item.\n\t\t\tif (submittedItem) this.saveCurrentItemSession();\n\t\t\t// Preserve client-collected responses across backend state updates.\n\t\t\t// Some backend adapters return an updatedState snapshot that may only include\n\t\t\t// responses for items that have been submitted so far, which would otherwise\n\t\t\t// wipe out responses for later items during this loop.\n\t\t\tconst allItemResponses = cloneData(this.state.itemResponses || {}) as any;\n\t\t\tallItemSessions = cloneData(this.state.itemSessions || {})!;\n\n\t\t\tfor (const q of items) {\n\t\t\t\tif (this.sessionCoordinator.hasItemResult(q.identifier)) continue;\n\t\t\t\tconst submittedAt = Date.now();\n\t\t\t\tconst responsesForItem = (allItemResponses?.[q.identifier] || {}) as any;\n\t\t\t\tconst itemSession = this.endItemSessionForSubmit(\n\t\t\t\t\tq,\n\t\t\t\t\tresponsesForItem,\n\t\t\t\t\tallItemSessions[q.identifier],\n\t\t\t\t);\n\t\t\t\tallItemSessions[q.identifier] = itemSession;\n\t\t\t\tconst res = await this.backend.submitResponses({\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\titemIdentifier: q.identifier,\n\t\t\t\t\tresponses: responsesForItem,\n\t\t\t\t\tsubmittedAt,\n\t\t\t\t\ttimeSpent: itemSession.duration,\n\t\t\t\t\ttiming: this.getSubmitTimingEvidence(q, itemSession.duration),\n\t\t\t\t\titemSession: this.config.sendItemSessionToBackend ? itemSession : undefined,\n\t\t\t\t\tcomment: this.sessionCoordinator.getItemComment(q.identifier),\n\t\t\t\t});\n\t\t\t\tif (!res.success || !res.result) {\n\t\t\t\t\tthrow new Error(res.error || `Submit failed for item ${q.identifier}`);\n\t\t\t\t}\n\t\t\t\tif (res.updatedState) {\n\t\t\t\t\tthis.sessionCoordinator.replaceStatePreservingResponsesAndSessions(\n\t\t\t\t\t\tres.updatedState,\n\t\t\t\t\t\tallItemResponses,\n\t\t\t\t\t\tallItemSessions,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.state.itemScores = this.state.itemScores || {};\n\t\t\t\t\tthis.state.itemScores[q.identifier] = res.result;\n\t\t\t\t\tthis.sessionCoordinator.markVisited(q.identifier);\n\t\t\t\t\tthis.state.itemResponses[q.identifier] = responsesForItem;\n\t\t\t\t\tthis.sessionCoordinator.setItemSession(q.identifier, itemSession);\n\t\t\t\t\tthis.sessionCoordinator.recordAttempt(q.identifier);\n\t\t\t\t}\n\t\t\t\tthis.sessionCoordinator.setItemResult({\n\t\t\t\t\titemIdentifier: q.identifier,\n\t\t\t\t\tscore: res.result.score,\n\t\t\t\t\tmaxScore: res.result.maxScore,\n\t\t\t\t\tresponses: this.state.itemResponses[q.identifier] || {},\n\t\t\t\t});\n\t\t\t\tthis.setTestOutcomes(res.outcomes);\n\t\t\t}\n\n\t\t\t// The attached item must represent the same accepted lifecycle as persistence.\n\t\t\t// Replace the provisional suspended object with one restored from the accepted\n\t\t\t// closed state; no second live state owner remains.\n\t\t\tif (submittedItem && this.items[this.currentItemIndex] === submittedItem) {\n\t\t\t\tconst accepted = allItemSessions[submittedItem.identifier];\n\t\t\t\tif (accepted) {\n\t\t\t\t\tthis.releaseCurrentItemSession();\n\t\t\t\t\tthis.attachCurrentItemSession(\n\t\t\t\t\t\tsubmittedItem,\n\t\t\t\t\t\tthis.getItemDefinition(submittedItem).openSession({ restore: accepted }),\n\t\t\t\t\t);\n\t\t\t\t\tthis.notifyItemChange();\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// The backend accepts simultaneous items one request at a time. Keep earlier\n\t\t\t// accepted items committed so retry cannot double-submit them. If the rendered\n\t\t\t// item was not accepted, restore only that item to its exact writable state.\n\t\t\tif (submittedItem && this.items[this.currentItemIndex] === submittedItem) {\n\t\t\t\tconst accepted = this.sessionCoordinator.hasItemResult(submittedItem.identifier)\n\t\t\t\t\t? allItemSessions[submittedItem.identifier]\n\t\t\t\t\t: undefined;\n\t\t\t\tconst restored = accepted ?? preSubmitSession;\n\t\t\t\tif (!accepted && preSubmitSession) {\n\t\t\t\t\tthis.sessionCoordinator.saveItemSession(\n\t\t\t\t\t\tsubmittedItem.identifier,\n\t\t\t\t\t\tcloneResponseRecord(valuesFromItemSession(preSubmitSession)),\n\t\t\t\t\t\tpreSubmitSession,\n\t\t\t\t\t\tpreSubmitSession.duration,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.releaseCurrentItemSession();\n\t\t\t\tif (restored) {\n\t\t\t\t\tthis.attachCurrentItemSession(\n\t\t\t\t\t\tsubmittedItem,\n\t\t\t\t\t\tthis.getItemDefinition(submittedItem).openSession({ restore: restored }),\n\t\t\t\t\t);\n\t\t\t\t\tthis.notifyItemChange();\n\t\t\t\t\tthis.notifyResponseChange();\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Submit entire assessment (finalize on backend) */\n\tpublic async submit(): Promise<AssessmentResults> {\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (current) {\n\t\t\tthis.assertMinimumTime('item', current);\n\t\t\tthis.assertMinimumTime('section', current);\n\t\t\tthis.assertMinimumTime('testPart', current);\n\t\t\tthis.assertMinimumTime('assessment', current);\n\t\t}\n\t\t// Submission modes belong to test parts. The assessment-level field is only\n\t\t// a fallback for older hosts that do not supply a mode on each part.\n\t\tawait this.submitSimultaneousItems(this.items.filter((q) =>\n\t\t\t(q.testPart.submissionMode ?? this.assessment.submissionMode) === 'simultaneous',\n\t\t));\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (q && (q.testPart.submissionMode ?? this.assessment.submissionMode) === 'individual'\n\t\t\t&& !this.sessionCoordinator.hasItemResult(q.identifier)) {\n\t\t\tawait this.submitCurrentItem();\n\t\t}\n\n\t\tconst finalized: FinalizeAssessmentResponse = await this.backend.finalizeAssessment({\n\t\t\tsessionId: this.sessionId,\n\t\t});\n\t\tif (!finalized.success) throw new Error('Finalize failed');\n\n\t\t// Map backend itemScores to ItemResult[]\n\t\tconst itemScores = finalized.itemScores || {};\n\t\tconst itemResults: ItemResult[] = Object.values(itemScores).map((r: AssessmentScoringResult) => ({\n\t\t\titemIdentifier: r.itemIdentifier,\n\t\t\tscore: r.score,\n\t\t\tmaxScore: r.maxScore,\n\t\t\tresponses: this.state.itemResponses[r.itemIdentifier] || {},\n\t\t}));\n\n\t\t// Outcome processing has run by the end of the test, so a backend returning no outcomes\n\t\t// leaves them all NULL.\n\t\tthis.finalized = true;\n\t\tthis.legacyFeedback = finalized.feedback;\n\t\tthis.testOutcomes = cloneData(finalized.outcomes ?? this.testOutcomes ?? {})!;\n\t\tthis.notifyTestFeedbackChange();\n\n\t\tthis.notifyComplete();\n\t\tif (this.config.onComplete) this.config.onComplete();\n\n\t\treturn {\n\t\t\ttotalScore: finalized.totalScore,\n\t\t\tmaxScore: finalized.maxScore,\n\t\t\titemResults,\n\t\t\tcompletedAt: new Date(finalized.finalizedAt),\n\t\t};\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Session info + time helpers\n\t// ---------------------------------------------------------------------------\n\n\tpublic getItemSessionInfo(_itemIdentifier?: string): {\n\t\tcanSubmit: boolean;\n\t\tremainingAttempts: number | null;\n\t\tattemptCount: number;\n\t\tshowFeedback: boolean;\n\t\tshowSolution: boolean;\n\t\tcanReview: boolean;\n\t\tcanSkip: boolean;\n\t\tcanComment: boolean;\n\t} | null {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return null;\n\t\tconst id = q.identifier;\n\n\t\treturn this.sessionCoordinator.getItemSessionInfo(id);\n\t}\n\n\t/**\n\t * Records the candidate's comment on an item (QTI `allowComment`), sent with its next submission.\n\t * Defaults to the current item; throws when the item does not allow comments.\n\t */\n\tpublic setItemComment(comment: string, itemIdentifier?: string): void {\n\t\tconst id = itemIdentifier ?? this.items[this.currentItemIndex]?.identifier;\n\t\tif (!id) throw new Error('No current item');\n\t\tthis.sessionCoordinator.setItemComment(id, comment);\n\t}\n\n\tpublic getItemComment(itemIdentifier?: string): string | undefined {\n\t\tconst id = itemIdentifier ?? this.items[this.currentItemIndex]?.identifier;\n\t\treturn id ? this.sessionCoordinator.getItemComment(id) : undefined;\n\t}\n\n\tpublic getRemainingTime(): number {\n\t\t// TimeManager exposes seconds getters.\n\t\treturn this.timeManager?.getRemainingSeconds() ?? 0;\n\t}\n\n\tpublic getElapsedTime(): number {\n\t\treturn this.timeManager?.getElapsedSeconds() ?? 0;\n\t}\n\n\tpublic isTimeExpired(): boolean {\n\t\treturn this.timeManager?.isExpired() ?? false;\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Event subscriptions\n\t// ---------------------------------------------------------------------------\n\n\tpublic onItemChange(listener: (index: number, total: number) => void): () => void {\n\t\tthis.itemChangeListeners.add(listener);\n\t\treturn () => this.itemChangeListeners.delete(listener);\n\t}\n\n\tpublic onSectionChange(listener: (index: number, total: number) => void): () => void {\n\t\tthis.sectionChangeListeners.add(listener);\n\t\treturn () => this.sectionChangeListeners.delete(listener);\n\t}\n\n\tpublic onResponseChange(listener: (responses: Record<string, unknown>) => void): () => void {\n\t\tthis.responseChangeListeners.add(listener);\n\t\treturn () => this.responseChangeListeners.delete(listener);\n\t}\n\n\tpublic onComplete(listener: () => void): () => void {\n\t\tthis.completeListeners.add(listener);\n\t\treturn () => this.completeListeners.delete(listener);\n\t}\n\n\t/** Called when `getVisibleFeedback()` may have changed: new outcomes, a new test part, or the end. */\n\tpublic onTestFeedbackChange(listener: () => void): () => void {\n\t\tthis.testFeedbackChangeListeners.add(listener);\n\t\treturn () => this.testFeedbackChangeListeners.delete(listener);\n\t}\n\n\tpublic onTimeWarning(listener: (remainingSeconds: number) => void): () => void {\n\t\tthis.timeWarningListeners.add(listener);\n\t\treturn () => this.timeWarningListeners.delete(listener);\n\t}\n\n\tpublic onTimeExpired(listener: () => void): () => void {\n\t\tthis.timeExpiredListeners.add(listener);\n\t\treturn () => this.timeExpiredListeners.delete(listener);\n\t}\n\n\tpublic onTimeTick(listener: (remainingSeconds: number, elapsedSeconds: number) => void): () => void {\n\t\tthis.timeTickListeners.add(listener);\n\t\treturn () => this.timeTickListeners.delete(listener);\n\t}\n\n\tpublic destroy(): void {\n\t\tthis.timeManager?.destroy();\n\t\tthis.releaseCurrentItemSession();\n\t\tthis.itemDefinitions.clear();\n\t\tthis.itemChangeListeners.clear();\n\t\tthis.sectionChangeListeners.clear();\n\t\tthis.responseChangeListeners.clear();\n\t\tthis.completeListeners.clear();\n\t\tthis.testFeedbackChangeListeners.clear();\n\t\tthis.timeWarningListeners.clear();\n\t\tthis.timeExpiredListeners.clear();\n\t\tthis.timeTickListeners.clear();\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Internal notify helpers\n\t// ---------------------------------------------------------------------------\n\n\tprivate notifyItemChange(): void {\n\t\tfor (const l of this.itemChangeListeners) l(this.currentItemIndex, this.items.length);\n\t\tthis.config.onItemChange?.(this.currentItemIndex, this.items.length);\n\t}\n\n\tprivate notifySectionChange(): void {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tconst sectionIndex = q?.sectionIndex ?? 0;\n\t\tconst totalSections = this.getAllSections().length;\n\t\tfor (const l of this.sectionChangeListeners) l(sectionIndex, totalSections);\n\t\tthis.config.onSectionChange?.(sectionIndex, totalSections);\n\t}\n\n\tprivate notifyResponseChange(): void {\n\t\tconst responses = this.sessionCoordinator.getActiveResponses();\n\t\tfor (const l of this.responseChangeListeners) l(responses);\n\t\tthis.config.onResponseChange?.(responses);\n\t}\n\n\tprivate notifyComplete(): void {\n\t\tfor (const l of this.completeListeners) l();\n\t}\n\n\tprivate notifyTestFeedbackChange(): void {\n\t\tfor (const l of this.testFeedbackChangeListeners) l();\n\t}\n\n\tprivate notifyTimeWarning(remainingSeconds: number): void {\n\t\tfor (const l of this.timeWarningListeners) l(remainingSeconds);\n\t}\n\n\tprivate evaluateTemplateDefaults(q: FlatItem): Record<string, unknown> | undefined {\n\t\tconst defaults = q.item.templateDefaults;\n\t\tif (!defaults?.length) return undefined;\n\t\tconst declarations = testOutcomeDeclarations(this.assessment, this.testOutcomes ?? undefined);\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const { templateIdentifier, expressionXml } of defaults) {\n\t\t\tout[templateIdentifier] = plainQtiValue(evaluateTestExpression(expressionXml, declarations, Math.random));\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate isItemLocked(q: FlatItem): boolean {\n\t\treturn (\n\t\t\tthis.lockedScopes.has(`item:${q.identifier}`) ||\n\t\t\tthis.lockedScopes.has(`testPart:${q.testPart.identifier}`) ||\n\t\t\tq.sections.some((section) => this.lockedScopes.has(`section:${section.identifier}`))\n\t\t);\n\t}\n\n\tprivate nextUnlockedIndex(fromIndex: number): number {\n\t\tfor (let i = fromIndex + 1; i < this.items.length; i++) {\n\t\t\tif (!this.isItemLocked(this.items[i]!)) return i;\n\t\t}\n\t\treturn -1;\n\t}\n\n\t/**\n\t * A test part, section or item without late submission ran out of time: its items close for the\n\t * candidate, and delivery moves to the next item outside it.\n\t */\n\tprivate handleScopeExpired(scope: 'testPart' | 'section' | 'item', identifier: string): void {\n\t\tthis.lockedScopes.add(`${scope}:${identifier}`);\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (!current || !this.isItemLocked(current)) return;\n\t\tthis.saveCurrentItemSession();\n\t\tthis.notifyItemChange();\n\t\tconst nextIndex = this.nextUnlockedIndex(this.currentItemIndex);\n\t\tif (nextIndex < 0) {\n\t\t\tthis.notifyTimeExpired();\n\t\t\treturn;\n\t\t}\n\t\tthis.navigateTo(nextIndex, { restoring: true }).catch(() => {});\n\t}\n\n\tprivate notifyTimeExpired(): void {\n\t\tfor (const l of this.timeExpiredListeners) l();\n\t}\n\n\tprivate notifyTimeTick(remainingSeconds: number, elapsedSeconds: number): void {\n\t\tfor (const l of this.timeTickListeners) l(remainingSeconds, elapsedSeconds);\n\t}\n\n\t/**\n\t * Get the i18n provider instance\n\t * @returns I18nProvider instance\n\t */\n\tpublic getI18nProvider(): I18nProvider {\n\t\treturn this.i18nProvider;\n\t}\n\n\t/**\n\t * Create a simple fallback i18n provider when none is provided\n\t */\n\tprivate createDefaultI18nProvider(): I18nProvider {\n\t\treturn {\n\t\t\tgetLocale: () => 'en-US',\n\t\t\tsetLocale: () => {},\n\t\t\tt: (key: string) => key, // Fallback to key\n\t\t\tplural: (key: string) => key,\n\t\t\tformatNumber: (value: number) => value.toString(),\n\t\t\tformatDate: (date: Date) => date.toISOString(),\n\t\t};\n\t}\n}\n\nfunction cloneData<T>(value: T | undefined): T | undefined {\n\treturn value === undefined ? undefined : structuredClone(value);\n}\n\nfunction cloneResponseRecord(\n\tresponses: Readonly<Record<string, unknown>>,\n): Record<string, unknown> {\n\treturn structuredClone(responses) as Record<string, unknown>;\n}\n\nfunction valuesFromItemSession(\n\tstate: SerializedItemSessionState,\n): Record<string, unknown> {\n\treturn Object.fromEntries(\n\t\tObject.entries(state.responseVariables).map(([identifier, variable]) => [\n\t\t\tidentifier,\n\t\t\tcloneData(variable.value),\n\t\t]),\n\t);\n}\n\nfunction responseValuesEqual(left: unknown, right: unknown): boolean {\n\tif (Object.is(left, right)) return true;\n\tif (Array.isArray(left) || Array.isArray(right)) {\n\t\tif (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;\n\t\treturn left.every((value, index) => responseValuesEqual(value, right[index]));\n\t}\n\tif (!isRecord(left) || !isRecord(right)) return false;\n\n\tconst leftKeys = Object.keys(left);\n\tconst rightKeys = Object.keys(right);\n\tif (leftKeys.length !== rightKeys.length) return false;\n\tconst rightKeySet = new Set(rightKeys);\n\treturn leftKeys.every(\n\t\t(key) => rightKeySet.has(key) && responseValuesEqual(left[key], right[key]),\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object';\n}\n\nfunction isWritableItemLifecycle(lifecycleStatus: SerializedItemSessionState['lifecycleStatus']): boolean {\n\treturn lifecycleStatus === 'initial' || lifecycleStatus === 'interacting';\n}\n"]}
1
+ {"version":3,"file":"AssessmentPlayer.js","sourceRoot":"","sources":["../../src/core/AssessmentPlayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,8BAA8B,GAS9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAqB,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAyB1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA8GhE,MAAM,OAAO,gBAAgB;IACrB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAqC;QAC/D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClE,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAiCD,YAA4B,MAAqC,EAAE,IAAyB;QAAhE,WAAM,GAAN,MAAM,CAA+B;QAxBzD,gBAAW,GAAuB,IAAI,CAAC;QAEvC,UAAK,GA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end-authoritative)\n *\n * Client responsibilities:\n * - Render items using @pie-qti/item-player\n * - Collect candidate responses\n * - Submit responses to BackendAdapter\n * - Apply backend navigation decisions + session state\n */\n\nimport {\n\tcreateAssessmentItemDefinition,\n\ttype AssessmentItemDefinition,\n\ttype AssessmentItemDefinitionPlugin,\n\ttype ItemSession,\n\ttype PciConfiguration,\n\ttype PnpProfile,\n\ttype PlayerSecurityConfig,\n\ttype QTIRole,\n\ttype SerializedItemSessionState,\n} from '@pie-qti/item-player';\nimport { DefaultI18nProvider, type I18nProvider } from '@pie-qti/i18n';\nimport { isShownByIdentifier } from '@pie-qti/qti-common';\nimport type { QtiSectionRuntimeHostContract, QtiSectionToolConfig } from '@pie-qti/section-player';\nimport type {\n\tAssessmentRubricBlock,\n\tAssessmentSessionState,\n\tAssessmentScoringResult,\n\tBackendAdapter,\n\tFinalizeAssessmentResponse,\n\tInitSessionRequest,\n\tInitSessionResponse,\n\tSecureAssessment,\n\tSecureItemRef,\n\tSecureSection,\n\tSecureTestPart,\n\tSessionId,\n\tTestFeedbackItem,\n\tTestOutcomeValues,\n} from '../integration/api-contract.js';\nimport type {\n\tAssessmentResults,\n\tItemResult,\n\tNavigationState,\n\tTimeLimits,\n\tVisibleTestFeedback,\n} from '../types/index.js';\nimport { AssessmentSessionCoordinator } from './AssessmentSessionCoordinator.js';\nimport { NavigationManager } from './NavigationManager.js';\nimport {\n\tdeliveredItems,\n\tevaluateTestExpression,\n\tisAdaptiveItemXml,\n\tplainQtiValue,\n\tresolveItemSessionControl,\n\tsectionComponents,\n\ttestOutcomeDeclarations,\n} from './testStructure.js';\nimport { extendTimeLimit, TimeManager } from './TimeManager.js';\n\nexport interface BackendAssessmentPlayerConfig {\n\tbackend: BackendAdapter;\n\tinitSession: InitSessionRequest;\n\trole?: QTIRole;\n\t/**\n\t * @deprecated Ignored. The backend draws selection and ordering at session start; pass an rng to\n\t * `new ReferenceBackendAdapter({ rng })` for deterministic draws.\n\t */\n\trng?: () => number;\n\t/** Definition-lifetime extractor and renderer extensions applied to every item. */\n\tplugins?: readonly AssessmentItemDefinitionPlugin[];\n\t/**\n\t * Shared catalog files the package manifest lists (resource type\n\t * `imsqti_catalog_xmlv3p0`), read by the host that loaded the package. When the\n\t * reference backend parses the assessment test they become package-scope\n\t * catalog sources beneath item-level catalogs (QTI 3.0 §6.3).\n\t */\n\tsharedCatalogs?: ReadonlyArray<{ href?: string; xml?: string }>;\n\t/**\n\t * Optional i18n provider for internationalization.\n\t * If provided, this will be shared across all item players in the assessment.\n\t */\n\ti18nProvider?: I18nProvider;\n\t/**\n\t * Security configuration for URL policy and content restrictions.\n\t * If provided, this will be passed to all item players in the assessment.\n\t */\n\tsecurity?: PlayerSecurityConfig;\n\t/**\n\t * Explicit host trust configuration for Portable Custom Interaction modules.\n\t * Without this resolver, authored PCI code remains disabled.\n\t */\n\tpci?: PciConfiguration;\n\t/**\n\t * Optional host hooks for delegated section rendering.\n\t * Used for section shared-content URL policy and runtime callbacks.\n\t */\n\tsectionHost?: QtiSectionRuntimeHostContract;\n\t/** Optional section-scoped tools rendered by delegated section players. */\n\tsectionTools?: QtiSectionToolConfig[];\n\t/** Optional tools rendered in passage/rubric headers. */\n\tpassageTools?: QtiSectionToolConfig[];\n\t/** Optional tools rendered in item headers. */\n\titemTools?: QtiSectionToolConfig[];\n\t/**\n\t * Demo/reference-only escape hatch. When false (default), rich item-session\n\t * variables stay client-local and are not submitted because template variables\n\t * can contain answer keys. Production backends should own this state server-side.\n\t */\n\tsendItemSessionToBackend?: boolean;\n\t// UI options\n\tshowSections?: boolean;\n\tallowSectionNavigation?: boolean;\n\tshowProgress?: boolean;\n\t// Time management\n\ttimeWarningThreshold?: number;\n\t/**\n\t * Deterministic clock for time-limit tracking. Defaults to Date.now; intended for\n\t * tests and hosts that drive delivery from their own timeline.\n\t */\n\tnow?: () => number;\n\t/**\n\t * QTI 3.0 §6.2 Personal Needs and Preferences profile.\n\t * Extended time (pnp.content.extendedTime) is applied to assessment timeLimits.\n\t * The full profile is passed down to each item player for component-level features\n\t * (color scheme, elimination tool).\n\t */\n\tpnp?: PnpProfile;\n\t// Callbacks\n\tonItemChange?: (itemIndex: number, totalItems: number) => void;\n\tonSectionChange?: (sectionIndex: number, totalSections: number) => void;\n\tonResponseChange?: (responses: Record<string, unknown>) => void;\n\tonComplete?: () => void;\n}\n\ntype FlatItem = {\n\tidentifier: string;\n\titem: SecureItemRef;\n\t/** Innermost enclosing section. */\n\tsection: SecureSection;\n\t/** Enclosing sections, outermost first. */\n\tsections: SecureSection[];\n\ttestPart: SecureTestPart;\n\tindex: number;\n\tsectionIndex: number;\n};\n\ntype CurrentItemView = {\n\tidentifier: string;\n\ttitle?: string;\n\trequired?: boolean;\n\titemXml: string;\n\tdeliveryContext?: SecureItemRef['deliveryContext'];\n};\n\ntype SectionItemRefView = {\n\tidentifier: string;\n\thref?: string;\n\ttitle?: string;\n\titemXml: string;\n\tdeliveryContext?: SecureItemRef['deliveryContext'];\n};\n\nexport interface EffectiveItemTimeLimits {\n\ttimeLimits?: TimeLimits;\n\tsource?: 'item' | 'section' | 'testPart' | 'assessment';\n}\n\nexport class AssessmentPlayer {\n\tpublic static async create(config: BackendAssessmentPlayerConfig): Promise<AssessmentPlayer> {\n\t\tconst init = await config.backend.initSession(config.initSession);\n\t\treturn new AssessmentPlayer(config, init);\n\t}\n\n\tprivate backend: BackendAdapter;\n\tprivate sessionId: SessionId;\n\tprivate assessment: SecureAssessment;\n\tprivate i18nProvider: I18nProvider;\n\n\tprivate navigationManager: NavigationManager;\n\tprivate sessionCoordinator!: AssessmentSessionCoordinator;\n\tprivate timeManager: TimeManager | null = null;\n\n\tprivate items: FlatItem[] = [];\n\tprivate currentItemIndex = -1;\n\tprivate readonly itemDefinitions = new Map<string, AssessmentItemDefinition>();\n\tprivate currentItemSession: ItemSession | null = null;\n\tprivate currentItemSessionUnsubscribe: (() => void) | null = null;\n\t/** Test-level outcomes from the last outcome processing; null until it first runs. */\n\tprivate testOutcomes: TestOutcomeValues | null = null;\n\tprivate finalized = false;\n\t/** Scopes whose time limit expired without late submission, keyed `scope:identifier`. */\n\tprivate readonly lockedScopes = new Set<string>();\n\tprivate legacyFeedback: string | undefined;\n\n\t// Event listeners\n\tprivate itemChangeListeners = new Set<(index: number, total: number) => void>();\n\tprivate sectionChangeListeners = new Set<(index: number, total: number) => void>();\n\tprivate responseChangeListeners = new Set<(responses: Record<string, unknown>) => void>();\n\tprivate completeListeners = new Set<() => void>();\n\tprivate testFeedbackChangeListeners = new Set<() => void>();\n\tprivate timeWarningListeners = new Set<(remainingSeconds: number) => void>();\n\tprivate timeExpiredListeners = new Set<() => void>();\n\tprivate timeTickListeners = new Set<(remainingSeconds: number, elapsedSeconds: number) => void>();\n\n\tprivate constructor(private config: BackendAssessmentPlayerConfig, init: InitSessionResponse) {\n\t\tthis.backend = config.backend;\n\t\tthis.sessionId = init.sessionId;\n\t\tthis.assessment = init.assessment;\n\t\tthis.testOutcomes = init.outcomes ? cloneData(init.outcomes)! : null;\n\t\tthis.i18nProvider = config.i18nProvider ?? this.createDefaultI18nProvider();\n\t\tconst initialState =\n\t\t\tinit.restoredState ??\n\t\t\t({\n\t\t\t\tcurrentItemIdentifier: init.currentItemIdentifier ?? '',\n\t\t\t\tvisitedItems: [],\n\t\t\t\titemResponses: {},\n\t\t\t\titemScores: {},\n\t\t\t\titemSessions: {},\n\t\t\t\ttiming: { startedAt: Date.now(), itemTimes: {}, totalTime: 0 },\n\t\t\t} as AssessmentSessionState);\n\n\t\tthis.items = this.flattenItems(this.assessment);\n\n\t\tconst navigationMode = this.assessment.navigationMode || 'nonlinear';\n\t\tthis.navigationManager = new NavigationManager(navigationMode, this.items.length);\n\n\t\t// Item session control is a UI hint; backend remains authoritative.\n\t\tthis.sessionCoordinator = new AssessmentSessionCoordinator({\n\t\t\tstate: initialState,\n\t\t\titemIdentifiers: this.items.map((q) => q.identifier),\n\t\t\titemSessionControlByItem: Object.fromEntries(\n\t\t\t\tthis.items.map((q) => [q.identifier, resolveItemSessionControl(q.testPart, q.sections, q.item)]),\n\t\t\t),\n\t\t});\n\n\t\tthis.timeManager = new TimeManager({\n\t\t\tassessmentTimeLimits: this.assessment.timeLimits,\n\t\t\twarningThreshold: config.timeWarningThreshold || 60,\n\t\t\tnow: config.now,\n\t\t\textendedTime: config.pnp?.content?.extendedTime,\n\t\t\tonWarning: (remainingSeconds) => this.notifyTimeWarning(remainingSeconds),\n\t\t\tonExpired: () => this.notifyTimeExpired(),\n\t\t\tonScopeExpired: (scope, identifier) => this.handleScopeExpired(scope, identifier),\n\t\t\tonTick: (remainingSeconds, elapsedSeconds) => this.notifyTimeTick(remainingSeconds, elapsedSeconds),\n\t\t});\n\t\tif (init.restoredState?.timing) {\n\t\t\tthis.restoreTimeTracking(init.restoredState.timing);\n\t\t}\n\n\t\t// Restore to backend-provided current item if present\n\t\tconst startId = this.state.currentItemIdentifier;\n\t\tconst idx = startId ? this.items.findIndex((q) => q.identifier === startId) : -1;\n\t\tif (idx >= 0) {\n\t\t\tthis.navigateTo(idx, { restoring: true }).catch(() => {});\n\t\t} else if (this.items.length > 0) {\n\t\t\tthis.navigateTo(0, { restoring: true }).catch(() => {});\n\t\t}\n\t}\n\n\tprivate get state(): AssessmentSessionState {\n\t\treturn this.sessionCoordinator.state;\n\t}\n\n\tprivate set state(state: AssessmentSessionState) {\n\t\tthis.sessionCoordinator.restoreState(state);\n\t}\n\n\tprivate getEffectiveItemTimeLimits(flat: FlatItem): EffectiveItemTimeLimits {\n\t\tconst scopes: Array<{ source: EffectiveItemTimeLimits['source']; limits?: TimeLimits }> = [\n\t\t\t{ source: 'assessment', limits: this.assessment.timeLimits },\n\t\t\t{ source: 'testPart', limits: flat.testPart.timeLimits },\n\t\t\t{ source: 'section', limits: flat.section.timeLimits },\n\t\t\t{ source: 'item', limits: flat.item.timeLimits },\n\t\t];\n\t\tlet source: EffectiveItemTimeLimits['source'];\n\t\tlet minTime: number | undefined;\n\t\tlet maxTime: number | undefined;\n\t\tlet allowLateSubmission: boolean | undefined;\n\t\tfor (const scope of scopes) {\n\t\t\tif (!scope.limits) continue;\n\t\t\tif (scope.limits.minTime !== undefined) {\n\t\t\t\tminTime = minTime === undefined ? scope.limits.minTime : Math.max(minTime, scope.limits.minTime);\n\t\t\t}\n\t\t\tif (scope.limits.maxTime !== undefined) {\n\t\t\t\tconst scopedMaxTime = extendTimeLimit(scope.limits.maxTime, this.config.pnp?.content?.extendedTime);\n\t\t\t\tif (scopedMaxTime !== undefined && (maxTime === undefined || scopedMaxTime < maxTime)) {\n\t\t\t\t\tmaxTime = scopedMaxTime;\n\t\t\t\t\tsource = scope.source;\n\t\t\t\t\tallowLateSubmission = scope.limits.allowLateSubmission;\n\t\t\t\t}\n\t\t\t} else if (scope.limits.allowLateSubmission !== undefined && maxTime === undefined) {\n\t\t\t\tallowLateSubmission = scope.limits.allowLateSubmission;\n\t\t\t\tsource = scope.source;\n\t\t\t}\n\t\t}\n\n\t\tif (maxTime === undefined && minTime === undefined && allowLateSubmission === undefined) {\n\t\t\treturn {};\n\t\t}\n\t\treturn { source, timeLimits: { minTime, maxTime, allowLateSubmission } };\n\t}\n\n\tpublic getCurrentEffectiveTimeLimits(): EffectiveItemTimeLimits {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\treturn q ? this.getEffectiveItemTimeLimits(q) : {};\n\t}\n\n\tprivate getSubmitTimingEvidence(q: FlatItem, elapsedMs: number): import('../integration/api-contract.js').SubmitTimingEvidence | undefined {\n\t\tconst effective = this.getEffectiveItemTimeLimits(q);\n\t\tconst limitSeconds = effective.timeLimits?.maxTime;\n\t\tif (!effective.source || limitSeconds === undefined) return undefined;\n\t\tconst scopeIdentifier = effective.source === 'item'\n\t\t\t? q.identifier\n\t\t\t: effective.source === 'section'\n\t\t\t\t? q.section.identifier\n\t\t\t\t: effective.source === 'testPart'\n\t\t\t\t\t? q.testPart.identifier\n\t\t\t\t\t: undefined;\n\t\tconst tracked = this.timeManager?.getScopeElapsedMs(effective.source, scopeIdentifier);\n\t\tconst scopedElapsedMs = tracked ?? elapsedMs;\n\t\treturn {\n\t\t\tscope: effective.source,\n\t\t\telapsedMs: scopedElapsedMs,\n\t\t\tlimitSeconds,\n\t\t\texpired: scopedElapsedMs >= limitSeconds * 1000,\n\t\t\tallowLateSubmission: effective.timeLimits?.allowLateSubmission,\n\t\t};\n\t}\n\n\tprivate assertMinimumTime(scope: 'assessment' | 'testPart' | 'section' | 'item', q: FlatItem): void {\n\t\tconst limits = scope === 'assessment'\n\t\t\t? this.assessment.timeLimits\n\t\t\t: scope === 'testPart'\n\t\t\t\t? q.testPart.timeLimits\n\t\t\t\t: scope === 'section'\n\t\t\t\t\t? q.section.timeLimits\n\t\t\t\t\t: q.item.timeLimits;\n\t\tif (limits?.minTime === undefined) return;\n\t\tconst identifier = scope === 'testPart'\n\t\t\t? q.testPart.identifier\n\t\t\t: scope === 'section'\n\t\t\t\t? q.section.identifier\n\t\t\t\t: scope === 'item'\n\t\t\t\t\t? q.identifier\n\t\t\t\t\t: undefined;\n\t\tconst elapsedMs = this.timeManager?.getScopeElapsedMs(scope, identifier) ?? 0;\n\t\tif (elapsedMs < limits.minTime * 1000) {\n\t\t\tconst remaining = Math.ceil(limits.minTime - elapsedMs / 1000);\n\t\t\tthrow new Error(`The ${scope} minimum time has not elapsed (${remaining}s remaining).`);\n\t\t}\n\t}\n\n\tprivate assertTransitionMinimum(current: FlatItem, target: FlatItem): void {\n\t\tif (current === target) return;\n\t\tthis.assertMinimumTime('item', current);\n\t\tif (current.section.identifier !== target.section.identifier) this.assertMinimumTime('section', current);\n\t\tif (current.testPart !== target.testPart) this.assertMinimumTime('testPart', current);\n\t}\n\n\tprivate flattenItems(assessment: SecureAssessment): FlatItem[] {\n\t\tconst sectionIndexes = new Map(this.getAllSections().map((section) => [section.id, section.index]));\n\t\treturn deliveredItems(assessment).map(({ item, testPart, sections }, index) => {\n\t\t\tconst section = sections[sections.length - 1];\n\t\t\treturn {\n\t\t\t\tidentifier: item.identifier,\n\t\t\t\titem,\n\t\t\t\tsection,\n\t\t\t\tsections,\n\t\t\t\ttestPart,\n\t\t\t\tindex,\n\t\t\t\tsectionIndex: sectionIndexes.get(section.identifier) ?? 0,\n\t\t\t};\n\t\t});\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Public API used by components\n\t// ---------------------------------------------------------------------------\n\n\tpublic getAllSections(): Array<{ id: string; title?: string; visible: boolean; index: number }> {\n\t\tconst out: Array<{ id: string; title?: string; visible: boolean; index: number }> = [];\n\t\tconst seen = new Set<string>();\n\t\tconst visit = (section: SecureSection): void => {\n\t\t\t// A keepTogether=\"false\" section mixed into its parent's shuffle appears as several fragments.\n\t\t\tif (!seen.has(section.identifier)) {\n\t\t\t\tseen.add(section.identifier);\n\t\t\t\tout.push({ id: section.identifier, title: section.title, visible: section.visible, index: out.length });\n\t\t\t}\n\t\t\tfor (const component of sectionComponents(section)) {\n\t\t\t\tif (component.type === 'section') visit(component.section);\n\t\t\t}\n\t\t};\n\t\tfor (const tp of this.assessment.testParts || []) {\n\t\t\tfor (const section of tp.sections || []) visit(section);\n\t\t}\n\t\treturn out;\n\t}\n\n\tpublic getNavigationState(): NavigationState {\n\t\tconst total = this.items.length;\n\t\tconst canPrevious = this.canPrevious();\n\t\tconst canNext = this.canNext();\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tconst totalSections = this.getAllSections().length;\n\t\treturn {\n\t\t\tcurrentIndex: this.currentItemIndex,\n\t\t\ttotalItems: total,\n\t\t\tcanNext,\n\t\t\tcanPrevious,\n\t\t\tisLoading: false,\n\t\t\tcurrentSection: q\n\t\t\t\t? { id: q.section.identifier, title: q.section.title, index: q.sectionIndex }\n\t\t\t\t: undefined,\n\t\t\ttotalSections,\n\t\t};\n\t}\n\n\tpublic getCurrentItem(): CurrentItemView | null {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return null;\n\t\treturn {\n\t\t\tidentifier: q.item.identifier,\n\t\t\ttitle: q.section.title,\n\t\t\trequired: q.item.required,\n\t\t\titemXml: q.item.itemXml,\n\t\t\tdeliveryContext: q.item.deliveryContext,\n\t\t};\n\t}\n\n\t/**\n\t * The one authoritative live session for the active item.\n\t *\n\t * Section and item renderers receive this exact instance. Serialized item-session\n\t * state is reserved for persistence and restore, never for synchronizing a second\n\t * live player.\n\t */\n\tpublic getCurrentItemSession(): ItemSession | null {\n\t\treturn this.currentItemSession;\n\t}\n\n\tpublic getCurrentSectionItemRefs(): SectionItemRefView[] {\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (!current) return [];\n\n\t\treturn this.items\n\t\t\t.filter((item) => item.section.identifier === current.section.identifier)\n\t\t\t.map((item) => {\n\t\t\t\tconst itemRef = item.item as SecureItemRef & { href?: string; title?: string };\n\t\t\t\treturn {\n\t\t\t\t\tidentifier: itemRef.identifier,\n\t\t\t\t\thref: itemRef.href,\n\t\t\t\t\ttitle: itemRef.title,\n\t\t\t\t\titemXml: itemRef.itemXml,\n\t\t\t\t\tdeliveryContext: cloneData(itemRef.deliveryContext),\n\t\t\t\t};\n\t\t\t});\n\t}\n\n\tpublic getResponsesForItem(itemIdentifier: string): Record<string, unknown> {\n\t\treturn cloneData(this.sessionCoordinator.getResponses(itemIdentifier)) ?? {};\n\t}\n\n\tpublic getCurrentSharedRubricBlocks(): AssessmentRubricBlock[] {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return [];\n\n\t\treturn [\n\t\t\t...(q.testPart.rubricBlocks ?? []),\n\t\t\t...(q.section.rubricBlocks ?? []),\n\t\t].map((block) => ({ ...block, view: [...block.view] }));\n\t}\n\n\tpublic getCurrentRubricBlocks(): AssessmentRubricBlock[] {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return [];\n\t\treturn q.section.rubricBlocks || q.testPart.rubricBlocks || [];\n\t}\n\n\t/**\n\t * Test feedback shown now, test-level first, then each test part's. Nothing shows before outcome\n\t * processing first runs. `during` feedback then shows by its outcome, test-part `during`\n\t * feedback while its part is current; `atEnd` feedback shows once the test, or its test part,\n\t * has ended.\n\t */\n\tpublic getVisibleFeedback(): VisibleTestFeedback[] {\n\t\tconst outcomes = this.testOutcomes;\n\t\tconst parts = this.assessment.testParts ?? [];\n\t\tconst hasStructured =\n\t\t\t(this.assessment.testFeedback?.length ?? 0) > 0 || parts.some((part) => (part.testFeedback?.length ?? 0) > 0);\n\t\tif (!hasStructured) {\n\t\t\treturn this.finalized && this.legacyFeedback\n\t\t\t\t? [{ key: 'testFeedback', identifier: 'testFeedback', content: this.legacyFeedback, access: 'atEnd' }]\n\t\t\t\t: [];\n\t\t}\n\t\tif (!outcomes) return [];\n\n\t\tconst shown: VisibleTestFeedback[] = [];\n\t\tconst add = (items: TestFeedbackItem[] | undefined, ended: boolean, current: boolean, part?: SecureTestPart) => {\n\t\t\titems?.forEach((fb, index) => {\n\t\t\t\tif (fb.access === 'atEnd' ? !ended : !current) return;\n\t\t\t\tif (!isShownByIdentifier(outcomes[fb.outcomeIdentifier] ?? null, fb.identifier, fb.showHide)) return;\n\t\t\t\tshown.push({\n\t\t\t\t\tkey: part ? `part:${part.identifier}:${index}` : `test:${index}`,\n\t\t\t\t\tidentifier: fb.identifier,\n\t\t\t\t\tcontent: fb.content,\n\t\t\t\t\taccess: fb.access,\n\t\t\t\t\t...(part ? { testPartIdentifier: part.identifier } : {}),\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\t\tadd(this.assessment.testFeedback, this.finalized, true);\n\t\tconst currentPart = this.currentTestPartIndex();\n\t\tparts.forEach((part, index) => {\n\t\t\tadd(part.testFeedback, this.finalized || currentPart > index, currentPart === index, part);\n\t\t});\n\t\treturn shown;\n\t}\n\n\tprivate currentTestPartIndex(): number {\n\t\tconst part = this.items[this.currentItemIndex]?.testPart;\n\t\treturn part ? (this.assessment.testParts ?? []).findIndex((p) => p.identifier === part.identifier) : -1;\n\t}\n\n\tprivate setTestOutcomes(outcomes: TestOutcomeValues | undefined): void {\n\t\tif (!outcomes) return;\n\t\tthis.testOutcomes = cloneData(outcomes)!;\n\t\tthis.notifyTestFeedbackChange();\n\t}\n\n\tpublic updateResponse(responseId: string, value: unknown): void {\n\t\tconst active = this.items[this.currentItemIndex];\n\t\tif (!active) return;\n\t\tif (this.currentItemSession) {\n\t\t\tthis.currentItemSession.dispatch({\n\t\t\t\taction: 'setResponse',\n\t\t\t\tresponseIdentifier: responseId,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionCoordinator.updateResponseForItem(active.identifier, responseId, value);\n\t\tthis.notifyResponseChange();\n\t}\n\n\t/**\n\t * Update a response for a specific item.\n\t * Useful when response events are observed outside the current-item renderer and we\n\t * want to be explicit about which item receives the response (some assessments reuse\n\t * the same responseIdentifier like \"RESPONSE\" across items).\n\t */\n\tpublic updateResponseForItem(itemIdentifier: string, responseId: string, value: unknown): void {\n\t\tconst active = this.items[this.currentItemIndex];\n\t\tif (active?.identifier === itemIdentifier && this.currentItemSession) {\n\t\t\tconst liveValue = this.currentItemSession.state().responses[responseId];\n\t\t\tif (!responseValuesEqual(liveValue, value)) {\n\t\t\t\t// Programmatic/host callers still enter through this API. Browser item\n\t\t\t\t// adapters have already dispatched, so their equal value is not applied twice.\n\t\t\t\tthis.currentItemSession.dispatch({\n\t\t\t\t\taction: 'setResponse',\n\t\t\t\t\tresponseIdentifier: responseId,\n\t\t\t\t\tvalue,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst persisted = this.sessionCoordinator.getPersistedItemSession(itemIdentifier);\n\t\tif (persisted && !isWritableItemLifecycle(persisted.lifecycleStatus)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot update responses while item session is ${persisted.lifecycleStatus}`,\n\t\t\t);\n\t\t}\n\n\t\tthis.sessionCoordinator.updateResponseForItem(itemIdentifier, responseId, value);\n\t\tthis.notifyResponseChange();\n\t}\n\n\t/**\n\t * Get current unsaved responses for the active item.\n\t * (Useful for host integrations / web components.)\n\t */\n\tpublic getResponses(): Record<string, unknown> {\n\t\tif (this.currentItemSession) {\n\t\t\treturn cloneData(this.currentItemSession.state().responses) ?? {};\n\t\t}\n\t\treturn this.sessionCoordinator.getActiveResponses();\n\t}\n\n\tpublic saveCurrentItemSession(): SerializedItemSessionState | null {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q || !this.currentItemSession) return null;\n\n\t\tconst currentView = this.currentItemSession.state();\n\t\tconst transition = isWritableItemLifecycle(currentView.lifecycleStatus)\n\t\t\t? this.currentItemSession.dispatch({ action: 'suspendAttempt' })\n\t\t\t: null;\n\t\tconst itemSession = transition?.result?.sessionState ?? this.currentItemSession.serialize();\n\t\tconst responses = cloneData(transition?.current.responses ?? currentView.responses) ?? {};\n\t\tthis.sessionCoordinator.saveItemSession(\n\t\t\tq.identifier,\n\t\t\tresponses,\n\t\t\titemSession,\n\t\t\ttransition?.current.duration ?? currentView.duration,\n\t\t);\n\t\treturn itemSession;\n\t}\n\n\tprivate endItemSessionForSubmit(\n\t\tq: FlatItem,\n\t\tresponses: Record<string, unknown>,\n\t\titemSession?: SerializedItemSessionState,\n\t): SerializedItemSessionState {\n\t\tconst validateResponses = this.sessionCoordinator.mustValidateResponses(q.identifier);\n\t\tconst endAttempt = (session: ItemSession): SerializedItemSessionState => {\n\t\t\tconst result = session.dispatch({ action: 'endAttempt', validateResponses }).result;\n\t\t\tif (result?.validation && !result.validation.valid) {\n\t\t\t\tthrow new Error(result.validation.issues[0]?.message || `Submit failed: invalid response for item ${q.identifier}`);\n\t\t\t}\n\t\t\treturn result?.sessionState ?? session.serialize();\n\t\t};\n\t\tconst active = this.items[this.currentItemIndex];\n\t\tif (\n\t\t\tactive === q &&\n\t\t\tthis.currentItemSession &&\n\t\t\tthis.currentItemSession.state().lifecycleStatus !== 'suspended'\n\t\t) {\n\t\t\treturn endAttempt(this.currentItemSession);\n\t\t}\n\n\t\tconst session = this.getItemDefinition(q).openSession({\n\t\t\trestore: itemSession,\n\t\t\tresponses: itemSession ? undefined : responses,\n\t\t\tactivate: true,\n\t\t});\n\t\ttry {\n\t\t\treturn endAttempt(session);\n\t\t} finally {\n\t\t\tsession.dispose();\n\t\t}\n\t}\n\n\tprivate getItemDefinition(q: FlatItem): AssessmentItemDefinition {\n\t\tconst cached = this.itemDefinitions.get(q.identifier);\n\t\tif (cached) return cached;\n\n\t\tconst definition = createAssessmentItemDefinition({\n\t\t\titemXml: q.item.itemXml,\n\t\t\t// The assessment host chooses the authorized delivery role. Item refs are\n\t\t\t// content records and must not silently widen or narrow session capabilities.\n\t\t\trole: this.config.role ?? 'candidate',\n\t\t\ti18nProvider: this.i18nProvider,\n\t\t\tpnp: this.config.pnp,\n\t\t\tsecurity: this.config.security,\n\t\t\tpci: this.config.pci,\n\t\t\tplugins: this.config.plugins,\n\t\t\tdeliveryContext: q.item.deliveryContext,\n\t\t});\n\t\tthis.itemDefinitions.set(q.identifier, definition);\n\t\treturn definition;\n\t}\n\n\tprivate mirrorSessionResponses(\n\t\titemIdentifier: string,\n\t\tresponses: Readonly<Record<string, unknown>>,\n\t): boolean {\n\t\tconst current = this.sessionCoordinator.getResponses(itemIdentifier);\n\t\tif (responseValuesEqual(current, responses)) return false;\n\n\t\tconst snapshot = cloneResponseRecord(responses);\n\t\tthis.state.itemResponses[itemIdentifier] = snapshot as any;\n\t\tthis.sessionCoordinator.markAnswered(itemIdentifier, snapshot);\n\t\treturn true;\n\t}\n\n\tprivate attachCurrentItemSession(q: FlatItem, session: ItemSession): void {\n\t\tthis.currentItemSession = session;\n\t\tthis.currentItemSessionUnsubscribe = session.subscribe((transition) => {\n\t\t\tif (this.currentItemSession !== session) return;\n\t\t\tif (this.mirrorSessionResponses(q.identifier, transition.current.responses)) {\n\t\t\t\tthis.notifyResponseChange();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate releaseCurrentItemSession(): void {\n\t\tthis.currentItemSessionUnsubscribe?.();\n\t\tthis.currentItemSessionUnsubscribe = null;\n\t\tthis.currentItemSession?.dispose();\n\t\tthis.currentItemSession = null;\n\t}\n\n\t/**\n\t * Get the current session state snapshot (client-side view).\n\t * Note: backend remains authoritative; this is intended for simple save/resume.\n\t */\n\tpublic getState(options: { includeItemSessions?: boolean } = {}): AssessmentSessionState {\n\t\tconst snapshot = this.sessionCoordinator.snapshot(options);\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (options.includeItemSessions && current && this.currentItemSession) {\n\t\t\t// Navigation snapshots may predate edits made after revisiting this item.\n\t\t\t// Serialize the live authority without suspending the learner's attempt.\n\t\t\tsnapshot.itemSessions = {\n\t\t\t\t...snapshot.itemSessions,\n\t\t\t\t[current.identifier]: this.currentItemSession.serialize(),\n\t\t\t};\n\t\t}\n\t\tconst timing = this.timeManager?.getState();\n\t\tif (timing) {\n\t\t\tsnapshot.timing = {\n\t\t\t\tstartedAt: timing.startedAt,\n\t\t\t\titemTimes: { ...timing.itemTimes },\n\t\t\t\tsectionTimes: { ...timing.sectionTimes },\n\t\t\t\ttestPartTimes: { ...timing.testPartTimes },\n\t\t\t\ttotalTime: timing.totalElapsed,\n\t\t\t\tcurrentItemIdentifier: timing.currentItemId,\n\t\t\t\tcurrentSectionIdentifier: timing.currentSectionId,\n\t\t\t\tcurrentTestPartIdentifier: timing.currentTestPartId,\n\t\t\t\tisPaused: timing.isPaused,\n\t\t\t};\n\t\t}\n\t\treturn snapshot;\n\t}\n\n\t/**\n\t * Restore a previously saved session state.\n\t */\n\tpublic async restoreState(state: AssessmentSessionState): Promise<void> {\n\t\tthis.state = state;\n\t\tthis.restoreTimeTracking(state.timing);\n\n\t\t// Restore visited state for UI navigation hints.\n\t\tconst visitedIdx = (state.visitedItems || [])\n\t\t\t.map((id) => this.items.findIndex((q) => q.identifier === id))\n\t\t\t.filter((i) => i >= 0);\n\t\tthis.navigationManager.restoreState(visitedIdx);\n\n\t\tconst currentId = state.currentItemIdentifier;\n\t\tconst idx = currentId ? this.items.findIndex((q) => q.identifier === currentId) : -1;\n\t\tif (idx >= 0) {\n\t\t\tawait this.navigateTo(idx, { restoring: true });\n\t\t} else if (this.items.length > 0) {\n\t\t\tawait this.navigateTo(0, { restoring: true });\n\t\t}\n\t}\n\n\tprivate restoreTimeTracking(timing: AssessmentSessionState['timing']): void {\n\t\tthis.timeManager?.restoreState({\n\t\t\ttotalElapsed: timing.totalTime,\n\t\t\titemTimes: { ...timing.itemTimes },\n\t\t\tsectionTimes: { ...(timing.sectionTimes ?? {}) },\n\t\t\ttestPartTimes: { ...(timing.testPartTimes ?? {}) },\n\t\t\tstartedAt: timing.startedAt,\n\t\t\tcurrentItemId: timing.currentItemIdentifier,\n\t\t\tcurrentSectionId: timing.currentSectionIdentifier,\n\t\t\tcurrentTestPartId: timing.currentTestPartIdentifier,\n\t\t\tisPaused: timing.isPaused === true,\n\t\t});\n\t}\n\n\tpublic async navigateTo(index: number, options: { restoring?: boolean } = {}): Promise<void> {\n\t\tif (index < 0 || index >= this.items.length) throw new Error(`Invalid item index: ${index}`);\n\n\t\t// Enforce navigation rules (UI hints, still backend-authoritative for real deployments).\n\t\tif (!options.restoring && this.currentItemIndex >= 0 && !this.canNavigateByTestPart(index, this.currentItemIndex)) {\n\t\t\tconst currentMode = this.items[this.currentItemIndex]?.testPart.navigationMode ?? this.assessment.navigationMode;\n\t\t\tif (currentMode === 'linear' && index > this.nextUnlockedIndex(this.currentItemIndex)) {\n\t\t\t\tthrow new Error('In linear navigation mode, you can only move to the next question.');\n\t\t\t}\n\t\t\tthrow new Error('Navigation is not allowed.');\n\t\t}\n\t\tconst target = this.items[index];\n\t\tif (!options.restoring && target && this.isItemLocked(target)) {\n\t\t\tthrow new Error('The time limit for this question has expired.');\n\t\t}\n\t\tif (!options.restoring && target && !this.sessionCoordinator.canReview(target.identifier)) {\n\t\t\tthrow new Error('You cannot go back to previous questions in this assessment.');\n\t\t}\n\n\t\tconst currentItem = this.items[this.currentItemIndex];\n\t\tif (!options.restoring && currentItem && target) {\n\t\t\tthis.assertTransitionMinimum(currentItem, target);\n\t\t\tif (currentItem.testPart !== target.testPart\n\t\t\t\t&& (currentItem.testPart.submissionMode ?? this.assessment.submissionMode) === 'simultaneous') {\n\t\t\t\t// Commit this part before leaving it; a failed request keeps the learner\n\t\t\t\t// in the current part so its remaining answers can be retried.\n\t\t\t\tawait this.submitSimultaneousItems(this.items.filter((q) => q.testPart === currentItem.testPart));\n\t\t\t}\n\t\t}\n\t\tif (!options.restoring && this.currentItemIndex === index && this.currentItemSession) {\n\t\t\treturn;\n\t\t}\n\t\tconst currentSessionStatus = currentItem\n\t\t\t? this.currentItemSession?.state().lifecycleStatus ??\n\t\t\t\tthis.state.itemSessions?.[currentItem.identifier]?.lifecycleStatus\n\t\t\t: undefined;\n\t\tif (\n\t\t\t!options.restoring &&\n\t\t\tthis.currentItemIndex >= 0 &&\n\t\t\tthis.currentItemIndex !== index &&\n\t\t\tcurrentSessionStatus !== 'closed'\n\t\t) {\n\t\t\tthis.saveCurrentItemSession();\n\t\t}\n\t\tif (currentItem && this.currentItemIndex !== index) {\n\t\t\tthis.timeManager?.endItem(currentItem.identifier);\n\t\t}\n\n\t\tthis.currentItemIndex = index;\n\t\tconst q = this.items[index]!;\n\t\tthis.state.currentItemIdentifier = q.identifier;\n\t\tthis.timeManager?.activateScopes({\n\t\t\ttestPart: { identifier: q.testPart.identifier, timeLimits: q.testPart.timeLimits },\n\t\t\tsection: { identifier: q.section.identifier, timeLimits: q.section.timeLimits },\n\t\t\titem: { identifier: q.identifier, timeLimits: q.item.timeLimits },\n\t\t});\n\n\t\t// Restore responses into one live session owned by the assessment. The section\n\t\t// composition and item renderer receive this exact object.\n\t\tconst responses = this.sessionCoordinator.activateItem(q.identifier);\n\t\tconst restoredItemSession = this.state.itemSessions?.[q.identifier];\n\t\tconst control = this.sessionCoordinator.getItemSettings(q.identifier);\n\t\tthis.releaseCurrentItemSession();\n\t\tconst session = this.getItemDefinition(q).openSession({\n\t\t\trestore: restoredItemSession,\n\t\t\tresponses: restoredItemSession ? undefined : responses,\n\t\t\tactivate: true,\n\t\t\ttemplateDefaults: restoredItemSession ? undefined : this.evaluateTemplateDefaults(q),\n\t\t\tpresentation: {\n\t\t\t\t// Feedback during an adaptive item's attempts is part of the item, whatever showFeedback says.\n\t\t\t\tshowFeedback: control.showFeedback === true || isAdaptiveItemXml(q.item.itemXml),\n\t\t\t\tshowSolution: control.showSolution === true,\n\t\t\t},\n\t\t});\n\t\tthis.attachCurrentItemSession(q, session);\n\n\t\tthis.notifyItemChange();\n\t\tthis.notifySectionChange();\n\t\tif (currentItem?.testPart.identifier !== q.testPart.identifier) this.notifyTestFeedbackChange();\n\t}\n\n\tpublic async navigateToSection(sectionId: string): Promise<void> {\n\t\tconst idx = this.items.findIndex((q) => q.section.identifier === sectionId);\n\t\tif (idx >= 0) await this.navigateTo(idx);\n\t}\n\n\tpublic async next(): Promise<void> {\n\t\tconst state = this.getNavigationState();\n\t\tif (!state.canNext) return;\n\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (q) {\n\t\t\tconst responses = this.sessionCoordinator.getActiveResponses();\n\t\t\tthis.sessionCoordinator.markAnswered(q.identifier, responses);\n\n\t\t\tconst navAway = this.sessionCoordinator.canNavigateAway(q.identifier, responses);\n\t\t\tif (!navAway.allowed) {\n\t\t\t\tthrow new Error(navAway.reason || 'You must answer this question before continuing.');\n\t\t\t}\n\n\t\t\t// In individual submission mode, submit the current item before moving forward\n\t\t\t// unless its attempts are used up or it is already closed.\n\t\t\tconst lifecycle = this.currentItemSession?.state().lifecycleStatus;\n\t\t\tif (\n\t\t\t\t(q.testPart.submissionMode ?? this.assessment.submissionMode) === 'individual' &&\n\t\t\t\tthis.sessionCoordinator.canSubmit(q.identifier) &&\n\t\t\t\tlifecycle !== 'closed'\n\t\t\t) {\n\t\t\t\tconst before = this.currentItemIndex;\n\t\t\t\tawait this.submitCurrentItem();\n\t\t\t\t// submitCurrentItem may branch/navigate; if it did, we're done.\n\t\t\t\tif (this.currentItemIndex !== before) return;\n\t\t\t}\n\t\t}\n\n\t\tconst nextIndex = this.nextUnlockedIndex(this.currentItemIndex);\n\t\tif (nextIndex < 0) return;\n\t\tawait this.navigateTo(nextIndex);\n\t}\n\n\tpublic async previous(): Promise<void> {\n\t\tconst state = this.getNavigationState();\n\t\tif (!state.canPrevious) return;\n\t\tawait this.navigateTo(this.currentItemIndex - 1);\n\t}\n\n\t/** Submit current item (server-side scoring) */\n\tpublic async submitCurrentItem(): Promise<ItemResult> {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) throw new Error('No current item');\n\t\tthis.assertMinimumTime('item', q);\n\n\t\tconst submittedAt = Date.now();\n\t\tlet itemSession: SerializedItemSessionState | undefined;\n\t\tconst submittedSession = this.currentItemSession;\n\t\tconst preSubmitSession = submittedSession?.serialize();\n\t\tconst responses = this.currentItemSession\n\t\t\t? cloneResponseRecord(this.currentItemSession.state().responses)\n\t\t\t: this.sessionCoordinator.getActiveResponses();\n\t\tlet res: Awaited<ReturnType<BackendAdapter['submitResponses']>>;\n\t\ttry {\n\t\t\tif (submittedSession) {\n\t\t\t\tconst transition = submittedSession.dispatch({\n\t\t\t\t\taction: 'endAttempt',\n\t\t\t\t\tvalidateResponses: this.sessionCoordinator.mustValidateResponses(q.identifier),\n\t\t\t\t});\n\t\t\t\tconst attempt = transition.result;\n\t\t\t\tif (!attempt) throw new Error('Item session did not produce an end-attempt result');\n\t\t\t\tif (attempt.validation && !attempt.validation.valid) {\n\t\t\t\t\tthrow new Error(attempt.validation.issues[0]?.message || 'Submit failed: invalid response');\n\t\t\t\t}\n\t\t\t\titemSession = attempt.sessionState;\n\t\t\t}\n\t\t\tres = await this.backend.submitResponses({\n\t\t\t\tsessionId: this.sessionId,\n\t\t\t\titemIdentifier: q.identifier,\n\t\t\t\tresponses: responses as any,\n\t\t\t\tsubmittedAt,\n\t\t\t\ttimeSpent: itemSession?.duration,\n\t\t\t\ttiming: this.getSubmitTimingEvidence(q, itemSession?.duration ?? 0),\n\t\t\t\titemSession: this.config.sendItemSessionToBackend ? itemSession : undefined,\n\t\t\t\tcomment: this.sessionCoordinator.getItemComment(q.identifier),\n\t\t\t});\n\n\t\t\tif (!res.success || !res.result) {\n\t\t\t\tthrow new Error(res.error || 'Submit failed');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Ending an attempt is a local provisional commit until the backend accepts\n\t\t\t// it. Restore the exact pre-submit lifecycle so a transient failure can be\n\t\t\t// retried without a closed item or a double-counted attempt.\n\t\t\tif (\n\t\t\t\tsubmittedSession &&\n\t\t\t\tpreSubmitSession &&\n\t\t\t\tthis.currentItemSession === submittedSession &&\n\t\t\t\tthis.items[this.currentItemIndex] === q\n\t\t\t) {\n\t\t\t\tthis.releaseCurrentItemSession();\n\t\t\t\tthis.attachCurrentItemSession(\n\t\t\t\t\tq,\n\t\t\t\t\tthis.getItemDefinition(q).openSession({ restore: preSubmitSession }),\n\t\t\t\t);\n\t\t\t\tthis.notifyItemChange();\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (itemSession) {\n\t\t\tthis.sessionCoordinator.setItemSession(q.identifier, itemSession);\n\t\t}\n\n\t\tif (res.updatedState) {\n\t\t\tconst localResponses = cloneData(this.state.itemResponses || {})!;\n\t\t\tlocalResponses[q.identifier] = cloneResponseRecord(responses) as any;\n\t\t\tthis.sessionCoordinator.replaceStatePreservingResponsesAndSessions(\n\t\t\t\tres.updatedState,\n\t\t\t\tlocalResponses,\n\t\t\t\tcloneData(this.state.itemSessions || {})!,\n\t\t\t);\n\t\t} else {\n\t\t\t// Minimal state update when backend doesn't return full state.\n\t\t\tthis.state.itemScores = this.state.itemScores || {};\n\t\t\tthis.state.itemScores[q.identifier] = res.result;\n\t\t\tthis.sessionCoordinator.markVisited(q.identifier);\n\t\t\tthis.state.itemResponses[q.identifier] = responses as any;\n\t\t\tif (itemSession) {\n\t\t\t\tthis.sessionCoordinator.setItemSession(q.identifier, itemSession);\n\t\t\t}\n\t\t}\n\n\t\tthis.setTestOutcomes(res.outcomes);\n\n\t\tconst itemResult: ItemResult = {\n\t\t\titemIdentifier: q.identifier,\n\t\t\tscore: res.result.score,\n\t\t\tmaxScore: res.result.maxScore,\n\t\t\tresponses: { ...responses },\n\t\t};\n\t\tthis.sessionCoordinator.setItemResult(itemResult);\n\n\t\t// Track item session rules (review/attempts) and visited items for navigation hints.\n\t\ttry {\n\t\t\tthis.sessionCoordinator.recordAttempt(q.identifier);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t\tthis.sessionCoordinator.markAnswered(q.identifier, responses);\n\t\tthis.navigationManager.markVisited(this.currentItemIndex);\n\n\t\t// Apply backend branching decision if provided.\n\t\t// Special QTI targets EXIT_TEST / EXIT_TESTPART / EXIT_SECTION trigger finalization.\n\t\tif (res.nextItemIdentifier) {\n\t\t\tconst special = res.nextItemIdentifier;\n\t\t\tif (special === 'EXIT_TEST') {\n\t\t\t\t// Finalize immediately — no further navigation\n\t\t\t\tfor (const l of this.completeListeners) l();\n\t\t\t\tthis.config.onComplete?.();\n\t\t\t} else if (special === 'EXIT_TESTPART' || special === 'EXIT_SECTION') {\n\t\t\t\t// Advance past all remaining items in the current testPart or section\n\t\t\t\tconst currentItem = this.items[this.currentItemIndex];\n\t\t\t\tconst isSection = special === 'EXIT_SECTION';\n\t\t\t\tconst nextIdx = this.items.findIndex((item, i) =>\n\t\t\t\t\ti > this.currentItemIndex &&\n\t\t\t\t\t(isSection\n\t\t\t\t\t\t? item.section.identifier !== currentItem?.section.identifier\n\t\t\t\t\t\t: item.testPart.identifier !== currentItem?.testPart.identifier)\n\t\t\t\t);\n\t\t\t\tif (nextIdx >= 0) {\n\t\t\t\t\tawait this.navigateTo(nextIdx, { restoring: true });\n\t\t\t\t} else {\n\t\t\t\t\t// No further items — signal completion\n\t\t\t\t\tfor (const l of this.completeListeners) l();\n\t\t\t\t\tthis.config.onComplete?.();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst nextIdx = this.items.findIndex((x) => x.identifier === special);\n\t\t\t\tif (nextIdx >= 0) {\n\t\t\t\t\tawait this.navigateTo(nextIdx, { restoring: true });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn itemResult;\n\t}\n\n\tprivate canPrevious(): boolean {\n\t\tif (this.currentItemIndex <= 0) return false;\n\t\tconst prev = this.items[this.currentItemIndex - 1];\n\t\tif (!prev || this.isItemLocked(prev)) return false;\n\t\tif (!this.canNavigateByTestPart(this.currentItemIndex - 1, this.currentItemIndex)) return false;\n\t\treturn this.sessionCoordinator.canReview(prev.identifier);\n\t}\n\n\tprivate canNext(): boolean {\n\t\tif (this.currentItemIndex < 0) return false;\n\t\tconst nextIdx = this.nextUnlockedIndex(this.currentItemIndex);\n\t\tif (nextIdx < 0) return false;\n\t\tif (!this.canNavigateByTestPart(nextIdx, this.currentItemIndex)) return false;\n\t\t// Note: itemSessionControl constraints on leaving current item are enforced in next().\n\t\treturn true;\n\t}\n\n\tprivate canNavigateByTestPart(targetIndex: number, currentIndex: number): boolean {\n\t\tif (targetIndex < 0 || targetIndex >= this.items.length) return false;\n\t\tconst current = this.items[currentIndex];\n\t\tconst target = this.items[targetIndex];\n\t\tif (!current || !target) return false;\n\t\t// Items locked by an expired time limit are passed over.\n\t\tconst nextIndex = this.nextUnlockedIndex(currentIndex);\n\t\tif (current.testPart !== target.testPart) {\n\t\t\t// QTI testParts are delivered in sequence. A candidate may enter the next\n\t\t\t// part, but cannot jump across parts or return to a completed part.\n\t\t\treturn targetIndex === nextIndex;\n\t\t}\n\t\tconst mode = current.testPart.navigationMode ?? this.assessment.navigationMode ?? 'nonlinear';\n\t\treturn mode === 'nonlinear' || targetIndex === currentIndex || targetIndex === nextIndex;\n\t}\n\n\tprivate async submitSimultaneousItems(items: readonly FlatItem[]): Promise<void> {\n\t\tif (items.every((q) => this.sessionCoordinator.hasItemResult(q.identifier))) return;\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tconst submittedItem = current && items.includes(current) ? current : undefined;\n\t\tconst preSubmitSession = submittedItem ? this.currentItemSession?.serialize() : undefined;\n\t\tlet allItemSessions: NonNullable<AssessmentSessionState['itemSessions']> = {};\n\n\t\ttry {\n\t\t\t// Suspending the rendered session gives the UI one non-writable state while\n\t\t\t// backend submission is in flight. Detached sessions perform the provisional\n\t\t\t// end-attempt work for every item.\n\t\t\tif (submittedItem) this.saveCurrentItemSession();\n\t\t\t// Preserve client-collected responses across backend state updates.\n\t\t\t// Some backend adapters return an updatedState snapshot that may only include\n\t\t\t// responses for items that have been submitted so far, which would otherwise\n\t\t\t// wipe out responses for later items during this loop.\n\t\t\tconst allItemResponses = cloneData(this.state.itemResponses || {}) as any;\n\t\t\tallItemSessions = cloneData(this.state.itemSessions || {})!;\n\n\t\t\tfor (const q of items) {\n\t\t\t\tif (this.sessionCoordinator.hasItemResult(q.identifier)) continue;\n\t\t\t\tconst submittedAt = Date.now();\n\t\t\t\tconst responsesForItem = (allItemResponses?.[q.identifier] || {}) as any;\n\t\t\t\tconst itemSession = this.endItemSessionForSubmit(\n\t\t\t\t\tq,\n\t\t\t\t\tresponsesForItem,\n\t\t\t\t\tallItemSessions[q.identifier],\n\t\t\t\t);\n\t\t\t\tallItemSessions[q.identifier] = itemSession;\n\t\t\t\tconst res = await this.backend.submitResponses({\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\titemIdentifier: q.identifier,\n\t\t\t\t\tresponses: responsesForItem,\n\t\t\t\t\tsubmittedAt,\n\t\t\t\t\ttimeSpent: itemSession.duration,\n\t\t\t\t\ttiming: this.getSubmitTimingEvidence(q, itemSession.duration),\n\t\t\t\t\titemSession: this.config.sendItemSessionToBackend ? itemSession : undefined,\n\t\t\t\t\tcomment: this.sessionCoordinator.getItemComment(q.identifier),\n\t\t\t\t});\n\t\t\t\tif (!res.success || !res.result) {\n\t\t\t\t\tthrow new Error(res.error || `Submit failed for item ${q.identifier}`);\n\t\t\t\t}\n\t\t\t\tif (res.updatedState) {\n\t\t\t\t\tthis.sessionCoordinator.replaceStatePreservingResponsesAndSessions(\n\t\t\t\t\t\tres.updatedState,\n\t\t\t\t\t\tallItemResponses,\n\t\t\t\t\t\tallItemSessions,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.state.itemScores = this.state.itemScores || {};\n\t\t\t\t\tthis.state.itemScores[q.identifier] = res.result;\n\t\t\t\t\tthis.sessionCoordinator.markVisited(q.identifier);\n\t\t\t\t\tthis.state.itemResponses[q.identifier] = responsesForItem;\n\t\t\t\t\tthis.sessionCoordinator.setItemSession(q.identifier, itemSession);\n\t\t\t\t\tthis.sessionCoordinator.recordAttempt(q.identifier);\n\t\t\t\t}\n\t\t\t\tthis.sessionCoordinator.setItemResult({\n\t\t\t\t\titemIdentifier: q.identifier,\n\t\t\t\t\tscore: res.result.score,\n\t\t\t\t\tmaxScore: res.result.maxScore,\n\t\t\t\t\tresponses: this.state.itemResponses[q.identifier] || {},\n\t\t\t\t});\n\t\t\t\tthis.setTestOutcomes(res.outcomes);\n\t\t\t}\n\n\t\t\t// The attached item must represent the same accepted lifecycle as persistence.\n\t\t\t// Replace the provisional suspended object with one restored from the accepted\n\t\t\t// closed state; no second live state owner remains.\n\t\t\tif (submittedItem && this.items[this.currentItemIndex] === submittedItem) {\n\t\t\t\tconst accepted = allItemSessions[submittedItem.identifier];\n\t\t\t\tif (accepted) {\n\t\t\t\t\tthis.releaseCurrentItemSession();\n\t\t\t\t\tthis.attachCurrentItemSession(\n\t\t\t\t\t\tsubmittedItem,\n\t\t\t\t\t\tthis.getItemDefinition(submittedItem).openSession({ restore: accepted }),\n\t\t\t\t\t);\n\t\t\t\t\tthis.notifyItemChange();\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// The backend accepts simultaneous items one request at a time. Keep earlier\n\t\t\t// accepted items committed so retry cannot double-submit them. If the rendered\n\t\t\t// item was not accepted, restore only that item to its exact writable state.\n\t\t\tif (submittedItem && this.items[this.currentItemIndex] === submittedItem) {\n\t\t\t\tconst accepted = this.sessionCoordinator.hasItemResult(submittedItem.identifier)\n\t\t\t\t\t? allItemSessions[submittedItem.identifier]\n\t\t\t\t\t: undefined;\n\t\t\t\tconst restored = accepted ?? preSubmitSession;\n\t\t\t\tif (!accepted && preSubmitSession) {\n\t\t\t\t\tthis.sessionCoordinator.saveItemSession(\n\t\t\t\t\t\tsubmittedItem.identifier,\n\t\t\t\t\t\tcloneResponseRecord(valuesFromItemSession(preSubmitSession)),\n\t\t\t\t\t\tpreSubmitSession,\n\t\t\t\t\t\tpreSubmitSession.duration,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.releaseCurrentItemSession();\n\t\t\t\tif (restored) {\n\t\t\t\t\tthis.attachCurrentItemSession(\n\t\t\t\t\t\tsubmittedItem,\n\t\t\t\t\t\tthis.getItemDefinition(submittedItem).openSession({ restore: restored }),\n\t\t\t\t\t);\n\t\t\t\t\tthis.notifyItemChange();\n\t\t\t\t\tthis.notifyResponseChange();\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Submit entire assessment (finalize on backend) */\n\tpublic async submit(): Promise<AssessmentResults> {\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (current) {\n\t\t\tthis.assertMinimumTime('item', current);\n\t\t\tthis.assertMinimumTime('section', current);\n\t\t\tthis.assertMinimumTime('testPart', current);\n\t\t\tthis.assertMinimumTime('assessment', current);\n\t\t}\n\t\t// Submission modes belong to test parts. The assessment-level field is only\n\t\t// a fallback for older hosts that do not supply a mode on each part.\n\t\tawait this.submitSimultaneousItems(this.items.filter((q) =>\n\t\t\t(q.testPart.submissionMode ?? this.assessment.submissionMode) === 'simultaneous',\n\t\t));\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (q && (q.testPart.submissionMode ?? this.assessment.submissionMode) === 'individual'\n\t\t\t&& !this.sessionCoordinator.hasItemResult(q.identifier)) {\n\t\t\tawait this.submitCurrentItem();\n\t\t}\n\n\t\tconst finalized: FinalizeAssessmentResponse = await this.backend.finalizeAssessment({\n\t\t\tsessionId: this.sessionId,\n\t\t});\n\t\tif (!finalized.success) throw new Error('Finalize failed');\n\n\t\t// Map backend itemScores to ItemResult[]\n\t\tconst itemScores = finalized.itemScores || {};\n\t\tconst itemResults: ItemResult[] = Object.values(itemScores).map((r: AssessmentScoringResult) => ({\n\t\t\titemIdentifier: r.itemIdentifier,\n\t\t\tscore: r.score,\n\t\t\tmaxScore: r.maxScore,\n\t\t\tresponses: this.state.itemResponses[r.itemIdentifier] || {},\n\t\t}));\n\n\t\t// Outcome processing has run by the end of the test, so a backend returning no outcomes\n\t\t// leaves them all NULL.\n\t\tthis.finalized = true;\n\t\tthis.legacyFeedback = finalized.feedback;\n\t\tthis.testOutcomes = cloneData(finalized.outcomes ?? this.testOutcomes ?? {})!;\n\t\tthis.notifyTestFeedbackChange();\n\n\t\tthis.notifyComplete();\n\t\tif (this.config.onComplete) this.config.onComplete();\n\n\t\treturn {\n\t\t\ttotalScore: finalized.totalScore,\n\t\t\tmaxScore: finalized.maxScore,\n\t\t\titemResults,\n\t\t\tcompletedAt: new Date(finalized.finalizedAt),\n\t\t};\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Session info + time helpers\n\t// ---------------------------------------------------------------------------\n\n\tpublic getItemSessionInfo(_itemIdentifier?: string): {\n\t\tcanSubmit: boolean;\n\t\tremainingAttempts: number | null;\n\t\tattemptCount: number;\n\t\tshowFeedback: boolean;\n\t\tshowSolution: boolean;\n\t\tcanReview: boolean;\n\t\tcanSkip: boolean;\n\t\tcanComment: boolean;\n\t} | null {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tif (!q) return null;\n\t\tconst id = q.identifier;\n\n\t\treturn this.sessionCoordinator.getItemSessionInfo(id);\n\t}\n\n\t/**\n\t * Records the candidate's comment on an item (QTI `allowComment`), sent with its next submission.\n\t * Defaults to the current item; throws when the item does not allow comments.\n\t */\n\tpublic setItemComment(comment: string, itemIdentifier?: string): void {\n\t\tconst id = itemIdentifier ?? this.items[this.currentItemIndex]?.identifier;\n\t\tif (!id) throw new Error('No current item');\n\t\tthis.sessionCoordinator.setItemComment(id, comment);\n\t}\n\n\tpublic getItemComment(itemIdentifier?: string): string | undefined {\n\t\tconst id = itemIdentifier ?? this.items[this.currentItemIndex]?.identifier;\n\t\treturn id ? this.sessionCoordinator.getItemComment(id) : undefined;\n\t}\n\n\tpublic getRemainingTime(): number {\n\t\t// TimeManager exposes seconds getters.\n\t\treturn this.timeManager?.getRemainingSeconds() ?? 0;\n\t}\n\n\tpublic getElapsedTime(): number {\n\t\treturn this.timeManager?.getElapsedSeconds() ?? 0;\n\t}\n\n\tpublic isTimeExpired(): boolean {\n\t\treturn this.timeManager?.isExpired() ?? false;\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Event subscriptions\n\t// ---------------------------------------------------------------------------\n\n\tpublic onItemChange(listener: (index: number, total: number) => void): () => void {\n\t\tthis.itemChangeListeners.add(listener);\n\t\treturn () => this.itemChangeListeners.delete(listener);\n\t}\n\n\tpublic onSectionChange(listener: (index: number, total: number) => void): () => void {\n\t\tthis.sectionChangeListeners.add(listener);\n\t\treturn () => this.sectionChangeListeners.delete(listener);\n\t}\n\n\tpublic onResponseChange(listener: (responses: Record<string, unknown>) => void): () => void {\n\t\tthis.responseChangeListeners.add(listener);\n\t\treturn () => this.responseChangeListeners.delete(listener);\n\t}\n\n\tpublic onComplete(listener: () => void): () => void {\n\t\tthis.completeListeners.add(listener);\n\t\treturn () => this.completeListeners.delete(listener);\n\t}\n\n\t/** Called when `getVisibleFeedback()` may have changed: new outcomes, a new test part, or the end. */\n\tpublic onTestFeedbackChange(listener: () => void): () => void {\n\t\tthis.testFeedbackChangeListeners.add(listener);\n\t\treturn () => this.testFeedbackChangeListeners.delete(listener);\n\t}\n\n\tpublic onTimeWarning(listener: (remainingSeconds: number) => void): () => void {\n\t\tthis.timeWarningListeners.add(listener);\n\t\treturn () => this.timeWarningListeners.delete(listener);\n\t}\n\n\tpublic onTimeExpired(listener: () => void): () => void {\n\t\tthis.timeExpiredListeners.add(listener);\n\t\treturn () => this.timeExpiredListeners.delete(listener);\n\t}\n\n\tpublic onTimeTick(listener: (remainingSeconds: number, elapsedSeconds: number) => void): () => void {\n\t\tthis.timeTickListeners.add(listener);\n\t\treturn () => this.timeTickListeners.delete(listener);\n\t}\n\n\tpublic destroy(): void {\n\t\tthis.timeManager?.destroy();\n\t\tthis.releaseCurrentItemSession();\n\t\tthis.itemDefinitions.clear();\n\t\tthis.itemChangeListeners.clear();\n\t\tthis.sectionChangeListeners.clear();\n\t\tthis.responseChangeListeners.clear();\n\t\tthis.completeListeners.clear();\n\t\tthis.testFeedbackChangeListeners.clear();\n\t\tthis.timeWarningListeners.clear();\n\t\tthis.timeExpiredListeners.clear();\n\t\tthis.timeTickListeners.clear();\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// Internal notify helpers\n\t// ---------------------------------------------------------------------------\n\n\tprivate notifyItemChange(): void {\n\t\tfor (const l of this.itemChangeListeners) l(this.currentItemIndex, this.items.length);\n\t\tthis.config.onItemChange?.(this.currentItemIndex, this.items.length);\n\t}\n\n\tprivate notifySectionChange(): void {\n\t\tconst q = this.items[this.currentItemIndex];\n\t\tconst sectionIndex = q?.sectionIndex ?? 0;\n\t\tconst totalSections = this.getAllSections().length;\n\t\tfor (const l of this.sectionChangeListeners) l(sectionIndex, totalSections);\n\t\tthis.config.onSectionChange?.(sectionIndex, totalSections);\n\t}\n\n\tprivate notifyResponseChange(): void {\n\t\tconst responses = this.sessionCoordinator.getActiveResponses();\n\t\tfor (const l of this.responseChangeListeners) l(responses);\n\t\tthis.config.onResponseChange?.(responses);\n\t}\n\n\tprivate notifyComplete(): void {\n\t\tfor (const l of this.completeListeners) l();\n\t}\n\n\tprivate notifyTestFeedbackChange(): void {\n\t\tfor (const l of this.testFeedbackChangeListeners) l();\n\t}\n\n\tprivate notifyTimeWarning(remainingSeconds: number): void {\n\t\tfor (const l of this.timeWarningListeners) l(remainingSeconds);\n\t}\n\n\tprivate evaluateTemplateDefaults(q: FlatItem): Record<string, unknown> | undefined {\n\t\tconst defaults = q.item.templateDefaults;\n\t\tif (!defaults?.length) return undefined;\n\t\tconst declarations = testOutcomeDeclarations(this.assessment, this.testOutcomes ?? undefined);\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const { templateIdentifier, expressionXml } of defaults) {\n\t\t\tout[templateIdentifier] = plainQtiValue(evaluateTestExpression(expressionXml, declarations, Math.random));\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate isItemLocked(q: FlatItem): boolean {\n\t\treturn (\n\t\t\tthis.lockedScopes.has(`item:${q.identifier}`) ||\n\t\t\tthis.lockedScopes.has(`testPart:${q.testPart.identifier}`) ||\n\t\t\tq.sections.some((section) => this.lockedScopes.has(`section:${section.identifier}`))\n\t\t);\n\t}\n\n\tprivate nextUnlockedIndex(fromIndex: number): number {\n\t\tfor (let i = fromIndex + 1; i < this.items.length; i++) {\n\t\t\tif (!this.isItemLocked(this.items[i]!)) return i;\n\t\t}\n\t\treturn -1;\n\t}\n\n\t/**\n\t * A test part, section or item without late submission ran out of time: its items close for the\n\t * candidate, and delivery moves to the next item outside it.\n\t */\n\tprivate handleScopeExpired(scope: 'testPart' | 'section' | 'item', identifier: string): void {\n\t\tthis.lockedScopes.add(`${scope}:${identifier}`);\n\t\tconst current = this.items[this.currentItemIndex];\n\t\tif (!current || !this.isItemLocked(current)) return;\n\t\tthis.saveCurrentItemSession();\n\t\tthis.notifyItemChange();\n\t\tconst nextIndex = this.nextUnlockedIndex(this.currentItemIndex);\n\t\tif (nextIndex < 0) {\n\t\t\tthis.notifyTimeExpired();\n\t\t\treturn;\n\t\t}\n\t\tthis.navigateTo(nextIndex, { restoring: true }).catch(() => {});\n\t}\n\n\tprivate notifyTimeExpired(): void {\n\t\tfor (const l of this.timeExpiredListeners) l();\n\t}\n\n\tprivate notifyTimeTick(remainingSeconds: number, elapsedSeconds: number): void {\n\t\tfor (const l of this.timeTickListeners) l(remainingSeconds, elapsedSeconds);\n\t}\n\n\t/**\n\t * Get the i18n provider instance\n\t * @returns I18nProvider instance\n\t */\n\tpublic getI18nProvider(): I18nProvider {\n\t\treturn this.i18nProvider;\n\t}\n\n\t/**\n\t * The provider used when the host passes none: English, from the catalog\n\t * `@pie-qti/i18n` bundles eagerly.\n\t */\n\tprivate createDefaultI18nProvider(): I18nProvider {\n\t\treturn new DefaultI18nProvider('en-US');\n\t}\n}\n\nfunction cloneData<T>(value: T | undefined): T | undefined {\n\treturn value === undefined ? undefined : structuredClone(value);\n}\n\nfunction cloneResponseRecord(\n\tresponses: Readonly<Record<string, unknown>>,\n): Record<string, unknown> {\n\treturn structuredClone(responses) as Record<string, unknown>;\n}\n\nfunction valuesFromItemSession(\n\tstate: SerializedItemSessionState,\n): Record<string, unknown> {\n\treturn Object.fromEntries(\n\t\tObject.entries(state.responseVariables).map(([identifier, variable]) => [\n\t\t\tidentifier,\n\t\t\tcloneData(variable.value),\n\t\t]),\n\t);\n}\n\nfunction responseValuesEqual(left: unknown, right: unknown): boolean {\n\tif (Object.is(left, right)) return true;\n\tif (Array.isArray(left) || Array.isArray(right)) {\n\t\tif (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;\n\t\treturn left.every((value, index) => responseValuesEqual(value, right[index]));\n\t}\n\tif (!isRecord(left) || !isRecord(right)) return false;\n\n\tconst leftKeys = Object.keys(left);\n\tconst rightKeys = Object.keys(right);\n\tif (leftKeys.length !== rightKeys.length) return false;\n\tconst rightKeySet = new Set(rightKeys);\n\treturn leftKeys.every(\n\t\t(key) => rightKeySet.has(key) && responseValuesEqual(left[key], right[key]),\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object';\n}\n\nfunction isWritableItemLifecycle(lifecycleStatus: SerializedItemSessionState['lifecycleStatus']): boolean {\n\treturn lifecycleStatus === 'initial' || lifecycleStatus === 'interacting';\n}\n"]}
@@ -176,8 +176,11 @@ export declare class TimeManager {
176
176
  allowsLateSubmission(): boolean;
177
177
  /**
178
178
  * Format time as MM:SS or HH:MM:SS
179
+ *
180
+ * Pass the provider's `formatNumber` to render the locale's digits; without
181
+ * it the digits are Western.
179
182
  */
180
- static formatTime(seconds: number): string;
183
+ static formatTime(seconds: number, formatNumber?: (value: number, options?: Intl.NumberFormatOptions) => string): string;
181
184
  /**
182
185
  * Cleanup - stop all timers
183
186
  */
@@ -405,15 +405,21 @@ export class TimeManager {
405
405
  }
406
406
  /**
407
407
  * Format time as MM:SS or HH:MM:SS
408
+ *
409
+ * Pass the provider's `formatNumber` to render the locale's digits; without
410
+ * it the digits are Western.
408
411
  */
409
- static formatTime(seconds) {
412
+ static formatTime(seconds, formatNumber) {
410
413
  const hours = Math.floor(seconds / 3600);
411
414
  const minutes = Math.floor((seconds % 3600) / 60);
412
415
  const secs = seconds % 60;
416
+ const format = (value, digits) => formatNumber
417
+ ? formatNumber(value, { minimumIntegerDigits: digits, useGrouping: false })
418
+ : value.toString().padStart(digits, '0');
413
419
  if (hours > 0) {
414
- return `${hours}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
420
+ return `${format(hours, 1)}:${format(minutes, 2)}:${format(secs, 2)}`;
415
421
  }
416
- return `${minutes}:${secs.toString().padStart(2, '0')}`;
422
+ return `${format(minutes, 1)}:${format(secs, 2)}`;
417
423
  }
418
424
  /**
419
425
  * Cleanup - stop all timers
@@ -1 +1 @@
1
- {"version":3,"file":"TimeManager.js","sourceRoot":"","sources":["../../src/core/TimeManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAyEH,gGAAgG;AAChG,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,QAAkC;IAClF,IAAI,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,OAAO,CAAC;IACtC,IAAI,QAAQ,CAAC,UAAU,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACvD,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,GAAG,CAA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OAAO,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,mBAAmB,IAAI,KAAK,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,OAAe;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,OAAO,GAAG,EAAE,CAAC;QAE1B,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACf,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;QAC9F,CAAC;QAED,OAAO,GAAG,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,OAAO;QACN,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;CACD","sourcesContent":["/**\n * TimeManager\n *\n * Manages time limits and tracking for QTI assessments.\n * Supports test-level, section-level, and item-level time limits.\n *\n * Features:\n * - Countdown timers with warnings\n * - Auto-submission when time expires\n * - Time spent tracking per item\n * - Pause/resume support\n * - Late submission handling\n */\n\nimport type { TimeLimits } from '../types/index.js';\n\nexport interface TimeManagerConfig {\n\t/** Assessment-level time limits */\n\tassessmentTimeLimits?: TimeLimits;\n\t/** Warning threshold (seconds before expiry) */\n\twarningThreshold?: number;\n\t/** Callback when time warning is triggered */\n\tonWarning?: (remainingSeconds: number) => void;\n\t/** Callback when time expires */\n\tonExpired?: () => void;\n\t/**\n\t * Callback when a test part, section or item limit without late submission expires. When set,\n\t * those expiries lock the scope through this callback and the timer keeps running; only the\n\t * assessment limit calls `onExpired`.\n\t */\n\tonScopeExpired?: (scope: 'testPart' | 'section' | 'item', identifier: string) => void;\n\t/** Callback for time updates (fires every second) */\n\tonTick?: (remainingSeconds: number, elapsedSeconds: number) => void;\n\t/**\n\t * QTI 3.0 PNP extended time accommodation, applied to every time limit by\n\t * `extendTimeLimit`.\n\t */\n\textendedTime?: ExtendedTime;\n\t/** Injectable monotonic wall clock for deterministic hosts/tests. */\n\tnow?: () => number;\n}\n\nexport interface ActiveTimeScopes {\n\ttestPart?: { identifier: string; timeLimits?: TimeLimits };\n\tsection?: { identifier: string; timeLimits?: TimeLimits };\n\titem?: { identifier: string; timeLimits?: TimeLimits };\n}\n\nexport interface TimeTrackingState {\n\t/** Total elapsed time (ms) */\n\ttotalElapsed: number;\n\t/** Time spent per item identifier (ms) */\n\titemTimes: Record<string, number>;\n\t/** Time spent per section identifier (ms) */\n\tsectionTimes: Record<string, number>;\n\t/** Time spent per testPart identifier (ms) */\n\ttestPartTimes: Record<string, number>;\n\t/** Session start timestamp */\n\tstartedAt: number;\n\t/** Current item start time (for tracking) */\n\tcurrentItemStartTime?: number;\n\t/** Current item identifier */\n\tcurrentItemId?: string;\n\t/** Current section identifier */\n\tcurrentSectionId?: string;\n\t/** Current section start time */\n\tcurrentSectionStartTime?: number;\n\t/** Current testPart identifier */\n\tcurrentTestPartId?: string;\n\t/** Current testPart start time */\n\tcurrentTestPartStartTime?: number;\n\t/** Is timer currently paused */\n\tisPaused: boolean;\n}\n\n/**\n * The PNP extended-time accommodation: `multiplier` scales a limit (Infinity removes it)\n * and `fixedMinutes`, AfA's `fixed-minutes`, adds to it.\n */\nexport interface ExtendedTime {\n\tactive: boolean;\n\tmultiplier: number;\n\tfixedMinutes?: number;\n}\n\n/** A time limit in seconds under extended time; undefined when the accommodation removes it. */\nexport function extendTimeLimit(seconds: number, extended: ExtendedTime | undefined): number | undefined {\n\tif (!extended?.active) return seconds;\n\tif (extended.multiplier === Infinity) return undefined;\n\tconst scaled = extended.multiplier > 0 ? seconds * extended.multiplier : seconds;\n\tconst fixedMinutes = extended.fixedMinutes;\n\treturn fixedMinutes !== undefined && Number.isFinite(fixedMinutes) && fixedMinutes > 0\n\t\t? scaled + fixedMinutes * 60\n\t\t: scaled;\n}\n\nexport class TimeManager {\n\tprivate config: TimeManagerConfig;\n\tprivate state: TimeTrackingState;\n\n\t// Timer internals\n\tprivate intervalId: ReturnType<typeof setInterval> | null = null;\n\tprivate maxTimeSeconds: number | null = null;\n\tprivate warningTriggered = new Set<string>();\n\tprivate expirationTriggered = new Set<string>();\n\tprivate activeScopes: ActiveTimeScopes = {};\n\tprivate lastTickAt: number;\n\n\tconstructor(config: TimeManagerConfig) {\n\t\tthis.config = config;\n\t\tthis.state = {\n\t\t\ttotalElapsed: 0,\n\t\t\titemTimes: {},\n\t\t\tsectionTimes: {},\n\t\t\ttestPartTimes: {},\n\t\t\tstartedAt: this.now(),\n\t\t\tisPaused: false,\n\t\t};\n\t\tthis.lastTickAt = this.now();\n\n\t\t// Initialize timer if time limit exists, applying PNP extended-time multiplier if set.\n\t\tif (config.assessmentTimeLimits?.maxTime) {\n\t\t\tthis.maxTimeSeconds = extendTimeLimit(config.assessmentTimeLimits.maxTime, config.extendedTime) ?? null;\n\t\t}\n\t\t// Scope timing is required even when the assessment itself has no maxTime.\n\t\tthis.startTimer();\n\t}\n\n\tprivate now(): number {\n\t\treturn this.config.now?.() ?? Date.now();\n\t}\n\n\tprivate applyExtendedTime(seconds: number | undefined): number | null {\n\t\tif (seconds === undefined) return null;\n\t\treturn extendTimeLimit(seconds, this.config.extendedTime) ?? null;\n\t}\n\n\t/**\n\t * Start or resume the timer\n\t */\n\tprivate startTimer(): void {\n\t\tif (this.intervalId) {\n\t\t\treturn; // Already running\n\t\t}\n\n\t\tthis.state.isPaused = false;\n\t\tthis.lastTickAt = this.now();\n\n\t\tthis.intervalId = setInterval(() => {\n\t\t\tconst now = this.now();\n\t\t\tif (this.state.isPaused) {\n\t\t\t\tthis.lastTickAt = now;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.state.totalElapsed += Math.max(0, now - this.lastTickAt);\n\t\t\tthis.lastTickAt = now;\n\n\t\t\tconst elapsedSeconds = Math.floor(this.state.totalElapsed / 1000);\n\t\t\tconst candidates = this.getActiveCandidates();\n\t\t\tfor (const candidate of candidates) {\n\t\t\t\tif (candidate.remainingSeconds > 0 || this.expirationTriggered.has(candidate.key)) continue;\n\t\t\t\tthis.expirationTriggered.add(candidate.key);\n\t\t\t\tif (!candidate.allowLateSubmission) {\n\t\t\t\t\tconst separator = candidate.key.indexOf(':');\n\t\t\t\t\tif (separator > 0 && this.config.onScopeExpired) {\n\t\t\t\t\t\tconst scope = candidate.key.slice(0, separator) as 'testPart' | 'section' | 'item';\n\t\t\t\t\t\tthis.config.onScopeExpired(scope, candidate.key.slice(separator + 1));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis.handleExpiration();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst activeRemaining = this.nearestRemaining(candidates);\n\t\t\tif (activeRemaining) {\n\t\t\t\tconst { key, remainingSeconds } = activeRemaining;\n\n\t\t\t\t// Trigger warning\n\t\t\t\tconst warningThreshold = this.config.warningThreshold ?? 60;\n\t\t\t\tif (!this.warningTriggered.has(key) && remainingSeconds <= warningThreshold && remainingSeconds > 0) {\n\t\t\t\t\tthis.warningTriggered.add(key);\n\t\t\t\t\tthis.config.onWarning?.(remainingSeconds);\n\t\t\t\t}\n\n\t\t\t\t// Tick callback\n\t\t\t\tthis.config.onTick?.(remainingSeconds, elapsedSeconds);\n\t\t\t} else {\n\t\t\t\t// No limit - just count up\n\t\t\t\tthis.config.onTick?.(0, elapsedSeconds);\n\t\t\t}\n\t\t}, 1000);\n\t}\n\n\tprivate getActiveCandidates(): Array<{\n\t\tkey: string;\n\t\tremainingSeconds: number;\n\t\tallowLateSubmission: boolean;\n\t}> {\n\t\tconst candidates: Array<{ key: string; remainingSeconds: number; allowLateSubmission: boolean }> = [];\n\t\tif (this.maxTimeSeconds !== null) {\n\t\t\tcandidates.push({\n\t\t\t\tkey: 'assessment',\n\t\t\t\tremainingSeconds: this.maxTimeSeconds - this.getElapsedSeconds(),\n\t\t\t\tallowLateSubmission: this.config.assessmentTimeLimits?.allowLateSubmission === true,\n\t\t\t});\n\t\t}\n\t\tfor (const scope of ['testPart', 'section', 'item'] as const) {\n\t\t\tconst active = this.activeScopes[scope];\n\t\t\tconst max = this.applyExtendedTime(active?.timeLimits?.maxTime);\n\t\t\tif (!active || max === null) continue;\n\t\t\tcandidates.push({\n\t\t\t\tkey: `${scope}:${active.identifier}`,\n\t\t\t\tremainingSeconds: max - this.getScopeElapsedMs(scope, active.identifier) / 1000,\n\t\t\t\tallowLateSubmission: active.timeLimits?.allowLateSubmission === true,\n\t\t\t});\n\t\t}\n\t\treturn candidates;\n\t}\n\n\tprivate nearestRemaining(\n\t\tcandidates: Array<{ key: string; remainingSeconds: number; allowLateSubmission: boolean }>,\n\t): { key: string; remainingSeconds: number; allowLateSubmission: boolean } | null {\n\t\tif (candidates.length === 0) return null;\n\t\treturn candidates.reduce((nearest, candidate) =>\n\t\t\tcandidate.remainingSeconds < nearest.remainingSeconds ? candidate : nearest\n\t\t);\n\t}\n\n\tprivate getActiveRemaining(): { key: string; remainingSeconds: number; allowLateSubmission: boolean } | null {\n\t\treturn this.nearestRemaining(this.getActiveCandidates());\n\t}\n\n\t/**\n\t * Handle time expiration\n\t */\n\tprivate handleExpiration(): void {\n\t\tthis.stopTimer();\n\t\tthis.config.onExpired?.();\n\t}\n\n\t/**\n\t * Stop the timer\n\t */\n\tstopTimer(): void {\n\t\tif (this.intervalId) {\n\t\t\tclearInterval(this.intervalId);\n\t\t\tthis.intervalId = null;\n\t\t}\n\t}\n\n\t/**\n\t * Pause the timer\n\t */\n\tpause(): void {\n\t\tif (this.state.isPaused) return;\n\t\tthis.state.totalElapsed = this.getTotalElapsedMs();\n\t\tthis.lastTickAt = this.now();\n\t\tthis.checkpointActiveScopes(false);\n\t\tthis.state.isPaused = true;\n\t}\n\n\t/**\n\t * Resume the timer\n\t */\n\tresume(): void {\n\t\tif (!this.state.isPaused) return;\n\t\tthis.state.isPaused = false;\n\t\tconst now = this.now();\n\t\tif (this.state.currentItemId) this.state.currentItemStartTime = now;\n\t\tif (this.state.currentSectionId) this.state.currentSectionStartTime = now;\n\t\tif (this.state.currentTestPartId) this.state.currentTestPartStartTime = now;\n\t\tthis.lastTickAt = now;\n\t}\n\n\t/**\n\t * Start tracking time for an item\n\t */\n\tstartItem(itemIdentifier: string): void {\n\t\tif (this.state.currentItemId === itemIdentifier && this.state.currentItemStartTime) return;\n\t\t// End previous item if any\n\t\tif (this.state.currentItemStartTime) {\n\t\t\tthis.endCurrentItem();\n\t\t}\n\n\t\tthis.state.currentItemId = itemIdentifier;\n\t\tthis.state.currentItemStartTime = this.state.isPaused ? undefined : this.now();\n\t}\n\n\t/**\n\t * End tracking time for current item\n\t */\n\tprivate endCurrentItem(): void {\n\t\tif (!this.state.currentItemStartTime) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeSpent = this.now() - this.state.currentItemStartTime;\n\t\tif (this.state.currentItemId) {\n\t\t\tthis.state.itemTimes[this.state.currentItemId] =\n\t\t\t\t(this.state.itemTimes[this.state.currentItemId] || 0) + Math.max(0, timeSpent);\n\t\t}\n\t\tthis.state.currentItemStartTime = undefined;\n\t\tthis.state.currentItemId = undefined;\n\t}\n\n\t/**\n\t * End tracking time for an item\n\t */\n\tendItem(itemIdentifier: string): void {\n\t\tif (!this.state.currentItemStartTime) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeSpent = this.now() - this.state.currentItemStartTime;\n\t\tconst activeIdentifier = this.state.currentItemId ?? itemIdentifier;\n\t\tthis.state.itemTimes[activeIdentifier] = (this.state.itemTimes[activeIdentifier] || 0) + Math.max(0, timeSpent);\n\t\tthis.state.currentItemStartTime = undefined;\n\t\tthis.state.currentItemId = undefined;\n\t}\n\n\t/**\n\t * Start tracking time for a section\n\t */\n\tstartSection(sectionIdentifier: string): void {\n\t\tif (this.state.currentSectionId === sectionIdentifier && this.state.currentSectionStartTime) return;\n\t\tthis.endCurrentSection();\n\t\tthis.state.currentSectionId = sectionIdentifier;\n\t\tthis.state.currentSectionStartTime = this.state.isPaused ? undefined : this.now();\n\t}\n\n\tstartTestPart(testPartIdentifier: string): void {\n\t\tif (this.state.currentTestPartId === testPartIdentifier && this.state.currentTestPartStartTime) return;\n\t\tthis.endCurrentTestPart();\n\t\tthis.state.currentTestPartId = testPartIdentifier;\n\t\tthis.state.currentTestPartStartTime = this.state.isPaused ? undefined : this.now();\n\t}\n\n\tactivateScopes(scopes: ActiveTimeScopes): void {\n\t\tif (scopes.testPart) this.startTestPart(scopes.testPart.identifier);\n\t\tif (scopes.section) this.startSection(scopes.section.identifier);\n\t\tif (scopes.item) this.startItem(scopes.item.identifier);\n\t\tthis.activeScopes = scopes;\n\t}\n\n\tprivate endCurrentSection(): void {\n\t\tif (this.state.currentSectionId && this.state.currentSectionStartTime) {\n\t\t\tconst elapsed = Math.max(0, this.now() - this.state.currentSectionStartTime);\n\t\t\tthis.state.sectionTimes[this.state.currentSectionId] =\n\t\t\t\t(this.state.sectionTimes[this.state.currentSectionId] || 0) + elapsed;\n\t\t}\n\t\tthis.state.currentSectionStartTime = undefined;\n\t}\n\n\tprivate endCurrentTestPart(): void {\n\t\tif (this.state.currentTestPartId && this.state.currentTestPartStartTime) {\n\t\t\tconst elapsed = Math.max(0, this.now() - this.state.currentTestPartStartTime);\n\t\t\tthis.state.testPartTimes[this.state.currentTestPartId] =\n\t\t\t\t(this.state.testPartTimes[this.state.currentTestPartId] || 0) + elapsed;\n\t\t}\n\t\tthis.state.currentTestPartStartTime = undefined;\n\t}\n\n\tprivate checkpointActiveScopes(restart: boolean): void {\n\t\tconst itemId = this.state.currentItemId;\n\t\tconst sectionId = this.state.currentSectionId;\n\t\tconst testPartId = this.state.currentTestPartId;\n\t\tthis.endCurrentItem();\n\t\tthis.endCurrentSection();\n\t\tthis.endCurrentTestPart();\n\t\tthis.state.currentItemId = itemId;\n\t\tthis.state.currentSectionId = sectionId;\n\t\tthis.state.currentTestPartId = testPartId;\n\t\tif (restart && !this.state.isPaused) {\n\t\t\tconst now = this.now();\n\t\t\tif (itemId) this.state.currentItemStartTime = now;\n\t\t\tif (sectionId) this.state.currentSectionStartTime = now;\n\t\t\tif (testPartId) this.state.currentTestPartStartTime = now;\n\t\t}\n\t}\n\n\t/**\n\t * Get remaining time in seconds (null if no limit)\n\t */\n\tgetRemainingSeconds(): number | null {\n\t\tconst active = this.getActiveRemaining();\n\t\treturn active ? Math.max(0, Math.ceil(active.remainingSeconds)) : null;\n\t}\n\n\t/**\n\t * Get elapsed time in seconds\n\t */\n\tgetElapsedSeconds(): number {\n\t\treturn Math.floor(this.getTotalElapsedMs() / 1000);\n\t}\n\n\tprivate getTotalElapsedMs(): number {\n\t\tif (this.state.isPaused) return this.state.totalElapsed;\n\t\treturn this.state.totalElapsed + Math.max(0, this.now() - this.lastTickAt);\n\t}\n\n\t/**\n\t * Get time spent on a specific item (ms)\n\t */\n\tgetItemTime(itemIdentifier: string): number {\n\t\treturn this.getScopeElapsedMs('item', itemIdentifier);\n\t}\n\n\tgetScopeElapsedMs(scope: 'assessment' | 'testPart' | 'section' | 'item', identifier?: string): number {\n\t\tif (scope === 'assessment') return this.getTotalElapsedMs();\n\t\tconst now = this.now();\n\t\tif (scope === 'item') {\n\t\t\tconst id = identifier ?? this.state.currentItemId;\n\t\t\tif (!id) return 0;\n\t\t\tconst active = id === this.state.currentItemId && this.state.currentItemStartTime && !this.state.isPaused\n\t\t\t\t? Math.max(0, now - this.state.currentItemStartTime)\n\t\t\t\t: 0;\n\t\t\treturn (this.state.itemTimes[id] || 0) + active;\n\t\t}\n\t\tif (scope === 'section') {\n\t\t\tconst id = identifier ?? this.state.currentSectionId;\n\t\t\tif (!id) return 0;\n\t\t\tconst active = id === this.state.currentSectionId && this.state.currentSectionStartTime && !this.state.isPaused\n\t\t\t\t? Math.max(0, now - this.state.currentSectionStartTime)\n\t\t\t\t: 0;\n\t\t\treturn (this.state.sectionTimes[id] || 0) + active;\n\t\t}\n\t\tconst id = identifier ?? this.state.currentTestPartId;\n\t\tif (!id) return 0;\n\t\tconst active = id === this.state.currentTestPartId && this.state.currentTestPartStartTime && !this.state.isPaused\n\t\t\t? Math.max(0, now - this.state.currentTestPartStartTime)\n\t\t\t: 0;\n\t\treturn (this.state.testPartTimes[id] || 0) + active;\n\t}\n\n\t/**\n\t * Get current tracking state (for persistence)\n\t */\n\tgetState(): TimeTrackingState {\n\t\tif (!this.state.isPaused) {\n\t\t\tthis.state.totalElapsed = this.getTotalElapsedMs();\n\t\t\tthis.lastTickAt = this.now();\n\t\t}\n\t\tthis.checkpointActiveScopes(true);\n\t\treturn {\n\t\t\t...this.state,\n\t\t\titemTimes: { ...this.state.itemTimes },\n\t\t\tsectionTimes: { ...this.state.sectionTimes },\n\t\t\ttestPartTimes: { ...this.state.testPartTimes },\n\t\t};\n\t}\n\n\t/**\n\t * Restore tracking state (for resume)\n\t */\n\trestoreState(state: TimeTrackingState): void {\n\t\tthis.state = {\n\t\t\t...state,\n\t\t\titemTimes: { ...state.itemTimes },\n\t\t\tsectionTimes: { ...state.sectionTimes },\n\t\t\ttestPartTimes: { ...(state.testPartTimes ?? {}) },\n\t\t\tcurrentItemStartTime: undefined,\n\t\t\tcurrentSectionStartTime: undefined,\n\t\t\tcurrentTestPartStartTime: undefined,\n\t\t};\n\t\tif (!this.state.isPaused) {\n\t\t\tconst now = this.now();\n\t\t\tif (this.state.currentItemId) this.state.currentItemStartTime = now;\n\t\t\tif (this.state.currentSectionId) this.state.currentSectionStartTime = now;\n\t\t\tif (this.state.currentTestPartId) this.state.currentTestPartStartTime = now;\n\t\t\tthis.lastTickAt = now;\n\t\t}\n\n\t\t// Restart timer if not expired\n\t\tif (this.maxTimeSeconds) {\n\t\t\tconst elapsedSeconds = Math.floor(this.state.totalElapsed / 1000);\n\t\t\tif (elapsedSeconds < this.maxTimeSeconds) {\n\t\t\t\tthis.startTimer();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Check if time has expired\n\t */\n\tisExpired(): boolean {\n\t\tconst active = this.getActiveRemaining();\n\t\treturn active !== null && active.remainingSeconds <= 0;\n\t}\n\n\t/**\n\t * Check if late submission is allowed\n\t */\n\tallowsLateSubmission(): boolean {\n\t\tconst candidates = this.getActiveCandidates();\n\t\tconst expired = candidates.filter((candidate) => candidate.remainingSeconds <= 0);\n\t\tif (expired.length > 0) {\n\t\t\treturn expired.every((candidate) => candidate.allowLateSubmission);\n\t\t}\n\t\treturn this.nearestRemaining(candidates)?.allowLateSubmission ?? false;\n\t}\n\n\t/**\n\t * Format time as MM:SS or HH:MM:SS\n\t */\n\tstatic formatTime(seconds: number): string {\n\t\tconst hours = Math.floor(seconds / 3600);\n\t\tconst minutes = Math.floor((seconds % 3600) / 60);\n\t\tconst secs = seconds % 60;\n\n\t\tif (hours > 0) {\n\t\t\treturn `${hours}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;\n\t\t}\n\n\t\treturn `${minutes}:${secs.toString().padStart(2, '0')}`;\n\t}\n\n\t/**\n\t * Cleanup - stop all timers\n\t */\n\tdestroy(): void {\n\t\tthis.checkpointActiveScopes(false);\n\t\tthis.stopTimer();\n\t}\n}\n"]}
1
+ {"version":3,"file":"TimeManager.js","sourceRoot":"","sources":["../../src/core/TimeManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAyEH,gGAAgG;AAChG,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,QAAkC;IAClF,IAAI,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,OAAO,CAAC;IACtC,IAAI,QAAQ,CAA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time limits and tracking for QTI assessments.\n * Supports test-level, section-level, and item-level time limits.\n *\n * Features:\n * - Countdown timers with warnings\n * - Auto-submission when time expires\n * - Time spent tracking per item\n * - Pause/resume support\n * - Late submission handling\n */\n\nimport type { TimeLimits } from '../types/index.js';\n\nexport interface TimeManagerConfig {\n\t/** Assessment-level time limits */\n\tassessmentTimeLimits?: TimeLimits;\n\t/** Warning threshold (seconds before expiry) */\n\twarningThreshold?: number;\n\t/** Callback when time warning is triggered */\n\tonWarning?: (remainingSeconds: number) => void;\n\t/** Callback when time expires */\n\tonExpired?: () => void;\n\t/**\n\t * Callback when a test part, section or item limit without late submission expires. When set,\n\t * those expiries lock the scope through this callback and the timer keeps running; only the\n\t * assessment limit calls `onExpired`.\n\t */\n\tonScopeExpired?: (scope: 'testPart' | 'section' | 'item', identifier: string) => void;\n\t/** Callback for time updates (fires every second) */\n\tonTick?: (remainingSeconds: number, elapsedSeconds: number) => void;\n\t/**\n\t * QTI 3.0 PNP extended time accommodation, applied to every time limit by\n\t * `extendTimeLimit`.\n\t */\n\textendedTime?: ExtendedTime;\n\t/** Injectable monotonic wall clock for deterministic hosts/tests. */\n\tnow?: () => number;\n}\n\nexport interface ActiveTimeScopes {\n\ttestPart?: { identifier: string; timeLimits?: TimeLimits };\n\tsection?: { identifier: string; timeLimits?: TimeLimits };\n\titem?: { identifier: string; timeLimits?: TimeLimits };\n}\n\nexport interface TimeTrackingState {\n\t/** Total elapsed time (ms) */\n\ttotalElapsed: number;\n\t/** Time spent per item identifier (ms) */\n\titemTimes: Record<string, number>;\n\t/** Time spent per section identifier (ms) */\n\tsectionTimes: Record<string, number>;\n\t/** Time spent per testPart identifier (ms) */\n\ttestPartTimes: Record<string, number>;\n\t/** Session start timestamp */\n\tstartedAt: number;\n\t/** Current item start time (for tracking) */\n\tcurrentItemStartTime?: number;\n\t/** Current item identifier */\n\tcurrentItemId?: string;\n\t/** Current section identifier */\n\tcurrentSectionId?: string;\n\t/** Current section start time */\n\tcurrentSectionStartTime?: number;\n\t/** Current testPart identifier */\n\tcurrentTestPartId?: string;\n\t/** Current testPart start time */\n\tcurrentTestPartStartTime?: number;\n\t/** Is timer currently paused */\n\tisPaused: boolean;\n}\n\n/**\n * The PNP extended-time accommodation: `multiplier` scales a limit (Infinity removes it)\n * and `fixedMinutes`, AfA's `fixed-minutes`, adds to it.\n */\nexport interface ExtendedTime {\n\tactive: boolean;\n\tmultiplier: number;\n\tfixedMinutes?: number;\n}\n\n/** A time limit in seconds under extended time; undefined when the accommodation removes it. */\nexport function extendTimeLimit(seconds: number, extended: ExtendedTime | undefined): number | undefined {\n\tif (!extended?.active) return seconds;\n\tif (extended.multiplier === Infinity) return undefined;\n\tconst scaled = extended.multiplier > 0 ? seconds * extended.multiplier : seconds;\n\tconst fixedMinutes = extended.fixedMinutes;\n\treturn fixedMinutes !== undefined && Number.isFinite(fixedMinutes) && fixedMinutes > 0\n\t\t? scaled + fixedMinutes * 60\n\t\t: scaled;\n}\n\nexport class TimeManager {\n\tprivate config: TimeManagerConfig;\n\tprivate state: TimeTrackingState;\n\n\t// Timer internals\n\tprivate intervalId: ReturnType<typeof setInterval> | null = null;\n\tprivate maxTimeSeconds: number | null = null;\n\tprivate warningTriggered = new Set<string>();\n\tprivate expirationTriggered = new Set<string>();\n\tprivate activeScopes: ActiveTimeScopes = {};\n\tprivate lastTickAt: number;\n\n\tconstructor(config: TimeManagerConfig) {\n\t\tthis.config = config;\n\t\tthis.state = {\n\t\t\ttotalElapsed: 0,\n\t\t\titemTimes: {},\n\t\t\tsectionTimes: {},\n\t\t\ttestPartTimes: {},\n\t\t\tstartedAt: this.now(),\n\t\t\tisPaused: false,\n\t\t};\n\t\tthis.lastTickAt = this.now();\n\n\t\t// Initialize timer if time limit exists, applying PNP extended-time multiplier if set.\n\t\tif (config.assessmentTimeLimits?.maxTime) {\n\t\t\tthis.maxTimeSeconds = extendTimeLimit(config.assessmentTimeLimits.maxTime, config.extendedTime) ?? null;\n\t\t}\n\t\t// Scope timing is required even when the assessment itself has no maxTime.\n\t\tthis.startTimer();\n\t}\n\n\tprivate now(): number {\n\t\treturn this.config.now?.() ?? Date.now();\n\t}\n\n\tprivate applyExtendedTime(seconds: number | undefined): number | null {\n\t\tif (seconds === undefined) return null;\n\t\treturn extendTimeLimit(seconds, this.config.extendedTime) ?? null;\n\t}\n\n\t/**\n\t * Start or resume the timer\n\t */\n\tprivate startTimer(): void {\n\t\tif (this.intervalId) {\n\t\t\treturn; // Already running\n\t\t}\n\n\t\tthis.state.isPaused = false;\n\t\tthis.lastTickAt = this.now();\n\n\t\tthis.intervalId = setInterval(() => {\n\t\t\tconst now = this.now();\n\t\t\tif (this.state.isPaused) {\n\t\t\t\tthis.lastTickAt = now;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.state.totalElapsed += Math.max(0, now - this.lastTickAt);\n\t\t\tthis.lastTickAt = now;\n\n\t\t\tconst elapsedSeconds = Math.floor(this.state.totalElapsed / 1000);\n\t\t\tconst candidates = this.getActiveCandidates();\n\t\t\tfor (const candidate of candidates) {\n\t\t\t\tif (candidate.remainingSeconds > 0 || this.expirationTriggered.has(candidate.key)) continue;\n\t\t\t\tthis.expirationTriggered.add(candidate.key);\n\t\t\t\tif (!candidate.allowLateSubmission) {\n\t\t\t\t\tconst separator = candidate.key.indexOf(':');\n\t\t\t\t\tif (separator > 0 && this.config.onScopeExpired) {\n\t\t\t\t\t\tconst scope = candidate.key.slice(0, separator) as 'testPart' | 'section' | 'item';\n\t\t\t\t\t\tthis.config.onScopeExpired(scope, candidate.key.slice(separator + 1));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis.handleExpiration();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst activeRemaining = this.nearestRemaining(candidates);\n\t\t\tif (activeRemaining) {\n\t\t\t\tconst { key, remainingSeconds } = activeRemaining;\n\n\t\t\t\t// Trigger warning\n\t\t\t\tconst warningThreshold = this.config.warningThreshold ?? 60;\n\t\t\t\tif (!this.warningTriggered.has(key) && remainingSeconds <= warningThreshold && remainingSeconds > 0) {\n\t\t\t\t\tthis.warningTriggered.add(key);\n\t\t\t\t\tthis.config.onWarning?.(remainingSeconds);\n\t\t\t\t}\n\n\t\t\t\t// Tick callback\n\t\t\t\tthis.config.onTick?.(remainingSeconds, elapsedSeconds);\n\t\t\t} else {\n\t\t\t\t// No limit - just count up\n\t\t\t\tthis.config.onTick?.(0, elapsedSeconds);\n\t\t\t}\n\t\t}, 1000);\n\t}\n\n\tprivate getActiveCandidates(): Array<{\n\t\tkey: string;\n\t\tremainingSeconds: number;\n\t\tallowLateSubmission: boolean;\n\t}> {\n\t\tconst candidates: Array<{ key: string; remainingSeconds: number; allowLateSubmission: boolean }> = [];\n\t\tif (this.maxTimeSeconds !== null) {\n\t\t\tcandidates.push({\n\t\t\t\tkey: 'assessment',\n\t\t\t\tremainingSeconds: this.maxTimeSeconds - this.getElapsedSeconds(),\n\t\t\t\tallowLateSubmission: this.config.assessmentTimeLimits?.allowLateSubmission === true,\n\t\t\t});\n\t\t}\n\t\tfor (const scope of ['testPart', 'section', 'item'] as const) {\n\t\t\tconst active = this.activeScopes[scope];\n\t\t\tconst max = this.applyExtendedTime(active?.timeLimits?.maxTime);\n\t\t\tif (!active || max === null) continue;\n\t\t\tcandidates.push({\n\t\t\t\tkey: `${scope}:${active.identifier}`,\n\t\t\t\tremainingSeconds: max - this.getScopeElapsedMs(scope, active.identifier) / 1000,\n\t\t\t\tallowLateSubmission: active.timeLimits?.allowLateSubmission === true,\n\t\t\t});\n\t\t}\n\t\treturn candidates;\n\t}\n\n\tprivate nearestRemaining(\n\t\tcandidates: Array<{ key: string; remainingSeconds: number; allowLateSubmission: boolean }>,\n\t): { key: string; remainingSeconds: number; allowLateSubmission: boolean } | null {\n\t\tif (candidates.length === 0) return null;\n\t\treturn candidates.reduce((nearest, candidate) =>\n\t\t\tcandidate.remainingSeconds < nearest.remainingSeconds ? candidate : nearest\n\t\t);\n\t}\n\n\tprivate getActiveRemaining(): { key: string; remainingSeconds: number; allowLateSubmission: boolean } | null {\n\t\treturn this.nearestRemaining(this.getActiveCandidates());\n\t}\n\n\t/**\n\t * Handle time expiration\n\t */\n\tprivate handleExpiration(): void {\n\t\tthis.stopTimer();\n\t\tthis.config.onExpired?.();\n\t}\n\n\t/**\n\t * Stop the timer\n\t */\n\tstopTimer(): void {\n\t\tif (this.intervalId) {\n\t\t\tclearInterval(this.intervalId);\n\t\t\tthis.intervalId = null;\n\t\t}\n\t}\n\n\t/**\n\t * Pause the timer\n\t */\n\tpause(): void {\n\t\tif (this.state.isPaused) return;\n\t\tthis.state.totalElapsed = this.getTotalElapsedMs();\n\t\tthis.lastTickAt = this.now();\n\t\tthis.checkpointActiveScopes(false);\n\t\tthis.state.isPaused = true;\n\t}\n\n\t/**\n\t * Resume the timer\n\t */\n\tresume(): void {\n\t\tif (!this.state.isPaused) return;\n\t\tthis.state.isPaused = false;\n\t\tconst now = this.now();\n\t\tif (this.state.currentItemId) this.state.currentItemStartTime = now;\n\t\tif (this.state.currentSectionId) this.state.currentSectionStartTime = now;\n\t\tif (this.state.currentTestPartId) this.state.currentTestPartStartTime = now;\n\t\tthis.lastTickAt = now;\n\t}\n\n\t/**\n\t * Start tracking time for an item\n\t */\n\tstartItem(itemIdentifier: string): void {\n\t\tif (this.state.currentItemId === itemIdentifier && this.state.currentItemStartTime) return;\n\t\t// End previous item if any\n\t\tif (this.state.currentItemStartTime) {\n\t\t\tthis.endCurrentItem();\n\t\t}\n\n\t\tthis.state.currentItemId = itemIdentifier;\n\t\tthis.state.currentItemStartTime = this.state.isPaused ? undefined : this.now();\n\t}\n\n\t/**\n\t * End tracking time for current item\n\t */\n\tprivate endCurrentItem(): void {\n\t\tif (!this.state.currentItemStartTime) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeSpent = this.now() - this.state.currentItemStartTime;\n\t\tif (this.state.currentItemId) {\n\t\t\tthis.state.itemTimes[this.state.currentItemId] =\n\t\t\t\t(this.state.itemTimes[this.state.currentItemId] || 0) + Math.max(0, timeSpent);\n\t\t}\n\t\tthis.state.currentItemStartTime = undefined;\n\t\tthis.state.currentItemId = undefined;\n\t}\n\n\t/**\n\t * End tracking time for an item\n\t */\n\tendItem(itemIdentifier: string): void {\n\t\tif (!this.state.currentItemStartTime) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeSpent = this.now() - this.state.currentItemStartTime;\n\t\tconst activeIdentifier = this.state.currentItemId ?? itemIdentifier;\n\t\tthis.state.itemTimes[activeIdentifier] = (this.state.itemTimes[activeIdentifier] || 0) + Math.max(0, timeSpent);\n\t\tthis.state.currentItemStartTime = undefined;\n\t\tthis.state.currentItemId = undefined;\n\t}\n\n\t/**\n\t * Start tracking time for a section\n\t */\n\tstartSection(sectionIdentifier: string): void {\n\t\tif (this.state.currentSectionId === sectionIdentifier && this.state.currentSectionStartTime) return;\n\t\tthis.endCurrentSection();\n\t\tthis.state.currentSectionId = sectionIdentifier;\n\t\tthis.state.currentSectionStartTime = this.state.isPaused ? undefined : this.now();\n\t}\n\n\tstartTestPart(testPartIdentifier: string): void {\n\t\tif (this.state.currentTestPartId === testPartIdentifier && this.state.currentTestPartStartTime) return;\n\t\tthis.endCurrentTestPart();\n\t\tthis.state.currentTestPartId = testPartIdentifier;\n\t\tthis.state.currentTestPartStartTime = this.state.isPaused ? undefined : this.now();\n\t}\n\n\tactivateScopes(scopes: ActiveTimeScopes): void {\n\t\tif (scopes.testPart) this.startTestPart(scopes.testPart.identifier);\n\t\tif (scopes.section) this.startSection(scopes.section.identifier);\n\t\tif (scopes.item) this.startItem(scopes.item.identifier);\n\t\tthis.activeScopes = scopes;\n\t}\n\n\tprivate endCurrentSection(): void {\n\t\tif (this.state.currentSectionId && this.state.currentSectionStartTime) {\n\t\t\tconst elapsed = Math.max(0, this.now() - this.state.currentSectionStartTime);\n\t\t\tthis.state.sectionTimes[this.state.currentSectionId] =\n\t\t\t\t(this.state.sectionTimes[this.state.currentSectionId] || 0) + elapsed;\n\t\t}\n\t\tthis.state.currentSectionStartTime = undefined;\n\t}\n\n\tprivate endCurrentTestPart(): void {\n\t\tif (this.state.currentTestPartId && this.state.currentTestPartStartTime) {\n\t\t\tconst elapsed = Math.max(0, this.now() - this.state.currentTestPartStartTime);\n\t\t\tthis.state.testPartTimes[this.state.currentTestPartId] =\n\t\t\t\t(this.state.testPartTimes[this.state.currentTestPartId] || 0) + elapsed;\n\t\t}\n\t\tthis.state.currentTestPartStartTime = undefined;\n\t}\n\n\tprivate checkpointActiveScopes(restart: boolean): void {\n\t\tconst itemId = this.state.currentItemId;\n\t\tconst sectionId = this.state.currentSectionId;\n\t\tconst testPartId = this.state.currentTestPartId;\n\t\tthis.endCurrentItem();\n\t\tthis.endCurrentSection();\n\t\tthis.endCurrentTestPart();\n\t\tthis.state.currentItemId = itemId;\n\t\tthis.state.currentSectionId = sectionId;\n\t\tthis.state.currentTestPartId = testPartId;\n\t\tif (restart && !this.state.isPaused) {\n\t\t\tconst now = this.now();\n\t\t\tif (itemId) this.state.currentItemStartTime = now;\n\t\t\tif (sectionId) this.state.currentSectionStartTime = now;\n\t\t\tif (testPartId) this.state.currentTestPartStartTime = now;\n\t\t}\n\t}\n\n\t/**\n\t * Get remaining time in seconds (null if no limit)\n\t */\n\tgetRemainingSeconds(): number | null {\n\t\tconst active = this.getActiveRemaining();\n\t\treturn active ? Math.max(0, Math.ceil(active.remainingSeconds)) : null;\n\t}\n\n\t/**\n\t * Get elapsed time in seconds\n\t */\n\tgetElapsedSeconds(): number {\n\t\treturn Math.floor(this.getTotalElapsedMs() / 1000);\n\t}\n\n\tprivate getTotalElapsedMs(): number {\n\t\tif (this.state.isPaused) return this.state.totalElapsed;\n\t\treturn this.state.totalElapsed + Math.max(0, this.now() - this.lastTickAt);\n\t}\n\n\t/**\n\t * Get time spent on a specific item (ms)\n\t */\n\tgetItemTime(itemIdentifier: string): number {\n\t\treturn this.getScopeElapsedMs('item', itemIdentifier);\n\t}\n\n\tgetScopeElapsedMs(scope: 'assessment' | 'testPart' | 'section' | 'item', identifier?: string): number {\n\t\tif (scope === 'assessment') return this.getTotalElapsedMs();\n\t\tconst now = this.now();\n\t\tif (scope === 'item') {\n\t\t\tconst id = identifier ?? this.state.currentItemId;\n\t\t\tif (!id) return 0;\n\t\t\tconst active = id === this.state.currentItemId && this.state.currentItemStartTime && !this.state.isPaused\n\t\t\t\t? Math.max(0, now - this.state.currentItemStartTime)\n\t\t\t\t: 0;\n\t\t\treturn (this.state.itemTimes[id] || 0) + active;\n\t\t}\n\t\tif (scope === 'section') {\n\t\t\tconst id = identifier ?? this.state.currentSectionId;\n\t\t\tif (!id) return 0;\n\t\t\tconst active = id === this.state.currentSectionId && this.state.currentSectionStartTime && !this.state.isPaused\n\t\t\t\t? Math.max(0, now - this.state.currentSectionStartTime)\n\t\t\t\t: 0;\n\t\t\treturn (this.state.sectionTimes[id] || 0) + active;\n\t\t}\n\t\tconst id = identifier ?? this.state.currentTestPartId;\n\t\tif (!id) return 0;\n\t\tconst active = id === this.state.currentTestPartId && this.state.currentTestPartStartTime && !this.state.isPaused\n\t\t\t? Math.max(0, now - this.state.currentTestPartStartTime)\n\t\t\t: 0;\n\t\treturn (this.state.testPartTimes[id] || 0) + active;\n\t}\n\n\t/**\n\t * Get current tracking state (for persistence)\n\t */\n\tgetState(): TimeTrackingState {\n\t\tif (!this.state.isPaused) {\n\t\t\tthis.state.totalElapsed = this.getTotalElapsedMs();\n\t\t\tthis.lastTickAt = this.now();\n\t\t}\n\t\tthis.checkpointActiveScopes(true);\n\t\treturn {\n\t\t\t...this.state,\n\t\t\titemTimes: { ...this.state.itemTimes },\n\t\t\tsectionTimes: { ...this.state.sectionTimes },\n\t\t\ttestPartTimes: { ...this.state.testPartTimes },\n\t\t};\n\t}\n\n\t/**\n\t * Restore tracking state (for resume)\n\t */\n\trestoreState(state: TimeTrackingState): void {\n\t\tthis.state = {\n\t\t\t...state,\n\t\t\titemTimes: { ...state.itemTimes },\n\t\t\tsectionTimes: { ...state.sectionTimes },\n\t\t\ttestPartTimes: { ...(state.testPartTimes ?? {}) },\n\t\t\tcurrentItemStartTime: undefined,\n\t\t\tcurrentSectionStartTime: undefined,\n\t\t\tcurrentTestPartStartTime: undefined,\n\t\t};\n\t\tif (!this.state.isPaused) {\n\t\t\tconst now = this.now();\n\t\t\tif (this.state.currentItemId) this.state.currentItemStartTime = now;\n\t\t\tif (this.state.currentSectionId) this.state.currentSectionStartTime = now;\n\t\t\tif (this.state.currentTestPartId) this.state.currentTestPartStartTime = now;\n\t\t\tthis.lastTickAt = now;\n\t\t}\n\n\t\t// Restart timer if not expired\n\t\tif (this.maxTimeSeconds) {\n\t\t\tconst elapsedSeconds = Math.floor(this.state.totalElapsed / 1000);\n\t\t\tif (elapsedSeconds < this.maxTimeSeconds) {\n\t\t\t\tthis.startTimer();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Check if time has expired\n\t */\n\tisExpired(): boolean {\n\t\tconst active = this.getActiveRemaining();\n\t\treturn active !== null && active.remainingSeconds <= 0;\n\t}\n\n\t/**\n\t * Check if late submission is allowed\n\t */\n\tallowsLateSubmission(): boolean {\n\t\tconst candidates = this.getActiveCandidates();\n\t\tconst expired = candidates.filter((candidate) => candidate.remainingSeconds <= 0);\n\t\tif (expired.length > 0) {\n\t\t\treturn expired.every((candidate) => candidate.allowLateSubmission);\n\t\t}\n\t\treturn this.nearestRemaining(candidates)?.allowLateSubmission ?? false;\n\t}\n\n\t/**\n\t * Format time as MM:SS or HH:MM:SS\n\t *\n\t * Pass the provider's `formatNumber` to render the locale's digits; without\n\t * it the digits are Western.\n\t */\n\tstatic formatTime(\n\t\tseconds: number,\n\t\tformatNumber?: (value: number, options?: Intl.NumberFormatOptions) => string\n\t): string {\n\t\tconst hours = Math.floor(seconds / 3600);\n\t\tconst minutes = Math.floor((seconds % 3600) / 60);\n\t\tconst secs = seconds % 60;\n\t\tconst format = (value: number, digits: number) =>\n\t\t\tformatNumber\n\t\t\t\t? formatNumber(value, { minimumIntegerDigits: digits, useGrouping: false })\n\t\t\t\t: value.toString().padStart(digits, '0');\n\n\t\tif (hours > 0) {\n\t\t\treturn `${format(hours, 1)}:${format(minutes, 2)}:${format(secs, 2)}`;\n\t\t}\n\n\t\treturn `${format(minutes, 1)}:${format(secs, 2)}`;\n\t}\n\n\t/**\n\t * Cleanup - stop all timers\n\t */\n\tdestroy(): void {\n\t\tthis.checkpointActiveScopes(false);\n\t\tthis.stopTimer();\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-qti/assessment-player",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "QTI Assessment Player supporting QTI 2.2 and 3.0 - Multi-item test player with navigation, sections, and rubric blocks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,29 +28,21 @@
28
28
  ],
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@pie-qti/assessment-toolkit": "1.0.0-beta.1",
32
- "@pie-qti/default-components": "1.0.0-beta.1",
33
- "@pie-qti/ims-cp-core": "1.0.0-beta.1",
34
- "@pie-qti/item-player": "1.0.0-beta.1",
35
- "@pie-qti/qti-common": "1.0.0-beta.1",
36
- "@pie-qti/qti-processing": "1.0.0-beta.1",
37
- "@pie-qti/section-player": "1.0.0-beta.1",
38
- "node-html-parser": "^9.0.4"
39
- },
40
- "peerDependencies": {
41
- "@pie-qti/i18n": "1.0.0-beta.1"
42
- },
43
- "peerDependenciesMeta": {
44
- "@pie-qti/i18n": {
45
- "optional": true
46
- }
31
+ "@pie-qti/assessment-toolkit": "1.0.0-beta.3",
32
+ "@pie-qti/default-components": "1.0.0-beta.3",
33
+ "@pie-qti/i18n": "1.0.0-beta.3",
34
+ "@pie-qti/ims-cp-core": "1.0.0-beta.3",
35
+ "@pie-qti/item-player": "1.0.0-beta.3",
36
+ "@pie-qti/qti-common": "1.0.0-beta.3",
37
+ "@pie-qti/qti-processing": "1.0.0-beta.3",
38
+ "@pie-qti/section-player": "1.0.0-beta.3",
39
+ "node-html-parser": "^9.0.5"
47
40
  },
48
41
  "devDependencies": {
49
- "@biomejs/biome": "^2.5.15",
50
- "@pie-qti/i18n": "1.0.0-beta.1",
42
+ "@biomejs/biome": "^2.6.2",
51
43
  "@types/node": "^26.6.4",
52
44
  "svelte": "^5.57.1",
53
- "svelte-check": "^4.7.5",
45
+ "svelte-check": "^4.7.7",
54
46
  "typescript": "^5.9.3"
55
47
  },
56
48
  "exports": {