@pie-qti/default-components 0.1.10 → 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.
Files changed (180) hide show
  1. package/dist/chunks/__vite-browser-external-BjvdLQIS.js +9 -0
  2. package/dist/chunks/__vite-browser-external-BjvdLQIS.js.map +1 -0
  3. package/dist/chunks/chunk-Bayd9M4T.js +20 -0
  4. package/dist/chunks/{mathlive.min-Bvtiaxg4.js → mathlive.min-CAPebTxM.js} +245 -29
  5. package/dist/chunks/{mathlive.min-Bvtiaxg4.js.map → mathlive.min-CAPebTxM.js.map} +1 -1
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +1 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/plugins/associate/index.d.ts +0 -1
  10. package/dist/plugins/associate/index.js +1 -0
  11. package/dist/plugins/associate/index.js.map +1 -0
  12. package/dist/plugins/choice/index.d.ts +0 -1
  13. package/dist/plugins/choice/index.js +1 -0
  14. package/dist/plugins/choice/index.js.map +1 -0
  15. package/dist/plugins/custom/index.d.ts +0 -1
  16. package/dist/plugins/custom/index.js +1 -0
  17. package/dist/plugins/custom/index.js.map +1 -0
  18. package/dist/plugins/end-attempt/index.d.ts +0 -1
  19. package/dist/plugins/end-attempt/index.js +1 -0
  20. package/dist/plugins/end-attempt/index.js.map +1 -0
  21. package/dist/plugins/extended-text/index.d.ts +0 -1
  22. package/dist/plugins/extended-text/index.js +1 -0
  23. package/dist/plugins/extended-text/index.js.map +1 -0
  24. package/dist/plugins/gap-match/index.d.ts +0 -1
  25. package/dist/plugins/gap-match/index.js +1 -0
  26. package/dist/plugins/gap-match/index.js.map +1 -0
  27. package/dist/plugins/graphic-associate/index.d.ts +0 -1
  28. package/dist/plugins/graphic-associate/index.js +1 -0
  29. package/dist/plugins/graphic-associate/index.js.map +1 -0
  30. package/dist/plugins/graphic-gap-match/index.d.ts +0 -1
  31. package/dist/plugins/graphic-gap-match/index.js +1 -0
  32. package/dist/plugins/graphic-gap-match/index.js.map +1 -0
  33. package/dist/plugins/graphic-order/index.d.ts +0 -1
  34. package/dist/plugins/graphic-order/index.js +1 -0
  35. package/dist/plugins/graphic-order/index.js.map +1 -0
  36. package/dist/plugins/hotspot/index.d.ts +0 -1
  37. package/dist/plugins/hotspot/index.js +1 -0
  38. package/dist/plugins/hotspot/index.js.map +1 -0
  39. package/dist/plugins/hottext/index.d.ts +0 -1
  40. package/dist/plugins/hottext/index.js +1 -0
  41. package/dist/plugins/hottext/index.js.map +1 -0
  42. package/dist/plugins/match/index.d.ts +0 -1
  43. package/dist/plugins/match/index.js +1 -0
  44. package/dist/plugins/match/index.js.map +1 -0
  45. package/dist/plugins/media/index.d.ts +0 -1
  46. package/dist/plugins/media/index.js +1 -0
  47. package/dist/plugins/media/index.js.map +1 -0
  48. package/dist/plugins/order/index.d.ts +0 -1
  49. package/dist/plugins/order/index.js +1 -0
  50. package/dist/plugins/order/index.js.map +1 -0
  51. package/dist/plugins/position-object/index.d.ts +0 -1
  52. package/dist/plugins/position-object/index.js +1 -0
  53. package/dist/plugins/position-object/index.js.map +1 -0
  54. package/dist/plugins/public-types.d.ts +5 -0
  55. package/dist/plugins/public-types.js +2 -0
  56. package/dist/plugins/public-types.js.map +1 -0
  57. package/dist/plugins/select-point/index.d.ts +0 -1
  58. package/dist/plugins/select-point/index.js +1 -0
  59. package/dist/plugins/select-point/index.js.map +1 -0
  60. package/dist/plugins/slider/index.d.ts +0 -1
  61. package/dist/plugins/slider/index.js +1 -0
  62. package/dist/plugins/slider/index.js.map +1 -0
  63. package/dist/plugins.js +25917 -7690
  64. package/dist/plugins.js.map +1 -1
  65. package/dist/shared/actions/typesetAction.d.ts +0 -1
  66. package/dist/shared/actions/typesetAction.js +1 -0
  67. package/dist/shared/actions/typesetAction.js.map +1 -0
  68. package/dist/shared/extensions/MathLiveEditor.d.ts +0 -1
  69. package/dist/shared/extensions/MathLiveEditor.js +1 -0
  70. package/dist/shared/extensions/MathLiveEditor.js.map +1 -0
  71. package/dist/shared/index.d.ts +0 -1
  72. package/dist/shared/index.js +1 -0
  73. package/dist/shared/index.js.map +1 -0
  74. package/dist/shared/utils/eventHelpers.d.ts +0 -1
  75. package/dist/shared/utils/eventHelpers.js +1 -0
  76. package/dist/shared/utils/eventHelpers.js.map +1 -0
  77. package/dist/shared/utils/matchGroupUtils.d.ts +0 -1
  78. package/dist/shared/utils/matchGroupUtils.js +1 -0
  79. package/dist/shared/utils/matchGroupUtils.js.map +1 -0
  80. package/dist/shared/utils/pairHelpers.d.ts +0 -1
  81. package/dist/shared/utils/pairHelpers.js +1 -0
  82. package/dist/shared/utils/pairHelpers.js.map +1 -0
  83. package/dist/shared/utils/webComponentHelpers.d.ts +0 -1
  84. package/dist/shared/utils/webComponentHelpers.js +1 -0
  85. package/dist/shared/utils/webComponentHelpers.js.map +1 -0
  86. package/package.json +11 -33
  87. package/dist/index.d.ts.map +0 -1
  88. package/dist/plugins/associate/index.d.ts.map +0 -1
  89. package/dist/plugins/choice/index.d.ts.map +0 -1
  90. package/dist/plugins/custom/index.d.ts.map +0 -1
  91. package/dist/plugins/end-attempt/index.d.ts.map +0 -1
  92. package/dist/plugins/extended-text/index.d.ts.map +0 -1
  93. package/dist/plugins/gap-match/index.d.ts.map +0 -1
  94. package/dist/plugins/graphic-associate/index.d.ts.map +0 -1
  95. package/dist/plugins/graphic-gap-match/index.d.ts.map +0 -1
  96. package/dist/plugins/graphic-order/index.d.ts.map +0 -1
  97. package/dist/plugins/hotspot/index.d.ts.map +0 -1
  98. package/dist/plugins/hottext/index.d.ts.map +0 -1
  99. package/dist/plugins/index.d.ts +0 -31
  100. package/dist/plugins/index.d.ts.map +0 -1
  101. package/dist/plugins/index.js +0 -31
  102. package/dist/plugins/match/index.d.ts.map +0 -1
  103. package/dist/plugins/media/index.d.ts.map +0 -1
  104. package/dist/plugins/order/index.d.ts.map +0 -1
  105. package/dist/plugins/position-object/index.d.ts.map +0 -1
  106. package/dist/plugins/select-point/index.d.ts.map +0 -1
  107. package/dist/plugins/slider/index.d.ts.map +0 -1
  108. package/dist/shared/actions/typesetAction.d.ts.map +0 -1
  109. package/dist/shared/extensions/MathLiveEditor.d.ts.map +0 -1
  110. package/dist/shared/index.d.ts.map +0 -1
  111. package/dist/shared/utils/eventHelpers.d.ts.map +0 -1
  112. package/dist/shared/utils/matchGroupUtils.d.ts.map +0 -1
  113. package/dist/shared/utils/pairHelpers.d.ts.map +0 -1
  114. package/dist/shared/utils/touchDragHelper.d.ts +0 -2
  115. package/dist/shared/utils/touchDragHelper.d.ts.map +0 -1
  116. package/dist/shared/utils/touchDragHelper.js +0 -1
  117. package/dist/shared/utils/webComponentHelpers.d.ts.map +0 -1
  118. package/src/catalog/CatalogPopup.svelte +0 -163
  119. package/src/index.ts +0 -141
  120. package/src/plugins/associate/AssociateInteraction.svelte +0 -304
  121. package/src/plugins/associate/index.ts +0 -9
  122. package/src/plugins/choice/ChoiceInteraction.svelte +0 -355
  123. package/src/plugins/choice/index.ts +0 -9
  124. package/src/plugins/custom/CustomInteraction.svelte +0 -61
  125. package/src/plugins/custom/index.ts +0 -9
  126. package/src/plugins/drawing/DrawingInteraction.svelte +0 -99
  127. package/src/plugins/end-attempt/EndAttemptInteraction.svelte +0 -142
  128. package/src/plugins/end-attempt/index.ts +0 -9
  129. package/src/plugins/extended-text/ExtendedTextInteraction.svelte +0 -152
  130. package/src/plugins/extended-text/index.ts +0 -9
  131. package/src/plugins/gap-match/GapMatchInteraction.svelte +0 -556
  132. package/src/plugins/gap-match/index.ts +0 -9
  133. package/src/plugins/graphic-associate/GraphicAssociateInteraction.svelte +0 -503
  134. package/src/plugins/graphic-associate/index.ts +0 -9
  135. package/src/plugins/graphic-gap-match/GraphicGapMatchInteraction.svelte +0 -593
  136. package/src/plugins/graphic-gap-match/index.ts +0 -9
  137. package/src/plugins/graphic-order/GraphicOrderInteraction.svelte +0 -241
  138. package/src/plugins/graphic-order/index.ts +0 -9
  139. package/src/plugins/hotspot/HotspotInteraction.svelte +0 -287
  140. package/src/plugins/hotspot/index.ts +0 -9
  141. package/src/plugins/hottext/HottextInteraction.svelte +0 -325
  142. package/src/plugins/hottext/index.ts +0 -9
  143. package/src/plugins/index.ts +0 -32
  144. package/src/plugins/match/MatchInteraction.svelte +0 -82
  145. package/src/plugins/match/index.ts +0 -9
  146. package/src/plugins/media/MediaInteraction.svelte +0 -216
  147. package/src/plugins/media/index.ts +0 -9
  148. package/src/plugins/order/OrderInteraction.svelte +0 -280
  149. package/src/plugins/order/index.ts +0 -9
  150. package/src/plugins/position-object/PositionObjectInteraction.svelte +0 -903
  151. package/src/plugins/position-object/README.md +0 -130
  152. package/src/plugins/position-object/index.ts +0 -9
  153. package/src/plugins/select-point/SelectPointInteraction.svelte +0 -571
  154. package/src/plugins/select-point/index.ts +0 -9
  155. package/src/plugins/slider/SliderInteraction.svelte +0 -141
  156. package/src/plugins/slider/index.ts +0 -9
  157. package/src/plugins/upload/UploadInteraction.svelte +0 -59
  158. package/src/shared/actions/typesetAction.ts +0 -87
  159. package/src/shared/components/CustomInteractionFallback.svelte +0 -153
  160. package/src/shared/components/DragHandle.svelte +0 -44
  161. package/src/shared/components/DrawingCanvas.svelte +0 -259
  162. package/src/shared/components/FileUpload.svelte +0 -158
  163. package/src/shared/components/GraphicGapMatch.svelte +0 -318
  164. package/src/shared/components/GraphicGapMatchAdapter.svelte +0 -45
  165. package/src/shared/components/InlineInteractionRenderer.svelte +0 -141
  166. package/src/shared/components/MatchDragDrop.svelte +0 -481
  167. package/src/shared/components/MathContent.svelte +0 -18
  168. package/src/shared/components/ModalFeedbackDisplay.svelte +0 -91
  169. package/src/shared/components/RichTextEditor.svelte +0 -316
  170. package/src/shared/components/ShadowBaseStyles.svelte +0 -390
  171. package/src/shared/components/SortableList.svelte +0 -297
  172. package/src/shared/extensions/MathLiveEditor.ts +0 -299
  173. package/src/shared/index.ts +0 -15
  174. package/src/shared/styles/shared.css +0 -16
  175. package/src/shared/utils/eventHelpers.ts +0 -69
  176. package/src/shared/utils/matchGroupUtils.ts +0 -14
  177. package/src/shared/utils/pairHelpers.ts +0 -109
  178. package/src/shared/utils/webComponentHelpers.ts +0 -69
  179. package/src/svelte-shims.d.ts +0 -9
  180. /package/{src → dist}/shared/styles/qti-shared-vocabulary.css +0 -0
@@ -1,355 +0,0 @@
1
- <svelte:options customElement="pie-qti-choice" />
2
-
3
- <script lang="ts">
4
- import type { ChoiceInteractionData } from '@pie-qti/item-player';
5
- import type { I18nProvider } from '@pie-qti/i18n';
6
- import { normalizeHeuristicsConfig, type QtiHeuristicsConfig } from '@pie-qti/item-player';
7
- import { processFeedbackInline } from '@pie-qti/item-player/components/utils';
8
- import { typesetAction } from '../../shared/actions/typesetAction';
9
- import ShadowBaseStyles from '../../shared/components/ShadowBaseStyles.svelte';
10
- import { emitInteractionChange } from '../../shared/utils/eventHelpers';
11
- import { createInteractionShell } from '../../shared/utils/webComponentHelpers';
12
-
13
- interface Props {
14
- interaction?: ChoiceInteractionData | string;
15
- response?: string | string[] | null;
16
- correctResponse?: string | string[] | null;
17
- disabled?: boolean;
18
- role?: string;
19
- i18n?: I18nProvider;
20
- typeset?: (element: HTMLElement) => void;
21
- onChange?: (value: string | string[]) => void;
22
- outcomeValues?: Record<string, any>;
23
- heuristicsConfig?: QtiHeuristicsConfig;
24
- /** When true, renders an elimination toggle button per choice (QTI 3.0 PNP §6.2). */
25
- eliminationTool?: boolean;
26
- }
27
-
28
- let {
29
- interaction = $bindable(),
30
- response = $bindable(),
31
- correctResponse = $bindable(),
32
- disabled = false,
33
- role = 'candidate',
34
- i18n = $bindable(),
35
- typeset,
36
- onChange,
37
- outcomeValues = {},
38
- heuristicsConfig,
39
- eliminationTool = false
40
- }: Props = $props();
41
-
42
- // Normalize heuristics configuration with defaults
43
- const heuristics = $derived(normalizeHeuristicsConfig(heuristicsConfig));
44
-
45
- // Translation helper:
46
- // The default i18n provider returns the key itself when a translation is missing.
47
- // We treat that as "missing" so we can safely fall back to the provided string.
48
- const t = $derived((key: string, fallback: string) => {
49
- const v = i18n?.t(key);
50
- return !v || v === key ? fallback : v;
51
- });
52
-
53
- const shell = $derived(
54
- createInteractionShell<ChoiceInteractionData, string | string[], string | string[]>({
55
- interaction,
56
- response,
57
- correctResponse,
58
- role,
59
- })
60
- );
61
- const parsedInteraction = $derived(shell.interaction);
62
- const parsedResponse = $derived(shell.response);
63
- const parsedCorrectResponse = $derived(shell.correctResponse);
64
- const isShowingCorrect = $derived(shell.isShowingCorrect);
65
-
66
- // Helper function to check if a choice is correct
67
- function isCorrectChoice(identifier: string): boolean {
68
- if (!isShowingCorrect) return false;
69
- if (Array.isArray(parsedCorrectResponse)) {
70
- return parsedCorrectResponse.includes(identifier);
71
- }
72
- return parsedCorrectResponse === identifier;
73
- }
74
-
75
- // Helper function to filter feedbackInline from choice text based on outcome values
76
- function filterFeedbackInline(text: string): string {
77
- return processFeedbackInline(text, {
78
- outcomeValues,
79
- applyHeuristics: heuristics.feedbackTextFormatting,
80
- wrapWithSpan: true
81
- });
82
- }
83
-
84
- // Get reference to the root element for event dispatching
85
- let rootElement: HTMLDivElement | undefined = $state();
86
-
87
- // Elimination tool state: set of eliminated choice identifiers.
88
- // Eliminated choices remain in DOM and in the response; only visually dimmed.
89
- let eliminatedChoices = $state(new Set<string>());
90
-
91
- function toggleElimination(identifier: string) {
92
- const next = new Set(eliminatedChoices);
93
- if (next.has(identifier)) {
94
- next.delete(identifier);
95
- } else {
96
- next.add(identifier);
97
- }
98
- eliminatedChoices = next;
99
- }
100
-
101
- function eliminationLabel(identifier: string): string {
102
- const isEliminated = eliminatedChoices.has(identifier);
103
- const action = isEliminated
104
- ? (i18n?.t('interactions.choice.restoreChoice') ?? 'Restore')
105
- : (i18n?.t('interactions.choice.eliminateChoice') ?? 'Eliminate');
106
- return action;
107
- }
108
-
109
- function handleRadioChange(identifier: string) {
110
- response = identifier;
111
- emitInteractionChange({ target: rootElement, responseId: shell.responseId, value: identifier, onChange });
112
- }
113
-
114
- function handleCheckboxChange(identifier: string, checked: boolean) {
115
- const currentValues = Array.isArray(parsedResponse) ? parsedResponse : [];
116
- let newValues = [...currentValues];
117
-
118
- if (checked) {
119
- // Enforce maxChoices (0 = unlimited)
120
- const max = parsedInteraction?.maxChoices ?? 0;
121
- if (max > 0 && newValues.length >= max) return;
122
- newValues.push(identifier);
123
- } else {
124
- newValues = newValues.filter((v) => v !== identifier);
125
- }
126
-
127
- response = newValues;
128
- emitInteractionChange({ target: rootElement, responseId: shell.responseId, value: newValues, onChange });
129
- }
130
-
131
- // Selection limit message: show max message when at/over limit; min message is for submit time
132
- const selectionCount = $derived(Array.isArray(parsedResponse) ? parsedResponse.length : (parsedResponse ? 1 : 0));
133
- const maxChoices = $derived(parsedInteraction?.maxChoices ?? 0);
134
- const showMaxMessage = $derived(
135
- maxChoices > 0 && selectionCount >= maxChoices && !!parsedInteraction?.maxSelectionsMessage
136
- );
137
- </script>
138
-
139
- <ShadowBaseStyles />
140
-
141
- <div bind:this={rootElement} part="root" class={['qti-choice-interaction space-y-2', ...(parsedInteraction?.interactionClasses ?? [])].join(' ')} use:typesetAction={{ typeset }}>
142
- {#if parsedInteraction?.prompt}
143
- <div part="prompt" class="qti-choice-prompt font-semibold">{@html parsedInteraction.prompt}</div>
144
- {/if}
145
-
146
- {#if !parsedInteraction}
147
- <div class="alert alert-error">{i18n?.t('common.errorNoData') ?? 'No interaction data provided'}</div>
148
- {:else if parsedInteraction.maxChoices === 1}
149
- <!-- Single choice (radio buttons) -->
150
- {#each parsedInteraction.choices as choice}
151
- <div
152
- part="option"
153
- class="qti-choice-option form-control"
154
- data-eliminated={eliminatedChoices.has(choice.identifier) ? '' : undefined}
155
- >
156
- <label
157
- part="label"
158
- class="qti-choice-label label cursor-pointer justify-start gap-4"
159
- class:qti-choice-correct={isCorrectChoice(choice.identifier)}
160
- >
161
- <input
162
- part="input"
163
- type="radio"
164
- name={parsedInteraction.responseId}
165
- class="radio radio-primary"
166
- class:radio-success={isCorrectChoice(choice.identifier)}
167
- value={choice.identifier}
168
- checked={parsedResponse === choice.identifier}
169
- onchange={() => handleRadioChange(choice.identifier)}
170
- {disabled}
171
- />
172
- <span part="text" class="qti-choice-text label-text">
173
- {@html choice.text}
174
- </span>
175
- {#if isCorrectChoice(choice.identifier)}
176
- <span class="badge badge-success badge-sm">{t('interactions.choice.correct', 'Correct')}</span>
177
- {/if}
178
- </label>
179
- {#if eliminationTool}
180
- <button
181
- type="button"
182
- class="qti-eliminate-btn"
183
- aria-label={eliminationLabel(choice.identifier)}
184
- aria-pressed={eliminatedChoices.has(choice.identifier)}
185
- onclick={() => toggleElimination(choice.identifier)}
186
- >✕</button>
187
- {/if}
188
- </div>
189
- {/each}
190
- {:else}
191
- <!-- Multiple choice (checkboxes) -->
192
- {@const currentValues = Array.isArray(parsedResponse) ? parsedResponse : []}
193
- {#each parsedInteraction.choices as choice}
194
- <div
195
- part="option"
196
- class="qti-choice-option form-control"
197
- data-eliminated={eliminatedChoices.has(choice.identifier) ? '' : undefined}
198
- >
199
- <label
200
- part="label"
201
- class="qti-choice-label label cursor-pointer justify-start gap-4"
202
- class:qti-choice-correct={isCorrectChoice(choice.identifier)}
203
- >
204
- <input
205
- part="input"
206
- type="checkbox"
207
- class="checkbox checkbox-primary"
208
- class:checkbox-success={isCorrectChoice(choice.identifier)}
209
- value={choice.identifier}
210
- checked={currentValues.includes(choice.identifier)}
211
- onchange={(e: Event) => {
212
- const checked = (e.currentTarget as HTMLInputElement).checked;
213
- handleCheckboxChange(choice.identifier, checked);
214
- }}
215
- {disabled}
216
- />
217
- <span part="text" class="qti-choice-text label-text">
218
- {@html choice.text}
219
- </span>
220
- {#if isCorrectChoice(choice.identifier)}
221
- <span class="badge badge-success badge-sm">{t('interactions.choice.correct', 'Correct')}</span>
222
- {/if}
223
- </label>
224
- {#if eliminationTool}
225
- <button
226
- type="button"
227
- class="qti-eliminate-btn"
228
- aria-label={eliminationLabel(choice.identifier)}
229
- aria-pressed={eliminatedChoices.has(choice.identifier)}
230
- onclick={() => toggleElimination(choice.identifier)}
231
- >✕</button>
232
- {/if}
233
- </div>
234
- {/each}
235
- {/if}
236
- {#if showMaxMessage}
237
- <p class="qti-selection-message qti-max-selection-message" role="alert">{parsedInteraction?.maxSelectionsMessage}</p>
238
- {/if}
239
- </div>
240
-
241
- <style>
242
- /* Minimal layout so this works without Tailwind/DaisyUI */
243
- .qti-choice-interaction {
244
- display: grid;
245
- gap: 0.5rem;
246
- }
247
- .qti-choice-prompt {
248
- margin: 0 0 0.25rem;
249
- }
250
- .qti-choice-option {
251
- display: block;
252
- }
253
- .qti-choice-label {
254
- display: flex;
255
- align-items: flex-start;
256
- gap: 0.75rem;
257
- cursor: pointer;
258
- }
259
- .qti-choice-text {
260
- display: inline-block;
261
- line-height: 1.35;
262
- }
263
- .qti-choice-interaction input[type='radio'],
264
- .qti-choice-interaction input[type='checkbox'] {
265
- margin-top: 0.15rem;
266
- }
267
-
268
- /* Correct answer highlighting */
269
- .qti-choice-correct {
270
- background-color: color-mix(in oklch, var(--color-success, oklch(76% 0.177 163.223)) 8%, transparent);
271
- border-radius: 0.5rem;
272
- padding: 0.25rem 0.5rem;
273
- margin: -0.25rem -0.5rem;
274
- }
275
-
276
- .radio-success,
277
- .checkbox-success {
278
- accent-color: var(--color-success, oklch(76% 0.177 163.223));
279
- }
280
-
281
- /* Elimination tool */
282
- .qti-choice-option {
283
- position: relative;
284
- }
285
-
286
- .qti-eliminate-btn {
287
- position: absolute;
288
- right: 0.25rem;
289
- top: 50%;
290
- transform: translateY(-50%);
291
- background: none;
292
- border: 1px solid currentColor;
293
- border-radius: 50%;
294
- width: 1.5rem;
295
- height: 1.5rem;
296
- line-height: 1;
297
- font-size: 0.75rem;
298
- cursor: pointer;
299
- opacity: 0.4;
300
- padding: 0;
301
- display: flex;
302
- align-items: center;
303
- justify-content: center;
304
- }
305
-
306
- .qti-eliminate-btn:hover,
307
- .qti-eliminate-btn[aria-pressed='true'] {
308
- opacity: 1;
309
- }
310
-
311
- /* Eliminated choices are dimmed with a strikethrough */
312
- [data-eliminated] .qti-choice-label {
313
- opacity: 0.4;
314
- text-decoration: line-through;
315
- }
316
-
317
- [data-eliminated] .qti-eliminate-btn {
318
- opacity: 1;
319
- color: var(--color-error, oklch(63% 0.237 25.331));
320
- }
321
-
322
- /* ── QTI Shared Vocabulary behavioral classes ─────────────────────────── */
323
-
324
- /* qti-input-control-hidden: hide radio/checkbox controls but keep keyboard-accessible */
325
- :global(.qti-input-control-hidden) .qti-choice-interaction input[type='radio'],
326
- :global(.qti-input-control-hidden) .qti-choice-interaction input[type='checkbox'],
327
- .qti-choice-interaction.qti-input-control-hidden input[type='radio'],
328
- .qti-choice-interaction.qti-input-control-hidden input[type='checkbox'] {
329
- position: absolute;
330
- opacity: 0;
331
- width: 0;
332
- height: 0;
333
- pointer-events: none;
334
- }
335
-
336
- /* qti-orientation-horizontal: choices in a row */
337
- .qti-choice-interaction.qti-orientation-horizontal {
338
- grid-auto-flow: column;
339
- grid-template-columns: repeat(auto-fill, minmax(0, 1fr));
340
- }
341
-
342
- /* qti-choices-stacking-N: N-column grid */
343
- .qti-choice-interaction.qti-choices-stacking-1 { grid-template-columns: 1fr; }
344
- .qti-choice-interaction.qti-choices-stacking-2 { grid-template-columns: repeat(2, 1fr); }
345
- .qti-choice-interaction.qti-choices-stacking-3 { grid-template-columns: repeat(3, 1fr); }
346
- .qti-choice-interaction.qti-choices-stacking-4 { grid-template-columns: repeat(4, 1fr); }
347
- .qti-choice-interaction.qti-choices-stacking-5 { grid-template-columns: repeat(5, 1fr); }
348
-
349
- /* Selection limit messages */
350
- .qti-selection-message {
351
- font-size: 0.875rem;
352
- color: var(--color-warning, oklch(77% 0.194 82));
353
- margin-top: 0.5rem;
354
- }
355
- </style>
@@ -1,9 +0,0 @@
1
- // Svelte component exported via web component
2
-
3
- export const metadata = {
4
- interactionType: 'choiceInteraction',
5
- tagName: 'pie-qti-choice',
6
- name: 'default-choice',
7
- description: 'Default Svelte-based choice interaction',
8
- priority: 0,
9
- };
@@ -1,61 +0,0 @@
1
- <svelte:options customElement="pie-qti-custom" />
2
-
3
- <script lang="ts">
4
- import type { CustomInteractionData, InteractionData } from '@pie-qti/item-player';
5
- import type { I18nProvider } from '@pie-qti/i18n';
6
- import CustomInteractionFallback from '../../shared/components/CustomInteractionFallback.svelte';
7
- import ShadowBaseStyles from '../../shared/components/ShadowBaseStyles.svelte';
8
- import { parseJsonProp } from '../../shared/utils/webComponentHelpers';
9
- import { createQtiChangeEvent } from '../../shared/utils/eventHelpers';
10
-
11
- interface Props {
12
- interaction?: InteractionData | string;
13
- response?: string | null;
14
- disabled?: boolean;
15
- i18n?: I18nProvider;
16
- typeset?: (element: HTMLElement) => void;
17
- onChange?: (value: string | null) => void;
18
- }
19
-
20
- let { interaction = $bindable(), response = $bindable(), disabled = false, i18n = $bindable(), typeset, onChange }: Props = $props();
21
-
22
- // Parse props that may be JSON strings (web component usage)
23
- const parsedInteraction = $derived(parseJsonProp<InteractionData>(interaction));
24
- const parsedResponse = $derived(parseJsonProp<string>(response));
25
-
26
- // Get reference to the root element for event dispatching
27
- let rootElement: HTMLDivElement | undefined = $state();
28
-
29
- // Type assertion for custom interaction data
30
- const customInteraction = $derived(parsedInteraction as CustomInteractionData | undefined);
31
-
32
- function handleChange(value: string | null) {
33
- response = value;
34
- // Call onChange callback if provided (for Svelte component usage)
35
- onChange?.(value);
36
- // Dispatch custom event for web component usage - event will bubble up to the host element
37
- if (rootElement) {
38
- rootElement.dispatchEvent(createQtiChangeEvent(customInteraction?.responseId, value));
39
- }
40
- }
41
- </script>
42
-
43
- <ShadowBaseStyles />
44
-
45
- <div bind:this={rootElement} part="root" class="qti-custom-interaction">
46
- {#if !customInteraction}
47
- <div class="alert alert-error">{i18n?.t('common.errorNoData', 'No interaction data provided')}</div>
48
- {:else}
49
- <!-- @ts-expect-error - CustomInteractionFallback has stricter prop types -->
50
- <CustomInteractionFallback
51
- responseId={customInteraction.responseId}
52
- prompt={customInteraction.prompt}
53
- rawAttributes={customInteraction.rawAttributes}
54
- xml={customInteraction.xml}
55
- {disabled}
56
- value={parsedResponse}
57
- onChange={handleChange}
58
- testIdInput={`custom-input-${customInteraction.responseId}`}
59
- />
60
- {/if}
61
- </div>
@@ -1,9 +0,0 @@
1
- // Svelte component exported via web component
2
-
3
- export const metadata = {
4
- interactionType: 'customInteraction',
5
- tagName: 'pie-qti-custom',
6
- name: 'default-custom',
7
- description: 'Default Svelte-based custom interaction',
8
- priority: 0,
9
- };
@@ -1,99 +0,0 @@
1
- <svelte:options customElement="pie-qti-drawing" />
2
-
3
- <script lang="ts">
4
- import type { DrawingInteractionData, QTIFileResponse } from '@pie-qti/item-player';
5
- import type { I18nProvider } from '@pie-qti/i18n';
6
- import ShadowBaseStyles from '../../shared/components/ShadowBaseStyles.svelte';
7
- import DrawingCanvas from '../../shared/components/DrawingCanvas.svelte';
8
- import { createQtiChangeEvent } from '../../shared/utils/eventHelpers';
9
- import { parseJsonProp } from '../../shared/utils/webComponentHelpers';
10
- import { typesetAction } from '../../shared/actions/typesetAction';
11
-
12
- interface Props {
13
- interaction?: DrawingInteractionData | string;
14
- response?: QTIFileResponse | string | null;
15
- disabled?: boolean;
16
- i18n?: I18nProvider;
17
- typeset?: (element: HTMLElement) => void;
18
- onChange?: (value: QTIFileResponse | null) => void;
19
- }
20
-
21
- let { interaction = $bindable(), response = $bindable(), disabled = false, i18n = $bindable(), typeset, onChange }: Props = $props();
22
-
23
- // Parse props that may be JSON strings (web component usage)
24
- const parsedInteraction = $derived(parseJsonProp<DrawingInteractionData>(interaction));
25
- const parsedResponse = $derived(parseJsonProp<QTIFileResponse>(response));
26
-
27
- // Get reference to the root element for event dispatching
28
- let rootElement: HTMLDivElement | undefined = $state();
29
-
30
- function handleChange(value: QTIFileResponse | null) {
31
- response = value;
32
- // Call onChange callback if provided (for Svelte component usage)
33
- onChange?.(value);
34
- // Dispatch event for web component usage - event will bubble up to the host element
35
- if (rootElement && parsedInteraction) {
36
- rootElement.dispatchEvent(createQtiChangeEvent(parsedInteraction.responseId, value));
37
- }
38
- }
39
-
40
- // Extract drawing configuration from rawAttributes
41
- const strokeColor = $derived(parsedInteraction?.rawAttributes?.['data-stroke-color'] ?? '#111827');
42
- const lineWidth = $derived(
43
- parsedInteraction?.rawAttributes?.['data-line-width']
44
- ? Number(parsedInteraction.rawAttributes['data-line-width'])
45
- : 3
46
- );
47
- const lineCap = $derived(
48
- (parsedInteraction?.rawAttributes?.['data-line-cap'] as 'butt' | 'round' | 'square') ?? 'round'
49
- );
50
- const lineJoin = $derived(
51
- (parsedInteraction?.rawAttributes?.['data-line-join'] as 'bevel' | 'round' | 'miter') ?? 'round'
52
- );
53
- </script>
54
-
55
- <ShadowBaseStyles />
56
-
57
- <div bind:this={rootElement} part="root" class="qti-drawing-interaction" use:typesetAction={{ typeset }}>
58
- {#if !parsedInteraction}
59
- <div class="alert alert-error">
60
- <span>{i18n?.t('common.error', 'Error')}: {i18n?.t('common.errorNoData', 'No interaction data provided')}</span>
61
- </div>
62
- {:else}
63
- {#if parsedInteraction.prompt}
64
- <p class="font-semibold mb-2">{parsedInteraction.prompt}</p>
65
- {/if}
66
- <!--
67
- Accessibility note (WCAG 2.1 SC 2.1.1 exemption):
68
- Free-form drawing is a path-dependent pointer input. WCAG 2.1.1 exempts inputs
69
- "where the underlying function requires input that depends on the path of the
70
- user's movement and not just the endpoints" (e.g. freehand drawing, handwriting).
71
- Item authors MUST provide an accessible alternative form (e.g. an extended-text
72
- response or upload interaction) so that keyboard-only and switch-access users
73
- can submit equivalent evidence of their knowledge.
74
- -->
75
- <DrawingCanvas
76
- responseId={parsedInteraction.responseId}
77
- imageData={parsedInteraction.imageData}
78
- {disabled}
79
- {i18n}
80
- value={parsedResponse}
81
- onChange={handleChange}
82
- {strokeColor}
83
- {lineWidth}
84
- {lineCap}
85
- {lineJoin}
86
- />
87
- {/if}
88
- </div>
89
-
90
- <style>
91
- /* Ensure pointer events work in Shadow DOM */
92
- :global(canvas) {
93
- pointer-events: auto !important;
94
- }
95
-
96
- :global(.touch-none) {
97
- touch-action: none;
98
- }
99
- </style>
@@ -1,142 +0,0 @@
1
- <svelte:options customElement="pie-qti-end-attempt" />
2
-
3
- <script lang="ts">
4
- import type { EndAttemptInteractionData } from '@pie-qti/item-player';
5
- import type { I18nProvider } from '@pie-qti/i18n';
6
- import ShadowBaseStyles from '../../shared/components/ShadowBaseStyles.svelte';
7
- import { createQtiChangeEvent } from '../../shared/utils/eventHelpers';
8
- import { parseJsonProp } from '../../shared/utils/webComponentHelpers';
9
-
10
- interface Props {
11
- interaction?: EndAttemptInteractionData | string;
12
- response?: boolean | null;
13
- disabled?: boolean;
14
- i18n?: I18nProvider;
15
- onChange?: (value: boolean) => void;
16
- }
17
-
18
- let { interaction = $bindable(), response = $bindable(), disabled = false, i18n = $bindable(), onChange }: Props = $props();
19
-
20
- // Parse props that may be JSON strings (web component usage)
21
- const parsedInteraction = $derived(parseJsonProp<EndAttemptInteractionData>(interaction));
22
- const parsedResponse = $derived(parseJsonProp<boolean>(response));
23
-
24
- // Get reference to the root element for event dispatching
25
- let rootElement: HTMLDivElement | undefined = $state();
26
-
27
- // Track if button has been clicked
28
- let hasEnded = $state(false);
29
-
30
- const canInteract = $derived(!disabled);
31
-
32
- $effect(() => {
33
- // Sync with parent response changes
34
- hasEnded = parsedResponse ?? false;
35
- });
36
-
37
- function handleEndAttempt() {
38
- if (!canInteract || hasEnded) return;
39
- hasEnded = true;
40
- response = true;
41
- // Call onChange callback if provided (for Svelte component usage)
42
- onChange?.(true);
43
- // Dispatch event for web component usage - event will bubble up to the host element
44
- if (rootElement) {
45
- rootElement.dispatchEvent(createQtiChangeEvent(parsedInteraction?.responseId, true));
46
- }
47
- }
48
- </script>
49
-
50
- <ShadowBaseStyles />
51
-
52
- <div bind:this={rootElement} class="qti-end-attempt-interaction">
53
- {#if !parsedInteraction}
54
- <div class="alert alert-error">{i18n?.t('common.errorNoData', 'No interaction data provided')}</div>
55
- {:else}
56
- {#if parsedInteraction.prompt}
57
- <p class="font-semibold mb-3">{@html parsedInteraction.prompt}</p>
58
- {/if}
59
-
60
- <div class="qti-end-row flex items-center gap-4">
61
- <button
62
- part="button"
63
- class="btn btn-error btn-lg {hasEnded ? 'btn-disabled' : ''}"
64
- onclick={handleEndAttempt}
65
- disabled={!canInteract || hasEnded}
66
- aria-label={parsedInteraction.title}
67
- >
68
- {#if hasEnded}
69
- <svg
70
- xmlns="http://www.w3.org/2000/svg"
71
- part="icon"
72
- class="qti-icon h-6 w-6 mr-2"
73
- fill="none"
74
- viewBox="0 0 24 24"
75
- stroke="currentColor"
76
- >
77
- <path
78
- stroke-linecap="round"
79
- stroke-linejoin="round"
80
- stroke-width="2"
81
- d="M5 13l4 4L19 7"
82
- />
83
- </svg>
84
- {parsedInteraction.countAttempt ? (i18n?.t('interactions.endAttempt.ended') ?? 'Attempt Ended') : (i18n?.t('interactions.endAttempt.requested') ?? 'Requested')}
85
- {:else}
86
- <svg
87
- xmlns="http://www.w3.org/2000/svg"
88
- part="icon"
89
- class="qti-icon h-6 w-6 mr-2"
90
- fill="none"
91
- viewBox="0 0 24 24"
92
- stroke="currentColor"
93
- >
94
- <path
95
- stroke-linecap="round"
96
- stroke-linejoin="round"
97
- stroke-width="2"
98
- d="M6 18L18 6M6 6l12 12"
99
- />
100
- </svg>
101
- {parsedInteraction.title}
102
- {/if}
103
- </button>
104
-
105
- {#if hasEnded && parsedInteraction.countAttempt}
106
- <div part="ended-message" class="alert alert-warning inline-flex items-center gap-2 w-auto">
107
- <svg
108
- xmlns="http://www.w3.org/2000/svg"
109
- part="ended-icon"
110
- class="qti-icon stroke-current shrink-0 h-6 w-6"
111
- fill="none"
112
- viewBox="0 0 24 24"
113
- >
114
- <path
115
- stroke-linecap="round"
116
- stroke-linejoin="round"
117
- stroke-width="2"
118
- 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"
119
- />
120
- </svg>
121
- <span>Your attempt has been ended and can no longer be modified.</span>
122
- </div>
123
- {/if}
124
- </div>
125
- {/if}
126
- </div>
127
-
128
- <style>
129
- /* Minimal icon sizing so SVGs don't fall back to browser default size without Tailwind */
130
- .qti-icon {
131
- width: 1.5rem;
132
- height: 1.5rem;
133
- flex: 0 0 auto;
134
- }
135
- /* Minimal layout if host doesn't provide utility classes */
136
- .qti-end-row {
137
- display: flex;
138
- align-items: center;
139
- gap: 1rem;
140
- flex-wrap: wrap;
141
- }
142
- </style>
@@ -1,9 +0,0 @@
1
- // Svelte component exported via web component
2
-
3
- export const metadata = {
4
- interactionType: 'endAttemptInteraction',
5
- tagName: 'pie-qti-end-attempt',
6
- name: 'default-end-attempt',
7
- description: 'Default Svelte-based end attempt interaction',
8
- priority: 0,
9
- };