@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,37 @@
1
+ import { css, html, LitElement } from 'lit';
2
+ import * as styles from '../styles';
3
+ import { dispatchPublic } from '../../public-events';
4
+ /**
5
+ * Scores the test: on click the test resets its outcomes to their declared defaults, runs its
6
+ * outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.
7
+ * The host decides where it sits, for example on the last item or in a review view.
8
+ */
9
+ export class TestSubmit extends LitElement {
10
+ static { this.styles = css `
11
+ :host {
12
+ ${styles.btn};
13
+ }
14
+ @media (hover: hover) and (pointer: fine) {
15
+ :host(:hover:not([disabled])) {
16
+ ${styles.btnInteractive};
17
+ }
18
+ }
19
+ :host(:active:not([disabled])) {
20
+ ${styles.btnActive};
21
+ }
22
+ :host(:focus-visible) {
23
+ ${styles.focusRing};
24
+ }
25
+ :host([disabled]) {
26
+ ${styles.dis};
27
+ }
28
+ `; }
29
+ constructor() {
30
+ super();
31
+ this.addEventListener('click', () => dispatchPublic(this, 'cito-test-submit', {}));
32
+ }
33
+ render() {
34
+ return html ` <slot></slot> `;
35
+ }
36
+ }
37
+ //# sourceMappingURL=test-submit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-submit.js","sourceRoot":"","sources":["../../../src/components/test-submit/test-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;aACxB,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,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\n/**\n * Scores the test: on click the test resets its outcomes to their declared defaults, runs its\n * outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.\n * The host decides where it sits, for example on the last item or in a review view.\n */\nexport class TestSubmit 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 constructor() {\n super();\n this.addEventListener('click', () => dispatchPublic(this, 'cito-test-submit', {}));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-submit': TestSubmit;\n }\n}\n"]}
@@ -101,6 +101,9 @@ export declare const qtiTestElements: readonly [{
101
101
  }, {
102
102
  readonly tag: "test-stamp";
103
103
  readonly ctor: typeof import("./elements").TestStamp;
104
+ }, {
105
+ readonly tag: "test-submit";
106
+ readonly ctor: typeof import("./elements").TestSubmit;
104
107
  }, {
105
108
  readonly tag: "test-view";
106
109
  readonly ctor: typeof import("./elements").TestView;
@@ -7,6 +7,7 @@ declare class TestProcessingInterface {
7
7
  getOutcome(identifier: string): Readonly<OutcomeVariable>;
8
8
  getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;
9
9
  outcomeProcessing(): boolean;
10
+ submit(): boolean;
10
11
  getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[];
11
12
  }
12
13
  export declare const TestProcessingMixin: <T extends Constructor<TestBaseInterface>>(superClass: T) => Constructor<TestProcessingInterface> & T;
@@ -1,3 +1,4 @@
1
+ import { dispatchPublic, listenPublic } from '../public-events';
1
2
  export const TestProcessingMixin = (superClass) => {
2
3
  class TestProcessingElement extends superClass {
3
4
  constructor(...args) {
@@ -9,6 +10,7 @@ export const TestProcessingMixin = (superClass) => {
9
10
  };
10
11
  e.stopPropagation();
11
12
  });
13
+ listenPublic(this, 'cito-test-submit', () => this.submit());
12
14
  // wordt aangeroepen vanuit de processingtemplate
13
15
  this.addEventListener('qti-set-outcome-value', (e) => {
14
16
  const { outcomeIdentifier, value } = e.detail;
@@ -22,7 +24,26 @@ export const TestProcessingMixin = (superClass) => {
22
24
  const outcomeProcessor = (this._testElement ?? this).querySelector('qti-outcome-processing');
23
25
  if (!outcomeProcessor)
24
26
  return false;
25
- outcomeProcessor?.process();
27
+ // QTI starts every run of the test's outcome processing from the declared defaults, so an
28
+ // accumulating rule (`SCORE_TOTAL = sum + SCORE_TOTAL`) gives the same total on every run.
29
+ this.testContext = {
30
+ ...this.testContext,
31
+ testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => ({
32
+ ...v,
33
+ value: v.defaultValue ?? null
34
+ }))
35
+ };
36
+ outcomeProcessor.process();
37
+ return true;
38
+ }
39
+ /**
40
+ * Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with
41
+ * `cito-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.
42
+ */
43
+ submit() {
44
+ if (!this.outcomeProcessing())
45
+ return false;
46
+ dispatchPublic(this, 'cito-test-submitted', {});
26
47
  return true;
27
48
  }
28
49
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"test-processing.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-processing.mixin.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2C,UAAa,EAAE,EAAE;IAC7F,MAAe,qBAAsB,SAAQ,UAAU;QACrD,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,CAAC,CAAiC,EAAE,EAAE;gBACnF,IAAI,CAAC,WAAW,GAAG;oBACjB,GAAG,IAAI,CAAC,WAAW;oBACnB,oBAAoB,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;iBAC5F,CAAC;gBACF,CAAC,CAAC,eAAe,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;YACH,iDAAiD;YACjD,IAAI,CAAC,gBAAgB,CACnB,uBAAuB,EACvB,CAAC,CAAuE,EAAE,EAAE;gBAC1E,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;gBAC9C,IAAI,CAAC,qBAAqB,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;gBACrD,CAAC,CAAC,eAAe,EAAE,CAAC;YACtB,CAAC,CACF,CAAC;QACJ,CAAC;QAED,iBAAiB;YACf,wFAAwF;YACxF,gGAAgG;YAChG,MAAM,gBAAgB,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,aAAa,CAChE,wBAAwB,CACU,CAAC;YACrC,IAAI,CAAC,gBAAgB;gBAAE,OAAO,KAAK,CAAC;YACpC,gBAAgB,EAAE,OAAO,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;WAIG;QACH,eAAe,CAAC,M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B;YACnC,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;QAC/F,CAAC;KAEF;IAED,OAAO,qBAAiE,CAAC;AAC3E,CAAC,CAAC","sourcesContent":["import type { QtiOutcomeProcessing } from '../components/qti-outcome-processing/qti-outcome-processing';\nimport type { QtiTestFeedback } from '../components/qti-test-feedback/qti-test-feedback';\nimport type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestProcessingInterface {\n updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;\n getOutcome(identifier: string): Readonly<OutcomeVariable>;\n getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;\n outcomeProcessing(): boolean;\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[];\n}\nexport const TestProcessingMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestProcessingElement extends superClass implements TestProcessingInterface {\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-register-variable', (e: CustomEvent<{ variable: any }>) => {\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: [...(this.testContext.testOutcomeVariables || []), e.detail.variable]\n };\n e.stopPropagation();\n });\n // wordt aangeroepen vanuit de processingtemplate\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n }\n );\n }\n\n outcomeProcessing(): boolean {\n // Inside the loaded test: `test-container` renders it into its own shadow root, which a\n // `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.\n const outcomeProcessor = (this._testElement ?? this).querySelector(\n 'qti-outcome-processing'\n ) as unknown as QtiOutcomeProcessing;\n if (!outcomeProcessor) return false;\n outcomeProcessor?.process();\n return true;\n }\n\n /**\n * The `qti-test-feedback` elements that apply now, read from the test outcomes: run\n * `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to\n * while it runs (`during`); without it, both.\n */\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[] {\n const feedback = Array.from(\n (this._testElement ?? this).querySelectorAll<QtiTestFeedback>('qti-test-feedback') ?? []\n );\n return feedback.filter(\n fb => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value)\n );\n }\n\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : [...v.value, value as string]\n };\n })\n };\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n public getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this.testContext.testOutcomeVariables?.find(v => v.identifier === identifier) || null;\n }\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n }\n\n return TestProcessingElement as Constructor<TestProcessingInterface> & T;\n};\n"]}
1
+ {"version":3,"file":"test-processing.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-processing.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiBhE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2C,UAAa,EAAE,EAAE;IAC7F,MAAe,qBA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AAE,CAAC;wBAChC,OAAO,CAAC,CAAC;oBACX,CAAC;oBACD,OAAO;wBACL,GAAG,CAAC;wBACJ,KAAK,EAAE,eAAe,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAe,CAAC;qBACxF,CAAC;gBACJ,CAAC,CAAC;aACH,CAAC;QACJ,CAAC;QAEM,UAAU,CAAC,UAAkB;YAClC,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAoB,CAAC;QACzD,CAAC;QACM,WAAW,CAAC,UAAkB;YACnC,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;QAC/F,CAAC;KAEF;IAED,OAAO,qBAAiE,CAAC;AAC3E,CAAC,CAAC","sourcesContent":["import { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { QtiOutcomeProcessing } from '../components/qti-outcome-processing/qti-outcome-processing';\nimport type { QtiTestFeedback } from '../components/qti-test-feedback/qti-test-feedback';\nimport type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestProcessingInterface {\n updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;\n getOutcome(identifier: string): Readonly<OutcomeVariable>;\n getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;\n outcomeProcessing(): boolean;\n submit(): boolean;\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[];\n}\nexport const TestProcessingMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestProcessingElement extends superClass implements TestProcessingInterface {\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-register-variable', (e: CustomEvent<{ variable: any }>) => {\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: [...(this.testContext.testOutcomeVariables || []), e.detail.variable]\n };\n e.stopPropagation();\n });\n listenPublic(this, 'cito-test-submit', () => this.submit());\n // wordt aangeroepen vanuit de processingtemplate\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n }\n );\n }\n\n outcomeProcessing(): boolean {\n // Inside the loaded test: `test-container` renders it into its own shadow root, which a\n // `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.\n const outcomeProcessor = (this._testElement ?? this).querySelector(\n 'qti-outcome-processing'\n ) as unknown as QtiOutcomeProcessing;\n if (!outcomeProcessor) return false;\n // QTI starts every run of the test's outcome processing from the declared defaults, so an\n // accumulating rule (`SCORE_TOTAL = sum + SCORE_TOTAL`) gives the same total on every run.\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => ({\n ...v,\n value: v.defaultValue ?? null\n }))\n };\n outcomeProcessor.process();\n return true;\n }\n\n /**\n * Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with\n * `cito-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.\n */\n submit(): boolean {\n if (!this.outcomeProcessing()) return false;\n dispatchPublic(this, 'cito-test-submitted', {});\n return true;\n }\n\n /**\n * The `qti-test-feedback` elements that apply now, read from the test outcomes: run\n * `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to\n * while it runs (`during`); without it, both.\n */\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[] {\n const feedback = Array.from(\n (this._testElement ?? this).querySelectorAll<QtiTestFeedback>('qti-test-feedback') ?? []\n );\n return feedback.filter(\n fb => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value)\n );\n }\n\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : [...v.value, value as string]\n };\n })\n };\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n public getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this.testContext.testOutcomeVariables?.find(v => v.identifier === identifier) || null;\n }\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n }\n\n return TestProcessingElement as Constructor<TestProcessingInterface> & T;\n};\n"]}
@@ -5,11 +5,12 @@ import { TestPrintVariables } from '../components/test-print-item-variables/test
5
5
  import { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';
6
6
  import { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';
7
7
  import { TestStamp } from '../components/test-stamp/test-stamp';
8
+ import { TestSubmit } from '../components/test-submit/test-submit';
8
9
  import { TestView } from '../components/test-view-toggle/test-view';
9
10
  import { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';
10
11
  export * from '../tts/elements';
11
12
  export { bookmarkedItems } from '../components/test-bookmark/test-bookmark';
12
- export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestView, TestViewToggle };
13
+ export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestSubmit, TestView, TestViewToggle };
13
14
  /**
14
15
  * Every test plugin's elements in one list. `qti-test` registers them with the rest of its
15
16
  * elements, and a scoped registry can use the list directly. Defines nothing.
@@ -38,6 +39,9 @@ export declare const pluginElements: readonly [{
38
39
  }, {
39
40
  readonly tag: "test-stamp";
40
41
  readonly ctor: typeof TestStamp;
42
+ }, {
43
+ readonly tag: "test-submit";
44
+ readonly ctor: typeof TestSubmit;
41
45
  }, {
42
46
  readonly tag: "test-view";
43
47
  readonly ctor: typeof TestView;
@@ -5,12 +5,13 @@ import { TestPrintVariables } from '../components/test-print-item-variables/test
5
5
  import { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';
6
6
  import { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';
7
7
  import { TestStamp } from '../components/test-stamp/test-stamp';
8
+ import { TestSubmit } from '../components/test-submit/test-submit';
8
9
  import { TestView } from '../components/test-view-toggle/test-view';
9
10
  import { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';
10
11
  import { ttsElements } from '../tts/elements';
11
12
  export * from '../tts/elements';
12
13
  export { bookmarkedItems } from '../components/test-bookmark/test-bookmark';
13
- export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestView, TestViewToggle };
14
+ export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestSubmit, TestView, TestViewToggle };
14
15
  /**
15
16
  * Every test plugin's elements in one list. `qti-test` registers them with the rest of its
16
17
  * elements, and a scoped registry can use the list directly. Defines nothing.
@@ -26,6 +27,7 @@ export const pluginElements = [
26
27
  { tag: 'test-scoring-buttons', ctor: TestScoringButtons },
27
28
  { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },
28
29
  { tag: 'test-stamp', ctor: TestStamp },
30
+ { tag: 'test-submit', ctor: TestSubmit },
29
31
  { tag: 'test-view', ctor: TestView },
30
32
  { tag: 'test-view-toggle', ctor: TestViewToggle },
31
33
  ...ttsElements
@@ -1 +1 @@
1
- {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/plugins/elements.ts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AI,EAAE,SAAS,EAAE;IACtC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpC,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE;IACjD,GAAG,WAAW;CACN,CAAC","sourcesContent":["import { TestBookmark } from '../components/test-bookmark/test-bookmark';\nimport { TestCheckItem } from '../components/test-check-item/test-check-item';\nimport { TestPrintContext } from '../components/test-print-context/test-print-context';\nimport { TestPrintVariables } from '../components/test-print-item-variables/test-print-item-variables';\nimport { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';\nimport { TestStamp } from '../components/test-stamp/test-stamp';\nimport { TestView } from '../components/test-view-toggle/test-view';\nimport { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';\nimport { ttsElements } from '../tts/elements';\n\nexport * from '../tts/elements';\n\nexport { bookmarkedItems } from '../components/test-bookmark/test-bookmark';\n\nexport {\n TestCheckItem,\n TestBookmark,\n TestPrintContext,\n TestPrintVariables,\n TestScoringButtons,\n TestScoringFeedback,\n TestStamp,\n TestView,\n TestViewToggle\n};\n\n/**\n * Every test plugin's elements in one list. `qti-test` registers them with the rest of its\n * elements, and a scoped registry can use the list directly. Defines nothing.\n *\n * A plugin is the set of files listed for it in `plugin-boundary.spec.ts` (`PLUGINS`); this file is\n * the one place that names them all.\n */\nexport const pluginElements = [\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-bookmark', ctor: TestBookmark },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle },\n ...ttsElements\n] as const;\n"]}
1
+ {"version":3,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ACzD,EAAE,GAAG,EAAE,uBAAuB,EAAE,IAAI,EAAE,mBAAmB,EAAE;IAC3D,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE;IACxC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpC,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE;IACjD,GAAG,WAAW;CACN,CAAC","sourcesContent":["import { TestBookmark } from '../components/test-bookmark/test-bookmark';\nimport { TestCheckItem } from '../components/test-check-item/test-check-item';\nimport { TestPrintContext } from '../components/test-print-context/test-print-context';\nimport { TestPrintVariables } from '../components/test-print-item-variables/test-print-item-variables';\nimport { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';\nimport { TestStamp } from '../components/test-stamp/test-stamp';\nimport { TestSubmit } from '../components/test-submit/test-submit';\nimport { TestView } from '../components/test-view-toggle/test-view';\nimport { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';\nimport { ttsElements } from '../tts/elements';\n\nexport * from '../tts/elements';\n\nexport { bookmarkedItems } from '../components/test-bookmark/test-bookmark';\n\nexport {\n TestCheckItem,\n TestBookmark,\n TestPrintContext,\n TestPrintVariables,\n TestScoringButtons,\n TestScoringFeedback,\n TestStamp,\n TestSubmit,\n TestView,\n TestViewToggle\n};\n\n/**\n * Every test plugin's elements in one list. `qti-test` registers them with the rest of its\n * elements, and a scoped registry can use the list directly. Defines nothing.\n *\n * A plugin is the set of files listed for it in `plugin-boundary.spec.ts` (`PLUGINS`); this file is\n * the one place that names them all.\n */\nexport const pluginElements = [\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-bookmark', ctor: TestBookmark },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-submit', ctor: TestSubmit },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle },\n ...ttsElements\n] as const;\n"]}
@@ -24,6 +24,8 @@ export interface NavigationFailure {
24
24
  export interface PublicEventMap {
25
25
  'cito-test-navigate': CustomEvent<NavigationTarget>;
26
26
  'cito-test-end-attempt': CustomEvent<unknown>;
27
+ /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `cito-test-submitted`. */
28
+ 'cito-test-submit': CustomEvent<Record<string, never>>;
27
29
  'cito-test-update-outcome': CustomEvent<{
28
30
  assessmentItemRefId: string;
29
31
  outcomeVariableId: string;
@@ -35,6 +37,8 @@ export interface PublicEventMap {
35
37
  plugin: string;
36
38
  value: unknown;
37
39
  }>;
40
+ /** Outcome processing ran after a submit: read the test outcomes now. */
41
+ 'cito-test-submitted': CustomEvent<Record<string, never>>;
38
42
  'cito-test-navigated': CustomEvent<NavigationTarget>;
39
43
  'cito-test-navigation-started': CustomEvent<NavigationTarget>;
40
44
  'cito-test-navigation-failed': CustomEvent<NavigationFailure>;
@@ -2,9 +2,11 @@ import { dispatchDeclared, listenDeclared } from '@qti-components/elements/publi
2
2
  export const PUBLIC_EVENTS = {
3
3
  'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },
4
4
  'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },
5
+ 'cito-test-submit': { kind: 'request', scope: 'test' },
5
6
  'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },
6
7
  'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },
7
8
  'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },
9
+ 'cito-test-submitted': { kind: 'notification', scope: 'test' },
8
10
  'cito-test-navigated': { kind: 'notification', scope: 'test' },
9
11
  'cito-test-navigation-started': {
10
12
  kind: 'notification',
@@ -1 +1 @@
1
- {"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAqD1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAAE;IAC9F,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE;IAC3F,0BAA0B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,8BAA8B,EAAE;IAC1G,+BAA+B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;IACnE,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE;IAC9F,qBAAqB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAC9D,8BAA8B,EAAE;QAC9B,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,MAAM;QACb,UAAU,EAAE,gCAAgC;KAC7C;IACD,6BAA6B,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,sBAAsB,EAAE;IAC1G,oBAAoB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE;IAC5F,kBAAkB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,+BAA+B,EAAE;IACxG,yBAAyB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE;IACnG,yBAAyB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAClE,uBAAuB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAChE,yBAAyB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,mCAAmC,EAAE;CACpH,CAAC;AAMF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,IAAO,EACP,MAAkE;IAElE,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'cito-test-navigate': CustomEvent<NavigationTarget>;\n 'cito-test-end-attempt': CustomEvent<unknown>;\n 'cito-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'cito-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'cito-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n 'cito-test-navigated': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-started': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'cito-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `cito-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-test-state-changed': CustomEvent<QtiTestState>;\n 'cito-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'cito-test-end-reached': CustomEvent<Record<string, never>>;\n 'cito-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },\n 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },\n 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },\n 'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },\n 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },\n 'cito-test-navigated': { kind: 'notification', scope: 'test' },\n 'cito-test-navigation-started': {\n kind: 'notification',\n scope: 'test',\n deprecated: 'qti-navigation-loading-started'\n },\n 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },\n 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },\n 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },\n 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },\n 'cito-test-items-skipped': { kind: 'notification', scope: 'test' },\n 'cito-test-end-reached': { kind: 'notification', scope: 'test' },\n 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
1
+ {"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAyD1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAAE;IAC9F,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE;IAC3F,kBAAkB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;IACtD,0BAA0B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,8BAA8B,EAAE;IAC1G,+BAA+B,EAAE,E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,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'cito-test-navigate': CustomEvent<NavigationTarget>;\n 'cito-test-end-attempt': CustomEvent<unknown>;\n /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `cito-test-submitted`. */\n 'cito-test-submit': CustomEvent<Record<string, never>>;\n 'cito-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'cito-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'cito-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n /** Outcome processing ran after a submit: read the test outcomes now. */\n 'cito-test-submitted': CustomEvent<Record<string, never>>;\n 'cito-test-navigated': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-started': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'cito-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `cito-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-test-state-changed': CustomEvent<QtiTestState>;\n 'cito-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'cito-test-end-reached': CustomEvent<Record<string, never>>;\n 'cito-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },\n 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },\n 'cito-test-submit': { kind: 'request', scope: 'test' },\n 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },\n 'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },\n 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },\n 'cito-test-submitted': { kind: 'notification', scope: 'test' },\n 'cito-test-navigated': { kind: 'notification', scope: 'test' },\n 'cito-test-navigation-started': {\n kind: 'notification',\n scope: 'test',\n deprecated: 'qti-navigation-loading-started'\n },\n 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },\n 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },\n 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },\n 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },\n 'cito-test-items-skipped': { kind: 'notification', scope: 'test' },\n 'cito-test-end-reached': { kind: 'notification', scope: 'test' },\n 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
@@ -13,14 +13,24 @@ import * as styles from '../components/styles';
13
13
  // ─── CSS Custom Highlight ─────────────────────────────────────────────────────
14
14
  const HIGHLIGHT_ELEMENT = 'tts-element'; // navigation cursor — whole element
15
15
  const HIGHLIGHT_WORD = 'tts-word'; // word boundary during speech
16
- // Shared across all instances — added to whichever shadow root needs it
16
+ // Shared across all instances — added to whichever shadow root needs it. The two highlights are
17
+ // tints of the theme's info (the element being read) and warning (the word being spoken) colours,
18
+ // see-through so the text and its own background stay visible. Without the theme they fall back to
19
+ // the system Highlight and Mark colours. A host repaints them with --test-tts-element-highlight and
20
+ // --test-tts-word-highlight.
17
21
  let highlightSheet = null;
18
22
  function getHighlightSheet() {
19
23
  if (!highlightSheet) {
20
24
  highlightSheet = new CSSStyleSheet();
21
25
  highlightSheet.replaceSync(`
22
- ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
23
- ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
26
+ ::highlight(${HIGHLIGHT_ELEMENT}) {
27
+ background-color: var(--test-tts-element-highlight, color-mix(in oklab, var(--qti-color-info, var(--cito-color-info, Highlight)) 15%, transparent));
28
+ color: inherit;
29
+ }
30
+ ::highlight(${HIGHLIGHT_WORD}) {
31
+ background-color: var(--test-tts-word-highlight, color-mix(in oklab, var(--qti-color-warning, var(--cito-color-warning, Mark)) 55%, transparent));
32
+ color: inherit;
33
+ }
24
34
  `);
25
35
  }
26
36
  return highlightSheet;
@@ -65,8 +75,13 @@ class TtsButtonBase extends LitElement {
65
75
  page as tall as the scrolled content. */
66
76
  position: relative;
67
77
  }
68
- button:hover:not(:disabled) {
69
- ${styles.btnInteractive};
78
+ @media (hover: hover) and (pointer: fine) {
79
+ button:hover:not(:disabled) {
80
+ ${styles.btnInteractive};
81
+ }
82
+ }
83
+ button:active:not(:disabled) {
84
+ ${styles.btnActive};
70
85
  }
71
86
  button:focus-visible {
72
87
  ${styles.focusRing};
@@ -76,8 +91,8 @@ class TtsButtonBase extends LitElement {
76
91
  }
77
92
  button[aria-pressed='true'],
78
93
  button[aria-pressed='true']:hover {
79
- background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
80
- color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
94
+ background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, Highlight));
95
+ color: var(--test-button-selected-color, var(--qti-selected-color, HighlightText));
81
96
  }
82
97
  svg,
83
98
  ::slotted(svg) {