@qti-components/test 2.0.0-next.6 → 2.0.0-next.8
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.
- package/dist/components/qti-test/qti-test.d.ts +1 -0
- package/dist/components/test-print-item-variables/test-print-item-variables.d.ts +5 -0
- package/dist/components/test-print-item-variables/test-print-item-variables.js +19 -7
- package/dist/components/test-print-item-variables/test-print-item-variables.js.map +1 -1
- package/dist/components/test-submit/test-submit.d.ts +16 -0
- package/dist/components/test-submit/test-submit.js +32 -0
- package/dist/components/test-submit/test-submit.js.map +1 -0
- package/dist/elements.d.ts +3 -0
- package/dist/mixins/test-processing.mixin.d.ts +1 -0
- package/dist/mixins/test-processing.mixin.js +22 -1
- package/dist/mixins/test-processing.mixin.js.map +1 -1
- package/dist/plugins/elements.d.ts +5 -1
- package/dist/plugins/elements.js +3 -1
- package/dist/plugins/elements.js.map +1 -1
- package/dist/public-events.d.ts +4 -0
- package/dist/public-events.js +2 -0
- package/dist/public-events.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
+
submit(): boolean;
|
|
10
11
|
getTestFeedback(access?: "atEnd" | "during"): import("..").QtiTestFeedback[];
|
|
11
12
|
}) & (abstract new (...args: any[]) => import("../..").ITestStateMixin) & (abstract new (...args: any[]) => import("../../mixins").TestBaseInterface) & typeof LitElement;
|
|
12
13
|
/**
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import type { ComputedContext } from '@qti-components/base';
|
|
3
|
+
/**
|
|
4
|
+
* A variable value as text: a list as `a, b`, a record (e.g. the response of a PCI) as `time: 3.6, point: 455 250`.
|
|
5
|
+
* Without this a record printed as "[object Object]".
|
|
6
|
+
*/
|
|
7
|
+
export declare const formatVariableValue: (value: unknown) => string;
|
|
3
8
|
export declare class TestPrintVariables extends LitElement {
|
|
4
9
|
computedContext?: ComputedContext;
|
|
5
10
|
static styles: import("lit").CSSResult;
|
|
@@ -6,7 +6,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { html, css, LitElement } from 'lit';
|
|
8
8
|
import { consume } from '@lit/context';
|
|
9
|
-
import { computedContext } from '@qti-components/base';
|
|
9
|
+
import { computedContext, isRecordValue } from '@qti-components/base';
|
|
10
|
+
/**
|
|
11
|
+
* A variable value as text: a list as `a, b`, a record (e.g. the response of a PCI) as `time: 3.6, point: 455 250`.
|
|
12
|
+
* Without this a record printed as "[object Object]".
|
|
13
|
+
*/
|
|
14
|
+
export const formatVariableValue = (value) => {
|
|
15
|
+
if (value === null || value === undefined)
|
|
16
|
+
return '';
|
|
17
|
+
if (Array.isArray(value))
|
|
18
|
+
return value.map(formatVariableValue).join(', ');
|
|
19
|
+
if (isRecordValue(value)) {
|
|
20
|
+
return Object.entries(value)
|
|
21
|
+
.map(([field, fieldValue]) => `${field}: ${formatVariableValue(fieldValue)}`)
|
|
22
|
+
.join(', ');
|
|
23
|
+
}
|
|
24
|
+
return String(value);
|
|
25
|
+
};
|
|
10
26
|
export class TestPrintVariables extends LitElement {
|
|
11
27
|
static { this.styles = css `
|
|
12
28
|
table {
|
|
@@ -52,17 +68,13 @@ export class TestPrintVariables extends LitElement {
|
|
|
52
68
|
</thead>
|
|
53
69
|
<tbody>
|
|
54
70
|
${variables.map(v => {
|
|
55
|
-
const correctResponse = v.correctResponse
|
|
56
|
-
? Array.isArray(v.correctResponse)
|
|
57
|
-
? v.correctResponse.join(', ')
|
|
58
|
-
: v.correctResponse
|
|
59
|
-
: '';
|
|
71
|
+
const correctResponse = formatVariableValue(v.correctResponse);
|
|
60
72
|
const mapEntries = v.mapping?.mapEntries?.map(m => `${m.mapKey}=${m.mappedValue}pt`).join(', ') || '';
|
|
61
73
|
const areaMapEntries = v.areaMapping?.areaMapEntries?.map(m => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(', ') || '';
|
|
62
74
|
return html `
|
|
63
75
|
<tr>
|
|
64
76
|
<td>${v.identifier}</td>
|
|
65
|
-
<td>${
|
|
77
|
+
<td>${formatVariableValue(v.value)}</td>
|
|
66
78
|
<td>${v.cardinality}</td>
|
|
67
79
|
<td>${v.baseType}</td>
|
|
68
80
|
<td>${correctResponse || mapEntries || areaMapEntries}</td>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-print-item-variables.js","sourceRoot":"","sources":["../../../src/components/test-print-item-variables/test-print-item-variables.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"test-print-item-variables.js","sourceRoot":"","sources":["../../../src/components/test-print-item-variables/test-print-item-variables.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKtE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAU,EAAE;IAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,mB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S,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAClB,MAAM,eAAe,GAAG,mBAAmB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;YAE/D,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAEtG,MAAM,cAAc,GAClB,CAAC,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAEzG,OAAO,IAAI,CAAA;;sBAED,CAAC,CAAC,UAAU;sBACZ,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;sBAC5B,CAAC,CAAC,WAAW;sBACb,CAAC,CAAC,QAAQ;sBACV,eAAe,IAAI,UAAU,IAAI,cAAc;;aAExD,CAAC;QACJ,CAAC,CAAC;;;KAGP,CAAC;QAEF,OAAO,IAAI,CAAA;QACP,WAAW,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,IAAI,WAAW,CAAC,gBAAgB,EAAE,mBAAmB,CAAC;KAC7G,CAAC;IACJ,CAAC;;AAzEM;IADN,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;2DACd","sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { consume } from '@lit/context';\n\nimport { computedContext, isRecordValue } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\nimport type { ComputedContext } from '@qti-components/base';\n\n/**\n * A variable value as text: a list as `a, b`, a record (e.g. the response of a PCI) as `time: 3.6, point: 455 250`.\n * Without this a record printed as \"[object Object]\".\n */\nexport const formatVariableValue = (value: unknown): string => {\n if (value === null || value === undefined) return '';\n if (Array.isArray(value)) return value.map(formatVariableValue).join(', ');\n if (isRecordValue(value)) {\n return Object.entries(value)\n .map(([field, fieldValue]) => `${field}: ${formatVariableValue(fieldValue)}`)\n .join(', ');\n }\n return String(value);\n};\n\nexport class TestPrintVariables extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n public computedContext?: ComputedContext;\n\n static override styles = css`\n table {\n width: 100%;\n border-collapse: collapse;\n margin: 20px 0;\n font-size: 14px;\n text-align: left;\n }\n th,\n td {\n border: 1px solid #ddd;\n padding: 8px;\n }\n th {\n background-color: #f4f4f4;\n font-weight: bold;\n }\n h3 {\n margin-top: 20px;\n font-size: 16px;\n }\n `;\n\n override render() {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const responseVariables: ResponseVariable[] = activeItem.variables.filter(v => v.type === 'response');\n const outcomeVariables = activeItem.variables.filter(v => v.type === 'outcome');\n\n const renderTable = (variables: ResponseVariable[], title: string) => html`\n <h3>${title}</h3>\n <table>\n <thead>\n <tr>\n <th>Identifier</th>\n <th>Value</th>\n <th>Cardinality</th>\n <th>Base Type</th>\n <th>Correct Response / Mappings</th>\n </tr>\n </thead>\n <tbody>\n ${variables.map(v => {\n const correctResponse = formatVariableValue(v.correctResponse);\n\n const mapEntries = v.mapping?.mapEntries?.map(m => `${m.mapKey}=${m.mappedValue}pt`).join(', ') || '';\n\n const areaMapEntries =\n v.areaMapping?.areaMapEntries?.map(m => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(', ') || '';\n\n return html`\n <tr>\n <td>${v.identifier}</td>\n <td>${formatVariableValue(v.value)}</td>\n <td>${v.cardinality}</td>\n <td>${v.baseType}</td>\n <td>${correctResponse || mapEntries || areaMapEntries}</td>\n </tr>\n `;\n })}\n </tbody>\n </table>\n `;\n\n return html`\n ${renderTable(responseVariables, 'Response Variables')} ${renderTable(outcomeVariables, 'Outcome Variables')}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-print-item-variables': TestPrintVariables;\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Scores the test: on click the test resets its outcomes to their declared defaults, runs its
|
|
4
|
+
* outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.
|
|
5
|
+
* The host decides where it sits, for example on the last item or in a review view.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TestSubmit extends LitElement {
|
|
8
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
constructor();
|
|
10
|
+
render(): import("lit").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'test-submit': TestSubmit;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
|
2
|
+
import * as styles from '../styles';
|
|
3
|
+
import { dispatchPublic } from '../../public-events';
|
|
4
|
+
/**
|
|
5
|
+
* Scores the test: on click the test resets its outcomes to their declared defaults, runs its
|
|
6
|
+
* outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.
|
|
7
|
+
* The host decides where it sits, for example on the last item or in a review view.
|
|
8
|
+
*/
|
|
9
|
+
export class TestSubmit extends LitElement {
|
|
10
|
+
static { this.styles = css `
|
|
11
|
+
:host {
|
|
12
|
+
${styles.btn};
|
|
13
|
+
}
|
|
14
|
+
:host(:hover:not([disabled])) {
|
|
15
|
+
${styles.btnInteractive};
|
|
16
|
+
}
|
|
17
|
+
:host(:focus-visible) {
|
|
18
|
+
${styles.focusRing};
|
|
19
|
+
}
|
|
20
|
+
:host([disabled]) {
|
|
21
|
+
${styles.dis};
|
|
22
|
+
}
|
|
23
|
+
`; }
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.addEventListener('click', () => dispatchPublic(this, 'cito-test-submit', {}));
|
|
27
|
+
}
|
|
28
|
+
render() {
|
|
29
|
+
return html ` <slot></slot> `;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=test-submit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-submit.js","sourceRoot":"","sources":["../../../src/components/test-submit/test-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;aACxB,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\n/**\n * Scores the test: on click the test resets its outcomes to their declared defaults, runs its\n * outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.\n * The host decides where it sits, for example on the last item or in a review view.\n */\nexport class TestSubmit extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => dispatchPublic(this, 'cito-test-submit', {}));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-submit': TestSubmit;\n }\n}\n"]}
|
package/dist/elements.d.ts
CHANGED
|
@@ -101,6 +101,9 @@ export declare const qtiTestElements: readonly [{
|
|
|
101
101
|
}, {
|
|
102
102
|
readonly tag: "test-stamp";
|
|
103
103
|
readonly ctor: typeof import("./elements").TestStamp;
|
|
104
|
+
}, {
|
|
105
|
+
readonly tag: "test-submit";
|
|
106
|
+
readonly ctor: typeof import("./elements").TestSubmit;
|
|
104
107
|
}, {
|
|
105
108
|
readonly tag: "test-view";
|
|
106
109
|
readonly ctor: typeof import("./elements").TestView;
|
|
@@ -7,6 +7,7 @@ declare class TestProcessingInterface {
|
|
|
7
7
|
getOutcome(identifier: string): Readonly<OutcomeVariable>;
|
|
8
8
|
getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;
|
|
9
9
|
outcomeProcessing(): boolean;
|
|
10
|
+
submit(): boolean;
|
|
10
11
|
getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[];
|
|
11
12
|
}
|
|
12
13
|
export declare const TestProcessingMixin: <T extends Constructor<TestBaseInterface>>(superClass: T) => Constructor<TestProcessingInterface> & T;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dispatchPublic, listenPublic } from '../public-events';
|
|
1
2
|
export const TestProcessingMixin = (superClass) => {
|
|
2
3
|
class TestProcessingElement extends superClass {
|
|
3
4
|
constructor(...args) {
|
|
@@ -9,6 +10,7 @@ export const TestProcessingMixin = (superClass) => {
|
|
|
9
10
|
};
|
|
10
11
|
e.stopPropagation();
|
|
11
12
|
});
|
|
13
|
+
listenPublic(this, 'cito-test-submit', () => this.submit());
|
|
12
14
|
// wordt aangeroepen vanuit de processingtemplate
|
|
13
15
|
this.addEventListener('qti-set-outcome-value', (e) => {
|
|
14
16
|
const { outcomeIdentifier, value } = e.detail;
|
|
@@ -22,7 +24,26 @@ export const TestProcessingMixin = (superClass) => {
|
|
|
22
24
|
const outcomeProcessor = (this._testElement ?? this).querySelector('qti-outcome-processing');
|
|
23
25
|
if (!outcomeProcessor)
|
|
24
26
|
return false;
|
|
25
|
-
|
|
27
|
+
// QTI starts every run of the test's outcome processing from the declared defaults, so an
|
|
28
|
+
// accumulating rule (`SCORE_TOTAL = sum + SCORE_TOTAL`) gives the same total on every run.
|
|
29
|
+
this.testContext = {
|
|
30
|
+
...this.testContext,
|
|
31
|
+
testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => ({
|
|
32
|
+
...v,
|
|
33
|
+
value: v.defaultValue ?? null
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
outcomeProcessor.process();
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with
|
|
41
|
+
* `cito-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.
|
|
42
|
+
*/
|
|
43
|
+
submit() {
|
|
44
|
+
if (!this.outcomeProcessing())
|
|
45
|
+
return false;
|
|
46
|
+
dispatchPublic(this, 'cito-test-submitted', {});
|
|
26
47
|
return true;
|
|
27
48
|
}
|
|
28
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-processing.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-processing.mixin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-processing.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-processing.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiBhE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2C,UAAa,EAAE,EAAE;IAC7F,MAAe,qBAAsB,SAA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C;wBAChC,OAAO,CAAC,CAAC;oBACX,CAAC;oBACD,OAAO;wBACL,GAAG,CAAC;wBACJ,KAAK,EAAE,eAAe,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAe,CAAC;qBACxF,CAAC;gBACJ,CAAC,CAAC;aACH,CAAC;QACJ,CAAC;QAEM,UAAU,CAAC,UAAkB;YAClC,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAoB,CAAC;QACzD,CAAC;QACM,WAAW,CAAC,UAAkB;YACnC,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;QAC/F,CAAC;KAEF;IAED,OAAO,qBAAiE,CAAC;AAC3E,CAAC,CAAC","sourcesContent":["import { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { QtiOutcomeProcessing } from '../components/qti-outcome-processing/qti-outcome-processing';\nimport type { QtiTestFeedback } from '../components/qti-test-feedback/qti-test-feedback';\nimport type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestProcessingInterface {\n updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;\n getOutcome(identifier: string): Readonly<OutcomeVariable>;\n getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;\n outcomeProcessing(): boolean;\n submit(): boolean;\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[];\n}\nexport const TestProcessingMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestProcessingElement extends superClass implements TestProcessingInterface {\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-register-variable', (e: CustomEvent<{ variable: any }>) => {\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: [...(this.testContext.testOutcomeVariables || []), e.detail.variable]\n };\n e.stopPropagation();\n });\n listenPublic(this, 'cito-test-submit', () => this.submit());\n // wordt aangeroepen vanuit de processingtemplate\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n }\n );\n }\n\n outcomeProcessing(): boolean {\n // Inside the loaded test: `test-container` renders it into its own shadow root, which a\n // `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.\n const outcomeProcessor = (this._testElement ?? this).querySelector(\n 'qti-outcome-processing'\n ) as unknown as QtiOutcomeProcessing;\n if (!outcomeProcessor) return false;\n // QTI starts every run of the test's outcome processing from the declared defaults, so an\n // accumulating rule (`SCORE_TOTAL = sum + SCORE_TOTAL`) gives the same total on every run.\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => ({\n ...v,\n value: v.defaultValue ?? null\n }))\n };\n outcomeProcessor.process();\n return true;\n }\n\n /**\n * Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with\n * `cito-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.\n */\n submit(): boolean {\n if (!this.outcomeProcessing()) return false;\n dispatchPublic(this, 'cito-test-submitted', {});\n return true;\n }\n\n /**\n * The `qti-test-feedback` elements that apply now, read from the test outcomes: run\n * `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to\n * while it runs (`during`); without it, both.\n */\n getTestFeedback(access?: 'atEnd' | 'during'): QtiTestFeedback[] {\n const feedback = Array.from(\n (this._testElement ?? this).querySelectorAll<QtiTestFeedback>('qti-test-feedback') ?? []\n );\n return feedback.filter(\n fb => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value)\n );\n }\n\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : [...v.value, value as string]\n };\n })\n };\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n public getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this.testContext.testOutcomeVariables?.find(v => v.identifier === identifier) || null;\n }\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n }\n\n return TestProcessingElement as Constructor<TestProcessingInterface> & T;\n};\n"]}
|
|
@@ -5,11 +5,12 @@ import { TestPrintVariables } from '../components/test-print-item-variables/test
|
|
|
5
5
|
import { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';
|
|
6
6
|
import { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';
|
|
7
7
|
import { TestStamp } from '../components/test-stamp/test-stamp';
|
|
8
|
+
import { TestSubmit } from '../components/test-submit/test-submit';
|
|
8
9
|
import { TestView } from '../components/test-view-toggle/test-view';
|
|
9
10
|
import { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';
|
|
10
11
|
export * from '../tts/elements';
|
|
11
12
|
export { bookmarkedItems } from '../components/test-bookmark/test-bookmark';
|
|
12
|
-
export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestView, TestViewToggle };
|
|
13
|
+
export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestSubmit, TestView, TestViewToggle };
|
|
13
14
|
/**
|
|
14
15
|
* Every test plugin's elements in one list. `qti-test` registers them with the rest of its
|
|
15
16
|
* elements, and a scoped registry can use the list directly. Defines nothing.
|
|
@@ -38,6 +39,9 @@ export declare const pluginElements: readonly [{
|
|
|
38
39
|
}, {
|
|
39
40
|
readonly tag: "test-stamp";
|
|
40
41
|
readonly ctor: typeof TestStamp;
|
|
42
|
+
}, {
|
|
43
|
+
readonly tag: "test-submit";
|
|
44
|
+
readonly ctor: typeof TestSubmit;
|
|
41
45
|
}, {
|
|
42
46
|
readonly tag: "test-view";
|
|
43
47
|
readonly ctor: typeof TestView;
|
package/dist/plugins/elements.js
CHANGED
|
@@ -5,12 +5,13 @@ import { TestPrintVariables } from '../components/test-print-item-variables/test
|
|
|
5
5
|
import { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';
|
|
6
6
|
import { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';
|
|
7
7
|
import { TestStamp } from '../components/test-stamp/test-stamp';
|
|
8
|
+
import { TestSubmit } from '../components/test-submit/test-submit';
|
|
8
9
|
import { TestView } from '../components/test-view-toggle/test-view';
|
|
9
10
|
import { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';
|
|
10
11
|
import { ttsElements } from '../tts/elements';
|
|
11
12
|
export * from '../tts/elements';
|
|
12
13
|
export { bookmarkedItems } from '../components/test-bookmark/test-bookmark';
|
|
13
|
-
export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestView, TestViewToggle };
|
|
14
|
+
export { TestCheckItem, TestBookmark, TestPrintContext, TestPrintVariables, TestScoringButtons, TestScoringFeedback, TestStamp, TestSubmit, TestView, TestViewToggle };
|
|
14
15
|
/**
|
|
15
16
|
* Every test plugin's elements in one list. `qti-test` registers them with the rest of its
|
|
16
17
|
* elements, and a scoped registry can use the list directly. Defines nothing.
|
|
@@ -26,6 +27,7 @@ export const pluginElements = [
|
|
|
26
27
|
{ tag: 'test-scoring-buttons', ctor: TestScoringButtons },
|
|
27
28
|
{ tag: 'test-scoring-feedback', ctor: TestScoringFeedback },
|
|
28
29
|
{ tag: 'test-stamp', ctor: TestStamp },
|
|
30
|
+
{ tag: 'test-submit', ctor: TestSubmit },
|
|
29
31
|
{ tag: 'test-view', ctor: TestView },
|
|
30
32
|
{ tag: 'test-view-toggle', ctor: TestViewToggle },
|
|
31
33
|
...ttsElements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/plugins/elements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mEAAmE,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,OAAO,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACR,cAAc,EACf,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,YAAY,EAAE;IAC5C,EAAE,GAAG,EAAE,oBAAoB,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACrD,EAAE,GAAG,EAAE,2BAA2B,EAAE,IAAI,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,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpC,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE;IACjD,GAAG,WAAW;CACN,CAAC","sourcesContent":["import { TestBookmark } from '../components/test-bookmark/test-bookmark';\nimport { TestCheckItem } from '../components/test-check-item/test-check-item';\nimport { TestPrintContext } from '../components/test-print-context/test-print-context';\nimport { TestPrintVariables } from '../components/test-print-item-variables/test-print-item-variables';\nimport { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';\nimport { TestStamp } from '../components/test-stamp/test-stamp';\nimport { TestView } from '../components/test-view-toggle/test-view';\nimport { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';\nimport { ttsElements } from '../tts/elements';\n\nexport * from '../tts/elements';\n\nexport { bookmarkedItems } from '../components/test-bookmark/test-bookmark';\n\nexport {\n TestCheckItem,\n TestBookmark,\n TestPrintContext,\n TestPrintVariables,\n TestScoringButtons,\n TestScoringFeedback,\n TestStamp,\n TestView,\n TestViewToggle\n};\n\n/**\n * Every test plugin's elements in one list. `qti-test` registers them with the rest of its\n * elements, and a scoped registry can use the list directly. Defines nothing.\n *\n * A plugin is the set of files listed for it in `plugin-boundary.spec.ts` (`PLUGINS`); this file is\n * the one place that names them all.\n */\nexport const pluginElements = [\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-bookmark', ctor: TestBookmark },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle },\n ...ttsElements\n] as const;\n"]}
|
|
1
|
+
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/plugins/elements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mEAAmE,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,OAAO,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,UAAU,EACV,QAAQ,EACR,cAAc,EACf,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,YAAY,EAAE;IAC5C,EAAE,GAAG,EAAE,oBAAoB,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACrD,EAAE,GAAG,EAAE,2BAA2B,EAAE,IAAI,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,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE;IACxC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpC,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE;IACjD,GAAG,WAAW;CACN,CAAC","sourcesContent":["import { TestBookmark } from '../components/test-bookmark/test-bookmark';\nimport { TestCheckItem } from '../components/test-check-item/test-check-item';\nimport { TestPrintContext } from '../components/test-print-context/test-print-context';\nimport { TestPrintVariables } from '../components/test-print-item-variables/test-print-item-variables';\nimport { TestScoringButtons } from '../components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from '../components/test-scoring-feedback/test-scoring-feedback';\nimport { TestStamp } from '../components/test-stamp/test-stamp';\nimport { TestSubmit } from '../components/test-submit/test-submit';\nimport { TestView } from '../components/test-view-toggle/test-view';\nimport { TestViewToggle } from '../components/test-view-toggle/test-view-toggle';\nimport { ttsElements } from '../tts/elements';\n\nexport * from '../tts/elements';\n\nexport { bookmarkedItems } from '../components/test-bookmark/test-bookmark';\n\nexport {\n TestCheckItem,\n TestBookmark,\n TestPrintContext,\n TestPrintVariables,\n TestScoringButtons,\n TestScoringFeedback,\n TestStamp,\n TestSubmit,\n TestView,\n TestViewToggle\n};\n\n/**\n * Every test plugin's elements in one list. `qti-test` registers them with the rest of its\n * elements, and a scoped registry can use the list directly. Defines nothing.\n *\n * A plugin is the set of files listed for it in `plugin-boundary.spec.ts` (`PLUGINS`); this file is\n * the one place that names them all.\n */\nexport const pluginElements = [\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-bookmark', ctor: TestBookmark },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-submit', ctor: TestSubmit },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle },\n ...ttsElements\n] as const;\n"]}
|
package/dist/public-events.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface NavigationFailure {
|
|
|
24
24
|
export interface PublicEventMap {
|
|
25
25
|
'cito-test-navigate': CustomEvent<NavigationTarget>;
|
|
26
26
|
'cito-test-end-attempt': CustomEvent<unknown>;
|
|
27
|
+
/** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `cito-test-submitted`. */
|
|
28
|
+
'cito-test-submit': CustomEvent<Record<string, never>>;
|
|
27
29
|
'cito-test-update-outcome': CustomEvent<{
|
|
28
30
|
assessmentItemRefId: string;
|
|
29
31
|
outcomeVariableId: string;
|
|
@@ -35,6 +37,8 @@ export interface PublicEventMap {
|
|
|
35
37
|
plugin: string;
|
|
36
38
|
value: unknown;
|
|
37
39
|
}>;
|
|
40
|
+
/** Outcome processing ran after a submit: read the test outcomes now. */
|
|
41
|
+
'cito-test-submitted': CustomEvent<Record<string, never>>;
|
|
38
42
|
'cito-test-navigated': CustomEvent<NavigationTarget>;
|
|
39
43
|
'cito-test-navigation-started': CustomEvent<NavigationTarget>;
|
|
40
44
|
'cito-test-navigation-failed': CustomEvent<NavigationFailure>;
|
package/dist/public-events.js
CHANGED
|
@@ -2,9 +2,11 @@ import { dispatchDeclared, listenDeclared } from '@qti-components/elements/publi
|
|
|
2
2
|
export const PUBLIC_EVENTS = {
|
|
3
3
|
'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },
|
|
4
4
|
'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },
|
|
5
|
+
'cito-test-submit': { kind: 'request', scope: 'test' },
|
|
5
6
|
'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },
|
|
6
7
|
'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },
|
|
7
8
|
'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },
|
|
9
|
+
'cito-test-submitted': { kind: 'notification', scope: 'test' },
|
|
8
10
|
'cito-test-navigated': { kind: 'notification', scope: 'test' },
|
|
9
11
|
'cito-test-navigation-started': {
|
|
10
12
|
kind: 'notification',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAyD1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAAE;IAC9F,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE;IAC3F,kBAAkB,EAAE,EAAE,IAA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;CACpH,CAAC;AAMF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,IAAO,EACP,MAAkE;IAElE,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'cito-test-navigate': CustomEvent<NavigationTarget>;\n 'cito-test-end-attempt': CustomEvent<unknown>;\n /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `cito-test-submitted`. */\n 'cito-test-submit': CustomEvent<Record<string, never>>;\n 'cito-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'cito-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'cito-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n /** Outcome processing ran after a submit: read the test outcomes now. */\n 'cito-test-submitted': CustomEvent<Record<string, never>>;\n 'cito-test-navigated': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-started': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'cito-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `cito-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-test-state-changed': CustomEvent<QtiTestState>;\n 'cito-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'cito-test-end-reached': CustomEvent<Record<string, never>>;\n 'cito-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },\n 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },\n 'cito-test-submit': { kind: 'request', scope: 'test' },\n 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },\n 'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },\n 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },\n 'cito-test-submitted': { kind: 'notification', scope: 'test' },\n 'cito-test-navigated': { kind: 'notification', scope: 'test' },\n 'cito-test-navigation-started': {\n kind: 'notification',\n scope: 'test',\n deprecated: 'qti-navigation-loading-started'\n },\n 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },\n 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },\n 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },\n 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },\n 'cito-test-items-skipped': { kind: 'notification', scope: 'test' },\n 'cito-test-end-reached': { kind: 'notification', scope: 'test' },\n 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
|