@pie-qti/default-components 0.1.10 → 0.1.12
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/dist/chunks/__vite-browser-external-Dz5RCjpq.js +9 -0
- package/dist/chunks/__vite-browser-external-Dz5RCjpq.js.map +1 -0
- package/dist/chunks/{mathlive.min-Bvtiaxg4.js → mathlive.min-ClqhKA_b.js} +4199 -3978
- package/dist/chunks/mathlive.min-ClqhKA_b.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/associate/index.d.ts +0 -1
- package/dist/plugins/associate/index.js +1 -0
- package/dist/plugins/associate/index.js.map +1 -0
- package/dist/plugins/choice/index.d.ts +0 -1
- package/dist/plugins/choice/index.js +1 -0
- package/dist/plugins/choice/index.js.map +1 -0
- package/dist/plugins/custom/index.d.ts +0 -1
- package/dist/plugins/custom/index.js +1 -0
- package/dist/plugins/custom/index.js.map +1 -0
- package/dist/plugins/end-attempt/index.d.ts +0 -1
- package/dist/plugins/end-attempt/index.js +1 -0
- package/dist/plugins/end-attempt/index.js.map +1 -0
- package/dist/plugins/extended-text/index.d.ts +0 -1
- package/dist/plugins/extended-text/index.js +1 -0
- package/dist/plugins/extended-text/index.js.map +1 -0
- package/dist/plugins/gap-match/index.d.ts +0 -1
- package/dist/plugins/gap-match/index.js +1 -0
- package/dist/plugins/gap-match/index.js.map +1 -0
- package/dist/plugins/graphic-associate/index.d.ts +0 -1
- package/dist/plugins/graphic-associate/index.js +1 -0
- package/dist/plugins/graphic-associate/index.js.map +1 -0
- package/dist/plugins/graphic-gap-match/index.d.ts +0 -1
- package/dist/plugins/graphic-gap-match/index.js +1 -0
- package/dist/plugins/graphic-gap-match/index.js.map +1 -0
- package/dist/plugins/graphic-order/index.d.ts +0 -1
- package/dist/plugins/graphic-order/index.js +1 -0
- package/dist/plugins/graphic-order/index.js.map +1 -0
- package/dist/plugins/hotspot/index.d.ts +0 -1
- package/dist/plugins/hotspot/index.js +1 -0
- package/dist/plugins/hotspot/index.js.map +1 -0
- package/dist/plugins/hottext/index.d.ts +0 -1
- package/dist/plugins/hottext/index.js +1 -0
- package/dist/plugins/hottext/index.js.map +1 -0
- package/dist/plugins/match/index.d.ts +0 -1
- package/dist/plugins/match/index.js +1 -0
- package/dist/plugins/match/index.js.map +1 -0
- package/dist/plugins/media/index.d.ts +0 -1
- package/dist/plugins/media/index.js +1 -0
- package/dist/plugins/media/index.js.map +1 -0
- package/dist/plugins/order/index.d.ts +0 -1
- package/dist/plugins/order/index.js +1 -0
- package/dist/plugins/order/index.js.map +1 -0
- package/dist/plugins/position-object/index.d.ts +0 -1
- package/dist/plugins/position-object/index.js +1 -0
- package/dist/plugins/position-object/index.js.map +1 -0
- package/dist/plugins/public-types.d.ts +5 -0
- package/dist/plugins/public-types.js +2 -0
- package/dist/plugins/public-types.js.map +1 -0
- package/dist/plugins/select-point/index.d.ts +0 -1
- package/dist/plugins/select-point/index.js +1 -0
- package/dist/plugins/select-point/index.js.map +1 -0
- package/dist/plugins/slider/index.d.ts +0 -1
- package/dist/plugins/slider/index.js +1 -0
- package/dist/plugins/slider/index.js.map +1 -0
- package/dist/plugins.js +27589 -9160
- package/dist/plugins.js.map +1 -1
- package/dist/shared/actions/typesetAction.d.ts +0 -1
- package/dist/shared/actions/typesetAction.js +1 -0
- package/dist/shared/actions/typesetAction.js.map +1 -0
- package/dist/shared/extensions/MathLiveEditor.d.ts +0 -1
- package/dist/shared/extensions/MathLiveEditor.js +1 -0
- package/dist/shared/extensions/MathLiveEditor.js.map +1 -0
- package/dist/shared/index.d.ts +0 -1
- package/dist/shared/index.js +1 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/utils/eventHelpers.d.ts +0 -1
- package/dist/shared/utils/eventHelpers.js +1 -0
- package/dist/shared/utils/eventHelpers.js.map +1 -0
- package/dist/shared/utils/matchGroupUtils.d.ts +0 -1
- package/dist/shared/utils/matchGroupUtils.js +1 -0
- package/dist/shared/utils/matchGroupUtils.js.map +1 -0
- package/dist/shared/utils/pairHelpers.d.ts +0 -1
- package/dist/shared/utils/pairHelpers.js +1 -0
- package/dist/shared/utils/pairHelpers.js.map +1 -0
- package/dist/shared/utils/webComponentHelpers.d.ts +0 -1
- package/dist/shared/utils/webComponentHelpers.js +1 -0
- package/dist/shared/utils/webComponentHelpers.js.map +1 -0
- package/package.json +15 -33
- package/dist/chunks/mathlive.min-Bvtiaxg4.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/associate/index.d.ts.map +0 -1
- package/dist/plugins/choice/index.d.ts.map +0 -1
- package/dist/plugins/custom/index.d.ts.map +0 -1
- package/dist/plugins/end-attempt/index.d.ts.map +0 -1
- package/dist/plugins/extended-text/index.d.ts.map +0 -1
- package/dist/plugins/gap-match/index.d.ts.map +0 -1
- package/dist/plugins/graphic-associate/index.d.ts.map +0 -1
- package/dist/plugins/graphic-gap-match/index.d.ts.map +0 -1
- package/dist/plugins/graphic-order/index.d.ts.map +0 -1
- package/dist/plugins/hotspot/index.d.ts.map +0 -1
- package/dist/plugins/hottext/index.d.ts.map +0 -1
- package/dist/plugins/index.d.ts +0 -31
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -31
- package/dist/plugins/match/index.d.ts.map +0 -1
- package/dist/plugins/media/index.d.ts.map +0 -1
- package/dist/plugins/order/index.d.ts.map +0 -1
- package/dist/plugins/position-object/index.d.ts.map +0 -1
- package/dist/plugins/select-point/index.d.ts.map +0 -1
- package/dist/plugins/slider/index.d.ts.map +0 -1
- package/dist/shared/actions/typesetAction.d.ts.map +0 -1
- package/dist/shared/extensions/MathLiveEditor.d.ts.map +0 -1
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/utils/eventHelpers.d.ts.map +0 -1
- package/dist/shared/utils/matchGroupUtils.d.ts.map +0 -1
- package/dist/shared/utils/pairHelpers.d.ts.map +0 -1
- package/dist/shared/utils/touchDragHelper.d.ts +0 -2
- package/dist/shared/utils/touchDragHelper.d.ts.map +0 -1
- package/dist/shared/utils/touchDragHelper.js +0 -1
- package/dist/shared/utils/webComponentHelpers.d.ts.map +0 -1
- package/src/catalog/CatalogPopup.svelte +0 -163
- package/src/index.ts +0 -141
- package/src/plugins/associate/AssociateInteraction.svelte +0 -304
- package/src/plugins/associate/index.ts +0 -9
- package/src/plugins/choice/ChoiceInteraction.svelte +0 -355
- package/src/plugins/choice/index.ts +0 -9
- package/src/plugins/custom/CustomInteraction.svelte +0 -61
- package/src/plugins/custom/index.ts +0 -9
- package/src/plugins/drawing/DrawingInteraction.svelte +0 -99
- package/src/plugins/end-attempt/EndAttemptInteraction.svelte +0 -142
- package/src/plugins/end-attempt/index.ts +0 -9
- package/src/plugins/extended-text/ExtendedTextInteraction.svelte +0 -152
- package/src/plugins/extended-text/index.ts +0 -9
- package/src/plugins/gap-match/GapMatchInteraction.svelte +0 -556
- package/src/plugins/gap-match/index.ts +0 -9
- package/src/plugins/graphic-associate/GraphicAssociateInteraction.svelte +0 -503
- package/src/plugins/graphic-associate/index.ts +0 -9
- package/src/plugins/graphic-gap-match/GraphicGapMatchInteraction.svelte +0 -593
- package/src/plugins/graphic-gap-match/index.ts +0 -9
- package/src/plugins/graphic-order/GraphicOrderInteraction.svelte +0 -241
- package/src/plugins/graphic-order/index.ts +0 -9
- package/src/plugins/hotspot/HotspotInteraction.svelte +0 -287
- package/src/plugins/hotspot/index.ts +0 -9
- package/src/plugins/hottext/HottextInteraction.svelte +0 -325
- package/src/plugins/hottext/index.ts +0 -9
- package/src/plugins/index.ts +0 -32
- package/src/plugins/match/MatchInteraction.svelte +0 -82
- package/src/plugins/match/index.ts +0 -9
- package/src/plugins/media/MediaInteraction.svelte +0 -216
- package/src/plugins/media/index.ts +0 -9
- package/src/plugins/order/OrderInteraction.svelte +0 -280
- package/src/plugins/order/index.ts +0 -9
- package/src/plugins/position-object/PositionObjectInteraction.svelte +0 -903
- package/src/plugins/position-object/README.md +0 -130
- package/src/plugins/position-object/index.ts +0 -9
- package/src/plugins/select-point/SelectPointInteraction.svelte +0 -571
- package/src/plugins/select-point/index.ts +0 -9
- package/src/plugins/slider/SliderInteraction.svelte +0 -141
- package/src/plugins/slider/index.ts +0 -9
- package/src/plugins/upload/UploadInteraction.svelte +0 -59
- package/src/shared/actions/typesetAction.ts +0 -87
- package/src/shared/components/CustomInteractionFallback.svelte +0 -153
- package/src/shared/components/DragHandle.svelte +0 -44
- package/src/shared/components/DrawingCanvas.svelte +0 -259
- package/src/shared/components/FileUpload.svelte +0 -158
- package/src/shared/components/GraphicGapMatch.svelte +0 -318
- package/src/shared/components/GraphicGapMatchAdapter.svelte +0 -45
- package/src/shared/components/InlineInteractionRenderer.svelte +0 -141
- package/src/shared/components/MatchDragDrop.svelte +0 -481
- package/src/shared/components/MathContent.svelte +0 -18
- package/src/shared/components/ModalFeedbackDisplay.svelte +0 -91
- package/src/shared/components/RichTextEditor.svelte +0 -316
- package/src/shared/components/ShadowBaseStyles.svelte +0 -390
- package/src/shared/components/SortableList.svelte +0 -297
- package/src/shared/extensions/MathLiveEditor.ts +0 -299
- package/src/shared/index.ts +0 -15
- package/src/shared/styles/shared.css +0 -16
- package/src/shared/utils/eventHelpers.ts +0 -69
- package/src/shared/utils/matchGroupUtils.ts +0 -14
- package/src/shared/utils/pairHelpers.ts +0 -109
- package/src/shared/utils/webComponentHelpers.ts +0 -69
- package/src/svelte-shims.d.ts +0 -9
- /package/{src → dist}/shared/styles/qti-shared-vocabulary.css +0 -0
|
@@ -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,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
|
-
};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
<svelte:options customElement="pie-qti-extended-text" />
|
|
2
|
-
|
|
3
|
-
<script lang="ts">
|
|
4
|
-
import type { ExtendedTextInteractionData } from '@pie-qti/item-player';
|
|
5
|
-
import type { I18nProvider } from '@pie-qti/i18n';
|
|
6
|
-
import RichTextEditor from '../../shared/components/RichTextEditor.svelte';
|
|
7
|
-
import { typesetAction } from '../../shared/actions/typesetAction';
|
|
8
|
-
import ShadowBaseStyles from '../../shared/components/ShadowBaseStyles.svelte';
|
|
9
|
-
import { emitInteractionChange } from '../../shared/utils/eventHelpers';
|
|
10
|
-
import { createInteractionShell } from '../../shared/utils/webComponentHelpers';
|
|
11
|
-
|
|
12
|
-
interface Props {
|
|
13
|
-
interaction?: ExtendedTextInteractionData | string;
|
|
14
|
-
response?: string | null;
|
|
15
|
-
correctResponse?: string | null;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
role?: string;
|
|
18
|
-
i18n?: I18nProvider;
|
|
19
|
-
typeset?: (element: HTMLElement) => void;
|
|
20
|
-
onChange?: (value: string) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let { interaction = $bindable(), response = $bindable(), correctResponse = $bindable(), disabled = false, role = 'candidate', i18n = $bindable(), typeset, onChange }: Props = $props();
|
|
24
|
-
|
|
25
|
-
const shell = $derived(
|
|
26
|
-
createInteractionShell<ExtendedTextInteractionData, string, string>({
|
|
27
|
-
interaction,
|
|
28
|
-
response,
|
|
29
|
-
correctResponse,
|
|
30
|
-
role,
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
const parsedInteraction = $derived(shell.interaction);
|
|
34
|
-
const parsedResponse = $derived(shell.response);
|
|
35
|
-
const parsedCorrectResponse = $derived(shell.correctResponse);
|
|
36
|
-
const isShowingCorrect = $derived(shell.isShowingCorrect);
|
|
37
|
-
|
|
38
|
-
// Get reference to the root element for event dispatching
|
|
39
|
-
let rootElement: HTMLDivElement | undefined = $state();
|
|
40
|
-
|
|
41
|
-
function handleChange(html: string) {
|
|
42
|
-
response = html;
|
|
43
|
-
emitInteractionChange({ target: rootElement, responseId: shell.responseId, value: html, onChange });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Character counter support (qti-counter-down / qti-counter-up)
|
|
47
|
-
function charCount(html: string, format: string): number {
|
|
48
|
-
if (format === 'xhtml') {
|
|
49
|
-
// Strip HTML tags, count only text characters
|
|
50
|
-
return html.replace(/<[^>]*>/g, '').length;
|
|
51
|
-
}
|
|
52
|
-
return html.length;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const currentCount = $derived(charCount(parsedResponse ?? '', parsedInteraction?.format ?? 'plain'));
|
|
56
|
-
const expectedLength = $derived(parsedInteraction?.expectedLength ?? 0);
|
|
57
|
-
const classes = $derived(parsedInteraction?.interactionClasses ?? []);
|
|
58
|
-
const showCounterDown = $derived(classes.includes('qti-counter-down') && expectedLength > 0);
|
|
59
|
-
const showCounterUp = $derived(classes.includes('qti-counter-up') && expectedLength > 0);
|
|
60
|
-
const remaining = $derived(expectedLength - currentCount);
|
|
61
|
-
</script>
|
|
62
|
-
|
|
63
|
-
<ShadowBaseStyles />
|
|
64
|
-
|
|
65
|
-
<div bind:this={rootElement} part="root" class={['qti-extended-text-interaction', ...(parsedInteraction?.interactionClasses ?? [])].join(' ')}>
|
|
66
|
-
{#if !parsedInteraction}
|
|
67
|
-
<div class="alert alert-error">{i18n?.t('common.errorNoData', 'No interaction data provided')}</div>
|
|
68
|
-
{:else}
|
|
69
|
-
{#if parsedInteraction.prompt}
|
|
70
|
-
<div part="prompt" class="qti-extended-text-prompt font-semibold" use:typesetAction={{ typeset }}>
|
|
71
|
-
{@html parsedInteraction.prompt}
|
|
72
|
-
</div>
|
|
73
|
-
{/if}
|
|
74
|
-
<div part="editor">
|
|
75
|
-
<RichTextEditor
|
|
76
|
-
value={parsedResponse || ''}
|
|
77
|
-
editable={!disabled}
|
|
78
|
-
placeholder={parsedInteraction.placeholderText || 'Enter your response...'}
|
|
79
|
-
minHeight={parsedInteraction.expectedLines ? parsedInteraction.expectedLines * 24 : 200}
|
|
80
|
-
{i18n}
|
|
81
|
-
onChange={handleChange}
|
|
82
|
-
/>
|
|
83
|
-
</div>
|
|
84
|
-
{#if showCounterDown}
|
|
85
|
-
<p part="counter" class="qti-character-counter" aria-live="polite">
|
|
86
|
-
{remaining >= 0 ? remaining : 0} {i18n?.t('interactions.extendedText.charsRemaining', 'characters remaining')}
|
|
87
|
-
</p>
|
|
88
|
-
{:else if showCounterUp}
|
|
89
|
-
<p part="counter" class="qti-character-counter" aria-live="polite">
|
|
90
|
-
{currentCount} / {expectedLength} {i18n?.t('interactions.extendedText.charsUsed', 'characters')}
|
|
91
|
-
</p>
|
|
92
|
-
{/if}
|
|
93
|
-
{#if isShowingCorrect && parsedCorrectResponse}
|
|
94
|
-
<div part="correct-answer" class="mt-3 p-3 bg-success bg-opacity-10 border border-success rounded">
|
|
95
|
-
<div class="text-sm font-semibold text-success mb-2">
|
|
96
|
-
{i18n?.t('interactions.choice.correct', 'Correct') ?? 'Correct'} Answer:
|
|
97
|
-
</div>
|
|
98
|
-
<div class="text-sm">{parsedCorrectResponse}</div>
|
|
99
|
-
</div>
|
|
100
|
-
{/if}
|
|
101
|
-
{/if}
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
<style>
|
|
105
|
-
/* Minimal layout so this works without Tailwind/DaisyUI */
|
|
106
|
-
.qti-extended-text-interaction {
|
|
107
|
-
display: grid;
|
|
108
|
-
gap: 0.75rem;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.qti-extended-text-prompt {
|
|
112
|
-
line-height: 1.5;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.qti-extended-text-prompt :global(:first-child) {
|
|
116
|
-
margin-top: 0;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.qti-extended-text-prompt :global(:last-child) {
|
|
120
|
-
margin-bottom: 0;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/* QTI 3.0 Shared Vocabulary: qti-height-lines-N sets minimum textarea height.
|
|
124
|
-
Each line unit = 1.5rem (24px) matching the editor's line-height. */
|
|
125
|
-
.qti-height-lines-1 { --qti-min-height: 1.5rem; }
|
|
126
|
-
.qti-height-lines-2 { --qti-min-height: 3rem; }
|
|
127
|
-
.qti-height-lines-3 { --qti-min-height: 4.5rem; }
|
|
128
|
-
.qti-height-lines-4 { --qti-min-height: 6rem; }
|
|
129
|
-
.qti-height-lines-5 { --qti-min-height: 7.5rem; }
|
|
130
|
-
.qti-height-lines-6 { --qti-min-height: 9rem; }
|
|
131
|
-
.qti-height-lines-7 { --qti-min-height: 10.5rem; }
|
|
132
|
-
.qti-height-lines-8 { --qti-min-height: 12rem; }
|
|
133
|
-
.qti-height-lines-10 { --qti-min-height: 15rem; }
|
|
134
|
-
.qti-height-lines-12 { --qti-min-height: 18rem; }
|
|
135
|
-
.qti-height-lines-15 { --qti-min-height: 22.5rem; }
|
|
136
|
-
.qti-height-lines-20 { --qti-min-height: 30rem; }
|
|
137
|
-
.qti-height-lines-25 { --qti-min-height: 37.5rem; }
|
|
138
|
-
|
|
139
|
-
/* Apply the CSS variable to the editor's inner textarea via the part */
|
|
140
|
-
[class*='qti-height-lines-'] :global([part='editor'] .ProseMirror),
|
|
141
|
-
[class*='qti-height-lines-'] :global([part='editor'] textarea) {
|
|
142
|
-
min-height: var(--qti-min-height);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.qti-character-counter {
|
|
146
|
-
font-size: 0.8125rem;
|
|
147
|
-
color: var(--color-base-content, #374151);
|
|
148
|
-
opacity: 0.7;
|
|
149
|
-
margin-top: 0.25rem;
|
|
150
|
-
text-align: right;
|
|
151
|
-
}
|
|
152
|
-
</style>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Svelte component exported via web component
|
|
2
|
-
|
|
3
|
-
export const metadata = {
|
|
4
|
-
interactionType: 'extendedTextInteraction',
|
|
5
|
-
tagName: 'pie-qti-extended-text',
|
|
6
|
-
name: 'default-extended-text',
|
|
7
|
-
description: 'Default Svelte-based extended text interaction',
|
|
8
|
-
priority: 0,
|
|
9
|
-
};
|