@pie-qti/assessment-player 0.1.4 → 0.1.5
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/README.md +19 -16
- package/dist/core/AssessmentPlayer.d.ts +16 -1
- package/dist/core/AssessmentPlayer.d.ts.map +1 -1
- package/dist/core/AssessmentPlayer.js +103 -8
- package/dist/core/TimeManager.d.ts +9 -0
- package/dist/core/TimeManager.d.ts.map +1 -1
- package/dist/core/TimeManager.js +16 -3
- package/dist/integration/ReferenceBackendAdapter.d.ts +27 -1
- package/dist/integration/ReferenceBackendAdapter.d.ts.map +1 -1
- package/dist/integration/ReferenceBackendAdapter.js +380 -10
- package/dist/integration/api-contract.d.ts +73 -2
- package/dist/integration/api-contract.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/components/index.ts +1 -1
- package/src/core/AssessmentPlayer.ts +115 -9
- package/src/core/TimeManager.ts +20 -3
- package/src/integration/ReferenceBackendAdapter.ts +441 -10
- package/src/integration/api-contract.ts +74 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @pie-qti/assessment-player
|
|
2
2
|
|
|
3
|
-
QTI 2.
|
|
3
|
+
QTI Assessment Player (QTI 2.2/3.0 compatible item delivery) - Multi-item test player with navigation, sections, and rubric blocks.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -10,13 +10,13 @@ QTI 2.x Assessment Player - Multi-item test player with navigation, sections, an
|
|
|
10
10
|
- ✅ **Rubric blocks** - Reading passages, instructions, and rubrics
|
|
11
11
|
- ✅ **Progress tracking** - Visual progress indicators
|
|
12
12
|
- ✅ **Section menu** - Quick navigation between sections
|
|
13
|
-
- ✅ **Outcome Processing** - QTI
|
|
13
|
+
- ✅ **Outcome Processing** - QTI-aligned scoring with total/weighted/percentage/pass-fail templates
|
|
14
14
|
- ✅ **Test Feedback** - Conditional feedback based on outcome variables
|
|
15
15
|
- ✅ **Time Limits** - Assessment-level countdown timers with warnings and auto-submission
|
|
16
16
|
- ✅ **Item Session Control** - Max attempts, review/skip controls, response validation
|
|
17
17
|
- ✅ **State Persistence** - Auto-save with resume capability and optional backend integration
|
|
18
|
-
- ✅ **Selection & Ordering** - Random item selection and shuffling per QTI
|
|
19
|
-
- ✅ **QTI
|
|
18
|
+
- ✅ **Selection & Ordering** - Random item selection and shuffling per QTI spec
|
|
19
|
+
- ✅ **QTI Role/View Actors** - candidate, scorer, tutor, author, proctor, testConstructor
|
|
20
20
|
- ✅ **Backend Integration** - Optional secure backend API (client-side by default)
|
|
21
21
|
- ✅ **Svelte 5 components** - Modern reactive UI
|
|
22
22
|
- ✅ **TypeScript** - Full type safety
|
|
@@ -112,7 +112,7 @@ console.log('Total score:', results.totalScore, '/', results.maxScore);
|
|
|
112
112
|
|
|
113
113
|
## Assessment Format
|
|
114
114
|
|
|
115
|
-
The player uses a QTI
|
|
115
|
+
The player uses a QTI-aligned JSON format:
|
|
116
116
|
|
|
117
117
|
```typescript
|
|
118
118
|
interface QtiAssessmentTest {
|
|
@@ -156,11 +156,14 @@ interface RubricBlock {
|
|
|
156
156
|
**By default**, the player runs 100% client-side with no backend required. This is perfect for demos, development, and non-critical assessments.
|
|
157
157
|
|
|
158
158
|
**For production**, integrate with a secure backend for:
|
|
159
|
+
|
|
159
160
|
- Server-side scoring (prevent score manipulation)
|
|
160
161
|
- Role-based data filtering (hide correct answers from candidates)
|
|
161
162
|
- Persistent session storage
|
|
162
163
|
- Authentication and authorization
|
|
163
164
|
|
|
165
|
+
The player can be embedded inside an LTI 1.3 / LTI Advantage tool, but LTI launch validation, Deep Linking, AGS grade passback, and NRPS roster lookup are host-application responsibilities. Use the `BackendAdapter` boundary to connect player sessions and submissions to the host tool's LTI-aware backend.
|
|
166
|
+
|
|
164
167
|
### Quick Start
|
|
165
168
|
|
|
166
169
|
```typescript
|
|
@@ -208,18 +211,18 @@ class MyBackendAdapter implements BackendAdapter {
|
|
|
208
211
|
|
|
209
212
|
**See [BACKEND-INTEGRATION.md](./BACKEND-INTEGRATION.md) for complete implementation guide.**
|
|
210
213
|
|
|
211
|
-
## QTI
|
|
214
|
+
## QTI Role/View Actors
|
|
212
215
|
|
|
213
|
-
|
|
216
|
+
QTI roles are audience markers for `view`-controlled content. This player applies the runtime policy below:
|
|
214
217
|
|
|
215
218
|
| Role | Behavior |
|
|
216
219
|
|------|----------|
|
|
217
220
|
| `candidate` | Test-taker - inputs editable, no correct answers shown |
|
|
218
|
-
| `scorer` | Grader - inputs readonly, correct answers shown |
|
|
219
|
-
| `author` | Content
|
|
220
|
-
| `tutor` | Instructional
|
|
221
|
-
| `proctor` | Test
|
|
222
|
-
| `testConstructor` | Test
|
|
221
|
+
| `scorer` | Grader/reviewer - inputs readonly, correct answers shown |
|
|
222
|
+
| `author` | Content authoring review - inputs readonly, correct answers shown |
|
|
223
|
+
| `tutor` | Instructional review - inputs readonly, correct answers shown |
|
|
224
|
+
| `proctor` | Test administration view - inputs readonly, no correct answers shown |
|
|
225
|
+
| `testConstructor` | Test construction review - inputs readonly, correct answers shown |
|
|
223
226
|
|
|
224
227
|
```typescript
|
|
225
228
|
// For test-takers
|
|
@@ -231,7 +234,7 @@ The player implements QTI 2.x standard roles to control behavior:
|
|
|
231
234
|
|
|
232
235
|
## Time Limits
|
|
233
236
|
|
|
234
|
-
QTI
|
|
237
|
+
QTI supports time limits at assessment, test part, section, and item levels. The player provides:
|
|
235
238
|
|
|
236
239
|
- **Countdown timer** - Displays remaining time to candidates
|
|
237
240
|
- **Warning threshold** - Alert before time expires (default: 60 seconds)
|
|
@@ -502,7 +505,7 @@ interface PersistableState {
|
|
|
502
505
|
|
|
503
506
|
## Selection & Ordering
|
|
504
507
|
|
|
505
|
-
The assessment player supports QTI
|
|
508
|
+
The assessment player supports QTI selection and ordering rules for creating randomized assessments and item pools.
|
|
506
509
|
|
|
507
510
|
### Selection Rules
|
|
508
511
|
|
|
@@ -699,7 +702,7 @@ ordering: { shuffle: true }
|
|
|
699
702
|
|
|
700
703
|
## Outcome Processing & Scoring
|
|
701
704
|
|
|
702
|
-
The assessment player implements QTI
|
|
705
|
+
The assessment player implements QTI outcome processing patterns for aggregating item scores into assessment-level outcomes.
|
|
703
706
|
|
|
704
707
|
### Scoring Templates
|
|
705
708
|
|
|
@@ -1051,7 +1054,7 @@ Renders individual QTI items within the assessment.
|
|
|
1051
1054
|
|
|
1052
1055
|
**Props:**
|
|
1053
1056
|
- `questionRef: QuestionRef` - Question reference with item XML
|
|
1054
|
-
- `role?: QTIRole` - QTI
|
|
1057
|
+
- `role?: QTIRole` - QTI role/view actor (default: 'candidate')
|
|
1055
1058
|
- `extendedTextEditor?: 'tiptap' | 'textarea'` - Editor type for extended text
|
|
1056
1059
|
- `responses?: Record<string, unknown>` - Response data
|
|
1057
1060
|
- `onResponseChange?: (responseId: string, value: unknown) => void` - Response handler
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* - Submit responses to BackendAdapter
|
|
8
8
|
* - Apply backend navigation decisions + session state
|
|
9
9
|
*/
|
|
10
|
-
import type { QTIRole } from '@pie-qti/item-player';
|
|
10
|
+
import type { QTIRole, PnpProfile } from '@pie-qti/item-player';
|
|
11
11
|
import type { AssessmentRubricBlock, AssessmentSessionState, BackendAdapter, InitSessionRequest } from '../integration/api-contract.js';
|
|
12
12
|
import type { AssessmentResults, ItemResult, NavigationState } from '../types/index.js';
|
|
13
13
|
export interface BackendAssessmentPlayerConfig {
|
|
14
14
|
backend: BackendAdapter;
|
|
15
15
|
initSession: InitSessionRequest;
|
|
16
16
|
role?: QTIRole;
|
|
17
|
+
/** Optional RNG for deterministic shuffling in selection/ordering. Defaults to Math.random. */
|
|
18
|
+
rng?: () => number;
|
|
17
19
|
/**
|
|
18
20
|
* Optional hint for item renderers that support multiple extended text editors.
|
|
19
21
|
* (Plumbed through the shell; the item player remains authoritative for behavior.)
|
|
@@ -33,6 +35,13 @@ export interface BackendAssessmentPlayerConfig {
|
|
|
33
35
|
allowSectionNavigation?: boolean;
|
|
34
36
|
showProgress?: boolean;
|
|
35
37
|
timeWarningThreshold?: number;
|
|
38
|
+
/**
|
|
39
|
+
* QTI 3.0 §6.2 Personal Needs and Preferences profile.
|
|
40
|
+
* Extended time (pnp.content.extendedTime) is applied to assessment timeLimits.
|
|
41
|
+
* The full profile is passed down to each item player for component-level features
|
|
42
|
+
* (color scheme, elimination tool).
|
|
43
|
+
*/
|
|
44
|
+
pnp?: PnpProfile;
|
|
36
45
|
onItemChange?: (itemIndex: number, totalItems: number) => void;
|
|
37
46
|
onSectionChange?: (sectionIndex: number, totalSections: number) => void;
|
|
38
47
|
onResponseChange?: (responses: Record<string, unknown>) => void;
|
|
@@ -69,6 +78,12 @@ export declare class AssessmentPlayer {
|
|
|
69
78
|
private timeExpiredListeners;
|
|
70
79
|
private timeTickListeners;
|
|
71
80
|
private constructor();
|
|
81
|
+
/**
|
|
82
|
+
* Compute effective itemSessionControl for a given item using three-level fallback:
|
|
83
|
+
* section-level (highest priority) → testPart-level → defaults.
|
|
84
|
+
* Section-level values override testPart-level when present.
|
|
85
|
+
*/
|
|
86
|
+
private getEffectiveItemSessionControl;
|
|
72
87
|
private hasAnyResponse;
|
|
73
88
|
private flattenItems;
|
|
74
89
|
getAllSections(): Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssessmentPlayer.d.ts","sourceRoot":"","sources":["../../src/core/AssessmentPlayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"AssessmentPlayer.d.ts","sourceRoot":"","sources":["../../src/core/AssessmentPlayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,KAAK,EACX,qBAAqB,EACrB,sBAAsB,EAEtB,cAAc,EAEd,kBAAkB,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AAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAK1E,eAAe,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAK7E,gBAAgB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAKpF,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAK5C,aAAa,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAKvE,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAK/C,UAAU,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAK5F,OAAO,IAAI,IAAI;IAetB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,cAAc;IAItB;;;OAGG;IACI,eAAe,IAAI,GAAG;IAI7B;;OAEG;IACH,OAAO,CAAC,yBAAyB;CAUjC"}
|
|
@@ -50,6 +50,7 @@ export class AssessmentPlayer {
|
|
|
50
50
|
const navigationMode = this.assessment.navigationMode || 'nonlinear';
|
|
51
51
|
this.navigationManager = new NavigationManager(navigationMode, this.items.length);
|
|
52
52
|
// Item session control is a UI hint; backend remains authoritative.
|
|
53
|
+
// Start with testPart-level defaults; section-level overrides are applied per item in navigateTo().
|
|
53
54
|
const itemSessionControl = this.assessment.testParts?.[0]?.itemSessionControl;
|
|
54
55
|
this.sessionController = new ItemSessionController(itemSessionControl);
|
|
55
56
|
// Initialize per-item session state so itemSessionControl checks work immediately.
|
|
@@ -61,6 +62,7 @@ export class AssessmentPlayer {
|
|
|
61
62
|
this.timeManager = new TimeManager({
|
|
62
63
|
assessmentTimeLimits: this.assessment.timeLimits,
|
|
63
64
|
warningThreshold: config.timeWarningThreshold || 60,
|
|
65
|
+
extendedTime: config.pnp?.content?.extendedTime,
|
|
64
66
|
onWarning: (remainingSeconds) => this.notifyTimeWarning(remainingSeconds),
|
|
65
67
|
onExpired: () => this.notifyTimeExpired(),
|
|
66
68
|
onTick: (remainingSeconds, elapsedSeconds) => this.notifyTimeTick(remainingSeconds, elapsedSeconds),
|
|
@@ -73,6 +75,28 @@ export class AssessmentPlayer {
|
|
|
73
75
|
this.navigateTo(idx).catch(() => { });
|
|
74
76
|
}
|
|
75
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Compute effective itemSessionControl for a given item using three-level fallback:
|
|
80
|
+
* section-level (highest priority) → testPart-level → defaults.
|
|
81
|
+
* Section-level values override testPart-level when present.
|
|
82
|
+
*/
|
|
83
|
+
getEffectiveItemSessionControl(flat) {
|
|
84
|
+
const testPartControl = flat.testPart.itemSessionControl;
|
|
85
|
+
const sectionControl = flat.section.itemSessionControl;
|
|
86
|
+
if (!sectionControl)
|
|
87
|
+
return testPartControl;
|
|
88
|
+
if (!testPartControl)
|
|
89
|
+
return sectionControl;
|
|
90
|
+
return {
|
|
91
|
+
maxAttempts: sectionControl.maxAttempts ?? testPartControl.maxAttempts,
|
|
92
|
+
showFeedback: sectionControl.showFeedback ?? testPartControl.showFeedback,
|
|
93
|
+
allowReview: sectionControl.allowReview ?? testPartControl.allowReview,
|
|
94
|
+
showSolution: sectionControl.showSolution ?? testPartControl.showSolution,
|
|
95
|
+
allowComment: sectionControl.allowComment ?? testPartControl.allowComment,
|
|
96
|
+
allowSkipping: sectionControl.allowSkipping ?? testPartControl.allowSkipping,
|
|
97
|
+
validateResponses: sectionControl.validateResponses ?? testPartControl.validateResponses,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
76
100
|
hasAnyResponse(responses) {
|
|
77
101
|
for (const v of Object.values(responses)) {
|
|
78
102
|
if (v == null)
|
|
@@ -97,9 +121,20 @@ export class AssessmentPlayer {
|
|
|
97
121
|
const testParts = assessment.testParts || [];
|
|
98
122
|
let idx = 0;
|
|
99
123
|
let secIdx = 0;
|
|
124
|
+
const rng = this.config.rng ?? Math.random;
|
|
100
125
|
for (const tp of testParts) {
|
|
101
126
|
for (const section of tp.sections || []) {
|
|
102
|
-
|
|
127
|
+
let refs = [...(section.assessmentItemRefs || [])];
|
|
128
|
+
// QTI ordering: shuffle items within the section when requested.
|
|
129
|
+
// The server may have already shuffled; if not (e.g. reference adapter), do it client-side.
|
|
130
|
+
if (section.ordering?.shuffle) {
|
|
131
|
+
refs = shuffleArray(refs, rng);
|
|
132
|
+
}
|
|
133
|
+
// QTI selection: take only `select` items from the (possibly shuffled) list.
|
|
134
|
+
if (section.selection && section.selection.select > 0 && section.selection.select < refs.length) {
|
|
135
|
+
refs = refs.slice(0, section.selection.select);
|
|
136
|
+
}
|
|
137
|
+
for (const item of refs) {
|
|
103
138
|
out.push({
|
|
104
139
|
identifier: item.identifier,
|
|
105
140
|
item,
|
|
@@ -265,6 +300,11 @@ export class AssessmentPlayer {
|
|
|
265
300
|
this.currentItemIndex = index;
|
|
266
301
|
const q = this.items[index];
|
|
267
302
|
this.state.currentItemIdentifier = q.identifier;
|
|
303
|
+
// Apply three-level itemSessionControl fallback for this item's section (S1).
|
|
304
|
+
const effectiveControl = this.getEffectiveItemSessionControl(q);
|
|
305
|
+
if (effectiveControl) {
|
|
306
|
+
this.sessionController.updateSettings(effectiveControl);
|
|
307
|
+
}
|
|
268
308
|
// Restore responses
|
|
269
309
|
this.responses = { ...(this.state.itemResponses[q.identifier] || {}) };
|
|
270
310
|
// Create item player
|
|
@@ -353,11 +393,39 @@ export class AssessmentPlayer {
|
|
|
353
393
|
}
|
|
354
394
|
this.sessionController.markAnswered(q.identifier, this.hasAnyResponse(this.responses));
|
|
355
395
|
this.navigationManager.markVisited(this.currentItemIndex);
|
|
356
|
-
// Apply backend branching decision if provided
|
|
396
|
+
// Apply backend branching decision if provided.
|
|
397
|
+
// Special QTI targets EXIT_TEST / EXIT_TESTPART / EXIT_SECTION trigger finalization.
|
|
357
398
|
if (res.nextItemIdentifier) {
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
|
|
399
|
+
const special = res.nextItemIdentifier;
|
|
400
|
+
if (special === 'EXIT_TEST') {
|
|
401
|
+
// Finalize immediately — no further navigation
|
|
402
|
+
for (const l of this.completeListeners)
|
|
403
|
+
l();
|
|
404
|
+
this.config.onComplete?.();
|
|
405
|
+
}
|
|
406
|
+
else if (special === 'EXIT_TESTPART' || special === 'EXIT_SECTION') {
|
|
407
|
+
// Advance past all remaining items in the current testPart or section
|
|
408
|
+
const currentItem = this.items[this.currentItemIndex];
|
|
409
|
+
const isSection = special === 'EXIT_SECTION';
|
|
410
|
+
const nextIdx = this.items.findIndex((item, i) => i > this.currentItemIndex &&
|
|
411
|
+
(isSection
|
|
412
|
+
? item.section.identifier !== currentItem?.section.identifier
|
|
413
|
+
: item.testPart.identifier !== currentItem?.testPart.identifier));
|
|
414
|
+
if (nextIdx >= 0) {
|
|
415
|
+
await this.navigateTo(nextIdx);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
// No further items — signal completion
|
|
419
|
+
for (const l of this.completeListeners)
|
|
420
|
+
l();
|
|
421
|
+
this.config.onComplete?.();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
const nextIdx = this.items.findIndex((x) => x.identifier === special);
|
|
426
|
+
if (nextIdx >= 0) {
|
|
427
|
+
await this.navigateTo(nextIdx);
|
|
428
|
+
}
|
|
361
429
|
}
|
|
362
430
|
}
|
|
363
431
|
return itemResult;
|
|
@@ -447,9 +515,27 @@ export class AssessmentPlayer {
|
|
|
447
515
|
maxScore: r.maxScore,
|
|
448
516
|
responses: this.state.itemResponses[r.itemIdentifier] || {},
|
|
449
517
|
}));
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
518
|
+
// Evaluate testFeedback visibility using QTI string equality:
|
|
519
|
+
// show when outcomeIdentifier's value equals feedback.identifier (for showHide='show'),
|
|
520
|
+
// or does NOT equal it (for showHide='hide').
|
|
521
|
+
const structuredFeedback = this.assessment.testFeedback ?? [];
|
|
522
|
+
const outcomes = finalized.outcomes ?? {};
|
|
523
|
+
if (structuredFeedback.length > 0) {
|
|
524
|
+
this.visibleFeedback = structuredFeedback
|
|
525
|
+
.filter((fb) => fb.access === 'atEnd')
|
|
526
|
+
.filter((fb) => {
|
|
527
|
+
const outcomeValue = String(outcomes[fb.outcomeIdentifier] ?? '');
|
|
528
|
+
const matches = outcomeValue === fb.identifier;
|
|
529
|
+
return fb.showHide === 'show' ? matches : !matches;
|
|
530
|
+
})
|
|
531
|
+
.map((fb) => ({ identifier: fb.identifier, content: fb.content, access: fb.access }));
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
// Legacy: backend returns a plain feedback string
|
|
535
|
+
this.visibleFeedback = finalized.feedback
|
|
536
|
+
? [{ identifier: 'testFeedback', content: finalized.feedback, access: 'atEnd' }]
|
|
537
|
+
: [];
|
|
538
|
+
}
|
|
453
539
|
this.notifyComplete();
|
|
454
540
|
if (this.config.onComplete)
|
|
455
541
|
this.config.onComplete();
|
|
@@ -592,3 +678,12 @@ export class AssessmentPlayer {
|
|
|
592
678
|
};
|
|
593
679
|
}
|
|
594
680
|
}
|
|
681
|
+
/** Fisher-Yates shuffle using a provided RNG (returns a new array). */
|
|
682
|
+
function shuffleArray(arr, rng) {
|
|
683
|
+
const out = [...arr];
|
|
684
|
+
for (let i = out.length - 1; i > 0; i--) {
|
|
685
|
+
const j = Math.floor(rng() * (i + 1));
|
|
686
|
+
[out[i], out[j]] = [out[j], out[i]];
|
|
687
|
+
}
|
|
688
|
+
return out;
|
|
689
|
+
}
|
|
@@ -23,6 +23,15 @@ export interface TimeManagerConfig {
|
|
|
23
23
|
onExpired?: () => void;
|
|
24
24
|
/** Callback for time updates (fires every second) */
|
|
25
25
|
onTick?: (remainingSeconds: number, elapsedSeconds: number) => void;
|
|
26
|
+
/**
|
|
27
|
+
* QTI 3.0 PNP extended time accommodation.
|
|
28
|
+
* When active, multiplies assessmentTimeLimits.maxTime by the given multiplier.
|
|
29
|
+
* multiplier: Infinity removes the time limit entirely.
|
|
30
|
+
*/
|
|
31
|
+
extendedTime?: {
|
|
32
|
+
active: boolean;
|
|
33
|
+
multiplier: number;
|
|
34
|
+
};
|
|
26
35
|
}
|
|
27
36
|
export interface TimeTrackingState {
|
|
28
37
|
/** Total elapsed time (ms) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeManager.d.ts","sourceRoot":"","sources":["../../src/core/TimeManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IACjC,mCAAmC;IACnC,oBAAoB,CAAC,EAAE,UAAU,CAAC;IAClC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,SAAS,CAAC,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,qDAAqD;IACrD,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"TimeManager.d.ts","sourceRoot":"","sources":["../../src/core/TimeManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IACjC,mCAAmC;I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K,IAAI,IAAI;IAIb;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI;IASxC;;OAEG;IACH,OAAO,CAAC,cAAc;IAWtB;;OAEG;IACH,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAUrC;;OAEG;IACH,YAAY,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAI7C;;OAEG;IACH,mBAAmB,IAAI,MAAM,GAAG,IAAI;IASpC;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAI3B;;OAEG;IACH,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAI3C;;OAEG;IACH,QAAQ,IAAI,iBAAiB;IAI7B;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAY5C;;OAEG;IACH,SAAS,IAAI,OAAO;IASpB;;OAEG;IACH,oBAAoB,IAAI,OAAO;IAI/B;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAY1C;;OAEG;IACH,OAAO,IAAI,IAAI;CAGf"}
|
package/dist/core/TimeManager.js
CHANGED
|
@@ -25,10 +25,23 @@ export class TimeManager {
|
|
|
25
25
|
startedAt: Date.now(),
|
|
26
26
|
isPaused: false,
|
|
27
27
|
};
|
|
28
|
-
// Initialize timer if time limit exists
|
|
28
|
+
// Initialize timer if time limit exists, applying PNP extended-time multiplier if set.
|
|
29
29
|
if (config.assessmentTimeLimits?.maxTime) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const base = config.assessmentTimeLimits.maxTime;
|
|
31
|
+
const et = config.extendedTime;
|
|
32
|
+
if (et?.active && et.multiplier === Infinity) {
|
|
33
|
+
// multiplier: Infinity → unlimited time (no countdown)
|
|
34
|
+
this.maxTimeSeconds = null;
|
|
35
|
+
}
|
|
36
|
+
else if (et?.active && et.multiplier > 0) {
|
|
37
|
+
this.maxTimeSeconds = base * et.multiplier;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.maxTimeSeconds = base;
|
|
41
|
+
}
|
|
42
|
+
if (this.maxTimeSeconds !== null) {
|
|
43
|
+
this.startTimer();
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* - Validates all requests with authentication
|
|
27
27
|
* - Filters sensitive data based on role
|
|
28
28
|
*/
|
|
29
|
-
import type { BackendAdapter, FinalizeAssessmentRequest, FinalizeAssessmentResponse, InitSessionRequest, InitSessionResponse, QueryItemBankRequest, QueryItemBankResponse, SaveAssessmentStateRequest, SaveAssessmentStateResponse, SecureAssessment, SessionId, SubmitResponsesRequest, SubmitResponsesResponse } from './api-contract.js';
|
|
29
|
+
import type { BackendAdapter, FinalizeAssessmentRequest, FinalizeAssessmentResponse, InitSessionRequest, InitSessionResponse, QueryItemBankRequest, QueryItemBankResponse, SaveAssessmentStateRequest, SaveAssessmentStateResponse, SecureAssessment, SecureItemRef, SessionId, SubmitResponsesRequest, SubmitResponsesResponse } from './api-contract.js';
|
|
30
30
|
/**
|
|
31
31
|
* Reference Backend Adapter using localStorage
|
|
32
32
|
*
|
|
@@ -66,6 +66,11 @@ export declare class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
66
66
|
* Finalize assessment and compute final scores
|
|
67
67
|
*/
|
|
68
68
|
finalizeAssessment(request: FinalizeAssessmentRequest): Promise<FinalizeAssessmentResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Execute test-level outcome processing (T9/T1).
|
|
71
|
+
* Returns a map of outcome variable values, or null if no outcomeProcessing is defined.
|
|
72
|
+
*/
|
|
73
|
+
private runOutcomeProcessing;
|
|
69
74
|
/**
|
|
70
75
|
* Resume existing session (alias for initSession with resumeSessionId)
|
|
71
76
|
*/
|
|
@@ -86,6 +91,7 @@ export declare class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
86
91
|
private loadSession;
|
|
87
92
|
private saveSession;
|
|
88
93
|
private findItemXml;
|
|
94
|
+
private findItemRef;
|
|
89
95
|
/**
|
|
90
96
|
* Score an item using the Player
|
|
91
97
|
*
|
|
@@ -99,6 +105,26 @@ export declare class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
99
105
|
* In production, this would fetch from database
|
|
100
106
|
*/
|
|
101
107
|
private createDemoAssessment;
|
|
108
|
+
/**
|
|
109
|
+
* Parse a QTI assessmentTest XML string into a SecureAssessment structure.
|
|
110
|
+
*
|
|
111
|
+
* Handles:
|
|
112
|
+
* - S1: section-level itemSessionControl
|
|
113
|
+
* - S9: assessmentSectionRef href resolution (requires fileResolver)
|
|
114
|
+
* - T9/T1: outcomeDeclarations + outcomeProcessing extraction
|
|
115
|
+
*
|
|
116
|
+
* @param testXml - Raw QTI assessmentTest XML string
|
|
117
|
+
* @param options.role - Role to assign to items (default: 'candidate')
|
|
118
|
+
* @param options.itemXmlMap - Map of item identifier -> itemXml for pre-loaded items
|
|
119
|
+
* @param options.fileResolver - Async function to load external files by relative href
|
|
120
|
+
* @param options.baseUrl - Base URL for resolving relative hrefs
|
|
121
|
+
*/
|
|
122
|
+
static parseAssessmentTestXml(testXml: string, options?: {
|
|
123
|
+
role?: SecureItemRef['role'];
|
|
124
|
+
itemXmlMap?: Record<string, string>;
|
|
125
|
+
fileResolver?: (href: string) => Promise<string>;
|
|
126
|
+
baseUrl?: string;
|
|
127
|
+
}): Promise<SecureAssessment>;
|
|
102
128
|
private evaluateConditionXml;
|
|
103
129
|
private getItemOrder;
|
|
104
130
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceBackendAdapter.d.ts","sourceRoot":"","sources":["../../src/integration/ReferenceBackendAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"ReferenceBackendAdapter.d.ts","sourceRoot":"","sources":["../../src/integration/Reference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