@citolab/qti-components 10.0.0-next.22 → 10.0.0-next.24

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  QtiTest,
3
3
  TestNavigation
4
- } from "./chunk-373IRT4X.js";
4
+ } from "./chunk-2NHZOI3W.js";
5
5
  import {
6
6
  QtiAssessmentItem
7
7
  } from "./chunk-H6DO5UHC.js";
@@ -1686,4 +1686,4 @@ export {
1686
1686
  TestNavigationCorrection,
1687
1687
  QtiTestCorrection
1688
1688
  };
1689
- //# sourceMappingURL=chunk-L73QXB6G.js.map
1689
+ //# sourceMappingURL=chunk-DU6RX3TX.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  qtiTestElements
3
- } from "./chunk-373IRT4X.js";
3
+ } from "./chunk-2NHZOI3W.js";
4
4
 
5
5
  // ../qti-test/dist/register.js
6
6
  for (const { tag, ctor } of qtiTestElements) {
@@ -8,4 +8,4 @@ for (const { tag, ctor } of qtiTestElements) {
8
8
  customElements.define(tag, ctor);
9
9
  }
10
10
  }
11
- //# sourceMappingURL=chunk-BB2ZSJXP.js.map
11
+ //# sourceMappingURL=chunk-FP3KXADH.js.map
@@ -21,6 +21,8 @@ var PUBLIC_EVENTS = {
21
21
  "qc-test-rendered": { kind: "notification", scope: "test", deprecated: "cito-test-rendered" },
22
22
  "qc-test-loaded": { kind: "notification", scope: "test", deprecated: "cito-test-loaded" },
23
23
  "qc-test-state-changed": { kind: "notification", scope: "test", deprecated: "cito-test-state-changed" },
24
+ // New in 10.0, so it has no cito- name.
25
+ "qc-test-state-refused": { kind: "notification", scope: "test" },
24
26
  "qc-test-items-skipped": { kind: "notification", scope: "test", deprecated: "cito-test-items-skipped" },
25
27
  "qc-test-end-reached": { kind: "notification", scope: "test", deprecated: "cito-test-end-reached" },
26
28
  "qc-item-ref-connected": { kind: "notification", scope: "item", deprecated: "cito-item-ref-connected" }
@@ -194,4 +196,4 @@ export {
194
196
  buttonPrimary,
195
197
  styles_exports
196
198
  };
197
- //# sourceMappingURL=chunk-J6VX4N7M.js.map
199
+ //# sourceMappingURL=chunk-HUM7ST4L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../qti-test/src/public-events.ts","../../qti-test/src/components/styles.ts"],"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; an event new in 10.0 has none. One helper\n * (`dispatchPublic`, `listenPublic`) sends or handles both names until the next major, then the field\n * goes. The 7.x names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no\n * longer sent 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\n/** The detail of `qc-test-state-refused`. */\nexport interface StateRefusal {\n /** Why the state was not read. */\n message: string;\n /** The value that was assigned to `state`, as given. */\n state: unknown;\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 /** A value assigned to `state` could not be read and was ignored: the test goes on without it. */\n 'qc-test-state-refused': CustomEvent<StateRefusal>;\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 // New in 10.0, so it has no cito- name.\n 'qc-test-state-refused': { kind: 'notification', scope: 'test' },\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","// /* 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"],"mappings":";;;;;;;;;AAyEO,IAAM,gBAAiE;EAC5E,oBAAoB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,qBAAoB;EACtF,uBAAuB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,wBAAuB;EAC5F,kBAAkB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,mBAAkB;EAClF,0BAA0B,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,2BAA0B;EAClG,+BAA+B,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,gCAA+B;EAC5G,uBAAuB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,wBAAuB;EAC5F,qBAAqB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,sBAAqB;EAC7F,qBAAqB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,sBAAqB;EAC7F,8BAA8B,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,+BAA8B;EAC/G,6BAA6B,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,8BAA6B;EAC7G,oBAAoB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,qBAAoB;EAC3F,kBAAkB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,mBAAkB;EACvF,yBAAyB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,0BAAyB;;EAErG,yBAAyB,EAAE,MAAM,gBAAgB,OAAO,OAAM;EAC9D,yBAAyB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,0BAAyB;EACrG,uBAAuB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,wBAAuB;EACjG,yBAAyB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,0BAAyB;;AAWjG,SAAU,eACd,QACA,MACA,QAAkE;AAElE,mBAAiB,QAAQ,eAAe,MAAM,MAAM;AACtD;AAMM,SAAU,aACd,QACA,MACA,SAAuC;AAEvC,iBAAe,QAAQ,eAAe,MAAM,OAA6B;AAC3E;;;ACxHA;;;;;;;;;;;;;;;;;AACA,SAAS,KAAK,YAAY;AAoC1B,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,iBAAiB;AACvB,IAAM,SAAS;AACf,IAAM,cAAc;AAYb,IAAM,UAAU;;;;mBAIJ,MAAM;;AAIlB,IAAM,OAAO;;;;;;;;;;;;;mBAaD,MAAM;;AAGlB,IAAM,MAAM;IACf,IAAI;yFACiF,OAAO;;YAEpF,WAAW;;;oFAG6D,OAAO,SAAS,OAAO;;;AAKpG,IAAM,aAAa;yGAC+E,OAAO;wEACxC,cAAc;qGACe,OAAO;;AAIrG,IAAM,iBAAiB;;;oEAGsC,OAAO,KAAK,OAAO;;;AAIhF,IAAM,wBAAwB;;;;;4BAKT,OAAO,KAAK,cAAc;;;;AAM/C,IAAM,YAAY;;;qEAG4C,OAAO,KAAK,OAAO;;;AAIjF,IAAM,mBAAmB;;;;;4BAKJ,OAAO,KAAK,cAAc;;;;AAM/C,IAAM,YAAY;;;;AAKlB,IAAM,MAAM;;;;AAKZ,IAAM,MAAM;IACf,IAAI;YACI,WAAW;;AAIhB,IAAM,UAAU;AAMhB,IAAM,SAAS;;MAEhB,OAAO;;;MAGP,GAAG;;;;QAID,cAAc;;;;MAIhB,SAAS;;;;;;;;;;;;;MAaT,SAAS;;;MAGT,GAAG;;;;;;AAQF,IAAM,gBAAgB;;MAEvB,UAAU;;;;QAIR,qBAAqB;;;;MAIvB,gBAAgB;;;","names":[]}
@@ -7,7 +7,7 @@ import { QtiAssessmentItem } from './elements.js';
7
7
  import { Q as QtiItem } from './qti-item.d-CxP6KtCH.js';
8
8
  import './public-events.d-3dGip9pd.js';
9
9
  import { V as View, C as ComputedItemContext } from './session.context.d-9gRdGK4T.js';
10
- import { l as QtiTest, r as TestNavigation } from './qti-test.d-CN2JZwAz.js';
10
+ import { l as QtiTest, r as TestNavigation } from './qti-test.d-DADK63uc.js';
11
11
  import { a as ComputedItem, C as ComputedContext } from './computed.types.d-6qQNFbu1.js';
12
12
  import './config.context.d-Dm11aAuw.js';
13
13
  import './interaction.interface.d-CvjHM2bi.js';
@@ -33,11 +33,11 @@ import {
33
33
  TestNavigationCorrection,
34
34
  TestShowCorrectResponse,
35
35
  correctionPart
36
- } from "./chunk-L73QXB6G.js";
36
+ } from "./chunk-DU6RX3TX.js";
37
37
  import {
38
38
  qtiTestElements
39
- } from "./chunk-373IRT4X.js";
40
- import "./chunk-J6VX4N7M.js";
39
+ } from "./chunk-2NHZOI3W.js";
40
+ import "./chunk-HUM7ST4L.js";
41
41
  import {
42
42
  qtiContentElements
43
43
  } from "./chunk-H6DO5UHC.js";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { I as ITestNavigationMixin, a as ITestStateMixin, b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiBranchRule, f as QtiItemSessionControl, g as QtiNumberPresented, h as QtiNumberSelected, i as QtiOutcomeProcessing, j as QtiOutcomeProcessingProcessor, k as QtiPreCondition, l as QtiTest, m as QtiTestFeedback, n as QtiTestPart, o as QtiTestVariables, p as QtiTestVariablesExpression, T as TestContainer, q as TestEndAttempt, r as TestNavigation, s as TestNext, t as TestPrev, u as TestSubmit } from './qti-test.d-CN2JZwAz.js';
2
- export { IMyQtiTest, IQtiTest, ITestProcessingMixin, pluginElements } from './test.js';
1
+ export { I as ITestNavigationMixin, a as ITestStateMixin, b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiBranchRule, f as QtiItemSessionControl, g as QtiNumberPresented, h as QtiNumberSelected, i as QtiOutcomeProcessing, j as QtiOutcomeProcessingProcessor, k as QtiPreCondition, l as QtiTest, m as QtiTestFeedback, n as QtiTestPart, o as QtiTestVariables, p as QtiTestVariablesExpression, T as TestContainer, q as TestEndAttempt, r as TestNavigation, s as TestNext, t as TestPrev, u as TestSubmit } from './qti-test.d-DADK63uc.js';
2
+ export { IMyQtiTest, IQtiTest, ITestProcessingMixin, StoredSessionContext, StoredTestContext, StoredVariable, pluginElements, stateFromContexts } from './test.js';
3
3
  export { Q as QTI_TEST_STATE_VERSION, a as QtiTestPluginState, b as QtiTestState, c as QtiTestStateItem, d as QtiTestStateSession, e as QtiTestStateValue, p as pluginState } from './qti-test-state-C71K8UNC.js';
4
4
  export { I as ItemContainer, a as ItemPrintVariables, Q as QtiItem } from './qti-item.d-CxP6KtCH.js';
5
5
  export { ItemViewMixin } from './item.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-BB2ZSJXP.js";
1
+ import "./chunk-FP3KXADH.js";
2
2
  import {
3
3
  pluginState
4
4
  } from "./chunk-DJ7PB252.js";
@@ -37,7 +37,7 @@ import {
37
37
  TestNavigationCorrection,
38
38
  TestShowCorrectResponse,
39
39
  correctionPart
40
- } from "./chunk-L73QXB6G.js";
40
+ } from "./chunk-DU6RX3TX.js";
41
41
  import {
42
42
  QTI_TEST_STATE_VERSION,
43
43
  QtiAssessmentItemRef,
@@ -61,9 +61,10 @@ import {
61
61
  TestNext,
62
62
  TestPrev,
63
63
  TestSubmit,
64
- pluginElements
65
- } from "./chunk-373IRT4X.js";
66
- import "./chunk-J6VX4N7M.js";
64
+ pluginElements,
65
+ stateFromContexts
66
+ } from "./chunk-2NHZOI3W.js";
67
+ import "./chunk-HUM7ST4L.js";
67
68
  import "./chunk-TSJGL6FI.js";
68
69
  import {
69
70
  QtiAssessmentItem,
@@ -531,6 +532,7 @@ export {
531
532
  serializeResponseAttribute,
532
533
  sessionContext,
533
534
  setState,
535
+ stateFromContexts,
534
536
  testContext,
535
537
  unregisterCustomOperator,
536
538
  validationMessage
@@ -4751,6 +4751,8 @@ object, do not mutate it: an in-place change does not notify the components insi
4751
4751
  "onqti-test-connected"?: ((e: CustomEvent) => void) | undefined;
4752
4752
  /** The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume. */
4753
4753
  "onqc-test-state-changed"?: ((e: Event) => void) | undefined;
4754
+ /** A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded. */
4755
+ "onqc-test-state-refused"?: ((e: Event) => void) | undefined;
4754
4756
  /** 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. */
4755
4757
  "onqti-test-context-updated"?: ((e: Event) => void) | undefined;
4756
4758
  };
@@ -4771,6 +4773,8 @@ object, do not mutate it: an in-place change does not notify the components insi
4771
4773
  "on:qti-test-connected"?: ((e: CustomEvent) => void) | undefined;
4772
4774
  /** The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume. */
4773
4775
  "on:qc-test-state-changed"?: ((e: Event) => void) | undefined;
4776
+ /** A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded. */
4777
+ "on:qc-test-state-refused"?: ((e: Event) => void) | undefined;
4774
4778
  /** 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. */
4775
4779
  "on:qti-test-context-updated"?: ((e: Event) => void) | undefined;
4776
4780
 
@@ -6250,6 +6254,8 @@ object, do not mutate it: an in-place change does not notify the components insi
6250
6254
  "onqti-test-connected"?: ((e: CustomEvent) => void) | undefined;
6251
6255
  /** The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume. */
6252
6256
  "onqc-test-state-changed"?: ((e: Event) => void) | undefined;
6257
+ /** A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded. */
6258
+ "onqc-test-state-refused"?: ((e: Event) => void) | undefined;
6253
6259
  /** 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. */
6254
6260
  "onqti-test-context-updated"?: ((e: Event) => void) | undefined;
6255
6261
  };
@@ -6270,6 +6276,8 @@ object, do not mutate it: an in-place change does not notify the components insi
6270
6276
  "on:qti-test-connected"?: ((e: CustomEvent) => void) | undefined;
6271
6277
  /** The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume. */
6272
6278
  "on:qc-test-state-changed"?: ((e: Event) => void) | undefined;
6279
+ /** A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded. */
6280
+ "on:qc-test-state-refused"?: ((e: Event) => void) | undefined;
6273
6281
  /** 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. */
6274
6282
  "on:qti-test-context-updated"?: ((e: Event) => void) | undefined;
6275
6283
 
@@ -9826,6 +9834,7 @@ export type CustomElements = {
9826
9834
  *
9827
9835
  * - `qti-test-connected`: undefined
9828
9836
  * - `qc-test-state-changed`: The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
9837
+ * - `qc-test-state-refused`: A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
9829
9838
  * - `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.
9830
9839
  */
9831
9840
  "qti-test": Partial<QtiTestProps & BaseProps<QtiTest> & BaseEvents>;
@@ -12058,6 +12067,7 @@ export type CustomElements = {
12058
12067
  *
12059
12068
  * - `qti-test-connected`: undefined
12060
12069
  * - `qc-test-state-changed`: The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
12070
+ * - `qc-test-state-refused`: A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
12061
12071
  * - `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.
12062
12072
  *
12063
12073
  * ## Methods
@@ -15720,6 +15730,7 @@ export type CustomElementsSolidJs = {
15720
15730
  *
15721
15731
  * - `qti-test-connected`: undefined
15722
15732
  * - `qc-test-state-changed`: The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
15733
+ * - `qc-test-state-refused`: A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
15723
15734
  * - `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.
15724
15735
  */
15725
15736
  "qti-test": Partial<
@@ -18168,6 +18179,7 @@ export type CustomElementsSolidJs = {
18168
18179
  *
18169
18180
  * - `qti-test-connected`: undefined
18170
18181
  * - `qc-test-state-changed`: The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
18182
+ * - `qc-test-state-refused`: A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
18171
18183
  * - `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.
18172
18184
  *
18173
18185
  * ## Methods
@@ -392,6 +392,11 @@ interface ITestStateMixin {
392
392
  * Items are matched by item-ref identifier; items the state does not mention start fresh, and
393
393
  * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a
394
394
  * resume, so linear-mode navigation restrictions do not apply.
395
+ *
396
+ * A value that is not a version 1 `QtiTestState` is ignored and reported with
397
+ * `qc-test-state-refused`: at once when the test has loaded, or when it does if it was assigned
398
+ * before. A state assigned earlier that could be read stays in effect. A stored 9.x
399
+ * `testContext` is turned into a state with `stateFromContexts`.
395
400
  */
396
401
  state: QtiTestState;
397
402
  }
@@ -692,6 +697,7 @@ declare const QtiTest_base: (abstract new (...args: any[]) => ITestNavigationMix
692
697
  * And you can use the `test-prev` and `test-next` elements to navigate through the test.
693
698
  *
694
699
  * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
700
+ * @event qc-test-state-refused - A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
695
701
  * @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.
696
702
  */
697
703
  declare class QtiTest extends QtiTest_base {
@@ -13,10 +13,10 @@ import './computed.types.d-6qQNFbu1.js';
13
13
  * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense
14
14
  * (the test dispatches them). All bubble and are composed.
15
15
  *
16
- * `deprecated` is the `cito-` name this event had in 9.x. One helper (`dispatchPublic`,
17
- * `listenPublic`) sends or handles both names until the next major, then the field goes. The 7.x
18
- * names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no longer sent
19
- * or handled.
16
+ * `deprecated` is the `cito-` name this event had in 9.x; an event new in 10.0 has none. One helper
17
+ * (`dispatchPublic`, `listenPublic`) sends or handles both names until the next major, then the field
18
+ * goes. The 7.x names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no
19
+ * longer sent or handled.
20
20
  */
21
21
  interface NavigationTarget {
22
22
  type: 'item' | 'section';
@@ -28,6 +28,13 @@ interface NavigationFailure {
28
28
  itemId?: string;
29
29
  sectionId?: string;
30
30
  }
31
+ /** The detail of `qc-test-state-refused`. */
32
+ interface StateRefusal {
33
+ /** Why the state was not read. */
34
+ message: string;
35
+ /** The value that was assigned to `state`, as given. */
36
+ state: unknown;
37
+ }
31
38
  interface PublicEventMap {
32
39
  'qc-test-navigate': CustomEvent<NavigationTarget>;
33
40
  /**
@@ -60,6 +67,8 @@ interface PublicEventMap {
60
67
  element: Element;
61
68
  }[]>;
62
69
  'qc-test-state-changed': CustomEvent<QtiTestState>;
70
+ /** A value assigned to `state` could not be read and was ignored: the test goes on without it. */
71
+ 'qc-test-state-refused': CustomEvent<StateRefusal>;
63
72
  'qc-test-items-skipped': CustomEvent<{
64
73
  ids: string[];
65
74
  }>;
@@ -131,4 +140,4 @@ declare namespace styles {
131
140
  export { styles_btn as btn, styles_btnActive as btnActive, styles_btnInteractive as btnInteractive, styles_btnPrimary as btnPrimary, styles_btnPrimaryActive as btnPrimaryActive, styles_btnPrimaryInteractive as btnPrimaryInteractive, styles_button as button, styles_buttonPrimary as buttonPrimary, styles_control as control, styles_dis as dis, styles_focusRing as focusRing, styles_form as form, styles_hostBox as hostBox, styles_ind as ind };
132
141
  }
133
142
 
134
- export { type NavigationFailure, type NavigationTarget, PUBLIC_EVENTS, type PublicEventMap, type PublicEventName, styles as controlStyles, dispatchPublic, listenPublic };
143
+ export { type NavigationFailure, type NavigationTarget, PUBLIC_EVENTS, type PublicEventMap, type PublicEventName, type StateRefusal, styles as controlStyles, dispatchPublic, listenPublic };
@@ -6,7 +6,7 @@ import {
6
6
  dispatchPublic,
7
7
  listenPublic,
8
8
  styles_exports
9
- } from "./chunk-J6VX4N7M.js";
9
+ } from "./chunk-HUM7ST4L.js";
10
10
  import "./chunk-UCXLDQYA.js";
11
11
  import "./chunk-PZ5AY32C.js";
12
12
  export {
package/dist/test.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { u as TestSubmit, v as ItemVariableValue, I as ITestNavigationMixin, a as ITestStateMixin } from './qti-test.d-CN2JZwAz.js';
2
- export { b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiBranchRule, f as QtiItemSessionControl, g as QtiNumberPresented, h as QtiNumberSelected, i as QtiOutcomeProcessing, j as QtiOutcomeProcessingProcessor, k as QtiPreCondition, l as QtiTest, m as QtiTestFeedback, n as QtiTestPart, o as QtiTestVariables, p as QtiTestVariablesExpression, T as TestContainer, q as TestEndAttempt, r as TestNavigation, s as TestNext, t as TestPrev } from './qti-test.d-CN2JZwAz.js';
3
- export { Q as QTI_TEST_STATE_VERSION, a as QtiTestPluginState, b as QtiTestState, c as QtiTestStateItem, d as QtiTestStateSession, e as QtiTestStateValue, p as pluginState } from './qti-test-state-C71K8UNC.js';
1
+ import { u as TestSubmit, v as ItemVariableValue, I as ITestNavigationMixin, a as ITestStateMixin } from './qti-test.d-DADK63uc.js';
2
+ export { b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiBranchRule, f as QtiItemSessionControl, g as QtiNumberPresented, h as QtiNumberSelected, i as QtiOutcomeProcessing, j as QtiOutcomeProcessingProcessor, k as QtiPreCondition, l as QtiTest, m as QtiTestFeedback, n as QtiTestPart, o as QtiTestVariables, p as QtiTestVariablesExpression, T as TestContainer, q as TestEndAttempt, r as TestNavigation, s as TestNext, t as TestPrev } from './qti-test.d-DADK63uc.js';
3
+ import { b as QtiTestState } from './qti-test-state-C71K8UNC.js';
4
+ export { Q as QTI_TEST_STATE_VERSION, a as QtiTestPluginState, c as QtiTestStateItem, d as QtiTestStateSession, e as QtiTestStateValue, p as pluginState } from './qti-test-state-C71K8UNC.js';
4
5
  import { LitElement } from 'lit';
5
6
  import { b as OutcomeVariable, V as VariableDeclaration } from './variables.d-DWHlTszN.js';
6
7
  import { S as SessionContext } from './session.context.d-9gRdGK4T.js';
@@ -29,6 +30,51 @@ declare const pluginElements: readonly [{
29
30
  readonly ctor: typeof TestSubmit;
30
31
  }];
31
32
 
33
+ /** A value as a 9.x host may have stored it: QTI values are strings, but JSON kept numbers as numbers. */
34
+ type StoredValue = string | number | boolean | null | undefined | readonly (string | number | boolean)[];
35
+ /** A variable as stored: only `identifier`, `value` and `type` are read; declaration metadata is ignored. */
36
+ interface StoredVariable {
37
+ identifier: string;
38
+ value?: StoredValue;
39
+ type?: string;
40
+ }
41
+ /**
42
+ * A `testContext` as a 9.x host stored it (`qtiTest.testContext` or the `qti-test-context-updated`
43
+ * payload), plain JSON. Fields this does not name, such as an item's `href` or a host's own
44
+ * additions, are ignored.
45
+ */
46
+ interface StoredTestContext {
47
+ items?: readonly {
48
+ identifier?: string;
49
+ variables?: readonly StoredVariable[];
50
+ state?: Readonly<Record<string, string | null>>;
51
+ }[];
52
+ testOutcomeVariables?: readonly StoredVariable[];
53
+ }
54
+ /** A `sessionContext` as a 9.x host stored it: the position and the plugin entries. */
55
+ interface StoredSessionContext {
56
+ navPartId?: string | null;
57
+ navSectionId?: string | null;
58
+ navItemRefId?: string | null;
59
+ plugins?: Readonly<Record<string, unknown>>;
60
+ }
61
+ /**
62
+ * Turns a stored `testContext` and `sessionContext` into a `QtiTestState`, so a host that stored the
63
+ * contexts in 9.x can resume with `qtiTest.state = stateFromContexts(testContext, sessionContext)`.
64
+ * `qtiTest.state` reads the same way from the live contexts.
65
+ *
66
+ * It keeps the values only: each item's variables (identifier, value and `type` when it is one QTI
67
+ * knows) and per-interaction state, the test outcomes, the position and the plugin entries. Values
68
+ * are written as QTI's strings, so a number a host stored as a JSON number (`SCORE: 0`) becomes
69
+ * `'0'`. Declaration metadata (`baseType`, `cardinality`, `correctResponse`, …) is left out, as in
70
+ * every `QtiTestState`. Items without an identifier are skipped.
71
+ *
72
+ * @param testContext The stored test context, plain JSON.
73
+ * @param sessionContext The stored session context, if the host kept one. A host that stored only the
74
+ * item it was on passes `{ navItemRefId }`.
75
+ */
76
+ declare const stateFromContexts: (testContext: Readonly<StoredTestContext> | null | undefined, sessionContext?: Readonly<StoredSessionContext> | null) => QtiTestState;
77
+
32
78
  interface IQtiTest extends LitElement, ITestNavigationMixin, ITestProcessingMixin, ITestStateMixin, IMyQtiTest {
33
79
  }
34
80
  interface IMyQtiTest {
@@ -45,4 +91,4 @@ interface ITestProcessingMixin {
45
91
  outcomeProcessing(): boolean;
46
92
  }
47
93
 
48
- export { type IMyQtiTest, type IQtiTest, ITestNavigationMixin, type ITestProcessingMixin, ITestStateMixin, TestSubmit, pluginElements };
94
+ export { type IMyQtiTest, type IQtiTest, ITestNavigationMixin, type ITestProcessingMixin, ITestStateMixin, QtiTestState, type StoredSessionContext, type StoredTestContext, type StoredVariable, TestSubmit, pluginElements, stateFromContexts };
package/dist/test.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-BB2ZSJXP.js";
1
+ import "./chunk-FP3KXADH.js";
2
2
  import {
3
3
  pluginState
4
4
  } from "./chunk-DJ7PB252.js";
@@ -25,9 +25,10 @@ import {
25
25
  TestNext,
26
26
  TestPrev,
27
27
  TestSubmit,
28
- pluginElements
29
- } from "./chunk-373IRT4X.js";
30
- import "./chunk-J6VX4N7M.js";
28
+ pluginElements,
29
+ stateFromContexts
30
+ } from "./chunk-2NHZOI3W.js";
31
+ import "./chunk-HUM7ST4L.js";
31
32
  import "./chunk-H6DO5UHC.js";
32
33
  import "./chunk-UCXLDQYA.js";
33
34
  import "./chunk-WWY2H2YO.js";
@@ -59,6 +60,7 @@ export {
59
60
  TestPrev,
60
61
  TestSubmit,
61
62
  pluginElements,
62
- pluginState
63
+ pluginState,
64
+ stateFromContexts
63
65
  };
64
66
  //# sourceMappingURL=test.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@citolab/qti-components",
3
3
  "description": "QTI component utilities",
4
- "version": "10.0.0-next.22",
4
+ "version": "10.0.0-next.24",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
@@ -12,13 +12,13 @@
12
12
  "devDependencies": {
13
13
  "@qti-components/base": "^3.0.0-next.9",
14
14
  "@qti-components/corrections": "^1.0.0-next.11",
15
- "@qti-components/delivery": "^0.1.0-next.1",
15
+ "@qti-components/delivery": "^0.1.0-next.2",
16
16
  "@qti-components/elements": "^2.0.0-next.7",
17
17
  "@qti-components/interactions": "^1.10.5-next.8",
18
18
  "@qti-components/item": "^1.5.1-next.7",
19
19
  "@qti-components/loader": "^1.3.4-next.2",
20
20
  "@qti-components/processing": "^1.6.1-next.5",
21
- "@qti-components/test": "^2.0.0-next.18",
21
+ "@qti-components/test": "^2.0.0-next.20",
22
22
  "@qti-components/theme": "^3.0.0-next.6",
23
23
  "@qti-components/transformers": "^1.8.0-next.1"
24
24
  },