@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,157 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import { registerDefaultComponents } from '@pie-qti/default-components';
|
|
4
|
-
// @ts-expect-error - Svelte-check can't resolve workspace subpath exports, but runtime works correctly
|
|
5
|
-
import { ItemBody } from '@pie-qti/item-player/components';
|
|
6
|
-
import { Player, type PlayerSecurityConfig, type PnpProfile, type QTIRole } from '@pie-qti/item-player';
|
|
7
|
-
import type { InteractionResponseValue } from '@pie-qti/item-player/web-components';
|
|
8
|
-
import type { I18nProvider } from '@pie-qti/i18n';
|
|
9
|
-
import { onMount } from 'svelte';
|
|
10
|
-
import type { ItemRef } from '../types/index.js';
|
|
11
|
-
|
|
12
|
-
type ItemResponseValue = InteractionResponseValue | null;
|
|
13
|
-
type ItemResponseMap = Record<string, ItemResponseValue>;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Ensure default interaction web components are registered (browser-only).
|
|
17
|
-
*
|
|
18
|
-
* NOTE: `@pie-qti/default-components/plugins` has side effects (customElements.define),
|
|
19
|
-
* so we only load it on the client to remain SSR-safe.
|
|
20
|
-
*/
|
|
21
|
-
let pluginsLoadPromise: Promise<void> | null = null;
|
|
22
|
-
function ensureDefaultPluginsLoaded() {
|
|
23
|
-
if (pluginsLoadPromise) return pluginsLoadPromise;
|
|
24
|
-
pluginsLoadPromise = import('@pie-qti/default-components/plugins')
|
|
25
|
-
.then(() => {})
|
|
26
|
-
.catch((err) => {
|
|
27
|
-
console.warn('Failed to load default QTI web components:', err);
|
|
28
|
-
});
|
|
29
|
-
return pluginsLoadPromise;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
onMount(() => {
|
|
33
|
-
void ensureDefaultPluginsLoaded();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
interface Props {
|
|
37
|
-
itemRef: ItemRef;
|
|
38
|
-
role?: QTIRole;
|
|
39
|
-
extendedTextEditor?: string;
|
|
40
|
-
/** Responses for the current item (keyed by responseIdentifier). */
|
|
41
|
-
responses?: ItemResponseMap;
|
|
42
|
-
onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
|
|
43
|
-
/** Math typesetting function (KaTeX, MathJax, etc.) */
|
|
44
|
-
typeset?: (root: HTMLElement) => void | Promise<void>;
|
|
45
|
-
/** I18n provider for translations */
|
|
46
|
-
i18n?: I18nProvider;
|
|
47
|
-
/** Security configuration for URL policy and content restrictions */
|
|
48
|
-
security?: PlayerSecurityConfig;
|
|
49
|
-
/** QTI 3.0 Personal Needs and Preferences profile */
|
|
50
|
-
pnp?: PnpProfile;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const {
|
|
54
|
-
itemRef,
|
|
55
|
-
role = 'candidate',
|
|
56
|
-
extendedTextEditor: _extendedTextEditor,
|
|
57
|
-
responses = {},
|
|
58
|
-
onResponseChange,
|
|
59
|
-
typeset,
|
|
60
|
-
i18n,
|
|
61
|
-
security,
|
|
62
|
-
pnp,
|
|
63
|
-
}: Props = $props();
|
|
64
|
-
|
|
65
|
-
// Derive player from itemRef
|
|
66
|
-
let playerData = $derived.by(() => {
|
|
67
|
-
if (!itemRef.itemXml) {
|
|
68
|
-
return { player: null, error: 'No item XML provided' };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const newPlayer = new Player({
|
|
73
|
-
itemXml: itemRef.itemXml,
|
|
74
|
-
role,
|
|
75
|
-
security,
|
|
76
|
-
pnp,
|
|
77
|
-
deliveryContext: itemRef.deliveryContext,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// Ensure the item player can actually render interactions by registering the
|
|
81
|
-
// default component set into this player's component registry.
|
|
82
|
-
registerDefaultComponents(newPlayer.getComponentRegistry());
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
player: newPlayer,
|
|
86
|
-
error: null,
|
|
87
|
-
};
|
|
88
|
-
} catch (err) {
|
|
89
|
-
console.error('Failed to initialize item player:', err);
|
|
90
|
-
return {
|
|
91
|
-
player: null,
|
|
92
|
-
error: err instanceof Error ? err.message : (i18n?.t('item.loadingError') ?? 'Failed to load item'),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Handle response changes
|
|
98
|
-
function handleResponseChange(responseId: string, value: ItemResponseValue) {
|
|
99
|
-
onResponseChange?.(responseId, value);
|
|
100
|
-
}
|
|
101
|
-
</script>
|
|
102
|
-
|
|
103
|
-
{#if playerData.error}
|
|
104
|
-
<div class="alert alert-error">
|
|
105
|
-
<svg
|
|
106
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
107
|
-
class="stroke-current shrink-0 h-6 w-6"
|
|
108
|
-
fill="none"
|
|
109
|
-
viewBox="0 0 24 24"
|
|
110
|
-
>
|
|
111
|
-
<path
|
|
112
|
-
stroke-linecap="round"
|
|
113
|
-
stroke-linejoin="round"
|
|
114
|
-
stroke-width="2"
|
|
115
|
-
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
116
|
-
/>
|
|
117
|
-
</svg>
|
|
118
|
-
<span>{i18n?.t('item.loadError', 'Error loading item: {error}', { error: playerData.error })}</span>
|
|
119
|
-
</div>
|
|
120
|
-
{:else if !playerData.player}
|
|
121
|
-
<div class="flex items-center justify-center p-8">
|
|
122
|
-
<span class="loading loading-spinner loading-lg"></span>
|
|
123
|
-
<span class="ml-4">{i18n?.t('item.loading', 'Loading item...')}</span>
|
|
124
|
-
</div>
|
|
125
|
-
{:else}
|
|
126
|
-
<div class="item-container">
|
|
127
|
-
{#if itemRef.title}
|
|
128
|
-
<div class="item-header">
|
|
129
|
-
<h3 class="text-lg font-semibold mb-4">{itemRef.title}</h3>
|
|
130
|
-
</div>
|
|
131
|
-
{/if}
|
|
132
|
-
|
|
133
|
-
<div class="item-content">
|
|
134
|
-
<ItemBody
|
|
135
|
-
player={playerData.player}
|
|
136
|
-
{responses}
|
|
137
|
-
disabled={role !== 'candidate'}
|
|
138
|
-
{role}
|
|
139
|
-
{typeset}
|
|
140
|
-
{i18n}
|
|
141
|
-
deliveryContext={itemRef.deliveryContext}
|
|
142
|
-
onResponseChange={handleResponseChange}
|
|
143
|
-
/>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
{/if}
|
|
147
|
-
|
|
148
|
-
<style>
|
|
149
|
-
.item-container {
|
|
150
|
-
width: 100%;
|
|
151
|
-
padding: 1rem;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.item-content {
|
|
155
|
-
width: 100%;
|
|
156
|
-
}
|
|
157
|
-
</style>
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onDestroy, onMount } from 'svelte';
|
|
3
|
-
import type { SvelteI18nProvider } from '@pie-qti/i18n';
|
|
4
|
-
import type { AssessmentPlayer } from '../core/AssessmentPlayer.js';
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
player: AssessmentPlayer;
|
|
8
|
-
i18n: SvelteI18nProvider;
|
|
9
|
-
/** Where to position the info display */
|
|
10
|
-
position?: 'inline' | 'floating';
|
|
11
|
-
/** Show detailed information */
|
|
12
|
-
showDetails?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let { player, i18n, position = 'inline', showDetails = false }: Props = $props();
|
|
16
|
-
|
|
17
|
-
let sessionInfo = $state<{
|
|
18
|
-
canSubmit: boolean;
|
|
19
|
-
remainingAttempts: number | null;
|
|
20
|
-
attemptCount: number;
|
|
21
|
-
showFeedback: boolean;
|
|
22
|
-
showSolution: boolean;
|
|
23
|
-
canReview: boolean;
|
|
24
|
-
canSkip: boolean;
|
|
25
|
-
} | null>(null);
|
|
26
|
-
|
|
27
|
-
let unsubscribeItemChange: (() => void) | null = null;
|
|
28
|
-
let unsubscribeResponseChange: (() => void) | null = null;
|
|
29
|
-
|
|
30
|
-
function updateSessionInfo() {
|
|
31
|
-
sessionInfo = player.getItemSessionInfo();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onMount(() => {
|
|
35
|
-
updateSessionInfo();
|
|
36
|
-
|
|
37
|
-
// Update when item changes
|
|
38
|
-
unsubscribeItemChange = player.onItemChange(() => {
|
|
39
|
-
updateSessionInfo();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Update when responses change (affects attempt state)
|
|
43
|
-
unsubscribeResponseChange = player.onResponseChange(() => {
|
|
44
|
-
updateSessionInfo();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
onDestroy(() => {
|
|
49
|
-
unsubscribeItemChange?.();
|
|
50
|
-
unsubscribeResponseChange?.();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
let hasAttemptLimit = $derived(
|
|
54
|
-
sessionInfo?.remainingAttempts !== null && sessionInfo?.remainingAttempts !== undefined
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
let attemptsMessage = $derived(() => {
|
|
58
|
-
if (!sessionInfo || !hasAttemptLimit) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (sessionInfo.remainingAttempts === 0) {
|
|
63
|
-
return i18n.t('assessment.attempts.noRemaining', { count: sessionInfo.attemptCount });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (sessionInfo.remainingAttempts === 1) {
|
|
67
|
-
return i18n.t('assessment.attempts.oneRemaining');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return i18n.t('assessment.attempts.remaining', { count: sessionInfo.remainingAttempts });
|
|
71
|
-
});
|
|
72
|
-
</script>
|
|
73
|
-
|
|
74
|
-
{#if sessionInfo}
|
|
75
|
-
<div
|
|
76
|
-
class="item-session-info"
|
|
77
|
-
class:inline={position === 'inline'}
|
|
78
|
-
class:floating={position === 'floating'}
|
|
79
|
-
class:no-attempts={hasAttemptLimit && sessionInfo.remainingAttempts === 0}
|
|
80
|
-
class:low-attempts={hasAttemptLimit && sessionInfo.remainingAttempts === 1}
|
|
81
|
-
>
|
|
82
|
-
<!-- Attempt count indicator -->
|
|
83
|
-
{#if hasAttemptLimit}
|
|
84
|
-
<div class="session-badge" role="status" aria-live="polite">
|
|
85
|
-
<span class="badge-icon" aria-hidden="true">
|
|
86
|
-
{#if sessionInfo.remainingAttempts === 0}
|
|
87
|
-
🚫
|
|
88
|
-
{:else if sessionInfo.remainingAttempts === 1}
|
|
89
|
-
⚠️
|
|
90
|
-
{:else}
|
|
91
|
-
📝
|
|
92
|
-
{/if}
|
|
93
|
-
</span>
|
|
94
|
-
<span class="badge-text">{attemptsMessage()}</span>
|
|
95
|
-
</div>
|
|
96
|
-
{/if}
|
|
97
|
-
|
|
98
|
-
<!-- Detailed information -->
|
|
99
|
-
{#if showDetails}
|
|
100
|
-
<div class="session-details">
|
|
101
|
-
{#if sessionInfo.attemptCount > 0}
|
|
102
|
-
<div class="detail-item">
|
|
103
|
-
<span class="detail-label">{i18n.t('assessment.attempts.used', { count: sessionInfo.attemptCount })}</span>
|
|
104
|
-
</div>
|
|
105
|
-
{/if}
|
|
106
|
-
|
|
107
|
-
{#if !sessionInfo.canSubmit}
|
|
108
|
-
<div class="detail-item warning">
|
|
109
|
-
<span class="detail-label">{i18n.t('common.status')}:</span>
|
|
110
|
-
<span class="detail-value">{i18n.t('assessment.attempts.maxReached')}</span>
|
|
111
|
-
</div>
|
|
112
|
-
{/if}
|
|
113
|
-
|
|
114
|
-
{#if !sessionInfo.canSkip}
|
|
115
|
-
<div class="detail-item info">
|
|
116
|
-
<span class="detail-label">{i18n.t('common.required')}:</span>
|
|
117
|
-
<span class="detail-value">{i18n.t('assessment.attempts.required')}</span>
|
|
118
|
-
</div>
|
|
119
|
-
{/if}
|
|
120
|
-
|
|
121
|
-
{#if !sessionInfo.canReview}
|
|
122
|
-
<div class="detail-item info">
|
|
123
|
-
<span class="detail-label">{i18n.t('common.review')}:</span>
|
|
124
|
-
<span class="detail-value">{i18n.t('assessment.attempts.reviewNotAllowed')}</span>
|
|
125
|
-
</div>
|
|
126
|
-
{/if}
|
|
127
|
-
</div>
|
|
128
|
-
{/if}
|
|
129
|
-
</div>
|
|
130
|
-
{/if}
|
|
131
|
-
|
|
132
|
-
<style>
|
|
133
|
-
.item-session-info {
|
|
134
|
-
display: flex;
|
|
135
|
-
flex-direction: column;
|
|
136
|
-
gap: 0.5rem;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.item-session-info.inline {
|
|
140
|
-
padding: 0.75rem;
|
|
141
|
-
background: hsl(var(--b2));
|
|
142
|
-
border-radius: 0.5rem;
|
|
143
|
-
border: 1px solid hsl(var(--bc) / 0.1);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.item-session-info.floating {
|
|
147
|
-
position: fixed;
|
|
148
|
-
bottom: 1rem;
|
|
149
|
-
right: 1rem;
|
|
150
|
-
padding: 0.75rem 1rem;
|
|
151
|
-
background: hsl(var(--b1));
|
|
152
|
-
border-radius: 0.5rem;
|
|
153
|
-
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
|
154
|
-
z-index: 100;
|
|
155
|
-
border: 2px solid hsl(var(--bc) / 0.1);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.session-badge {
|
|
159
|
-
display: flex;
|
|
160
|
-
align-items: center;
|
|
161
|
-
gap: 0.5rem;
|
|
162
|
-
padding: 0.5rem 0.75rem;
|
|
163
|
-
background: hsl(var(--b1));
|
|
164
|
-
border-radius: 0.375rem;
|
|
165
|
-
border: 1px solid hsl(var(--bc) / 0.1);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.item-session-info.no-attempts .session-badge {
|
|
169
|
-
background: hsl(var(--er) / 0.1);
|
|
170
|
-
border-color: hsl(var(--er));
|
|
171
|
-
color: hsl(var(--er));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.item-session-info.low-attempts .session-badge {
|
|
175
|
-
background: hsl(var(--wa) / 0.1);
|
|
176
|
-
border-color: hsl(var(--wa));
|
|
177
|
-
color: hsl(var(--wa));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.badge-icon {
|
|
181
|
-
font-size: 1.25rem;
|
|
182
|
-
line-height: 1;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.badge-text {
|
|
186
|
-
font-size: 0.875rem;
|
|
187
|
-
font-weight: 600;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.session-details {
|
|
191
|
-
display: flex;
|
|
192
|
-
flex-direction: column;
|
|
193
|
-
gap: 0.375rem;
|
|
194
|
-
padding-top: 0.5rem;
|
|
195
|
-
border-top: 1px solid hsl(var(--bc) / 0.1);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.detail-item {
|
|
199
|
-
display: flex;
|
|
200
|
-
justify-content: space-between;
|
|
201
|
-
align-items: center;
|
|
202
|
-
font-size: 0.8125rem;
|
|
203
|
-
padding: 0.25rem 0;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.detail-label {
|
|
207
|
-
font-weight: 600;
|
|
208
|
-
color: hsl(var(--bc) / 0.7);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.detail-value {
|
|
212
|
-
color: hsl(var(--bc));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.detail-item.warning .detail-value {
|
|
216
|
-
color: hsl(var(--er));
|
|
217
|
-
font-weight: 600;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.detail-item.info .detail-value {
|
|
221
|
-
color: hsl(var(--in));
|
|
222
|
-
font-weight: 500;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
@media (max-width: 640px) {
|
|
226
|
-
.item-session-info.floating {
|
|
227
|
-
bottom: 0.5rem;
|
|
228
|
-
right: 0.5rem;
|
|
229
|
-
left: 0.5rem;
|
|
230
|
-
padding: 0.5rem 0.75rem;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.badge-text {
|
|
234
|
-
font-size: 0.8125rem;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.badge-icon {
|
|
238
|
-
font-size: 1.125rem;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
</style>
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { NavigationState } from '../types/index.js';
|
|
3
|
-
import type { SvelteI18nProvider } from '@pie-qti/i18n';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
navState: NavigationState;
|
|
7
|
-
i18n?: SvelteI18nProvider;
|
|
8
|
-
onPrevious?: () => void;
|
|
9
|
-
onNext?: () => void;
|
|
10
|
-
onSubmit?: () => void;
|
|
11
|
-
showProgress?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const { navState, i18n, onPrevious, onNext, onSubmit, showProgress = true }: Props = $props();
|
|
15
|
-
|
|
16
|
-
const progressPercentage = $derived(
|
|
17
|
-
navState.totalItems > 0 ? ((navState.currentIndex + 1) / navState.totalItems) * 100 : 0,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
// Simplified translations - no manual subscriptions needed
|
|
21
|
-
// Locale changes trigger page refresh, so reactivity is not required
|
|
22
|
-
const translations = $derived({
|
|
23
|
-
question: i18n?.t('assessment.question', { current: navState.currentIndex + 1, total: navState.totalItems })
|
|
24
|
-
?? `Question ${navState.currentIndex + 1} of ${navState.totalItems}`,
|
|
25
|
-
section: navState.currentSection
|
|
26
|
-
? (navState.currentSection.title ?? (i18n?.t('assessment.section', { current: navState.currentSection.index + 1, total: 0 })
|
|
27
|
-
?? `Section ${navState.currentSection.index + 1}`))
|
|
28
|
-
: null,
|
|
29
|
-
previous: i18n?.t('common.previous') ?? 'Previous',
|
|
30
|
-
next: i18n?.t('common.next') ?? 'Next',
|
|
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}`}`,
|
|
33
|
-
});
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<div class="navigation-bar">
|
|
37
|
-
<!-- Progress indicator -->
|
|
38
|
-
{#if showProgress}
|
|
39
|
-
<div class="progress-section">
|
|
40
|
-
<div class="progress-label text-sm">
|
|
41
|
-
{translations.question}
|
|
42
|
-
{#if translations.section}
|
|
43
|
-
<span class="text-base-content/60">
|
|
44
|
-
({translations.section})
|
|
45
|
-
</span>
|
|
46
|
-
{/if}
|
|
47
|
-
</div>
|
|
48
|
-
<progress
|
|
49
|
-
class="progress progress-primary w-full"
|
|
50
|
-
value={progressPercentage}
|
|
51
|
-
max="100"
|
|
52
|
-
aria-label={translations.progress}
|
|
53
|
-
></progress>
|
|
54
|
-
</div>
|
|
55
|
-
{/if}
|
|
56
|
-
|
|
57
|
-
<!-- Navigation buttons -->
|
|
58
|
-
<div class="navigation-buttons">
|
|
59
|
-
<button
|
|
60
|
-
class="btn btn-outline"
|
|
61
|
-
data-testid="assessment-prev"
|
|
62
|
-
onclick={() => onPrevious?.()}
|
|
63
|
-
disabled={!navState.canPrevious || navState.isLoading}
|
|
64
|
-
>
|
|
65
|
-
<svg
|
|
66
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
67
|
-
class="h-5 w-5"
|
|
68
|
-
fill="none"
|
|
69
|
-
viewBox="0 0 24 24"
|
|
70
|
-
stroke="currentColor"
|
|
71
|
-
>
|
|
72
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
|
73
|
-
</svg>
|
|
74
|
-
{translations.previous}
|
|
75
|
-
</button>
|
|
76
|
-
|
|
77
|
-
<div class="flex-1"></div>
|
|
78
|
-
|
|
79
|
-
{#if navState.currentIndex === navState.totalItems - 1}
|
|
80
|
-
<!-- Submit button on last item -->
|
|
81
|
-
<button class="btn btn-primary" data-testid="assessment-submit" onclick={() => onSubmit?.()} disabled={navState.isLoading}>
|
|
82
|
-
{translations.submit}
|
|
83
|
-
</button>
|
|
84
|
-
{:else}
|
|
85
|
-
<!-- Next button -->
|
|
86
|
-
<button
|
|
87
|
-
class="btn btn-primary"
|
|
88
|
-
data-testid="assessment-next"
|
|
89
|
-
onclick={() => onNext?.()}
|
|
90
|
-
disabled={!navState.canNext || navState.isLoading}
|
|
91
|
-
>
|
|
92
|
-
{translations.next}
|
|
93
|
-
<svg
|
|
94
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
95
|
-
class="h-5 w-5"
|
|
96
|
-
fill="none"
|
|
97
|
-
viewBox="0 0 24 24"
|
|
98
|
-
stroke="currentColor"
|
|
99
|
-
>
|
|
100
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
|
|
101
|
-
</svg>
|
|
102
|
-
</button>
|
|
103
|
-
{/if}
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
<style>
|
|
108
|
-
.navigation-bar {
|
|
109
|
-
display: flex;
|
|
110
|
-
flex-direction: column;
|
|
111
|
-
gap: 1rem;
|
|
112
|
-
padding: 1rem;
|
|
113
|
-
border-top: 1px solid var(--color-base-300);
|
|
114
|
-
background: var(--color-base-100);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.progress-section {
|
|
118
|
-
display: flex;
|
|
119
|
-
flex-direction: column;
|
|
120
|
-
gap: 0.5rem;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.progress-label {
|
|
124
|
-
font-weight: 500;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.navigation-buttons {
|
|
128
|
-
display: flex;
|
|
129
|
-
gap: 0.5rem;
|
|
130
|
-
align-items: center;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@media (max-width: 640px) {
|
|
134
|
-
.navigation-buttons {
|
|
135
|
-
flex-direction: column;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.navigation-buttons button {
|
|
139
|
-
width: 100%;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.flex-1 {
|
|
143
|
-
display: none;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
</style>
|