@pie-qti/assessment-player 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/AssessmentPlayer.d.ts +10 -1
- package/dist/core/AssessmentPlayer.js +187 -39
- package/dist/core/AssessmentPlayer.js.map +1 -1
- package/dist/core/AssessmentSessionCoordinator.js +6 -0
- package/dist/core/AssessmentSessionCoordinator.js.map +1 -1
- package/dist/core/NavigationManager.d.ts +1 -1
- package/dist/core/NavigationManager.js +5 -13
- package/dist/core/NavigationManager.js.map +1 -1
- package/dist/core/TimeManager.d.ts +42 -1
- package/dist/core/TimeManager.js +235 -42
- package/dist/core/TimeManager.js.map +1 -1
- package/dist/integration/ReferenceBackendAdapter.d.ts +4 -0
- package/dist/integration/ReferenceBackendAdapter.js +209 -52
- package/dist/integration/ReferenceBackendAdapter.js.map +1 -1
- package/dist/integration/api-contract.d.ts +38 -0
- package/dist/integration/api-contract.js.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-contract.js","sourceRoot":"","sources":["../../src/integration/api-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG","sourcesContent":["/**\n * QTI 2.2 Assessment Player - Backend Integration API Contract\n *\n * This file defines the secure API boundary between the client-side player\n * and backend services. The design prioritizes security by ensuring sensitive\n * data (correct answers, scoring rules) never reaches the client.\n *\n * ## Security Model\n *\n * - **Client-side**: Collects and submits candidate responses only\n * - **Server-side**: Stores QTI XML, performs scoring, validates submissions\n * - **Role-based**: Server controls what data client receives based on QTI role\n *\n * ## Reference Implementation\n *\n * See `ReferenceBackendAdapter.ts` for a simple localStorage-based implementation\n * that demonstrates the API contract without requiring a real backend.\n */\n\nimport type { QTIRole, ResolvedItemDeliveryContext, SerializedItemSessionState } from '@pie-qti/item-player';\n\n// ============================================================================\n// SESSION MANAGEMENT\n// ============================================================================\n\n/**\n * Unique identifier for an assessment session\n * Format: \"{assessmentId}:{candidateId}:{timestamp}\" or similar\n */\nexport type SessionId = string;\n\n/**\n * Initialize a new assessment session\n *\n * Security: Server validates candidate identity and assessment access\n */\nexport interface InitSessionRequest {\n\t/** Assessment identifier (QTI assessmentTest identifier) */\n\tassessmentId: string;\n\t/** Candidate identifier (from authentication system) */\n\tcandidateId: string;\n\t/** Optional: Resume from existing session */\n\tresumeSessionId?: SessionId;\n}\n\nexport interface InitSessionResponse {\n\t/** Unique session identifier for all subsequent requests */\n\tsessionId: SessionId;\n\t/** Assessment structure WITHOUT sensitive data */\n\tassessment: SecureAssessment;\n\t/** Restored state if resuming, undefined if new session */\n\trestoredState?: AssessmentSessionState;\n}\n\n// ============================================================================\n// ASSESSMENT STRUCTURE (CLIENT-SAFE)\n// ============================================================================\n\n/**\n * Assessment structure safe for client consumption\n *\n * Security: NO correct answers, NO scoring rules, NO sensitive rubrics\n */\nexport interface TestFeedbackItem {\n\tidentifier: string;\n\t/** Outcome variable name to evaluate (e.g. \"PASS\", \"GRADE\") */\n\toutcomeIdentifier: string;\n\t/** 'show' = show when outcome equals identifier; 'hide' = show when it does not */\n\tshowHide: 'show' | 'hide';\n\t/** 'atEnd' = only after submission; 'during' = also during attempt */\n\taccess: 'atEnd' | 'during';\n\t/** HTML content to display */\n\tcontent: string;\n}\n\nexport interface SecureTimeLimits {\n\tminTime?: number;\n\tmaxTime?: number;\n\tallowLateSubmission?: boolean;\n}\n\nexport interface SecureAssessment {\n\tidentifier: string;\n\ttitle: string;\n\t/** Navigation mode affects UI */\n\tnavigationMode: 'linear' | 'nonlinear';\n\t/** Submission mode affects when responses are finalized */\n\tsubmissionMode: 'individual' | 'simultaneous';\n\t/** Test parts contain sections */\n\ttestParts: SecureTestPart[];\n\t/** Overall time limit in seconds (optional) */\n\ttimeLimits?: SecureTimeLimits;\n\t/** QTI outcomeDeclarations for test-level variables */\n\toutcomeDeclarations?: Array<{\n\t\tidentifier: string;\n\t\tbaseType: string;\n\t\tcardinality: string;\n\t\tdefaultValue?: unknown;\n\t}>;\n\t/** Raw <outcomeProcessing> XML string, if present */\n\toutcomeProcessingXml?: string;\n\t/** Base URL/path for resolving relative hrefs (e.g. assessmentSectionRef) */\n\tbaseUrl?: string;\n\t/** QTI testFeedback blocks for post-submission display */\n\ttestFeedback?: TestFeedbackItem[];\n}\n\nexport interface SecureTestPart {\n\tidentifier: string;\n\t/** Sections contain items */\n\tsections: SecureSection[];\n\t/** TestPart-level time limit. */\n\ttimeLimits?: SecureTimeLimits;\n\t/** Candidate instructions (safe for display) */\n\trubricBlocks?: AssessmentRubricBlock[];\n\t/**\n\t * Item session control (QTI testPart/itemSessionControl).\n\t * Server is authoritative; client uses this for UI hints only.\n\t */\n\titemSessionControl?: {\n\t\tmaxAttempts?: number;\n\t\tshowFeedback?: boolean;\n\t\tallowReview?: boolean;\n\t\tshowSolution?: boolean;\n\t\tallowComment?: boolean;\n\t\tallowSkipping?: boolean;\n\t\tvalidateResponses?: boolean;\n\t};\n}\n\nexport interface SecureSection {\n\tidentifier: string;\n\ttitle?: string;\n\t/** Visible determines if section appears in navigation */\n\tvisible: boolean;\n\t/** Assessment item references (order reflects selection/ordering already applied server-side) */\n\tassessmentItemRefs: SecureItemRef[];\n\t/** Section-level time limit */\n\ttimeLimits?: SecureTimeLimits;\n\t/** Candidate instructions (safe for display) */\n\trubricBlocks?: AssessmentRubricBlock[];\n\t/**\n\t * QTI selection: how many items to present from this section.\n\t * When present the server has already applied selection; client uses this for progress display.\n\t */\n\tselection?: {\n\t\t/** Number of items selected for this session */\n\t\tselect: number;\n\t\twithReplacement?: boolean;\n\t};\n\t/**\n\t * QTI ordering: whether items were shuffled.\n\t * When true the server has already shuffled assessmentItemRefs.\n\t */\n\tordering?: {\n\t\tshuffle: boolean;\n\t};\n\t/**\n\t * Item session control (QTI assessmentSection/itemSessionControl).\n\t * Section-level values take precedence over testPart-level when present.\n\t */\n\titemSessionControl?: {\n\t\tmaxAttempts?: number;\n\t\tshowFeedback?: boolean;\n\t\tallowReview?: boolean;\n\t\tshowSolution?: boolean;\n\t\tallowComment?: boolean;\n\t\tallowSkipping?: boolean;\n\t\tvalidateResponses?: boolean;\n\t};\n}\n\nexport interface SecureItemRef {\n\t/** Unique item identifier */\n\tidentifier: string;\n\t/** Item XML WITHOUT responseProcessing if role is 'candidate' */\n\titemXml: string;\n\t/** QTI role determines what's visible in itemXml */\n\trole: QTIRole;\n\t/** Required=true means item must be attempted */\n\trequired?: boolean;\n\t/** Item-ref-level time limit. */\n\ttimeLimits?: SecureTimeLimits;\n\t/** Optional resolved QTI 3 delivery context. Additive; itemXml remains the compatibility path. */\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\t/**\n\t * QTI branchRule: ordered list of branch rules on this item.\n\t * The backend evaluates these after scoring and returns nextItemIdentifier in SubmitResponsesResponse.\n\t * Carried here so reference/demo adapters can evaluate them client-side.\n\t */\n\tbranchRule?: Array<{\n\t\t/** Identifier of the target item, section, testPart, or one of the special values:\n\t\t * EXIT_TEST | EXIT_TESTPART | EXIT_SECTION */\n\t\ttarget: string;\n\t\t/** Serialised QTI expression XML (the child of <branchRule>). Absent means unconditional. */\n\t\tconditionXml?: string;\n\t}>;\n}\n\nexport interface AssessmentRubricBlock {\n\t/** Optional rubric identifier (QTI rubricBlock@identifier) */\n\tidentifier?: string;\n\t/** Rubric content (HTML) */\n\tcontent: string;\n\t/** View controls when rubric is shown */\n\tview: QTIRole[];\n\t/** Optional rubric use (QTI rubricBlock@use), e.g. \"passage\" */\n\tuse?: string;\n}\n\n// ============================================================================\n// RESPONSE SUBMISSION\n// ============================================================================\n\n/**\n * Submit responses for scoring\n *\n * Security: Client sends responses only, server performs scoring\n */\nexport interface SubmitResponsesRequest {\n\tsessionId: SessionId;\n\t/** Item identifier */\n\titemIdentifier: string;\n\t/** Response data keyed by responseIdentifier */\n\tresponses: Record<string, ResponseValue>;\n\t/** Client timestamp for analytics */\n\tsubmittedAt: number;\n\t/** Time spent on item (ms) for analytics */\n\ttimeSpent?: number;\n\t/** Optional client timing evidence; production backends remain authoritative. */\n\ttiming?: SubmitTimingEvidence;\n\t/**\n\t * Serialized item session used by backends to restore template/context variables while scoring.\n\t * Production backends should treat this as a client save format and validate against server-owned state.\n\t */\n\titemSession?: SerializedItemSessionState;\n}\n\nexport interface SubmitTimingEvidence {\n\tscope: 'assessment' | 'testPart' | 'section' | 'item';\n\telapsedMs: number;\n\tlimitSeconds?: number;\n\texpired?: boolean;\n\tallowLateSubmission?: boolean;\n}\n\n/**\n * Response value can be string, string[], or complex types\n */\nexport type ResponseValue = string | string[] | Record<string, any>;\n\nexport interface SubmitResponsesResponse {\n\t/** Was submission accepted? */\n\tsuccess: boolean;\n\t/** Scoring result (if submission mode allows immediate scoring) */\n\tresult?: AssessmentScoringResult;\n\t/**\n\t * Backend-authoritative next item (branching/navigation decision).\n\t * If omitted, client may fall back to linear next/previous UI navigation.\n\t */\n\tnextItemIdentifier?: string;\n\t/**\n\t * Backend-authoritative session state snapshot after applying the submission.\n\t * If provided, client should replace its local state with this.\n\t */\n\tupdatedState?: AssessmentSessionState;\n\t/** Error message if success=false */\n\terror?: string;\n}\n\n// ============================================================================\n// SCORING RESULTS\n// ============================================================================\n\n/**\n * Scoring result returned from server\n *\n * Security: Server computes this, client never sees scoring rules\n */\nexport interface AssessmentScoringResult {\n\t/** Item identifier */\n\titemIdentifier: string;\n\t/** Normalized score 0.0-1.0 */\n\tscore: number;\n\t/** Maximum possible score (usually 1.0) */\n\tmaxScore: number;\n\t/** Was item completed? */\n\tcompleted: boolean;\n\t/** QTI outcome variables */\n\toutcomeValues: Record<string, any>;\n\t/** Feedback to display (role-dependent) */\n\tfeedback?: FeedbackItem[];\n\t/** Correct response (only if role allows) */\n\tcorrectResponse?: Record<string, ResponseValue>;\n}\n\nexport interface FeedbackItem {\n\t/** Feedback content (HTML) */\n\tcontent: string;\n\t/** Feedback type */\n\ttype: 'correct' | 'incorrect' | 'hint' | 'solution';\n}\n\n// ============================================================================\n// STATE PERSISTENCE\n// ============================================================================\n\n/**\n * Save assessment state\n *\n * Security: State includes responses but not scores (until finalized)\n */\nexport interface SaveAssessmentStateRequest {\n\tsessionId: SessionId;\n\tstate: AssessmentSessionState;\n}\n\nexport interface SaveAssessmentStateResponse {\n\tsuccess: boolean;\n\t/** Server timestamp of save */\n\tsavedAt: number;\n}\n\nexport interface AssessmentSessionState {\n\t/** Current item identifier */\n\tcurrentItemIdentifier: string;\n\t/** Visited items (for navigation) */\n\tvisitedItems: string[];\n\t/** Submitted responses per item */\n\titemResponses: Record<string, Record<string, ResponseValue>>;\n\t/** Scoring results per item (populated after submission) */\n\titemScores?: Record<string, AssessmentScoringResult>;\n\t/** ItemSession lifecycle hints per item, used to restore attempt/review UI state */\n\titemSessionStates?: Record<string, AssessmentItemSessionState>;\n\t/** Rich QTI item session snapshots, used to restore variables and score saved sessions. */\n\titemSessions?: Record<string, SerializedItemSessionState>;\n\t/** Time tracking */\n\ttiming: {\n\t\t/** Session start time */\n\t\tstartedAt: number;\n\t\t/** Time spent per item (ms) */\n\t\titemTimes: Record<string, number>;\n\t\t/** Total elapsed time (ms) */\n\t\ttotalTime: number;\n\t};\n}\n\nexport interface AssessmentItemSessionState {\n\titemIdentifier: string;\n\tattemptCount: number;\n\tisAnswered: boolean;\n\tisSubmitted: boolean;\n\tlastSubmissionTime?: number;\n}\n\n// ============================================================================\n// FINALIZE ASSESSMENT\n// ============================================================================\n\n/**\n * Finalize assessment and get full results\n *\n * Security: Server computes final scores, applies late penalties, etc.\n */\nexport interface FinalizeAssessmentRequest {\n\tsessionId: SessionId;\n}\n\nexport interface FinalizeAssessmentResponse {\n\tsuccess: boolean;\n\t/** Overall assessment score */\n\ttotalScore: number;\n\t/** Maximum possible score */\n\tmaxScore: number;\n\t/** Per-item results */\n\titemScores: Record<string, AssessmentScoringResult>;\n\t/** Assessment-level feedback (legacy: single string; prefer outcomes + assessment.testFeedback) */\n\tfeedback?: string;\n\t/**\n\t * Test-level outcome variable values after outcomeProcessing.\n\t * Used to evaluate testFeedback visibility via string equality.\n\t * Keys are outcome identifiers (e.g. \"PASS\", \"GRADE\"); values are their string representations.\n\t */\n\toutcomes?: Record<string, string>;\n\t/** Server timestamp */\n\tfinalizedAt: number;\n}\n\n// ============================================================================\n// ITEM BANK QUERIES\n// ============================================================================\n\n/**\n * Request items from an item bank for random selection\n *\n * Security: Server validates candidate access to bank\n */\nexport interface QueryItemBankRequest {\n\t/** Unique session identifier */\n\tsessionId: SessionId;\n\t/** Item bank identifier (from selection/@fromBank attribute) */\n\tbankId: string;\n\t/** Number of items to select */\n\tcount: number;\n\t/** Whether to allow selecting same item multiple times */\n\twithReplacement?: boolean;\n\t/** Optional filtering criteria (difficulty, topic, etc.) */\n\tfilters?: {\n\t\tdifficulty?: 'easy' | 'medium' | 'hard';\n\t\ttopics?: string[];\n\t\t[key: string]: unknown;\n\t};\n}\n\n/**\n * Items selected from item bank\n *\n * Security: Returns items WITHOUT correct answers or scoring rules\n */\nexport interface QueryItemBankResponse {\n\t/** Selected item references (client-safe) */\n\titems: SecureItemRef[];\n\t/** Server timestamp */\n\tselectedAt: number;\n}\n\n// ============================================================================\n// BACKEND ADAPTER INTERFACE\n// ============================================================================\n\n/**\n * Backend adapter interface - implement this for your backend\n *\n * @example\n * ```typescript\n * class MyBackendAdapter implements BackendAdapter {\n * async initSession(req: InitSessionRequest): Promise<InitSessionResponse> {\n * const response = await fetch('/api/qti/init', {\n * method: 'POST',\n * body: JSON.stringify(req)\n * });\n * return response.json();\n * }\n * // ... implement other methods\n * }\n * ```\n */\nexport interface BackendAdapter {\n\t/**\n\t * Initialize new assessment session\n\t */\n\tinitSession(request: InitSessionRequest): Promise<InitSessionResponse>;\n\n\t/**\n\t * Submit item responses for scoring\n\t */\n\tsubmitResponses(request: SubmitResponsesRequest): Promise<SubmitResponsesResponse>;\n\n\t/**\n\t * Save session state (auto-save during assessment)\n\t */\n\tsaveState(request: SaveAssessmentStateRequest): Promise<SaveAssessmentStateResponse>;\n\n\t/**\n\t * Finalize assessment and get results\n\t */\n\tfinalizeAssessment(request: FinalizeAssessmentRequest): Promise<FinalizeAssessmentResponse>;\n\n\t/**\n\t * Resume session (optional - can reuse initSession)\n\t */\n\tresumeSession?(sessionId: SessionId): Promise<InitSessionResponse>;\n\n\t/**\n\t * Query item bank for random item selection\n\t *\n\t * Security: Server validates access and returns items WITHOUT sensitive data\n\t */\n\tqueryItemBank?(request: QueryItemBankRequest): Promise<QueryItemBankResponse>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api-contract.js","sourceRoot":"","sources":["../../src/integration/api-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG","sourcesContent":["/**\n * QTI 2.2 Assessment Player - Backend Integration API Contract\n *\n * This file defines the secure API boundary between the client-side player\n * and backend services. The design prioritizes security by ensuring sensitive\n * data (correct answers, scoring rules) never reaches the client.\n *\n * ## Security Model\n *\n * - **Client-side**: Collects and submits candidate responses only\n * - **Server-side**: Stores QTI XML, performs scoring, validates submissions\n * - **Role-based**: Server controls what data client receives based on QTI role\n *\n * ## Reference Implementation\n *\n * See `ReferenceBackendAdapter.ts` for a simple localStorage-based implementation\n * that demonstrates the API contract without requiring a real backend.\n */\n\nimport type { QTIRole, ResolvedItemDeliveryContext, SerializedItemSessionState } from '@pie-qti/item-player';\n\n// ============================================================================\n// SESSION MANAGEMENT\n// ============================================================================\n\n/**\n * Unique identifier for an assessment session\n * Format: \"{assessmentId}:{candidateId}:{timestamp}\" or similar\n */\nexport type SessionId = string;\n\n/**\n * Initialize a new assessment session\n *\n * Security: Server validates candidate identity and assessment access\n */\nexport interface InitSessionRequest {\n\t/** Assessment identifier (QTI assessmentTest identifier) */\n\tassessmentId: string;\n\t/** Candidate identifier (from authentication system) */\n\tcandidateId: string;\n\t/** Optional: Resume from existing session */\n\tresumeSessionId?: SessionId;\n}\n\nexport interface InitSessionResponse {\n\t/** Unique session identifier for all subsequent requests */\n\tsessionId: SessionId;\n\t/** Assessment structure WITHOUT sensitive data */\n\tassessment: SecureAssessment;\n\t/** Restored state if resuming, undefined if new session */\n\trestoredState?: AssessmentSessionState;\n}\n\n// ============================================================================\n// ASSESSMENT STRUCTURE (CLIENT-SAFE)\n// ============================================================================\n\n/**\n * Assessment structure safe for client consumption\n *\n * Security: NO correct answers, NO scoring rules, NO sensitive rubrics\n */\nexport interface TestFeedbackItem {\n\tidentifier: string;\n\t/** Outcome variable name to evaluate (e.g. \"PASS\", \"GRADE\") */\n\toutcomeIdentifier: string;\n\t/** 'show' = show when outcome equals identifier; 'hide' = show when it does not */\n\tshowHide: 'show' | 'hide';\n\t/** 'atEnd' = only after submission; 'during' = also during attempt */\n\taccess: 'atEnd' | 'during';\n\t/** HTML content to display */\n\tcontent: string;\n}\n\nexport interface SecureTimeLimits {\n\tminTime?: number;\n\tmaxTime?: number;\n\tallowLateSubmission?: boolean;\n}\n\nexport interface SecureAssessment {\n\tidentifier: string;\n\ttitle: string;\n\t/** Navigation mode affects UI */\n\tnavigationMode: 'linear' | 'nonlinear';\n\t/** Submission mode affects when responses are finalized */\n\tsubmissionMode: 'individual' | 'simultaneous';\n\t/** Test parts contain sections */\n\ttestParts: SecureTestPart[];\n\t/** Overall time limit in seconds (optional) */\n\ttimeLimits?: SecureTimeLimits;\n\t/** QTI outcomeDeclarations for test-level variables */\n\toutcomeDeclarations?: Array<{\n\t\tidentifier: string;\n\t\tbaseType: string;\n\t\tcardinality: string;\n\t\tdefaultValue?: unknown;\n\t}>;\n\t/** Raw <outcomeProcessing> XML string, if present */\n\toutcomeProcessingXml?: string;\n\t/** Base URL/path for resolving relative hrefs (e.g. assessmentSectionRef) */\n\tbaseUrl?: string;\n\t/** QTI testFeedback blocks for post-submission display */\n\ttestFeedback?: TestFeedbackItem[];\n}\n\nexport interface SecureTestPart {\n\tidentifier: string;\n\t/** Navigation and submission modes are scoped to each QTI testPart. */\n\tnavigationMode?: 'linear' | 'nonlinear';\n\tsubmissionMode?: 'individual' | 'simultaneous';\n\t/** Sections contain items */\n\tsections: SecureSection[];\n\t/** TestPart-level time limit. */\n\ttimeLimits?: SecureTimeLimits;\n\t/** Candidate instructions (safe for display) */\n\trubricBlocks?: AssessmentRubricBlock[];\n\t/**\n\t * Item session control (QTI testPart/itemSessionControl).\n\t * Server is authoritative; client uses this for UI hints only.\n\t */\n\titemSessionControl?: {\n\t\tmaxAttempts?: number;\n\t\tshowFeedback?: boolean;\n\t\tallowReview?: boolean;\n\t\tshowSolution?: boolean;\n\t\tallowComment?: boolean;\n\t\tallowSkipping?: boolean;\n\t\tvalidateResponses?: boolean;\n\t};\n}\n\nexport interface SecureSection {\n\tidentifier: string;\n\ttitle?: string;\n\trequired?: boolean;\n\tfixed?: boolean;\n\t/** Visible determines if section appears in navigation */\n\tvisible: boolean;\n\t/** Assessment item references (order reflects selection/ordering already applied server-side) */\n\tassessmentItemRefs: SecureItemRef[];\n\t/** Nested QTI sections, retained instead of being flattened during XML ingestion. */\n\tsections?: SecureSection[];\n\t/**\n\t * Direct delivery components in document order. When present, this is the\n\t * authoritative order for mixed item/section children.\n\t */\n\tchildren?: SecureSectionComponent[];\n\t/** Section-level time limit */\n\ttimeLimits?: SecureTimeLimits;\n\t/** Candidate instructions (safe for display) */\n\trubricBlocks?: AssessmentRubricBlock[];\n\t/**\n\t * QTI selection: how many items to present from this section.\n\t * When present the server has already applied selection; client uses this for progress display.\n\t */\n\tselection?: {\n\t\t/** Number of items selected for this session */\n\t\tselect: number;\n\t\twithReplacement?: boolean;\n\t};\n\t/**\n\t * QTI ordering: whether items were shuffled.\n\t * When true the server has already shuffled assessmentItemRefs.\n\t */\n\tordering?: {\n\t\tshuffle: boolean;\n\t};\n\t/** Serialized direct preCondition expressions, evaluated by the backend. */\n\tpreConditions?: string[];\n\t/**\n\t * Item session control (QTI assessmentSection/itemSessionControl).\n\t * Section-level values take precedence over testPart-level when present.\n\t */\n\titemSessionControl?: {\n\t\tmaxAttempts?: number;\n\t\tshowFeedback?: boolean;\n\t\tallowReview?: boolean;\n\t\tshowSolution?: boolean;\n\t\tallowComment?: boolean;\n\t\tallowSkipping?: boolean;\n\t\tvalidateResponses?: boolean;\n\t};\n}\n\nexport type SecureSectionComponent =\n\t| { type: 'item'; item: SecureItemRef }\n\t| { type: 'section'; section: SecureSection };\n\nexport interface SecureItemRef {\n\t/** Unique item identifier */\n\tidentifier: string;\n\t/** Item XML WITHOUT responseProcessing if role is 'candidate' */\n\titemXml: string;\n\t/** QTI role determines what's visible in itemXml */\n\trole: QTIRole;\n\t/** Required=true means item must be attempted */\n\trequired?: boolean;\n\tfixed?: boolean;\n\t/** Item-ref-level time limit. */\n\ttimeLimits?: SecureTimeLimits;\n\t/** Optional resolved QTI 3 delivery context. Additive; itemXml remains the compatibility path. */\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\t/**\n\t * QTI branchRule: ordered list of branch rules on this item.\n\t * The backend evaluates these after scoring and returns nextItemIdentifier in SubmitResponsesResponse.\n\t * Carried here so reference/demo adapters can evaluate them client-side.\n\t */\n\tbranchRule?: Array<{\n\t\t/** Identifier of the target item, section, testPart, or one of the special values:\n\t\t * EXIT_TEST | EXIT_TESTPART | EXIT_SECTION */\n\t\ttarget: string;\n\t\t/** Serialised QTI expression XML (the child of <branchRule>). Absent means unconditional. */\n\t\tconditionXml?: string;\n\t}>;\n\t/** Serialized direct preCondition expressions, evaluated by the backend. */\n\tpreConditions?: string[];\n\t/** QTI item-ref weights, preserved for backend outcome processing. */\n\tweights?: Array<{ identifier: string; value: number }>;\n}\n\nexport interface AssessmentRubricBlock {\n\t/** Optional rubric identifier (QTI rubricBlock@identifier) */\n\tidentifier?: string;\n\t/** Rubric content (HTML) */\n\tcontent: string;\n\t/** View controls when rubric is shown */\n\tview: QTIRole[];\n\t/** Optional rubric use (QTI rubricBlock@use), e.g. \"passage\" */\n\tuse?: string;\n}\n\n// ============================================================================\n// RESPONSE SUBMISSION\n// ============================================================================\n\n/**\n * Submit responses for scoring\n *\n * Security: Client sends responses only, server performs scoring\n */\nexport interface SubmitResponsesRequest {\n\tsessionId: SessionId;\n\t/** Item identifier */\n\titemIdentifier: string;\n\t/** Response data keyed by responseIdentifier */\n\tresponses: Record<string, ResponseValue>;\n\t/** Client timestamp for analytics */\n\tsubmittedAt: number;\n\t/** Time spent on item (ms) for analytics */\n\ttimeSpent?: number;\n\t/** Optional client timing evidence; production backends remain authoritative. */\n\ttiming?: SubmitTimingEvidence;\n\t/**\n\t * Serialized item session used by backends to restore template/context variables while scoring.\n\t * Production backends should treat this as a client save format and validate against server-owned state.\n\t */\n\titemSession?: SerializedItemSessionState;\n}\n\nexport interface SubmitTimingEvidence {\n\tscope: 'assessment' | 'testPart' | 'section' | 'item';\n\telapsedMs: number;\n\tlimitSeconds?: number;\n\texpired?: boolean;\n\tallowLateSubmission?: boolean;\n}\n\n/**\n * Response value can be string, string[], or complex types\n */\nexport type ResponseValue = string | string[] | Record<string, any>;\n\nexport interface SubmitResponsesResponse {\n\t/** Was submission accepted? */\n\tsuccess: boolean;\n\t/** Scoring result (if submission mode allows immediate scoring) */\n\tresult?: AssessmentScoringResult;\n\t/**\n\t * Backend-authoritative next item (branching/navigation decision).\n\t * If omitted, client may fall back to linear next/previous UI navigation.\n\t */\n\tnextItemIdentifier?: string;\n\t/**\n\t * Backend-authoritative session state snapshot after applying the submission.\n\t * If provided, client should replace its local state with this.\n\t */\n\tupdatedState?: AssessmentSessionState;\n\t/** Error message if success=false */\n\terror?: string;\n}\n\n// ============================================================================\n// SCORING RESULTS\n// ============================================================================\n\n/**\n * Scoring result returned from server\n *\n * Security: Server computes this, client never sees scoring rules\n */\nexport interface AssessmentScoringResult {\n\t/** Item identifier */\n\titemIdentifier: string;\n\t/** Normalized score 0.0-1.0 */\n\tscore: number;\n\t/** Maximum possible score (usually 1.0) */\n\tmaxScore: number;\n\t/** Was item completed? */\n\tcompleted: boolean;\n\t/** QTI outcome variables */\n\toutcomeValues: Record<string, any>;\n\t/** Feedback to display (role-dependent) */\n\tfeedback?: FeedbackItem[];\n\t/** Correct response (only if role allows) */\n\tcorrectResponse?: Record<string, ResponseValue>;\n}\n\nexport interface FeedbackItem {\n\t/** Feedback content (HTML) */\n\tcontent: string;\n\t/** Feedback type */\n\ttype: 'correct' | 'incorrect' | 'hint' | 'solution';\n}\n\n// ============================================================================\n// STATE PERSISTENCE\n// ============================================================================\n\n/**\n * Save assessment state\n *\n * Security: State includes responses but not scores (until finalized)\n */\nexport interface SaveAssessmentStateRequest {\n\tsessionId: SessionId;\n\tstate: AssessmentSessionState;\n}\n\nexport interface SaveAssessmentStateResponse {\n\tsuccess: boolean;\n\t/** Server timestamp of save */\n\tsavedAt: number;\n}\n\nexport interface AssessmentSessionState {\n\t/** Current item identifier */\n\tcurrentItemIdentifier: string;\n\t/** Visited items (for navigation) */\n\tvisitedItems: string[];\n\t/** Submitted responses per item */\n\titemResponses: Record<string, Record<string, ResponseValue>>;\n\t/** Scoring results per item (populated after submission) */\n\titemScores?: Record<string, AssessmentScoringResult>;\n\t/** ItemSession lifecycle hints per item, used to restore attempt/review UI state */\n\titemSessionStates?: Record<string, AssessmentItemSessionState>;\n\t/** Rich QTI item session snapshots, used to restore variables and score saved sessions. */\n\titemSessions?: Record<string, SerializedItemSessionState>;\n\t/** Time tracking */\n\ttiming: {\n\t\t/** Session start time */\n\t\tstartedAt: number;\n\t\t/** Time spent per item (ms) */\n\t\titemTimes: Record<string, number>;\n\t\t/** Time spent per assessment section (ms). */\n\t\tsectionTimes?: Record<string, number>;\n\t\t/** Time spent per testPart (ms). */\n\t\ttestPartTimes?: Record<string, number>;\n\t\t/** Total elapsed time (ms) */\n\t\ttotalTime: number;\n\t\t/** Active scope identifiers retained for save/resume timing continuity. */\n\t\tcurrentItemIdentifier?: string;\n\t\tcurrentSectionIdentifier?: string;\n\t\tcurrentTestPartIdentifier?: string;\n\t\tisPaused?: boolean;\n\t};\n}\n\nexport interface AssessmentItemSessionState {\n\titemIdentifier: string;\n\tattemptCount: number;\n\tisAnswered: boolean;\n\tisSubmitted: boolean;\n\tlastSubmissionTime?: number;\n}\n\n// ============================================================================\n// FINALIZE ASSESSMENT\n// ============================================================================\n\n/**\n * Finalize assessment and get full results\n *\n * Security: Server computes final scores, applies late penalties, etc.\n */\nexport interface FinalizeAssessmentRequest {\n\tsessionId: SessionId;\n}\n\nexport interface FinalizeAssessmentResponse {\n\tsuccess: boolean;\n\t/** Overall assessment score */\n\ttotalScore: number;\n\t/** Maximum possible score */\n\tmaxScore: number;\n\t/** Per-item results */\n\titemScores: Record<string, AssessmentScoringResult>;\n\t/** Assessment-level feedback (legacy: single string; prefer outcomes + assessment.testFeedback) */\n\tfeedback?: string;\n\t/**\n\t * Test-level outcome variable values after outcomeProcessing.\n\t * Used to evaluate testFeedback visibility via string equality.\n\t * Keys are outcome identifiers (e.g. \"PASS\", \"GRADE\"); values are their string representations.\n\t */\n\toutcomes?: Record<string, string>;\n\t/** Server timestamp */\n\tfinalizedAt: number;\n}\n\n// ============================================================================\n// ITEM BANK QUERIES\n// ============================================================================\n\n/**\n * Request items from an item bank for random selection\n *\n * Security: Server validates candidate access to bank\n */\nexport interface QueryItemBankRequest {\n\t/** Unique session identifier */\n\tsessionId: SessionId;\n\t/** Item bank identifier (from selection/@fromBank attribute) */\n\tbankId: string;\n\t/** Number of items to select */\n\tcount: number;\n\t/** Whether to allow selecting same item multiple times */\n\twithReplacement?: boolean;\n\t/** Optional filtering criteria (difficulty, topic, etc.) */\n\tfilters?: {\n\t\tdifficulty?: 'easy' | 'medium' | 'hard';\n\t\ttopics?: string[];\n\t\t[key: string]: unknown;\n\t};\n}\n\n/**\n * Items selected from item bank\n *\n * Security: Returns items WITHOUT correct answers or scoring rules\n */\nexport interface QueryItemBankResponse {\n\t/** Selected item references (client-safe) */\n\titems: SecureItemRef[];\n\t/** Server timestamp */\n\tselectedAt: number;\n}\n\n// ============================================================================\n// BACKEND ADAPTER INTERFACE\n// ============================================================================\n\n/**\n * Backend adapter interface - implement this for your backend\n *\n * @example\n * ```typescript\n * class MyBackendAdapter implements BackendAdapter {\n * async initSession(req: InitSessionRequest): Promise<InitSessionResponse> {\n * const response = await fetch('/api/qti/init', {\n * method: 'POST',\n * body: JSON.stringify(req)\n * });\n * return response.json();\n * }\n * // ... implement other methods\n * }\n * ```\n */\nexport interface BackendAdapter {\n\t/**\n\t * Initialize new assessment session\n\t */\n\tinitSession(request: InitSessionRequest): Promise<InitSessionResponse>;\n\n\t/**\n\t * Submit item responses for scoring\n\t */\n\tsubmitResponses(request: SubmitResponsesRequest): Promise<SubmitResponsesResponse>;\n\n\t/**\n\t * Save session state (auto-save during assessment)\n\t */\n\tsaveState(request: SaveAssessmentStateRequest): Promise<SaveAssessmentStateResponse>;\n\n\t/**\n\t * Finalize assessment and get results\n\t */\n\tfinalizeAssessment(request: FinalizeAssessmentRequest): Promise<FinalizeAssessmentResponse>;\n\n\t/**\n\t * Resume session (optional - can reuse initSession)\n\t */\n\tresumeSession?(sessionId: SessionId): Promise<InitSessionResponse>;\n\n\t/**\n\t * Query item bank for random item selection\n\t *\n\t * Security: Server validates access and returns items WITHOUT sensitive data\n\t */\n\tqueryItemBank?(request: QueryItemBankRequest): Promise<QueryItemBankResponse>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-qti/assessment-player",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
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,14 +28,14 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@pie-qti/assessment-toolkit": "0.1.
|
|
32
|
-
"@pie-qti/default-components": "0.1.
|
|
33
|
-
"@pie-qti/i18n": "0.1.
|
|
34
|
-
"@pie-qti/ims-cp-core": "0.1.
|
|
35
|
-
"@pie-qti/item-player": "0.1.
|
|
36
|
-
"@pie-qti/qti-common": "0.1.
|
|
37
|
-
"@pie-qti/qti-processing": "0.1.
|
|
38
|
-
"@pie-qti/section-player": "0.1.
|
|
31
|
+
"@pie-qti/assessment-toolkit": "0.1.16",
|
|
32
|
+
"@pie-qti/default-components": "0.1.16",
|
|
33
|
+
"@pie-qti/i18n": "0.1.16",
|
|
34
|
+
"@pie-qti/ims-cp-core": "0.1.16",
|
|
35
|
+
"@pie-qti/item-player": "0.1.16",
|
|
36
|
+
"@pie-qti/qti-common": "0.1.16",
|
|
37
|
+
"@pie-qti/qti-processing": "0.1.16",
|
|
38
|
+
"@pie-qti/section-player": "0.1.16",
|
|
39
39
|
"node-html-parser": "^7.0.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
|
60
|
-
"url": "https://github.com/pie-framework/pie-qti.git",
|
|
60
|
+
"url": "git+https://github.com/pie-framework/pie-qti.git",
|
|
61
61
|
"directory": "packages/assessment-player"
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://github.com/pie-framework/pie-qti/tree/master/packages/assessment-player",
|