@pie-qti/assessment-player 0.1.9 → 0.1.11
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 +22 -82
- package/dist/core/AssessmentPlayer.d.ts +3 -8
- package/dist/core/AssessmentPlayer.js +61 -170
- package/dist/core/AssessmentPlayer.js.map +1 -0
- package/dist/core/AssessmentSessionCoordinator.d.ts +50 -0
- package/dist/core/AssessmentSessionCoordinator.js +216 -0
- package/dist/core/AssessmentSessionCoordinator.js.map +1 -0
- package/dist/core/ItemSessionController.d.ts +0 -1
- package/dist/core/ItemSessionController.js +1 -0
- package/dist/core/ItemSessionController.js.map +1 -0
- package/dist/core/NavigationManager.d.ts +0 -1
- package/dist/core/NavigationManager.js +1 -0
- package/dist/core/NavigationManager.js.map +1 -0
- package/dist/core/StatePersistenceManager.d.ts +0 -1
- package/dist/core/StatePersistenceManager.js +1 -0
- package/dist/core/StatePersistenceManager.js.map +1 -0
- package/dist/core/TimeManager.d.ts +0 -1
- package/dist/core/TimeManager.js +1 -0
- package/dist/core/TimeManager.js.map +1 -0
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -0
- package/dist/integration/ReferenceBackendAdapter.d.ts +0 -1
- package/dist/integration/ReferenceBackendAdapter.js +1 -0
- package/dist/integration/ReferenceBackendAdapter.js.map +1 -0
- package/dist/integration/api-contract.d.ts +0 -1
- package/dist/integration/api-contract.js +1 -0
- package/dist/integration/api-contract.js.map +1 -0
- package/dist/integration/assessment-item-scorer.d.ts +0 -1
- package/dist/integration/assessment-item-scorer.js +1 -0
- package/dist/integration/assessment-item-scorer.js.map +1 -0
- package/dist/integration/index.d.ts +0 -1
- package/dist/integration/index.js +1 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/PerformanceMonitor.d.ts +0 -1
- package/dist/utils/PerformanceMonitor.js +1 -0
- package/dist/utils/PerformanceMonitor.js.map +1 -0
- package/package.json +8 -36
- package/dist/core/AssessmentPlayer.d.ts.map +0 -1
- package/dist/core/ItemSessionController.d.ts.map +0 -1
- package/dist/core/NavigationManager.d.ts.map +0 -1
- package/dist/core/StatePersistenceManager.d.ts.map +0 -1
- package/dist/core/TimeManager.d.ts.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/integration/ReferenceBackendAdapter.d.ts.map +0 -1
- package/dist/integration/api-contract.d.ts.map +0 -1
- package/dist/integration/assessment-item-scorer.d.ts.map +0 -1
- package/dist/integration/index.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/PerformanceMonitor.d.ts.map +0 -1
- package/src/ambient.d.ts +0 -55
- package/src/components/AccessibilityAnnouncer.svelte +0 -113
- package/src/components/AssessmentHeader.svelte +0 -76
- package/src/components/AssessmentShell.svelte +0 -468
- package/src/components/AssessmentTimer.svelte +0 -251
- package/src/components/ItemRenderer.svelte +0 -157
- package/src/components/ItemSessionInfo.svelte +0 -241
- package/src/components/NavigationBar.svelte +0 -146
- package/src/components/RubricDisplay.svelte +0 -185
- package/src/components/SectionMenu.svelte +0 -273
- package/src/components/SplitPaneResizer.svelte +0 -288
- package/src/components/TestFeedback.svelte +0 -147
- package/src/components/index.ts +0 -19
- package/src/core/AssessmentPlayer.ts +0 -1059
- package/src/core/ItemSessionController.ts +0 -287
- package/src/core/NavigationManager.ts +0 -126
- package/src/core/StatePersistenceManager.ts +0 -344
- package/src/core/TimeManager.ts +0 -306
- package/src/core/index.ts +0 -15
- package/src/index.ts +0 -13
- package/src/integration/ReferenceBackendAdapter.ts +0 -1382
- package/src/integration/api-contract.ts +0 -480
- package/src/integration/assessment-item-scorer.ts +0 -58
- package/src/integration/index.ts +0 -77
- package/src/svelte-shims.d.ts +0 -7
- package/src/types/index.ts +0 -59
- package/src/utils/PerformanceMonitor.ts +0 -222
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount, tick, getContext } from 'svelte';
|
|
3
|
-
import type { SvelteI18nProvider } from '@pie-qti/i18n';
|
|
4
|
-
import type { BackendAssessmentPlayerConfig } from '../core/AssessmentPlayer.js';
|
|
5
|
-
import { AssessmentPlayer } from '../core/AssessmentPlayer.js';
|
|
6
|
-
import type { BackendAdapter, InitSessionRequest } from '../integration/api-contract.js';
|
|
7
|
-
import type { AssessmentResults, NavigationState } from '../types/index.js';
|
|
8
|
-
import AccessibilityAnnouncer from './AccessibilityAnnouncer.svelte';
|
|
9
|
-
import AssessmentHeader from './AssessmentHeader.svelte';
|
|
10
|
-
import ItemRenderer from './ItemRenderer.svelte';
|
|
11
|
-
import NavigationBar from './NavigationBar.svelte';
|
|
12
|
-
import RubricDisplay from './RubricDisplay.svelte';
|
|
13
|
-
import SplitPaneResizer from './SplitPaneResizer.svelte';
|
|
14
|
-
import TestFeedback from './TestFeedback.svelte';
|
|
15
|
-
|
|
16
|
-
interface Props {
|
|
17
|
-
backend: BackendAdapter;
|
|
18
|
-
initSession: InitSessionRequest;
|
|
19
|
-
config?: Partial<BackendAssessmentPlayerConfig>;
|
|
20
|
-
/**
|
|
21
|
-
* Called after a successful submit (with results).
|
|
22
|
-
* Note: `config.onComplete` is invoked by `AssessmentPlayer.submit()` already.
|
|
23
|
-
*/
|
|
24
|
-
onSubmit?: (results: AssessmentResults) => void;
|
|
25
|
-
/** Math typesetting function (KaTeX, MathJax, etc.) */
|
|
26
|
-
typeset?: (root: HTMLElement) => void | Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const { backend, initSession, config = {}, onSubmit, typeset }: Props = $props();
|
|
30
|
-
|
|
31
|
-
// Get i18n from context (set by +layout.svelte)
|
|
32
|
-
const contextI18nWrapper = getContext<{ value: SvelteI18nProvider | null } | undefined>('i18n');
|
|
33
|
-
const contextI18n = $derived(contextI18nWrapper?.value);
|
|
34
|
-
|
|
35
|
-
let player = $state<AssessmentPlayer | null>(null);
|
|
36
|
-
const i18n = $derived(player?.getI18nProvider() ?? contextI18n);
|
|
37
|
-
let navState = $state<NavigationState>({
|
|
38
|
-
currentIndex: -1,
|
|
39
|
-
totalItems: 0,
|
|
40
|
-
canNext: false,
|
|
41
|
-
canPrevious: false,
|
|
42
|
-
isLoading: false,
|
|
43
|
-
currentSection: undefined,
|
|
44
|
-
totalSections: undefined,
|
|
45
|
-
});
|
|
46
|
-
let currentItem = $state<any>(null);
|
|
47
|
-
let currentRubricBlocks = $state<any[]>([]);
|
|
48
|
-
let currentResponses = $state<Record<string, unknown>>({});
|
|
49
|
-
let sections = $state<any[]>([]);
|
|
50
|
-
let error = $state<string | null>(null);
|
|
51
|
-
let navError = $state<string | null>(null);
|
|
52
|
-
let itemPaneEl = $state<HTMLDivElement | null>(null);
|
|
53
|
-
let rootEl = $state<HTMLElement | null>(null);
|
|
54
|
-
let testFeedback = $state<Array<{ identifier: string; content: string; access: string }>>([]);
|
|
55
|
-
let isComplete = $state(false);
|
|
56
|
-
let initTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
57
|
-
let hasFirstItem = $state(false);
|
|
58
|
-
let announcer = $state<AccessibilityAnnouncer | null>(null);
|
|
59
|
-
|
|
60
|
-
const passageBlocks = $derived(currentRubricBlocks.filter((b) => b?.use === 'passage'));
|
|
61
|
-
const nonPassageRubricBlocks = $derived(currentRubricBlocks.filter((b) => b?.use !== 'passage'));
|
|
62
|
-
const hasPassage = $derived(passageBlocks.length > 0);
|
|
63
|
-
|
|
64
|
-
// Initialize player
|
|
65
|
-
onMount(() => {
|
|
66
|
-
// Never allow infinite "Loading assessment..." state
|
|
67
|
-
initTimeout = setTimeout(() => {
|
|
68
|
-
if (!hasFirstItem && !error) {
|
|
69
|
-
error = contextI18n?.t('assessment.loadingError') ?? 'assessment.loadingError';
|
|
70
|
-
announcer?.announce(error, 3000, 'assertive');
|
|
71
|
-
}
|
|
72
|
-
}, 10000);
|
|
73
|
-
|
|
74
|
-
const playerConfig: BackendAssessmentPlayerConfig = {
|
|
75
|
-
backend,
|
|
76
|
-
initSession,
|
|
77
|
-
showSections: config.showSections !== false,
|
|
78
|
-
allowSectionNavigation: config.allowSectionNavigation !== false,
|
|
79
|
-
showProgress: config.showProgress !== false,
|
|
80
|
-
i18nProvider: contextI18n, // Pass i18n from context
|
|
81
|
-
...config,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
(async () => {
|
|
85
|
-
player = await AssessmentPlayer.create(playerConfig);
|
|
86
|
-
|
|
87
|
-
// Get sections
|
|
88
|
-
sections = player.getAllSections();
|
|
89
|
-
|
|
90
|
-
// Set up event listeners
|
|
91
|
-
player.onItemChange(async () => {
|
|
92
|
-
updateState();
|
|
93
|
-
navError = null;
|
|
94
|
-
hasFirstItem = true;
|
|
95
|
-
if (initTimeout) {
|
|
96
|
-
clearTimeout(initTimeout);
|
|
97
|
-
initTimeout = null;
|
|
98
|
-
}
|
|
99
|
-
await tick();
|
|
100
|
-
itemPaneEl?.scrollTo({ top: 0, behavior: 'auto' });
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
player.onSectionChange(() => {
|
|
104
|
-
updateState();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
player.onResponseChange((responses) => {
|
|
108
|
-
currentResponses = responses;
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// If backend did not restore a current item, start at index 0.
|
|
112
|
-
if (player.getNavigationState().currentIndex < 0) {
|
|
113
|
-
await player.navigateTo(0);
|
|
114
|
-
} else {
|
|
115
|
-
updateState();
|
|
116
|
-
hasFirstItem = true;
|
|
117
|
-
if (initTimeout) {
|
|
118
|
-
clearTimeout(initTimeout);
|
|
119
|
-
initTimeout = null;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
})().catch((err) => {
|
|
123
|
-
console.error('Failed to initialize assessment player:', err);
|
|
124
|
-
error = err instanceof Error ? err.message : (contextI18n?.t('assessment.loadingError') ?? 'assessment.loadingError');
|
|
125
|
-
announcer?.announce(error, 3000, 'assertive');
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
return () => {
|
|
129
|
-
if (initTimeout) {
|
|
130
|
-
clearTimeout(initTimeout);
|
|
131
|
-
initTimeout = null;
|
|
132
|
-
}
|
|
133
|
-
if (player) {
|
|
134
|
-
player.destroy();
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
function updateState() {
|
|
140
|
-
if (!player) return;
|
|
141
|
-
|
|
142
|
-
navState = player.getNavigationState();
|
|
143
|
-
currentItem = player.getCurrentItem();
|
|
144
|
-
currentRubricBlocks = player.getCurrentRubricBlocks();
|
|
145
|
-
currentResponses = player.getResponses();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function handlePrevious() {
|
|
149
|
-
if (!player) return;
|
|
150
|
-
try {
|
|
151
|
-
navError = null;
|
|
152
|
-
await player.previous();
|
|
153
|
-
await manageFocusAfterNavigation();
|
|
154
|
-
announceCurrentQuestion();
|
|
155
|
-
} catch (err) {
|
|
156
|
-
console.error('Previous navigation failed:', err);
|
|
157
|
-
const message = err instanceof Error ? err.message : (i18n?.t('assessment.errors.navigationFailed') ?? 'assessment.errors.navigationFailed');
|
|
158
|
-
navError = message;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async function handleNext() {
|
|
163
|
-
if (!player) return;
|
|
164
|
-
try {
|
|
165
|
-
navError = null;
|
|
166
|
-
await player.next();
|
|
167
|
-
await manageFocusAfterNavigation();
|
|
168
|
-
announceCurrentQuestion();
|
|
169
|
-
} catch (err) {
|
|
170
|
-
console.error('Next navigation failed:', err);
|
|
171
|
-
const message = err instanceof Error ? err.message : (i18n?.t('assessment.errors.navigationFailed') ?? 'assessment.errors.navigationFailed');
|
|
172
|
-
navError = message;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Announce current question to screen readers
|
|
178
|
-
*/
|
|
179
|
-
function announceCurrentQuestion() {
|
|
180
|
-
if (!player) return;
|
|
181
|
-
const state = player.getNavigationState();
|
|
182
|
-
const msg = i18n?.t('assessment.questionAnnouncement', {
|
|
183
|
-
current: state.currentIndex + 1,
|
|
184
|
-
total: state.totalItems
|
|
185
|
-
}) ?? `assessment.questionAnnouncement (${state.currentIndex + 1}/${state.totalItems})`;
|
|
186
|
-
announcer?.announce(msg, 1500);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async function handleSectionSelect(sectionIndex: number) {
|
|
190
|
-
if (!player || !sections[sectionIndex]) return;
|
|
191
|
-
|
|
192
|
-
const section = sections[sectionIndex];
|
|
193
|
-
await player.navigateToSection(section.id);
|
|
194
|
-
await manageFocusAfterNavigation();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Manage focus after navigation to improve accessibility.
|
|
199
|
-
* Moves focus to the content area so screen reader users are aware of the content change.
|
|
200
|
-
*/
|
|
201
|
-
async function manageFocusAfterNavigation() {
|
|
202
|
-
await tick(); // Wait for DOM updates
|
|
203
|
-
|
|
204
|
-
// Try to focus on the item pane (for split pane layout)
|
|
205
|
-
if (itemPaneEl) {
|
|
206
|
-
itemPaneEl.focus();
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Otherwise focus on the content area
|
|
211
|
-
const contentEl = document.querySelector('.assessment-content') as HTMLElement;
|
|
212
|
-
if (contentEl) {
|
|
213
|
-
contentEl.focus();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
async function handleSubmit() {
|
|
218
|
-
if (!player) return;
|
|
219
|
-
|
|
220
|
-
try {
|
|
221
|
-
const results = await player.submit();
|
|
222
|
-
console.log('Assessment results:', results);
|
|
223
|
-
|
|
224
|
-
// Get test feedback based on outcomes
|
|
225
|
-
testFeedback = player.getVisibleFeedback();
|
|
226
|
-
isComplete = true;
|
|
227
|
-
|
|
228
|
-
onSubmit?.(results);
|
|
229
|
-
|
|
230
|
-
// Could also emit a custom event here
|
|
231
|
-
// Or show results modal
|
|
232
|
-
} catch (err) {
|
|
233
|
-
console.error('Failed to submit assessment:', err);
|
|
234
|
-
const message = err instanceof Error ? err.message : (i18n?.t('assessment.errors.submitFailed') ?? 'assessment.errors.submitFailed');
|
|
235
|
-
error = message;
|
|
236
|
-
announcer?.announce(message, 3000, 'assertive');
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function handleResponseChange(responseId: string, value: unknown) {
|
|
241
|
-
if (!player) return;
|
|
242
|
-
if (currentItem?.identifier) {
|
|
243
|
-
player.updateResponseForItem(currentItem.identifier, responseId, value);
|
|
244
|
-
} else {
|
|
245
|
-
player.updateResponse(responseId, value);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Imperative API (useful for embedding in host frameworks / custom elements)
|
|
251
|
-
*/
|
|
252
|
-
export async function next() {
|
|
253
|
-
return player?.next();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export async function previous() {
|
|
257
|
-
return player?.previous();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export async function navigateTo(index: number) {
|
|
261
|
-
return player?.navigateTo(index);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export async function navigateToSection(sectionIdentifier: string) {
|
|
265
|
-
return player?.navigateToSection(sectionIdentifier);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export async function submit() {
|
|
269
|
-
return player?.submit();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export function getResponses() {
|
|
273
|
-
return player?.getResponses();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export function getState() {
|
|
277
|
-
return player?.getState();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export function restoreState(state: any) {
|
|
281
|
-
return player?.restoreState(state);
|
|
282
|
-
}
|
|
283
|
-
</script>
|
|
284
|
-
|
|
285
|
-
<!-- Accessibility announcer for screen readers -->
|
|
286
|
-
<AccessibilityAnnouncer bind:this={announcer} />
|
|
287
|
-
|
|
288
|
-
{#if error}
|
|
289
|
-
<div class="assessment-error">
|
|
290
|
-
<div class="alert alert-error" role="alert" aria-live="assertive">
|
|
291
|
-
<svg
|
|
292
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
293
|
-
class="stroke-current shrink-0 h-6 w-6"
|
|
294
|
-
fill="none"
|
|
295
|
-
viewBox="0 0 24 24"
|
|
296
|
-
>
|
|
297
|
-
<path
|
|
298
|
-
stroke-linecap="round"
|
|
299
|
-
stroke-linejoin="round"
|
|
300
|
-
stroke-width="2"
|
|
301
|
-
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
302
|
-
/>
|
|
303
|
-
</svg>
|
|
304
|
-
<span>{error}</span>
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
{:else if !player || navState.currentIndex < 0}
|
|
308
|
-
<div class="assessment-loading">
|
|
309
|
-
<div class="flex items-center justify-center p-8" role="status" aria-live="polite">
|
|
310
|
-
<span class="loading loading-spinner loading-lg"></span>
|
|
311
|
-
<span class="ml-4">{contextI18n?.t('assessment.loading') ?? 'assessment.loading'}</span>
|
|
312
|
-
</div>
|
|
313
|
-
</div>
|
|
314
|
-
{:else}
|
|
315
|
-
<div bind:this={rootEl} class="assessment-shell" role="region" aria-label="Assessment player">
|
|
316
|
-
<!-- Header with title and section menu -->
|
|
317
|
-
<AssessmentHeader
|
|
318
|
-
title={initSession.assessmentId || (i18n?.t('assessment.title') ?? 'Assessment')}
|
|
319
|
-
{sections}
|
|
320
|
-
currentSectionIndex={navState.currentSection?.index}
|
|
321
|
-
showSections={config.showSections}
|
|
322
|
-
allowSectionNavigation={config.allowSectionNavigation}
|
|
323
|
-
onSectionSelect={handleSectionSelect}
|
|
324
|
-
/>
|
|
325
|
-
|
|
326
|
-
<!-- Test Feedback (shown after completion) -->
|
|
327
|
-
{#if isComplete && testFeedback.length > 0}
|
|
328
|
-
<TestFeedback feedback={testFeedback} />
|
|
329
|
-
{/if}
|
|
330
|
-
|
|
331
|
-
{#if navError}
|
|
332
|
-
<div class="assessment-nav-error">
|
|
333
|
-
<div class="alert alert-warning" role="alert" aria-live="assertive">
|
|
334
|
-
<svg
|
|
335
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
336
|
-
class="stroke-current shrink-0 h-6 w-6"
|
|
337
|
-
fill="none"
|
|
338
|
-
viewBox="0 0 24 24"
|
|
339
|
-
>
|
|
340
|
-
<path
|
|
341
|
-
stroke-linecap="round"
|
|
342
|
-
stroke-linejoin="round"
|
|
343
|
-
stroke-width="2"
|
|
344
|
-
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
345
|
-
/>
|
|
346
|
-
</svg>
|
|
347
|
-
<span>{navError}</span>
|
|
348
|
-
</div>
|
|
349
|
-
</div>
|
|
350
|
-
{/if}
|
|
351
|
-
|
|
352
|
-
<!-- Main content area -->
|
|
353
|
-
<div
|
|
354
|
-
class:has-passage={hasPassage}
|
|
355
|
-
class="assessment-content"
|
|
356
|
-
tabindex="-1"
|
|
357
|
-
role="region"
|
|
358
|
-
aria-label={i18n?.t('accessibility.itemBody') ?? 'Question content'}
|
|
359
|
-
>
|
|
360
|
-
{#if hasPassage}
|
|
361
|
-
<SplitPaneResizer
|
|
362
|
-
leftContent={passageBlocks}
|
|
363
|
-
{typeset}
|
|
364
|
-
storageKey="pie-qti22-assessment-player.splitLeftPct"
|
|
365
|
-
onRightPaneReady={(el) => itemPaneEl = el}
|
|
366
|
-
>
|
|
367
|
-
{#if nonPassageRubricBlocks.length > 0}
|
|
368
|
-
<RubricDisplay blocks={nonPassageRubricBlocks} {typeset} />
|
|
369
|
-
{/if}
|
|
370
|
-
|
|
371
|
-
{#if currentItem}
|
|
372
|
-
<ItemRenderer
|
|
373
|
-
itemRef={currentItem}
|
|
374
|
-
responses={currentResponses}
|
|
375
|
-
role={config.role || 'candidate'}
|
|
376
|
-
extendedTextEditor={config.extendedTextEditor || 'tiptap'}
|
|
377
|
-
onResponseChange={handleResponseChange}
|
|
378
|
-
{typeset}
|
|
379
|
-
{i18n}
|
|
380
|
-
security={config.security}
|
|
381
|
-
pnp={config.pnp}
|
|
382
|
-
/>
|
|
383
|
-
{/if}
|
|
384
|
-
</SplitPaneResizer>
|
|
385
|
-
{:else}
|
|
386
|
-
<!-- Rubric blocks (passages, instructions) -->
|
|
387
|
-
{#if currentRubricBlocks.length > 0}
|
|
388
|
-
<RubricDisplay blocks={currentRubricBlocks} {typeset} />
|
|
389
|
-
{/if}
|
|
390
|
-
|
|
391
|
-
<!-- Current item -->
|
|
392
|
-
{#if currentItem}
|
|
393
|
-
<ItemRenderer
|
|
394
|
-
itemRef={currentItem}
|
|
395
|
-
responses={currentResponses}
|
|
396
|
-
role={config.role || 'candidate'}
|
|
397
|
-
onResponseChange={handleResponseChange}
|
|
398
|
-
{typeset}
|
|
399
|
-
{i18n}
|
|
400
|
-
security={config.security}
|
|
401
|
-
pnp={config.pnp}
|
|
402
|
-
/>
|
|
403
|
-
{/if}
|
|
404
|
-
{/if}
|
|
405
|
-
</div>
|
|
406
|
-
|
|
407
|
-
<!-- Navigation bar -->
|
|
408
|
-
{#if i18n}
|
|
409
|
-
<NavigationBar
|
|
410
|
-
navState={navState}
|
|
411
|
-
{i18n}
|
|
412
|
-
onPrevious={handlePrevious}
|
|
413
|
-
onNext={handleNext}
|
|
414
|
-
onSubmit={handleSubmit}
|
|
415
|
-
showProgress={config.showProgress !== false}
|
|
416
|
-
/>
|
|
417
|
-
{/if}
|
|
418
|
-
</div>
|
|
419
|
-
{/if}
|
|
420
|
-
|
|
421
|
-
<style>
|
|
422
|
-
.assessment-shell {
|
|
423
|
-
display: flex;
|
|
424
|
-
flex-direction: column;
|
|
425
|
-
height: 100vh;
|
|
426
|
-
overflow: hidden;
|
|
427
|
-
background: var(--color-base-100);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
.assessment-content {
|
|
431
|
-
flex: 1;
|
|
432
|
-
padding: 2rem;
|
|
433
|
-
max-width: 1200px;
|
|
434
|
-
margin: 0 auto;
|
|
435
|
-
width: 100%;
|
|
436
|
-
overflow: auto;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
.assessment-content:focus {
|
|
440
|
-
outline: 2px solid var(--color-primary);
|
|
441
|
-
outline-offset: -2px;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
.assessment-content.has-passage {
|
|
445
|
-
padding: 0;
|
|
446
|
-
max-width: none;
|
|
447
|
-
overflow: hidden;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
.assessment-error,
|
|
451
|
-
.assessment-loading {
|
|
452
|
-
padding: 2rem;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
.assessment-nav-error {
|
|
456
|
-
padding: 1rem 2rem 0;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
@media (max-width: 768px) {
|
|
460
|
-
.assessment-content {
|
|
461
|
-
padding: 1rem;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.assessment-content.has-passage {
|
|
465
|
-
padding: 0;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
</style>
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { AssessmentPlayer } from '../core/AssessmentPlayer.js';
|
|
3
|
-
import type { I18nProvider } from '@pie-qti/i18n';
|
|
4
|
-
import { TimeManager } from '../core/TimeManager.js';
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
player: AssessmentPlayer;
|
|
8
|
-
i18n?: I18nProvider;
|
|
9
|
-
/** Show timer even when no time limit */
|
|
10
|
-
showElapsed?: boolean;
|
|
11
|
-
/** Position of timer */
|
|
12
|
-
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let { player, i18n, showElapsed = false, position = 'top-right' }: Props = $props();
|
|
16
|
-
|
|
17
|
-
// State
|
|
18
|
-
let remainingSeconds = $state<number | null>(null);
|
|
19
|
-
let elapsedSeconds = $state(0);
|
|
20
|
-
let isWarning = $state(false);
|
|
21
|
-
let isExpired = $state(false);
|
|
22
|
-
let announcement = $state('');
|
|
23
|
-
let announcementPriority = $state<'polite' | 'assertive'>('polite');
|
|
24
|
-
|
|
25
|
-
// Initialize state and subscribe to timer events
|
|
26
|
-
$effect(() => {
|
|
27
|
-
// Initialize from player
|
|
28
|
-
remainingSeconds = player.getRemainingTime();
|
|
29
|
-
elapsedSeconds = player.getElapsedTime();
|
|
30
|
-
isExpired = player.isTimeExpired();
|
|
31
|
-
|
|
32
|
-
// Subscribe to timer events
|
|
33
|
-
const unsubscribeWarning = player.onTimeWarning((remaining) => {
|
|
34
|
-
isWarning = true;
|
|
35
|
-
remainingSeconds = remaining;
|
|
36
|
-
announcementPriority = 'polite';
|
|
37
|
-
announcement =
|
|
38
|
-
i18n?.t('assessment.timer.timeRemaining', { time: TimeManager.formatTime(remaining) }) ??
|
|
39
|
-
`Time remaining: ${TimeManager.formatTime(remaining)}`;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const unsubscribeExpired = player.onTimeExpired(() => {
|
|
43
|
-
isExpired = true;
|
|
44
|
-
remainingSeconds = 0;
|
|
45
|
-
announcementPriority = 'assertive';
|
|
46
|
-
announcement = i18n?.t('assessment.timer.expired') ?? 'Time expired';
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const unsubscribeTick = player.onTimeTick((remaining, elapsed) => {
|
|
50
|
-
remainingSeconds = remaining;
|
|
51
|
-
elapsedSeconds = elapsed;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Cleanup subscriptions when effect reruns or component unmounts
|
|
55
|
-
return () => {
|
|
56
|
-
unsubscribeWarning?.();
|
|
57
|
-
unsubscribeExpired?.();
|
|
58
|
-
unsubscribeTick?.();
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Derived values
|
|
63
|
-
const displayTime = $derived(() => {
|
|
64
|
-
if (remainingSeconds !== null && remainingSeconds >= 0) {
|
|
65
|
-
return TimeManager.formatTime(remainingSeconds);
|
|
66
|
-
}
|
|
67
|
-
if (showElapsed) {
|
|
68
|
-
return TimeManager.formatTime(elapsedSeconds);
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const timerLabel = $derived(() => {
|
|
74
|
-
if (remainingSeconds !== null) {
|
|
75
|
-
return isExpired
|
|
76
|
-
? (i18n?.t('assessment.timer.expired') ?? 'assessment.timer.expired')
|
|
77
|
-
: (i18n?.t('assessment.timer.remaining') ?? 'assessment.timer.remaining');
|
|
78
|
-
}
|
|
79
|
-
if (showElapsed) {
|
|
80
|
-
return i18n?.t('assessment.timer.elapsed') ?? 'assessment.timer.elapsed';
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Position classes
|
|
86
|
-
const positionClasses = {
|
|
87
|
-
'top-right': 'top-4 right-4',
|
|
88
|
-
'top-left': 'top-4 left-4',
|
|
89
|
-
'bottom-right': 'bottom-4 right-4',
|
|
90
|
-
'bottom-left': 'bottom-4 left-4',
|
|
91
|
-
};
|
|
92
|
-
</script>
|
|
93
|
-
|
|
94
|
-
{#if displayTime()}
|
|
95
|
-
<div
|
|
96
|
-
class="assessment-timer {positionClasses[position]}"
|
|
97
|
-
class:warning={isWarning && !isExpired}
|
|
98
|
-
class:expired={isExpired}
|
|
99
|
-
role="timer"
|
|
100
|
-
aria-live="polite"
|
|
101
|
-
aria-atomic="true"
|
|
102
|
-
aria-label="{timerLabel()}: {displayTime()}"
|
|
103
|
-
>
|
|
104
|
-
<div class="timer-icon" aria-hidden="true">
|
|
105
|
-
{#if isExpired}
|
|
106
|
-
⏰
|
|
107
|
-
{:else if isWarning}
|
|
108
|
-
⏱️
|
|
109
|
-
{:else}
|
|
110
|
-
🕒
|
|
111
|
-
{/if}
|
|
112
|
-
</div>
|
|
113
|
-
<div class="timer-content">
|
|
114
|
-
<div class="timer-label">{timerLabel()}</div>
|
|
115
|
-
<div class="timer-value">{displayTime()}</div>
|
|
116
|
-
</div>
|
|
117
|
-
<div class="sr-only" role={announcementPriority === 'assertive' ? 'alert' : 'status'} aria-live={announcementPriority} aria-atomic="true">
|
|
118
|
-
{announcement}
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
{/if}
|
|
122
|
-
|
|
123
|
-
<style>
|
|
124
|
-
.assessment-timer {
|
|
125
|
-
position: fixed;
|
|
126
|
-
z-index: 1000;
|
|
127
|
-
background: hsl(var(--b1));
|
|
128
|
-
border: 2px solid hsl(var(--bc) / 0.2);
|
|
129
|
-
border-radius: 0.5rem;
|
|
130
|
-
padding: 0.75rem 1rem;
|
|
131
|
-
display: flex;
|
|
132
|
-
align-items: center;
|
|
133
|
-
gap: 0.75rem;
|
|
134
|
-
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
|
135
|
-
transition: all 0.3s ease;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.assessment-timer.warning {
|
|
139
|
-
background: hsl(var(--wa) / 0.1);
|
|
140
|
-
border-color: hsl(var(--wa));
|
|
141
|
-
animation: pulse-warning 2s ease-in-out infinite;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.assessment-timer.expired {
|
|
145
|
-
background: hsl(var(--er) / 0.1);
|
|
146
|
-
border-color: hsl(var(--er));
|
|
147
|
-
animation: pulse-error 1s ease-in-out infinite;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.timer-icon {
|
|
151
|
-
font-size: 1.5rem;
|
|
152
|
-
line-height: 1;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.timer-content {
|
|
156
|
-
display: flex;
|
|
157
|
-
flex-direction: column;
|
|
158
|
-
gap: 0.125rem;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.timer-label {
|
|
162
|
-
font-size: 0.75rem;
|
|
163
|
-
font-weight: 600;
|
|
164
|
-
text-transform: uppercase;
|
|
165
|
-
letter-spacing: 0.05em;
|
|
166
|
-
color: hsl(var(--bc) / 0.6);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.assessment-timer.warning .timer-label {
|
|
170
|
-
color: hsl(var(--wa));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.assessment-timer.expired .timer-label {
|
|
174
|
-
color: hsl(var(--er));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.timer-value {
|
|
178
|
-
font-size: 1.25rem;
|
|
179
|
-
font-weight: 700;
|
|
180
|
-
font-variant-numeric: tabular-nums;
|
|
181
|
-
color: hsl(var(--bc));
|
|
182
|
-
}
|
|
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
|
-
|
|
196
|
-
.assessment-timer.warning .timer-value {
|
|
197
|
-
color: hsl(var(--wa));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.assessment-timer.expired .timer-value {
|
|
201
|
-
color: hsl(var(--er));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
@keyframes pulse-warning {
|
|
205
|
-
0%,
|
|
206
|
-
100% {
|
|
207
|
-
box-shadow:
|
|
208
|
-
0 4px 6px -1px rgb(0 0 0 / 0.1),
|
|
209
|
-
0 0 0 0 hsl(var(--wa) / 0.4);
|
|
210
|
-
}
|
|
211
|
-
50% {
|
|
212
|
-
box-shadow:
|
|
213
|
-
0 4px 6px -1px rgb(0 0 0 / 0.1),
|
|
214
|
-
0 0 0 8px hsl(var(--wa) / 0);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
@keyframes pulse-error {
|
|
219
|
-
0%,
|
|
220
|
-
100% {
|
|
221
|
-
box-shadow:
|
|
222
|
-
0 4px 6px -1px rgb(0 0 0 / 0.1),
|
|
223
|
-
0 0 0 0 hsl(var(--er) / 0.4);
|
|
224
|
-
}
|
|
225
|
-
50% {
|
|
226
|
-
box-shadow:
|
|
227
|
-
0 4px 6px -1px rgb(0 0 0 / 0.1),
|
|
228
|
-
0 0 0 8px hsl(var(--er) / 0);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/* Responsive adjustments */
|
|
233
|
-
@media (max-width: 640px) {
|
|
234
|
-
.assessment-timer {
|
|
235
|
-
padding: 0.5rem 0.75rem;
|
|
236
|
-
gap: 0.5rem;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.timer-icon {
|
|
240
|
-
font-size: 1.25rem;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.timer-label {
|
|
244
|
-
font-size: 0.625rem;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.timer-value {
|
|
248
|
-
font-size: 1rem;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
</style>
|