@pie-qti/assessment-player 1.0.0-beta.4 → 1.0.0-beta.6

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.
Files changed (134) hide show
  1. package/README.md +28 -7
  2. package/dist/components/createPlayerConnection.svelte.d.ts +90 -0
  3. package/dist/components/createPlayerConnection.svelte.js +151 -0
  4. package/dist/components/createPlayerConnection.svelte.js.map +1 -0
  5. package/dist/components/displaySettings.svelte.d.ts +23 -0
  6. package/dist/components/displaySettings.svelte.js +40 -0
  7. package/dist/components/displaySettings.svelte.js.map +1 -0
  8. package/dist/components/srOnly.d.ts +29 -0
  9. package/dist/components/srOnly.js +55 -0
  10. package/dist/components/srOnly.js.map +1 -0
  11. package/dist/components/submitDialogAction.d.ts +25 -0
  12. package/dist/components/submitDialogAction.js +89 -0
  13. package/dist/components/submitDialogAction.js.map +1 -0
  14. package/dist/core/AssessmentPlayer.d.ts +1102 -53
  15. package/dist/core/AssessmentPlayer.js +2835 -460
  16. package/dist/core/AssessmentPlayer.js.map +1 -1
  17. package/dist/core/AssessmentSessionCoordinator.d.ts +76 -7
  18. package/dist/core/AssessmentSessionCoordinator.js +185 -10
  19. package/dist/core/AssessmentSessionCoordinator.js.map +1 -1
  20. package/dist/core/AutosaveManager.d.ts +104 -0
  21. package/dist/core/AutosaveManager.js +181 -0
  22. package/dist/core/AutosaveManager.js.map +1 -0
  23. package/dist/core/ItemSessionController.d.ts +17 -26
  24. package/dist/core/ItemSessionController.js +33 -73
  25. package/dist/core/ItemSessionController.js.map +1 -1
  26. package/dist/core/NavigationManager.d.ts +18 -50
  27. package/dist/core/NavigationManager.js +21 -83
  28. package/dist/core/NavigationManager.js.map +1 -1
  29. package/dist/core/TimeManager.d.ts +62 -16
  30. package/dist/core/TimeManager.js +148 -57
  31. package/dist/core/TimeManager.js.map +1 -1
  32. package/dist/core/autosave.d.ts +44 -0
  33. package/dist/core/autosave.js +46 -0
  34. package/dist/core/autosave.js.map +1 -0
  35. package/dist/core/deliveryStructure.d.ts +54 -0
  36. package/dist/core/deliveryStructure.js +72 -0
  37. package/dist/core/deliveryStructure.js.map +1 -0
  38. package/dist/core/errors.d.ts +116 -0
  39. package/dist/core/errors.js +77 -0
  40. package/dist/core/errors.js.map +1 -0
  41. package/dist/core/exitBoundaries.d.ts +64 -0
  42. package/dist/core/exitBoundaries.js +98 -0
  43. package/dist/core/exitBoundaries.js.map +1 -0
  44. package/dist/core/feedback.d.ts +46 -0
  45. package/dist/core/feedback.js +47 -0
  46. package/dist/core/feedback.js.map +1 -0
  47. package/dist/core/formatTime.d.ts +8 -0
  48. package/dist/core/formatTime.js +20 -0
  49. package/dist/core/formatTime.js.map +1 -0
  50. package/dist/core/index.d.ts +7 -4
  51. package/dist/core/index.js +4 -1
  52. package/dist/core/index.js.map +1 -1
  53. package/dist/core/navigationPolicy.d.ts +42 -0
  54. package/dist/core/navigationPolicy.js +62 -0
  55. package/dist/core/navigationPolicy.js.map +1 -0
  56. package/dist/core/pause.d.ts +58 -0
  57. package/dist/core/pause.js +101 -0
  58. package/dist/core/pause.js.map +1 -0
  59. package/dist/core/playerEvents.d.ts +51 -0
  60. package/dist/core/playerEvents.js +66 -0
  61. package/dist/core/playerEvents.js.map +1 -0
  62. package/dist/core/reviewState.d.ts +81 -0
  63. package/dist/core/reviewState.js +113 -0
  64. package/dist/core/reviewState.js.map +1 -0
  65. package/dist/core/reviewViews.d.ts +43 -0
  66. package/dist/core/reviewViews.js +88 -0
  67. package/dist/core/reviewViews.js.map +1 -0
  68. package/dist/core/scopeLocks.d.ts +36 -0
  69. package/dist/core/scopeLocks.js +78 -0
  70. package/dist/core/scopeLocks.js.map +1 -0
  71. package/dist/core/sessionRecords.d.ts +31 -0
  72. package/dist/core/sessionRecords.js +74 -0
  73. package/dist/core/sessionRecords.js.map +1 -0
  74. package/dist/core/submissionPolicy.d.ts +62 -0
  75. package/dist/core/submissionPolicy.js +67 -0
  76. package/dist/core/submissionPolicy.js.map +1 -0
  77. package/dist/core/templateDefaults.d.ts +26 -0
  78. package/dist/core/templateDefaults.js +53 -0
  79. package/dist/core/templateDefaults.js.map +1 -0
  80. package/dist/core/testStructure.d.ts +118 -3
  81. package/dist/core/testStructure.js +252 -6
  82. package/dist/core/testStructure.js.map +1 -1
  83. package/dist/core/timePolicy.d.ts +40 -0
  84. package/dist/core/timePolicy.js +106 -0
  85. package/dist/core/timePolicy.js.map +1 -0
  86. package/dist/index.d.ts +7 -4
  87. package/dist/index.js +5 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/integration/ReferenceBackendAdapter.d.ts +64 -101
  90. package/dist/integration/ReferenceBackendAdapter.js +216 -1035
  91. package/dist/integration/ReferenceBackendAdapter.js.map +1 -1
  92. package/dist/integration/api-contract.d.ts +179 -17
  93. package/dist/integration/api-contract.js.map +1 -1
  94. package/dist/integration/assessment-item-scorer.d.ts +56 -5
  95. package/dist/integration/assessment-item-scorer.js +116 -13
  96. package/dist/integration/assessment-item-scorer.js.map +1 -1
  97. package/dist/integration/index.d.ts +2 -2
  98. package/dist/integration/index.js +1 -1
  99. package/dist/integration/index.js.map +1 -1
  100. package/dist/integration/qti-test-parser.d.ts +44 -0
  101. package/dist/integration/qti-test-parser.js +529 -0
  102. package/dist/integration/qti-test-parser.js.map +1 -0
  103. package/dist/integration/session-store.d.ts +54 -0
  104. package/dist/integration/session-store.js +75 -0
  105. package/dist/integration/session-store.js.map +1 -0
  106. package/dist/integration/test-navigation.d.ts +23 -0
  107. package/dist/integration/test-navigation.js +32 -0
  108. package/dist/integration/test-navigation.js.map +1 -0
  109. package/dist/integration/toSectionComposition.js +8 -1
  110. package/dist/integration/toSectionComposition.js.map +1 -1
  111. package/dist/reporting/index.d.ts +3 -0
  112. package/dist/reporting/index.js +3 -0
  113. package/dist/reporting/index.js.map +1 -0
  114. package/dist/reporting/inferBaseType.d.ts +13 -0
  115. package/dist/reporting/inferBaseType.js +26 -0
  116. package/dist/reporting/inferBaseType.js.map +1 -0
  117. package/dist/reporting/serializeAssessmentResult.d.ts +27 -0
  118. package/dist/reporting/serializeAssessmentResult.js +377 -0
  119. package/dist/reporting/serializeAssessmentResult.js.map +1 -0
  120. package/dist/reporting/toAssessmentResultXml.d.ts +39 -0
  121. package/dist/reporting/toAssessmentResultXml.js +304 -0
  122. package/dist/reporting/toAssessmentResultXml.js.map +1 -0
  123. package/dist/reporting/types.d.ts +85 -0
  124. package/dist/reporting/types.js +8 -0
  125. package/dist/reporting/types.js.map +1 -0
  126. package/dist/types/index.d.ts +96 -9
  127. package/dist/types/index.js.map +1 -1
  128. package/package.json +21 -15
  129. package/dist/core/StatePersistenceManager.d.ts +0 -125
  130. package/dist/core/StatePersistenceManager.js +0 -268
  131. package/dist/core/StatePersistenceManager.js.map +0 -1
  132. package/dist/utils/PerformanceMonitor.d.ts +0 -114
  133. package/dist/utils/PerformanceMonitor.js +0 -172
  134. package/dist/utils/PerformanceMonitor.js.map +0 -1
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@pie-qti/assessment-player",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.6",
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",
7
7
  "types": "./dist/index.d.ts",
8
8
  "scripts": {
9
9
  "build": "tsc",
10
- "test": "bun test --preload ./tests/setup.ts",
11
- "typecheck": "tsc --noEmit",
10
+ "test": "bun test --preload ./tests/setup.ts && bun run test:component",
11
+ "test:component": "vitest run",
12
+ "typecheck": "tsc --noEmit && tsc -p ./tsconfig.test.json --noEmit",
12
13
  "check": "svelte-check --tsconfig ./tsconfig.svelte.json",
13
14
  "lint": "biome check .",
14
15
  "lint:fix": "biome check --write .",
@@ -28,20 +29,25 @@
28
29
  ],
29
30
  "license": "MIT",
30
31
  "dependencies": {
31
- "@pie-qti/assessment-toolkit": "1.0.0-beta.4",
32
- "@pie-qti/i18n": "1.0.0-beta.4",
33
- "@pie-qti/ims-cp-core": "1.0.0-beta.4",
34
- "@pie-qti/item-player": "1.0.0-beta.4",
35
- "@pie-qti/qti-common": "1.0.0-beta.4",
36
- "@pie-qti/qti-processing": "1.0.0-beta.4",
37
- "@pie-qti/section-player": "1.0.0-beta.4"
32
+ "@pie-qti/assessment-toolkit": "1.0.0-beta.6",
33
+ "@pie-qti/i18n": "1.0.0-beta.6",
34
+ "@pie-qti/ims-cp-core": "1.0.0-beta.6",
35
+ "@pie-qti/item-player": "1.0.0-beta.6",
36
+ "@pie-qti/qti-common": "1.0.0-beta.6",
37
+ "@pie-qti/qti-processing": "1.0.0-beta.6",
38
+ "@pie-qti/section-player": "1.0.0-beta.6",
39
+ "node-html-parser": "^9.0.7"
38
40
  },
39
41
  "devDependencies": {
40
- "@biomejs/biome": "^2.6.2",
41
- "@types/node": "^26.6.4",
42
- "svelte": "^5.57.1",
43
- "svelte-check": "^4.7.7",
44
- "typescript": "^5.9.3"
42
+ "@biomejs/biome": "^2.6.8",
43
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
44
+ "@types/node": "^26.6.6",
45
+ "jsdom": "^31.0.1",
46
+ "svelte": "^5.57.3",
47
+ "svelte-check": "^4.7.8",
48
+ "typescript": "^6.0.3",
49
+ "vite": "^8.3.8",
50
+ "vitest": "^5.1.0"
45
51
  },
46
52
  "exports": {
47
53
  ".": {
@@ -1,125 +0,0 @@
1
- /**
2
- * StatePersistenceManager
3
- *
4
- * Manages automatic state persistence for assessment sessions.
5
- * Supports both client-side (localStorage) and server-side persistence.
6
- *
7
- * Features:
8
- * - Auto-save on state changes (debounced)
9
- * - Manual save triggers
10
- * - State restoration
11
- * - Optional backend integration
12
- * - Fallback to localStorage when backend unavailable
13
- */
14
- export interface PersistableState {
15
- /** Assessment identifier */
16
- assessmentId: string;
17
- /** Current item index */
18
- currentItemIndex: number;
19
- /** Visited item indices */
20
- visitedItems: number[];
21
- /** Response data per item */
22
- responses: Record<string, unknown>;
23
- /** Item session states (attempts, submission status) */
24
- itemSessionStates: Record<string, {
25
- attemptCount: number;
26
- isAnswered: boolean;
27
- isSubmitted: boolean;
28
- lastSubmissionTime?: number;
29
- }>;
30
- /** Time tracking data */
31
- timeTracking?: {
32
- startedAt: number;
33
- totalElapsed: number;
34
- itemTimes: Record<string, number>;
35
- sectionTimes: Record<string, number>;
36
- };
37
- /** Last saved timestamp */
38
- savedAt: number;
39
- }
40
- export interface PersistenceConfig {
41
- /** Unique session identifier */
42
- sessionId: string;
43
- /** Assessment identifier */
44
- assessmentId: string;
45
- /** Auto-save enabled (default: true) */
46
- autoSave?: boolean;
47
- /** Auto-save debounce delay in ms (default: 2000) */
48
- autoSaveDelay?: number;
49
- /** Storage strategy */
50
- storage?: 'localStorage' | 'sessionStorage' | 'memory';
51
- /** Optional backend save callback */
52
- onBackendSave?: (state: PersistableState) => Promise<void>;
53
- /** Optional save success callback */
54
- onSaveSuccess?: (state: PersistableState) => void;
55
- /** Optional save error callback */
56
- onSaveError?: (error: Error) => void;
57
- }
58
- export declare class StatePersistenceManager {
59
- private config;
60
- private currentState;
61
- private autoSaveTimer;
62
- private isSaving;
63
- private memoryStorage;
64
- constructor(config: PersistenceConfig);
65
- /**
66
- * Update state and trigger auto-save
67
- */
68
- updateState(state: Partial<PersistableState>): void;
69
- /**
70
- * Schedule auto-save with debouncing
71
- */
72
- private scheduleAutoSave;
73
- /**
74
- * Manually save current state
75
- */
76
- save(): Promise<void>;
77
- /**
78
- * Save to configured storage
79
- */
80
- private saveToStorage;
81
- /**
82
- * Load state from storage
83
- */
84
- load(): Promise<PersistableState | null>;
85
- /**
86
- * Check if saved state exists
87
- */
88
- hasSavedState(): Promise<boolean>;
89
- /**
90
- * Clear saved state
91
- */
92
- clear(): Promise<void>;
93
- /**
94
- * Get current state without saving
95
- */
96
- getCurrentState(): PersistableState | null;
97
- /**
98
- * Get storage key for this session
99
- */
100
- private getStorageKey;
101
- /**
102
- * Force immediate save (bypasses debounce)
103
- */
104
- forceSave(): Promise<void>;
105
- /**
106
- * Pause auto-save (useful during navigation transitions)
107
- */
108
- pauseAutoSave(): void;
109
- /**
110
- * Resume auto-save
111
- */
112
- resumeAutoSave(): void;
113
- /**
114
- * Get last save timestamp
115
- */
116
- getLastSaveTime(): number | null;
117
- /**
118
- * Check if state has been modified since last save
119
- */
120
- isDirty(): boolean;
121
- /**
122
- * Cleanup
123
- */
124
- destroy(): void;
125
- }
@@ -1,268 +0,0 @@
1
- /**
2
- * StatePersistenceManager
3
- *
4
- * Manages automatic state persistence for assessment sessions.
5
- * Supports both client-side (localStorage) and server-side persistence.
6
- *
7
- * Features:
8
- * - Auto-save on state changes (debounced)
9
- * - Manual save triggers
10
- * - State restoration
11
- * - Optional backend integration
12
- * - Fallback to localStorage when backend unavailable
13
- */
14
- export class StatePersistenceManager {
15
- constructor(config) {
16
- this.currentState = null;
17
- this.autoSaveTimer = null;
18
- this.isSaving = false;
19
- this.memoryStorage = new Map();
20
- this.config = {
21
- autoSave: true,
22
- autoSaveDelay: 2000,
23
- storage: 'localStorage',
24
- ...config,
25
- };
26
- }
27
- /**
28
- * Update state and trigger auto-save
29
- */
30
- updateState(state) {
31
- // Merge with existing state
32
- this.currentState = {
33
- ...this.currentState,
34
- assessmentId: this.config.assessmentId,
35
- savedAt: Date.now(),
36
- ...state,
37
- };
38
- // Trigger auto-save
39
- if (this.config.autoSave) {
40
- this.scheduleAutoSave();
41
- }
42
- }
43
- /**
44
- * Schedule auto-save with debouncing
45
- */
46
- scheduleAutoSave() {
47
- // Clear existing timer
48
- if (this.autoSaveTimer) {
49
- clearTimeout(this.autoSaveTimer);
50
- }
51
- // Schedule new save
52
- this.autoSaveTimer = setTimeout(() => {
53
- this.save().catch((error) => {
54
- console.error('[StatePersistenceManager] Auto-save failed:', error);
55
- this.config.onSaveError?.(error);
56
- });
57
- }, this.config.autoSaveDelay);
58
- }
59
- /**
60
- * Manually save current state
61
- */
62
- async save() {
63
- if (!this.currentState) {
64
- return;
65
- }
66
- if (this.isSaving) {
67
- console.warn('[StatePersistenceManager] Save already in progress');
68
- return;
69
- }
70
- this.isSaving = true;
71
- try {
72
- // Update timestamp
73
- this.currentState.savedAt = Date.now();
74
- // Try backend save first (if configured)
75
- if (this.config.onBackendSave) {
76
- try {
77
- await this.config.onBackendSave(this.currentState);
78
- }
79
- catch (backendError) {
80
- console.warn('[StatePersistenceManager] Backend save failed, falling back to local:', backendError);
81
- // Continue to local save as fallback
82
- }
83
- }
84
- // Save to local storage
85
- this.saveToStorage(this.currentState);
86
- // Success callback
87
- this.config.onSaveSuccess?.(this.currentState);
88
- }
89
- catch (error) {
90
- console.error('[StatePersistenceManager] Save failed:', error);
91
- this.config.onSaveError?.(error);
92
- throw error;
93
- }
94
- finally {
95
- this.isSaving = false;
96
- }
97
- }
98
- /**
99
- * Save to configured storage
100
- */
101
- saveToStorage(state) {
102
- const key = this.getStorageKey();
103
- const data = JSON.stringify(state);
104
- try {
105
- switch (this.config.storage) {
106
- case 'localStorage':
107
- if (typeof localStorage !== 'undefined') {
108
- localStorage.setItem(key, data);
109
- }
110
- else {
111
- this.memoryStorage.set(key, data);
112
- }
113
- break;
114
- case 'sessionStorage':
115
- if (typeof sessionStorage !== 'undefined') {
116
- sessionStorage.setItem(key, data);
117
- }
118
- else {
119
- this.memoryStorage.set(key, data);
120
- }
121
- break;
122
- case 'memory':
123
- this.memoryStorage.set(key, data);
124
- break;
125
- }
126
- }
127
- catch (error) {
128
- // Storage quota exceeded or other storage error
129
- console.error('[StatePersistenceManager] Storage save failed:', error);
130
- // Fallback to memory storage
131
- this.memoryStorage.set(key, data);
132
- }
133
- }
134
- /**
135
- * Load state from storage
136
- */
137
- async load() {
138
- const key = this.getStorageKey();
139
- let data = null;
140
- try {
141
- switch (this.config.storage) {
142
- case 'localStorage':
143
- data = typeof localStorage !== 'undefined'
144
- ? localStorage.getItem(key)
145
- : this.memoryStorage.get(key) || null;
146
- break;
147
- case 'sessionStorage':
148
- data = typeof sessionStorage !== 'undefined'
149
- ? sessionStorage.getItem(key)
150
- : this.memoryStorage.get(key) || null;
151
- break;
152
- case 'memory':
153
- data = this.memoryStorage.get(key) || null;
154
- break;
155
- }
156
- if (!data) {
157
- return null;
158
- }
159
- const state = JSON.parse(data);
160
- this.currentState = state;
161
- return state;
162
- }
163
- catch (error) {
164
- console.error('[StatePersistenceManager] Failed to load state:', error);
165
- return null;
166
- }
167
- }
168
- /**
169
- * Check if saved state exists
170
- */
171
- async hasSavedState() {
172
- const state = await this.load();
173
- return state !== null;
174
- }
175
- /**
176
- * Clear saved state
177
- */
178
- async clear() {
179
- const key = this.getStorageKey();
180
- try {
181
- switch (this.config.storage) {
182
- case 'localStorage':
183
- if (typeof localStorage !== 'undefined') {
184
- localStorage.removeItem(key);
185
- }
186
- this.memoryStorage.delete(key);
187
- break;
188
- case 'sessionStorage':
189
- if (typeof sessionStorage !== 'undefined') {
190
- sessionStorage.removeItem(key);
191
- }
192
- this.memoryStorage.delete(key);
193
- break;
194
- case 'memory':
195
- this.memoryStorage.delete(key);
196
- break;
197
- }
198
- this.currentState = null;
199
- }
200
- catch (error) {
201
- console.error('[StatePersistenceManager] Failed to clear state:', error);
202
- }
203
- }
204
- /**
205
- * Get current state without saving
206
- */
207
- getCurrentState() {
208
- return this.currentState ? { ...this.currentState } : null;
209
- }
210
- /**
211
- * Get storage key for this session
212
- */
213
- getStorageKey() {
214
- return `qti-assessment-${this.config.assessmentId}-${this.config.sessionId}`;
215
- }
216
- /**
217
- * Force immediate save (bypasses debounce)
218
- */
219
- async forceSave() {
220
- // Clear any pending auto-save
221
- if (this.autoSaveTimer) {
222
- clearTimeout(this.autoSaveTimer);
223
- this.autoSaveTimer = null;
224
- }
225
- await this.save();
226
- }
227
- /**
228
- * Pause auto-save (useful during navigation transitions)
229
- */
230
- pauseAutoSave() {
231
- if (this.autoSaveTimer) {
232
- clearTimeout(this.autoSaveTimer);
233
- this.autoSaveTimer = null;
234
- }
235
- }
236
- /**
237
- * Resume auto-save
238
- */
239
- resumeAutoSave() {
240
- if (this.config.autoSave && this.currentState) {
241
- this.scheduleAutoSave();
242
- }
243
- }
244
- /**
245
- * Get last save timestamp
246
- */
247
- getLastSaveTime() {
248
- return this.currentState?.savedAt || null;
249
- }
250
- /**
251
- * Check if state has been modified since last save
252
- */
253
- isDirty() {
254
- // Simple check - could be enhanced with deep comparison
255
- return this.autoSaveTimer !== null;
256
- }
257
- /**
258
- * Cleanup
259
- */
260
- destroy() {
261
- if (this.autoSaveTimer) {
262
- clearTimeout(this.autoSaveTimer);
263
- this.autoSaveTimer = null;
264
- }
265
- this.currentState = null;
266
- }
267
- }
268
- //# sourceMappingURL=StatePersistenceManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatePersistenceManager.js","sourceRoot":"","sources":["../../src/core/StatePersistenceManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAgDH,MAAM,OAAO,uBAAuB;IAOnC,YAAY,MAAyB;QAL7B,iBAAY,GAA4B,IAAI,CAAC;QAC7C,kBAAa,GAAyC,IAAI,CAAC;QAC3D,aAAQ,GAAG,KAAK,CAAC;QACjB,kBAAa,GAAwB,IAAI,GAAG,EAAE,CAAC;QAGtD,IAAI,CAAC,MAAM,GAAG;YACb,QAAQ,EAAE,IAAI;YACd,aAAa,EAAE,IAAI;YACnB,OAAO,EAAE,cAAc;YACvB,GAAG,MAAM;SACT,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,KAAgC;QAC3C,4BAA4B;QAC5B,IAAI,CAAC,YAAY,GAAG;YACnB,GAAG,IAAI,CAAC,YAAY;YACpB,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;YACtC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;YACnB,GAAG,KAAK;SACY,CAAC;QAEtB,oBAAoB;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAC,gBAAgB,EAAE,C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,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/**\n * StatePersistenceManager\n *\n * Manages automatic state persistence for assessment sessions.\n * Supports both client-side (localStorage) and server-side persistence.\n *\n * Features:\n * - Auto-save on state changes (debounced)\n * - Manual save triggers\n * - State restoration\n * - Optional backend integration\n * - Fallback to localStorage when backend unavailable\n */\n\nexport interface PersistableState {\n\t/** Assessment identifier */\n\tassessmentId: string;\n\t/** Current item index */\n\tcurrentItemIndex: number;\n\t/** Visited item indices */\n\tvisitedItems: number[];\n\t/** Response data per item */\n\tresponses: Record<string, unknown>;\n\t/** Item session states (attempts, submission status) */\n\titemSessionStates: Record<string, {\n\t\tattemptCount: number;\n\t\tisAnswered: boolean;\n\t\tisSubmitted: boolean;\n\t\tlastSubmissionTime?: number;\n\t}>;\n\t/** Time tracking data */\n\ttimeTracking?: {\n\t\tstartedAt: number;\n\t\ttotalElapsed: number;\n\t\titemTimes: Record<string, number>;\n\t\tsectionTimes: Record<string, number>;\n\t};\n\t/** Last saved timestamp */\n\tsavedAt: number;\n}\n\nexport interface PersistenceConfig {\n\t/** Unique session identifier */\n\tsessionId: string;\n\t/** Assessment identifier */\n\tassessmentId: string;\n\t/** Auto-save enabled (default: true) */\n\tautoSave?: boolean;\n\t/** Auto-save debounce delay in ms (default: 2000) */\n\tautoSaveDelay?: number;\n\t/** Storage strategy */\n\tstorage?: 'localStorage' | 'sessionStorage' | 'memory';\n\t/** Optional backend save callback */\n\tonBackendSave?: (state: PersistableState) => Promise<void>;\n\t/** Optional save success callback */\n\tonSaveSuccess?: (state: PersistableState) => void;\n\t/** Optional save error callback */\n\tonSaveError?: (error: Error) => void;\n}\n\nexport class StatePersistenceManager {\n\tprivate config: PersistenceConfig;\n\tprivate currentState: PersistableState | null = null;\n\tprivate autoSaveTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate isSaving = false;\n\tprivate memoryStorage: Map<string, string> = new Map();\n\n\tconstructor(config: PersistenceConfig) {\n\t\tthis.config = {\n\t\t\tautoSave: true,\n\t\t\tautoSaveDelay: 2000,\n\t\t\tstorage: 'localStorage',\n\t\t\t...config,\n\t\t};\n\t}\n\n\t/**\n\t * Update state and trigger auto-save\n\t */\n\tupdateState(state: Partial<PersistableState>): void {\n\t\t// Merge with existing state\n\t\tthis.currentState = {\n\t\t\t...this.currentState,\n\t\t\tassessmentId: this.config.assessmentId,\n\t\t\tsavedAt: Date.now(),\n\t\t\t...state,\n\t\t} as PersistableState;\n\n\t\t// Trigger auto-save\n\t\tif (this.config.autoSave) {\n\t\t\tthis.scheduleAutoSave();\n\t\t}\n\t}\n\n\t/**\n\t * Schedule auto-save with debouncing\n\t */\n\tprivate scheduleAutoSave(): void {\n\t\t// Clear existing timer\n\t\tif (this.autoSaveTimer) {\n\t\t\tclearTimeout(this.autoSaveTimer);\n\t\t}\n\n\t\t// Schedule new save\n\t\tthis.autoSaveTimer = setTimeout(() => {\n\t\t\tthis.save().catch((error) => {\n\t\t\t\tconsole.error('[StatePersistenceManager] Auto-save failed:', error);\n\t\t\t\tthis.config.onSaveError?.(error);\n\t\t\t});\n\t\t}, this.config.autoSaveDelay);\n\t}\n\n\t/**\n\t * Manually save current state\n\t */\n\tasync save(): Promise<void> {\n\t\tif (!this.currentState) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isSaving) {\n\t\t\tconsole.warn('[StatePersistenceManager] Save already in progress');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isSaving = true;\n\n\t\ttry {\n\t\t\t// Update timestamp\n\t\t\tthis.currentState.savedAt = Date.now();\n\n\t\t\t// Try backend save first (if configured)\n\t\t\tif (this.config.onBackendSave) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.config.onBackendSave(this.currentState);\n\t\t\t\t} catch (backendError) {\n\t\t\t\t\tconsole.warn('[StatePersistenceManager] Backend save failed, falling back to local:', backendError);\n\t\t\t\t\t// Continue to local save as fallback\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Save to local storage\n\t\t\tthis.saveToStorage(this.currentState);\n\n\t\t\t// Success callback\n\t\t\tthis.config.onSaveSuccess?.(this.currentState);\n\t\t} catch (error) {\n\t\t\tconsole.error('[StatePersistenceManager] Save failed:', error);\n\t\t\tthis.config.onSaveError?.(error as Error);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis.isSaving = false;\n\t\t}\n\t}\n\n\t/**\n\t * Save to configured storage\n\t */\n\tprivate saveToStorage(state: PersistableState): void {\n\t\tconst key = this.getStorageKey();\n\t\tconst data = JSON.stringify(state);\n\n\t\ttry {\n\t\t\tswitch (this.config.storage) {\n\t\t\t\tcase 'localStorage':\n\t\t\t\t\tif (typeof localStorage !== 'undefined') {\n\t\t\t\t\t\tlocalStorage.setItem(key, data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.memoryStorage.set(key, data);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'sessionStorage':\n\t\t\t\t\tif (typeof sessionStorage !== 'undefined') {\n\t\t\t\t\t\tsessionStorage.setItem(key, data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.memoryStorage.set(key, data);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'memory':\n\t\t\t\t\tthis.memoryStorage.set(key, data);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Storage quota exceeded or other storage error\n\t\t\tconsole.error('[StatePersistenceManager] Storage save failed:', error);\n\t\t\t// Fallback to memory storage\n\t\t\tthis.memoryStorage.set(key, data);\n\t\t}\n\t}\n\n\t/**\n\t * Load state from storage\n\t */\n\tasync load(): Promise<PersistableState | null> {\n\t\tconst key = this.getStorageKey();\n\t\tlet data: string | null = null;\n\n\t\ttry {\n\t\t\tswitch (this.config.storage) {\n\t\t\t\tcase 'localStorage':\n\t\t\t\t\tdata = typeof localStorage !== 'undefined'\n\t\t\t\t\t\t? localStorage.getItem(key)\n\t\t\t\t\t\t: this.memoryStorage.get(key) || null;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'sessionStorage':\n\t\t\t\t\tdata = typeof sessionStorage !== 'undefined'\n\t\t\t\t\t\t? sessionStorage.getItem(key)\n\t\t\t\t\t\t: this.memoryStorage.get(key) || null;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'memory':\n\t\t\t\t\tdata = this.memoryStorage.get(key) || null;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (!data) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst state = JSON.parse(data) as PersistableState;\n\t\t\tthis.currentState = state;\n\t\t\treturn state;\n\t\t} catch (error) {\n\t\t\tconsole.error('[StatePersistenceManager] Failed to load state:', error);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Check if saved state exists\n\t */\n\tasync hasSavedState(): Promise<boolean> {\n\t\tconst state = await this.load();\n\t\treturn state !== null;\n\t}\n\n\t/**\n\t * Clear saved state\n\t */\n\tasync clear(): Promise<void> {\n\t\tconst key = this.getStorageKey();\n\n\t\ttry {\n\t\t\tswitch (this.config.storage) {\n\t\t\t\tcase 'localStorage':\n\t\t\t\t\tif (typeof localStorage !== 'undefined') {\n\t\t\t\t\t\tlocalStorage.removeItem(key);\n\t\t\t\t\t}\n\t\t\t\t\tthis.memoryStorage.delete(key);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'sessionStorage':\n\t\t\t\t\tif (typeof sessionStorage !== 'undefined') {\n\t\t\t\t\t\tsessionStorage.removeItem(key);\n\t\t\t\t\t}\n\t\t\t\t\tthis.memoryStorage.delete(key);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'memory':\n\t\t\t\t\tthis.memoryStorage.delete(key);\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tthis.currentState = null;\n\t\t} catch (error) {\n\t\t\tconsole.error('[StatePersistenceManager] Failed to clear state:', error);\n\t\t}\n\t}\n\n\t/**\n\t * Get current state without saving\n\t */\n\tgetCurrentState(): PersistableState | null {\n\t\treturn this.currentState ? { ...this.currentState } : null;\n\t}\n\n\t/**\n\t * Get storage key for this session\n\t */\n\tprivate getStorageKey(): string {\n\t\treturn `qti-assessment-${this.config.assessmentId}-${this.config.sessionId}`;\n\t}\n\n\t/**\n\t * Force immediate save (bypasses debounce)\n\t */\n\tasync forceSave(): Promise<void> {\n\t\t// Clear any pending auto-save\n\t\tif (this.autoSaveTimer) {\n\t\t\tclearTimeout(this.autoSaveTimer);\n\t\t\tthis.autoSaveTimer = null;\n\t\t}\n\n\t\tawait this.save();\n\t}\n\n\t/**\n\t * Pause auto-save (useful during navigation transitions)\n\t */\n\tpauseAutoSave(): void {\n\t\tif (this.autoSaveTimer) {\n\t\t\tclearTimeout(this.autoSaveTimer);\n\t\t\tthis.autoSaveTimer = null;\n\t\t}\n\t}\n\n\t/**\n\t * Resume auto-save\n\t */\n\tresumeAutoSave(): void {\n\t\tif (this.config.autoSave && this.currentState) {\n\t\t\tthis.scheduleAutoSave();\n\t\t}\n\t}\n\n\t/**\n\t * Get last save timestamp\n\t */\n\tgetLastSaveTime(): number | null {\n\t\treturn this.currentState?.savedAt || null;\n\t}\n\n\t/**\n\t * Check if state has been modified since last save\n\t */\n\tisDirty(): boolean {\n\t\t// Simple check - could be enhanced with deep comparison\n\t\treturn this.autoSaveTimer !== null;\n\t}\n\n\t/**\n\t * Cleanup\n\t */\n\tdestroy(): void {\n\t\tif (this.autoSaveTimer) {\n\t\t\tclearTimeout(this.autoSaveTimer);\n\t\t\tthis.autoSaveTimer = null;\n\t\t}\n\t\tthis.currentState = null;\n\t}\n}\n"]}
@@ -1,114 +0,0 @@
1
- /**
2
- * Assessment Performance Monitor
3
- *
4
- * Tracks assessment-level performance metrics including:
5
- * - Navigation timing
6
- * - Response submission latency
7
- * - Section loading times
8
- * - Overall assessment duration
9
- *
10
- * This extends the base performance monitor from item-player with
11
- * assessment-specific functionality.
12
- */
13
- export { globalPerformanceMonitor, type PerformanceEntry, PerformanceMonitor, type PerformanceMonitorConfig, type PerformanceReport, } from '@pie-qti/item-player';
14
- /**
15
- * Assessment-specific performance metrics
16
- */
17
- export interface AssessmentPerformanceMetrics {
18
- /** Assessment start time */
19
- assessmentStartTime?: number;
20
- /** Assessment end time */
21
- assessmentEndTime?: number;
22
- /** Total assessment duration (ms) */
23
- totalDuration?: number;
24
- /** Number of items completed */
25
- itemsCompleted: number;
26
- /** Average time per item (ms) */
27
- averageItemTime?: number;
28
- /** Navigation events count */
29
- navigationCount: number;
30
- /** Response submissions count */
31
- submissionCount: number;
32
- /** Average submission latency (ms) */
33
- averageSubmissionLatency?: number;
34
- }
35
- /**
36
- * Assessment Performance Tracker
37
- *
38
- * Higher-level wrapper around PerformanceMonitor specifically
39
- * for tracking assessment-level metrics.
40
- *
41
- * Usage:
42
- * ```typescript
43
- * import { AssessmentPerformanceTracker } from './utils/PerformanceMonitor';
44
- *
45
- * const tracker = new AssessmentPerformanceTracker({ enabled: true });
46
- *
47
- * tracker.startAssessment();
48
- * tracker.trackNavigation('next');
49
- * tracker.trackItemStart('item-001');
50
- * tracker.trackItemComplete('item-001');
51
- * tracker.trackSubmission(125); // Latency in ms
52
- * tracker.endAssessment();
53
- *
54
- * const metrics = tracker.getAssessmentMetrics();
55
- * console.log(metrics);
56
- * ```
57
- */
58
- export declare class AssessmentPerformanceTracker {
59
- private assessmentStartTime?;
60
- private assessmentEndTime?;
61
- private itemStartTimes;
62
- private itemDurations;
63
- private navigationCount;
64
- private submissionCount;
65
- private submissionLatencies;
66
- private enabled;
67
- constructor(config?: {
68
- enabled?: boolean;
69
- });
70
- /**
71
- * Enable tracking
72
- */
73
- enable(): void;
74
- /**
75
- * Disable tracking
76
- */
77
- disable(): void;
78
- /**
79
- * Mark assessment start
80
- */
81
- startAssessment(): void;
82
- /**
83
- * Mark assessment end
84
- */
85
- endAssessment(): void;
86
- /**
87
- * Track navigation event
88
- */
89
- trackNavigation(_type: 'next' | 'previous' | 'jump' | 'section'): void;
90
- /**
91
- * Track item start
92
- */
93
- trackItemStart(itemId: string): void;
94
- /**
95
- * Track item completion
96
- */
97
- trackItemComplete(itemId: string): void;
98
- /**
99
- * Track response submission
100
- */
101
- trackSubmission(latencyMs: number): void;
102
- /**
103
- * Get aggregated assessment metrics
104
- */
105
- getAssessmentMetrics(): AssessmentPerformanceMetrics;
106
- /**
107
- * Reset all metrics
108
- */
109
- reset(): void;
110
- /**
111
- * Export metrics to console
112
- */
113
- exportToConsole(): void;
114
- }