@pie-qti/assessment-player 0.1.1
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/.turbo/turbo-build.log +1 -0
- package/BACKEND-INTEGRATION.md +620 -0
- package/CHANGELOG.md +11 -0
- package/EXTENSIBILITY.md +551 -0
- package/README.md +1137 -0
- package/dist/core/AssessmentPlayer.d.ts +151 -0
- package/dist/core/AssessmentPlayer.d.ts.map +1 -0
- package/dist/core/AssessmentPlayer.js +595 -0
- package/dist/core/ItemSessionController.d.ts +119 -0
- package/dist/core/ItemSessionController.d.ts.map +1 -0
- package/dist/core/ItemSessionController.js +227 -0
- package/dist/core/NavigationManager.d.ts +59 -0
- package/dist/core/NavigationManager.d.ts.map +1 -0
- package/dist/core/NavigationManager.js +104 -0
- package/dist/core/StatePersistenceManager.d.ts +126 -0
- package/dist/core/StatePersistenceManager.d.ts.map +1 -0
- package/dist/core/StatePersistenceManager.js +267 -0
- package/dist/core/TimeManager.d.ts +123 -0
- package/dist/core/TimeManager.d.ts.map +1 -0
- package/dist/core/TimeManager.js +217 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/integration/ReferenceBackendAdapter.d.ts +128 -0
- package/dist/integration/ReferenceBackendAdapter.d.ts.map +1 -0
- package/dist/integration/ReferenceBackendAdapter.js +735 -0
- package/dist/integration/api-contract.d.ts +319 -0
- package/dist/integration/api-contract.d.ts.map +1 -0
- package/dist/integration/api-contract.js +19 -0
- package/dist/integration/index.d.ts +47 -0
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +46 -0
- package/dist/types/index.d.ts +51 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/utils/PerformanceMonitor.d.ts +115 -0
- package/dist/utils/PerformanceMonitor.d.ts.map +1 -0
- package/dist/utils/PerformanceMonitor.js +171 -0
- package/package.json +82 -0
- package/src/ambient.d.ts +55 -0
- package/src/components/AccessibilityAnnouncer.svelte +102 -0
- package/src/components/AssessmentHeader.svelte +76 -0
- package/src/components/AssessmentShell.svelte +485 -0
- package/src/components/AssessmentTimer.svelte +228 -0
- package/src/components/ItemRenderer.svelte +147 -0
- package/src/components/ItemSessionInfo.svelte +241 -0
- package/src/components/NavigationBar.svelte +142 -0
- package/src/components/RubricDisplay.svelte +185 -0
- package/src/components/SectionMenu.svelte +206 -0
- package/src/components/SplitPaneResizer.svelte +288 -0
- package/src/components/TestFeedback.svelte +147 -0
- package/src/components/index.ts +19 -0
- package/src/core/AssessmentPlayer.ts +720 -0
- package/src/core/ItemSessionController.ts +287 -0
- package/src/core/NavigationManager.ts +126 -0
- package/src/core/StatePersistenceManager.ts +344 -0
- package/src/core/TimeManager.ts +289 -0
- package/src/core/index.ts +15 -0
- package/src/index.ts +13 -0
- package/src/integration/ReferenceBackendAdapter.ts +861 -0
- package/src/integration/api-contract.ts +377 -0
- package/src/integration/index.ts +70 -0
- package/src/svelte-shims.d.ts +7 -0
- package/src/types/index.ts +56 -0
- package/src/utils/PerformanceMonitor.ts +222 -0
- package/svelte.config.js +8 -0
- package/tests/ReferenceBackendAdapter.spec.ts +309 -0
- package/tests/setup.ts +103 -0
- package/tests/smoke.test.ts +7 -0
- package/tsconfig.json +20 -0
- package/tsconfig.svelte.json +10 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI 2.2 Assessment Player - Backend Integration API Contract
|
|
3
|
+
*
|
|
4
|
+
* This file defines the secure API boundary between the client-side player
|
|
5
|
+
* and backend services. The design prioritizes security by ensuring sensitive
|
|
6
|
+
* data (correct answers, scoring rules) never reaches the client.
|
|
7
|
+
*
|
|
8
|
+
* ## Security Model
|
|
9
|
+
*
|
|
10
|
+
* - **Client-side**: Collects and submits candidate responses only
|
|
11
|
+
* - **Server-side**: Stores QTI XML, performs scoring, validates submissions
|
|
12
|
+
* - **Role-based**: Server controls what data client receives based on QTI role
|
|
13
|
+
*
|
|
14
|
+
* ## Reference Implementation
|
|
15
|
+
*
|
|
16
|
+
* See `ReferenceBackendAdapter.ts` for a simple localStorage-based implementation
|
|
17
|
+
* that demonstrates the API contract without requiring a real backend.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { QTIRole } from '@pie-qti/item-player';
|
|
21
|
+
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// SESSION MANAGEMENT
|
|
24
|
+
// ============================================================================
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Unique identifier for an assessment session
|
|
28
|
+
* Format: "{assessmentId}:{candidateId}:{timestamp}" or similar
|
|
29
|
+
*/
|
|
30
|
+
export type SessionId = string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Initialize a new assessment session
|
|
34
|
+
*
|
|
35
|
+
* Security: Server validates candidate identity and assessment access
|
|
36
|
+
*/
|
|
37
|
+
export interface InitSessionRequest {
|
|
38
|
+
/** Assessment identifier (QTI assessmentTest identifier) */
|
|
39
|
+
assessmentId: string;
|
|
40
|
+
/** Candidate identifier (from authentication system) */
|
|
41
|
+
candidateId: string;
|
|
42
|
+
/** Optional: Resume from existing session */
|
|
43
|
+
resumeSessionId?: SessionId;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface InitSessionResponse {
|
|
47
|
+
/** Unique session identifier for all subsequent requests */
|
|
48
|
+
sessionId: SessionId;
|
|
49
|
+
/** Assessment structure WITHOUT sensitive data */
|
|
50
|
+
assessment: SecureAssessment;
|
|
51
|
+
/** Restored state if resuming, undefined if new session */
|
|
52
|
+
restoredState?: SessionState;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// ASSESSMENT STRUCTURE (CLIENT-SAFE)
|
|
57
|
+
// ============================================================================
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Assessment structure safe for client consumption
|
|
61
|
+
*
|
|
62
|
+
* Security: NO correct answers, NO scoring rules, NO sensitive rubrics
|
|
63
|
+
*/
|
|
64
|
+
export interface SecureAssessment {
|
|
65
|
+
identifier: string;
|
|
66
|
+
title: string;
|
|
67
|
+
/** Navigation mode affects UI */
|
|
68
|
+
navigationMode: 'linear' | 'nonlinear';
|
|
69
|
+
/** Submission mode affects when responses are finalized */
|
|
70
|
+
submissionMode: 'individual' | 'simultaneous';
|
|
71
|
+
/** Test parts contain sections */
|
|
72
|
+
testParts: SecureTestPart[];
|
|
73
|
+
/** Overall time limit in seconds (optional) */
|
|
74
|
+
timeLimits?: {
|
|
75
|
+
maxTime?: number; // seconds
|
|
76
|
+
allowLateSubmission?: boolean;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface SecureTestPart {
|
|
81
|
+
identifier: string;
|
|
82
|
+
/** Sections contain items */
|
|
83
|
+
sections: SecureSection[];
|
|
84
|
+
/** Candidate instructions (safe for display) */
|
|
85
|
+
rubrics?: RubricBlock[];
|
|
86
|
+
/**
|
|
87
|
+
* Item session control (QTI testPart/itemSessionControl).
|
|
88
|
+
* Server is authoritative; client uses this for UI hints only.
|
|
89
|
+
*/
|
|
90
|
+
itemSessionControl?: {
|
|
91
|
+
maxAttempts?: number;
|
|
92
|
+
showFeedback?: boolean;
|
|
93
|
+
allowReview?: boolean;
|
|
94
|
+
showSolution?: boolean;
|
|
95
|
+
allowComment?: boolean;
|
|
96
|
+
allowSkipping?: boolean;
|
|
97
|
+
validateResponses?: boolean;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface SecureSection {
|
|
102
|
+
identifier: string;
|
|
103
|
+
title?: string;
|
|
104
|
+
/** Visible determines if section appears in navigation */
|
|
105
|
+
visible: boolean;
|
|
106
|
+
/** Item references */
|
|
107
|
+
items: SecureItemRef[];
|
|
108
|
+
/** Section-level time limit */
|
|
109
|
+
timeLimits?: {
|
|
110
|
+
maxTime?: number;
|
|
111
|
+
};
|
|
112
|
+
/** Candidate instructions (safe for display) */
|
|
113
|
+
rubrics?: RubricBlock[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface SecureItemRef {
|
|
117
|
+
/** Unique item identifier */
|
|
118
|
+
identifier: string;
|
|
119
|
+
/** Item XML WITHOUT responseProcessing if role is 'candidate' */
|
|
120
|
+
itemXml: string;
|
|
121
|
+
/** QTI role determines what's visible in itemXml */
|
|
122
|
+
role: QTIRole;
|
|
123
|
+
/** Required=true means item must be attempted */
|
|
124
|
+
required?: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface RubricBlock {
|
|
128
|
+
/** Optional rubric identifier (QTI rubricBlock@identifier) */
|
|
129
|
+
identifier?: string;
|
|
130
|
+
/** Rubric content (HTML) */
|
|
131
|
+
content: string;
|
|
132
|
+
/** View controls when rubric is shown */
|
|
133
|
+
view: QTIRole[];
|
|
134
|
+
/** Optional rubric use (QTI rubricBlock@use), e.g. "passage" */
|
|
135
|
+
use?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// RESPONSE SUBMISSION
|
|
140
|
+
// ============================================================================
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Submit responses for scoring
|
|
144
|
+
*
|
|
145
|
+
* Security: Client sends responses only, server performs scoring
|
|
146
|
+
*/
|
|
147
|
+
export interface SubmitResponsesRequest {
|
|
148
|
+
sessionId: SessionId;
|
|
149
|
+
/** Item identifier */
|
|
150
|
+
itemIdentifier: string;
|
|
151
|
+
/** Response data keyed by responseIdentifier */
|
|
152
|
+
responses: Record<string, ResponseValue>;
|
|
153
|
+
/** Client timestamp for analytics */
|
|
154
|
+
submittedAt: number;
|
|
155
|
+
/** Time spent on item (ms) for analytics */
|
|
156
|
+
timeSpent?: number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Response value can be string, string[], or complex types
|
|
161
|
+
*/
|
|
162
|
+
export type ResponseValue = string | string[] | Record<string, any>;
|
|
163
|
+
|
|
164
|
+
export interface SubmitResponsesResponse {
|
|
165
|
+
/** Was submission accepted? */
|
|
166
|
+
success: boolean;
|
|
167
|
+
/** Scoring result (if submission mode allows immediate scoring) */
|
|
168
|
+
result?: ScoringResult;
|
|
169
|
+
/**
|
|
170
|
+
* Backend-authoritative next item (branching/navigation decision).
|
|
171
|
+
* If omitted, client may fall back to linear next/previous UI navigation.
|
|
172
|
+
*/
|
|
173
|
+
nextItemIdentifier?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Backend-authoritative session state snapshot after applying the submission.
|
|
176
|
+
* If provided, client should replace its local state with this.
|
|
177
|
+
*/
|
|
178
|
+
updatedState?: SessionState;
|
|
179
|
+
/** Error message if success=false */
|
|
180
|
+
error?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ============================================================================
|
|
184
|
+
// SCORING RESULTS
|
|
185
|
+
// ============================================================================
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Scoring result returned from server
|
|
189
|
+
*
|
|
190
|
+
* Security: Server computes this, client never sees scoring rules
|
|
191
|
+
*/
|
|
192
|
+
export interface ScoringResult {
|
|
193
|
+
/** Item identifier */
|
|
194
|
+
itemIdentifier: string;
|
|
195
|
+
/** Normalized score 0.0-1.0 */
|
|
196
|
+
score: number;
|
|
197
|
+
/** Maximum possible score (usually 1.0) */
|
|
198
|
+
maxScore: number;
|
|
199
|
+
/** Was item completed? */
|
|
200
|
+
completed: boolean;
|
|
201
|
+
/** QTI outcome variables */
|
|
202
|
+
outcomeValues: Record<string, any>;
|
|
203
|
+
/** Feedback to display (role-dependent) */
|
|
204
|
+
feedback?: FeedbackItem[];
|
|
205
|
+
/** Correct response (only if role allows) */
|
|
206
|
+
correctResponse?: Record<string, ResponseValue>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface FeedbackItem {
|
|
210
|
+
/** Feedback content (HTML) */
|
|
211
|
+
content: string;
|
|
212
|
+
/** Feedback type */
|
|
213
|
+
type: 'correct' | 'incorrect' | 'hint' | 'solution';
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// STATE PERSISTENCE
|
|
218
|
+
// ============================================================================
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Save assessment state
|
|
222
|
+
*
|
|
223
|
+
* Security: State includes responses but not scores (until finalized)
|
|
224
|
+
*/
|
|
225
|
+
export interface SaveStateRequest {
|
|
226
|
+
sessionId: SessionId;
|
|
227
|
+
state: SessionState;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface SaveStateResponse {
|
|
231
|
+
success: boolean;
|
|
232
|
+
/** Server timestamp of save */
|
|
233
|
+
savedAt: number;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Session state for persistence
|
|
238
|
+
*/
|
|
239
|
+
export interface SessionState {
|
|
240
|
+
/** Current item identifier */
|
|
241
|
+
currentItemIdentifier: string;
|
|
242
|
+
/** Visited items (for navigation) */
|
|
243
|
+
visitedItems: string[];
|
|
244
|
+
/** Submitted responses per item */
|
|
245
|
+
itemResponses: Record<string, Record<string, ResponseValue>>;
|
|
246
|
+
/** Scoring results per item (populated after submission) */
|
|
247
|
+
itemScores?: Record<string, ScoringResult>;
|
|
248
|
+
/** Time tracking */
|
|
249
|
+
timing: {
|
|
250
|
+
/** Session start time */
|
|
251
|
+
startedAt: number;
|
|
252
|
+
/** Time spent per item (ms) */
|
|
253
|
+
itemTimes: Record<string, number>;
|
|
254
|
+
/** Total elapsed time (ms) */
|
|
255
|
+
totalTime: number;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ============================================================================
|
|
260
|
+
// FINALIZE ASSESSMENT
|
|
261
|
+
// ============================================================================
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Finalize assessment and get full results
|
|
265
|
+
*
|
|
266
|
+
* Security: Server computes final scores, applies late penalties, etc.
|
|
267
|
+
*/
|
|
268
|
+
export interface FinalizeAssessmentRequest {
|
|
269
|
+
sessionId: SessionId;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface FinalizeAssessmentResponse {
|
|
273
|
+
success: boolean;
|
|
274
|
+
/** Overall assessment score */
|
|
275
|
+
totalScore: number;
|
|
276
|
+
/** Maximum possible score */
|
|
277
|
+
maxScore: number;
|
|
278
|
+
/** Per-item results */
|
|
279
|
+
itemScores: Record<string, ScoringResult>;
|
|
280
|
+
/** Assessment-level feedback */
|
|
281
|
+
feedback?: string;
|
|
282
|
+
/** Server timestamp */
|
|
283
|
+
finalizedAt: number;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ============================================================================
|
|
287
|
+
// ITEM BANK QUERIES
|
|
288
|
+
// ============================================================================
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Request items from an item bank for random selection
|
|
292
|
+
*
|
|
293
|
+
* Security: Server validates candidate access to bank
|
|
294
|
+
*/
|
|
295
|
+
export interface QueryItemBankRequest {
|
|
296
|
+
/** Unique session identifier */
|
|
297
|
+
sessionId: SessionId;
|
|
298
|
+
/** Item bank identifier (from selection/@fromBank attribute) */
|
|
299
|
+
bankId: string;
|
|
300
|
+
/** Number of items to select */
|
|
301
|
+
count: number;
|
|
302
|
+
/** Whether to allow selecting same item multiple times */
|
|
303
|
+
withReplacement?: boolean;
|
|
304
|
+
/** Optional filtering criteria (difficulty, topic, etc.) */
|
|
305
|
+
filters?: {
|
|
306
|
+
difficulty?: 'easy' | 'medium' | 'hard';
|
|
307
|
+
topics?: string[];
|
|
308
|
+
[key: string]: unknown;
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Items selected from item bank
|
|
314
|
+
*
|
|
315
|
+
* Security: Returns items WITHOUT correct answers or scoring rules
|
|
316
|
+
*/
|
|
317
|
+
export interface QueryItemBankResponse {
|
|
318
|
+
/** Selected item references (client-safe) */
|
|
319
|
+
items: SecureItemRef[];
|
|
320
|
+
/** Server timestamp */
|
|
321
|
+
selectedAt: number;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ============================================================================
|
|
325
|
+
// BACKEND ADAPTER INTERFACE
|
|
326
|
+
// ============================================================================
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Backend adapter interface - implement this for your backend
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* class MyBackendAdapter implements BackendAdapter {
|
|
334
|
+
* async initSession(req: InitSessionRequest): Promise<InitSessionResponse> {
|
|
335
|
+
* const response = await fetch('/api/qti/init', {
|
|
336
|
+
* method: 'POST',
|
|
337
|
+
* body: JSON.stringify(req)
|
|
338
|
+
* });
|
|
339
|
+
* return response.json();
|
|
340
|
+
* }
|
|
341
|
+
* // ... implement other methods
|
|
342
|
+
* }
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
export interface BackendAdapter {
|
|
346
|
+
/**
|
|
347
|
+
* Initialize new assessment session
|
|
348
|
+
*/
|
|
349
|
+
initSession(request: InitSessionRequest): Promise<InitSessionResponse>;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Submit item responses for scoring
|
|
353
|
+
*/
|
|
354
|
+
submitResponses(request: SubmitResponsesRequest): Promise<SubmitResponsesResponse>;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Save session state (auto-save during assessment)
|
|
358
|
+
*/
|
|
359
|
+
saveState(request: SaveStateRequest): Promise<SaveStateResponse>;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Finalize assessment and get results
|
|
363
|
+
*/
|
|
364
|
+
finalizeAssessment(request: FinalizeAssessmentRequest): Promise<FinalizeAssessmentResponse>;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Resume session (optional - can reuse initSession)
|
|
368
|
+
*/
|
|
369
|
+
resumeSession?(sessionId: SessionId): Promise<InitSessionResponse>;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Query item bank for random item selection
|
|
373
|
+
*
|
|
374
|
+
* Security: Server validates access and returns items WITHOUT sensitive data
|
|
375
|
+
*/
|
|
376
|
+
queryItemBank?(request: QueryItemBankRequest): Promise<QueryItemBankResponse>;
|
|
377
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI 2.2 Assessment Player - Backend Integration
|
|
3
|
+
*
|
|
4
|
+
* ## Default Behavior: Client-Side Only
|
|
5
|
+
*
|
|
6
|
+
* By default, the assessment player runs entirely client-side:
|
|
7
|
+
* - No backend required for demos, development, testing
|
|
8
|
+
* - Uses ReferenceBackendAdapter with localStorage
|
|
9
|
+
* - Scoring performed in-browser using the QTI Player
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { AssessmentPlayer } from '@pie-qti/assessment-player';
|
|
14
|
+
*
|
|
15
|
+
* // Client-only mode (default) - no backend needed
|
|
16
|
+
* const player = new AssessmentPlayer({
|
|
17
|
+
* assessment: myAssessment,
|
|
18
|
+
* role: 'candidate'
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* ## Production: Backend Integration
|
|
23
|
+
*
|
|
24
|
+
* For production deployments, implement BackendAdapter for:
|
|
25
|
+
* - Server-side scoring (secure)
|
|
26
|
+
* - Persistent session storage
|
|
27
|
+
* - Authentication/authorization
|
|
28
|
+
* - Sensitive data protection
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { AssessmentPlayer } from '@pie-qti/assessment-player';
|
|
33
|
+
* import { MyBackendAdapter } from './adapters/MyBackendAdapter';
|
|
34
|
+
*
|
|
35
|
+
* // Production mode with backend
|
|
36
|
+
* const player = new AssessmentPlayer({
|
|
37
|
+
* backend: new MyBackendAdapter('https://api.example.com', authToken),
|
|
38
|
+
* assessmentId: 'test-001',
|
|
39
|
+
* candidateId: 'student-123'
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* See BACKEND-INTEGRATION.md for complete implementation guide.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
// Export API contract (TypeScript interfaces)
|
|
47
|
+
export type {
|
|
48
|
+
BackendAdapter,
|
|
49
|
+
FeedbackItem,
|
|
50
|
+
FinalizeAssessmentRequest,
|
|
51
|
+
FinalizeAssessmentResponse,
|
|
52
|
+
InitSessionRequest,
|
|
53
|
+
InitSessionResponse,
|
|
54
|
+
ResponseValue,
|
|
55
|
+
RubricBlock,
|
|
56
|
+
SaveStateRequest,
|
|
57
|
+
SaveStateResponse,
|
|
58
|
+
ScoringResult,
|
|
59
|
+
SecureAssessment,
|
|
60
|
+
SecureItemRef,
|
|
61
|
+
SecureSection,
|
|
62
|
+
SecureTestPart,
|
|
63
|
+
SessionId,
|
|
64
|
+
SessionState,
|
|
65
|
+
SubmitResponsesRequest,
|
|
66
|
+
SubmitResponsesResponse,
|
|
67
|
+
} from './api-contract.js';
|
|
68
|
+
|
|
69
|
+
// Export reference implementation (for development/demos)
|
|
70
|
+
export { ReferenceBackendAdapter } from './ReferenceBackendAdapter.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type definitions for the backend-authoritative assessment player.
|
|
3
|
+
*
|
|
4
|
+
* The client does not evaluate branching or outcome processing; it renders items and
|
|
5
|
+
* delegates decisions to a BackendAdapter.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type QTIRole = import('@pie-qti/item-player').QTIRole;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Minimal item reference shape used by the UI renderer.
|
|
12
|
+
*/
|
|
13
|
+
export interface QuestionRef {
|
|
14
|
+
identifier: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
/** Client-safe item XML (backend filtered by role). */
|
|
18
|
+
itemXml?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Time limits (test/section/item level), matching QTI concepts.
|
|
23
|
+
*/
|
|
24
|
+
export interface TimeLimits {
|
|
25
|
+
maxTime?: number; // seconds
|
|
26
|
+
minTime?: number; // seconds
|
|
27
|
+
allowLateSubmission?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NavigationState {
|
|
31
|
+
currentIndex: number;
|
|
32
|
+
totalItems: number;
|
|
33
|
+
canNext: boolean;
|
|
34
|
+
canPrevious: boolean;
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
currentSection?: {
|
|
37
|
+
id: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
index: number;
|
|
40
|
+
};
|
|
41
|
+
totalSections?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ItemResult {
|
|
45
|
+
itemIdentifier: string;
|
|
46
|
+
score: number;
|
|
47
|
+
maxScore: number;
|
|
48
|
+
responses: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface AssessmentResults {
|
|
52
|
+
totalScore: number;
|
|
53
|
+
maxScore: number;
|
|
54
|
+
itemResults: ItemResult[];
|
|
55
|
+
completedAt: Date;
|
|
56
|
+
}
|