@pie-qti/assessment-player 0.1.4 → 0.1.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.
- package/README.md +19 -16
- package/dist/core/AssessmentPlayer.d.ts +21 -2
- package/dist/core/AssessmentPlayer.d.ts.map +1 -1
- package/dist/core/AssessmentPlayer.js +144 -15
- 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 +28 -8
- package/dist/integration/ReferenceBackendAdapter.d.ts.map +1 -1
- package/dist/integration/ReferenceBackendAdapter.js +409 -51
- package/dist/integration/api-contract.d.ts +82 -2
- package/dist/integration/api-contract.d.ts.map +1 -1
- package/dist/integration/assessment-item-scorer.d.ts +12 -0
- package/dist/integration/assessment-item-scorer.d.ts.map +1 -0
- package/dist/integration/assessment-item-scorer.js +40 -0
- package/dist/integration/index.d.ts +1 -0
- package/dist/integration/index.d.ts.map +1 -1
- package/dist/integration/index.js +1 -0
- package/package.json +6 -6
- package/src/components/AccessibilityAnnouncer.svelte +13 -2
- package/src/components/AssessmentShell.svelte +13 -8
- package/src/components/AssessmentTimer.svelte +23 -0
- package/src/components/ItemRenderer.svelte +7 -3
- package/src/components/NavigationBar.svelte +2 -0
- package/src/components/SectionMenu.svelte +72 -5
- package/src/components/index.ts +1 -1
- package/src/core/AssessmentPlayer.ts +162 -17
- package/src/core/TimeManager.ts +20 -3
- package/src/integration/ReferenceBackendAdapter.ts +467 -54
- package/src/integration/api-contract.ts +84 -2
- package/src/integration/assessment-item-scorer.ts +53 -0
- package/src/integration/index.ts +5 -0
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,7 +78,15 @@ 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;
|
|
88
|
+
private restoreItemSessionsFromState;
|
|
89
|
+
private getItemSessionStateSnapshot;
|
|
73
90
|
private flattenItems;
|
|
74
91
|
getAllSections(): Array<{
|
|
75
92
|
id: string;
|
|
@@ -107,7 +124,9 @@ export declare class AssessmentPlayer {
|
|
|
107
124
|
* Restore a previously saved session state.
|
|
108
125
|
*/
|
|
109
126
|
restoreState(state: AssessmentSessionState): Promise<void>;
|
|
110
|
-
navigateTo(index: number
|
|
127
|
+
navigateTo(index: number, options?: {
|
|
128
|
+
restoring?: boolean;
|
|
129
|
+
}): Promise<void>;
|
|
111
130
|
navigateToSection(sectionId: string): Promise<void>;
|
|
112
131
|
next(): Promise<void>;
|
|
113
132
|
previous(): Promise<void>;
|
|
@@ -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,EAOlB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,MAAM,mBAAmB,CAAC;AAK3B,MAAM,WAAW,6BAA6B;IAC7C,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,EAAE,kBAAkB,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,+FAA+F;IAC/F,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB;;;OAGG;IACH,QAAQ,C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AM,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,17 +50,20 @@ 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.
|
|
56
57
|
for (const q of this.items) {
|
|
57
58
|
this.sessionController.initializeItem(q.identifier);
|
|
58
59
|
}
|
|
60
|
+
this.restoreItemSessionsFromState(this.state);
|
|
59
61
|
// Initialize time manager if time limits exist
|
|
60
62
|
if (this.assessment.timeLimits?.maxTime) {
|
|
61
63
|
this.timeManager = new TimeManager({
|
|
62
64
|
assessmentTimeLimits: this.assessment.timeLimits,
|
|
63
65
|
warningThreshold: config.timeWarningThreshold || 60,
|
|
66
|
+
extendedTime: config.pnp?.content?.extendedTime,
|
|
64
67
|
onWarning: (remainingSeconds) => this.notifyTimeWarning(remainingSeconds),
|
|
65
68
|
onExpired: () => this.notifyTimeExpired(),
|
|
66
69
|
onTick: (remainingSeconds, elapsedSeconds) => this.notifyTimeTick(remainingSeconds, elapsedSeconds),
|
|
@@ -70,9 +73,31 @@ export class AssessmentPlayer {
|
|
|
70
73
|
const startId = this.state.currentItemIdentifier;
|
|
71
74
|
const idx = startId ? this.items.findIndex((q) => q.identifier === startId) : -1;
|
|
72
75
|
if (idx >= 0) {
|
|
73
|
-
this.navigateTo(idx).catch(() => { });
|
|
76
|
+
this.navigateTo(idx, { restoring: true }).catch(() => { });
|
|
74
77
|
}
|
|
75
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Compute effective itemSessionControl for a given item using three-level fallback:
|
|
81
|
+
* section-level (highest priority) → testPart-level → defaults.
|
|
82
|
+
* Section-level values override testPart-level when present.
|
|
83
|
+
*/
|
|
84
|
+
getEffectiveItemSessionControl(flat) {
|
|
85
|
+
const testPartControl = flat.testPart.itemSessionControl;
|
|
86
|
+
const sectionControl = flat.section.itemSessionControl;
|
|
87
|
+
if (!sectionControl)
|
|
88
|
+
return testPartControl;
|
|
89
|
+
if (!testPartControl)
|
|
90
|
+
return sectionControl;
|
|
91
|
+
return {
|
|
92
|
+
maxAttempts: sectionControl.maxAttempts ?? testPartControl.maxAttempts,
|
|
93
|
+
showFeedback: sectionControl.showFeedback ?? testPartControl.showFeedback,
|
|
94
|
+
allowReview: sectionControl.allowReview ?? testPartControl.allowReview,
|
|
95
|
+
showSolution: sectionControl.showSolution ?? testPartControl.showSolution,
|
|
96
|
+
allowComment: sectionControl.allowComment ?? testPartControl.allowComment,
|
|
97
|
+
allowSkipping: sectionControl.allowSkipping ?? testPartControl.allowSkipping,
|
|
98
|
+
validateResponses: sectionControl.validateResponses ?? testPartControl.validateResponses,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
76
101
|
hasAnyResponse(responses) {
|
|
77
102
|
for (const v of Object.values(responses)) {
|
|
78
103
|
if (v == null)
|
|
@@ -92,14 +117,56 @@ export class AssessmentPlayer {
|
|
|
92
117
|
}
|
|
93
118
|
return false;
|
|
94
119
|
}
|
|
120
|
+
restoreItemSessionsFromState(state) {
|
|
121
|
+
const restoredStates = new Map();
|
|
122
|
+
for (const item of this.items) {
|
|
123
|
+
const persisted = state.itemSessionStates?.[item.identifier];
|
|
124
|
+
if (persisted) {
|
|
125
|
+
restoredStates.set(item.identifier, {
|
|
126
|
+
itemIdentifier: item.identifier,
|
|
127
|
+
attemptCount: Math.max(0, persisted.attemptCount),
|
|
128
|
+
isAnswered: persisted.isAnswered,
|
|
129
|
+
isSubmitted: persisted.isSubmitted,
|
|
130
|
+
lastSubmissionTime: persisted.lastSubmissionTime,
|
|
131
|
+
});
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const responses = state.itemResponses?.[item.identifier] ?? {};
|
|
135
|
+
const isSubmitted = Boolean(state.itemScores?.[item.identifier]);
|
|
136
|
+
restoredStates.set(item.identifier, {
|
|
137
|
+
itemIdentifier: item.identifier,
|
|
138
|
+
attemptCount: isSubmitted ? 1 : 0,
|
|
139
|
+
isAnswered: this.hasAnyResponse(responses),
|
|
140
|
+
isSubmitted,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
this.sessionController.restoreStates(restoredStates);
|
|
144
|
+
}
|
|
145
|
+
getItemSessionStateSnapshot() {
|
|
146
|
+
return Object.fromEntries([...this.sessionController.getAllStates().entries()].map(([itemIdentifier, state]) => [
|
|
147
|
+
itemIdentifier,
|
|
148
|
+
{ ...state },
|
|
149
|
+
]));
|
|
150
|
+
}
|
|
95
151
|
flattenItems(assessment) {
|
|
96
152
|
const out = [];
|
|
97
153
|
const testParts = assessment.testParts || [];
|
|
98
154
|
let idx = 0;
|
|
99
155
|
let secIdx = 0;
|
|
156
|
+
const rng = this.config.rng ?? Math.random;
|
|
100
157
|
for (const tp of testParts) {
|
|
101
158
|
for (const section of tp.sections || []) {
|
|
102
|
-
|
|
159
|
+
let refs = [...(section.assessmentItemRefs || [])];
|
|
160
|
+
// QTI ordering: shuffle items within the section when requested.
|
|
161
|
+
// The server may have already shuffled; if not (e.g. reference adapter), do it client-side.
|
|
162
|
+
if (section.ordering?.shuffle) {
|
|
163
|
+
refs = shuffleArray(refs, rng);
|
|
164
|
+
}
|
|
165
|
+
// QTI selection: take only `select` items from the (possibly shuffled) list.
|
|
166
|
+
if (section.selection && section.selection.select > 0 && section.selection.select < refs.length) {
|
|
167
|
+
refs = refs.slice(0, section.selection.select);
|
|
168
|
+
}
|
|
169
|
+
for (const item of refs) {
|
|
103
170
|
out.push({
|
|
104
171
|
identifier: item.identifier,
|
|
105
172
|
item,
|
|
@@ -184,11 +251,11 @@ export class AssessmentPlayer {
|
|
|
184
251
|
const prev = (this.state.itemResponses?.[itemIdentifier] || {});
|
|
185
252
|
const next = { ...prev, [responseId]: value };
|
|
186
253
|
this.state.itemResponses[itemIdentifier] = next;
|
|
254
|
+
this.sessionController.markAnswered(itemIdentifier, this.hasAnyResponse(next));
|
|
187
255
|
// If this is the active item, keep the live response state + UI hints in sync.
|
|
188
256
|
const active = this.items[this.currentItemIndex];
|
|
189
257
|
if (active?.identifier === itemIdentifier) {
|
|
190
258
|
this.responses = next;
|
|
191
|
-
this.sessionController.markAnswered(itemIdentifier, this.hasAnyResponse(this.responses));
|
|
192
259
|
this.currentItemPlayer?.setResponses(this.responses);
|
|
193
260
|
this.notifyResponseChange();
|
|
194
261
|
}
|
|
@@ -211,6 +278,7 @@ export class AssessmentPlayer {
|
|
|
211
278
|
visitedItems: [...this.state.visitedItems],
|
|
212
279
|
itemResponses: { ...this.state.itemResponses },
|
|
213
280
|
itemScores: this.state.itemScores ? { ...this.state.itemScores } : undefined,
|
|
281
|
+
itemSessionStates: this.getItemSessionStateSnapshot(),
|
|
214
282
|
timing: {
|
|
215
283
|
...this.state.timing,
|
|
216
284
|
itemTimes: { ...this.state.timing.itemTimes },
|
|
@@ -227,6 +295,7 @@ export class AssessmentPlayer {
|
|
|
227
295
|
.map((id) => this.items.findIndex((q) => q.identifier === id))
|
|
228
296
|
.filter((i) => i >= 0);
|
|
229
297
|
this.navigationManager.restoreState(visitedIdx);
|
|
298
|
+
this.restoreItemSessionsFromState(state);
|
|
230
299
|
// Rehydrate itemResults from scores if present, so submit() can behave sensibly.
|
|
231
300
|
this.itemResults.clear();
|
|
232
301
|
if (state.itemScores) {
|
|
@@ -242,29 +311,34 @@ export class AssessmentPlayer {
|
|
|
242
311
|
const currentId = state.currentItemIdentifier;
|
|
243
312
|
const idx = currentId ? this.items.findIndex((q) => q.identifier === currentId) : -1;
|
|
244
313
|
if (idx >= 0) {
|
|
245
|
-
await this.navigateTo(idx);
|
|
314
|
+
await this.navigateTo(idx, { restoring: true });
|
|
246
315
|
}
|
|
247
316
|
else if (this.items.length > 0) {
|
|
248
|
-
await this.navigateTo(0);
|
|
317
|
+
await this.navigateTo(0, { restoring: true });
|
|
249
318
|
}
|
|
250
319
|
}
|
|
251
|
-
async navigateTo(index) {
|
|
320
|
+
async navigateTo(index, options = {}) {
|
|
252
321
|
if (index < 0 || index >= this.items.length)
|
|
253
322
|
throw new Error(`Invalid item index: ${index}`);
|
|
254
323
|
// Enforce navigation rules (UI hints, still backend-authoritative for real deployments).
|
|
255
|
-
if (this.currentItemIndex >= 0 && !this.navigationManager.canNavigateTo(index, this.currentItemIndex)) {
|
|
324
|
+
if (!options.restoring && this.currentItemIndex >= 0 && !this.navigationManager.canNavigateTo(index, this.currentItemIndex)) {
|
|
256
325
|
if (this.navigationManager.getMode() === 'linear' && index > this.currentItemIndex + 1) {
|
|
257
326
|
throw new Error('In linear navigation mode, you can only move to the next question.');
|
|
258
327
|
}
|
|
259
328
|
throw new Error('Navigation is not allowed.');
|
|
260
329
|
}
|
|
261
330
|
const target = this.items[index];
|
|
262
|
-
if (target && !this.sessionController.canReview(target.identifier)) {
|
|
331
|
+
if (!options.restoring && target && !this.sessionController.canReview(target.identifier)) {
|
|
263
332
|
throw new Error('You cannot go back to previous questions in this assessment.');
|
|
264
333
|
}
|
|
265
334
|
this.currentItemIndex = index;
|
|
266
335
|
const q = this.items[index];
|
|
267
336
|
this.state.currentItemIdentifier = q.identifier;
|
|
337
|
+
// Apply three-level itemSessionControl fallback for this item's section (S1).
|
|
338
|
+
const effectiveControl = this.getEffectiveItemSessionControl(q);
|
|
339
|
+
if (effectiveControl) {
|
|
340
|
+
this.sessionController.updateSettings(effectiveControl);
|
|
341
|
+
}
|
|
268
342
|
// Restore responses
|
|
269
343
|
this.responses = { ...(this.state.itemResponses[q.identifier] || {}) };
|
|
270
344
|
// Create item player
|
|
@@ -353,11 +427,39 @@ export class AssessmentPlayer {
|
|
|
353
427
|
}
|
|
354
428
|
this.sessionController.markAnswered(q.identifier, this.hasAnyResponse(this.responses));
|
|
355
429
|
this.navigationManager.markVisited(this.currentItemIndex);
|
|
356
|
-
// Apply backend branching decision if provided
|
|
430
|
+
// Apply backend branching decision if provided.
|
|
431
|
+
// Special QTI targets EXIT_TEST / EXIT_TESTPART / EXIT_SECTION trigger finalization.
|
|
357
432
|
if (res.nextItemIdentifier) {
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
|
|
433
|
+
const special = res.nextItemIdentifier;
|
|
434
|
+
if (special === 'EXIT_TEST') {
|
|
435
|
+
// Finalize immediately — no further navigation
|
|
436
|
+
for (const l of this.completeListeners)
|
|
437
|
+
l();
|
|
438
|
+
this.config.onComplete?.();
|
|
439
|
+
}
|
|
440
|
+
else if (special === 'EXIT_TESTPART' || special === 'EXIT_SECTION') {
|
|
441
|
+
// Advance past all remaining items in the current testPart or section
|
|
442
|
+
const currentItem = this.items[this.currentItemIndex];
|
|
443
|
+
const isSection = special === 'EXIT_SECTION';
|
|
444
|
+
const nextIdx = this.items.findIndex((item, i) => i > this.currentItemIndex &&
|
|
445
|
+
(isSection
|
|
446
|
+
? item.section.identifier !== currentItem?.section.identifier
|
|
447
|
+
: item.testPart.identifier !== currentItem?.testPart.identifier));
|
|
448
|
+
if (nextIdx >= 0) {
|
|
449
|
+
await this.navigateTo(nextIdx);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
// No further items — signal completion
|
|
453
|
+
for (const l of this.completeListeners)
|
|
454
|
+
l();
|
|
455
|
+
this.config.onComplete?.();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
const nextIdx = this.items.findIndex((x) => x.identifier === special);
|
|
460
|
+
if (nextIdx >= 0) {
|
|
461
|
+
await this.navigateTo(nextIdx);
|
|
462
|
+
}
|
|
361
463
|
}
|
|
362
464
|
}
|
|
363
465
|
return itemResult;
|
|
@@ -447,9 +549,27 @@ export class AssessmentPlayer {
|
|
|
447
549
|
maxScore: r.maxScore,
|
|
448
550
|
responses: this.state.itemResponses[r.itemIdentifier] || {},
|
|
449
551
|
}));
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
552
|
+
// Evaluate testFeedback visibility using QTI string equality:
|
|
553
|
+
// show when outcomeIdentifier's value equals feedback.identifier (for showHide='show'),
|
|
554
|
+
// or does NOT equal it (for showHide='hide').
|
|
555
|
+
const structuredFeedback = this.assessment.testFeedback ?? [];
|
|
556
|
+
const outcomes = finalized.outcomes ?? {};
|
|
557
|
+
if (structuredFeedback.length > 0) {
|
|
558
|
+
this.visibleFeedback = structuredFeedback
|
|
559
|
+
.filter((fb) => fb.access === 'atEnd')
|
|
560
|
+
.filter((fb) => {
|
|
561
|
+
const outcomeValue = String(outcomes[fb.outcomeIdentifier] ?? '');
|
|
562
|
+
const matches = outcomeValue === fb.identifier;
|
|
563
|
+
return fb.showHide === 'show' ? matches : !matches;
|
|
564
|
+
})
|
|
565
|
+
.map((fb) => ({ identifier: fb.identifier, content: fb.content, access: fb.access }));
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
// Legacy: backend returns a plain feedback string
|
|
569
|
+
this.visibleFeedback = finalized.feedback
|
|
570
|
+
? [{ identifier: 'testFeedback', content: finalized.feedback, access: 'atEnd' }]
|
|
571
|
+
: [];
|
|
572
|
+
}
|
|
453
573
|
this.notifyComplete();
|
|
454
574
|
if (this.config.onComplete)
|
|
455
575
|
this.config.onComplete();
|
|
@@ -592,3 +712,12 @@ export class AssessmentPlayer {
|
|
|
592
712
|
};
|
|
593
713
|
}
|
|
594
714
|
}
|
|
715
|
+
/** Fisher-Yates shuffle using a provided RNG (returns a new array). */
|
|
716
|
+
function shuffleArray(arr, rng) {
|
|
717
|
+
const out = [...arr];
|
|
718
|
+
for (let i = out.length - 1; i > 0; i--) {
|
|
719
|
+
const j = Math.floor(rng() * (i + 1));
|
|
720
|
+
[out[i], out[j]] = [out[j], out[i]];
|
|
721
|
+
}
|
|
722
|
+
return out;
|
|
723
|
+
}
|
|
@@ -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,mCAA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;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
|
*
|
|
@@ -50,6 +50,7 @@ export declare class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
50
50
|
*/
|
|
51
51
|
registerAssessment(assessmentId: string, assessment: SecureAssessment): void;
|
|
52
52
|
private getAssessment;
|
|
53
|
+
private hasAnyResponse;
|
|
53
54
|
/**
|
|
54
55
|
* Initialize a new assessment session
|
|
55
56
|
*/
|
|
@@ -66,6 +67,11 @@ export declare class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
66
67
|
* Finalize assessment and compute final scores
|
|
67
68
|
*/
|
|
68
69
|
finalizeAssessment(request: FinalizeAssessmentRequest): Promise<FinalizeAssessmentResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Execute test-level outcome processing (T9/T1).
|
|
72
|
+
* Returns a map of outcome variable values, or null if no outcomeProcessing is defined.
|
|
73
|
+
*/
|
|
74
|
+
private runOutcomeProcessing;
|
|
69
75
|
/**
|
|
70
76
|
* Resume existing session (alias for initSession with resumeSessionId)
|
|
71
77
|
*/
|
|
@@ -86,19 +92,33 @@ export declare class ReferenceBackendAdapter implements BackendAdapter {
|
|
|
86
92
|
private loadSession;
|
|
87
93
|
private saveSession;
|
|
88
94
|
private findItemXml;
|
|
89
|
-
|
|
90
|
-
* Score an item using the Player
|
|
91
|
-
*
|
|
92
|
-
* **SECURITY WARNING**: This is done CLIENT-SIDE for demo purposes only.
|
|
93
|
-
* Production implementations MUST perform scoring SERVER-SIDE.
|
|
94
|
-
*/
|
|
95
|
-
private scoreItem;
|
|
95
|
+
private findItemRef;
|
|
96
96
|
/**
|
|
97
97
|
* Create demo assessment for testing
|
|
98
98
|
*
|
|
99
99
|
* In production, this would fetch from database
|
|
100
100
|
*/
|
|
101
101
|
private createDemoAssessment;
|
|
102
|
+
/**
|
|
103
|
+
* Parse a QTI assessmentTest XML string into a SecureAssessment structure.
|
|
104
|
+
*
|
|
105
|
+
* Handles:
|
|
106
|
+
* - S1: section-level itemSessionControl
|
|
107
|
+
* - S9: assessmentSectionRef href resolution (requires fileResolver)
|
|
108
|
+
* - T9/T1: outcomeDeclarations + outcomeProcessing extraction
|
|
109
|
+
*
|
|
110
|
+
* @param testXml - Raw QTI assessmentTest XML string
|
|
111
|
+
* @param options.role - Role to assign to items (default: 'candidate')
|
|
112
|
+
* @param options.itemXmlMap - Map of item identifier -> itemXml for pre-loaded items
|
|
113
|
+
* @param options.fileResolver - Async function to load external files by relative href
|
|
114
|
+
* @param options.baseUrl - Base URL for resolving relative hrefs
|
|
115
|
+
*/
|
|
116
|
+
static parseAssessmentTestXml(testXml: string, options?: {
|
|
117
|
+
role?: SecureItemRef['role'];
|
|
118
|
+
itemXmlMap?: Record<string, string>;
|
|
119
|
+
fileResolver?: (href: string) => Promise<string>;
|
|
120
|
+
baseUrl?: string;
|
|
121
|
+
}): Promise<SecureAssessment>;
|
|
102
122
|
private evaluateConditionXml;
|
|
103
123
|
private getItemOrder;
|
|
104
124
|
/**
|
|
@@ -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/ReferenceBackendAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAiBH,OAAO,KAAK,EAGX,cAAc,EACd,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EAChB,aAAa,EAGb,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,MAAM,mBAAmB,CAAC;AAmD3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