@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-contract.d.ts","sourceRoot":"","sources":["../../src/integration/api-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAA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AAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;QACxC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC,6CAA6C;IAC7C,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEvE;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAEnF;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAErF;;OAEG;IACH,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAE5F;;OAEG;IACH,aAAa,CAAC,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEnE;;;;OAIG;IACH,aAAa,CAAC,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC9E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AssessmentScoringResult, ResponseValue } from './api-contract.js';
|
|
2
|
+
export interface AssessmentItemScoringInput {
|
|
3
|
+
itemXml: string;
|
|
4
|
+
responses: Record<string, ResponseValue>;
|
|
5
|
+
}
|
|
6
|
+
export declare function getAssessmentItemIdentifier(itemXml: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Runs QTI ResponseProcessing for one AssessmentItem and normalizes the result
|
|
9
|
+
* to the BackendAdapter scoring shape used by AssessmentPlayer.
|
|
10
|
+
*/
|
|
11
|
+
export declare function scoreAssessmentItem({ itemXml, responses, }: AssessmentItemScoringInput): AssessmentScoringResult;
|
|
12
|
+
//# sourceMappingURL=assessment-item-scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment-item-scorer.d.ts","sourceRoot":"","sources":["../../src/integration/assessment-item-scorer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEhF,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACzC;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,OAAO,EACP,SAAS,GACT,EAAE,0BAA0B,GAAG,uBAAuB,CAgCtD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Player } from '@pie-qti/item-player';
|
|
2
|
+
export function getAssessmentItemIdentifier(itemXml) {
|
|
3
|
+
const identifierMatch = itemXml.match(/assessmentItem[^>]+identifier=["']([^"']+)["']/);
|
|
4
|
+
return identifierMatch?.[1] || 'unknown';
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Runs QTI ResponseProcessing for one AssessmentItem and normalizes the result
|
|
8
|
+
* to the BackendAdapter scoring shape used by AssessmentPlayer.
|
|
9
|
+
*/
|
|
10
|
+
export function scoreAssessmentItem({ itemXml, responses, }) {
|
|
11
|
+
const itemIdentifier = getAssessmentItemIdentifier(itemXml);
|
|
12
|
+
try {
|
|
13
|
+
// Use a scorer-grade view of the item for accurate scoring.
|
|
14
|
+
// NOTE: This reference scorer is intentionally insecure and runs client-side.
|
|
15
|
+
// In production, scoring must happen server-side with secured item content.
|
|
16
|
+
const player = new Player({
|
|
17
|
+
itemXml,
|
|
18
|
+
role: 'scorer',
|
|
19
|
+
});
|
|
20
|
+
player.setResponses(responses);
|
|
21
|
+
const result = player.processResponses();
|
|
22
|
+
return {
|
|
23
|
+
itemIdentifier,
|
|
24
|
+
score: result.score,
|
|
25
|
+
maxScore: result.maxScore,
|
|
26
|
+
completed: result.completed,
|
|
27
|
+
outcomeValues: result.outcomeValues,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error('Scoring error:', error);
|
|
32
|
+
return {
|
|
33
|
+
itemIdentifier,
|
|
34
|
+
score: 0,
|
|
35
|
+
maxScore: 1,
|
|
36
|
+
completed: false,
|
|
37
|
+
outcomeValues: {},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -44,4 +44,5 @@
|
|
|
44
44
|
*/
|
|
45
45
|
export type { BackendAdapter, FeedbackItem, AssessmentSessionState, AssessmentScoringResult, AssessmentRubricBlock, FinalizeAssessmentRequest, FinalizeAssessmentResponse, InitSessionRequest, InitSessionResponse, ResponseValue, SaveAssessmentStateRequest, SaveAssessmentStateResponse, SecureAssessment, SecureItemRef, SecureSection, SecureTestPart, SessionId, SubmitResponsesRequest, SubmitResponsesResponse, } from './api-contract.js';
|
|
46
46
|
export { ReferenceBackendAdapter } from './ReferenceBackendAdapter.js';
|
|
47
|
+
export { getAssessmentItemIdentifier, scoreAssessmentItem, type AssessmentItemScoringInput, } from './assessment-item-scorer.js';
|
|
47
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,YAAY,EACX,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,SAAS,EACT,sBAAsB,EACtB,uBAAuB,GACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,YAAY,EACX,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,SAAS,EACT,sBAAsB,EACtB,uBAAuB,GACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,2BAA2B,EAC3B,mBAAmB,EACnB,KAAK,0BAA0B,GAC/B,MAAM,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-qti/assessment-player",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "QTI Assessment Player supporting QTI 2.
|
|
3
|
+
"version": "0.1.6",
|
|
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",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@pie-qti/default-components": "0.1.
|
|
32
|
-
"@pie-qti/i18n": "0.1.
|
|
33
|
-
"@pie-qti/item-player": "0.1.
|
|
34
|
-
"@pie-qti/qti-processing": "0.1.
|
|
31
|
+
"@pie-qti/default-components": "0.1.6",
|
|
32
|
+
"@pie-qti/i18n": "0.1.6",
|
|
33
|
+
"@pie-qti/item-player": "0.1.6",
|
|
34
|
+
"@pie-qti/qti-processing": "0.1.6",
|
|
35
35
|
"node-html-parser": "^7.0.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -24,8 +24,15 @@
|
|
|
24
24
|
const { priority = 'polite' }: Props = $props();
|
|
25
25
|
|
|
26
26
|
let announcement = $state('');
|
|
27
|
+
let currentPriority = $state<'polite' | 'assertive'>('polite');
|
|
27
28
|
let announceTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
28
29
|
|
|
30
|
+
$effect(() => {
|
|
31
|
+
if (!announcement) {
|
|
32
|
+
currentPriority = priority;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
29
36
|
// Clean up timeout on destroy to prevent memory leaks
|
|
30
37
|
onDestroy(() => {
|
|
31
38
|
if (announceTimeout) {
|
|
@@ -39,8 +46,9 @@
|
|
|
39
46
|
*
|
|
40
47
|
* @param message - Text to announce
|
|
41
48
|
* @param clearAfter - Milliseconds to wait before clearing (default: 1000)
|
|
49
|
+
* @param nextPriority - Announcement priority for this message
|
|
42
50
|
*/
|
|
43
|
-
export function announce(message: string, clearAfter = 1000): void {
|
|
51
|
+
export function announce(message: string, clearAfter = 1000, nextPriority: 'polite' | 'assertive' = priority): void {
|
|
44
52
|
// Clear any existing announcement timeout
|
|
45
53
|
if (announceTimeout) {
|
|
46
54
|
clearTimeout(announceTimeout);
|
|
@@ -48,12 +56,14 @@
|
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
// Set the new announcement
|
|
59
|
+
currentPriority = nextPriority;
|
|
51
60
|
announcement = message;
|
|
52
61
|
|
|
53
62
|
// Clear after delay to allow screen readers to announce
|
|
54
63
|
// and prepare for next announcement
|
|
55
64
|
announceTimeout = setTimeout(() => {
|
|
56
65
|
announcement = '';
|
|
66
|
+
currentPriority = priority;
|
|
57
67
|
announceTimeout = null;
|
|
58
68
|
}, clearAfter);
|
|
59
69
|
}
|
|
@@ -67,6 +77,7 @@
|
|
|
67
77
|
announceTimeout = null;
|
|
68
78
|
}
|
|
69
79
|
announcement = '';
|
|
80
|
+
currentPriority = priority;
|
|
70
81
|
}
|
|
71
82
|
</script>
|
|
72
83
|
|
|
@@ -80,7 +91,7 @@
|
|
|
80
91
|
<div
|
|
81
92
|
class="sr-only"
|
|
82
93
|
role="status"
|
|
83
|
-
aria-live={
|
|
94
|
+
aria-live={currentPriority}
|
|
84
95
|
aria-atomic="true"
|
|
85
96
|
>
|
|
86
97
|
{announcement}
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
initTimeout = setTimeout(() => {
|
|
97
97
|
if (!hasFirstItem && !error) {
|
|
98
98
|
error = contextI18n?.t('assessment.loadingError') ?? 'assessment.loadingError';
|
|
99
|
+
announcer?.announce(error, 3000, 'assertive');
|
|
99
100
|
}
|
|
100
101
|
}, 10000);
|
|
101
102
|
|
|
@@ -143,6 +144,7 @@
|
|
|
143
144
|
})().catch((err) => {
|
|
144
145
|
console.error('Failed to initialize assessment player:', err);
|
|
145
146
|
error = err instanceof Error ? err.message : (contextI18n?.t('assessment.loadingError') ?? 'assessment.loadingError');
|
|
147
|
+
announcer?.announce(error, 3000, 'assertive');
|
|
146
148
|
});
|
|
147
149
|
|
|
148
150
|
return () => {
|
|
@@ -176,7 +178,8 @@
|
|
|
176
178
|
announceCurrentQuestion();
|
|
177
179
|
} catch (err) {
|
|
178
180
|
console.error('Previous navigation failed:', err);
|
|
179
|
-
|
|
181
|
+
const message = err instanceof Error ? err.message : (i18n?.t('assessment.errors.navigationFailed') ?? 'assessment.errors.navigationFailed');
|
|
182
|
+
navError = message;
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
185
|
|
|
@@ -189,7 +192,8 @@
|
|
|
189
192
|
announceCurrentQuestion();
|
|
190
193
|
} catch (err) {
|
|
191
194
|
console.error('Next navigation failed:', err);
|
|
192
|
-
|
|
195
|
+
const message = err instanceof Error ? err.message : (i18n?.t('assessment.errors.navigationFailed') ?? 'assessment.errors.navigationFailed');
|
|
196
|
+
navError = message;
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
|
|
@@ -251,7 +255,9 @@
|
|
|
251
255
|
// Or show results modal
|
|
252
256
|
} catch (err) {
|
|
253
257
|
console.error('Failed to submit assessment:', err);
|
|
254
|
-
|
|
258
|
+
const message = err instanceof Error ? err.message : (i18n?.t('assessment.errors.submitFailed') ?? 'assessment.errors.submitFailed');
|
|
259
|
+
error = message;
|
|
260
|
+
announcer?.announce(message, 3000, 'assertive');
|
|
255
261
|
}
|
|
256
262
|
}
|
|
257
263
|
|
|
@@ -305,7 +311,7 @@
|
|
|
305
311
|
|
|
306
312
|
{#if error}
|
|
307
313
|
<div class="assessment-error">
|
|
308
|
-
<div class="alert alert-error">
|
|
314
|
+
<div class="alert alert-error" role="alert" aria-live="assertive">
|
|
309
315
|
<svg
|
|
310
316
|
xmlns="http://www.w3.org/2000/svg"
|
|
311
317
|
class="stroke-current shrink-0 h-6 w-6"
|
|
@@ -324,13 +330,13 @@
|
|
|
324
330
|
</div>
|
|
325
331
|
{:else if !player || navState.currentIndex < 0}
|
|
326
332
|
<div class="assessment-loading">
|
|
327
|
-
<div class="flex items-center justify-center p-8">
|
|
333
|
+
<div class="flex items-center justify-center p-8" role="status" aria-live="polite">
|
|
328
334
|
<span class="loading loading-spinner loading-lg"></span>
|
|
329
335
|
<span class="ml-4">{contextI18n?.t('assessment.loading') ?? 'assessment.loading'}</span>
|
|
330
336
|
</div>
|
|
331
337
|
</div>
|
|
332
338
|
{:else}
|
|
333
|
-
<div bind:this={rootEl} class="assessment-shell" role="
|
|
339
|
+
<div bind:this={rootEl} class="assessment-shell" role="region" aria-label="Assessment player">
|
|
334
340
|
<!-- Header with title and section menu -->
|
|
335
341
|
<AssessmentHeader
|
|
336
342
|
title={initSession.assessmentId || (i18n?.t('assessment.title') ?? 'Assessment')}
|
|
@@ -348,7 +354,7 @@
|
|
|
348
354
|
|
|
349
355
|
{#if navError}
|
|
350
356
|
<div class="assessment-nav-error">
|
|
351
|
-
<div class="alert alert-warning">
|
|
357
|
+
<div class="alert alert-warning" role="alert" aria-live="assertive">
|
|
352
358
|
<svg
|
|
353
359
|
xmlns="http://www.w3.org/2000/svg"
|
|
354
360
|
class="stroke-current shrink-0 h-6 w-6"
|
|
@@ -374,7 +380,6 @@
|
|
|
374
380
|
tabindex="-1"
|
|
375
381
|
role="region"
|
|
376
382
|
aria-label={i18n?.t('accessibility.itemBody') ?? 'Question content'}
|
|
377
|
-
aria-live="polite"
|
|
378
383
|
>
|
|
379
384
|
{#if hasPassage}
|
|
380
385
|
<SplitPaneResizer
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
let elapsedSeconds = $state(0);
|
|
20
20
|
let isWarning = $state(false);
|
|
21
21
|
let isExpired = $state(false);
|
|
22
|
+
let announcement = $state('');
|
|
23
|
+
let announcementPriority = $state<'polite' | 'assertive'>('polite');
|
|
22
24
|
|
|
23
25
|
// Initialize state and subscribe to timer events
|
|
24
26
|
$effect(() => {
|
|
@@ -31,11 +33,17 @@
|
|
|
31
33
|
const unsubscribeWarning = player.onTimeWarning((remaining) => {
|
|
32
34
|
isWarning = true;
|
|
33
35
|
remainingSeconds = remaining;
|
|
36
|
+
announcementPriority = 'polite';
|
|
37
|
+
announcement =
|
|
38
|
+
i18n?.t('assessment.timer.timeRemaining', { time: TimeManager.formatTime(remaining) }) ??
|
|
39
|
+
`Time remaining: ${TimeManager.formatTime(remaining)}`;
|
|
34
40
|
});
|
|
35
41
|
|
|
36
42
|
const unsubscribeExpired = player.onTimeExpired(() => {
|
|
37
43
|
isExpired = true;
|
|
38
44
|
remainingSeconds = 0;
|
|
45
|
+
announcementPriority = 'assertive';
|
|
46
|
+
announcement = i18n?.t('assessment.timer.expired') ?? 'Time expired';
|
|
39
47
|
});
|
|
40
48
|
|
|
41
49
|
const unsubscribeTick = player.onTimeTick((remaining, elapsed) => {
|
|
@@ -106,6 +114,9 @@
|
|
|
106
114
|
<div class="timer-label">{timerLabel()}</div>
|
|
107
115
|
<div class="timer-value">{displayTime()}</div>
|
|
108
116
|
</div>
|
|
117
|
+
<div class="sr-only" role={announcementPriority === 'assertive' ? 'alert' : 'status'} aria-live={announcementPriority} aria-atomic="true">
|
|
118
|
+
{announcement}
|
|
119
|
+
</div>
|
|
109
120
|
</div>
|
|
110
121
|
{/if}
|
|
111
122
|
|
|
@@ -170,6 +181,18 @@
|
|
|
170
181
|
color: hsl(var(--bc));
|
|
171
182
|
}
|
|
172
183
|
|
|
184
|
+
.sr-only {
|
|
185
|
+
position: absolute;
|
|
186
|
+
width: 1px;
|
|
187
|
+
height: 1px;
|
|
188
|
+
padding: 0;
|
|
189
|
+
margin: -1px;
|
|
190
|
+
overflow: hidden;
|
|
191
|
+
clip: rect(0, 0, 0, 0);
|
|
192
|
+
white-space: nowrap;
|
|
193
|
+
border-width: 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
173
196
|
.assessment-timer.warning .timer-value {
|
|
174
197
|
color: hsl(var(--wa));
|
|
175
198
|
}
|
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
// @ts-expect-error - Svelte-check can't resolve workspace subpath exports, but runtime works correctly
|
|
5
5
|
import { ItemBody } from '@pie-qti/item-player/components';
|
|
6
6
|
import { Player, type PlayerSecurityConfig, type QTIRole } from '@pie-qti/item-player';
|
|
7
|
+
import type { InteractionResponseValue } from '@pie-qti/item-player/web-components';
|
|
7
8
|
import type { I18nProvider } from '@pie-qti/i18n';
|
|
8
9
|
import { onMount } from 'svelte';
|
|
9
10
|
import type { ItemRef } from '../types/index.js';
|
|
10
11
|
|
|
12
|
+
type ItemResponseValue = InteractionResponseValue | null;
|
|
13
|
+
type ItemResponseMap = Record<string, ItemResponseValue>;
|
|
14
|
+
|
|
11
15
|
/**
|
|
12
16
|
* Ensure default interaction web components are registered (browser-only).
|
|
13
17
|
*
|
|
@@ -34,8 +38,8 @@
|
|
|
34
38
|
role?: QTIRole;
|
|
35
39
|
extendedTextEditor?: string;
|
|
36
40
|
/** Responses for the current item (keyed by responseIdentifier). */
|
|
37
|
-
responses?:
|
|
38
|
-
onResponseChange?: (responseId: string, value:
|
|
41
|
+
responses?: ItemResponseMap;
|
|
42
|
+
onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
|
|
39
43
|
/** Math typesetting function (KaTeX, MathJax, etc.) */
|
|
40
44
|
typeset?: (root: HTMLElement) => void | Promise<void>;
|
|
41
45
|
/** I18n provider for translations */
|
|
@@ -86,7 +90,7 @@
|
|
|
86
90
|
});
|
|
87
91
|
|
|
88
92
|
// Handle response changes
|
|
89
|
-
function handleResponseChange(responseId: string, value:
|
|
93
|
+
function handleResponseChange(responseId: string, value: ItemResponseValue) {
|
|
90
94
|
onResponseChange?.(responseId, value);
|
|
91
95
|
}
|
|
92
96
|
</script>
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
previous: i18n?.t('common.previous') ?? 'Previous',
|
|
30
30
|
next: i18n?.t('common.next') ?? 'Next',
|
|
31
31
|
submit: i18n?.t('assessment.navigation.submit') ?? 'Submit',
|
|
32
|
+
progress: `${i18n?.t('assessment.navigation.progress', { percent: Math.round(progressPercentage) }) ?? `Progress: ${Math.round(progressPercentage)}%`}: ${i18n?.t('assessment.question', { current: navState.currentIndex + 1, total: navState.totalItems }) ?? `Question ${navState.currentIndex + 1} of ${navState.totalItems}`}`,
|
|
32
33
|
});
|
|
33
34
|
</script>
|
|
34
35
|
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
class="progress progress-primary w-full"
|
|
49
50
|
value={progressPercentage}
|
|
50
51
|
max="100"
|
|
52
|
+
aria-label={translations.progress}
|
|
51
53
|
></progress>
|
|
52
54
|
</div>
|
|
53
55
|
{/if}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { tick } from 'svelte';
|
|
2
3
|
import type { I18nProvider } from '@pie-qti/i18n';
|
|
3
4
|
|
|
4
5
|
interface Section {
|
|
@@ -18,9 +19,50 @@
|
|
|
18
19
|
const { sections, currentSectionIndex, i18n, onSectionSelect, disabled = false }: Props = $props();
|
|
19
20
|
|
|
20
21
|
let isOpen = $state(false);
|
|
22
|
+
let toggleButton = $state<HTMLButtonElement | null>(null);
|
|
23
|
+
let dropdownContent = $state<HTMLDivElement | null>(null);
|
|
24
|
+
const menuId = 'assessment-section-menu';
|
|
25
|
+
|
|
26
|
+
async function openMenu() {
|
|
27
|
+
if (disabled) return;
|
|
28
|
+
isOpen = true;
|
|
29
|
+
await tick();
|
|
30
|
+
const active = dropdownContent?.querySelector<HTMLButtonElement>('.section-item.active');
|
|
31
|
+
const first = dropdownContent?.querySelector<HTMLButtonElement>('.section-item:not(:disabled)');
|
|
32
|
+
(active ?? first)?.focus();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function closeMenu({ restoreFocus = true } = {}) {
|
|
36
|
+
isOpen = false;
|
|
37
|
+
if (restoreFocus) {
|
|
38
|
+
toggleButton?.focus();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
21
41
|
|
|
22
42
|
function toggleMenu() {
|
|
23
|
-
isOpen
|
|
43
|
+
if (isOpen) {
|
|
44
|
+
closeMenu();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
void openMenu();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function handleMenuKeydown(event: KeyboardEvent) {
|
|
51
|
+
if (event.key === 'Escape') {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
closeMenu();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleToggleKeydown(event: KeyboardEvent) {
|
|
58
|
+
if (event.key === 'ArrowDown') {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
void openMenu();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function handleBackdropClick() {
|
|
65
|
+
closeMenu();
|
|
24
66
|
}
|
|
25
67
|
|
|
26
68
|
function selectSection(sectionIndex: number) {
|
|
@@ -28,13 +70,22 @@
|
|
|
28
70
|
if (onSectionSelect) {
|
|
29
71
|
onSectionSelect(sectionIndex);
|
|
30
72
|
}
|
|
31
|
-
|
|
73
|
+
closeMenu();
|
|
32
74
|
}
|
|
33
75
|
</script>
|
|
34
76
|
|
|
35
77
|
{#if sections.length > 1}
|
|
36
78
|
<div class="section-menu">
|
|
37
|
-
<button
|
|
79
|
+
<button
|
|
80
|
+
bind:this={toggleButton}
|
|
81
|
+
class="btn btn-outline btn-sm"
|
|
82
|
+
type="button"
|
|
83
|
+
aria-expanded={isOpen}
|
|
84
|
+
aria-controls={menuId}
|
|
85
|
+
onclick={() => toggleMenu?.()}
|
|
86
|
+
onkeydown={handleToggleKeydown}
|
|
87
|
+
disabled={disabled}
|
|
88
|
+
>
|
|
38
89
|
<svg
|
|
39
90
|
xmlns="http://www.w3.org/2000/svg"
|
|
40
91
|
class="h-5 w-5"
|
|
@@ -54,12 +105,23 @@
|
|
|
54
105
|
|
|
55
106
|
{#if isOpen}
|
|
56
107
|
<div class="section-dropdown">
|
|
57
|
-
<div
|
|
108
|
+
<div
|
|
109
|
+
bind:this={dropdownContent}
|
|
110
|
+
id={menuId}
|
|
111
|
+
class="section-dropdown-content"
|
|
112
|
+
role="menu"
|
|
113
|
+
tabindex="-1"
|
|
114
|
+
aria-label={i18n?.t('assessment.sections.title') ?? 'Sections'}
|
|
115
|
+
onkeydown={handleMenuKeydown}
|
|
116
|
+
>
|
|
58
117
|
<div class="section-list">
|
|
59
118
|
{#each sections as section}
|
|
60
119
|
<button
|
|
61
120
|
class="section-item"
|
|
62
121
|
class:active={currentSectionIndex === section.index}
|
|
122
|
+
type="button"
|
|
123
|
+
role="menuitemradio"
|
|
124
|
+
aria-checked={currentSectionIndex === section.index}
|
|
63
125
|
onclick={() => selectSection(section.index)}
|
|
64
126
|
disabled={disabled}
|
|
65
127
|
>
|
|
@@ -103,7 +165,12 @@
|
|
|
103
165
|
{/each}
|
|
104
166
|
</div>
|
|
105
167
|
</div>
|
|
106
|
-
<button
|
|
168
|
+
<button
|
|
169
|
+
class="section-backdrop"
|
|
170
|
+
type="button"
|
|
171
|
+
onclick={handleBackdropClick}
|
|
172
|
+
aria-label={i18n?.t('assessment.closeMenu') ?? 'Close menu'}
|
|
173
|
+
></button>
|
|
107
174
|
</div>
|
|
108
175
|
{/if}
|
|
109
176
|
</div>
|
package/src/components/index.ts
CHANGED