@qti-components/test 2.0.0-next.13 → 2.0.0-next.15

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 (107) hide show
  1. package/dist/components/index.d.ts +0 -2
  2. package/dist/components/index.js +0 -2
  3. package/dist/components/index.js.map +1 -1
  4. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +1 -1
  5. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
  6. package/dist/components/qti-assessment-test/qti-assessment-test.d.ts +1 -1
  7. package/dist/components/qti-assessment-test/qti-assessment-test.js +1 -1
  8. package/dist/components/qti-assessment-test/qti-assessment-test.js.map +1 -1
  9. package/dist/components/qti-number-presented/qti-number-presented.js +1 -1
  10. package/dist/components/qti-number-presented/qti-number-presented.js.map +1 -1
  11. package/dist/components/qti-number-selected/qti-number-selected.js +2 -2
  12. package/dist/components/qti-number-selected/qti-number-selected.js.map +1 -1
  13. package/dist/components/qti-test/qti-test.d.ts +2 -2
  14. package/dist/components/qti-test/qti-test.js +2 -2
  15. package/dist/components/qti-test/qti-test.js.map +1 -1
  16. package/dist/components/qti-test-variables/qti-test-variables.js +2 -2
  17. package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -1
  18. package/dist/components/styles.js +64 -34
  19. package/dist/components/styles.js.map +1 -1
  20. package/dist/components/test-container/test-container.js +1 -1
  21. package/dist/components/test-container/test-container.js.map +1 -1
  22. package/dist/components/test-end-attempt/test-end-attempt.d.ts +1 -1
  23. package/dist/components/test-end-attempt/test-end-attempt.js +2 -2
  24. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  25. package/dist/components/test-navigation/test-navigation.js +4 -4
  26. package/dist/components/test-navigation/test-navigation.js.map +1 -1
  27. package/dist/components/test-next/test-next.js +1 -1
  28. package/dist/components/test-next/test-next.js.map +1 -1
  29. package/dist/components/test-prev/test-prev.js +1 -1
  30. package/dist/components/test-prev/test-prev.js.map +1 -1
  31. package/dist/components/test-submit/test-submit.d.ts +1 -1
  32. package/dist/components/test-submit/test-submit.js +2 -2
  33. package/dist/components/test-submit/test-submit.js.map +1 -1
  34. package/dist/elements.d.ts +1 -63
  35. package/dist/elements.js +1 -5
  36. package/dist/elements.js.map +1 -1
  37. package/dist/mixins/test-base.js +3 -3
  38. package/dist/mixins/test-base.js.map +1 -1
  39. package/dist/mixins/test-navigation.mixin.js +13 -13
  40. package/dist/mixins/test-navigation.mixin.js.map +1 -1
  41. package/dist/mixins/test-processing.mixin.js +3 -3
  42. package/dist/mixins/test-processing.mixin.js.map +1 -1
  43. package/dist/mixins/test-state.mixin.d.ts +2 -7
  44. package/dist/mixins/test-state.mixin.js +6 -6
  45. package/dist/mixins/test-state.mixin.js.map +1 -1
  46. package/dist/mixins/test-view.mixin.js +2 -2
  47. package/dist/mixins/test-view.mixin.js.map +1 -1
  48. package/dist/plugin-api.d.ts +10 -0
  49. package/dist/plugin-api.js +9 -0
  50. package/dist/plugin-api.js.map +1 -0
  51. package/dist/plugin-state.d.ts +1 -1
  52. package/dist/plugin-state.js +1 -1
  53. package/dist/plugin-state.js.map +1 -1
  54. package/dist/plugins/elements.d.ts +5 -72
  55. package/dist/plugins/elements.js +6 -33
  56. package/dist/plugins/elements.js.map +1 -1
  57. package/dist/plugins/index.d.ts +1 -1
  58. package/dist/plugins/index.js +1 -1
  59. package/dist/plugins/index.js.map +1 -1
  60. package/dist/public-events.d.ts +22 -20
  61. package/dist/public-events.js +16 -20
  62. package/dist/public-events.js.map +1 -1
  63. package/dist/types/qti-test-state.d.ts +1 -1
  64. package/dist/types/qti-test-state.js.map +1 -1
  65. package/package.json +10 -6
  66. package/dist/components/test-bookmark/test-bookmark.d.ts +0 -48
  67. package/dist/components/test-bookmark/test-bookmark.js +0 -132
  68. package/dist/components/test-bookmark/test-bookmark.js.map +0 -1
  69. package/dist/components/test-check-item/test-check-item.d.ts +0 -20
  70. package/dist/components/test-check-item/test-check-item.js +0 -35
  71. package/dist/components/test-check-item/test-check-item.js.map +0 -1
  72. package/dist/components/test-item-link/test-item-link.d.ts +0 -13
  73. package/dist/components/test-item-link/test-item-link.js +0 -28
  74. package/dist/components/test-item-link/test-item-link.js.map +0 -1
  75. package/dist/components/test-print-context/test-print-context.d.ts +0 -11
  76. package/dist/components/test-print-context/test-print-context.js +0 -20
  77. package/dist/components/test-print-context/test-print-context.js.map +0 -1
  78. package/dist/components/test-print-item-variables/test-print-item-variables.d.ts +0 -17
  79. package/dist/components/test-print-item-variables/test-print-item-variables.js +0 -95
  80. package/dist/components/test-print-item-variables/test-print-item-variables.js.map +0 -1
  81. package/dist/components/test-print-state/test-print-state.d.ts +0 -27
  82. package/dist/components/test-print-state/test-print-state.js +0 -87
  83. package/dist/components/test-print-state/test-print-state.js.map +0 -1
  84. package/dist/components/test-scoring-buttons/test-scoring-buttons.d.ts +0 -19
  85. package/dist/components/test-scoring-buttons/test-scoring-buttons.js +0 -95
  86. package/dist/components/test-scoring-buttons/test-scoring-buttons.js.map +0 -1
  87. package/dist/components/test-scoring-feedback/test-scoring-feedback.d.ts +0 -13
  88. package/dist/components/test-scoring-feedback/test-scoring-feedback.js +0 -54
  89. package/dist/components/test-scoring-feedback/test-scoring-feedback.js.map +0 -1
  90. package/dist/components/test-section-link/test-section-link.d.ts +0 -13
  91. package/dist/components/test-section-link/test-section-link.js +0 -28
  92. package/dist/components/test-section-link/test-section-link.js.map +0 -1
  93. package/dist/components/test-stamp/test-stamp.d.ts +0 -29
  94. package/dist/components/test-stamp/test-stamp.js +0 -105
  95. package/dist/components/test-stamp/test-stamp.js.map +0 -1
  96. package/dist/components/test-view-toggle/test-view-toggle.d.ts +0 -16
  97. package/dist/components/test-view-toggle/test-view-toggle.js +0 -49
  98. package/dist/components/test-view-toggle/test-view-toggle.js.map +0 -1
  99. package/dist/components/test-view-toggle/test-view.d.ts +0 -20
  100. package/dist/components/test-view-toggle/test-view.js +0 -73
  101. package/dist/components/test-view-toggle/test-view.js.map +0 -1
  102. package/dist/tts/elements.d.ts +0 -28
  103. package/dist/tts/elements.js +0 -14
  104. package/dist/tts/elements.js.map +0 -1
  105. package/dist/tts/test-item-to-speech.d.ts +0 -252
  106. package/dist/tts/test-item-to-speech.js +0 -1053
  107. package/dist/tts/test-item-to-speech.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"test-state.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-state.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgChE,MAAM,IAAI,GAAG,CAAC,KAAkC,EAAS,EAAE,CACzD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,KAAmC,IAAI,IAAI,CAAC,CAAC;AAErF,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE;IAC/D,MAAM,KAAK,GAAG,KAA4B,CAAC;IAC3C,OAAO,CACL,KAAK,EAAE,OAAO,KAAK,sBAAsB;QACzC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC;QACnC,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,KAAK,CAAC,OAAO,KAAK,IAAI,CACvB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,IAA2B,EAAE,OAAiC,EAAgB,EAAE,CAAC,CAAC;IACjG,OAAO,EAAE,sBAAsB;IAC/B,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;aACvB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;aAC/B,GAAG,CAAC,IA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CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvF,GAAG,CAAC,MAAM,CAAC,wBAAwB,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzG,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC;oBACzE,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE;oBACxC,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;QACJ,CAAC;QAED,kBAAkB,CAAC,IAAwB,EAAE,EAAU;YACrD,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3D,CAAC;KACF;IAED,OAAO,cAAkD,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';\nimport { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { PropertyValues } from 'lit';\nimport type { SessionContext, TestContext } from '@qti-components/base';\nimport type { QtiTestState, QtiTestStateSession } from '../types/qti-test-state';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\ntype Value = string | string[] | null;\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'qti-state-changed': CustomEvent<QtiTestState>;\n }\n}\n\nexport interface ITestStateMixin {\n /**\n * The candidate's persistable state: what they answered and where they are.\n *\n * Assign a stored state to resume. It may be assigned at any time: before the test document\n * has loaded it is held and applied as soon as the test connects — before the first item\n * loads, so items and the initial navigation start from it — and after that it is applied\n * immediately and the test navigates to the restored position.\n *\n * Items are matched by item-ref identifier; items the state does not mention start fresh, and\n * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a\n * resume, so linear-mode navigation restrictions do not apply.\n */\n state: QtiTestState;\n}\n\nconst copy = (value: Readonly<Value> | undefined): Value =>\n Array.isArray(value) ? [...value] : ((value as string | null | undefined) ?? null);\n\nconst isQtiTestState = (value: unknown): value is QtiTestState => {\n const state = value as QtiTestState | null;\n return (\n state?.version === QTI_TEST_STATE_VERSION &&\n Array.isArray(state.test?.items) &&\n Array.isArray(state.test?.outcomes) &&\n typeof state.session === 'object' &&\n state.session !== null\n );\n};\n\nconst toState = (test: Readonly<TestContext>, session: Readonly<SessionContext>): QtiTestState => ({\n version: QTI_TEST_STATE_VERSION,\n test: {\n items: (test?.items ?? [])\n .filter(item => item.identifier)\n .map(item => ({\n identifier: item.identifier,\n variables: (item.variables ?? []).map(v => ({\n identifier: v.identifier,\n ...(v.type ? { type: v.type } : {}),\n value: copy(v.value)\n })),\n ...(item.state ? { state: { ...item.state } } : {})\n })),\n outcomes: (test?.testOutcomeVariables ?? []).map(v => ({ identifier: v.identifier, value: copy(v.value) }))\n },\n session: {\n ...(session?.plugins && Object.keys(session.plugins).length > 0 ? { plugins: { ...session.plugins } } : {}),\n ...(session?.navPartId !== undefined ? { navPartId: session.navPartId } : {}),\n ...(session?.navSectionId !== undefined ? { navSectionId: session.navSectionId } : {}),\n ...(session?.navItemRefId !== undefined ? { navItemRefId: session.navItemRefId } : {})\n }\n});\n\n/**\n * Persist and resume a test session through one value, `state`, and one event,\n * `qti-state-changed`.\n *\n * Sits directly on top of `TestBaseMixin`, so its `qti-assessment-test-connected` listener runs\n * after the base has built `testContext.items` from the item-refs, and before the navigation\n * mixin's listener picks the first item to load.\n */\nexport const TestStateMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestStateClass extends superClass implements ITestStateMixin {\n /** A state assigned before the test connected, applied when it does. */\n #pending: QtiTestState | null = null;\n\n /**\n * False while a test document is loading. Loading resets both contexts and rebuilds them, so\n * the intermediate states are empty — emitting one would invite a host to save it over the\n * real one.\n */\n #ready = false;\n\n #lastEmitted: string | null = null;\n\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-testdoc-loaded', () => {\n this.#ready = false;\n this.#lastEmitted = null;\n });\n listenPublic(this, 'cito-test-update-plugin-state', ({ detail }) => this.#updatePluginState(detail));\n listenPublic(this, 'cito-test-loaded', () => {\n if (this.#pending) {\n this.#apply(this.#pending);\n this.#pending = null;\n }\n this.#ready = true;\n });\n }\n\n /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */\n #updatePluginState({ plugin, value }: { plugin: string; value: unknown }): void {\n if (typeof plugin !== 'string' || plugin === '') return;\n const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};\n let next: Record<string, unknown> = others;\n if (value !== null && value !== undefined) {\n try {\n next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };\n } catch {\n console.warn(`[qti-test] Ignoring plugin state for \"${plugin}\": it is not JSON.`);\n return;\n }\n }\n this.sessionContext = { ...this.sessionContext, plugins: next };\n }\n\n get state(): QtiTestState {\n return toState(this.testContext, this.sessionContext);\n }\n\n set state(value: QtiTestState) {\n if (!isQtiTestState(value)) {\n console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);\n return;\n }\n if (!this.#ready) {\n this.#pending = value;\n return;\n }\n\n const { navItemRefId, navSectionId } = this.sessionContext;\n this.#apply(value);\n\n const restored = this.sessionContext;\n if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {\n this.#requestNavigation('item', restored.navItemRefId);\n } else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {\n this.#requestNavigation('section', restored.navSectionId);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (!this.#ready || !(changed.has('testContext') || changed.has('sessionContext'))) return;\n\n const state = this.state;\n const serialized = JSON.stringify(state);\n if (serialized === this.#lastEmitted) return;\n this.#lastEmitted = serialized;\n dispatchPublic(this, 'cito-test-state-changed', state);\n }\n\n #apply(state: QtiTestState): void {\n // Before the items load this only fills the test context; items already on screen are\n // updated too.\n for (const saved of state.test.items) this.updateItemVariables(saved.identifier, saved.variables, saved.state);\n\n const savedOutcomes = new Map(state.test.outcomes.map(outcome => [outcome.identifier, outcome.value]));\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v =>\n savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v\n )\n };\n\n // Written before any navigation request, so the linear-mode restriction — which compares\n // against the current position — sees the restored item as current and lets it load.\n // Plugins are replaced, not merged: a state without them clears what an earlier one left.\n this.sessionContext = {\n ...this.sessionContext,\n ...this.#validSession(state.session),\n plugins: state.session.plugins && typeof state.session.plugins === 'object' ? { ...state.session.plugins } : {}\n };\n }\n\n /** A stored position may point at an item or section a revised test no longer has. */\n #validSession(session: QtiTestStateSession): QtiTestStateSession {\n const exists = (selector: string, id: string | null | undefined) =>\n !!id && !!this._testElement?.querySelector(`${selector}[identifier=\"${CSS.escape(id)}\"]`);\n return {\n ...(exists('qti-test-part', session.navPartId) ? { navPartId: session.navPartId } : {}),\n ...(exists('qti-assessment-section', session.navSectionId) ? { navSectionId: session.navSectionId } : {}),\n ...(this.testContext.items.some(i => i.identifier === session.navItemRefId)\n ? { navItemRefId: session.navItemRefId }\n : {})\n };\n }\n\n #requestNavigation(type: 'item' | 'section', id: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type, id });\n }\n }\n\n return TestStateClass as Constructor<ITestStateMixin> & T;\n};\n"]}
1
+ {"version":3,"file":"test-state.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-state.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0BhE,MAAM,IAAI,GAAG,CAAC,KAAkC,EAAS,EAA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BACxC,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;QACJ,CAAC;QAED,kBAAkB,CAAC,IAAwB,EAAE,EAAU;YACrD,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACzD,CAAC;KACF;IAED,OAAO,cAAkD,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';\nimport { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { PropertyValues } from 'lit';\nimport type { SessionContext, TestContext } from '@qti-components/base';\nimport type { QtiTestState, QtiTestStateSession } from '../types/qti-test-state';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\ntype Value = string | string[] | null;\n\nexport interface ITestStateMixin {\n /**\n * The candidate's persistable state: what they answered and where they are.\n *\n * Assign a stored state to resume. It may be assigned at any time: before the test document\n * has loaded it is held and applied as soon as the test connects — before the first item\n * loads, so items and the initial navigation start from it — and after that it is applied\n * immediately and the test navigates to the restored position.\n *\n * Items are matched by item-ref identifier; items the state does not mention start fresh, and\n * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a\n * resume, so linear-mode navigation restrictions do not apply.\n */\n state: QtiTestState;\n}\n\nconst copy = (value: Readonly<Value> | undefined): Value =>\n Array.isArray(value) ? [...value] : ((value as string | null | undefined) ?? null);\n\nconst isQtiTestState = (value: unknown): value is QtiTestState => {\n const state = value as QtiTestState | null;\n return (\n state?.version === QTI_TEST_STATE_VERSION &&\n Array.isArray(state.test?.items) &&\n Array.isArray(state.test?.outcomes) &&\n typeof state.session === 'object' &&\n state.session !== null\n );\n};\n\nconst toState = (test: Readonly<TestContext>, session: Readonly<SessionContext>): QtiTestState => ({\n version: QTI_TEST_STATE_VERSION,\n test: {\n items: (test?.items ?? [])\n .filter(item => item.identifier)\n .map(item => ({\n identifier: item.identifier,\n variables: (item.variables ?? []).map(v => ({\n identifier: v.identifier,\n ...(v.type ? { type: v.type } : {}),\n value: copy(v.value)\n })),\n ...(item.state ? { state: { ...item.state } } : {})\n })),\n outcomes: (test?.testOutcomeVariables ?? []).map(v => ({ identifier: v.identifier, value: copy(v.value) }))\n },\n session: {\n ...(session?.plugins && Object.keys(session.plugins).length > 0 ? { plugins: { ...session.plugins } } : {}),\n ...(session?.navPartId !== undefined ? { navPartId: session.navPartId } : {}),\n ...(session?.navSectionId !== undefined ? { navSectionId: session.navSectionId } : {}),\n ...(session?.navItemRefId !== undefined ? { navItemRefId: session.navItemRefId } : {})\n }\n});\n\n/**\n * Persist and resume a test session through one value, `state`, and one event,\n * `qc-test-state-changed`.\n *\n * Sits directly on top of `TestBaseMixin`, so its `qc-test-loaded` listener runs\n * after the base has built `testContext.items` from the item-refs, and before the navigation\n * mixin's listener picks the first item to load.\n */\nexport const TestStateMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestStateClass extends superClass implements ITestStateMixin {\n /** A state assigned before the test connected, applied when it does. */\n #pending: QtiTestState | null = null;\n\n /**\n * False while a test document is loading. Loading resets both contexts and rebuilds them, so\n * the intermediate states are empty — emitting one would invite a host to save it over the\n * real one.\n */\n #ready = false;\n\n #lastEmitted: string | null = null;\n\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-testdoc-loaded', () => {\n this.#ready = false;\n this.#lastEmitted = null;\n });\n listenPublic(this, 'qc-test-update-plugin-state', ({ detail }) => this.#updatePluginState(detail));\n listenPublic(this, 'qc-test-loaded', () => {\n if (this.#pending) {\n this.#apply(this.#pending);\n this.#pending = null;\n }\n this.#ready = true;\n });\n }\n\n /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */\n #updatePluginState({ plugin, value }: { plugin: string; value: unknown }): void {\n if (typeof plugin !== 'string' || plugin === '') return;\n const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};\n let next: Record<string, unknown> = others;\n if (value !== null && value !== undefined) {\n try {\n next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };\n } catch {\n console.warn(`[qti-test] Ignoring plugin state for \"${plugin}\": it is not JSON.`);\n return;\n }\n }\n this.sessionContext = { ...this.sessionContext, plugins: next };\n }\n\n get state(): QtiTestState {\n return toState(this.testContext, this.sessionContext);\n }\n\n set state(value: QtiTestState) {\n if (!isQtiTestState(value)) {\n console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);\n return;\n }\n if (!this.#ready) {\n this.#pending = value;\n return;\n }\n\n const { navItemRefId, navSectionId } = this.sessionContext;\n this.#apply(value);\n\n const restored = this.sessionContext;\n if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {\n this.#requestNavigation('item', restored.navItemRefId);\n } else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {\n this.#requestNavigation('section', restored.navSectionId);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (!this.#ready || !(changed.has('testContext') || changed.has('sessionContext'))) return;\n\n const state = this.state;\n const serialized = JSON.stringify(state);\n if (serialized === this.#lastEmitted) return;\n this.#lastEmitted = serialized;\n dispatchPublic(this, 'qc-test-state-changed', state);\n }\n\n #apply(state: QtiTestState): void {\n // Before the items load this only fills the test context; items already on screen are\n // updated too.\n for (const saved of state.test.items) this.updateItemVariables(saved.identifier, saved.variables, saved.state);\n\n const savedOutcomes = new Map(state.test.outcomes.map(outcome => [outcome.identifier, outcome.value]));\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v =>\n savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v\n )\n };\n\n // Written before any navigation request, so the linear-mode restriction — which compares\n // against the current position — sees the restored item as current and lets it load.\n // Plugins are replaced, not merged: a state without them clears what an earlier one left.\n this.sessionContext = {\n ...this.sessionContext,\n ...this.#validSession(state.session),\n plugins: state.session.plugins && typeof state.session.plugins === 'object' ? { ...state.session.plugins } : {}\n };\n }\n\n /** A stored position may point at an item or section a revised test no longer has. */\n #validSession(session: QtiTestStateSession): QtiTestStateSession {\n const exists = (selector: string, id: string | null | undefined) =>\n !!id && !!this._testElement?.querySelector(`${selector}[identifier=\"${CSS.escape(id)}\"]`);\n return {\n ...(exists('qti-test-part', session.navPartId) ? { navPartId: session.navPartId } : {}),\n ...(exists('qti-assessment-section', session.navSectionId) ? { navSectionId: session.navSectionId } : {}),\n ...(this.testContext.items.some(i => i.identifier === session.navItemRefId)\n ? { navItemRefId: session.navItemRefId }\n : {})\n };\n }\n\n #requestNavigation(type: 'item' | 'section', id: string): void {\n dispatchPublic(this, 'qc-test-navigate', { type, id });\n }\n }\n\n return TestStateClass as Constructor<ITestStateMixin> & T;\n};\n"]}
@@ -4,11 +4,11 @@ export const TestViewMixin = (superClass) => {
4
4
  constructor(...args) {
5
5
  super(...args);
6
6
  this.sessionContext = { ...this.sessionContext, view: 'candidate' };
7
- listenPublic(this, 'cito-test-switch-view', e => {
7
+ listenPublic(this, 'qc-test-switch-view', e => {
8
8
  this.sessionContext = { ...this.sessionContext, view: e.detail };
9
9
  this._updateElementView();
10
10
  });
11
- listenPublic(this, 'cito-test-loaded', () => {
11
+ listenPublic(this, 'qc-test-loaded', () => {
12
12
  this._updateElementView();
13
13
  });
14
14
  this.addEventListener('qti-assessment-item-connected', (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"test-view.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-view.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAahD,MAAM,CAAC,MAAM,aAAa,GAAG,CAA2C,UAAa,EAAE,EAAE;IACvF,MAAe,aAAc,SAAQ,UAAU;QAC7C,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,C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AY,CAAC,aAAa,CACvD,uCAAuC,IAAI,CAAC,cAAc,CAAC,YAAY,IAAI,CAC5E,CAAC;gBACF,MAAM,cAAc,GAAG,iBAAiB,EAAE,cAAc,CAAC;gBAEzD,IAAI,cAAc;oBAAE,IAAI,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC9F,CAAC;QACH,CAAC;QAED,mDAAmD;QAC3C,6BAA6B,CAAC,cAAiC;YACrE,IAAI,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1E,CAAC;QAED,oFAAoF;QAC7E,wBAAwB,CAAC,eAAkC,EAAE,KAAW,IAAS,CAAC;KAC1F;IAED,OAAO,aAAmD,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["import { listenPublic } from '../public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestViewInterface {\n updateAssessmentItemView(assessmentItem: QtiAssessmentItem, view: View): void;\n}\n\nexport const TestViewMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestViewClass extends superClass implements TestViewInterface {\n constructor(...args: any[]) {\n super(...args);\n this.sessionContext = { ...this.sessionContext, view: 'candidate' };\n\n listenPublic(this, 'cito-test-switch-view', e => {\n this.sessionContext = { ...this.sessionContext, view: e.detail };\n this._updateElementView();\n });\n listenPublic(this, 'cito-test-loaded', () => {\n this._updateElementView();\n });\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent) => {\n this._updateElementView();\n this._setCorrectResponseVisibility(e.detail);\n });\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate(changedProperties);\n if (changedProperties.has('sessionContext')) {\n this._updateElementView();\n }\n }\n\n // Method to handle view updates for elements based on the current context view\n private _updateElementView() {\n if (this._testElement) {\n const viewElements = Array.from(this._testElement.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', element.getAttribute('view') === this.sessionContext.view);\n });\n\n const assessmentItemRef = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this.sessionContext.navItemRefId}\"]`\n );\n const assessmentItem = assessmentItemRef?.assessmentItem;\n\n if (assessmentItem) this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n }\n\n // Event handler for connected QTI assessment items\n private _setCorrectResponseVisibility(assessmentItem: QtiAssessmentItem): void {\n this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n\n /** Extension point for packages that add view-dependent assessment presentation. */\n public updateAssessmentItemView(_assessmentItem: QtiAssessmentItem, _view: View): void {}\n }\n\n return TestViewClass as Constructor<TestViewInterface> & T;\n};\n"]}
1
+ {"version":3,"file":"test-view.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-view.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAahD,MAAM,CAAC,MAAM,aAAa,GAAG,CAA2C,UAAa,EAAE,EAAE;IACvF,MAAe,aAAc,SAAQ,UAAU;QAC7C,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YAEpE,YAAY,CAAC,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAC,EAAE;gBAC5C,IAAI,CAAC,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;gBACjE,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,C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AC,CAAC;YAC9F,CAAC;QACH,CAAC;QAED,mDAAmD;QAC3C,6BAA6B,CAAC,cAAiC;YACrE,IAAI,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1E,CAAC;QAED,oFAAoF;QAC7E,wBAAwB,CAAC,eAAkC,EAAE,KAAW,IAAS,CAAC;KAC1F;IAED,OAAO,aAAmD,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["import { listenPublic } from '../public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestViewInterface {\n updateAssessmentItemView(assessmentItem: QtiAssessmentItem, view: View): void;\n}\n\nexport const TestViewMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestViewClass extends superClass implements TestViewInterface {\n constructor(...args: any[]) {\n super(...args);\n this.sessionContext = { ...this.sessionContext, view: 'candidate' };\n\n listenPublic(this, 'qc-test-switch-view', e => {\n this.sessionContext = { ...this.sessionContext, view: e.detail };\n this._updateElementView();\n });\n listenPublic(this, 'qc-test-loaded', () => {\n this._updateElementView();\n });\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent) => {\n this._updateElementView();\n this._setCorrectResponseVisibility(e.detail);\n });\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate(changedProperties);\n if (changedProperties.has('sessionContext')) {\n this._updateElementView();\n }\n }\n\n // Method to handle view updates for elements based on the current context view\n private _updateElementView() {\n if (this._testElement) {\n const viewElements = Array.from(this._testElement.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', element.getAttribute('view') === this.sessionContext.view);\n });\n\n const assessmentItemRef = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this.sessionContext.navItemRefId}\"]`\n );\n const assessmentItem = assessmentItemRef?.assessmentItem;\n\n if (assessmentItem) this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n }\n\n // Event handler for connected QTI assessment items\n private _setCorrectResponseVisibility(assessmentItem: QtiAssessmentItem): void {\n this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n\n /** Extension point for packages that add view-dependent assessment presentation. */\n public updateAssessmentItemView(_assessmentItem: QtiAssessmentItem, _view: View): void {}\n }\n\n return TestViewClass as Constructor<TestViewInterface> & T;\n};\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * What a plugin in another package builds on, with no registration side effect: the public events
3
+ * and their helpers, the typed read of plugin state, the state types, and the look of the test
4
+ * controls. `@qti-components/extended` is the consumer; a plugin of your own may use it too.
5
+ */
6
+ export { dispatchPublic, listenPublic, PUBLIC_EVENTS } from './public-events.js';
7
+ export type { NavigationFailure, NavigationTarget, PublicEventMap, PublicEventName } from './public-events.js';
8
+ export { pluginState } from './plugin-state.js';
9
+ export type { QtiTestPluginState, QtiTestState } from './types/qti-test-state.js';
10
+ export * as controlStyles from './components/styles.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * What a plugin in another package builds on, with no registration side effect: the public events
3
+ * and their helpers, the typed read of plugin state, the state types, and the look of the test
4
+ * controls. `@qti-components/extended` is the consumer; a plugin of your own may use it too.
5
+ */
6
+ export { dispatchPublic, listenPublic, PUBLIC_EVENTS } from './public-events.js';
7
+ export { pluginState } from './plugin-state.js';
8
+ export * as controlStyles from './components/styles.js';
9
+ //# sourceMappingURL=plugin-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-api.js","sourceRoot":"","sources":["../src/plugin-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC","sourcesContent":["/**\n * What a plugin in another package builds on, with no registration side effect: the public events\n * and their helpers, the typed read of plugin state, the state types, and the look of the test\n * controls. `@qti-components/extended` is the consumer; a plugin of your own may use it too.\n */\nexport { dispatchPublic, listenPublic, PUBLIC_EVENTS } from './public-events.js';\nexport type { NavigationFailure, NavigationTarget, PublicEventMap, PublicEventName } from './public-events.js';\nexport { pluginState } from './plugin-state.js';\nexport type { QtiTestPluginState, QtiTestState } from './types/qti-test-state.js';\nexport * as controlStyles from './components/styles.js';\n"]}
@@ -3,6 +3,6 @@ import type { QtiTestPluginState } from './types/qti-test-state';
3
3
  /**
4
4
  * A plugin's entry in the state, typed through `QtiTestPluginState`, or `undefined` before the
5
5
  * plugin has stored anything. Read it from `computedContext`; write it by dispatching
6
- * `cito-test-update-plugin-state` (`dispatchPublic`).
6
+ * `qc-test-update-plugin-state` (`dispatchPublic`).
7
7
  */
8
8
  export declare const pluginState: <K extends keyof QtiTestPluginState & string>(context: Pick<ComputedContext, "plugins"> | undefined, plugin: K) => QtiTestPluginState[K] | undefined;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A plugin's entry in the state, typed through `QtiTestPluginState`, or `undefined` before the
3
3
  * plugin has stored anything. Read it from `computedContext`; write it by dispatching
4
- * `cito-test-update-plugin-state` (`dispatchPublic`).
4
+ * `qc-test-update-plugin-state` (`dispatchPublic`).
5
5
  */
6
6
  export const pluginState = (context, plugin) => context?.plugins?.[plugin];
7
7
  //# sourceMappingURL=plugin-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-state.js","sourceRoot":"","sources":["../src/plugin-state.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAqD,EACrD,MAAS,EAC0B,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,MAAM,CAAsC,CAAC","sourcesContent":["import type { ComputedContext } from '@qti-components/base';\nimport type { QtiTestPluginState } from './types/qti-test-state';\n\n/**\n * A plugin's entry in the state, typed through `QtiTestPluginState`, or `undefined` before the\n * plugin has stored anything. Read it from `computedContext`; write it by dispatching\n * `cito-test-update-plugin-state` (`dispatchPublic`).\n */\nexport const pluginState = <K extends keyof QtiTestPluginState & string>(\n context: Pick<ComputedContext, 'plugins'> | undefined,\n plugin: K\n): QtiTestPluginState[K] | undefined => context?.plugins?.[plugin] as QtiTestPluginState[K] | undefined;\n"]}
1
+ {"version":3,"file":"plugin-state.js","sourceRoot":"","sources":["../src/plugin-state.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAqD,EACrD,MAAS,EAC0B,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,MAAM,CAAsC,CAAC","sourcesContent":["import type { ComputedContext } from '@qti-components/base';\nimport type { QtiTestPluginState } from './types/qti-test-state';\n\n/**\n * A plugin's entry in the state, typed through `QtiTestPluginState`, or `undefined` before the\n * plugin has stored anything. Read it from `computedContext`; write it by dispatching\n * `qc-test-update-plugin-state` (`dispatchPublic`).\n */\nexport const pluginState = <K extends keyof QtiTestPluginState & string>(\n context: Pick<ComputedContext, 'plugins'> | undefined,\n plugin: K\n): QtiTestPluginState[K] | undefined => context?.plugins?.[plugin] as QtiTestPluginState[K] | undefined;\n"]}
@@ -1,79 +1,12 @@
1
- import { TestBookmark } from '../components/test-bookmark/test-bookmark';
2
- import { TestCheckItem } from '../components/test-check-item/test-check-item';
3
- import { TestPrintContext } from '../components/test-print-context/test-print-context';
4
- import { TestPrintVariables } from '../components/test-print-item-variables/test-print-item-variables';
5
- import { TestPrintState } from '../components/test-print-state/test-print-state';
6
- import { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';
7
- import { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';
8
- import { TestStamp } from '../components/test-stamp/test-stamp';
9
1
  import { TestSubmit } from '../components/test-submit/test-submit';
10
- import { TestView } from '../components/test-view-toggle/test-view';
11
- import { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';
12
- export * from '../tts/elements';
13
- export { bookmarkedItems } from '../components/test-bookmark/test-bookmark';
14
- export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestPrintState, TestScoringButtons, TestScoringFeedback, TestStamp, TestSubmit, TestView, TestViewToggle };
2
+ export { TestSubmit };
15
3
  /**
16
- * Every test plugin's elements in one list. `qti-test` registers them with the rest of its
17
- * elements, and a scoped registry can use the list directly. Defines nothing.
18
- *
19
- * A plugin is the set of files listed for it in `plugin-boundary.spec.ts` (`PLUGINS`); this file is
20
- * the one place that names them all.
4
+ * The plugins' `{ tag, ctor }` pairs, so a scoped registry (an item-ref template is stamped into
5
+ * `test-container`'s shadow root) can define them with the rest. `elements.ts` spreads these into
6
+ * `qtiTestElements`; this is the one place that composes the plugins. The other plugins are in
7
+ * `@qti-components/extended`.
21
8
  */
22
9
  export declare const pluginElements: readonly [{
23
- readonly tag: "test-check-item";
24
- readonly ctor: typeof TestCheckItem;
25
- }, {
26
- readonly tag: "test-bookmark";
27
- readonly ctor: typeof TestBookmark;
28
- }, {
29
- readonly tag: "test-print-context";
30
- readonly ctor: typeof TestPrintContext;
31
- }, {
32
- readonly tag: "test-print-item-variables";
33
- readonly ctor: typeof TestPrintVariables;
34
- }, {
35
- readonly tag: "test-print-state";
36
- readonly ctor: typeof TestPrintState;
37
- }, {
38
- readonly tag: "test-scoring-buttons";
39
- readonly ctor: typeof TestScoringButtons;
40
- }, {
41
- readonly tag: "test-scoring-feedback";
42
- readonly ctor: typeof TestScoringFeedback;
43
- }, {
44
- readonly tag: "test-stamp";
45
- readonly ctor: typeof TestStamp;
46
- }, {
47
10
  readonly tag: "test-submit";
48
11
  readonly ctor: typeof TestSubmit;
49
- }, {
50
- readonly tag: "test-view";
51
- readonly ctor: typeof TestView;
52
- }, {
53
- readonly tag: "test-view-toggle";
54
- readonly ctor: typeof TestViewToggle;
55
- }, {
56
- readonly tag: "test-item-to-speech";
57
- readonly ctor: typeof import("./elements").TestItemToSpeech;
58
- }, {
59
- readonly tag: "test-tts-next";
60
- readonly ctor: typeof import("./elements").TestTtsNext;
61
- }, {
62
- readonly tag: "test-tts-pause";
63
- readonly ctor: typeof import("./elements").TestTtsPause;
64
- }, {
65
- readonly tag: "test-tts-pick";
66
- readonly ctor: typeof import("./elements").TestTtsPick;
67
- }, {
68
- readonly tag: "test-tts-play";
69
- readonly ctor: typeof import("./elements").TestTtsPlay;
70
- }, {
71
- readonly tag: "test-tts-prev";
72
- readonly ctor: typeof import("./elements").TestTtsPrev;
73
- }, {
74
- readonly tag: "test-tts-resume";
75
- readonly ctor: typeof import("./elements").TestTtsResume;
76
- }, {
77
- readonly tag: "test-tts-stop";
78
- readonly ctor: typeof import("./elements").TestTtsStop;
79
12
  }];
@@ -1,37 +1,10 @@
1
- import { TestBookmark } from '../components/test-bookmark/test-bookmark';
2
- import { TestCheckItem } from '../components/test-check-item/test-check-item';
3
- import { TestPrintContext } from '../components/test-print-context/test-print-context';
4
- import { TestPrintVariables } from '../components/test-print-item-variables/test-print-item-variables';
5
- import { TestPrintState } from '../components/test-print-state/test-print-state';
6
- import { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';
7
- import { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';
8
- import { TestStamp } from '../components/test-stamp/test-stamp';
9
1
  import { TestSubmit } from '../components/test-submit/test-submit';
10
- import { TestView } from '../components/test-view-toggle/test-view';
11
- import { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';
12
- import { ttsElements } from '../tts/elements';
13
- export * from '../tts/elements';
14
- export { bookmarkedItems } from '../components/test-bookmark/test-bookmark';
15
- export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestPrintState, TestScoringButtons, TestScoringFeedback, TestStamp, TestSubmit, TestView, TestViewToggle };
2
+ export { TestSubmit };
16
3
  /**
17
- * Every test plugin's elements in one list. `qti-test` registers them with the rest of its
18
- * elements, and a scoped registry can use the list directly. Defines nothing.
19
- *
20
- * A plugin is the set of files listed for it in `plugin-boundary.spec.ts` (`PLUGINS`); this file is
21
- * the one place that names them all.
4
+ * The plugins' `{ tag, ctor }` pairs, so a scoped registry (an item-ref template is stamped into
5
+ * `test-container`'s shadow root) can define them with the rest. `elements.ts` spreads these into
6
+ * `qtiTestElements`; this is the one place that composes the plugins. The other plugins are in
7
+ * `@qti-components/extended`.
22
8
  */
23
- export const pluginElements = [
24
- { tag: 'test-check-item', ctor: TestCheckItem },
25
- { tag: 'test-bookmark', ctor: TestBookmark },
26
- { tag: 'test-print-context', ctor: TestPrintContext },
27
- { tag: 'test-print-item-variables', ctor: TestPrintVariables },
28
- { tag: 'test-print-state', ctor: TestPrintState },
29
- { tag: 'test-scoring-buttons', ctor: TestScoringButtons },
30
- { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },
31
- { tag: 'test-stamp', ctor: TestStamp },
32
- { tag: 'test-submit', ctor: TestSubmit },
33
- { tag: 'test-view', ctor: TestView },
34
- { tag: 'test-view-toggle', ctor: TestViewToggle },
35
- ...ttsElements
36
- ];
9
+ export const pluginElements = [{ tag: 'test-submit', ctor: TestSubmit }];
37
10
  //# sourceMappingURL=elements.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/plugins/elements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mEAAmE,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAC7F,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EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE;IACjD,GAAG,WAAW;CACN,CAAC","sourcesContent":["import { TestBookmark } from '../components/test-bookmark/test-bookmark';\nimport { TestCheckItem } from '../components/test-check-item/test-check-item';\nimport { TestPrintContext } from '../components/test-print-context/test-print-context';\nimport { TestPrintVariables } from '../components/test-print-item-variables/test-print-item-variables';\nimport { TestPrintState } from '../components/test-print-state/test-print-state';\nimport { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';\nimport { TestStamp } from '../components/test-stamp/test-stamp';\nimport { TestSubmit } from '../components/test-submit/test-submit';\nimport { TestView } from '../components/test-view-toggle/test-view';\nimport { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';\nimport { ttsElements } from '../tts/elements';\n\nexport * from '../tts/elements';\n\nexport { bookmarkedItems } from '../components/test-bookmark/test-bookmark';\n\nexport {\n TestCheckItem,\n TestBookmark,\n TestPrintContext,\n TestPrintVariables,\n TestPrintState,\n TestScoringButtons,\n TestScoringFeedback,\n TestStamp,\n TestSubmit,\n TestView,\n TestViewToggle\n};\n\n/**\n * Every test plugin's elements in one list. `qti-test` registers them with the rest of its\n * elements, and a scoped registry can use the list directly. Defines nothing.\n *\n * A plugin is the set of files listed for it in `plugin-boundary.spec.ts` (`PLUGINS`); this file is\n * the one place that names them all.\n */\nexport const pluginElements = [\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-bookmark', ctor: TestBookmark },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-print-state', ctor: TestPrintState },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-submit', ctor: TestSubmit },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle },\n ...ttsElements\n] as const;\n"]}
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/plugins/elements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,CAAU,CAAC","sourcesContent":["import { TestSubmit } from '../components/test-submit/test-submit';\n\nexport { TestSubmit };\n\n/**\n * The plugins' `{ tag, ctor }` pairs, so a scoped registry (an item-ref template is stamped into\n * `test-container`'s shadow root) can define them with the rest. `elements.ts` spreads these into\n * `qtiTestElements`; this is the one place that composes the plugins. The other plugins are in\n * `@qti-components/extended`.\n */\nexport const pluginElements = [{ tag: 'test-submit', ctor: TestSubmit }] as const;\n"]}
@@ -1,2 +1,2 @@
1
- /** The test plugins: print, scoring, stamp, text-to-speech and view. The core composes them here and nowhere else. */
1
+ /** The test plugins: submit. The core composes them here and nowhere else. */
2
2
  export * from './elements.js';
@@ -1,3 +1,3 @@
1
- /** The test plugins: print, scoring, stamp, text-to-speech and view. The core composes them here and nowhere else. */
1
+ /** The test plugins: submit. The core composes them here and nowhere else. */
2
2
  export * from './elements.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,cAAc,eAAe,CAAC","sourcesContent":["/** The test plugins: print, scoring, stamp, text-to-speech and view. The core composes them here and nowhere else. */\nexport * from './elements.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,cAAc,eAAe,CAAC","sourcesContent":["/** The test plugins: submit. The core composes them here and nowhere else. */\nexport * from './elements.js';\n"]}
@@ -3,13 +3,15 @@ import type { PublicEventDeclaration } from '@qti-components/elements/public-eve
3
3
  import type { QtiTestState } from './types/qti-test-state';
4
4
  /**
5
5
  * The public events of the test. The name tells you it is public: everything here starts with
6
- * `cito-`; every other event is internal plumbing and may change in any release.
6
+ * `qc-`; every other event is internal plumbing and may change in any release.
7
7
  *
8
8
  * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense
9
9
  * (the test dispatches them). All bubble and are composed.
10
10
  *
11
- * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,
12
- * `listenPublic`) sends or handles both names until the next major, then the field goes.
11
+ * `deprecated` is the `cito-` name this event had in 9.x. One helper (`dispatchPublic`,
12
+ * `listenPublic`) sends or handles both names until the next major, then the field goes. The 7.x
13
+ * names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no longer sent
14
+ * or handled.
13
15
  */
14
16
  export interface NavigationTarget {
15
17
  type: 'item' | 'section';
@@ -22,42 +24,42 @@ export interface NavigationFailure {
22
24
  sectionId?: string;
23
25
  }
24
26
  export interface PublicEventMap {
25
- 'cito-test-navigate': CustomEvent<NavigationTarget>;
27
+ 'qc-test-navigate': CustomEvent<NavigationTarget>;
26
28
  /**
27
29
  * Ends an attempt: processes the response of the item-ref `itemId`, or, without it, of the item on
28
- * screen. `test-end-attempt` sends the `itemId` of the item it is stamped into or names.
30
+ * screen. `<test-end-attempt>` sends the `itemId` of the item it is stamped into or names.
29
31
  */
30
- 'cito-test-end-attempt': CustomEvent<{
32
+ 'qc-test-end-attempt': CustomEvent<{
31
33
  itemId?: string;
32
34
  }>;
33
- /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `cito-test-submitted`. */
34
- 'cito-test-submit': CustomEvent<Record<string, never>>;
35
- 'cito-test-update-outcome': CustomEvent<{
35
+ /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `qc-test-submitted`. */
36
+ 'qc-test-submit': CustomEvent<Record<string, never>>;
37
+ 'qc-test-update-outcome': CustomEvent<{
36
38
  assessmentItemRefId: string;
37
39
  outcomeVariableId: string;
38
40
  value: number | string;
39
41
  }>;
40
- 'cito-test-switch-view': CustomEvent<View>;
42
+ 'qc-test-switch-view': CustomEvent<View>;
41
43
  /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */
42
- 'cito-test-update-plugin-state': CustomEvent<{
44
+ 'qc-test-update-plugin-state': CustomEvent<{
43
45
  plugin: string;
44
46
  value: unknown;
45
47
  }>;
46
48
  /** Outcome processing ran after a submit: read the test outcomes now. */
47
- 'cito-test-submitted': CustomEvent<Record<string, never>>;
48
- 'cito-test-navigated': CustomEvent<NavigationTarget>;
49
- 'cito-test-navigation-started': CustomEvent<NavigationTarget>;
50
- 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;
51
- 'cito-test-rendered': CustomEvent<{
49
+ 'qc-test-submitted': CustomEvent<Record<string, never>>;
50
+ 'qc-test-navigated': CustomEvent<NavigationTarget>;
51
+ 'qc-test-navigation-started': CustomEvent<NavigationTarget>;
52
+ 'qc-test-navigation-failed': CustomEvent<NavigationFailure>;
53
+ 'qc-test-rendered': CustomEvent<{
52
54
  identifier: string;
53
55
  element: Element;
54
56
  }[]>;
55
- 'cito-test-state-changed': CustomEvent<QtiTestState>;
56
- 'cito-test-items-skipped': CustomEvent<{
57
+ 'qc-test-state-changed': CustomEvent<QtiTestState>;
58
+ 'qc-test-items-skipped': CustomEvent<{
57
59
  ids: string[];
58
60
  }>;
59
- 'cito-test-end-reached': CustomEvent<Record<string, never>>;
60
- 'cito-item-ref-connected': CustomEvent<{
61
+ 'qc-test-end-reached': CustomEvent<Record<string, never>>;
62
+ 'qc-item-ref-connected': CustomEvent<{
61
63
  identifier: string;
62
64
  href: string;
63
65
  category: string;
@@ -1,25 +1,21 @@
1
1
  import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';
2
2
  export const PUBLIC_EVENTS = {
3
- 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },
4
- 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },
5
- 'cito-test-submit': { kind: 'request', scope: 'test' },
6
- 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },
7
- 'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },
8
- 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },
9
- 'cito-test-submitted': { kind: 'notification', scope: 'test' },
10
- 'cito-test-navigated': { kind: 'notification', scope: 'test' },
11
- 'cito-test-navigation-started': {
12
- kind: 'notification',
13
- scope: 'test',
14
- deprecated: 'qti-navigation-loading-started'
15
- },
16
- 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },
17
- 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },
18
- 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },
19
- 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },
20
- 'cito-test-items-skipped': { kind: 'notification', scope: 'test' },
21
- 'cito-test-end-reached': { kind: 'notification', scope: 'test' },
22
- 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }
3
+ 'qc-test-navigate': { kind: 'request', scope: 'test', deprecated: 'cito-test-navigate' },
4
+ 'qc-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'cito-test-end-attempt' },
5
+ 'qc-test-submit': { kind: 'request', scope: 'test', deprecated: 'cito-test-submit' },
6
+ 'qc-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-outcome' },
7
+ 'qc-test-update-plugin-state': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-plugin-state' },
8
+ 'qc-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'cito-test-switch-view' },
9
+ 'qc-test-submitted': { kind: 'notification', scope: 'test', deprecated: 'cito-test-submitted' },
10
+ 'qc-test-navigated': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigated' },
11
+ 'qc-test-navigation-started': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-started' },
12
+ 'qc-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-failed' },
13
+ 'qc-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'cito-test-rendered' },
14
+ 'qc-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'cito-test-loaded' },
15
+ 'qc-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-state-changed' },
16
+ 'qc-test-items-skipped': { kind: 'notification', scope: 'test', deprecated: 'cito-test-items-skipped' },
17
+ 'qc-test-end-reached': { kind: 'notification', scope: 'test', deprecated: 'cito-test-end-reached' },
18
+ 'qc-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'cito-item-ref-connected' }
23
19
  };
24
20
  /**
25
21
  * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is
@@ -1 +1 @@
1
- {"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AA6D1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAAE;IAC9F,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE;IAC3F,kBAAkB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;IACtD,0BAA0B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,8BAA8B,EAAE;IAC1G,+BAA+B,EAAE,EAAE,IAAI,EAAE,SAAS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ACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'cito-test-navigate': CustomEvent<NavigationTarget>;\n /**\n * Ends an attempt: processes the response of the item-ref `itemId`, or, without it, of the item on\n * screen. `test-end-attempt` sends the `itemId` of the item it is stamped into or names.\n */\n 'cito-test-end-attempt': CustomEvent<{ itemId?: string }>;\n /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `cito-test-submitted`. */\n 'cito-test-submit': CustomEvent<Record<string, never>>;\n 'cito-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'cito-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'cito-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n /** Outcome processing ran after a submit: read the test outcomes now. */\n 'cito-test-submitted': CustomEvent<Record<string, never>>;\n 'cito-test-navigated': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-started': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'cito-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `cito-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-test-state-changed': CustomEvent<QtiTestState>;\n 'cito-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'cito-test-end-reached': CustomEvent<Record<string, never>>;\n 'cito-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },\n 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },\n 'cito-test-submit': { kind: 'request', scope: 'test' },\n 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },\n 'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },\n 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },\n 'cito-test-submitted': { kind: 'notification', scope: 'test' },\n 'cito-test-navigated': { kind: 'notification', scope: 'test' },\n 'cito-test-navigation-started': {\n kind: 'notification',\n scope: 'test',\n deprecated: 'qti-navigation-loading-started'\n },\n 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },\n 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },\n 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },\n 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },\n 'cito-test-items-skipped': { kind: 'notification', scope: 'test' },\n 'cito-test-end-reached': { kind: 'notification', scope: 'test' },\n 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
1
+ {"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AA+D1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,kBAAkB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE;IACxF,qBAAqB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,uBAAuB,EAAE;IAC9F,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE;IACpF,wBAAwB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,0BAA0B,EAAE;IACpG,6BAA6B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,+BAA+B,EAAE;IAC9G,qBAAqB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,uBAAuB,EAAE;IAC9F,m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,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `qc-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the `cito-` name this event had in 9.x. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes. The 7.x\n * names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no longer sent\n * or handled.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'qc-test-navigate': CustomEvent<NavigationTarget>;\n /**\n * Ends an attempt: processes the response of the item-ref `itemId`, or, without it, of the item on\n * screen. `<test-end-attempt>` sends the `itemId` of the item it is stamped into or names.\n */\n 'qc-test-end-attempt': CustomEvent<{ itemId?: string }>;\n /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `qc-test-submitted`. */\n 'qc-test-submit': CustomEvent<Record<string, never>>;\n 'qc-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'qc-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'qc-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n /** Outcome processing ran after a submit: read the test outcomes now. */\n 'qc-test-submitted': CustomEvent<Record<string, never>>;\n 'qc-test-navigated': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-started': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'qc-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `qc-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'qc-test-state-changed': CustomEvent<QtiTestState>;\n 'qc-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'qc-test-end-reached': CustomEvent<Record<string, never>>;\n 'qc-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'qc-test-navigate': { kind: 'request', scope: 'test', deprecated: 'cito-test-navigate' },\n 'qc-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'cito-test-end-attempt' },\n 'qc-test-submit': { kind: 'request', scope: 'test', deprecated: 'cito-test-submit' },\n 'qc-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-outcome' },\n 'qc-test-update-plugin-state': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-plugin-state' },\n 'qc-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'cito-test-switch-view' },\n 'qc-test-submitted': { kind: 'notification', scope: 'test', deprecated: 'cito-test-submitted' },\n 'qc-test-navigated': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigated' },\n 'qc-test-navigation-started': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-started' },\n 'qc-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-failed' },\n 'qc-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'cito-test-rendered' },\n 'qc-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'cito-test-loaded' },\n 'qc-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-state-changed' },\n 'qc-test-items-skipped': { kind: 'notification', scope: 'test', deprecated: 'cito-test-items-skipped' },\n 'qc-test-end-reached': { kind: 'notification', scope: 'test', deprecated: 'cito-test-end-reached' },\n 'qc-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'cito-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Everything a host needs to persist to resume a candidate's test session, and nothing else.
3
3
  *
4
- * Read it from `qtiTest.state` or the `qti-state-changed` event, store it wherever you like —
4
+ * Read it from `qtiTest.state` or the `qc-test-state-changed` event, store it wherever you like —
5
5
  * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.
6
6
  *
7
7
  * Deliberately not here:
@@ -1 +1 @@
1
- {"version":3,"file":"qti-test-state.js","sourceRoot":"","sources":["../../src/types/qti-test-state.ts"],"names":[],"mappings":"AA0DA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC","sourcesContent":["/**\n * Everything a host needs to persist to resume a candidate's test session, and nothing else.\n *\n * Read it from `qtiTest.state` or the `qti-state-changed` event, store it wherever you like —\n * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.\n *\n * Deliberately not here:\n * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes\n * from the item XML on every load, and persisting the answer key with the candidate's data is\n * both bloat and a leak;\n * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.\n * The shuffle `seed` in particular must be passed in again, or the restored order changes;\n * - `view`: a role the host decides, not something the candidate produced;\n * - anything computed — scores per section, `done`, `active` — which is rederived from this.\n */\nexport interface QtiTestState {\n /** Bumped on any incompatible change to this shape. A state with another version is ignored. */\n version: 1;\n test: {\n items: QtiTestStateItem[];\n /** Test-level outcome values. Only outcomes the test declares are restored. */\n outcomes: QtiTestStateValue[];\n };\n session: QtiTestStateSession;\n}\n\nexport interface QtiTestStateItem {\n /** The `qti-assessment-item-ref` identifier. */\n identifier: string;\n variables: (QtiTestStateValue & { type?: 'response' | 'outcome' | 'template' | 'context' })[];\n /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */\n state?: Record<string, string | null>;\n}\n\nexport interface QtiTestStateValue {\n identifier: string;\n value: string | string[] | null;\n}\n\n/**\n * What each plugin keeps in the state, by plugin name. Empty here: a plugin adds its own entry by\n * augmenting this interface (`declare module` on the module that declares it, with\n * `interface QtiTestPluginState { bookmarks: string[] }`), and reads it with\n * `pluginState(computedContext, 'bookmarks')`. The test never reads an entry; it\n * stores and restores it, so a value must survive `JSON.stringify`.\n */\n \nexport interface QtiTestPluginState {}\n\n/** Where the candidate is, and what plugins keep. */\nexport interface QtiTestStateSession {\n /** Plugin entries by plugin name. Entries of plugins that are not loaded are kept as they are. */\n plugins?: Partial<QtiTestPluginState> & Record<string, unknown>;\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n}\n\nexport const QTI_TEST_STATE_VERSION = 1;\n"]}
1
+ {"version":3,"file":"qti-test-state.js","sourceRoot":"","sources":["../../src/types/qti-test-state.ts"],"names":[],"mappings":"AA0DA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC","sourcesContent":["/**\n * Everything a host needs to persist to resume a candidate's test session, and nothing else.\n *\n * Read it from `qtiTest.state` or the `qc-test-state-changed` event, store it wherever you like —\n * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.\n *\n * Deliberately not here:\n * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes\n * from the item XML on every load, and persisting the answer key with the candidate's data is\n * both bloat and a leak;\n * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.\n * The shuffle `seed` in particular must be passed in again, or the restored order changes;\n * - `view`: a role the host decides, not something the candidate produced;\n * - anything computed — scores per section, `done`, `active` — which is rederived from this.\n */\nexport interface QtiTestState {\n /** Bumped on any incompatible change to this shape. A state with another version is ignored. */\n version: 1;\n test: {\n items: QtiTestStateItem[];\n /** Test-level outcome values. Only outcomes the test declares are restored. */\n outcomes: QtiTestStateValue[];\n };\n session: QtiTestStateSession;\n}\n\nexport interface QtiTestStateItem {\n /** The `qti-assessment-item-ref` identifier. */\n identifier: string;\n variables: (QtiTestStateValue & { type?: 'response' | 'outcome' | 'template' | 'context' })[];\n /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */\n state?: Record<string, string | null>;\n}\n\nexport interface QtiTestStateValue {\n identifier: string;\n value: string | string[] | null;\n}\n\n/**\n * What each plugin keeps in the state, by plugin name. Empty here: a plugin adds its own entry by\n * augmenting this interface (`declare module` on the module that declares it, with\n * `interface QtiTestPluginState { bookmarks: string[] }`), and reads it with\n * `pluginState(computedContext, 'bookmarks')`. The test never reads an entry; it\n * stores and restores it, so a value must survive `JSON.stringify`.\n */\n\nexport interface QtiTestPluginState {}\n\n/** Where the candidate is, and what plugins keep. */\nexport interface QtiTestStateSession {\n /** Plugin entries by plugin name. Entries of plugins that are not loaded are kept as they are. */\n plugins?: Partial<QtiTestPluginState> & Record<string, unknown>;\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n}\n\nexport const QTI_TEST_STATE_VERSION = 1;\n"]}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@qti-components/test",
3
3
  "description": "QTI test utilities",
4
- "version": "2.0.0-next.13",
4
+ "version": "2.0.0-next.15",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
8
- "@qti-components/base": "^3.0.0-next.5",
9
- "@qti-components/elements": "^2.0.0-next.6",
10
- "@qti-components/interactions": "^1.10.5-next.7",
11
- "@qti-components/processing": "^1.6.1-next.4",
12
- "@qti-components/theme": "^2.3.0-next.5",
8
+ "@qti-components/base": "^3.0.0-next.6",
9
+ "@qti-components/elements": "^2.0.0-next.7",
10
+ "@qti-components/interactions": "^1.10.5-next.8",
11
+ "@qti-components/processing": "^1.6.1-next.5",
12
+ "@qti-components/theme": "^3.0.0-next.6",
13
13
  "@qti-components/transformers": "^1.8.0-next.0",
14
14
  "@qti-components/utilities": "^1.3.3"
15
15
  },
@@ -40,6 +40,10 @@
40
40
  "./plugins/elements": {
41
41
  "types": "./dist/plugins/elements.d.ts",
42
42
  "import": "./dist/plugins/elements.js"
43
+ },
44
+ "./plugin-api": {
45
+ "types": "./dist/plugin-api.d.ts",
46
+ "import": "./dist/plugin-api.js"
43
47
  }
44
48
  },
45
49
  "peerDependencies": {