@qti-components/test 2.0.0-next.7 → 2.0.0-next.9

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 (40) hide show
  1. package/dist/components/qti-test/getting-started.fixtures.d.ts +6 -0
  2. package/dist/components/qti-test/getting-started.fixtures.js +7 -0
  3. package/dist/components/qti-test/getting-started.fixtures.js.map +1 -0
  4. package/dist/components/qti-test/qti-test.d.ts +1 -0
  5. package/dist/components/styles.d.ts +8 -1
  6. package/dist/components/styles.js +63 -14
  7. package/dist/components/styles.js.map +1 -1
  8. package/dist/components/test-bookmark/test-bookmark.js +7 -2
  9. package/dist/components/test-bookmark/test-bookmark.js.map +1 -1
  10. package/dist/components/test-check-item/test-check-item.js +7 -2
  11. package/dist/components/test-check-item/test-check-item.js.map +1 -1
  12. package/dist/components/test-end-attempt/test-end-attempt.js +7 -2
  13. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  14. package/dist/components/test-item-link/test-item-link.js +7 -2
  15. package/dist/components/test-item-link/test-item-link.js.map +1 -1
  16. package/dist/components/test-next/test-next.js +8 -2
  17. package/dist/components/test-next/test-next.js.map +1 -1
  18. package/dist/components/test-prev/test-prev.js +7 -2
  19. package/dist/components/test-prev/test-prev.js.map +1 -1
  20. package/dist/components/test-section-link/test-section-link.js +7 -2
  21. package/dist/components/test-section-link/test-section-link.js.map +1 -1
  22. package/dist/components/test-stamp/test-stamp.d.ts +3 -2
  23. package/dist/components/test-stamp/test-stamp.js +3 -2
  24. package/dist/components/test-stamp/test-stamp.js.map +1 -1
  25. package/dist/components/test-submit/test-submit.d.ts +16 -0
  26. package/dist/components/test-submit/test-submit.js +37 -0
  27. package/dist/components/test-submit/test-submit.js.map +1 -0
  28. package/dist/elements.d.ts +3 -0
  29. package/dist/mixins/test-processing.mixin.d.ts +1 -0
  30. package/dist/mixins/test-processing.mixin.js +22 -1
  31. package/dist/mixins/test-processing.mixin.js.map +1 -1
  32. package/dist/plugins/elements.d.ts +5 -1
  33. package/dist/plugins/elements.js +3 -1
  34. package/dist/plugins/elements.js.map +1 -1
  35. package/dist/public-events.d.ts +4 -0
  36. package/dist/public-events.js +2 -0
  37. package/dist/public-events.js.map +1 -1
  38. package/dist/tts/test-item-to-speech.js +22 -7
  39. package/dist/tts/test-item-to-speech.js.map +1 -1
  40. package/package.json +3 -3
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The test behind the Getting started page. Its files live in `public/assets/docs/getting-started/`,
3
+ * named after the page; a docs page or story that needs a test of its own gets a folder of its own
4
+ * under `public/assets/docs/` and a `*.fixtures.ts` next to it, so the file and its user stay together.
5
+ */
6
+ export declare const GETTING_STARTED_TEST = "/assets/docs/getting-started/assessment.xml";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The test behind the Getting started page. Its files live in `public/assets/docs/getting-started/`,
3
+ * named after the page; a docs page or story that needs a test of its own gets a folder of its own
4
+ * under `public/assets/docs/` and a `*.fixtures.ts` next to it, so the file and its user stay together.
5
+ */
6
+ export const GETTING_STARTED_TEST = '/assets/docs/getting-started/assessment.xml';
7
+ //# sourceMappingURL=getting-started.fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getting-started.fixtures.js","sourceRoot":"","sources":["../../../src/components/qti-test/getting-started.fixtures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,6CAA6C,CAAC","sourcesContent":["/**\n * The test behind the Getting started page. Its files live in `public/assets/docs/getting-started/`,\n * named after the page; a docs page or story that needs a test of its own gets a folder of its own\n * under `public/assets/docs/` and a `*.fixtures.ts` next to it, so the file and its user stay together.\n */\nexport const GETTING_STARTED_TEST = '/assets/docs/getting-started/assessment.xml';\n"]}
@@ -7,6 +7,7 @@ declare const QtiTest_base: (abstract new (...args: any[]) => import("../..").IT
7
7
  getOutcome(identifier: string): Readonly<import("@qti-components/base").OutcomeVariable>;
8
8
  getVariable(identifier: string): Readonly<import("@qti-components/base").VariableDeclaration<string | string[] | null>>;
9
9
  outcomeProcessing(): boolean;
10
+ submit(): boolean;
10
11
  getTestFeedback(access?: "atEnd" | "during"): import("..").QtiTestFeedback[];
11
12
  }) & (abstract new (...args: any[]) => import("../..").ITestStateMixin) & (abstract new (...args: any[]) => import("../../mixins").TestBaseInterface) & typeof LitElement;
12
13
  /**
@@ -1,7 +1,14 @@
1
1
  export declare const form: import("lit").CSSResult;
2
2
  export declare const btn: import("lit").CSSResult;
3
- /** Hover and keyboard focus; paint only, so the box never moves. */
3
+ /** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */
4
+ export declare const btnPrimary: import("lit").CSSResult;
5
+ /** Hover; paint only, so the box never moves. */
4
6
  export declare const btnInteractive: import("lit").CSSResult;
7
+ export declare const btnPrimaryInteractive: import("lit").CSSResult;
8
+ /** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */
9
+ export declare const btnActive: import("lit").CSSResult;
10
+ export declare const btnPrimaryActive: import("lit").CSSResult;
11
+ /** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */
5
12
  export declare const focusRing: import("lit").CSSResult;
6
13
  export declare const dis: import("lit").CSSResult;
7
14
  export declare const ind: import("lit").CSSResult;
@@ -3,11 +3,31 @@ import { css } from 'lit';
3
3
  /*
4
4
  * The resting look of the test controls (next, prev, item/section links, TTS buttons).
5
5
  *
6
- * Paint reads the qti-theme tokens, so a theme or brand that re-values them repaints the test
7
- * chrome along with the items; every token has a literal fallback equal to the theme's own
8
- * default, so the controls look the same without qti-theme loaded. A `--test-button-*` slot
9
- * in front of each token repaints the test controls alone.
6
+ * Two looks, both plain: a neutral one (the page's surface, the theme's border, the surrounding text
7
+ * colour) and a filled one that `test-next` wears, in the theme's neutral colour with its content
8
+ * colour on top. No shadow, no glow, no transition, so the controls read as unbranded until a host
9
+ * repaints them.
10
+ *
11
+ * Every colour is the theme's tier 1 (CONTRACT.md §8 in qti-theme), with a CSS system colour behind
12
+ * it for a page that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the
13
+ * controls stay legible in dark mode without the theme too. Hover and press mix the content colour
14
+ * into the fill, by --qti-hover-mix and --qti-active-mix.
15
+ *
16
+ * Paint comes from the `--test-button-*` slots, which repaint the test controls alone, and never
17
+ * from the shared `--qti-component-*` tokens: those also paint the items' own borders, and a change
18
+ * to how a button looks must not move an interaction.
19
+ *
20
+ * --test-button-background-color, --test-button-color, --test-button-border-color,
21
+ * --test-button-hover-background-color, --test-button-active-background-color
22
+ * the neutral look, and the filled look's slots
23
+ * --test-button-primary-background-color, --test-button-primary-color,
24
+ * --test-button-primary-hover-background-color, --test-button-primary-active-background-color
25
+ * the filled look only
10
26
  */
27
+ const surface = css `var(--qti-color-base-100, var(--cito-color-base-100, Canvas))`;
28
+ const content = css `var(--qti-color-base-content, var(--cito-color-base-content, CanvasText))`;
29
+ const neutral = css `var(--qti-color-neutral, var(--cito-color-neutral, CanvasText))`;
30
+ const neutralContent = css `var(--qti-color-neutral-content, var(--cito-color-neutral-content, Canvas))`;
11
31
  export const form = css `
12
32
  display: inline-flex;
13
33
  align-items: center;
@@ -20,22 +40,51 @@ export const form = css `
20
40
  line-height: 1.25;
21
41
  cursor: pointer;
22
42
  user-select: none;
23
- border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
43
+ border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));
24
44
  `;
25
45
  export const btn = css `
26
46
  ${form};
27
- background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
28
- color: var(--test-button-color, var(--qti-component-color, inherit));
29
- border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
30
- var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
47
+ background-color: var(--test-button-background-color, ${surface});
48
+ color: var(--test-button-color, inherit);
49
+ border: var(--qti-border-width, var(--cito-border-width, 1px)) solid
50
+ var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})));
51
+ `;
52
+ /** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */
53
+ export const btnPrimary = css `
54
+ background-color: var(--test-button-primary-background-color, ${neutral});
55
+ color: var(--test-button-primary-color, ${neutralContent});
56
+ border-color: var(--test-button-primary-background-color, ${neutral});
31
57
  `;
32
- /** Hover and keyboard focus; paint only, so the box never moves. */
58
+ /** Hover; paint only, so the box never moves. */
33
59
  export const btnInteractive = css `
34
- background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
60
+ background-color: var(
61
+ --test-button-hover-background-color,
62
+ color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%))
63
+ );
64
+ `;
65
+ export const btnPrimaryInteractive = css `
66
+ background-color: var(
67
+ --test-button-primary-hover-background-color,
68
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))
69
+ );
70
+ `;
71
+ /** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */
72
+ export const btnActive = css `
73
+ background-color: var(
74
+ --test-button-active-background-color,
75
+ color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%))
76
+ );
77
+ `;
78
+ export const btnPrimaryActive = css `
79
+ background-color: var(
80
+ --test-button-primary-active-background-color,
81
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))
82
+ );
35
83
  `;
84
+ /** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */
36
85
  export const focusRing = css `
37
- outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
38
- outline-offset: 2px;
86
+ outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, Highlight);
87
+ outline-offset: var(--qti-focus-offset, 2px);
39
88
  `;
40
89
  export const dis = css `
41
90
  cursor: not-allowed;
@@ -43,6 +92,6 @@ export const dis = css `
43
92
  `;
44
93
  export const ind = css `
45
94
  ${form};
46
- border: 1px solid gray;
95
+ border: var(--qti-border-width, var(--cito-border-width, 1px)) solid var(--qti-border-color, GrayText);
47
96
  `;
48
97
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAatB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;;;;CAKP,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;CAEhC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;CAG3B,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;;;CAGrB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;CAEP,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\n/*\n * The resting look of the test controls (next, prev, item/section links, TTS buttons).\n *\n * Paint reads the qti-theme tokens, so a theme or brand that re-values them repaints the test\n * chrome along with the items; every token has a literal fallback equal to the theme's own\n * default, so the controls look the same without qti-theme loaded. A `--test-button-*` slot\n * in front of each token repaints the test controls alone.\n */\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--test-button-size, 2.25rem);\n padding: 0 0.875rem;\n font: inherit;\n line-height: 1.25;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));\n color: var(--test-button-color, var(--qti-component-color, inherit));\n border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)\n var(--test-button-border-color, var(--qti-component-border-color, #0175aa));\n`;\n\n/** Hover and keyboard focus; paint only, so the box never moves. */\nexport const btnInteractive = css`\n background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));\n`;\n\nexport const focusRing = css`\n outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);\n outline-offset: 2px;\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.45;\n`;\n\nexport const ind = css`\n ${form};\n border: 1px solid gray;\n`;\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,OAAO,GAAG,GAAG,CAAA,+DAA+D,CAAC;AACnF,MAAM,OAAO,GAAG,GAAG,CAAA,2EAA2E,CAAC;AAC/F,MAAM,OAAO,GAAG,GAAG,CAAA,iEAAiE,CAAC;AACrF,MAAM,cAAc,GAAG,GAAG,CAAA,6EAA6E,CAAC;AAExG,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAatB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;0DACkD,OAAO;;;kFAGiB,OAAO,SAAS,OAAO;CACxG,CAAC;AAEF,+GAA+G;AAC/G,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;kEACqC,OAAO;4CAC7B,cAAc;8DACI,OAAO;CACpE,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;0BAGP,OAAO,KAAK,OAAO;;CAE5C,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;0BAGd,OAAO,KAAK,cAAc;;CAEnD,CAAC;AAEF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;0BAGF,OAAO,KAAK,OAAO;;CAE5C,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;;;0BAGT,OAAO,KAAK,cAAc;;CAEnD,CAAC;AAEF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;CAG3B,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;;;CAGrB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;CAEP,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\n/*\n * The resting look of the test controls (next, prev, item/section links, TTS buttons).\n *\n * Two looks, both plain: a neutral one (the page's surface, the theme's border, the surrounding text\n * colour) and a filled one that `test-next` wears, in the theme's neutral colour with its content\n * colour on top. No shadow, no glow, no transition, so the controls read as unbranded until a host\n * repaints them.\n *\n * Every colour is the theme's tier 1 (CONTRACT.md §8 in qti-theme), with a CSS system colour behind\n * it for a page that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the\n * controls stay legible in dark mode without the theme too. Hover and press mix the content colour\n * into the fill, by --qti-hover-mix and --qti-active-mix.\n *\n * Paint comes from the `--test-button-*` slots, which repaint the test controls alone, and never\n * from the shared `--qti-component-*` tokens: those also paint the items' own borders, and a change\n * to how a button looks must not move an interaction.\n *\n * --test-button-background-color, --test-button-color, --test-button-border-color,\n * --test-button-hover-background-color, --test-button-active-background-color\n * the neutral look, and the filled look's slots\n * --test-button-primary-background-color, --test-button-primary-color,\n * --test-button-primary-hover-background-color, --test-button-primary-active-background-color\n * the filled look only\n */\n\nconst surface = css`var(--qti-color-base-100, var(--cito-color-base-100, Canvas))`;\nconst content = css`var(--qti-color-base-content, var(--cito-color-base-content, CanvasText))`;\nconst neutral = css`var(--qti-color-neutral, var(--cito-color-neutral, CanvasText))`;\nconst neutralContent = css`var(--qti-color-neutral-content, var(--cito-color-neutral-content, Canvas))`;\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--test-button-size, 2.25rem);\n padding: 0 0.875rem;\n font: inherit;\n line-height: 1.25;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--test-button-background-color, ${surface});\n color: var(--test-button-color, inherit);\n border: var(--qti-border-width, var(--cito-border-width, 1px)) solid\n var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})));\n`;\n\n/** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */\nexport const btnPrimary = css`\n background-color: var(--test-button-primary-background-color, ${neutral});\n color: var(--test-button-primary-color, ${neutralContent});\n border-color: var(--test-button-primary-background-color, ${neutral});\n`;\n\n/** Hover; paint only, so the box never moves. */\nexport const btnInteractive = css`\n background-color: var(\n --test-button-hover-background-color,\n color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%))\n );\n`;\n\nexport const btnPrimaryInteractive = css`\n background-color: var(\n --test-button-primary-hover-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))\n );\n`;\n\n/** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */\nexport const btnActive = css`\n background-color: var(\n --test-button-active-background-color,\n color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%))\n );\n`;\n\nexport const btnPrimaryActive = css`\n background-color: var(\n --test-button-primary-active-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))\n );\n`;\n\n/** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */\nexport const focusRing = css`\n outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, Highlight);\n outline-offset: var(--qti-focus-offset, 2px);\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.45;\n`;\n\nexport const ind = css`\n ${form};\n border: var(--qti-border-width, var(--cito-border-width, 1px)) solid var(--qti-border-color, GrayText);\n`;\n"]}
@@ -46,8 +46,13 @@ export class TestBookmark extends LitElement {
46
46
  :host {
47
47
  ${styles.btn};
48
48
  }
49
- :host(:hover:not([disabled])) {
50
- ${styles.btnInteractive};
49
+ @media (hover: hover) and (pointer: fine) {
50
+ :host(:hover:not([disabled])) {
51
+ ${styles.btnInteractive};
52
+ }
53
+ }
54
+ :host(:active:not([disabled])) {
55
+ ${styles.btnActive};
51
56
  }
52
57
  :host {
53
58
  display: inline-flex;
@@ -1 +1 @@
1
- {"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAqD,EAAY,EAAE,CACjG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AAE1C,2HAA2H;AAC3H,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAsB,EAAE;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC3D,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC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QAChG,4FAA4F;QAC5F,cAAc,CAAC,IAAI,EAAE,+BAA+B,EAAE;YACpD,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;SACrC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,qGAAqG,CAAC;IACnH,CAAC;;AA/FS;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACa;AAEf;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAoB;AAEnB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { consume } from '@lit/context';\nimport { property } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { pluginState } from '../../plugin-state';\n\nimport type { ComputedContext } from '@qti-components/base';\n\ndeclare module '../../types/qti-test-state' {\n interface QtiTestPluginState {\n /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */\n bookmarks: string[];\n }\n}\n\n/** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */\nexport const bookmarkedItems = (context: Pick<ComputedContext, 'plugins'> | undefined): string[] =>\n pluginState(context, 'bookmarks') ?? [];\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A toggle that marks the item on screen to come back to. The marks live in the test's state under\n * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a\n * reloaded test shows them again.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in\n * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button\n * (`role=\"button\"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is\n * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads\n * the marks with `bookmarkedItems(computedContext)`.\n *\n * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a\n * stamp template that lists the items of a section, `<test-bookmark item=\"{{ item.identifier }}\">`\n * puts a button next to each one.\n *\n * @slot - The label.\n * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.\n * @attr bookmarked - Reflected: the item on screen is bookmarked.\n * @attr disabled - Reflected: there is no item on screen.\n */\nexport class TestBookmark extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext?: ComputedContext;\n\n @property({ reflect: true }) item?: string;\n\n @property({ type: Boolean, reflect: true }) bookmarked = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host {\n display: inline-flex;\n align-items: center;\n gap: 0.4em;\n }\n svg {\n width: 1.1em;\n height: 1.1em;\n flex: none;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n }\n :host([bookmarked]) {\n color: var(--qti-bookmark-color, #b45309);\n }\n :host([bookmarked]) svg {\n fill: currentColor;\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#toggle());\n this.addEventListener('keydown', event => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n this.#toggle();\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'button');\n if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', '0');\n }\n\n /** The item this button marks: its own, or else the one on screen. */\n get #activeItem(): string | undefined {\n return (\n this.item ||\n (itemRefOf(this) ??\n this.computedContext?.testParts\n ?.flatMap(part => part.sections.flatMap(section => section.items))\n .find(item => item.active)?.identifier)\n );\n }\n\n protected override willUpdate(): void {\n const active = this.#activeItem;\n this.disabled = !active;\n this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);\n }\n\n protected override updated(): void {\n this.setAttribute('aria-pressed', String(this.bookmarked));\n this.setAttribute('aria-disabled', String(this.disabled));\n }\n\n #toggle(): void {\n const active = this.#activeItem;\n if (!active) return;\n const marked = bookmarkedItems(this.computedContext);\n const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];\n // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.\n dispatchPublic(this, 'cito-test-update-plugin-state', {\n plugin: 'bookmarks',\n value: next.length > 0 ? next : null\n });\n }\n\n override render() {\n return html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
1
+ {"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAA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it/context';\nimport { property } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { pluginState } from '../../plugin-state';\n\nimport type { ComputedContext } from '@qti-components/base';\n\ndeclare module '../../types/qti-test-state' {\n interface QtiTestPluginState {\n /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */\n bookmarks: string[];\n }\n}\n\n/** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */\nexport const bookmarkedItems = (context: Pick<ComputedContext, 'plugins'> | undefined): string[] =>\n pluginState(context, 'bookmarks') ?? [];\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A toggle that marks the item on screen to come back to. The marks live in the test's state under\n * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a\n * reloaded test shows them again.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in\n * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button\n * (`role=\"button\"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is\n * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads\n * the marks with `bookmarkedItems(computedContext)`.\n *\n * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a\n * stamp template that lists the items of a section, `<test-bookmark item=\"{{ item.identifier }}\">`\n * puts a button next to each one.\n *\n * @slot - The label.\n * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.\n * @attr bookmarked - Reflected: the item on screen is bookmarked.\n * @attr disabled - Reflected: there is no item on screen.\n */\nexport class TestBookmark extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext?: ComputedContext;\n\n @property({ reflect: true }) item?: string;\n\n @property({ type: Boolean, reflect: true }) bookmarked = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host {\n display: inline-flex;\n align-items: center;\n gap: 0.4em;\n }\n svg {\n width: 1.1em;\n height: 1.1em;\n flex: none;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n }\n :host([bookmarked]) {\n color: var(--qti-bookmark-color, #b45309);\n }\n :host([bookmarked]) svg {\n fill: currentColor;\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#toggle());\n this.addEventListener('keydown', event => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n this.#toggle();\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'button');\n if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', '0');\n }\n\n /** The item this button marks: its own, or else the one on screen. */\n get #activeItem(): string | undefined {\n return (\n this.item ||\n (itemRefOf(this) ??\n this.computedContext?.testParts\n ?.flatMap(part => part.sections.flatMap(section => section.items))\n .find(item => item.active)?.identifier)\n );\n }\n\n protected override willUpdate(): void {\n const active = this.#activeItem;\n this.disabled = !active;\n this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);\n }\n\n protected override updated(): void {\n this.setAttribute('aria-pressed', String(this.bookmarked));\n this.setAttribute('aria-disabled', String(this.disabled));\n }\n\n #toggle(): void {\n const active = this.#activeItem;\n if (!active) return;\n const marked = bookmarkedItems(this.computedContext);\n const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];\n // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.\n dispatchPublic(this, 'cito-test-update-plugin-state', {\n plugin: 'bookmarks',\n value: next.length > 0 ? next : null\n });\n }\n\n override render() {\n return html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
@@ -20,8 +20,13 @@ export class TestCheckItem extends LitElement {
20
20
  :host {
21
21
  ${styles.btn};
22
22
  }
23
- :host(:hover:not([disabled])) {
24
- ${styles.btnInteractive};
23
+ @media (hover: hover) and (pointer: fine) {
24
+ :host(:hover:not([disabled])) {
25
+ ${styles.btnInteractive};
26
+ }
27
+ }
28
+ :host(:active:not([disabled])) {
29
+ ${styles.btnActive};
25
30
  }
26
31
  :host(:focus-visible) {
27
32
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;aAG3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAEF;QACE,KAAK,EAAE,CAAC;QAlBkB,SAAI,GAAS,QAAQ,CAAC;QAmBhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AA3B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { View } from '@qti-components/base';\n\n/**\n * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which\n * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until\n * something switches it back (`test-view-toggle`).\n *\n * @attr view - The view to switch to after the attempt ended.\n */\nexport class TestCheckItem extends LitElement {\n @property({ type: String }) view: View = 'scorer';\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n dispatchPublic(this, 'cito-test-switch-view', this.view);\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
1
+ {"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;aAG3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAEF;QACE,KAAK,EAAE,CAAC;QAvBkB,SAAI,GAAS,QAAQ,CAAC;QAwBhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAhC2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { View } from '@qti-components/base';\n\n/**\n * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which\n * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until\n * something switches it back (`test-view-toggle`).\n *\n * @attr view - The view to switch to after the attempt ended.\n */\nexport class TestCheckItem extends LitElement {\n @property({ type: String }) view: View = 'scorer';\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n dispatchPublic(this, 'cito-test-switch-view', this.view);\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
@@ -21,8 +21,13 @@ export class TestEndAttempt extends LitElement {
21
21
  :host {
22
22
  ${styles.btn};
23
23
  }
24
- :host(:hover:not([disabled])) {
25
- ${styles.btnInteractive};
24
+ @media (hover: hover) and (pointer: fine) {
25
+ :host(:hover:not([disabled])) {
26
+ ${styles.btnInteractive};
27
+ }
28
+ }
29
+ :host(:active:not([disabled])) {
30
+ ${styles.btnActive};
26
31
  }
27
32
  :host(:focus-visible) {
28
33
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAS5C,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QA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AI,CAAC,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YAC/C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,kFAAkF;QAClF,4CAA4C;QAC5C,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,gBAAgB,KAAK,WAAW,EAAE,CAAC;YACvE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,sEAAsE;QACtE,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;YAC1E,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,UAAU,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,KAAK,KAAK,IAAI,UAAU,CAAC,iBAAiB,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAtFS;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDACY;AAGpC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAGjC;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // An adaptive item ends itself: once its response processing set completionStatus\n // to 'completed', there is no next attempt.\n if (activeItem.adaptive && activeItem.completionStatus === 'completed') {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
1
+ {"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAS5C,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAEF;QACE,KAAK,EAAE,CAAC;QA9BH,sBAAiB,GAAG,KAAK,CAAC;QA+B/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YACjC,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,C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AC;YAC9B,OAAO;QACT,CAAC;QAED,sEAAsE;QACtE,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;YAC1E,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,UAAU,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,KAAK,KAAK,IAAI,UAAU,CAAC,iBAAiB,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AA3FS;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDACY;AAGpC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAGjC;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // An adaptive item ends itself: once its response processing set completionStatus\n // to 'completed', there is no next attempt.\n if (activeItem.adaptive && activeItem.completionStatus === 'completed') {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
@@ -13,8 +13,13 @@ export class TestItemLink extends LitElement {
13
13
  :host {
14
14
  ${styles.btn};
15
15
  }
16
- :host(:hover:not([disabled])) {
17
- ${styles.btnInteractive};
16
+ @media (hover: hover) and (pointer: fine) {
17
+ :host(:hover:not([disabled])) {
18
+ ${styles.btnInteractive};
19
+ }
20
+ }
21
+ :host(:active:not([disabled])) {
22
+ ${styles.btnActive};
18
23
  }
19
24
  :host(:focus-visible) {
20
25
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAKF;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
1
+ {"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAKF;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
@@ -31,9 +31,15 @@ export class TestNext extends LitElement {
31
31
  static { this.styles = css `
32
32
  :host {
33
33
  ${styles.btn};
34
+ ${styles.btnPrimary};
34
35
  }
35
- :host(:hover:not([disabled])) {
36
- ${styles.btnInteractive};
36
+ @media (hover: hover) and (pointer: fine) {
37
+ :host(:hover:not([disabled])) {
38
+ ${styles.btnPrimaryInteractive};
39
+ }
40
+ }
41
+ :host(:active:not([disabled])) {
42
+ ${styles.btnPrimaryActive};
37
43
  }
38
44
  :host(:focus-visible) {
39
45
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-next.js","sourceRoot":"","sources":["../../../src/components/test-next/test-next.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAWtC,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IACF,UAAU,CAAmB;IAE7B;QACE,KAAK,EAAE,CAAC;QAhCH,sBAAiB,GAAG,IAAI,CAAC;QAkC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,QAAQ,CAAC;QAChC,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,WAAW,CAAC;QAExC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,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cAAc,CAAC;QAChF,MAAM,cAAc,GAAG,aAAa,EAAE,cAAc,IAAI,QAAQ,CAAC,cAAc,CAAC;QAChF,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAErD,MAAM,kBAAkB,GAAG,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,YAAY,CAAC;QAE1F,yEAAyE;QACzE,8EAA8E;QAC9E,+EAA+E;QAC/E,yEAAyE;QACzE,2DAA2D;QAC3D,IAAI,CAAC,iBAAiB;YACpB,CAAC,IAAI,CAAC,eAAe;gBACrB,IAAI,CAAC,SAAS,GAAG,CAAC;gBAClB,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;gBACtD,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AAtFM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGtB;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACZ;AAM3C;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the next test item.\n *\n * @remarks\n * This element provides functionality for navigating to the next test item.\n *\n * @example\n * ```html\n * <test-next></test-next>\n * ```\n */\n\nexport class TestNext extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n #internals: ElementInternals;\n\n constructor() {\n super();\n\n this.#internals = this.attachInternals();\n this.#internals.role = 'button';\n this.#internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.checkDisabled();\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const activeSection = testPart.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart.navigationMode;\n const submissionMode = activeSection?.submissionMode || testPart.submissionMode;\n const activeItem = this.sectionItems[this.itemIndex];\n\n const isLinearIndividual = navigationMode === 'linear' && submissionMode === 'individual';\n\n // In linear individual mode the candidate may only advance once they are\n // \"done\" with the active item: they reached the optimal outcome (best score),\n // exhausted maxAttempts, or the item has no judgeable optimal value. `done` is\n // computed centrally in test-navigation (#isItemDone), so this Next gate\n // matches the exact rule that decides an item is resolved.\n this._internalDisabled =\n !this.computedContext ||\n this.itemIndex < 0 ||\n this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 ||\n (isLinearIndividual && !activeItem?.done);\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-next': TestNext;\n }\n}\n"]}
1
+ {"version":3,"file":"test-next.js","sourceRoot":"","sources":["../../../src/components/test-next/test-next.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAWtC,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;QACV,MAAM,CAAC,UAAU;;;;UAIf,MAAM,CAAC,qBAAqB;;;;QAI9B,MAAM,CAAC,gBAAgB;;;QAGvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAA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AE,CAAC;mDAClC;AAGtB;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACZ;AAM3C;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the next test item.\n *\n * @remarks\n * This element provides functionality for navigating to the next test item.\n *\n * @example\n * ```html\n * <test-next></test-next>\n * ```\n */\n\nexport class TestNext extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n ${styles.btnPrimary};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnPrimaryInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnPrimaryActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n #internals: ElementInternals;\n\n constructor() {\n super();\n\n this.#internals = this.attachInternals();\n this.#internals.role = 'button';\n this.#internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.checkDisabled();\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const activeSection = testPart.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart.navigationMode;\n const submissionMode = activeSection?.submissionMode || testPart.submissionMode;\n const activeItem = this.sectionItems[this.itemIndex];\n\n const isLinearIndividual = navigationMode === 'linear' && submissionMode === 'individual';\n\n // In linear individual mode the candidate may only advance once they are\n // \"done\" with the active item: they reached the optimal outcome (best score),\n // exhausted maxAttempts, or the item has no judgeable optimal value. `done` is\n // computed centrally in test-navigation (#isItemDone), so this Next gate\n // matches the exact rule that decides an item is resolved.\n this._internalDisabled =\n !this.computedContext ||\n this.itemIndex < 0 ||\n this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 ||\n (isLinearIndividual && !activeItem?.done);\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-next': TestNext;\n }\n}\n"]}
@@ -32,8 +32,13 @@ export class TestPrev extends LitElement {
32
32
  :host {
33
33
  ${styles.btn};
34
34
  }
35
- :host(:hover:not([disabled])) {
36
- ${styles.btnInteractive};
35
+ @media (hover: hover) and (pointer: fine) {
36
+ :host(:hover:not([disabled])) {
37
+ ${styles.btnInteractive};
38
+ }
39
+ }
40
+ :host(:active:not([disabled])) {
41
+ ${styles.btnActive};
37
42
  }
38
43
  :host(:focus-visible) {
39
44
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-prev.js","sourceRoot":"","sources":["../../../src/components/test-prev/test-prev.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO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AAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACd;AAMzC;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n\nexport class TestPrev extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const activeSection = testPart?.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || 'nonlinear';\n\n this._internalDisabled =\n navigationMode === 'linear' || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-prev': TestPrev;\n }\n}\n"]}
1
+ {"version":3,"file":"test-prev.js","sourceRoot":"","sources":["../../../src/components/test-prev/test-prev.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAWtC,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAEF;QACE,KAAK,EAAE,CAAC;QApCH,sBAAiB,GAAG,IAAI,CAAC;QAsC9B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,C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,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC;IAC1G,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AApEM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGxB;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACd;AAMzC;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n\nexport class TestPrev extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const activeSection = testPart?.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || 'nonlinear';\n\n this._internalDisabled =\n navigationMode === 'linear' || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-prev': TestPrev;\n }\n}\n"]}
@@ -13,8 +13,13 @@ export class TestSectionLink extends LitElement {
13
13
  :host {
14
14
  ${styles.btn};
15
15
  }
16
- :host(:hover:not([disabled])) {
17
- ${styles.btnInteractive};
16
+ @media (hover: hover) and (pointer: fine) {
17
+ :host(:hover:not([disabled])) {
18
+ ${styles.btnInteractive};
19
+ }
20
+ }
21
+ :host(:active:not([disabled])) {
22
+ ${styles.btnActive};
18
23
  }
19
24
  :host(:focus-visible) {
20
25
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-section-link.js","sourceRoot":"","sources":["../../../src/components/test-section-link/test-section-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAKF,YAAY,CAAC,UAAkB;QAC7B,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAPF,cAAS,GAAW,IAAI,CAAC;QAQ/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestSectionLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'section-id' })\n private sectionId: string = null;\n\n #requestItem(identifier: string) {\n dispatchPublic(this, 'cito-test-navigate', { type: 'section', id: identifier });\n }\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#requestItem(this.sectionId));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-link': TestSectionLink;\n }\n}\n"]}
1
+ {"version":3,"file":"test-section-link.js","sourceRoot":"","sources":["../../../src/components/test-section-link/test-section-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAKF,YAAY,CAAC,UAAkB;QAC7B,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAPF,cAAS,GAAW,IAAI,CAAC;QAQ/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestSectionLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'section-id' })\n private sectionId: string = null;\n\n #requestItem(identifier: string) {\n dispatchPublic(this, 'cito-test-navigate', { type: 'section', id: identifier });\n }\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#requestItem(this.sectionId));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-link': TestSectionLink;\n }\n}\n"]}
@@ -2,8 +2,9 @@ import { LitElement } from 'lit';
2
2
  import type { PropertyValues } from 'lit';
3
3
  import type { TemplateFunction } from '@heximal/templates';
4
4
  /**
5
- * A custom web component that renders a test stamp using the Lit framework.
6
- * This component is deprecated and will be removed in the future.
5
+ * The stamp plugin: renders its `<template>` child with the state of the test (`test`,
6
+ * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player
7
+ * can show progress or numbered navigation without writing a component.
7
8
  * @customElement
8
9
  * @extends {LitElement}
9
10
  */
@@ -10,8 +10,9 @@ import { prepareTemplate } from '@heximal/templates';
10
10
  import { consume } from '@lit/context';
11
11
  import { computedContext } from '@qti-components/base';
12
12
  /**
13
- * A custom web component that renders a test stamp using the Lit framework.
14
- * This component is deprecated and will be removed in the future.
13
+ * The stamp plugin: renders its `<template>` child with the state of the test (`test`,
14
+ * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player
15
+ * can show progress or numbered navigation without writing a component.
15
16
  * @customElement
16
17
  * @extends {LitElement}
17
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"test-stamp.js","sourceRoot":"","sources":["../../../src/components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I,CAAC,eAAe,CAAC,IAAI;YAC/B,UAAU,EAAE,aAAa;YACzB,aAAa,EAAE,gBAAgB;YAC/B,cAAc,EAAE,iBAAiB;YACjC,IAAI,EAAE,UAAU;SACjB,CAAC;QACF,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,2BAA2B,EAAE;YAC3C,MAAM,EAAE,IAAI,CAAC,YAAY;YACzB,OAAO,EAAE,IAAI;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,0CAA0C;QAC1C,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA,eAAe,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO;MACjH,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;CACF;AA3FQ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCACtB;AAIb;IAFP,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDACd;AAGjC;IADP,KAAK,EAAE;+CAkBN","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { View } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * A custom web component that renders a test stamp using the Lit framework.\n * This component is deprecated and will be removed in the future.\n * @customElement\n * @extends {LitElement}\n */\n\nexport class TestStamp extends LitElement {\n /**\n * Indicates whether the component is in debug mode.\n * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.\n */\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n view?: View;\n test?: unknown;\n activeTestpart?: unknown;\n activeSection?: unknown;\n activeItem?: unknown;\n } = {\n view: 'candidate',\n activeItem: {},\n activeSection: {\n items: []\n },\n activeTestpart: {\n items: [],\n sections: []\n },\n test: {}\n };\n\n myTemplate: TemplateFunction;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n return;\n }\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = activeTestPart?.sections.find(section => section.active);\n const activeItem = activeSection?.items.find(item => item.active);\n // In `navigate=\"section\"` the test shows a section, not one item, so there may be no active item.\n const { variables, ...augmentedItem } = activeItem || {};\n\n if (!activeTestPart) {\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),\n sections: activeTestPart.sections.map(section => ({\n ...section,\n items: section.items.map(({ variables, ...rest }) => rest)\n }))\n };\n\n const augmentedSection = {\n ...activeSection,\n items: (activeSection?.items ?? []).map(({ variables, ...rest }) => rest)\n };\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n view: this.computedContext.view,\n activeItem: augmentedItem,\n activeSection: augmentedSection,\n activeTestpart: augmentedTestPart,\n test: activeTest\n };\n this.dispatchEvent(\n new CustomEvent('qti-stamp-context-updated', {\n detail: this.stampContext,\n bubbles: true\n })\n );\n }\n\n override render() {\n // if (!this.stampContext) return nothing;\n return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}\n ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"]}
1
+ {"version":3,"file":"test-stamp.js","sourceRoot":"","sources":["../../../src/components/test-stamp/test-stamp.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOvD;;;;;;GAMG;AAEH,MAAM,OAAO,SAAU,SAAQ,UAAU;IAAzC;;QACE;;;WAGG;QAEI,UAAK,GAAG,KAAK,CAAC;QAOb,iBAAY,GAMhB;YACF,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE,EAAE;YACd,aAAa,EAAE;gBACb,KAAK,EAAE,EAAE;aACV;YACD,cAAc,EAAE;gBACd,KAAK,EAAE,EAAE;gBACT,QAAQ,EAAE,EAAE;aACb;YACD,IAAI,EAAE,EAAE;SACT,CAAC;IAmEJ,CAAC;IA/DoB,gBAAgB;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAsB,UAAU,CAAC,CAAC;QAC5E,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,e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I,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;SAC1E,CAAC;QACF,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QAE1D,IAAI,CAAC,YAAY,GAAG;YAClB,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;YAC/B,UAAU,EAAE,aAAa;YACzB,aAAa,EAAE,gBAAgB;YAC/B,cAAc,EAAE,iBAAiB;YACjC,IAAI,EAAE,UAAU;SACjB,CAAC;QACF,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,2BAA2B,EAAE;YAC3C,MAAM,EAAE,IAAI,CAAC,YAAY;YACzB,OAAO,EAAE,IAAI;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,0CAA0C;QAC1C,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA,eAAe,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO;MACjH,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;CACF;AA3FQ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCACtB;AAIb;IAFP,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDACd;AAGjC;IADP,KAAK,EAAE;+CAkBN","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { View } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * The stamp plugin: renders its `<template>` child with the state of the test (`test`,\n * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player\n * can show progress or numbered navigation without writing a component.\n * @customElement\n * @extends {LitElement}\n */\n\nexport class TestStamp extends LitElement {\n /**\n * Indicates whether the component is in debug mode.\n * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.\n */\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n view?: View;\n test?: unknown;\n activeTestpart?: unknown;\n activeSection?: unknown;\n activeItem?: unknown;\n } = {\n view: 'candidate',\n activeItem: {},\n activeSection: {\n items: []\n },\n activeTestpart: {\n items: [],\n sections: []\n },\n test: {}\n };\n\n myTemplate: TemplateFunction;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n return;\n }\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = activeTestPart?.sections.find(section => section.active);\n const activeItem = activeSection?.items.find(item => item.active);\n // In `navigate=\"section\"` the test shows a section, not one item, so there may be no active item.\n const { variables, ...augmentedItem } = activeItem || {};\n\n if (!activeTestPart) {\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),\n sections: activeTestPart.sections.map(section => ({\n ...section,\n items: section.items.map(({ variables, ...rest }) => rest)\n }))\n };\n\n const augmentedSection = {\n ...activeSection,\n items: (activeSection?.items ?? []).map(({ variables, ...rest }) => rest)\n };\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n view: this.computedContext.view,\n activeItem: augmentedItem,\n activeSection: augmentedSection,\n activeTestpart: augmentedTestPart,\n test: activeTest\n };\n this.dispatchEvent(\n new CustomEvent('qti-stamp-context-updated', {\n detail: this.stampContext,\n bubbles: true\n })\n );\n }\n\n override render() {\n // if (!this.stampContext) return nothing;\n return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}\n ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Scores the test: on click the test resets its outcomes to their declared defaults, runs its
4
+ * outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.
5
+ * The host decides where it sits, for example on the last item or in a review view.
6
+ */
7
+ export declare class TestSubmit extends LitElement {
8
+ static styles: import("lit").CSSResult;
9
+ constructor();
10
+ render(): import("lit").TemplateResult<1>;
11
+ }
12
+ declare global {
13
+ interface HTMLElementTagNameMap {
14
+ 'test-submit': TestSubmit;
15
+ }
16
+ }