@qti-components/test 2.0.0-next.12 → 2.0.0-next.14

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 (70) hide show
  1. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +1 -1
  2. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
  3. package/dist/components/qti-assessment-test/qti-assessment-test.d.ts +1 -1
  4. package/dist/components/qti-assessment-test/qti-assessment-test.js +1 -1
  5. package/dist/components/qti-assessment-test/qti-assessment-test.js.map +1 -1
  6. package/dist/components/qti-number-presented/qti-number-presented.js +1 -1
  7. package/dist/components/qti-number-presented/qti-number-presented.js.map +1 -1
  8. package/dist/components/qti-number-selected/qti-number-selected.js +2 -2
  9. package/dist/components/qti-number-selected/qti-number-selected.js.map +1 -1
  10. package/dist/components/qti-test/qti-test.d.ts +2 -2
  11. package/dist/components/qti-test/qti-test.js +2 -2
  12. package/dist/components/qti-test/qti-test.js.map +1 -1
  13. package/dist/components/qti-test-variables/qti-test-variables.js +2 -2
  14. package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -1
  15. package/dist/components/styles.js +64 -34
  16. package/dist/components/styles.js.map +1 -1
  17. package/dist/components/test-bookmark/test-bookmark.js +1 -1
  18. package/dist/components/test-bookmark/test-bookmark.js.map +1 -1
  19. package/dist/components/test-check-item/test-check-item.js +2 -2
  20. package/dist/components/test-check-item/test-check-item.js.map +1 -1
  21. package/dist/components/test-container/test-container.js +1 -1
  22. package/dist/components/test-container/test-container.js.map +1 -1
  23. package/dist/components/test-end-attempt/test-end-attempt.d.ts +1 -1
  24. package/dist/components/test-end-attempt/test-end-attempt.js +2 -2
  25. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  26. package/dist/components/test-item-link/test-item-link.js +1 -1
  27. package/dist/components/test-item-link/test-item-link.js.map +1 -1
  28. package/dist/components/test-navigation/test-navigation.js +4 -4
  29. package/dist/components/test-navigation/test-navigation.js.map +1 -1
  30. package/dist/components/test-next/test-next.js +1 -1
  31. package/dist/components/test-next/test-next.js.map +1 -1
  32. package/dist/components/test-prev/test-prev.js +1 -1
  33. package/dist/components/test-prev/test-prev.js.map +1 -1
  34. package/dist/components/test-print-state/test-print-state.d.ts +1 -1
  35. package/dist/components/test-print-state/test-print-state.js +3 -3
  36. package/dist/components/test-print-state/test-print-state.js.map +1 -1
  37. package/dist/components/test-scoring-buttons/test-scoring-buttons.js +1 -1
  38. package/dist/components/test-scoring-buttons/test-scoring-buttons.js.map +1 -1
  39. package/dist/components/test-section-link/test-section-link.js +1 -1
  40. package/dist/components/test-section-link/test-section-link.js.map +1 -1
  41. package/dist/components/test-submit/test-submit.d.ts +1 -1
  42. package/dist/components/test-submit/test-submit.js +2 -2
  43. package/dist/components/test-submit/test-submit.js.map +1 -1
  44. package/dist/components/test-view-toggle/test-view-toggle.js +1 -1
  45. package/dist/components/test-view-toggle/test-view-toggle.js.map +1 -1
  46. package/dist/components/test-view-toggle/test-view.js +1 -1
  47. package/dist/components/test-view-toggle/test-view.js.map +1 -1
  48. package/dist/mixins/test-base.js +3 -3
  49. package/dist/mixins/test-base.js.map +1 -1
  50. package/dist/mixins/test-navigation.mixin.js +13 -13
  51. package/dist/mixins/test-navigation.mixin.js.map +1 -1
  52. package/dist/mixins/test-processing.mixin.js +3 -3
  53. package/dist/mixins/test-processing.mixin.js.map +1 -1
  54. package/dist/mixins/test-state.mixin.d.ts +2 -7
  55. package/dist/mixins/test-state.mixin.js +6 -6
  56. package/dist/mixins/test-state.mixin.js.map +1 -1
  57. package/dist/mixins/test-view.mixin.js +2 -2
  58. package/dist/mixins/test-view.mixin.js.map +1 -1
  59. package/dist/plugin-state.d.ts +1 -1
  60. package/dist/plugin-state.js +1 -1
  61. package/dist/plugin-state.js.map +1 -1
  62. package/dist/public-events.d.ts +22 -20
  63. package/dist/public-events.js +16 -20
  64. package/dist/public-events.js.map +1 -1
  65. package/dist/tts/test-item-to-speech.d.ts +10 -2
  66. package/dist/tts/test-item-to-speech.js +38 -12
  67. package/dist/tts/test-item-to-speech.js.map +1 -1
  68. package/dist/types/qti-test-state.d.ts +1 -1
  69. package/dist/types/qti-test-state.js.map +1 -1
  70. package/package.json +7 -7
@@ -96,7 +96,7 @@ export class QtiAssessmentItemRef extends LitElement {
96
96
  this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;
97
97
  this.requestUpdate();
98
98
  await this.updateComplete;
99
- dispatchPublic(this, 'cito-item-ref-connected', {
99
+ dispatchPublic(this, 'qc-item-ref-connected', {
100
100
  identifier: this.identifier,
101
101
  href: this.href,
102
102
  category: this.category
@@ -1 +1 @@
1
- {"version":3,"file":"qti-assessment-item-ref.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAOrD,iEAAiE;AACjE,MAAM,wBAAwB,GAAG;IAC/B,aAAa,CAAC,KAAa;QACzB,OAAO,KAAK,KAAK,MAAM,CAAC;IAC1B,CAAC;IACD,WAAW,CAAC,KAAc;QACxB,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAClC,CAAC;CACF,CAAC;AA2BF,4CAA4C;AAC5C,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAApD;;QAoCE,WAAM,GAA4B,IAAI,CAAC;QAUv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;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO,MAAM,CAAC;QAEpC,MAAM,KAAK,GAAyB;YAClC,MAAM;YACN,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE;YAC1B,OAAO,EAAE,IAAI;SACd,CAAC;QACF,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF;AA5I6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAmB;AAClB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAqB;AACkB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;sDAAoB;AACnB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;mDAAiB;AACtD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAe;AAKhC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6DACX;AA0B5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACN;AAc7B;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sDACzB","sourcesContent":["import { LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TemplateFunction } from '@heximal/templates';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * The model a `<template item-ref>` is rendered with.\n *\n * Only what this element already knows: the item's parsed document and the\n * attributes off the item-ref itself. `itemRef` is the escape hatch — a\n * template that needs anything else (a click handler, a value from the host\n * app) reaches it through a property on the element, which the host is free to\n * set.\n */\nexport interface ItemRefTemplateModel {\n /** The item's parsed document, i.e. what the element renders by default. */\n xmlDoc: DocumentFragment;\n identifier?: string;\n href?: string;\n category?: string;\n /**\n * This item's entry in the computed context, the same object the stamps\n * iterate as `item`: `index` (1-based, null for info items), `score`,\n * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.\n */\n item?: ComputedItem;\n /** The element being rendered. */\n itemRef: QtiAssessmentItemRef;\n}\n\n// @customElement('qti-assessment-item-ref')\nexport class QtiAssessmentItemRef extends LitElement {\n @property({ type: String }) category?: string;\n @property({ type: String }) identifier?: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) required?: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed?: boolean;\n @property({ type: String }) href?: string;\n\n // Only read by a <template item-ref>; subscribing re-renders it as scores come in\n @state()\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n /**\n * The `<qti-weight>` children of this ref, keyed by identifier — what\n * `qti-test-variables`' `weight-identifier` resolves against.\n *\n * Read on access rather than cached: the test document is rendered into this\n * element's light DOM, so the weights are not in place at construction time,\n * and outcome processing runs long after they are.\n */\n get weights(): Map<string, number> {\n const weights = new Map<string, number>();\n for (const weight of this.querySelectorAll(':scope > qti-weight')) {\n const identifier = weight.getAttribute('identifier');\n if (!identifier) continue;\n const value = Number(weight.getAttribute('value'));\n if (Number.isNaN(value)) {\n console.warn(`qti-weight \"${identifier}\" has a non-numeric value, ignoring it`);\n continue;\n }\n weights.set(identifier, value);\n }\n return weights;\n }\n\n @property({ type: Object, attribute: false })\n xmlDoc: DocumentFragment | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n get assessmentItem(): QtiAssessmentItem | null {\n return this.renderRoot?.querySelector('qti-assessment-item');\n }\n\n myTemplate: TemplateFunction | null = null;\n\n /** The `qti-test` this ref belongs to, wherever it renders: light DOM, or any depth of shadow roots. */\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n // A context consumer keeps its last value when it is moved somewhere with no provider, and\n // `closest()` never did: a ref moved out of a test must not keep that test's template.\n this.testHost = undefined;\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n\n /*\n Optional per-item template, used to render extra things around an item —\n a bookmark, an index number, a score badge. Put it in the light DOM of\n your qti-test, and every item-ref in the test renders with it:\n\n <qti-test>\n <template item-ref>\n <div class=\"badge\">{{ identifier }}</div>\n {{ xmlDoc }}\n </template>\n …\n </qti-test>\n\n The template is the WHOLE render, so it has to place {{ xmlDoc }} itself;\n leaving it out renders the chrome and no item. Without a template the\n element renders the item on its own, exactly as before.\n\n Resolved once, on connect: one template serves every item, and everything\n that varies per item comes through the model (see ItemRefTemplateModel).\n */\n const templateElement = this.testHost?.querySelector<HTMLTemplateElement>('template[item-ref]');\n this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;\n this.requestUpdate();\n\n await this.updateComplete;\n\n dispatchPublic(this, 'cito-item-ref-connected', {\n identifier: this.identifier,\n href: this.href,\n category: this.category\n });\n }\n\n #computedItem(): ComputedItem | undefined {\n for (const testPart of this.computedContext?.testParts ?? []) {\n for (const section of testPart.sections) {\n const item = section.items.find(i => i.identifier === this.identifier);\n if (item) return item;\n }\n }\n return undefined;\n }\n\n /**\n * The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned\n * once per document and template, not per render: re-renders from\n * computed-context changes then hand Lit the same fragment, which it leaves\n * alone, instead of rebuilding the item (and reloading its PCIs, which\n * changes the context again).\n */\n #rendered: { source: DocumentFragment; template: TemplateFunction | null; doc: DocumentFragment } | null = null;\n\n override render() {\n // Item refs connect before loading, and navigation clears their documents.\n if (!this.xmlDoc) {\n this.#rendered = null;\n return nothing;\n }\n\n if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {\n this.#rendered = {\n source: this.xmlDoc,\n template: this.myTemplate,\n doc: this.xmlDoc.cloneNode(true) as DocumentFragment\n };\n }\n const xmlDoc = this.#rendered.doc;\n if (!this.myTemplate) return xmlDoc;\n\n const model: ItemRefTemplateModel = {\n xmlDoc,\n identifier: this.identifier,\n href: this.href,\n category: this.category,\n item: this.#computedItem(),\n itemRef: this\n };\n return this.myTemplate(model);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item-ref': QtiAssessmentItemRef;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-assessment-item-ref.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MA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,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6DACX;AA0B5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACN;AAc7B;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sDACzB","sourcesContent":["import { LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TemplateFunction } from '@heximal/templates';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * The model a `<template item-ref>` is rendered with.\n *\n * Only what this element already knows: the item's parsed document and the\n * attributes off the item-ref itself. `itemRef` is the escape hatch — a\n * template that needs anything else (a click handler, a value from the host\n * app) reaches it through a property on the element, which the host is free to\n * set.\n */\nexport interface ItemRefTemplateModel {\n /** The item's parsed document, i.e. what the element renders by default. */\n xmlDoc: DocumentFragment;\n identifier?: string;\n href?: string;\n category?: string;\n /**\n * This item's entry in the computed context, the same object the stamps\n * iterate as `item`: `index` (1-based, null for info items), `score`,\n * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.\n */\n item?: ComputedItem;\n /** The element being rendered. */\n itemRef: QtiAssessmentItemRef;\n}\n\n// @customElement('qti-assessment-item-ref')\nexport class QtiAssessmentItemRef extends LitElement {\n @property({ type: String }) category?: string;\n @property({ type: String }) identifier?: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) required?: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed?: boolean;\n @property({ type: String }) href?: string;\n\n // Only read by a <template item-ref>; subscribing re-renders it as scores come in\n @state()\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n /**\n * The `<qti-weight>` children of this ref, keyed by identifier — what\n * `qti-test-variables`' `weight-identifier` resolves against.\n *\n * Read on access rather than cached: the test document is rendered into this\n * element's light DOM, so the weights are not in place at construction time,\n * and outcome processing runs long after they are.\n */\n get weights(): Map<string, number> {\n const weights = new Map<string, number>();\n for (const weight of this.querySelectorAll(':scope > qti-weight')) {\n const identifier = weight.getAttribute('identifier');\n if (!identifier) continue;\n const value = Number(weight.getAttribute('value'));\n if (Number.isNaN(value)) {\n console.warn(`qti-weight \"${identifier}\" has a non-numeric value, ignoring it`);\n continue;\n }\n weights.set(identifier, value);\n }\n return weights;\n }\n\n @property({ type: Object, attribute: false })\n xmlDoc: DocumentFragment | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n get assessmentItem(): QtiAssessmentItem | null {\n return this.renderRoot?.querySelector('qti-assessment-item');\n }\n\n myTemplate: TemplateFunction | null = null;\n\n /** The `qti-test` this ref belongs to, wherever it renders: light DOM, or any depth of shadow roots. */\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n // A context consumer keeps its last value when it is moved somewhere with no provider, and\n // `closest()` never did: a ref moved out of a test must not keep that test's template.\n this.testHost = undefined;\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n\n /*\n Optional per-item template, used to render extra things around an item —\n a bookmark, an index number, a score badge. Put it in the light DOM of\n your qti-test, and every item-ref in the test renders with it:\n\n <qti-test>\n <template item-ref>\n <div class=\"badge\">{{ identifier }}</div>\n {{ xmlDoc }}\n </template>\n …\n </qti-test>\n\n The template is the WHOLE render, so it has to place {{ xmlDoc }} itself;\n leaving it out renders the chrome and no item. Without a template the\n element renders the item on its own, exactly as before.\n\n Resolved once, on connect: one template serves every item, and everything\n that varies per item comes through the model (see ItemRefTemplateModel).\n */\n const templateElement = this.testHost?.querySelector<HTMLTemplateElement>('template[item-ref]');\n this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;\n this.requestUpdate();\n\n await this.updateComplete;\n\n dispatchPublic(this, 'qc-item-ref-connected', {\n identifier: this.identifier,\n href: this.href,\n category: this.category\n });\n }\n\n #computedItem(): ComputedItem | undefined {\n for (const testPart of this.computedContext?.testParts ?? []) {\n for (const section of testPart.sections) {\n const item = section.items.find(i => i.identifier === this.identifier);\n if (item) return item;\n }\n }\n return undefined;\n }\n\n /**\n * The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned\n * once per document and template, not per render: re-renders from\n * computed-context changes then hand Lit the same fragment, which it leaves\n * alone, instead of rebuilding the item (and reloading its PCIs, which\n * changes the context again).\n */\n #rendered: { source: DocumentFragment; template: TemplateFunction | null; doc: DocumentFragment } | null = null;\n\n override render() {\n // Item refs connect before loading, and navigation clears their documents.\n if (!this.xmlDoc) {\n this.#rendered = null;\n return nothing;\n }\n\n if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {\n this.#rendered = {\n source: this.xmlDoc,\n template: this.myTemplate,\n doc: this.xmlDoc.cloneNode(true) as DocumentFragment\n };\n }\n const xmlDoc = this.#rendered.doc;\n if (!this.myTemplate) return xmlDoc;\n\n const model: ItemRefTemplateModel = {\n xmlDoc,\n identifier: this.identifier,\n href: this.href,\n category: this.category,\n item: this.#computedItem(),\n itemRef: this\n };\n return this.myTemplate(model);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item-ref': QtiAssessmentItemRef;\n }\n}\n"]}
@@ -16,6 +16,6 @@ declare global {
16
16
  }
17
17
  declare module '../../public-events' {
18
18
  interface PublicEventMap {
19
- 'cito-test-loaded': CustomEvent<QtiAssessmentTest>;
19
+ 'qc-test-loaded': CustomEvent<QtiAssessmentTest>;
20
20
  }
21
21
  }
@@ -22,7 +22,7 @@ export class QtiAssessmentTest extends LitElement {
22
22
  async connectedCallback() {
23
23
  super.connectedCallback();
24
24
  await this.updateComplete;
25
- dispatchPublic(this, 'cito-test-loaded', this);
25
+ dispatchPublic(this, 'qc-test-loaded', this);
26
26
  }
27
27
  render() {
28
28
  return html ` <slot></slot>`;
@@ -1 +1 @@
1
- {"version":3,"file":"qti-assessment-test.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-test/qti-assessment-test.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAG/C,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,IAAa,KAAK,CAAC,KAAa;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAID,MAAM,GAAG,EAAE,CAAC;IAEH,KAAK,CAAC,iBAAiB;QAC9B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,gBAAgB,CAAC;IAC9B,CAAC;CACF;AAxB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAoB;AAE/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAG1B;AAQM;IADN,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACjB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { testContext } from '@qti-components/base';\n\nimport { dispatchPublic } from '../../public-events';\n\nimport type { TestContext } from '@qti-components/base';\n\nexport class QtiAssessmentTest extends LitElement {\n @property({ type: String }) identifier: string;\n @property({ type: String })\n override get title(): string {\n return this.#title;\n }\n override set title(value: string) {\n this.#title = value;\n this.removeAttribute('title');\n this.setAttribute('data-title', value);\n }\n\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n #title = '';\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n dispatchPublic(this, 'cito-test-loaded', this);\n }\n\n override render() {\n return html` <slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-test': QtiAssessmentTest;\n }\n}\n\ndeclare module '../../public-events' {\n interface PublicEventMap {\n 'cito-test-loaded': CustomEvent<QtiAssessmentTest>;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-assessment-test.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-test/qti-assessment-test.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAG/C,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,IAAa,KAAK,CAAC,KAAa;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAID,MAAM,GAAG,EAAE,CAAC;IAEH,KAAK,CAAC,iBAAiB;QAC9B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,gBAAgB,CAAC;IAC9B,CAAC;CACF;AAxB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAoB;AAE/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAG1B;AAQM;IADN,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACjB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { testContext } from '@qti-components/base';\n\nimport { dispatchPublic } from '../../public-events';\n\nimport type { TestContext } from '@qti-components/base';\n\nexport class QtiAssessmentTest extends LitElement {\n @property({ type: String }) identifier: string;\n @property({ type: String })\n override get title(): string {\n return this.#title;\n }\n override set title(value: string) {\n this.#title = value;\n this.removeAttribute('title');\n this.setAttribute('data-title', value);\n }\n\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n #title = '';\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n dispatchPublic(this, 'qc-test-loaded', this);\n }\n\n override render() {\n return html` <slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-test': QtiAssessmentTest;\n }\n}\n\ndeclare module '../../public-events' {\n interface PublicEventMap {\n 'qc-test-loaded': CustomEvent<QtiAssessmentTest>;\n }\n}\n"]}
@@ -26,7 +26,7 @@ export class QtiNumberPresented extends QtiExpression {
26
26
  #connectedTest = null;
27
27
  constructor() {
28
28
  super();
29
- listenPublic(this, 'cito-test-loaded', (e) => (this.#connectedTest = e.detail));
29
+ listenPublic(this, 'qc-test-loaded', (e) => (this.#connectedTest = e.detail));
30
30
  }
31
31
  /** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */
32
32
  get #testElement() {
@@ -1 +1 @@
1
- {"version":3,"file":"qti-number-presented.js","sourceRoot":"","sources":["../../../src/components/qti-number-presented/qti-number-presented.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKnD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,kBAAmB,SAAQ,aAAqB;IAI3D,cAAc,GAA6B,IAAI,CAAC;IAEhD;QACE,KAAK,EAAE,CAAC;QACR,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAiC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAClH,CAAC;IAED,8GAA8G;IAC9G,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,CAAoB,qBAAqB,CAAC,CAAC;IACvF,CAAC;IAEe,SAAS;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;YACzF,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,CACvB,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC;aAC7B,MAAM,CAAC,IAAI,CAAC,EAAE;YACb,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,kBAAkB,CAAC,EAAE,KAAK,CAAC;YACrF,OAAO,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,eAAe,CAAC;QACtD,CAAC,CAAC;aACD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAChC,CAAC;QACF,OAAO,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IACtH,CAAC;IAEe,SAAS;QACvB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF;AAnCQ;IADN,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;wDACjB","sourcesContent":["import { consume } from '@lit/context';\n\nimport { QtiExpression, testContext } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { TestContext } from '@qti-components/base';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\n\n/**\n * @summary The qti-number-presented expression counts the selected items that have been presented to the candidate.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-presented\n *\n * Outcome processing only. `section-identifier`, `include-category` and\n * `exclude-category` narrow which item references are counted, the same way as\n * for `qti-number-selected` and `qti-test-variables`.\n *\n * An item is presented once its `completionStatus` has left `not_attempted`:\n * presenting an item starts its first attempt. An item a linear test part\n * passed over (pre-condition, branch rule) or one the candidate has not reached\n * keeps `not_attempted`. That makes this the count to use for a total over the\n * candidate's own route, such as a maximum score of one point per presented item.\n */\nexport class QtiNumberPresented extends QtiExpression<number> {\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult(): number {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-number-presented: no enclosing qti-assessment-test, nothing to count');\n return 0;\n }\n\n const presented = new Set(\n (this._testContext?.items ?? [])\n .filter(item => {\n const status = item.variables?.find(v => v.identifier === 'completionStatus')?.value;\n return status != null && status !== 'not_attempted';\n })\n .map(item => item.identifier)\n );\n return selectItemRefs(testElement, selectionFrom(this)).filter(itemRef => presented.has(itemRef.identifier)).length;\n }\n\n public override calculate(): number {\n return this.getResult();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-number-presented': QtiNumberPresented;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-number-presented.js","sourceRoot":"","sources":["../../../src/components/qti-number-presented/qti-number-presented.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,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H,CAAC;IAEe,SAAS;QACvB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF;AAnCQ;IADN,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;wDACjB","sourcesContent":["import { consume } from '@lit/context';\n\nimport { QtiExpression, testContext } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { TestContext } from '@qti-components/base';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\n\n/**\n * @summary The qti-number-presented expression counts the selected items that have been presented to the candidate.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-presented\n *\n * Outcome processing only. `section-identifier`, `include-category` and\n * `exclude-category` narrow which item references are counted, the same way as\n * for `qti-number-selected` and `qti-test-variables`.\n *\n * An item is presented once its `completionStatus` has left `not_attempted`:\n * presenting an item starts its first attempt. An item a linear test part\n * passed over (pre-condition, branch rule) or one the candidate has not reached\n * keeps `not_attempted`. That makes this the count to use for a total over the\n * candidate's own route, such as a maximum score of one point per presented item.\n */\nexport class QtiNumberPresented extends QtiExpression<number> {\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult(): number {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-number-presented: no enclosing qti-assessment-test, nothing to count');\n return 0;\n }\n\n const presented = new Set(\n (this._testContext?.items ?? [])\n .filter(item => {\n const status = item.variables?.find(v => v.identifier === 'completionStatus')?.value;\n return status != null && status !== 'not_attempted';\n })\n .map(item => item.identifier)\n );\n return selectItemRefs(testElement, selectionFrom(this)).filter(itemRef => presented.has(itemRef.identifier)).length;\n }\n\n public override calculate(): number {\n return this.getResult();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-number-presented': QtiNumberPresented;\n }\n}\n"]}
@@ -17,10 +17,10 @@ export class QtiNumberSelected extends QtiExpression {
17
17
  #connectedTest = null;
18
18
  constructor() {
19
19
  super();
20
- listenPublic(this, 'cito-test-loaded', (e) => (this.#connectedTest = e.detail));
20
+ listenPublic(this, 'qc-test-loaded', (e) => (this.#connectedTest = e.detail));
21
21
  }
22
22
  /**
23
- * `qti-assessment-test-connected` bubbles *up* from the test element, and this
23
+ * `qc-test-loaded` bubbles *up* from the test element, and this
24
24
  * expression lives inside that test's `qti-outcome-processing` — so the
25
25
  * listener above only ever fires for a test handed to us directly (a test
26
26
  * harness). Walking up the tree is what resolves the test in a real document.
@@ -1 +1 @@
1
- {"version":3,"file":"qti-number-selected.js","sourceRoot":"","sources":["../../../src/components/qti-number-selected/qti-number-selected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAkB,SAAQ,aAAqB;IAC1D,cAAc,GAA6B,IAAI,CAAC;IAEhD;QACE,KAAK,EAAE,CAAC;QACR,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAiC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAClH,CAAC;IAED;;;;;OAKG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,CAAoB,qBAAqB,CAAC,CAAC;IACvF,CAAC;IAEe,SAAS;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC;YACxF,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACjE,CAAC;IAEe,SAAS;QACvB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\n\n/**\n * @summary The qti-number-selected expression counts the item refs selected for the test.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-selected\n *\n * Outcome processing only. `section-identifier`, `include-category` and\n * `exclude-category` narrow which item references are counted; with none of\n * them it is every item reference in the test.\n *\n * The count comes from the item refs in the document rather than the test\n * context, so it is the same set `qti-test-variables` aggregates over — and it\n * is right before any item has been attempted.\n */\nexport class QtiNumberSelected extends QtiExpression<number> {\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /**\n * `qti-assessment-test-connected` bubbles *up* from the test element, and this\n * expression lives inside that test's `qti-outcome-processing` — so the\n * listener above only ever fires for a test handed to us directly (a test\n * harness). Walking up the tree is what resolves the test in a real document.\n */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult(): number {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-number-selected: no enclosing qti-assessment-test, nothing to count');\n return 0;\n }\n\n return selectItemRefs(testElement, selectionFrom(this)).length;\n }\n\n public override calculate(): number {\n return this.getResult();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-number-selected': QtiNumberSelected;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-number-selected.js","sourceRoot":"","sources":["../../../src/components/qti-number-selected/qti-number-selected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAkB,SAAQ,aAAqB;IAC1D,cAAc,GAA6B,IAAI,CAAC;IAEhD;QACE,KAAK,EAAE,CAAC;QACR,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAiC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAChH,CAAC;IAED;;;;;OAKG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,CAAoB,qBAAqB,CAAC,CAAC;IACvF,CAAC;IAEe,SAAS;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC;YACxF,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACjE,CAAC;IAEe,SAAS;QACvB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\n\n/**\n * @summary The qti-number-selected expression counts the item refs selected for the test.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-selected\n *\n * Outcome processing only. `section-identifier`, `include-category` and\n * `exclude-category` narrow which item references are counted; with none of\n * them it is every item reference in the test.\n *\n * The count comes from the item refs in the document rather than the test\n * context, so it is the same set `qti-test-variables` aggregates over — and it\n * is right before any item has been attempted.\n */\nexport class QtiNumberSelected extends QtiExpression<number> {\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /**\n * `qc-test-loaded` bubbles *up* from the test element, and this\n * expression lives inside that test's `qti-outcome-processing` — so the\n * listener above only ever fires for a test handed to us directly (a test\n * harness). Walking up the tree is what resolves the test in a real document.\n */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult(): number {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-number-selected: no enclosing qti-assessment-test, nothing to count');\n return 0;\n }\n\n return selectItemRefs(testElement, selectionFrom(this)).length;\n }\n\n public override calculate(): number {\n return this.getResult();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-number-selected': QtiNumberSelected;\n }\n}\n"]}
@@ -57,8 +57,8 @@ declare const QtiTest_base: (abstract new (...args: any[]) => import("../..").IT
57
57
  * You can use normal class names to style the elements.
58
58
  * And you can use the `test-prev` and `test-next` elements to navigate through the test.
59
59
  *
60
- * @event qti-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
61
- * @event qti-test-context-updated - Deprecated: listen to `qti-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
60
+ * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
61
+ * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
62
62
  */
63
63
  export declare class QtiTest extends QtiTest_base {
64
64
  constructor();
@@ -60,8 +60,8 @@ import { TestStateMixin } from '../../mixins/test-state.mixin';
60
60
  * You can use normal class names to style the elements.
61
61
  * And you can use the `test-prev` and `test-next` elements to navigate through the test.
62
62
  *
63
- * @event qti-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
64
- * @event qti-test-context-updated - Deprecated: listen to `qti-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
63
+ * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
64
+ * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
65
65
  */
66
66
  export class QtiTest extends TestNavigationMixin(TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))) {
67
67
  // TODO: Properly implement IQtiTest interface
@@ -1 +1 @@
1
- {"version":3,"file":"qti-test.js","sourceRoot":"","sources":["../../../src/components/qti-test/qti-test.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC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{ state } from 'lit/decorators.js';\n\nimport { configContext, qtiContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { TestNavigationMixin, TestViewMixin } from '../../mixins';\nimport { TestBaseMixin } from '../../mixins/test-base';\nimport { TestProcessingMixin } from '../../mixins/test-processing.mixin';\nimport { TestStateMixin } from '../../mixins/test-state.mixin';\n\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { IQtiTest } from '../../types/iqti-test';\n\n/**\n * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.\n *\n * This component leverages several mixins to provide functionality for loading, navigating, processing, and displaying QTI test assessments.\n *\n * ### Example Usage\n *\n * Minimal example including navigation:\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container test-url=\"./path/to/assessment.xml\"></test-container>\n * <nav class=\"flex\">\n * <test-prev></test-prev>\n * <test-next></test-next>\n * </nav>\n * </test-navigation>\n * </qti-test>\n * ```\n *\n * Use the following file structure\n * A qti-test loads a QTI3.0 assessmenttest.xml file from a package folder.\n *\n * ```plaintext\n * Root/\n * ├── index.html\n * └── /assets/api/examples/\n * ├── assessmenttest.xml\n * └── imsmanifest.xml\n *\n * ```\n *\n * ### Test components\n *\n * Use test components inside the qti-test component for added functionality.\n * ### Test next\n * `<test-next> | TestNext`\n *\n * ### Test prev\n *\n * `<test-prev> | TestPrev`\n * ### Test components\n *\n * You can use normal class names to style the elements.\n * And you can use the `test-prev` and `test-next` elements to navigate through the test.\n *\n * @event qti-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.\n * @event qti-test-context-updated - Deprecated: listen to `qti-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.\n */\n\nexport class QtiTest extends TestNavigationMixin(\n TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))\n) {\n // TODO: Properly implement IQtiTest interface\n // export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {\n\n constructor() {\n super();\n // The components inside find their test through this, across shadow roots (see TestHost).\n new ContextProvider(this, { context: testHostContext, initialValue: this });\n }\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n /**\n * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so\n * everything inside reads one value: the test-container shuffling the item order, the test\n * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.\n *\n * Pass the same `seed` when resuming a session, or the order comes back different. Replace the\n * object, do not mutate it: an in-place change does not notify the components inside.\n *\n * `test-navigation.qtiContext` is an alias of this.\n */\n @state()\n @provide({ context: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\n\n /**\n * Renders the component's template.\n * Provides a default `<slot>` for content projection.\n */\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(new CustomEvent('qti-test-connected', { detail: this }));\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test': QtiTest;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-test.js","sourceRoot":"","sources":["../../../src/components/qti-test/qti-test.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAK/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,MAAM,OAAO,OAAQ,SAAQ,mBAAmB,CAC9C,aAAa,CAAC,mBAAmB,CAAC,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAC9E;IACC,8CAA8C;IAC9C,+FAA+F;IAE/F;QACE,KAAK,EAAE,CAAC;QAOH,kBAAa,GAAkB,EAAE,CAAC;QAEzC;;;;;;;;;WASG;QAGI,eAAU,GAAe;YAC9B,WAAW,EAAE;gBACX,cAAc,EAAE,EAAE;gBAClB,mBAAmB,EAAE,EAAE;gBACvB,qBAAqB,EAAE,SAAS;aACjC;SACF,CAAC;QA1BA,0FAA0F;QAC1F,IAAI,eAAe,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;IA0BD;;;OAGG;IACM,KAAK,CAAC,iBAAiB;QAC9B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;CACF;AAnCQ;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;8CACK;AAclC;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;2CAO/B","sourcesContent":["import { ContextProvider, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { configContext, qtiContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { TestNavigationMixin, TestViewMixin } from '../../mixins';\nimport { TestBaseMixin } from '../../mixins/test-base';\nimport { TestProcessingMixin } from '../../mixins/test-processing.mixin';\nimport { TestStateMixin } from '../../mixins/test-state.mixin';\n\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { IQtiTest } from '../../types/iqti-test';\n\n/**\n * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.\n *\n * This component leverages several mixins to provide functionality for loading, navigating, processing, and displaying QTI test assessments.\n *\n * ### Example Usage\n *\n * Minimal example including navigation:\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container test-url=\"./path/to/assessment.xml\"></test-container>\n * <nav class=\"flex\">\n * <test-prev></test-prev>\n * <test-next></test-next>\n * </nav>\n * </test-navigation>\n * </qti-test>\n * ```\n *\n * Use the following file structure\n * A qti-test loads a QTI3.0 assessmenttest.xml file from a package folder.\n *\n * ```plaintext\n * Root/\n * ├── index.html\n * └── /assets/api/examples/\n * ├── assessmenttest.xml\n * └── imsmanifest.xml\n *\n * ```\n *\n * ### Test components\n *\n * Use test components inside the qti-test component for added functionality.\n * ### Test next\n * `<test-next> | TestNext`\n *\n * ### Test prev\n *\n * `<test-prev> | TestPrev`\n * ### Test components\n *\n * You can use normal class names to style the elements.\n * And you can use the `test-prev` and `test-next` elements to navigate through the test.\n *\n * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.\n * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.\n */\n\nexport class QtiTest extends TestNavigationMixin(\n TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))\n) {\n // TODO: Properly implement IQtiTest interface\n // export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {\n\n constructor() {\n super();\n // The components inside find their test through this, across shadow roots (see TestHost).\n new ContextProvider(this, { context: testHostContext, initialValue: this });\n }\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n /**\n * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so\n * everything inside reads one value: the test-container shuffling the item order, the test\n * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.\n *\n * Pass the same `seed` when resuming a session, or the order comes back different. Replace the\n * object, do not mutate it: an in-place change does not notify the components inside.\n *\n * `test-navigation.qtiContext` is an alias of this.\n */\n @state()\n @provide({ context: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\n\n /**\n * Renders the component's template.\n * Provides a default `<slot>` for content projection.\n */\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(new CustomEvent('qti-test-connected', { detail: this }));\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test': QtiTest;\n }\n}\n"]}
@@ -13,10 +13,10 @@ export class QtiTestVariables extends QtiExpression {
13
13
  #connectedTest = null;
14
14
  constructor() {
15
15
  super();
16
- listenPublic(this, 'cito-test-loaded', (e) => (this.#connectedTest = e.detail));
16
+ listenPublic(this, 'qc-test-loaded', (e) => (this.#connectedTest = e.detail));
17
17
  }
18
18
  /**
19
- * `qti-assessment-test-connected` bubbles *up* from the test element, and this
19
+ * `qc-test-loaded` bubbles *up* from the test element, and this
20
20
  * expression lives inside that test's `qti-outcome-processing` — so the
21
21
  * listener above only ever fires for a test handed to us directly (a test
22
22
  * harness). Walking up the tree is what resolves the test in a real document.
@@ -1 +1 @@
1
- {"version":3,"file":"qti-test-variables.js","sourceRoot":"","sources":["../../../src/components/qti-test-variables/qti-test-variables.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM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,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;gBACrF,IAAI,QAAQ,EAAE,CAAC;oBACb,mEAAmE;oBACnE,sEAAsE;oBACtE,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;oBACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;wBACzB,KAAK,IAAI,KAAK,GAAG,MAAM,CAAC;oBAC1B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { consume } from '@lit/context';\n\nimport { testContext } from '@qti-components/base';\nimport { QtiExpression } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { TestContext } from '@qti-components/base';\nimport type { QtiExpressionBase } from '@qti-components/base';\n\nexport class QtiTestVariables extends QtiExpression<number> {\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /**\n * `qti-assessment-test-connected` bubbles *up* from the test element, and this\n * expression lives inside that test's `qti-outcome-processing` — so the\n * listener above only ever fires for a test handed to us directly (a test\n * harness). Walking up the tree is what resolves the test in a real document.\n */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult() {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-test-variables: no enclosing qti-assessment-test, nothing to aggregate');\n return 0;\n }\n\n const weightIdentifier = this.getAttribute('weight-identifier') ?? '';\n const itemVariable = this.getAttribute('variable-identifier');\n\n const includedItems = selectItemRefs(testElement, selectionFrom(this)).map(itemRef => ({\n item: itemRef.identifier,\n weight: (weightIdentifier ? itemRef.weights.get(weightIdentifier) : undefined) ?? 1\n }));\n\n const logic = new QtiTestVariablesExpression(this._testContext, itemVariable, includedItems);\n const value = logic.calculate();\n return value;\n }\n\n public override calculate() {\n return this.getResult();\n }\n}\n\nexport class QtiTestVariablesExpression implements QtiExpressionBase<number> {\n constructor(\n private testContext: TestContext,\n private itemVariable: string,\n private includedItems: { item: string; weight: number }[]\n ) {}\n\n calculate(): number {\n const items = this.testContext?.items ?? [];\n let total = 0;\n const uniqueItems = [...new Set(this.includedItems.map(item => item.item))];\n items.forEach(item => {\n if (uniqueItems.includes(item.identifier)) {\n const variable = item.variables.find(vr => vr.identifier === this.itemVariable);\n const weight = this.includedItems.find(i => i.item === item.identifier)?.weight ?? 1;\n if (variable) {\n // An unscored item carries a non-numeric value; counting it as NaN\n // would poison the whole total rather than just its own contribution.\n const value = Number(variable.value);\n if (!Number.isNaN(value)) {\n total += value * weight;\n }\n }\n }\n });\n return total;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test-variables': QtiTestVariables;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-test-variables.js","sourceRoot":"","sources":["../../../src/components/qti-test-variables/qti-test-variables.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,MAAM,OAAO,gBAAiB,SAAQ,aAAqB;IAIzD,cAAc,GAA6B,IAAI,CAAC;IAEhD;QACE,KAAK,EAAE,CAAC;QACR,YAAY,CAAC,IAAI,EAAE,gBA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O,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { consume } from '@lit/context';\n\nimport { testContext } from '@qti-components/base';\nimport { QtiExpression } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { TestContext } from '@qti-components/base';\nimport type { QtiExpressionBase } from '@qti-components/base';\n\nexport class QtiTestVariables extends QtiExpression<number> {\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /**\n * `qc-test-loaded` bubbles *up* from the test element, and this\n * expression lives inside that test's `qti-outcome-processing` — so the\n * listener above only ever fires for a test handed to us directly (a test\n * harness). Walking up the tree is what resolves the test in a real document.\n */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult() {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-test-variables: no enclosing qti-assessment-test, nothing to aggregate');\n return 0;\n }\n\n const weightIdentifier = this.getAttribute('weight-identifier') ?? '';\n const itemVariable = this.getAttribute('variable-identifier');\n\n const includedItems = selectItemRefs(testElement, selectionFrom(this)).map(itemRef => ({\n item: itemRef.identifier,\n weight: (weightIdentifier ? itemRef.weights.get(weightIdentifier) : undefined) ?? 1\n }));\n\n const logic = new QtiTestVariablesExpression(this._testContext, itemVariable, includedItems);\n const value = logic.calculate();\n return value;\n }\n\n public override calculate() {\n return this.getResult();\n }\n}\n\nexport class QtiTestVariablesExpression implements QtiExpressionBase<number> {\n constructor(\n private testContext: TestContext,\n private itemVariable: string,\n private includedItems: { item: string; weight: number }[]\n ) {}\n\n calculate(): number {\n const items = this.testContext?.items ?? [];\n let total = 0;\n const uniqueItems = [...new Set(this.includedItems.map(item => item.item))];\n items.forEach(item => {\n if (uniqueItems.includes(item.identifier)) {\n const variable = item.variables.find(vr => vr.identifier === this.itemVariable);\n const weight = this.includedItems.find(i => i.item === item.identifier)?.weight ?? 1;\n if (variable) {\n // An unscored item carries a non-numeric value; counting it as NaN\n // would poison the whole total rather than just its own contribution.\n const value = Number(variable.value);\n if (!Number.isNaN(value)) {\n total += value * weight;\n }\n }\n }\n });\n return total;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test-variables': QtiTestVariables;\n }\n}\n"]}
@@ -8,26 +8,37 @@ import { css, html } from 'lit';
8
8
  * colour on top. No shadow, no glow, no transition, so the controls read as unbranded until a host
9
9
  * repaints them.
10
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.
11
+ * Every colour is the theme's tier 1 (CONTRACT.md §8 in qti-theme): `--qc-*` first, the older
12
+ * `--cito-*` name as its fallback for this major, and a CSS system colour behind both for a page
13
+ * that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the controls stay
14
+ * legible in dark mode without the theme too. Hover and press mix the content colour into the
15
+ * fill, by --qti-hover-mix and --qti-active-mix.
15
16
  *
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.
17
+ * Paint comes from the `--button-*` slots, the one button slot set the theme's `@mixin paint button`
18
+ * reads too, so a host that repaints its buttons repaints the test controls, the end-attempt and the
19
+ * upload button alike. The older `--test-button-*` names are aliases: each slot is read as
20
+ * `var(--button-X, var(--test-button-X, <default>))`. Never the shared `--qti-component-*` tokens:
21
+ * those also paint the items' own borders, and a change to how a button looks must not move an
22
+ * interaction.
19
23
  *
20
- * --test-button-background-color, --test-button-color, --test-button-border-color,
21
- * --test-button-hover-background-color, --test-button-active-background-color
24
+ * --button-size, --button-border-radius the box
25
+ * --button-background-color, --button-color, --button-border-color,
26
+ * --button-hover-background-color, --button-active-background-color
22
27
  * 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
28
+ * --button-primary-background-color, --button-primary-color,
29
+ * --button-primary-hover-background-color, --button-primary-active-background-color
25
30
  * the filled look only
31
+ * --button-selected-background-color, --button-selected-color
32
+ * a toggle that is on (the host carries :state(selected))
33
+ *
34
+ * --test-button-<same> aliases of the names above
26
35
  */
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))`;
36
+ const surface = css `var(--qti-color-base-100, var(--qc-color-base-100, var(--cito-color-base-100, Canvas)))`;
37
+ const content = css `var(--qti-color-base-content, var(--qc-color-base-content, var(--cito-color-base-content, CanvasText)))`;
38
+ const neutral = css `var(--qti-color-neutral, var(--qc-color-neutral, var(--cito-color-neutral, CanvasText)))`;
39
+ const neutralContent = css `var(--qti-color-neutral-content, var(--qc-color-neutral-content, var(--cito-color-neutral-content, Canvas)))`;
40
+ const radius = css `var(--button-border-radius, var(--test-button-border-radius, var(--qti-radius-field, var(--qc-radius-field, var(--cito-radius-field, 0.2rem)))))`;
41
+ const borderWidth = css `var(--qti-border-width, var(--qc-border-width, var(--cito-border-width, 1px)))`;
31
42
  /*
32
43
  * A test control is drawn on an inner element (`.control`, part "button"), never on its host.
33
44
  *
@@ -42,7 +53,7 @@ export const hostBox = css `
42
53
  display: inline-flex;
43
54
  cursor: pointer;
44
55
  user-select: none;
45
- border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));
56
+ border-radius: ${radius};
46
57
  `;
47
58
  /** The box of the control itself: the inner element. */
48
59
  export const form = css `
@@ -52,51 +63,60 @@ export const form = css `
52
63
  justify-content: center;
53
64
  gap: 0.375em;
54
65
  box-sizing: border-box;
55
- min-block-size: var(--test-button-size, 2.25rem);
66
+ min-block-size: var(--button-size, var(--test-button-size, 2.25rem));
56
67
  padding: 0 0.875rem;
57
68
  font: inherit;
58
69
  line-height: 1.25;
59
70
  cursor: pointer;
60
71
  user-select: none;
61
- border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));
72
+ border-radius: ${radius};
62
73
  `;
63
74
  export const btn = css `
64
75
  ${form};
65
- background-color: var(--test-button-background-color, ${surface});
66
- color: var(--test-button-color, inherit);
67
- border: var(--qti-border-width, var(--cito-border-width, 1px)) solid
68
- var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})));
76
+ background-color: var(--button-background-color, var(--test-button-background-color, ${surface}));
77
+ color: var(--button-color, var(--test-button-color, inherit));
78
+ border: ${borderWidth} solid
79
+ var(
80
+ --button-border-color,
81
+ var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})))
82
+ );
69
83
  `;
70
84
  /** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */
71
85
  export const btnPrimary = css `
72
- background-color: var(--test-button-primary-background-color, ${neutral});
73
- color: var(--test-button-primary-color, ${neutralContent});
74
- border-color: var(--test-button-primary-background-color, ${neutral});
86
+ background-color: var(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));
87
+ color: var(--button-primary-color, var(--test-button-primary-color, ${neutralContent}));
88
+ border-color: var(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));
75
89
  `;
76
90
  /** Hover; paint only, so the box never moves. */
77
91
  export const btnInteractive = css `
78
92
  background-color: var(
79
- --test-button-hover-background-color,
80
- color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%))
93
+ --button-hover-background-color,
94
+ var(--test-button-hover-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%)))
81
95
  );
82
96
  `;
83
97
  export const btnPrimaryInteractive = css `
84
98
  background-color: var(
85
- --test-button-primary-hover-background-color,
86
- color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))
99
+ --button-primary-hover-background-color,
100
+ var(
101
+ --test-button-primary-hover-background-color,
102
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))
103
+ )
87
104
  );
88
105
  `;
89
106
  /** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */
90
107
  export const btnActive = css `
91
108
  background-color: var(
92
- --test-button-active-background-color,
93
- color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%))
109
+ --button-active-background-color,
110
+ var(--test-button-active-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%)))
94
111
  );
95
112
  `;
96
113
  export const btnPrimaryActive = css `
97
114
  background-color: var(
98
- --test-button-primary-active-background-color,
99
- color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))
115
+ --button-primary-active-background-color,
116
+ var(
117
+ --test-button-primary-active-background-color,
118
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))
119
+ )
100
120
  );
101
121
  `;
102
122
  /** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */
@@ -110,7 +130,7 @@ export const dis = css `
110
130
  `;
111
131
  export const ind = css `
112
132
  ${form};
113
- border: var(--qti-border-width, var(--cito-border-width, 1px)) solid var(--qti-border-color, GrayText);
133
+ border: ${borderWidth} solid var(--qti-border-color, GrayText);
114
134
  `;
115
135
  /** What a test control renders: the inner element that carries the look (see `hostBox`). */
116
136
  export const control = html `<span class="control" part="button"><slot></slot></span>`;
@@ -133,6 +153,16 @@ export const button = css `
133
153
  :host(:active:not([disabled])) .control {
134
154
  ${btnActive};
135
155
  }
156
+ /* The press the theme gives a choice (qti-motion.css), from the same knob: a touch smaller while
157
+ the button is down, springing back on release; 0 motion means no press. */
158
+ .control {
159
+ transition:
160
+ background-color calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1),
161
+ scale calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1);
162
+ }
163
+ :host(:active:not([disabled])) .control {
164
+ scale: calc(1 - 0.03 * var(--qti-motion, 1));
165
+ }
136
166
  :host(:focus-visible) {
137
167
  ${focusRing};
138
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;;;;;CAKzB,CAAC;AAEF,wDAAwD;AACxD,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;;CActB,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;AAEF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAA,0DAA0D,CAAC;AAEtF;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;MAEnB,OAAO;;;MAGP,GAAG;;;;QAID,cAAc;;;;MAIhB,SAAS;;;MAGT,SAAS;;;MAGT,GAAG;;;;;CAKR,CAAC;AAEF,iGAAiG;AACjG,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;;MAE1B,UAAU;;;;QAIR,qBAAqB;;;;MAIvB,gBAAgB;;CAErB,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css, html } 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\n/*\n * A test control is drawn on an inner element (`.control`, part \"button\"), never on its host.\n *\n * A page's reset, Tailwind's preflight for one (`*, ::before, ::after { margin: 0; padding: 0; border: 0 solid }`),\n * is a rule of the page, and a page rule beats the `:host` rules of a shadow root whatever its layer or its\n * specificity. A control that paints its padding and border on the host loses them to such a reset. The\n * inner element lives in the shadow tree, where the page's `*` does not reach, so the control looks the same with\n * or without a reset. The host keeps only what a reset leaves alone: its display, the radius its focus ring\n * follows, and the cursor.\n */\nexport const hostBox = css`\n display: inline-flex;\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\n/** The box of the control itself: the inner element. */\nexport const form = css`\n display: flex;\n flex: 1 1 auto;\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\n/** What a test control renders: the inner element that carries the look (see `hostBox`). */\nexport const control = html`<span class=\"control\" part=\"button\"><slot></slot></span>`;\n\n/**\n * The stylesheet of a neutral test control: the host box, the look on `.control`, and its hover, press,\n * focus and disabled states. A control with its own content (a bookmark's icon) adds to it.\n */\nexport const button = css`\n :host {\n ${hostBox};\n }\n .control {\n ${btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnActive};\n }\n :host(:focus-visible) {\n ${focusRing};\n }\n :host([disabled]) {\n ${dis};\n }\n :host([disabled]) .control {\n cursor: not-allowed;\n }\n`;\n\n/** The filled look of `test-next`: add after `button`, so its rules win at equal specificity. */\nexport const buttonPrimary = css`\n .control {\n ${btnPrimary};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnPrimaryInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnPrimaryActive};\n }\n`;\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,MAAM,OAAO,GAAG,GAAG,CAAA,yFAAyF,CAAC;AAC7G,MAAM,OAAO,GAAG,GAAG,CAAA,yGAAyG,CAAC;AAC7H,MAAM,OAAO,GAAG,GAAG,CAAA,0FAA0F,CAAC;AAC9G,MAAM,cAAc,GAAG,GAAG,CAAA,8GAA8G,CAAC;AACzI,MAAM,MAAM,GAAG,GAAG,CAAA,kJAAkJ,CAAC;AACrK,MAAM,WAAW,GAAG,GAAG,CAAA,gFAAgF,CAAC;AAExG;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;;;;mBAIP,MAAM;CACxB,CAAC;AAEF,wDAAwD;AACxD,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;mBAaJ,MAAM;CACxB,CA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AAqB;;;;MAIvB,gBAAgB;;CAErB,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css, html } 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): `--qc-*` first, the older\n * `--cito-*` name as its fallback for this major, and a CSS system colour behind both for a page\n * that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the controls stay\n * legible in dark mode without the theme too. Hover and press mix the content colour into the\n * fill, by --qti-hover-mix and --qti-active-mix.\n *\n * Paint comes from the `--button-*` slots, the one button slot set the theme's `@mixin paint button`\n * reads too, so a host that repaints its buttons repaints the test controls, the end-attempt and the\n * upload button alike. The older `--test-button-*` names are aliases: each slot is read as\n * `var(--button-X, var(--test-button-X, <default>))`. Never the shared `--qti-component-*` tokens:\n * those also paint the items' own borders, and a change to how a button looks must not move an\n * interaction.\n *\n * --button-size, --button-border-radius the box\n * --button-background-color, --button-color, --button-border-color,\n * --button-hover-background-color, --button-active-background-color\n * the neutral look, and the filled look's slots\n * --button-primary-background-color, --button-primary-color,\n * --button-primary-hover-background-color, --button-primary-active-background-color\n * the filled look only\n * --button-selected-background-color, --button-selected-color\n * a toggle that is on (the host carries :state(selected))\n *\n * --test-button-<same> aliases of the names above\n */\n\nconst surface = css`var(--qti-color-base-100, var(--qc-color-base-100, var(--cito-color-base-100, Canvas)))`;\nconst content = css`var(--qti-color-base-content, var(--qc-color-base-content, var(--cito-color-base-content, CanvasText)))`;\nconst neutral = css`var(--qti-color-neutral, var(--qc-color-neutral, var(--cito-color-neutral, CanvasText)))`;\nconst neutralContent = css`var(--qti-color-neutral-content, var(--qc-color-neutral-content, var(--cito-color-neutral-content, Canvas)))`;\nconst radius = css`var(--button-border-radius, var(--test-button-border-radius, var(--qti-radius-field, var(--qc-radius-field, var(--cito-radius-field, 0.2rem)))))`;\nconst borderWidth = css`var(--qti-border-width, var(--qc-border-width, var(--cito-border-width, 1px)))`;\n\n/*\n * A test control is drawn on an inner element (`.control`, part \"button\"), never on its host.\n *\n * A page's reset, Tailwind's preflight for one (`*, ::before, ::after { margin: 0; padding: 0; border: 0 solid }`),\n * is a rule of the page, and a page rule beats the `:host` rules of a shadow root whatever its layer or its\n * specificity. A control that paints its padding and border on the host loses them to such a reset. The\n * inner element lives in the shadow tree, where the page's `*` does not reach, so the control looks the same with\n * or without a reset. The host keeps only what a reset leaves alone: its display, the radius its focus ring\n * follows, and the cursor.\n */\nexport const hostBox = css`\n display: inline-flex;\n cursor: pointer;\n user-select: none;\n border-radius: ${radius};\n`;\n\n/** The box of the control itself: the inner element. */\nexport const form = css`\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--button-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: ${radius};\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--button-background-color, var(--test-button-background-color, ${surface}));\n color: var(--button-color, var(--test-button-color, inherit));\n border: ${borderWidth} solid\n var(\n --button-border-color,\n var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})))\n );\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(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));\n color: var(--button-primary-color, var(--test-button-primary-color, ${neutralContent}));\n border-color: var(--button-primary-background-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 --button-hover-background-color,\n var(--test-button-hover-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%)))\n );\n`;\n\nexport const btnPrimaryInteractive = css`\n background-color: var(\n --button-primary-hover-background-color,\n var(\n --test-button-primary-hover-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))\n )\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 --button-active-background-color,\n var(--test-button-active-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%)))\n );\n`;\n\nexport const btnPrimaryActive = css`\n background-color: var(\n --button-primary-active-background-color,\n var(\n --test-button-primary-active-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))\n )\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: ${borderWidth} solid var(--qti-border-color, GrayText);\n`;\n\n/** What a test control renders: the inner element that carries the look (see `hostBox`). */\nexport const control = html`<span class=\"control\" part=\"button\"><slot></slot></span>`;\n\n/**\n * The stylesheet of a neutral test control: the host box, the look on `.control`, and its hover, press,\n * focus and disabled states. A control with its own content (a bookmark's icon) adds to it.\n */\nexport const button = css`\n :host {\n ${hostBox};\n }\n .control {\n ${btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnActive};\n }\n /* The press the theme gives a choice (qti-motion.css), from the same knob: a touch smaller while\n the button is down, springing back on release; 0 motion means no press. */\n .control {\n transition:\n background-color calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1),\n scale calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1);\n }\n :host(:active:not([disabled])) .control {\n scale: calc(1 - 0.03 * var(--qti-motion, 1));\n }\n :host(:focus-visible) {\n ${focusRing};\n }\n :host([disabled]) {\n ${dis};\n }\n :host([disabled]) .control {\n cursor: not-allowed;\n }\n`;\n\n/** The filled look of `test-next`: add after `button`, so its rules win at equal specificity. */\nexport const buttonPrimary = css`\n .control {\n ${btnPrimary};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnPrimaryInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnPrimaryActive};\n }\n`;\n"]}
@@ -105,7 +105,7 @@ export class TestBookmark extends LitElement {
105
105
  const marked = bookmarkedItems(this.computedContext);
106
106
  const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];
107
107
  // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.
108
- dispatchPublic(this, 'cito-test-update-plugin-state', {
108
+ dispatchPublic(this, 'qc-test-update-plugin-state', {
109
109
  plugin: 'bookmarks',
110
110
  value: next.length > 0 ? next : null
111
111
  });
@@ -1 +1 @@
1
- {"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAqD,EAAY,EAAE,CACjG,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CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;QAChG,4FAA4F;QAC5F,cAAc,CAAC,IAAI,EAAE,+BAA+B,EAAE;YACpD,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;SACrC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;;aAEF,CAAC;IACZ,CAAC;;AAnFS;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 = [\n styles.button,\n css`\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 `\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`<span class=\"control\" part=\"button\"\n ><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot\n ></span>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
1
+ {"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAA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AI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO;QACL,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACrD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;QAChG,4FAA4F;QAC5F,cAAc,CAAC,IAAI,EAAE,6BAA6B,EAAE;YAClD,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;SACrC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;;aAEF,CAAC;IACZ,CAAC;;AAnFS;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 = [\n styles.button,\n css`\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 `\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, 'qc-test-update-plugin-state', {\n plugin: 'bookmarks',\n value: next.length > 0 ? next : null\n });\n }\n\n override render() {\n return html`<span class=\"control\" part=\"button\"\n ><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot\n ></span>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
@@ -21,8 +21,8 @@ export class TestCheckItem extends LitElement {
21
21
  super();
22
22
  this.view = 'scorer';
23
23
  this.addEventListener('click', () => {
24
- dispatchPublic(this, 'cito-test-end-attempt', {});
25
- dispatchPublic(this, 'cito-test-switch-view', this.view);
24
+ dispatchPublic(this, 'qc-test-end-attempt', {});
25
+ dispatchPublic(this, 'qc-test-switch-view', this.view);
26
26
  });
27
27
  }
28
28
  render() {
@@ -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,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,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,MAAM,CAAC,MAAM,AAAhB,CAAiB;IAEvC;QACE,KAAK,EAAE,CAAC;QALkB,SAAI,GAAS,QAAQ,CAAC;QAMhD,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,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAd2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { 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 = styles.button;\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 styles.control;\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,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,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,MAAM,CAAC,MAAM,AAAhB,CAAiB;IAEvC;QACE,KAAK,EAAE,CAAC;QALkB,SAAI,GAAS,QAAQ,CAAC;QAMhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;YAChD,cAAc,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAd2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { 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 = styles.button;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'qc-test-end-attempt', {});\n dispatchPublic(this, 'qc-test-switch-view', this.view);\n });\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
@@ -85,7 +85,7 @@ export class TestContainer extends LitElement {
85
85
  * Assign a new test document and announce it.
86
86
  *
87
87
  * The announcement has to happen here rather than on
88
- * `qti-assessment-test-connected`, because by then the new document's
88
+ * `qc-test-loaded`, because by then the new document's
89
89
  * children have already connected and registered themselves — a host that
90
90
  * resets its context on that event throws those registrations away. Lit's
91
91
  * re-render is async, so a handler running now still gets in before any child