@qti-components/test 1.10.0-next.2 → 1.10.0-next.3

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.
@@ -7,6 +7,7 @@ export * from '../components/qti-test-feedback/qti-test-feedback';
7
7
  export * from '../components/qti-outcome-processing/qti-outcome-processing';
8
8
  export * from '../components/qti-test-variables/qti-test-variables';
9
9
  export * from '../components/qti-number-selected/qti-number-selected';
10
+ export * from '../components/qti-number-presented/qti-number-presented';
10
11
  export * from '../components/qti-pre-condition/qti-pre-condition';
11
12
  export * from '../components/qti-branch-rule/qti-branch-rule';
12
13
  export * from '../components/qti-item-session-control/qti-item-session-control';
@@ -8,6 +8,7 @@ export * from '../components/qti-test-feedback/qti-test-feedback';
8
8
  export * from '../components/qti-outcome-processing/qti-outcome-processing';
9
9
  export * from '../components/qti-test-variables/qti-test-variables';
10
10
  export * from '../components/qti-number-selected/qti-number-selected';
11
+ export * from '../components/qti-number-presented/qti-number-presented';
11
12
  export * from '../components/qti-pre-condition/qti-pre-condition';
12
13
  export * from '../components/qti-branch-rule/qti-branch-rule';
13
14
  export * from '../components/qti-item-session-control/qti-item-session-control';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,cAAc,iCAAiC,CAAC;AAChD,cAAc,+DAA+D,CAAC;AAC9E,cAAc,6DAA6D,CAAC;AAC5E,cAAc,uDAAuD,CAAC;AACtE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mDAAmD,CAAC;AAClE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,qDAAqD,CAAC;AACpE,cAAc,uDAAuD,CAAC;AACtE,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iEAAiE,CAAC;AAEhF,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uDAAuD,CAAC;AACtE,cAAc,iCAAiC,CAAC;AAChD,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC","sourcesContent":["/* test functionality webcomponents which are tested and can be used in your project */\nexport * from '../components/qti-test/qti-test';\nexport * from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nexport * from '../components/qti-assessment-section/qti-assessment-section';\nexport * from '../components/qti-assessment-test/qti-assessment-test';\nexport * from '../components/qti-test-part/qti-test-part';\nexport * from '../components/qti-test-feedback/qti-test-feedback';\nexport * from '../components/qti-outcome-processing/qti-outcome-processing';\nexport * from '../components/qti-test-variables/qti-test-variables';\nexport * from '../components/qti-number-selected/qti-number-selected';\nexport * from '../components/qti-pre-condition/qti-pre-condition';\nexport * from '../components/qti-branch-rule/qti-branch-rule';\nexport * from '../components/qti-item-session-control/qti-item-session-control';\n\nexport * from './test-navigation/test-navigation';\nexport * from './test-next/test-next';\nexport * from './test-prev/test-prev';\nexport * from './test-view-toggle/test-view';\nexport * from './test-item-link/test-item-link';\nexport * from './test-end-attempt/test-end-attempt';\nexport * from './test-paging-buttons-stamp/test-paging-buttons-stamp';\nexport * from './test-container/test-container';\nexport * from './test-print-item-variables/test-print-item-variables';\nexport * from './test-section-buttons-stamp/test-section-buttons-stamp';\nexport * from './test-section-link/test-section-link';\nexport * from './test-print-context/test-print-context';\nexport * from './test-stamp/test-stamp';\nexport * from './test-scoring-buttons/test-scoring-buttons';\nexport * from './test-view-toggle/test-view-toggle';\nexport * from './test-scoring-feedback/test-scoring-feedback';\nexport * from './test-check-item/test-check-item';\nexport * from './test-item-to-speech/test-item-to-speech';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,cAAc,iCAAiC,CAAC;AAChD,cAAc,+DAA+D,CAAC;AAC9E,cAAc,6DAA6D,CAAC;AAC5E,cAAc,uDAAuD,CAAC;AACtE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mDAAmD,CAAC;AAClE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,qDAAqD,CAAC;AACpE,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iEAAiE,CAAC;AAEhF,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uDAAuD,CAAC;AACtE,cAAc,iCAAiC,CAAC;AAChD,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC","sourcesContent":["/* test functionality webcomponents which are tested and can be used in your project */\nexport * from '../components/qti-test/qti-test';\nexport * from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nexport * from '../components/qti-assessment-section/qti-assessment-section';\nexport * from '../components/qti-assessment-test/qti-assessment-test';\nexport * from '../components/qti-test-part/qti-test-part';\nexport * from '../components/qti-test-feedback/qti-test-feedback';\nexport * from '../components/qti-outcome-processing/qti-outcome-processing';\nexport * from '../components/qti-test-variables/qti-test-variables';\nexport * from '../components/qti-number-selected/qti-number-selected';\nexport * from '../components/qti-number-presented/qti-number-presented';\nexport * from '../components/qti-pre-condition/qti-pre-condition';\nexport * from '../components/qti-branch-rule/qti-branch-rule';\nexport * from '../components/qti-item-session-control/qti-item-session-control';\n\nexport * from './test-navigation/test-navigation';\nexport * from './test-next/test-next';\nexport * from './test-prev/test-prev';\nexport * from './test-view-toggle/test-view';\nexport * from './test-item-link/test-item-link';\nexport * from './test-end-attempt/test-end-attempt';\nexport * from './test-paging-buttons-stamp/test-paging-buttons-stamp';\nexport * from './test-container/test-container';\nexport * from './test-print-item-variables/test-print-item-variables';\nexport * from './test-section-buttons-stamp/test-section-buttons-stamp';\nexport * from './test-section-link/test-section-link';\nexport * from './test-print-context/test-print-context';\nexport * from './test-stamp/test-stamp';\nexport * from './test-scoring-buttons/test-scoring-buttons';\nexport * from './test-view-toggle/test-view-toggle';\nexport * from './test-scoring-feedback/test-scoring-feedback';\nexport * from './test-check-item/test-check-item';\nexport * from './test-item-to-speech/test-item-to-speech';\n"]}
@@ -0,0 +1,28 @@
1
+ import { QtiExpression } from '@qti-components/base';
2
+ import type { TestContext } from '@qti-components/base';
3
+ /**
4
+ * @summary The qti-number-presented expression counts the selected items that have been presented to the candidate.
5
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-presented
6
+ *
7
+ * Outcome processing only. `section-identifier`, `include-category` and
8
+ * `exclude-category` narrow which item references are counted, the same way as
9
+ * for `qti-number-selected` and `qti-test-variables`.
10
+ *
11
+ * An item is presented once its `completionStatus` has left `not_attempted`:
12
+ * presenting an item starts its first attempt. An item a linear test part
13
+ * passed over (pre-condition, branch rule) or one the candidate has not reached
14
+ * keeps `not_attempted`. That makes this the count to use for a total over the
15
+ * candidate's own route, such as a maximum score of one point per presented item.
16
+ */
17
+ export declare class QtiNumberPresented extends QtiExpression<number> {
18
+ #private;
19
+ _testContext?: TestContext;
20
+ constructor();
21
+ getResult(): number;
22
+ calculate(): number;
23
+ }
24
+ declare global {
25
+ interface HTMLElementTagNameMap {
26
+ 'qti-number-presented': QtiNumberPresented;
27
+ }
28
+ }
@@ -0,0 +1,56 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { consume } from '@lit/context';
8
+ import { QtiExpression, testContext } from '@qti-components/base';
9
+ import { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';
10
+ import { listenPublic } from '../../public-events';
11
+ /**
12
+ * @summary The qti-number-presented expression counts the selected items that have been presented to the candidate.
13
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-presented
14
+ *
15
+ * Outcome processing only. `section-identifier`, `include-category` and
16
+ * `exclude-category` narrow which item references are counted, the same way as
17
+ * for `qti-number-selected` and `qti-test-variables`.
18
+ *
19
+ * An item is presented once its `completionStatus` has left `not_attempted`:
20
+ * presenting an item starts its first attempt. An item a linear test part
21
+ * passed over (pre-condition, branch rule) or one the candidate has not reached
22
+ * keeps `not_attempted`. That makes this the count to use for a total over the
23
+ * candidate's own route, such as a maximum score of one point per presented item.
24
+ */
25
+ export class QtiNumberPresented extends QtiExpression {
26
+ #connectedTest = null;
27
+ constructor() {
28
+ super();
29
+ listenPublic(this, 'cito-test-loaded', (e) => (this.#connectedTest = e.detail));
30
+ }
31
+ /** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */
32
+ get #testElement() {
33
+ return this.#connectedTest ?? this.closest('qti-assessment-test');
34
+ }
35
+ getResult() {
36
+ const testElement = this.#testElement;
37
+ if (!testElement) {
38
+ console.warn('qti-number-presented: no enclosing qti-assessment-test, nothing to count');
39
+ return 0;
40
+ }
41
+ const presented = new Set((this._testContext?.items ?? [])
42
+ .filter(item => {
43
+ const status = item.variables?.find(v => v.identifier === 'completionStatus')?.value;
44
+ return status != null && status !== 'not_attempted';
45
+ })
46
+ .map(item => item.identifier));
47
+ return selectItemRefs(testElement, selectionFrom(this)).filter(itemRef => presented.has(itemRef.identifier)).length;
48
+ }
49
+ calculate() {
50
+ return this.getResult();
51
+ }
52
+ }
53
+ __decorate([
54
+ consume({ context: testContext, subscribe: true })
55
+ ], QtiNumberPresented.prototype, "_testContext", void 0);
56
+ //# sourceMappingURL=qti-number-presented.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qti-number-presented.js","sourceRoot":"","sources":["../../../src/components/qti-number-presented/qti-number-presented.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKnD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,kBAAmB,SAAQ,aAAqB;IAI3D,cAAc,GAA6B,IAAI,CAAC;IAEhD;QACE,KAAK,EAAE,CAAC;QACR,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAiC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAClH,CAAC;IAED,8GAA8G;IAC9G,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,CAAoB,qBAAqB,CAAC,CAAC;IACvF,CAAC;IAEe,SAAS;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;YACzF,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,CACvB,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC;aAC7B,MAAM,CAAC,IAAI,CAAC,EAAE;YACb,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,kBAAkB,CAAC,EAAE,KAAK,CAAC;YACrF,OAAO,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,eAAe,CAAC;QACtD,CAAC,CAAC;aACD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAChC,CAAC;QACF,OAAO,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IACtH,CAAC;IAEe,SAAS;QACvB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF;AAnCQ;IADN,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;wDACjB","sourcesContent":["import { consume } from '@lit/context';\n\nimport { QtiExpression, testContext } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { TestContext } from '@qti-components/base';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\n\n/**\n * @summary The qti-number-presented expression counts the selected items that have been presented to the candidate.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-presented\n *\n * Outcome processing only. `section-identifier`, `include-category` and\n * `exclude-category` narrow which item references are counted, the same way as\n * for `qti-number-selected` and `qti-test-variables`.\n *\n * An item is presented once its `completionStatus` has left `not_attempted`:\n * presenting an item starts its first attempt. An item a linear test part\n * passed over (pre-condition, branch rule) or one the candidate has not reached\n * keeps `not_attempted`. That makes this the count to use for a total over the\n * candidate's own route, such as a maximum score of one point per presented item.\n */\nexport class QtiNumberPresented extends QtiExpression<number> {\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult(): number {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-number-presented: no enclosing qti-assessment-test, nothing to count');\n return 0;\n }\n\n const presented = new Set(\n (this._testContext?.items ?? [])\n .filter(item => {\n const status = item.variables?.find(v => v.identifier === 'completionStatus')?.value;\n return status != null && status !== 'not_attempted';\n })\n .map(item => item.identifier)\n );\n return selectItemRefs(testElement, selectionFrom(this)).filter(itemRef => presented.has(itemRef.identifier)).length;\n }\n\n public override calculate(): number {\n return this.getResult();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-number-presented': QtiNumberPresented;\n }\n}\n"]}
@@ -7,6 +7,7 @@ declare const QtiTest_base: (abstract new (...args: any[]) => import("../..").IT
7
7
  getOutcome(identifier: string): Readonly<import("@qti-components/base").OutcomeVariable>;
8
8
  getVariable(identifier: string): Readonly<import("@qti-components/base").VariableDeclaration<string | string[] | null>>;
9
9
  outcomeProcessing(): boolean;
10
+ getTestFeedback(access?: "atEnd" | "during"): import("..").QtiTestFeedback[];
10
11
  }) & (abstract new (...args: any[]) => import("../..").ITestStateMixin) & (abstract new (...args: any[]) => import("../../mixins").TestBaseInterface) & typeof LitElement;
11
12
  /**
12
13
  * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.
@@ -1,6 +1,17 @@
1
1
  import { QtiModalFeedback } from '@qti-components/elements/elements';
2
+ /**
3
+ * Test-level feedback. It renders nothing where it is declared: where and when it appears is up to
4
+ * the host. After outcome processing, `qtiTest.getTestFeedback(access)` returns the ones that apply.
5
+ */
2
6
  export declare class QtiTestFeedback extends QtiModalFeedback {
3
7
  static styles: import("lit").CSSResult;
8
+ /** When the feedback may be shown: at the end of the test (`atEnd`), or while it runs (`during`). */
9
+ access: 'atEnd' | 'during';
10
+ /**
11
+ * Whether this feedback applies for a value of its `outcome-identifier`: with `show-hide="show"`
12
+ * when the value is (or, for a container, holds) its `identifier`; with `hide` when it is not.
13
+ */
14
+ matches(value: string | readonly string[] | null | undefined): boolean;
4
15
  render(): import("lit").TemplateResult<1>;
5
16
  }
6
17
  declare global {
@@ -1,13 +1,40 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import { css, html } from 'lit';
8
+ import { property } from 'lit/decorators.js';
2
9
  import { QtiModalFeedback } from '@qti-components/elements/elements';
10
+ /**
11
+ * Test-level feedback. It renders nothing where it is declared: where and when it appears is up to
12
+ * the host. After outcome processing, `qtiTest.getTestFeedback(access)` returns the ones that apply.
13
+ */
3
14
  export class QtiTestFeedback extends QtiModalFeedback {
15
+ constructor() {
16
+ super(...arguments);
17
+ /** When the feedback may be shown: at the end of the test (`atEnd`), or while it runs (`during`). */
18
+ this.access = 'atEnd';
19
+ }
4
20
  static { this.styles = css `
5
21
  :host {
6
22
  color: gray;
7
23
  }
8
24
  `; }
25
+ /**
26
+ * Whether this feedback applies for a value of its `outcome-identifier`: with `show-hide="show"`
27
+ * when the value is (or, for a container, holds) its `identifier`; with `hide` when it is not.
28
+ */
29
+ matches(value) {
30
+ const found = Array.isArray(value) ? value.includes(this.identifier) : value != null && value === this.identifier;
31
+ return this.showHide === 'hide' ? !found : found;
32
+ }
9
33
  render() {
10
34
  return html ``;
11
35
  }
12
36
  }
37
+ __decorate([
38
+ property({ type: String })
39
+ ], QtiTestFeedback.prototype, "access", void 0);
13
40
  //# sourceMappingURL=qti-test-feedback.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"qti-test-feedback.js","sourceRoot":"","sources":["../../../src/components/qti-test-feedback/qti-test-feedback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,MAAM,OAAO,eAAgB,SAAQ,gBAAgB;aACnC,WAAM,GAAG,GAAG,CAAA;;;;GAI3B,CAAC;IACO,MAAM;QACb,OAAO,IAAI,CAAA,EAAE,CAAC;IAChB,CAAC","sourcesContent":["import { css, html } from 'lit';\n\nimport { QtiModalFeedback } from '@qti-components/elements/elements';\n\nexport class QtiTestFeedback extends QtiModalFeedback {\n static override styles = css`\n :host {\n color: gray;\n }\n `;\n override render() {\n return html``;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test-feedback': QtiTestFeedback;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-test-feedback.js","sourceRoot":"","sources":["../../../src/components/qti-test-feedback/qti-test-feedback.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,gBAAgB;IAArD;;QAOE,qGAAqG;QACzE,WAAM,GAAuB,OAAO,CAAC;IAcnE,CAAC;aArBiB,WAAM,GAAG,GAAG,CAAA;;;;GAI3B,AAJqB,CAIpB;IAKF;;;OAGG;IACH,OAAO,CAAC,KAAoD;QAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,UAAU,CAAC;QAClH,OAAO,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,EAAE,CAAC;IAChB,CAAC;;AAb2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAsC","sourcesContent":["import { css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { QtiModalFeedback } from '@qti-components/elements/elements';\n\n/**\n * Test-level feedback. It renders nothing where it is declared: where and when it appears is up to\n * the host. After outcome processing, `qtiTest.getTestFeedback(access)` returns the ones that apply.\n */\nexport class QtiTestFeedback extends QtiModalFeedback {\n static override styles = css`\n :host {\n color: gray;\n }\n `;\n\n /** When the feedback may be shown: at the end of the test (`atEnd`), or while it runs (`during`). */\n @property({ type: String }) access: 'atEnd' | 'during' = 'atEnd';\n\n /**\n * Whether this feedback applies for a value of its `outcome-identifier`: with `show-hide=\"show\"`\n * when the value is (or, for a container, holds) its `identifier`; with `hide` when it is not.\n */\n matches(value: string | readonly string[] | null | undefined): boolean {\n const found = Array.isArray(value) ? value.includes(this.identifier) : value != null && value === this.identifier;\n return this.showHide === 'hide' ? !found : found;\n }\n\n override render() {\n return html``;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test-feedback': QtiTestFeedback;\n }\n}\n"]}
@@ -3,6 +3,7 @@ import { QtiAssessmentSection } from './components/qti-assessment-section/qti-as
3
3
  import { QtiAssessmentTest } from './components/qti-assessment-test/qti-assessment-test';
4
4
  import { QtiBranchRule } from './components/qti-branch-rule/qti-branch-rule';
5
5
  import { QtiItemSessionControl } from './components/qti-item-session-control/qti-item-session-control';
6
+ import { QtiNumberPresented } from './components/qti-number-presented/qti-number-presented';
6
7
  import { QtiNumberSelected } from './components/qti-number-selected/qti-number-selected';
7
8
  import { QtiPreCondition } from './components/qti-pre-condition/qti-pre-condition';
8
9
  import { QtiOutcomeProcessing } from './components/qti-outcome-processing/qti-outcome-processing';
@@ -28,7 +29,7 @@ import { TestSectionLink } from './components/test-section-link/test-section-lin
28
29
  import { TestStamp } from './components/test-stamp/test-stamp';
29
30
  import { TestView } from './components/test-view-toggle/test-view';
30
31
  import { TestViewToggle } from './components/test-view-toggle/test-view-toggle';
31
- export { QtiAssessmentItemRef, QtiAssessmentSection, QtiAssessmentTest, QtiBranchRule, QtiItemSessionControl, QtiNumberSelected, QtiOutcomeProcessing, QtiPreCondition, QtiTest, QtiTestFeedback, QtiTestPart, QtiTestVariables, TestCheckItem, TestContainer, TestEndAttempt, TestItemLink, TestItemToSpeech, TestNavigation, TestNext, TestPagingButtonsStamp, TestPrev, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestSectionButtonsStamp, TestSectionLink, TestStamp, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop, TestView, TestViewToggle };
32
+ export { QtiAssessmentItemRef, QtiAssessmentSection, QtiAssessmentTest, QtiBranchRule, QtiItemSessionControl, QtiNumberPresented, QtiNumberSelected, QtiOutcomeProcessing, QtiPreCondition, QtiTest, QtiTestFeedback, QtiTestPart, QtiTestVariables, TestCheckItem, TestContainer, TestEndAttempt, TestItemLink, TestItemToSpeech, TestNavigation, TestNext, TestPagingButtonsStamp, TestPrev, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestSectionButtonsStamp, TestSectionLink, TestStamp, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop, TestView, TestViewToggle };
32
33
  export declare const qtiTestElements: readonly [{
33
34
  readonly tag: "qti-assessment-item-ref";
34
35
  readonly ctor: typeof QtiAssessmentItemRef;
@@ -44,6 +45,9 @@ export declare const qtiTestElements: readonly [{
44
45
  }, {
45
46
  readonly tag: "qti-item-session-control";
46
47
  readonly ctor: typeof QtiItemSessionControl;
48
+ }, {
49
+ readonly tag: "qti-number-presented";
50
+ readonly ctor: typeof QtiNumberPresented;
47
51
  }, {
48
52
  readonly tag: "qti-number-selected";
49
53
  readonly ctor: typeof QtiNumberSelected;
package/dist/elements.js CHANGED
@@ -3,6 +3,7 @@ import { QtiAssessmentSection } from './components/qti-assessment-section/qti-as
3
3
  import { QtiAssessmentTest } from './components/qti-assessment-test/qti-assessment-test';
4
4
  import { QtiBranchRule } from './components/qti-branch-rule/qti-branch-rule';
5
5
  import { QtiItemSessionControl } from './components/qti-item-session-control/qti-item-session-control';
6
+ import { QtiNumberPresented } from './components/qti-number-presented/qti-number-presented';
6
7
  import { QtiNumberSelected } from './components/qti-number-selected/qti-number-selected';
7
8
  import { QtiPreCondition } from './components/qti-pre-condition/qti-pre-condition';
8
9
  import { QtiOutcomeProcessing } from './components/qti-outcome-processing/qti-outcome-processing';
@@ -28,13 +29,14 @@ import { TestSectionLink } from './components/test-section-link/test-section-lin
28
29
  import { TestStamp } from './components/test-stamp/test-stamp';
29
30
  import { TestView } from './components/test-view-toggle/test-view';
30
31
  import { TestViewToggle } from './components/test-view-toggle/test-view-toggle';
31
- export { QtiAssessmentItemRef, QtiAssessmentSection, QtiAssessmentTest, QtiBranchRule, QtiItemSessionControl, QtiNumberSelected, QtiOutcomeProcessing, QtiPreCondition, QtiTest, QtiTestFeedback, QtiTestPart, QtiTestVariables, TestCheckItem, TestContainer, TestEndAttempt, TestItemLink, TestItemToSpeech, TestNavigation, TestNext, TestPagingButtonsStamp, TestPrev, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestSectionButtonsStamp, TestSectionLink, TestStamp, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop, TestView, TestViewToggle };
32
+ export { QtiAssessmentItemRef, QtiAssessmentSection, QtiAssessmentTest, QtiBranchRule, QtiItemSessionControl, QtiNumberPresented, QtiNumberSelected, QtiOutcomeProcessing, QtiPreCondition, QtiTest, QtiTestFeedback, QtiTestPart, QtiTestVariables, TestCheckItem, TestContainer, TestEndAttempt, TestItemLink, TestItemToSpeech, TestNavigation, TestNext, TestPagingButtonsStamp, TestPrev, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestSectionButtonsStamp, TestSectionLink, TestStamp, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop, TestView, TestViewToggle };
32
33
  export const qtiTestElements = [
33
34
  { tag: 'qti-assessment-item-ref', ctor: QtiAssessmentItemRef },
34
35
  { tag: 'qti-assessment-section', ctor: QtiAssessmentSection },
35
36
  { tag: 'qti-assessment-test', ctor: QtiAssessmentTest },
36
37
  { tag: 'qti-branch-rule', ctor: QtiBranchRule },
37
38
  { tag: 'qti-item-session-control', ctor: QtiItemSessionControl },
39
+ { tag: 'qti-number-presented', ctor: QtiNumberPresented },
38
40
  { tag: 'qti-number-selected', ctor: QtiNumberSelected },
39
41
  { tag: 'qti-outcome-processing', ctor: QtiOutcomeProcessing },
40
42
  { tag: 'qti-pre-condition', ctor: Q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AI,EAAE,kBAAkB,EAAE;IAC9D,EAAE,GAAG,EAAE,sBAAsB,EAAE,IAAI,EAAE,kBAAkB,EAAE;IACzD,EAAE,GAAG,EAAE,uBAAuB,EAAE,IAAI,EAAE,mBAAmB,EAAE;IAC3D,EAAE,GAAG,EAAE,4BAA4B,EAAE,IAAI,EAAE,uBAAuB,EAAE;IACpE,EAAE,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,eAAe,EAAE;IACnD,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAAE;IAC7C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpC,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE;CACzC,CAAC","sourcesContent":["import { QtiAssessmentItemRef } from './components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport { QtiAssessmentSection } from './components/qti-assessment-section/qti-assessment-section';\nimport { QtiAssessmentTest } from './components/qti-assessment-test/qti-assessment-test';\nimport { QtiBranchRule } from './components/qti-branch-rule/qti-branch-rule';\nimport { QtiItemSessionControl } from './components/qti-item-session-control/qti-item-session-control';\nimport { QtiNumberSelected } from './components/qti-number-selected/qti-number-selected';\nimport { QtiPreCondition } from './components/qti-pre-condition/qti-pre-condition';\nimport { QtiOutcomeProcessing } from './components/qti-outcome-processing/qti-outcome-processing';\nimport { QtiTestFeedback } from './components/qti-test-feedback/qti-test-feedback';\nimport { QtiTestPart } from './components/qti-test-part/qti-test-part';\nimport { QtiTestVariables } from './components/qti-test-variables/qti-test-variables';\nimport { QtiTest } from './components/qti-test/qti-test';\nimport { TestCheckItem } from './components/test-check-item/test-check-item';\nimport { TestContainer } from './components/test-container/test-container';\nimport { TestEndAttempt } from './components/test-end-attempt/test-end-attempt';\nimport { TestItemLink } from './components/test-item-link/test-item-link';\nimport {\n TestItemToSpeech,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop\n} from './components/test-item-to-speech/test-item-to-speech';\nimport { TestNavigation } from './components/test-navigation/test-navigation';\nimport { TestNext } from './components/test-next/test-next';\nimport { TestPagingButtonsStamp } from './components/test-paging-buttons-stamp/test-paging-buttons-stamp';\nimport { TestPrev } from './components/test-prev/test-prev';\nimport { TestPrintContext } from './components/test-print-context/test-print-context';\nimport { TestPrintVariables } from './components/test-print-item-variables/test-print-item-variables';\nimport { TestScoringButtons } from './components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from './components/test-scoring-feedback/test-scoring-feedback';\nimport { TestSectionButtonsStamp } from './components/test-section-buttons-stamp/test-section-buttons-stamp';\nimport { TestSectionLink } from './components/test-section-link/test-section-link';\nimport { TestStamp } from './components/test-stamp/test-stamp';\nimport { TestView } from './components/test-view-toggle/test-view';\nimport { TestViewToggle } from './components/test-view-toggle/test-view-toggle';\n\nexport {\n QtiAssessmentItemRef,\n QtiAssessmentSection,\n QtiAssessmentTest,\n QtiBranchRule,\n QtiItemSessionControl,\n QtiNumberSelected,\n QtiOutcomeProcessing,\n QtiPreCondition,\n QtiTest,\n QtiTestFeedback,\n QtiTestPart,\n QtiTestVariables,\n TestCheckItem,\n TestContainer,\n TestEndAttempt,\n TestItemLink,\n TestItemToSpeech,\n TestNavigation,\n TestNext,\n TestPagingButtonsStamp,\n TestPrev,\n TestPrintContext,\n TestPrintVariables,\n TestScoringButtons,\n TestScoringFeedback,\n TestSectionButtonsStamp,\n TestSectionLink,\n TestStamp,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop,\n TestView,\n TestViewToggle\n};\n\nexport const qtiTestElements = [\n { tag: 'qti-assessment-item-ref', ctor: QtiAssessmentItemRef },\n { tag: 'qti-assessment-section', ctor: QtiAssessmentSection },\n { tag: 'qti-assessment-test', ctor: QtiAssessmentTest },\n { tag: 'qti-branch-rule', ctor: QtiBranchRule },\n { tag: 'qti-item-session-control', ctor: QtiItemSessionControl },\n { tag: 'qti-number-selected', ctor: QtiNumberSelected },\n { tag: 'qti-outcome-processing', ctor: QtiOutcomeProcessing },\n { tag: 'qti-pre-condition', ctor: QtiPreCondition },\n { tag: 'qti-test', ctor: QtiTest },\n { tag: 'qti-test-feedback', ctor: QtiTestFeedback },\n { tag: 'qti-test-part', ctor: QtiTestPart },\n { tag: 'qti-test-variables', ctor: QtiTestVariables },\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-container', ctor: TestContainer },\n { tag: 'test-end-attempt', ctor: TestEndAttempt },\n { tag: 'test-item-link', ctor: TestItemLink },\n { tag: 'test-item-to-speech', ctor: TestItemToSpeech },\n { tag: 'test-navigation', ctor: TestNavigation },\n { tag: 'test-next', ctor: TestNext },\n { tag: 'test-paging-buttons-stamp', ctor: TestPagingButtonsStamp },\n { tag: 'test-prev', ctor: TestPrev },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-section-buttons-stamp', ctor: TestSectionButtonsStamp },\n { tag: 'test-section-link', ctor: TestSectionLink },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-tts-next', ctor: TestTtsNext },\n { tag: 'test-tts-pause', ctor: TestTtsPause },\n { tag: 'test-tts-pick', ctor: TestTtsPick },\n { tag: 'test-tts-play', ctor: TestTtsPlay },\n { tag: 'test-tts-prev', ctor: TestTtsPrev },\n { tag: 'test-tts-resume', ctor: TestTtsResume },\n { tag: 'test-tts-stop', ctor: TestTtsStop },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle }\n] as const;\n"]}
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,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AG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpC,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE;CACzC,CAAC","sourcesContent":["import { QtiAssessmentItemRef } from './components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport { QtiAssessmentSection } from './components/qti-assessment-section/qti-assessment-section';\nimport { QtiAssessmentTest } from './components/qti-assessment-test/qti-assessment-test';\nimport { QtiBranchRule } from './components/qti-branch-rule/qti-branch-rule';\nimport { QtiItemSessionControl } from './components/qti-item-session-control/qti-item-session-control';\nimport { QtiNumberPresented } from './components/qti-number-presented/qti-number-presented';\nimport { QtiNumberSelected } from './components/qti-number-selected/qti-number-selected';\nimport { QtiPreCondition } from './components/qti-pre-condition/qti-pre-condition';\nimport { QtiOutcomeProcessing } from './components/qti-outcome-processing/qti-outcome-processing';\nimport { QtiTestFeedback } from './components/qti-test-feedback/qti-test-feedback';\nimport { QtiTestPart } from './components/qti-test-part/qti-test-part';\nimport { QtiTestVariables } from './components/qti-test-variables/qti-test-variables';\nimport { QtiTest } from './components/qti-test/qti-test';\nimport { TestCheckItem } from './components/test-check-item/test-check-item';\nimport { TestContainer } from './components/test-container/test-container';\nimport { TestEndAttempt } from './components/test-end-attempt/test-end-attempt';\nimport { TestItemLink } from './components/test-item-link/test-item-link';\nimport {\n TestItemToSpeech,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop\n} from './components/test-item-to-speech/test-item-to-speech';\nimport { TestNavigation } from './components/test-navigation/test-navigation';\nimport { TestNext } from './components/test-next/test-next';\nimport { TestPagingButtonsStamp } from './components/test-paging-buttons-stamp/test-paging-buttons-stamp';\nimport { TestPrev } from './components/test-prev/test-prev';\nimport { TestPrintContext } from './components/test-print-context/test-print-context';\nimport { TestPrintVariables } from './components/test-print-item-variables/test-print-item-variables';\nimport { TestScoringButtons } from './components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from './components/test-scoring-feedback/test-scoring-feedback';\nimport { TestSectionButtonsStamp } from './components/test-section-buttons-stamp/test-section-buttons-stamp';\nimport { TestSectionLink } from './components/test-section-link/test-section-link';\nimport { TestStamp } from './components/test-stamp/test-stamp';\nimport { TestView } from './components/test-view-toggle/test-view';\nimport { TestViewToggle } from './components/test-view-toggle/test-view-toggle';\n\nexport {\n QtiAssessmentItemRef,\n QtiAssessmentSection,\n QtiAssessmentTest,\n QtiBranchRule,\n QtiItemSessionControl,\n QtiNumberPresented,\n QtiNumberSelected,\n QtiOutcomeProcessing,\n QtiPreCondition,\n QtiTest,\n QtiTestFeedback,\n QtiTestPart,\n QtiTestVariables,\n TestCheckItem,\n TestContainer,\n TestEndAttempt,\n TestItemLink,\n TestItemToSpeech,\n TestNavigation,\n TestNext,\n TestPagingButtonsStamp,\n TestPrev,\n TestPrintContext,\n TestPrintVariables,\n TestScoringButtons,\n TestScoringFeedback,\n TestSectionButtonsStamp,\n TestSectionLink,\n TestStamp,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop,\n TestView,\n TestViewToggle\n};\n\nexport const qtiTestElements = [\n { tag: 'qti-assessment-item-ref', ctor: QtiAssessmentItemRef },\n { tag: 'qti-assessment-section', ctor: QtiAssessmentSection },\n { tag: 'qti-assessment-test', ctor: QtiAssessmentTest },\n { tag: 'qti-branch-rule', ctor: QtiBranchRule },\n { tag: 'qti-item-session-control', ctor: QtiItemSessionControl },\n { tag: 'qti-number-presented', ctor: QtiNumberPresented },\n { tag: 'qti-number-selected', ctor: QtiNumberSelected },\n { tag: 'qti-outcome-processing', ctor: QtiOutcomeProcessing },\n { tag: 'qti-pre-condition', ctor: QtiPreCondition },\n { tag: 'qti-test', ctor: QtiTest },\n { tag: 'qti-test-feedback', ctor: QtiTestFeedback },\n { tag: 'qti-test-part', ctor: QtiTestPart },\n { tag: 'qti-test-variables', ctor: QtiTestVariables },\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-container', ctor: TestContainer },\n { tag: 'test-end-attempt', ctor: TestEndAttempt },\n { tag: 'test-item-link', ctor: TestItemLink },\n { tag: 'test-item-to-speech', ctor: TestItemToSpeech },\n { tag: 'test-navigation', ctor: TestNavigation },\n { tag: 'test-next', ctor: TestNext },\n { tag: 'test-paging-buttons-stamp', ctor: TestPagingButtonsStamp },\n { tag: 'test-prev', ctor: TestPrev },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-section-buttons-stamp', ctor: TestSectionButtonsStamp },\n { tag: 'test-section-link', ctor: TestSectionLink },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-tts-next', ctor: TestTtsNext },\n { tag: 'test-tts-pause', ctor: TestTtsPause },\n { tag: 'test-tts-pick', ctor: TestTtsPick },\n { tag: 'test-tts-play', ctor: TestTtsPlay },\n { tag: 'test-tts-prev', ctor: TestTtsPrev },\n { tag: 'test-tts-resume', ctor: TestTtsResume },\n { tag: 'test-tts-stop', ctor: TestTtsStop },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle }\n] as const;\n"]}
@@ -44,6 +44,10 @@ export const TestBaseMixin = (superClass) => {
44
44
  const newVariables = [...assessmentItem.variables];
45
45
  // Sync the assessment item's variables with the test context
46
46
  for (const variable of itemContext.variables) {
47
+ // Presenting an item starts its first attempt, so it is no longer `not_attempted` once it
48
+ // is on screen: the item keeps its own status (`unknown`) — `qti-number-presented` reads it.
49
+ if (variable.identifier === 'completionStatus' && variable.value === 'not_attempted')
50
+ continue;
47
51
  const currentVariable = newVariables.find(v => v.identifier === variable.identifier);
48
52
  if (currentVariable) {
49
53
  currentVariable.value = variable.value;
@@ -53,6 +57,7 @@ export const TestBaseMixin = (superClass) => {
53
57
  }
54
58
  }
55
59
  assessmentItem.variables = newVariables;
60
+ this.#leaveNotAttempted(identifier, newVariables.find(v => v.identifier === 'completionStatus')?.value);
56
61
  // Opaque interaction state (a PCI's getState()) is read from the item context when the
57
62
  // interaction initializes, so it has to be in place now, before that happens.
58
63
  if (itemContext.state) {
@@ -181,6 +186,24 @@ export const TestBaseMixin = (superClass) => {
181
186
  // Deprecated for hosts, see `@event` on `qti-test`; kept until the next major.
182
187
  this.dispatchEvent(new CustomEvent('qti-test-context-updated', { detail: this.testContext, bubbles: false, composed: false }));
183
188
  }
189
+ /** Write the presented item's own status over a `not_attempted` the test context still holds for it. */
190
+ #leaveNotAttempted(identifier, status) {
191
+ if (typeof status !== 'string' || status === 'not_attempted')
192
+ return;
193
+ const item = this.testContext.items.find(i => i.identifier === identifier);
194
+ const current = item?.variables.find(v => v.identifier === 'completionStatus');
195
+ if (current?.value !== 'not_attempted')
196
+ return;
197
+ this.testContext = {
198
+ ...this.testContext,
199
+ items: this.testContext.items.map(i => i.identifier !== identifier
200
+ ? i
201
+ : {
202
+ ...i,
203
+ variables: i.variables.map(v => (v.identifier === 'completionStatus' ? { ...v, value: status } : v))
204
+ })
205
+ };
206
+ }
184
207
  }
185
208
  __decorate([
186
209
  property({ attribute: false, type: Object }),
@@ -1 +1 @@
1
- {"version":3,"file":"test-base.js","sourceRoot":"","sources":["../../src/mixins/test-base.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAuB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB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AAE,CAAC;qBAC1C,CAAC;gBACJ,CAAC,CAAC;aACH,CAAC;YACF,+EAA+E;YAC/E,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,0BAA0B,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAC3G,CAAC;QACJ,CAAC;KA+CF;IApMQ;QAFN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC5C,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;sDAC+B;IAI1D;QAFN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC5C,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;yDACqC;IAkM5E,OAAO,aAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,2EAA2E;AAC3E,MAAM,OAAgB,QAAS,SAAQ,aAAa,CAAC,UAAU,CAAC;CAAG","sourcesContent":["import { provide } from '@lit/context';\nimport { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { INITIAL_TEST_CONTEXT, testContext } from '@qti-components/base';\nimport { INITIAL_SESSION_CONTEXT, type SessionContext, sessionContext } from '@qti-components/base';\n\nimport { listenPublic } from '../public-events';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { OutcomeVariable, VariableDeclaration, VariableValue } from '@qti-components/base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport interface TestBaseInterface extends LitElement {\n testContext: Readonly<TestContext>;\n sessionContext: Readonly<SessionContext>;\n configContext?: Readonly<ConfigContext>;\n /** Provided by `qti-test`. */\n qtiContext?: Readonly<QtiContext>;\n _testElement: QtiAssessmentTest;\n updateItemVariables(itemRefID: string, variables: readonly ItemVariableValue[], state?: ItemContext['state']): void;\n}\n\n/** A value to set on an item; `type` is only needed for a variable the item does not declare. */\nexport type ItemVariableValue = Pick<VariableValue<string | string[] | null>, 'identifier' | 'value'> &\n Partial<Pick<VariableValue<string | string[] | null>, 'type'>>;\n\nexport const TestBaseMixin = <T extends Constructor<LitElement>>(superClass: T) => {\n abstract class TestBaseClass extends superClass implements TestBaseInterface {\n @property({ attribute: false, type: Object })\n @provide({ context: testContext })\n public testContext: Readonly<TestContext> = INITIAL_TEST_CONTEXT;\n\n @property({ attribute: false, type: Object })\n @provide({ context: sessionContext })\n public sessionContext: Readonly<SessionContext> = INITIAL_SESSION_CONTEXT;\n\n public _testElement: QtiAssessmentTest;\n\n constructor(...args: any[]) {\n super(...args);\n this._initializeEventListeners();\n }\n\n /**\n * Sets values on one item from outside the candidate's session, e.g. a score from manual\n * scoring. Values are merged into the item's entry in the test context, and into the item\n * itself if it is on screen; a value the item has not seen yet is added, so this also works\n * before the item has loaded. To restore a whole session, assign `state` instead.\n *\n * The test context is replaced rather than changed in place, so its consumers update and\n * `qti-state-changed` fires.\n *\n * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.\n * @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.\n */\n updateItemVariables(itemRefID: string, values: readonly ItemVariableValue[], state?: ItemContext['state']): void {\n this.testContext = {\n ...this.testContext,\n items: this.testContext.items.map(item => {\n if (item.identifier !== itemRefID) return item;\n\n const variables = [...(item.variables ?? [])];\n for (const { identifier, type, value } of values) {\n const index = variables.findIndex(v => v.identifier === identifier);\n const updated = {\n ...(index >= 0 ? variables[index] : {}),\n identifier,\n ...(type ? { type } : {}),\n value: Array.isArray(value) ? [...value] : value\n } as VariableDeclaration<string | string[] | null>;\n if (index >= 0) variables[index] = updated;\n else variables.push(updated);\n }\n return { ...item, variables, ...(state ? { state: { ...state } } : {}) };\n })\n };\n\n const assessmentItem = this._testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(itemRefID)}\"]`\n )?.assessmentItem;\n if (!assessmentItem) return;\n assessmentItem.variables = [...(this.testContext.items.find(i => i.identifier === itemRefID)?.variables ?? [])];\n if (state) assessmentItem.state = state;\n }\n\n private _initializeEventListeners(): void {\n /**\n * A new test document means a new test and session context.\n *\n * This resets on the document being loaded rather than on\n * `qti-assessment-test-connected`, because the new document's children —\n * test-level `qti-outcome-declaration` among them — connect and register\n * themselves into the context *before* the test element announces itself.\n * Resetting on that announcement discarded every one of those\n * registrations, so no test-level outcome could be read or set.\n */\n this.addEventListener('qti-testdoc-loaded', () => {\n this.testContext = INITIAL_TEST_CONTEXT;\n this.sessionContext = INITIAL_SESSION_CONTEXT;\n });\n\n /**\n * When the test is connected, its item-refs are added to the test context.\n * Registrations from the document's children are already present on the\n * context reset above, so this must preserve what is there.\n */\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => {\n this._testElement = e.detail;\n const items = Array.from(this._testElement.querySelectorAll('qti-assessment-item-ref')).map(itemRef => {\n return {\n href: itemRef.href,\n identifier: itemRef.identifier,\n category: itemRef.category,\n variables: [\n {\n identifier: 'completionStatus',\n value: 'not_attempted',\n type: 'outcome'\n } as OutcomeVariable\n ]\n };\n });\n this.testContext = { ...this.testContext, items };\n });\n\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent<QtiAssessmentItem>) => {\n const assessmentItem = e.detail as QtiAssessmentItem;\n const assessmentRefId = assessmentItem.closest('qti-assessment-item-ref')?.identifier;\n if (assessmentRefId) {\n assessmentItem.assessmentItemRefId = assessmentRefId;\n }\n this._updateItemInTestContext(e.detail);\n });\n\n this.addEventListener('qti-item-context-updated', (e: CustomEvent<{ itemContext: ItemContext }>) => {\n // const assessmentitem = e.composedPath()[0] as QtiAssessmentItem;\n this._updateItemVariablesInTestContext(\n e.detail.itemContext.identifier,\n e.detail.itemContext.variables,\n e.detail.itemContext.state,\n e.detail.itemContext.valid\n );\n });\n }\n\n private _updateItemVariablesInTestContext(\n identifier: string,\n variables: readonly VariableDeclaration<string | string[] | null>[],\n state?: ItemContext['state'],\n valid?: boolean\n ): void {\n // Update the test context with modified variables for the specified item\n this.testContext = {\n ...this.testContext, // Spread existing test context properties\n items: this.testContext.items.map(itemContext => {\n // If the item identifier doesn't match, keep it unchanged\n if (itemContext.identifier !== identifier) {\n return itemContext;\n }\n\n // Update the matching item with new variables\n return {\n ...itemContext, // Keep other properties of the item context\n variables: variables.map(variable => {\n // Find a matching variable in the current item context\n const matchingVariable = itemContext.variables.find(v => v.identifier === variable.identifier);\n\n // Merge matching variable with the new one, or use the new variable if no match\n return matchingVariable ? { ...matchingVariable, ...variable } : variable;\n }),\n ...(state !== undefined ? { state: state ? { ...state } : undefined } : {}),\n ...(valid !== undefined ? { valid } : {})\n };\n })\n };\n // Deprecated for hosts, see `@event` on `qti-test`; kept until the next major.\n this.dispatchEvent(\n new CustomEvent('qti-test-context-updated', { detail: this.testContext, bubbles: false, composed: false })\n );\n }\n\n /**\n * Updates the variables of an assessment item in the test context.\n * - Matches the assessment item with the corresponding test context item.\n * - If the item is not found, logs a warning.\n * - Updates variables in the test context if exactly one variable exists.\n * - Otherwise, syncs the assessment item's variables with the test context.\n *\n * @param assessmentItem - The assessment item to update.\n */\n private _updateItemInTestContext = (assessmentItem: QtiAssessmentItem): void => {\n const context = assessmentItem.itemContext;\n const identifier = context.identifier;\n const fullVariables = context.variables;\n\n // Find the corresponding item in the test context by identifier\n const itemContext = this.testContext.items.find(i => i?.identifier === identifier);\n\n if (!itemContext) {\n console.warn(`Item IDs between assessment.xml and item.xml should match: ${identifier} is not found!`);\n return;\n }\n\n // Update variables in the test context or sync them to the assessment item\n if (itemContext.variables?.length === 1) {\n // The loaded qti-assessment-item itself has variables which are not in test context yet.\n this._updateItemVariablesInTestContext(identifier, fullVariables, undefined, context.valid);\n } else {\n const newVariables = [...assessmentItem.variables];\n // Sync the assessment item's variables with the test context\n for (const variable of itemContext.variables) {\n const currentVariable = newVariables.find(v => v.identifier === variable.identifier);\n if (currentVariable) {\n currentVariable.value = variable.value;\n } else {\n newVariables.push(variable);\n }\n }\n assessmentItem.variables = newVariables;\n // Opaque interaction state (a PCI's getState()) is read from the item context when the\n // interaction initializes, so it has to be in place now, before that happens.\n if (itemContext.state) {\n assessmentItem.state = itemContext.state;\n }\n }\n };\n }\n\n return TestBaseClass as Constructor<TestBaseInterface> & T;\n};\n\n// Keep the old abstract class for backwards compatibility during migration\nexport abstract class TestBase extends TestBaseMixin(LitElement) {}\n"]}
1
+ {"version":3,"file":"test-base.js","sourceRoot":"","sources":["../../src/mixins/test-base.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAuB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0BhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAoC,UAAa,EAAE,EAAE;IAChF,MAAe,aAAc,SAAQ,UAAU;QAW7C,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YATV,gBAAW,GAA0B,oBAAoB,CAAC;YAI1D,mBAAc,GAA6B,uBAAuB,CAAC;YAmJ1E;;;;;;;;eAQG;YACK,6BAAwB,GAAG,CAAC,cAAiC,EAAQ,EAAE;gBAC7E,MAAM,OAAO,GAAG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AI,EAAE,MAAM,EAAE,CAAC;QAC5C,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;sDAC+B;IAI1D;QAFN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC5C,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;yDACqC;IAyN5E,OAAO,aAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,2EAA2E;AAC3E,MAAM,OAAgB,QAAS,SAAQ,aAAa,CAAC,UAAU,CAAC;CAAG","sourcesContent":["import { provide } from '@lit/context';\nimport { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { INITIAL_TEST_CONTEXT, testContext } from '@qti-components/base';\nimport { INITIAL_SESSION_CONTEXT, type SessionContext, sessionContext } from '@qti-components/base';\n\nimport { listenPublic } from '../public-events';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { OutcomeVariable, VariableDeclaration, VariableValue } from '@qti-components/base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport interface TestBaseInterface extends LitElement {\n testContext: Readonly<TestContext>;\n sessionContext: Readonly<SessionContext>;\n configContext?: Readonly<ConfigContext>;\n /** Provided by `qti-test`. */\n qtiContext?: Readonly<QtiContext>;\n _testElement: QtiAssessmentTest;\n updateItemVariables(itemRefID: string, variables: readonly ItemVariableValue[], state?: ItemContext['state']): void;\n}\n\n/** A value to set on an item; `type` is only needed for a variable the item does not declare. */\nexport type ItemVariableValue = Pick<VariableValue<string | string[] | null>, 'identifier' | 'value'> &\n Partial<Pick<VariableValue<string | string[] | null>, 'type'>>;\n\nexport const TestBaseMixin = <T extends Constructor<LitElement>>(superClass: T) => {\n abstract class TestBaseClass extends superClass implements TestBaseInterface {\n @property({ attribute: false, type: Object })\n @provide({ context: testContext })\n public testContext: Readonly<TestContext> = INITIAL_TEST_CONTEXT;\n\n @property({ attribute: false, type: Object })\n @provide({ context: sessionContext })\n public sessionContext: Readonly<SessionContext> = INITIAL_SESSION_CONTEXT;\n\n public _testElement: QtiAssessmentTest;\n\n constructor(...args: any[]) {\n super(...args);\n this._initializeEventListeners();\n }\n\n /**\n * Sets values on one item from outside the candidate's session, e.g. a score from manual\n * scoring. Values are merged into the item's entry in the test context, and into the item\n * itself if it is on screen; a value the item has not seen yet is added, so this also works\n * before the item has loaded. To restore a whole session, assign `state` instead.\n *\n * The test context is replaced rather than changed in place, so its consumers update and\n * `qti-state-changed` fires.\n *\n * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.\n * @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.\n */\n updateItemVariables(itemRefID: string, values: readonly ItemVariableValue[], state?: ItemContext['state']): void {\n this.testContext = {\n ...this.testContext,\n items: this.testContext.items.map(item => {\n if (item.identifier !== itemRefID) return item;\n\n const variables = [...(item.variables ?? [])];\n for (const { identifier, type, value } of values) {\n const index = variables.findIndex(v => v.identifier === identifier);\n const updated = {\n ...(index >= 0 ? variables[index] : {}),\n identifier,\n ...(type ? { type } : {}),\n value: Array.isArray(value) ? [...value] : value\n } as VariableDeclaration<string | string[] | null>;\n if (index >= 0) variables[index] = updated;\n else variables.push(updated);\n }\n return { ...item, variables, ...(state ? { state: { ...state } } : {}) };\n })\n };\n\n const assessmentItem = this._testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(itemRefID)}\"]`\n )?.assessmentItem;\n if (!assessmentItem) return;\n assessmentItem.variables = [...(this.testContext.items.find(i => i.identifier === itemRefID)?.variables ?? [])];\n if (state) assessmentItem.state = state;\n }\n\n private _initializeEventListeners(): void {\n /**\n * A new test document means a new test and session context.\n *\n * This resets on the document being loaded rather than on\n * `qti-assessment-test-connected`, because the new document's children —\n * test-level `qti-outcome-declaration` among them — connect and register\n * themselves into the context *before* the test element announces itself.\n * Resetting on that announcement discarded every one of those\n * registrations, so no test-level outcome could be read or set.\n */\n this.addEventListener('qti-testdoc-loaded', () => {\n this.testContext = INITIAL_TEST_CONTEXT;\n this.sessionContext = INITIAL_SESSION_CONTEXT;\n });\n\n /**\n * When the test is connected, its item-refs are added to the test context.\n * Registrations from the document's children are already present on the\n * context reset above, so this must preserve what is there.\n */\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => {\n this._testElement = e.detail;\n const items = Array.from(this._testElement.querySelectorAll('qti-assessment-item-ref')).map(itemRef => {\n return {\n href: itemRef.href,\n identifier: itemRef.identifier,\n category: itemRef.category,\n variables: [\n {\n identifier: 'completionStatus',\n value: 'not_attempted',\n type: 'outcome'\n } as OutcomeVariable\n ]\n };\n });\n this.testContext = { ...this.testContext, items };\n });\n\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent<QtiAssessmentItem>) => {\n const assessmentItem = e.detail as QtiAssessmentItem;\n const assessmentRefId = assessmentItem.closest('qti-assessment-item-ref')?.identifier;\n if (assessmentRefId) {\n assessmentItem.assessmentItemRefId = assessmentRefId;\n }\n this._updateItemInTestContext(e.detail);\n });\n\n this.addEventListener('qti-item-context-updated', (e: CustomEvent<{ itemContext: ItemContext }>) => {\n // const assessmentitem = e.composedPath()[0] as QtiAssessmentItem;\n this._updateItemVariablesInTestContext(\n e.detail.itemContext.identifier,\n e.detail.itemContext.variables,\n e.detail.itemContext.state,\n e.detail.itemContext.valid\n );\n });\n }\n\n private _updateItemVariablesInTestContext(\n identifier: string,\n variables: readonly VariableDeclaration<string | string[] | null>[],\n state?: ItemContext['state'],\n valid?: boolean\n ): void {\n // Update the test context with modified variables for the specified item\n this.testContext = {\n ...this.testContext, // Spread existing test context properties\n items: this.testContext.items.map(itemContext => {\n // If the item identifier doesn't match, keep it unchanged\n if (itemContext.identifier !== identifier) {\n return itemContext;\n }\n\n // Update the matching item with new variables\n return {\n ...itemContext, // Keep other properties of the item context\n variables: variables.map(variable => {\n // Find a matching variable in the current item context\n const matchingVariable = itemContext.variables.find(v => v.identifier === variable.identifier);\n\n // Merge matching variable with the new one, or use the new variable if no match\n return matchingVariable ? { ...matchingVariable, ...variable } : variable;\n }),\n ...(state !== undefined ? { state: state ? { ...state } : undefined } : {}),\n ...(valid !== undefined ? { valid } : {})\n };\n })\n };\n // Deprecated for hosts, see `@event` on `qti-test`; kept until the next major.\n this.dispatchEvent(\n new CustomEvent('qti-test-context-updated', { detail: this.testContext, bubbles: false, composed: false })\n );\n }\n\n /**\n * Updates the variables of an assessment item in the test context.\n * - Matches the assessment item with the corresponding test context item.\n * - If the item is not found, logs a warning.\n * - Updates variables in the test context if exactly one variable exists.\n * - Otherwise, syncs the assessment item's variables with the test context.\n *\n * @param assessmentItem - The assessment item to update.\n */\n private _updateItemInTestContext = (assessmentItem: QtiAssessmentItem): void => {\n const context = assessmentItem.itemContext;\n const identifier = context.identifier;\n const fullVariables = context.variables;\n\n // Find the corresponding item in the test context by identifier\n const itemContext = this.testContext.items.find(i => i?.identifier === identifier);\n\n if (!itemContext) {\n console.warn(`Item IDs between assessment.xml and item.xml should match: ${identifier} is not found!`);\n return;\n }\n\n // Update variables in the test context or sync them to the assessment item\n if (itemContext.variables?.length === 1) {\n // The loaded qti-assessment-item itself has variables which are not in test context yet.\n this._updateItemVariablesInTestContext(identifier, fullVariables, undefined, context.valid);\n } else {\n const newVariables = [...assessmentItem.variables];\n // Sync the assessment item's variables with the test context\n for (const variable of itemContext.variables) {\n // Presenting an item starts its first attempt, so it is no longer `not_attempted` once it\n // is on screen: the item keeps its own status (`unknown`) — `qti-number-presented` reads it.\n if (variable.identifier === 'completionStatus' && variable.value === 'not_attempted') continue;\n const currentVariable = newVariables.find(v => v.identifier === variable.identifier);\n if (currentVariable) {\n currentVariable.value = variable.value;\n } else {\n newVariables.push(variable);\n }\n }\n assessmentItem.variables = newVariables;\n this.#leaveNotAttempted(identifier, newVariables.find(v => v.identifier === 'completionStatus')?.value);\n // Opaque interaction state (a PCI's getState()) is read from the item context when the\n // interaction initializes, so it has to be in place now, before that happens.\n if (itemContext.state) {\n assessmentItem.state = itemContext.state;\n }\n }\n };\n\n /** Write the presented item's own status over a `not_attempted` the test context still holds for it. */\n #leaveNotAttempted(identifier: string, status: Readonly<string | string[] | null> | undefined): void {\n if (typeof status !== 'string' || status === 'not_attempted') return;\n const item = this.testContext.items.find(i => i.identifier === identifier);\n const current = item?.variables.find(v => v.identifier === 'completionStatus');\n if (current?.value !== 'not_attempted') return;\n this.testContext = {\n ...this.testContext,\n items: this.testContext.items.map(i =>\n i.identifier !== identifier\n ? i\n : {\n ...i,\n variables: i.variables.map(v => (v.identifier === 'completionStatus' ? { ...v, value: status } : v))\n }\n )\n };\n }\n }\n\n return TestBaseClass as Constructor<TestBaseInterface> & T;\n};\n\n// Keep the old abstract class for backwards compatibility during migration\nexport abstract class TestBase extends TestBaseMixin(LitElement) {}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { QtiTestFeedback } from '../components/qti-test-feedback/qti-test-feedback';
1
2
  import type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';
2
3
  import type { TestBaseInterface } from './test-base';
3
4
  type Constructor<T = {}> = abstract new (...args: any[]) => T;
@@ -6,6 +7,7 @@ declare class TestProcessingInterface {
6
7
  getOutcome(identifier: string): Readonly<OutcomeVariable>;
7
8
  getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;
8
9
  outcomeProcessing(): boolean;
10
+ getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[];
9
11
  }
10
12
  export declare const TestProcessingMixin: <T extends Constructor<TestBaseInterface>>(superClass: T) => Constructor<TestProcessingInterface> & T;
11
13
  export {};
@@ -25,6 +25,15 @@ export const TestProcessingMixin = (superClass) => {
25
25
  outcomeProcessor?.process();
26
26
  return true;
27
27
  }
28
+ /**
29
+ * The `qti-test-feedback` elements that apply now, read from the test outcomes: run
30
+ * `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to
31
+ * while it runs (`during`); without it, both.
32
+ */
33
+ getTestFeedback(access) {
34
+ const feedback = Array.from((this._testElement ?? this).querySelectorAll('qti-test-feedback') ?? []);
35
+ return feedback.filter(fb => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value));
36
+ }
28
37
  /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */
29
38
  updateOutcomeVariable(identifier, value) {
30
39
  const outcomeVariable = this.getOutcome(identifier);
@@ -1 +1 @@
1
- {"version":3,"file":"test-processing.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-processing.mixin.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2C,UAAa,EAAE,EAAE;IAC7F,MAAe,qBAAsB,SAAQ,UAAU;QACrD,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,CAAC,CAAiC,EAAE,EAAE;gBACnF,IAAI,CAAC,WAAW,GAAG;oBACjB,GAAG,IAAI,CAAC,WAAW;oBACnB,oBAAoB,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;iBAC5F,CAAC;gBACF,CAAC,CAAC,eAAe,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;YACH,iDAAiD;YACjD,IAAI,CAAC,gBAAgB,CACnB,uBAAuB,EACvB,CAAC,CAAuE,EAAE,EAAE;gBAC1E,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;gBAC9C,IAAI,CA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nC,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;QAC/F,CAAC;KAEF;IAED,OAAO,qBAAiE,CAAC;AAC3E,CAAC,CAAC","sourcesContent":["import type { QtiOutcomeProcessing } from '../components/qti-outcome-processing/qti-outcome-processing';\nimport type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestProcessingInterface {\n updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;\n getOutcome(identifier: string): Readonly<OutcomeVariable>;\n getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;\n outcomeProcessing(): boolean;\n}\nexport const TestProcessingMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestProcessingElement extends superClass implements TestProcessingInterface {\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-register-variable', (e: CustomEvent<{ variable: any }>) => {\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: [...(this.testContext.testOutcomeVariables || []), e.detail.variable]\n };\n e.stopPropagation();\n });\n // wordt aangeroepen vanuit de processingtemplate\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n }\n );\n }\n\n outcomeProcessing(): boolean {\n // Inside the loaded test: `test-container` renders it into its own shadow root, which a\n // `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.\n const outcomeProcessor = (this._testElement ?? this).querySelector(\n 'qti-outcome-processing'\n ) as unknown as QtiOutcomeProcessing;\n if (!outcomeProcessor) return false;\n outcomeProcessor?.process();\n return true;\n }\n\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : [...v.value, value as string]\n };\n })\n };\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n public getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this.testContext.testOutcomeVariables?.find(v => v.identifier === identifier) || null;\n }\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n }\n\n return TestProcessingElement as Constructor<TestProcessingInterface> & T;\n};\n"]}
1
+ {"version":3,"file":"test-processing.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-processing.mixin.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2C,UAAa,EAAE,EAAE;IAC7F,MAAe,qBAAsB,SAAQ,UAAU;QACrD,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,CAAC,CAAiC,EAAE,EAAE;gBACnF,IAAI,CAAC,WAAW,GAAG;oBACjB,GAAG,IAAI,CAAC,WAAW;oBACnB,oBAAoB,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;iBAC5F,CAAC;gBACF,CAAC,CAAC,eAAe,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;YACH,iDAAiD;YACjD,IAAI,CAAC,gBAAgB,CACnB,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,GAAG;gBACjB,GAAG,IAAI,CAAC,WAAW;gBACnB,oBAAoB,EAAE,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE;oBACnE,IAAI,CAAC,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;wBAChC,OAAO,CAAC,CAAC;oBACX,CAAC;oBACD,OAAO;wBACL,GAAG,CAAC;wBACJ,KAAK,EAAE,eAAe,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAe,CAAC;qBACxF,CAAC;gBACJ,CAAC,CAAC;aACH,CAAC;QACJ,CAAC;QAEM,UAAU,CAAC,UAAkB;YAClC,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAoB,CAAC;QACzD,CAAC;QACM,WAAW,CAAC,UAAkB;YACnC,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;QAC/F,CAAC;KAEF;IAED,OAAO,qBAAiE,CAAC;AAC3E,CAAC,CAAC","sourcesContent":["import type { QtiOutcomeProcessing } from '../components/qti-outcome-processing/qti-outcome-processing';\nimport type { QtiTestFeedback } from '../components/qti-test-feedback/qti-test-feedback';\nimport type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestProcessingInterface {\n updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;\n getOutcome(identifier: string): Readonly<OutcomeVariable>;\n getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;\n outcomeProcessing(): boolean;\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[];\n}\nexport const TestProcessingMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestProcessingElement extends superClass implements TestProcessingInterface {\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-register-variable', (e: CustomEvent<{ variable: any }>) => {\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: [...(this.testContext.testOutcomeVariables || []), e.detail.variable]\n };\n e.stopPropagation();\n });\n // wordt aangeroepen vanuit de processingtemplate\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n }\n );\n }\n\n outcomeProcessing(): boolean {\n // Inside the loaded test: `test-container` renders it into its own shadow root, which a\n // `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.\n const outcomeProcessor = (this._testElement ?? this).querySelector(\n 'qti-outcome-processing'\n ) as unknown as QtiOutcomeProcessing;\n if (!outcomeProcessor) return false;\n outcomeProcessor?.process();\n return true;\n }\n\n /**\n * The `qti-test-feedback` elements that apply now, read from the test outcomes: run\n * `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to\n * while it runs (`during`); without it, both.\n */\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[] {\n const feedback = Array.from(\n (this._testElement ?? this).querySelectorAll<QtiTestFeedback>('qti-test-feedback') ?? []\n );\n return feedback.filter(\n fb => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value)\n );\n }\n\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : [...v.value, value as string]\n };\n })\n };\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n public getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this.testContext.testOutcomeVariables?.find(v => v.identifier === identifier) || null;\n }\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n }\n\n return TestProcessingElement as Constructor<TestProcessingInterface> & T;\n};\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qti-components/test",
3
3
  "description": "QTI test utilities",
4
- "version": "1.10.0-next.2",
4
+ "version": "1.10.0-next.3",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",