@qti-components/test 1.10.0 → 2.0.0-next.10

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 (81) hide show
  1. package/dist/components/index.d.ts +0 -11
  2. package/dist/components/index.js +0 -11
  3. package/dist/components/index.js.map +1 -1
  4. package/dist/components/qti-test/getting-started.fixtures.d.ts +6 -0
  5. package/dist/components/qti-test/getting-started.fixtures.js +7 -0
  6. package/dist/components/qti-test/getting-started.fixtures.js.map +1 -0
  7. package/dist/components/qti-test/qti-test.d.ts +1 -0
  8. package/dist/components/qti-test/showcase.fixtures.d.ts +6 -0
  9. package/dist/components/qti-test/showcase.fixtures.js +7 -0
  10. package/dist/components/qti-test/showcase.fixtures.js.map +1 -0
  11. package/dist/components/styles.d.ts +8 -1
  12. package/dist/components/styles.js +63 -14
  13. package/dist/components/styles.js.map +1 -1
  14. package/dist/components/test-bookmark/test-bookmark.d.ts +48 -0
  15. package/dist/components/test-bookmark/test-bookmark.js +149 -0
  16. package/dist/components/test-bookmark/test-bookmark.js.map +1 -0
  17. package/dist/components/test-check-item/test-check-item.d.ts +9 -2
  18. package/dist/components/test-check-item/test-check-item.js +19 -13
  19. package/dist/components/test-check-item/test-check-item.js.map +1 -1
  20. package/dist/components/test-end-attempt/test-end-attempt.js +7 -2
  21. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  22. package/dist/components/test-item-link/test-item-link.js +7 -2
  23. package/dist/components/test-item-link/test-item-link.js.map +1 -1
  24. package/dist/components/test-navigation/test-navigation.js +8 -2
  25. package/dist/components/test-navigation/test-navigation.js.map +1 -1
  26. package/dist/components/test-next/test-next.js +8 -2
  27. package/dist/components/test-next/test-next.js.map +1 -1
  28. package/dist/components/test-prev/test-prev.js +7 -2
  29. package/dist/components/test-prev/test-prev.js.map +1 -1
  30. package/dist/components/test-print-item-variables/test-print-item-variables.d.ts +5 -0
  31. package/dist/components/test-print-item-variables/test-print-item-variables.js +19 -7
  32. package/dist/components/test-print-item-variables/test-print-item-variables.js.map +1 -1
  33. package/dist/components/test-section-link/test-section-link.js +7 -2
  34. package/dist/components/test-section-link/test-section-link.js.map +1 -1
  35. package/dist/components/test-stamp/test-stamp.d.ts +3 -2
  36. package/dist/components/test-stamp/test-stamp.js +9 -4
  37. package/dist/components/test-stamp/test-stamp.js.map +1 -1
  38. package/dist/components/test-submit/test-submit.d.ts +16 -0
  39. package/dist/components/test-submit/test-submit.js +37 -0
  40. package/dist/components/test-submit/test-submit.js.map +1 -0
  41. package/dist/elements.d.ts +34 -44
  42. package/dist/elements.js +4 -30
  43. package/dist/elements.js.map +1 -1
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.js +2 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/mixins/test-navigation.mixin.js +4 -2
  48. package/dist/mixins/test-navigation.mixin.js.map +1 -1
  49. package/dist/mixins/test-processing.mixin.d.ts +1 -0
  50. package/dist/mixins/test-processing.mixin.js +22 -1
  51. package/dist/mixins/test-processing.mixin.js.map +1 -1
  52. package/dist/mixins/test-state.mixin.js +25 -1
  53. package/dist/mixins/test-state.mixin.js.map +1 -1
  54. package/dist/plugin-state.d.ts +8 -0
  55. package/dist/plugin-state.js +7 -0
  56. package/dist/plugin-state.js.map +1 -0
  57. package/dist/plugins/elements.d.ts +75 -0
  58. package/dist/plugins/elements.js +35 -0
  59. package/dist/plugins/elements.js.map +1 -0
  60. package/dist/plugins/index.d.ts +2 -0
  61. package/dist/plugins/index.js +3 -0
  62. package/dist/plugins/index.js.map +1 -0
  63. package/dist/public-events.d.ts +9 -0
  64. package/dist/public-events.js +3 -0
  65. package/dist/public-events.js.map +1 -1
  66. package/dist/tts/elements.d.ts +28 -0
  67. package/dist/tts/elements.js +14 -0
  68. package/dist/tts/elements.js.map +1 -0
  69. package/dist/{components/test-item-to-speech → tts}/test-item-to-speech.d.ts +9 -9
  70. package/dist/{components/test-item-to-speech → tts}/test-item-to-speech.js +81 -92
  71. package/dist/tts/test-item-to-speech.js.map +1 -0
  72. package/dist/types/qti-test-state.d.ts +12 -1
  73. package/dist/types/qti-test-state.js.map +1 -1
  74. package/package.json +11 -7
  75. package/dist/components/test-item-to-speech/test-item-to-speech.js.map +0 -1
  76. package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.d.ts +0 -19
  77. package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js +0 -39
  78. package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js.map +0 -1
  79. package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.d.ts +0 -19
  80. package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js +0 -39
  81. package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js.map +0 -1
@@ -14,18 +14,7 @@ export * from '../components/qti-item-session-control/qti-item-session-control';
14
14
  export * from './test-navigation/test-navigation';
15
15
  export * from './test-next/test-next';
16
16
  export * from './test-prev/test-prev';
17
- export * from './test-view-toggle/test-view';
18
17
  export * from './test-item-link/test-item-link';
19
18
  export * from './test-end-attempt/test-end-attempt';
20
- export * from './test-paging-buttons-stamp/test-paging-buttons-stamp';
21
19
  export * from './test-container/test-container';
22
- export * from './test-print-item-variables/test-print-item-variables';
23
- export * from './test-section-buttons-stamp/test-section-buttons-stamp';
24
20
  export * from './test-section-link/test-section-link';
25
- export * from './test-print-context/test-print-context';
26
- export * from './test-stamp/test-stamp';
27
- export * from './test-scoring-buttons/test-scoring-buttons';
28
- export * from './test-view-toggle/test-view-toggle';
29
- export * from './test-scoring-feedback/test-scoring-feedback';
30
- export * from './test-check-item/test-check-item';
31
- export * from './test-item-to-speech/test-item-to-speech';
@@ -15,19 +15,8 @@ export * from '../components/qti-item-session-control/qti-item-session-control';
15
15
  export * from './test-navigation/test-navigation';
16
16
  export * from './test-next/test-next';
17
17
  export * from './test-prev/test-prev';
18
- export * from './test-view-toggle/test-view';
19
18
  export * from './test-item-link/test-item-link';
20
19
  export * from './test-end-attempt/test-end-attempt';
21
- export * from './test-paging-buttons-stamp/test-paging-buttons-stamp';
22
20
  export * from './test-container/test-container';
23
- export * from './test-print-item-variables/test-print-item-variables';
24
- export * from './test-section-buttons-stamp/test-section-buttons-stamp';
25
21
  export * from './test-section-link/test-section-link';
26
- export * from './test-print-context/test-print-context';
27
- export * from './test-stamp/test-stamp';
28
- export * from './test-scoring-buttons/test-scoring-buttons';
29
- export * from './test-view-toggle/test-view-toggle';
30
- export * from './test-scoring-feedback/test-scoring-feedback';
31
- export * from './test-check-item/test-check-item';
32
- export * from './test-item-to-speech/test-item-to-speech';
33
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,cAAc,iCAAiC,CAAC;AAChD,cAAc,+DAA+D,CAAC;AAC9E,cAAc,6DAA6D,CAAC;AAC5E,cAAc,uDAAuD,CAAC;AACtE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mDAAmD,CAAC;AAClE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,qDAAqD,CAAC;AACpE,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iEAAiE,CAAC;AAEhF,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uDAAuD,CAAC;AACtE,cAAc,iCAAiC,CAAC;AAChD,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC","sourcesContent":["/* test functionality webcomponents which are tested and can be used in your project */\nexport * from '../components/qti-test/qti-test';\nexport * from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nexport * from '../components/qti-assessment-section/qti-assessment-section';\nexport * from '../components/qti-assessment-test/qti-assessment-test';\nexport * from '../components/qti-test-part/qti-test-part';\nexport * from '../components/qti-test-feedback/qti-test-feedback';\nexport * from '../components/qti-outcome-processing/qti-outcome-processing';\nexport * from '../components/qti-test-variables/qti-test-variables';\nexport * from '../components/qti-number-selected/qti-number-selected';\nexport * from '../components/qti-number-presented/qti-number-presented';\nexport * from '../components/qti-pre-condition/qti-pre-condition';\nexport * from '../components/qti-branch-rule/qti-branch-rule';\nexport * from '../components/qti-item-session-control/qti-item-session-control';\n\nexport * from './test-navigation/test-navigation';\nexport * from './test-next/test-next';\nexport * from './test-prev/test-prev';\nexport * from './test-view-toggle/test-view';\nexport * from './test-item-link/test-item-link';\nexport * from './test-end-attempt/test-end-attempt';\nexport * from './test-paging-buttons-stamp/test-paging-buttons-stamp';\nexport * from './test-container/test-container';\nexport * from './test-print-item-variables/test-print-item-variables';\nexport * from './test-section-buttons-stamp/test-section-buttons-stamp';\nexport * from './test-section-link/test-section-link';\nexport * from './test-print-context/test-print-context';\nexport * from './test-stamp/test-stamp';\nexport * from './test-scoring-buttons/test-scoring-buttons';\nexport * from './test-view-toggle/test-view-toggle';\nexport * from './test-scoring-feedback/test-scoring-feedback';\nexport * from './test-check-item/test-check-item';\nexport * from './test-item-to-speech/test-item-to-speech';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,cAAc,iCAAiC,CAAC;AAChD,cAAc,+DAA+D,CAAC;AAC9E,cAAc,6DAA6D,CAAC;AAC5E,cAAc,uDAAuD,CAAC;AACtE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mDAAmD,CAAC;AAClE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,qDAAqD,CAAC;AACpE,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iEAAiE,CAAC;AAEhF,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC","sourcesContent":["/* test functionality webcomponents which are tested and can be used in your project */\nexport * from '../components/qti-test/qti-test';\nexport * from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nexport * from '../components/qti-assessment-section/qti-assessment-section';\nexport * from '../components/qti-assessment-test/qti-assessment-test';\nexport * from '../components/qti-test-part/qti-test-part';\nexport * from '../components/qti-test-feedback/qti-test-feedback';\nexport * from '../components/qti-outcome-processing/qti-outcome-processing';\nexport * from '../components/qti-test-variables/qti-test-variables';\nexport * from '../components/qti-number-selected/qti-number-selected';\nexport * from '../components/qti-number-presented/qti-number-presented';\nexport * from '../components/qti-pre-condition/qti-pre-condition';\nexport * from '../components/qti-branch-rule/qti-branch-rule';\nexport * from '../components/qti-item-session-control/qti-item-session-control';\n\nexport * from './test-navigation/test-navigation';\nexport * from './test-next/test-next';\nexport * from './test-prev/test-prev';\nexport * from './test-item-link/test-item-link';\nexport * from './test-end-attempt/test-end-attempt';\nexport * from './test-container/test-container';\nexport * from './test-section-link/test-section-link';\n"]}
@@ -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
  /**
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The English showcase test: Kennisnet's demo items translated, plus an item for every interaction
3
+ * they do not cover. Its files live in `public/assets/tests/showcase/`; the README there lists the
4
+ * items and where they come from.
5
+ */
6
+ export declare const SHOWCASE_TEST = "/assets/tests/showcase/assessment.xml";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The English showcase test: Kennisnet's demo items translated, plus an item for every interaction
3
+ * they do not cover. Its files live in `public/assets/tests/showcase/`; the README there lists the
4
+ * items and where they come from.
5
+ */
6
+ export const SHOWCASE_TEST = '/assets/tests/showcase/assessment.xml';
7
+ //# sourceMappingURL=showcase.fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"showcase.fixtures.js","sourceRoot":"","sources":["../../../src/components/qti-test/showcase.fixtures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,uCAAuC,CAAC","sourcesContent":["/**\n * The English showcase test: Kennisnet's demo items translated, plus an item for every interaction\n * they do not cover. Its files live in `public/assets/tests/showcase/`; the README there lists the\n * items and where they come from.\n */\nexport const SHOWCASE_TEST = '/assets/tests/showcase/assessment.xml';\n"]}
@@ -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"]}
@@ -0,0 +1,48 @@
1
+ import { LitElement } from 'lit';
2
+ import type { ComputedContext } from '@qti-components/base';
3
+ declare module '../../types/qti-test-state' {
4
+ interface QtiTestPluginState {
5
+ /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */
6
+ bookmarks: string[];
7
+ }
8
+ }
9
+ /** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */
10
+ export declare const bookmarkedItems: (context: Pick<ComputedContext, "plugins"> | undefined) => string[];
11
+ /**
12
+ * A toggle that marks the item on screen to come back to. The marks live in the test's state under
13
+ * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a
14
+ * reloaded test shows them again.
15
+ *
16
+ * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in
17
+ * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button
18
+ * (`role="button"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is
19
+ * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads
20
+ * the marks with `bookmarkedItems(computedContext)`.
21
+ *
22
+ * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a
23
+ * stamp template that lists the items of a section, `<test-bookmark item="{{ item.identifier }}">`
24
+ * puts a button next to each one.
25
+ *
26
+ * @slot - The label.
27
+ * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.
28
+ * @attr bookmarked - Reflected: the item on screen is bookmarked.
29
+ * @attr disabled - Reflected: there is no item on screen.
30
+ */
31
+ export declare class TestBookmark extends LitElement {
32
+ #private;
33
+ protected computedContext?: ComputedContext;
34
+ item?: string;
35
+ bookmarked: boolean;
36
+ disabled: boolean;
37
+ static styles: import("lit").CSSResult;
38
+ constructor();
39
+ connectedCallback(): void;
40
+ protected willUpdate(): void;
41
+ protected updated(): void;
42
+ render(): import("lit").TemplateResult<1>;
43
+ }
44
+ declare global {
45
+ interface HTMLElementTagNameMap {
46
+ 'test-bookmark': TestBookmark;
47
+ }
48
+ }
@@ -0,0 +1,149 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, html, LitElement } from 'lit';
8
+ import { consume } from '@lit/context';
9
+ import { property } from 'lit/decorators.js';
10
+ import { computedContext } from '@qti-components/base';
11
+ import * as styles from '../styles';
12
+ import { dispatchPublic } from '../../public-events';
13
+ import { pluginState } from '../../plugin-state';
14
+ /** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */
15
+ export const bookmarkedItems = (context) => pluginState(context, 'bookmarks') ?? [];
16
+ /** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */
17
+ const itemRefOf = (element) => {
18
+ const itemRef = element.closest('qti-assessment-item-ref');
19
+ if (itemRef)
20
+ return itemRef.getAttribute('identifier') ?? undefined;
21
+ const root = element.getRootNode();
22
+ return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;
23
+ };
24
+ /**
25
+ * A toggle that marks the item on screen to come back to. The marks live in the test's state under
26
+ * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a
27
+ * reloaded test shows them again.
28
+ *
29
+ * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in
30
+ * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button
31
+ * (`role="button"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is
32
+ * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads
33
+ * the marks with `bookmarkedItems(computedContext)`.
34
+ *
35
+ * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a
36
+ * stamp template that lists the items of a section, `<test-bookmark item="{{ item.identifier }}">`
37
+ * puts a button next to each one.
38
+ *
39
+ * @slot - The label.
40
+ * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.
41
+ * @attr bookmarked - Reflected: the item on screen is bookmarked.
42
+ * @attr disabled - Reflected: there is no item on screen.
43
+ */
44
+ export class TestBookmark extends LitElement {
45
+ static { this.styles = css `
46
+ :host {
47
+ ${styles.btn};
48
+ }
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};
56
+ }
57
+ :host {
58
+ display: inline-flex;
59
+ align-items: center;
60
+ gap: 0.4em;
61
+ }
62
+ svg {
63
+ width: 1.1em;
64
+ height: 1.1em;
65
+ flex: none;
66
+ fill: none;
67
+ stroke: currentColor;
68
+ stroke-width: 2;
69
+ stroke-linejoin: round;
70
+ }
71
+ :host([bookmarked]) {
72
+ color: var(--qti-bookmark-color, #b45309);
73
+ }
74
+ :host([bookmarked]) svg {
75
+ fill: currentColor;
76
+ }
77
+ :host(:focus-visible) {
78
+ ${styles.focusRing};
79
+ }
80
+ :host([disabled]) {
81
+ ${styles.dis};
82
+ }
83
+ `; }
84
+ constructor() {
85
+ super();
86
+ this.bookmarked = false;
87
+ this.disabled = false;
88
+ this.addEventListener('click', () => this.#toggle());
89
+ this.addEventListener('keydown', event => {
90
+ if (event.key !== 'Enter' && event.key !== ' ')
91
+ return;
92
+ event.preventDefault();
93
+ this.#toggle();
94
+ });
95
+ }
96
+ connectedCallback() {
97
+ super.connectedCallback();
98
+ if (!this.hasAttribute('role'))
99
+ this.setAttribute('role', 'button');
100
+ if (!this.hasAttribute('tabindex'))
101
+ this.setAttribute('tabindex', '0');
102
+ }
103
+ /** The item this button marks: its own, or else the one on screen. */
104
+ get #activeItem() {
105
+ return (this.item ||
106
+ (itemRefOf(this) ??
107
+ this.computedContext?.testParts
108
+ ?.flatMap(part => part.sections.flatMap(section => section.items))
109
+ .find(item => item.active)?.identifier));
110
+ }
111
+ willUpdate() {
112
+ const active = this.#activeItem;
113
+ this.disabled = !active;
114
+ this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);
115
+ }
116
+ updated() {
117
+ this.setAttribute('aria-pressed', String(this.bookmarked));
118
+ this.setAttribute('aria-disabled', String(this.disabled));
119
+ }
120
+ #toggle() {
121
+ const active = this.#activeItem;
122
+ if (!active)
123
+ return;
124
+ const marked = bookmarkedItems(this.computedContext);
125
+ const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];
126
+ // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.
127
+ dispatchPublic(this, 'cito-test-update-plugin-state', {
128
+ plugin: 'bookmarks',
129
+ value: next.length > 0 ? next : null
130
+ });
131
+ }
132
+ render() {
133
+ return html `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot>`;
134
+ }
135
+ }
136
+ __decorate([
137
+ consume({ context: computedContext, subscribe: true }),
138
+ property({ attribute: false })
139
+ ], TestBookmark.prototype, "computedContext", void 0);
140
+ __decorate([
141
+ property({ reflect: true })
142
+ ], TestBookmark.prototype, "item", void 0);
143
+ __decorate([
144
+ property({ type: Boolean, reflect: true })
145
+ ], TestBookmark.prototype, "bookmarked", void 0);
146
+ __decorate([
147
+ property({ type: Boolean, reflect: true })
148
+ ], TestBookmark.prototype, "disabled", void 0);
149
+ //# sourceMappingURL=test-bookmark.js.map
@@ -0,0 +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,YAAY,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC,CA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C;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,qGAAqG,CAAC;IACnH,CAAC;;AApGS;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 @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"]}
@@ -1,7 +1,14 @@
1
1
  import { LitElement } from 'lit';
2
- import type { TestHost } from '../../internal/test-host.context';
2
+ import type { View } from '@qti-components/base';
3
+ /**
4
+ * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which
5
+ * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until
6
+ * something switches it back (`test-view-toggle`).
7
+ *
8
+ * @attr view - The view to switch to after the attempt ended.
9
+ */
3
10
  export declare class TestCheckItem extends LitElement {
4
- protected testHost?: TestHost;
11
+ view: View;
5
12
  static styles: import("lit").CSSResult;
6
13
  constructor();
7
14
  render(): import("lit").TemplateResult<1>;
@@ -4,18 +4,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { consume } from '@lit/context';
8
7
  import { css, html, LitElement } from 'lit';
9
- import { testHostContext } from '../../internal/test-host.context';
8
+ import { property } from 'lit/decorators.js';
10
9
  import * as styles from '../styles';
11
10
  import { dispatchPublic } from '../../public-events';
11
+ /**
12
+ * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which
13
+ * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until
14
+ * something switches it back (`test-view-toggle`).
15
+ *
16
+ * @attr view - The view to switch to after the attempt ended.
17
+ */
12
18
  export class TestCheckItem extends LitElement {
13
19
  static { this.styles = css `
14
20
  :host {
15
21
  ${styles.btn};
16
22
  }
17
- :host(:hover:not([disabled])) {
18
- ${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};
19
30
  }
20
31
  :host(:focus-visible) {
21
32
  ${styles.focusRing};
@@ -26,15 +37,10 @@ export class TestCheckItem extends LitElement {
26
37
  `; }
27
38
  constructor() {
28
39
  super();
40
+ this.view = 'scorer';
29
41
  this.addEventListener('click', () => {
30
42
  dispatchPublic(this, 'cito-test-end-attempt', {});
31
- const testContainer = this.testHost?.querySelector('test-container');
32
- if (!testContainer)
33
- return;
34
- const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll('[view]'));
35
- viewElements.forEach((element) => {
36
- element.classList.toggle('show', true);
37
- });
43
+ dispatchPublic(this, 'cito-test-switch-view', this.view);
38
44
  });
39
45
  }
40
46
  render() {
@@ -42,6 +48,6 @@ export class TestCheckItem extends LitElement {
42
48
  }
43
49
  }
44
50
  __decorate([
45
- consume({ context: testHostContext, subscribe: true })
46
- ], TestCheckItem.prototype, "testHost", void 0);
51
+ property({ type: String })
52
+ ], TestCheckItem.prototype, "view", void 0);
47
53
  //# sourceMappingURL=test-check-item.js.map
@@ -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,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,MAAM,OAAO,aAAc,SAAQ,UAAU;aAI3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAgB,gBAAgB,CAAC,CAAC;YACpF,IAAI,CAAC,aAAa;gBAAE,OAAO;YAE3B,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAErF,YAAY,CAAC,OAAO,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAlCS;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACzB","sourcesContent":["import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TestContainer } from '../test-container/test-container';\n\nexport class TestCheckItem extends LitElement {\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\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 const testContainer = this.testHost?.querySelector<TestContainer>('test-container');\n if (!testContainer) return;\n\n const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', true);\n });\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;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbq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iB,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,CAAC,iBAAiB,EAAE,CAAC;gBAC5B,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC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,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"]}