@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.
Files changed (35) hide show
  1. package/dist/core/AssessmentPlayer.d.ts +14 -7
  2. package/dist/core/AssessmentPlayer.d.ts.map +1 -1
  3. package/dist/core/AssessmentPlayer.js +33 -34
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/integration/ReferenceBackendAdapter.d.ts +2 -2
  7. package/dist/integration/ReferenceBackendAdapter.d.ts.map +1 -1
  8. package/dist/integration/ReferenceBackendAdapter.js +5 -5
  9. package/dist/integration/api-contract.d.ts +16 -16
  10. package/dist/integration/api-contract.d.ts.map +1 -1
  11. package/dist/integration/index.d.ts +1 -1
  12. package/dist/integration/index.d.ts.map +1 -1
  13. package/dist/types/index.d.ts +1 -1
  14. package/dist/types/index.d.ts.map +1 -1
  15. package/package.json +100 -80
  16. package/src/components/AssessmentShell.svelte +8 -8
  17. package/src/components/ItemRenderer.svelte +8 -8
  18. package/src/components/NavigationBar.svelte +3 -1
  19. package/src/components/RubricDisplay.svelte +2 -2
  20. package/src/core/AssessmentPlayer.ts +51 -44
  21. package/src/index.ts +1 -1
  22. package/src/integration/ReferenceBackendAdapter.ts +13 -13
  23. package/src/integration/api-contract.ts +16 -16
  24. package/src/integration/index.ts +5 -5
  25. package/src/types/index.ts +1 -1
  26. package/.turbo/turbo-build.log +0 -1
  27. package/BACKEND-INTEGRATION.md +0 -620
  28. package/CHANGELOG.md +0 -11
  29. package/EXTENSIBILITY.md +0 -551
  30. package/svelte.config.js +0 -8
  31. package/tests/ReferenceBackendAdapter.spec.ts +0 -309
  32. package/tests/setup.ts +0 -103
  33. package/tests/smoke.test.ts +0 -7
  34. package/tsconfig.json +0 -20
  35. package/tsconfig.svelte.json +0 -10
package/EXTENSIBILITY.md DELETED
@@ -1,551 +0,0 @@
1
- # Assessment Player Extensibility Analysis
2
-
3
- This document evaluates the current extensibility mechanisms and proposes potential enhancements for the QTI 2.2 Assessment Player.
4
-
5
- ## Current Extensibility Points
6
-
7
- ### 1. **Interaction Rendering (Item Player Level)** ✅ IMPLEMENTED
8
-
9
- **Mechanism**: Item-player plugins + registries (`QTIPlugin`, `ComponentRegistry`, `ExtractionRegistry`)
10
-
11
- **What can be extended**:
12
- - Custom renderers for any QTI interaction type
13
- - Override default rendering behavior
14
- - Add support for custom interactions
15
-
16
- **Example**: Provide a `QTIPlugin` to the underlying item player to register custom extractors and/or custom web components.
17
-
18
- **Strengths**:
19
- - Simple, proven pattern (Map-based lookup)
20
- - No over-engineering
21
- - Well-documented in PLUGGABILITY.md
22
- - Works seamlessly across item and assessment players
23
-
24
- ### 2. **Event Listeners (Assessment Player Level)** ✅ IMPLEMENTED
25
-
26
- **Mechanism**: Event listener pattern with unsubscribe functions
27
-
28
- **Available Events**:
29
- - `onItemChange(index, total)` - Item navigation
30
- - `onSectionChange(index, total)` - Section navigation
31
- - `onResponseChange(responses)` - Response updates
32
- - `onComplete()` - Assessment completion
33
- - `onTimeWarning(remainingSeconds)` - Time warning threshold
34
- - `onTimeExpired()` - Time limit reached
35
- - `onTimeTick(remaining, elapsed)` - Timer updates (every second)
36
- - `onStateSaved(timestamp)` - State persistence
37
- - `onStateRestored(timestamp)` - State restoration
38
-
39
- **Example**:
40
- ```typescript
41
- const player = new AssessmentPlayer({ assessment });
42
-
43
- // Subscribe to events
44
- const unsubscribe = player.onItemChange((index, total) => {
45
- console.log(`Navigated to item ${index + 1} of ${total}`);
46
- });
47
-
48
- // Unsubscribe when done
49
- unsubscribe();
50
- ```
51
-
52
- **Strengths**:
53
- - Clean unsubscribe pattern
54
- - Multiple listeners per event
55
- - No memory leaks
56
-
57
- ### 3. **Configuration Callbacks** ✅ IMPLEMENTED
58
-
59
- **Mechanism**: Optional callback functions in `AssessmentPlayerConfig`
60
-
61
- **Available Callbacks**:
62
- - `onItemChange(index, total)` - Single callback (simpler than listener)
63
- - `onSectionChange(index, total)`
64
- - `onResponseChange(responses)`
65
- - `onComplete()`
66
- - `onStateSaved(timestamp)`
67
- - `onStateRestored(timestamp)`
68
-
69
- **Note**: Config callbacks are simpler for single handlers, event listeners better for multiple subscribers.
70
-
71
- ### 4. **State Persistence Backend** ✅ IMPLEMENTED
72
-
73
- **Mechanism**: `onBackendSave` callback in `PersistenceConfig`
74
-
75
- **Example**:
76
- ```typescript
77
- const persistenceManager = new StatePersistenceManager({
78
- sessionId: 'session-123',
79
- assessmentId: 'assessment-456',
80
- onBackendSave: async (state: PersistableState) => {
81
- await fetch('/api/save', {
82
- method: 'POST',
83
- body: JSON.stringify(state)
84
- });
85
- },
86
- onSaveSuccess: (state) => console.log('Saved'),
87
- onSaveError: (error) => console.error('Save failed', error)
88
- });
89
- ```
90
-
91
- **Strengths**:
92
- - Optional (client-side by default)
93
- - Graceful fallback to localStorage
94
- - Clear separation of concerns
95
-
96
- ### 5. **Extended Text Editor** ✅ IMPLEMENTED
97
-
98
- **Mechanism**: `extendedTextEditor` config option
99
-
100
- **Options**:
101
- - `'tiptap'` - Rich text with math support
102
- - `'textarea'` - Lightweight plain text
103
-
104
- **Extensibility**: Could be enhanced to accept custom editor factory.
105
-
106
- ---
107
-
108
- ## Potential Extensibility Gaps & Proposals
109
-
110
- ### Gap 1: **Custom Navigation Logic** ⚠️ LIMITED
111
-
112
- **Current State**: Navigation controlled by `NavigationManager` (linear/nonlinear modes only)
113
-
114
- **Use Cases That Can't Be Addressed**:
115
- - Adaptive assessments (branch based on performance)
116
- - Prerequisite items (must complete A before accessing B)
117
- - Content-based branching (different paths based on responses)
118
- - Custom navigation rules
119
-
120
- **Proposal**: Navigation hooks or strategy pattern
121
-
122
- ```typescript
123
- interface NavigationStrategy {
124
- canNavigateTo(fromIndex: number, toIndex: number, context: NavigationContext): boolean;
125
- getNextIndex(currentIndex: number, context: NavigationContext): number | null;
126
- getPreviousIndex(currentIndex: number, context: NavigationContext): number | null;
127
- getAvailableItems(currentIndex: number, context: NavigationContext): number[];
128
- }
129
-
130
- interface NavigationContext {
131
- responses: Record<string, unknown>;
132
- itemResults: Map<string, ItemResult>;
133
- visitedItems: number[];
134
- assessment: QtiAssessmentTest;
135
- }
136
-
137
- // Usage
138
- const player = new AssessmentPlayer({
139
- assessment,
140
- navigationStrategy: new AdaptiveNavigationStrategy({
141
- branchingRules: [
142
- { ifScore: '>= 80%', then: 'skip-remedial-items' },
143
- { ifScore: '< 50%', then: 'require-tutorial' }
144
- ]
145
- })
146
- });
147
- ```
148
-
149
- **Priority**: Medium (branching is Priority 7 in approved list)
150
-
151
- ### Gap 2: **Scoring Plugins** ⚠️ LIMITED
152
-
153
- **Current State**: Basic scoring via `calculateItemScore()` and `calculateMaxScore()` methods
154
-
155
- **Use Cases That Can't Be Addressed**:
156
- - Custom scoring algorithms
157
- - Partial credit strategies
158
- - IRT-based scoring
159
- - Complex rubric scoring
160
- - Portfolio scoring across items
161
-
162
- **Proposal**: Scoring strategy interface
163
-
164
- ```typescript
165
- interface ScoringStrategy {
166
- scoreItem(responses: InteractionResponse, correctResponses: any, itemXml: string): ItemScore;
167
- scoreAssessment(itemResults: ItemResult[], assessment: QtiAssessmentTest): AssessmentScore;
168
- calculatePartialCredit?(responses: any, expected: any): number;
169
- }
170
-
171
- interface ItemScore {
172
- score: number;
173
- maxScore: number;
174
- feedback?: string;
175
- details?: any;
176
- }
177
-
178
- // Usage
179
- const player = new AssessmentPlayer({
180
- assessment,
181
- scoringStrategy: new IRT_ScoringStrategy({
182
- model: '3PL',
183
- calibration: itemCalibrationData
184
- })
185
- });
186
- ```
187
-
188
- **Priority**: Medium-High (detailed scoring is Priority 5)
189
-
190
- ### Gap 3: **Feedback Rendering** ⚠️ LIMITED
191
-
192
- **Current State**: Basic feedback display in item player, assessment-level feedback not implemented
193
-
194
- **Use Cases That Can't Be Addressed**:
195
- - Custom feedback templates
196
- - Conditional feedback based on performance
197
- - Rich media feedback (video, interactive)
198
- - Personalized feedback messages
199
- - Feedback localization
200
-
201
- **Proposal**: Feedback renderer interface
202
-
203
- ```typescript
204
- interface FeedbackRenderer {
205
- renderItemFeedback(result: ItemResult, container: HTMLElement): void;
206
- renderAssessmentFeedback(results: AssessmentResults, container: HTMLElement): void;
207
- renderConditionalFeedback(condition: string, content: string, container: HTMLElement): void;
208
- }
209
-
210
- // Usage
211
- const player = new AssessmentPlayer({
212
- assessment,
213
- feedbackRenderer: new CustomFeedbackRenderer({
214
- template: 'detailed',
215
- includeCorrectAnswers: true,
216
- showExplanations: true
217
- })
218
- });
219
- ```
220
-
221
- **Priority**: Medium (assessment feedback is Priority 6)
222
-
223
- ### Gap 4: **Selection & Ordering Rules** ❌ NOT IMPLEMENTED
224
-
225
- **Current State**: Not implemented (static item lists only)
226
-
227
- **Use Cases That Can't Be Addressed**:
228
- - Random item pools
229
- - Item bank sampling
230
- - Shuffle items/sections
231
- - Fixed vs. random positioning
232
- - Stratified sampling
233
-
234
- **Proposal**: Implementation of QTI selection/ordering rules
235
-
236
- ```typescript
237
- // This should be implemented per QTI 2.2 spec, not as a plugin
238
- interface SelectionRule {
239
- select: number;
240
- withReplacement?: boolean;
241
- fromBank?: string;
242
- }
243
-
244
- interface OrderingRule {
245
- shuffle?: boolean;
246
- fixed?: string[]; // Item IDs that should not be shuffled
247
- }
248
-
249
- // Already defined in types, needs implementation in SectionManager
250
- ```
251
-
252
- **Priority**: High (Priority 4 in approved list)
253
-
254
- ### Gap 5: **Time Management Hooks** ✅ MOSTLY COVERED
255
-
256
- **Current State**: Callbacks for warnings, expiration, ticks
257
-
258
- **Potential Enhancement**: Pause/resume hooks
259
-
260
- ```typescript
261
- interface TimeManagementHooks {
262
- onPause?: () => void;
263
- onResume?: () => void;
264
- onTimeAdjustment?: (adjustment: number) => void; // For accommodations
265
- }
266
- ```
267
-
268
- **Priority**: Low (current implementation is sufficient)
269
-
270
- ### Gap 6: **Custom Item Loading** ⚠️ LIMITED
271
-
272
- **Current State**: Items loaded via `itemXml` property in `QuestionRef`
273
-
274
- **Use Cases That Can't Be Addressed**:
275
- - Lazy loading from server
276
- - Item encryption/decryption
277
- - Dynamic item generation
278
- - Item caching strategies
279
-
280
- **Proposal**: Item loader interface
281
-
282
- ```typescript
283
- interface ItemLoader {
284
- loadItem(itemRef: QuestionRef): Promise<string>; // Returns itemXml
285
- preloadItems?(itemRefs: QuestionRef[]): Promise<void>;
286
- cacheStrategy?: 'eager' | 'lazy' | 'on-demand';
287
- }
288
-
289
- // Usage
290
- const player = new AssessmentPlayer({
291
- assessment,
292
- itemLoader: new RemoteItemLoader({
293
- baseUrl: '/api/items',
294
- cache: true,
295
- decrypt: true
296
- })
297
- });
298
- ```
299
-
300
- **Priority**: Low (current approach works, optimization not critical)
301
-
302
- ### Gap 7: **Validation Hooks** ⚠️ LIMITED
303
-
304
- **Current State**: Basic validation in `ItemSessionController.validateItem()`
305
-
306
- **Use Cases That Can't Be Addressed**:
307
- - Custom validation rules per interaction
308
- - Cross-item validation
309
- - Business logic validation
310
- - Custom error messages
311
-
312
- **Proposal**: Validation strategy interface
313
-
314
- ```typescript
315
- interface ValidationStrategy {
316
- validateResponse(responseId: string, value: unknown, context: ValidationContext): ValidationResult;
317
- validateItem(responses: InteractionResponse, context: ValidationContext): ValidationResult;
318
- validateBeforeNavigation?(fromIndex: number, toIndex: number): ValidationResult;
319
- }
320
-
321
- interface ValidationResult {
322
- isValid: boolean;
323
- errors?: string[];
324
- warnings?: string[];
325
- }
326
-
327
- // Usage
328
- const player = new AssessmentPlayer({
329
- assessment,
330
- validationStrategy: new CustomValidationStrategy({
331
- rules: {
332
- 'RESPONSE_1': [required(), minLength(10), noHTML()],
333
- 'RESPONSE_2': [required(), isNumber(), range(0, 100)]
334
- }
335
- })
336
- });
337
- ```
338
-
339
- **Priority**: Low-Medium (current validation works for standard cases)
340
-
341
- ### Gap 8: **UI Component Customization** ⚠️ LIMITED
342
-
343
- **Current State**: Svelte components can be imported and used, but no composition/override mechanism
344
-
345
- **Use Cases That Can't Be Addressed**:
346
- - Custom progress indicator
347
- - Custom navigation bar
348
- - Custom section menu
349
- - Custom timer display
350
- - Custom rubric display
351
-
352
- **Proposal**: Component slot system (Svelte-specific)
353
-
354
- ```svelte
355
- <AssessmentShell {assessment} {config}>
356
- <!-- Custom navigation -->
357
- <svelte:fragment slot="navigation">
358
- <MyCustomNavigationBar {navState} />
359
- </svelte:fragment>
360
-
361
- <!-- Custom timer -->
362
- <svelte:fragment slot="timer">
363
- <MyCustomTimer remaining={remainingTime} />
364
- </svelte:fragment>
365
-
366
- <!-- Custom progress -->
367
- <svelte:fragment slot="progress">
368
- <MyCustomProgressBar current={currentIndex} total={totalItems} />
369
- </svelte:fragment>
370
- </AssessmentShell>
371
- ```
372
-
373
- **Alternative**: Export components separately (already done)
374
-
375
- ```svelte
376
- <script>
377
- import { ItemRenderer, RubricDisplay } from '@pie-framework/assessment-player/components';
378
- // Build custom layout
379
- </script>
380
-
381
- <div class="my-layout">
382
- <RubricDisplay {blocks} />
383
- <ItemRenderer {player} />
384
- <MyCustomNavigation />
385
- </div>
386
- ```
387
-
388
- **Priority**: Low (current approach allows full customization, just requires manual composition)
389
-
390
- ### Gap 9: **Accessibility Hooks** ⚠️ LIMITED
391
-
392
- **Current State**: Basic accessibility in components, no hooks for customization
393
-
394
- **Use Cases That Can't Be Addressed**:
395
- - Screen reader announcements
396
- - Keyboard navigation customization
397
- - Focus management
398
- - Alternative input methods
399
- - Assistive technology integration
400
-
401
- **Proposal**: Accessibility adapter interface
402
-
403
- ```typescript
404
- interface AccessibilityAdapter {
405
- announceNavigation(fromIndex: number, toIndex: number): void;
406
- announceTimeWarning(remainingSeconds: number): void;
407
- announceValidationError(error: string): void;
408
- configureFocusManagement?(): FocusConfig;
409
- configureKeyboardNav?(): KeyboardConfig;
410
- }
411
-
412
- // Usage
413
- const player = new AssessmentPlayer({
414
- assessment,
415
- accessibilityAdapter: new ScreenReaderAdapter({
416
- verbosity: 'detailed',
417
- announceAll: true
418
- })
419
- });
420
- ```
421
-
422
- **Priority**: Medium (important for compliance, but can be added incrementally)
423
-
424
- ### Gap 10: **Analytics & Telemetry** ❌ NOT IMPLEMENTED
425
-
426
- **Current State**: No built-in analytics
427
-
428
- **Use Cases That Can't Be Addressed**:
429
- - Response time tracking
430
- - Interaction patterns
431
- - Performance metrics
432
- - Engagement analytics
433
- - Completion funnels
434
-
435
- **Proposal**: Analytics adapter interface
436
-
437
- ```typescript
438
- interface AnalyticsAdapter {
439
- trackItemView(itemIndex: number, itemIdentifier: string): void;
440
- trackResponseChange(responseId: string, value: unknown, timeSpent: number): void;
441
- trackItemSubmit(result: ItemResult, attempts: number): void;
442
- trackNavigationEvent(from: number, to: number, direction: 'next' | 'previous' | 'jump'): void;
443
- trackTimeEvent(event: 'warning' | 'expired' | 'pause' | 'resume'): void;
444
- trackStateEvent(event: 'saved' | 'restored' | 'cleared'): void;
445
- }
446
-
447
- // Usage
448
- const player = new AssessmentPlayer({
449
- assessment,
450
- analyticsAdapter: new GoogleAnalyticsAdapter({
451
- trackingId: 'UA-XXXXX-Y',
452
- userId: 'candidate-123'
453
- })
454
- });
455
- ```
456
-
457
- **Priority**: Low-Medium (useful but not critical, can be implemented via existing event listeners)
458
-
459
- ---
460
-
461
- ## Summary & Recommendations
462
-
463
- ### ✅ Well-Covered Extensibility Areas
464
-
465
- 1. **Interaction Rendering** - Excellent via item-player plugins + registries
466
- 2. **Event Listening** - Comprehensive event system
467
- 3. **State Persistence** - Clean backend integration
468
- 4. **Time Management** - Good callback coverage
469
-
470
- ### ⚠️ Areas Needing Enhancement
471
-
472
- 1. **Navigation Logic** (for branching) - Priority: Medium
473
- 2. **Scoring Strategies** - Priority: Medium-High
474
- 3. **Feedback Rendering** - Priority: Medium
475
- 4. **Validation Strategies** - Priority: Low-Medium
476
- 5. **Accessibility** - Priority: Medium
477
-
478
- ### ❌ Missing Features (Not Extensibility Issues)
479
-
480
- 1. **Selection & Ordering Rules** - Priority: HIGH (implement per QTI spec)
481
- 2. **Assessment-level Feedback** - Priority: Medium (implement per QTI spec)
482
-
483
- ### Recommended Approach
484
-
485
- **Phase 1: Complete QTI 2.2 Core Features** (Current Priority)
486
- - Implement selection & ordering rules (Priority 4)
487
- - Implement detailed scoring (Priority 5)
488
- - Implement assessment feedback (Priority 6)
489
- - Consider branching (Priority 7)
490
-
491
- **Phase 2: Add Strategic Extension Points** (Future)
492
- - Scoring strategy interface (if detailed scoring reveals need)
493
- - Navigation strategy interface (if branching reveals need)
494
- - Feedback renderer interface (if assessment feedback reveals need)
495
-
496
- **Phase 3: Add Nice-to-Have Extensions** (Future)
497
- - Validation strategy interface
498
- - Accessibility adapter interface
499
- - Analytics adapter interface
500
- - Item loader interface
501
-
502
- ### Design Philosophy
503
-
504
- The current extensibility approach is **excellent** and follows best practices:
505
-
506
- 1. ✅ **Simple registries** - Not over-engineered plugin systems
507
- 2. ✅ **Event listeners** - Standard observer pattern
508
- 3. ✅ **Optional callbacks** - Clean integration points
509
- 4. ✅ **Component exports** - Svelte composition
510
- 5. ✅ **Sensible defaults** - Works out of the box
511
-
512
- **Recommendation**: Don't add extension points until there's a proven need. The current approach allows most customizations through:
513
- - Event listeners (for observing behavior)
514
- - Item player plugins/registries (for custom extraction/rendering)
515
- - Component composition (for custom UI)
516
- - Callbacks (for backend integration)
517
-
518
- This is **sufficient for 95% of use cases**.
519
-
520
- ### Anti-Patterns to Avoid
521
-
522
- ❌ **Don't create**:
523
- - Abstract factory patterns
524
- - Plugin lifecycle systems
525
- - Event buses
526
- - Middleware chains
527
- - Dependency injection containers
528
- - Over-abstracted interfaces
529
-
530
- ✅ **Keep it simple**:
531
- - Map-based registries
532
- - Direct function callbacks
533
- - Event listener pattern
534
- - Component composition
535
- - Optional strategies
536
-
537
- ---
538
-
539
- ## Conclusion
540
-
541
- The current extensibility mechanisms are **well-designed and sufficient** for most use cases. Before adding new extension points:
542
-
543
- 1. **Complete the core QTI 2.2 features** (Priorities 4-7)
544
- 2. **Evaluate real-world usage** - Do users actually need these extensions?
545
- 3. **Start with examples** - Show how to achieve goals with current APIs
546
- 4. **Add extension points incrementally** - Only when proven necessary
547
-
548
- The priority should be:
549
- 1. ✅ **Core QTI functionality** (selection, ordering, feedback)
550
- 2. ⏸️ **Strategic extensions** (only if needed after core complete)
551
- 3. ⏸️ **Nice-to-have extensions** (only if requested by users)
package/svelte.config.js DELETED
@@ -1,8 +0,0 @@
1
- /** @type {import('@sveltejs/kit').Config} */
2
- const config = {
3
- compilerOptions: {
4
- runes: true
5
- }
6
- };
7
-
8
- export default config;