@pie-qti/assessment-player 0.1.1 → 0.1.4
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 +14 -7
- package/dist/core/AssessmentPlayer.d.ts.map +1 -1
- package/dist/core/AssessmentPlayer.js +33 -34
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/integration/ReferenceBackendAdapter.d.ts +2 -2
- package/dist/integration/ReferenceBackendAdapter.d.ts.map +1 -1
- package/dist/integration/ReferenceBackendAdapter.js +5 -5
- package/dist/integration/api-contract.d.ts +16 -16
- package/dist/integration/api-contract.d.ts.map +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/integration/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +100 -80
- package/src/components/AssessmentShell.svelte +8 -8
- package/src/components/ItemRenderer.svelte +8 -8
- package/src/components/NavigationBar.svelte +3 -1
- package/src/components/RubricDisplay.svelte +2 -2
- package/src/core/AssessmentPlayer.ts +51 -44
- package/src/index.ts +1 -1
- package/src/integration/ReferenceBackendAdapter.ts +13 -13
- package/src/integration/api-contract.ts +16 -16
- package/src/integration/index.ts +5 -5
- package/src/types/index.ts +1 -1
- package/.turbo/turbo-build.log +0 -1
- package/BACKEND-INTEGRATION.md +0 -620
- package/CHANGELOG.md +0 -11
- package/EXTENSIBILITY.md +0 -551
- package/svelte.config.js +0 -8
- package/tests/ReferenceBackendAdapter.spec.ts +0 -309
- package/tests/setup.ts +0 -103
- package/tests/smoke.test.ts +0 -7
- package/tsconfig.json +0 -20
- package/tsconfig.svelte.json +0 -10
|
@@ -41,6 +41,8 @@ import {
|
|
|
41
41
|
import { Player } from '@pie-qti/item-player';
|
|
42
42
|
import { parse } from 'node-html-parser';
|
|
43
43
|
import type {
|
|
44
|
+
AssessmentSessionState,
|
|
45
|
+
AssessmentScoringResult,
|
|
44
46
|
BackendAdapter,
|
|
45
47
|
FinalizeAssessmentRequest,
|
|
46
48
|
FinalizeAssessmentResponse,
|
|
@@ -48,13 +50,11 @@ import type {
|
|
|
48
50
|
InitSessionResponse,
|
|
49
51
|
QueryItemBankRequest,
|
|
50
52
|
QueryItemBankResponse,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ScoringResult,
|
|
53
|
+
SaveAssessmentStateRequest,
|
|
54
|
+
SaveAssessmentStateResponse,
|
|
54
55
|
SecureAssessment,
|
|
55
56
|
SecureItemRef,
|
|
56
57
|
SessionId,
|
|
57
|
-
SessionState,
|
|
58
58
|
SubmitResponsesRequest,
|
|
59
59
|
SubmitResponsesResponse,
|
|
60
60
|
} from './api-contract.js';
|
|
@@ -88,7 +88,7 @@ interface StoredSession {
|
|
|
88
88
|
/** Full assessment structure with QTI XML */
|
|
89
89
|
assessment: SecureAssessment;
|
|
90
90
|
/** Current state */
|
|
91
|
-
state:
|
|
91
|
+
state: AssessmentSessionState;
|
|
92
92
|
/** Created timestamp */
|
|
93
93
|
createdAt: number;
|
|
94
94
|
/** Finalized flag */
|
|
@@ -152,8 +152,8 @@ export class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
152
152
|
// For reference implementation, we'll use demo data
|
|
153
153
|
const assessment = this.getAssessment(request.assessmentId);
|
|
154
154
|
|
|
155
|
-
const state:
|
|
156
|
-
currentItemIdentifier: assessment.testParts[0].sections[0].
|
|
155
|
+
const state: AssessmentSessionState = {
|
|
156
|
+
currentItemIdentifier: assessment.testParts[0].sections[0].assessmentItemRefs[0].identifier,
|
|
157
157
|
visitedItems: [],
|
|
158
158
|
itemResponses: {},
|
|
159
159
|
itemScores: {},
|
|
@@ -258,7 +258,7 @@ export class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
258
258
|
/**
|
|
259
259
|
* Save session state (for auto-save)
|
|
260
260
|
*/
|
|
261
|
-
async saveState(request:
|
|
261
|
+
async saveState(request: SaveAssessmentStateRequest): Promise<SaveAssessmentStateResponse> {
|
|
262
262
|
const session = this.loadSession(request.sessionId);
|
|
263
263
|
if (!session) {
|
|
264
264
|
return {
|
|
@@ -400,7 +400,7 @@ export class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
400
400
|
private findItemXml(assessment: SecureAssessment, itemIdentifier: string): string | null {
|
|
401
401
|
for (const part of assessment.testParts) {
|
|
402
402
|
for (const section of part.sections) {
|
|
403
|
-
for (const item of section.
|
|
403
|
+
for (const item of section.assessmentItemRefs) {
|
|
404
404
|
if (item.identifier === itemIdentifier) {
|
|
405
405
|
return item.itemXml;
|
|
406
406
|
}
|
|
@@ -416,7 +416,7 @@ export class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
416
416
|
* **SECURITY WARNING**: This is done CLIENT-SIDE for demo purposes only.
|
|
417
417
|
* Production implementations MUST perform scoring SERVER-SIDE.
|
|
418
418
|
*/
|
|
419
|
-
private scoreItem(itemXml: string, responses: Record<string, any>):
|
|
419
|
+
private scoreItem(itemXml: string, responses: Record<string, any>): AssessmentScoringResult {
|
|
420
420
|
try {
|
|
421
421
|
// Extract identifier from XML using regex (more reliable than DOM parsing)
|
|
422
422
|
const identifierMatch = itemXml.match(/assessmentItem[^>]+identifier=["']([^"']+)["']/);
|
|
@@ -471,7 +471,7 @@ export class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
471
471
|
testParts: [
|
|
472
472
|
{
|
|
473
473
|
identifier: 'part1',
|
|
474
|
-
|
|
474
|
+
rubricBlocks: [],
|
|
475
475
|
itemSessionControl: {
|
|
476
476
|
maxAttempts: 1,
|
|
477
477
|
showFeedback: true,
|
|
@@ -486,7 +486,7 @@ export class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
486
486
|
identifier: 'section1',
|
|
487
487
|
title: 'Section 1',
|
|
488
488
|
visible: true,
|
|
489
|
-
|
|
489
|
+
assessmentItemRefs: [
|
|
490
490
|
{
|
|
491
491
|
identifier: 'item1',
|
|
492
492
|
role: 'candidate',
|
|
@@ -607,7 +607,7 @@ export class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
607
607
|
const out: string[] = [];
|
|
608
608
|
for (const part of assessment.testParts || []) {
|
|
609
609
|
for (const section of part.sections || []) {
|
|
610
|
-
for (const item of section.
|
|
610
|
+
for (const item of section.assessmentItemRefs || []) {
|
|
611
611
|
out.push(item.identifier);
|
|
612
612
|
}
|
|
613
613
|
}
|
|
@@ -49,7 +49,7 @@ export interface InitSessionResponse {
|
|
|
49
49
|
/** Assessment structure WITHOUT sensitive data */
|
|
50
50
|
assessment: SecureAssessment;
|
|
51
51
|
/** Restored state if resuming, undefined if new session */
|
|
52
|
-
restoredState?:
|
|
52
|
+
restoredState?: AssessmentSessionState;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// ============================================================================
|
|
@@ -82,7 +82,7 @@ export interface SecureTestPart {
|
|
|
82
82
|
/** Sections contain items */
|
|
83
83
|
sections: SecureSection[];
|
|
84
84
|
/** Candidate instructions (safe for display) */
|
|
85
|
-
|
|
85
|
+
rubricBlocks?: AssessmentRubricBlock[];
|
|
86
86
|
/**
|
|
87
87
|
* Item session control (QTI testPart/itemSessionControl).
|
|
88
88
|
* Server is authoritative; client uses this for UI hints only.
|
|
@@ -103,14 +103,14 @@ export interface SecureSection {
|
|
|
103
103
|
title?: string;
|
|
104
104
|
/** Visible determines if section appears in navigation */
|
|
105
105
|
visible: boolean;
|
|
106
|
-
/**
|
|
107
|
-
|
|
106
|
+
/** Assessment item references */
|
|
107
|
+
assessmentItemRefs: SecureItemRef[];
|
|
108
108
|
/** Section-level time limit */
|
|
109
109
|
timeLimits?: {
|
|
110
110
|
maxTime?: number;
|
|
111
111
|
};
|
|
112
112
|
/** Candidate instructions (safe for display) */
|
|
113
|
-
|
|
113
|
+
rubricBlocks?: AssessmentRubricBlock[];
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
export interface SecureItemRef {
|
|
@@ -124,7 +124,7 @@ export interface SecureItemRef {
|
|
|
124
124
|
required?: boolean;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export interface
|
|
127
|
+
export interface AssessmentRubricBlock {
|
|
128
128
|
/** Optional rubric identifier (QTI rubricBlock@identifier) */
|
|
129
129
|
identifier?: string;
|
|
130
130
|
/** Rubric content (HTML) */
|
|
@@ -165,7 +165,7 @@ export interface SubmitResponsesResponse {
|
|
|
165
165
|
/** Was submission accepted? */
|
|
166
166
|
success: boolean;
|
|
167
167
|
/** Scoring result (if submission mode allows immediate scoring) */
|
|
168
|
-
result?:
|
|
168
|
+
result?: AssessmentScoringResult;
|
|
169
169
|
/**
|
|
170
170
|
* Backend-authoritative next item (branching/navigation decision).
|
|
171
171
|
* If omitted, client may fall back to linear next/previous UI navigation.
|
|
@@ -175,7 +175,7 @@ export interface SubmitResponsesResponse {
|
|
|
175
175
|
* Backend-authoritative session state snapshot after applying the submission.
|
|
176
176
|
* If provided, client should replace its local state with this.
|
|
177
177
|
*/
|
|
178
|
-
updatedState?:
|
|
178
|
+
updatedState?: AssessmentSessionState;
|
|
179
179
|
/** Error message if success=false */
|
|
180
180
|
error?: string;
|
|
181
181
|
}
|
|
@@ -189,7 +189,7 @@ export interface SubmitResponsesResponse {
|
|
|
189
189
|
*
|
|
190
190
|
* Security: Server computes this, client never sees scoring rules
|
|
191
191
|
*/
|
|
192
|
-
export interface
|
|
192
|
+
export interface AssessmentScoringResult {
|
|
193
193
|
/** Item identifier */
|
|
194
194
|
itemIdentifier: string;
|
|
195
195
|
/** Normalized score 0.0-1.0 */
|
|
@@ -222,12 +222,12 @@ export interface FeedbackItem {
|
|
|
222
222
|
*
|
|
223
223
|
* Security: State includes responses but not scores (until finalized)
|
|
224
224
|
*/
|
|
225
|
-
export interface
|
|
225
|
+
export interface SaveAssessmentStateRequest {
|
|
226
226
|
sessionId: SessionId;
|
|
227
|
-
state:
|
|
227
|
+
state: AssessmentSessionState;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
export interface
|
|
230
|
+
export interface SaveAssessmentStateResponse {
|
|
231
231
|
success: boolean;
|
|
232
232
|
/** Server timestamp of save */
|
|
233
233
|
savedAt: number;
|
|
@@ -236,7 +236,7 @@ export interface SaveStateResponse {
|
|
|
236
236
|
/**
|
|
237
237
|
* Session state for persistence
|
|
238
238
|
*/
|
|
239
|
-
export interface
|
|
239
|
+
export interface AssessmentSessionState {
|
|
240
240
|
/** Current item identifier */
|
|
241
241
|
currentItemIdentifier: string;
|
|
242
242
|
/** Visited items (for navigation) */
|
|
@@ -244,7 +244,7 @@ export interface SessionState {
|
|
|
244
244
|
/** Submitted responses per item */
|
|
245
245
|
itemResponses: Record<string, Record<string, ResponseValue>>;
|
|
246
246
|
/** Scoring results per item (populated after submission) */
|
|
247
|
-
itemScores?: Record<string,
|
|
247
|
+
itemScores?: Record<string, AssessmentScoringResult>;
|
|
248
248
|
/** Time tracking */
|
|
249
249
|
timing: {
|
|
250
250
|
/** Session start time */
|
|
@@ -276,7 +276,7 @@ export interface FinalizeAssessmentResponse {
|
|
|
276
276
|
/** Maximum possible score */
|
|
277
277
|
maxScore: number;
|
|
278
278
|
/** Per-item results */
|
|
279
|
-
itemScores: Record<string,
|
|
279
|
+
itemScores: Record<string, AssessmentScoringResult>;
|
|
280
280
|
/** Assessment-level feedback */
|
|
281
281
|
feedback?: string;
|
|
282
282
|
/** Server timestamp */
|
|
@@ -356,7 +356,7 @@ export interface BackendAdapter {
|
|
|
356
356
|
/**
|
|
357
357
|
* Save session state (auto-save during assessment)
|
|
358
358
|
*/
|
|
359
|
-
saveState(request:
|
|
359
|
+
saveState(request: SaveAssessmentStateRequest): Promise<SaveAssessmentStateResponse>;
|
|
360
360
|
|
|
361
361
|
/**
|
|
362
362
|
* Finalize assessment and get results
|
package/src/integration/index.ts
CHANGED
|
@@ -47,21 +47,21 @@
|
|
|
47
47
|
export type {
|
|
48
48
|
BackendAdapter,
|
|
49
49
|
FeedbackItem,
|
|
50
|
+
AssessmentSessionState,
|
|
51
|
+
AssessmentScoringResult,
|
|
52
|
+
AssessmentRubricBlock,
|
|
50
53
|
FinalizeAssessmentRequest,
|
|
51
54
|
FinalizeAssessmentResponse,
|
|
52
55
|
InitSessionRequest,
|
|
53
56
|
InitSessionResponse,
|
|
54
57
|
ResponseValue,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
SaveStateResponse,
|
|
58
|
-
ScoringResult,
|
|
58
|
+
SaveAssessmentStateRequest,
|
|
59
|
+
SaveAssessmentStateResponse,
|
|
59
60
|
SecureAssessment,
|
|
60
61
|
SecureItemRef,
|
|
61
62
|
SecureSection,
|
|
62
63
|
SecureTestPart,
|
|
63
64
|
SessionId,
|
|
64
|
-
SessionState,
|
|
65
65
|
SubmitResponsesRequest,
|
|
66
66
|
SubmitResponsesResponse,
|
|
67
67
|
} from './api-contract.js';
|
package/src/types/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type QTIRole = import('@pie-qti/item-player').QTIRole;
|
|
|
10
10
|
/**
|
|
11
11
|
* Minimal item reference shape used by the UI renderer.
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
13
|
+
export interface ItemRef {
|
|
14
14
|
identifier: string;
|
|
15
15
|
title?: string;
|
|
16
16
|
required?: boolean;
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$ tsc
|