@qti-components/extended 0.0.0-stage → 1.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE.md +674 -0
  2. package/dist/elements.d.ts +100 -0
  3. package/dist/elements.js +44 -0
  4. package/dist/elements.js.map +1 -0
  5. package/dist/index.d.ts +11 -0
  6. package/dist/index.js +12 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/qti-extended-jsx.d.ts +1894 -0
  9. package/dist/qti-extended-jsx.js +1 -0
  10. package/dist/register.d.ts +1 -0
  11. package/dist/register.js +7 -0
  12. package/dist/register.js.map +1 -0
  13. package/dist/test-bookmark/test-bookmark.d.ts +45 -0
  14. package/dist/test-bookmark/test-bookmark.js +136 -0
  15. package/dist/test-bookmark/test-bookmark.js.map +1 -0
  16. package/dist/test-character-sheet/test-character-sheet.d.ts +46 -0
  17. package/dist/test-character-sheet/test-character-sheet.js +259 -0
  18. package/dist/test-character-sheet/test-character-sheet.js.map +1 -0
  19. package/dist/test-item-link/test-item-link.d.ts +13 -0
  20. package/dist/test-item-link/test-item-link.js +28 -0
  21. package/dist/test-item-link/test-item-link.js.map +1 -0
  22. package/dist/test-lock/test-lock.d.ts +72 -0
  23. package/dist/test-lock/test-lock.js +242 -0
  24. package/dist/test-lock/test-lock.js.map +1 -0
  25. package/dist/test-print-context/test-print-context.d.ts +11 -0
  26. package/dist/test-print-context/test-print-context.js +20 -0
  27. package/dist/test-print-context/test-print-context.js.map +1 -0
  28. package/dist/test-print-item-variables/test-print-item-variables.d.ts +17 -0
  29. package/dist/test-print-item-variables/test-print-item-variables.js +95 -0
  30. package/dist/test-print-item-variables/test-print-item-variables.js.map +1 -0
  31. package/dist/test-print-state/test-print-state.d.ts +29 -0
  32. package/dist/test-print-state/test-print-state.js +101 -0
  33. package/dist/test-print-state/test-print-state.js.map +1 -0
  34. package/dist/test-scoring-buttons/test-scoring-buttons.d.ts +19 -0
  35. package/dist/test-scoring-buttons/test-scoring-buttons.js +95 -0
  36. package/dist/test-scoring-buttons/test-scoring-buttons.js.map +1 -0
  37. package/dist/test-scoring-feedback/test-scoring-feedback.d.ts +13 -0
  38. package/dist/test-scoring-feedback/test-scoring-feedback.js +54 -0
  39. package/dist/test-scoring-feedback/test-scoring-feedback.js.map +1 -0
  40. package/dist/test-section-link/test-section-link.d.ts +13 -0
  41. package/dist/test-section-link/test-section-link.js +28 -0
  42. package/dist/test-section-link/test-section-link.js.map +1 -0
  43. package/dist/test-stamp/test-stamp.d.ts +29 -0
  44. package/dist/test-stamp/test-stamp.js +105 -0
  45. package/dist/test-stamp/test-stamp.js.map +1 -0
  46. package/dist/test-view-toggle/test-view-toggle.d.ts +16 -0
  47. package/dist/test-view-toggle/test-view-toggle.js +49 -0
  48. package/dist/test-view-toggle/test-view-toggle.js.map +1 -0
  49. package/dist/test-view-toggle/test-view.d.ts +20 -0
  50. package/dist/test-view-toggle/test-view.js +73 -0
  51. package/dist/test-view-toggle/test-view.js.map +1 -0
  52. package/dist/test-zoom/test-zoom.d.ts +75 -0
  53. package/dist/test-zoom/test-zoom.js +158 -0
  54. package/dist/test-zoom/test-zoom.js.map +1 -0
  55. package/dist/tts/elements.d.ts +28 -0
  56. package/dist/tts/elements.js +14 -0
  57. package/dist/tts/elements.js.map +1 -0
  58. package/dist/tts/test-item-to-speech.d.ts +260 -0
  59. package/dist/tts/test-item-to-speech.js +1091 -0
  60. package/dist/tts/test-item-to-speech.js.map +1 -0
  61. package/package.json +65 -3
  62. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-print-state.js","sourceRoot":"","sources":["../../src/test-print-state/test-print-state.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK1C;;;GAGG;AACH,MAAM,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AAC,KAAK,CAAC,CAAC;AACrF,CAAC,CAAC","sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport type { TemplateResult } from 'lit';\nimport type { QtiTestState } from '@citolab/qti-components/qti-test/plugin-api';\n\n/**\n * Whether `node` sits inside `ancestor`, also through shadow roots: the test a notification comes\n * from is this element's own test when the element is somewhere inside it.\n */\nconst isInside = (node: Node, ancestor: EventTarget | undefined): boolean => {\n for (let current: Node | null = node; current; ) {\n if (current === ancestor) return true;\n current = current.parentNode ?? (current instanceof ShadowRoot ? current.host : null);\n }\n return false;\n};\n\n/**\n * Shows the test's state (`qtiTest.state`) as a tree you can fold open and shut. It shows the state\n * each `qc-test-state-changed` of its own test carries: the test sends one once it is ready and one on\n * every change, so place it in the page from the start. A debug helper: drop it anywhere inside\n * `<qti-test>`.\n *\n * The first two levels start open. A list entry with an `identifier` (an item, a variable) is labelled\n * by it. The element only lays out the tree; give it a font, colour and height from the page.\n *\n * @customElement test-print-state\n * @csspart key - the name of a field, or the label of a list entry\n * @csspart value - a value that is not an object or a list\n * @csspart count - the number of entries of a folded object or list\n */\nexport class TestPrintState extends LitElement {\n @state() private testState?: QtiTestState;\n\n static override styles = css`\n :host {\n display: block;\n }\n ul {\n list-style: none;\n margin: 0;\n padding-inline-start: 1rem;\n }\n summary {\n cursor: pointer;\n }\n [part~='count'] {\n opacity: 0.7;\n }\n `;\n\n /** A notification goes up from the test, so it is heard on the document; only its own test's counts. */\n #onStateChanged = (event: Event) => {\n if (!isInside(this, event.composedPath()[0])) return;\n this.testState = (event as CustomEvent<QtiTestState>).detail;\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Under the public name only: `cito-test-state-changed` carries the same state, once more.\n this.ownerDocument.addEventListener('qc-test-state-changed', this.#onStateChanged);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.ownerDocument.removeEventListener('qc-test-state-changed', this.#onStateChanged);\n }\n\n override render() {\n if (!this.testState) return nothing;\n return html`<ul>\n ${this.#renderNode('state', this.testState, 0)}\n </ul>`;\n }\n\n #renderNode(label: string, value: unknown, depth: number): TemplateResult {\n if (value === null || typeof value !== 'object') {\n return html`<li><span part=\"key\">${label}</span>: <span part=\"value\">${JSON.stringify(value)}</span></li>`;\n }\n const entries: [string, unknown][] = Array.isArray(value)\n ? value.map((entry, index) => [entryLabel(entry, index), entry])\n : Object.entries(value);\n const count = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;\n // `open` is bound once per depth, so Lit leaves a node the reader folded alone on the next update.\n return html`<li>\n <details ?open=${depth < 2}>\n <summary><span part=\"key\">${label}</span> <span part=\"count\">${count}</span></summary>\n <ul>\n ${entries.map(([key, entry]) => this.#renderNode(key, entry, depth + 1))}\n </ul>\n </details>\n </li>`;\n }\n}\n\n/** An item or a variable is easier to find by its identifier than by its index. */\nconst entryLabel = (entry: unknown, index: number): string => {\n const identifier = (entry as { identifier?: unknown } | null)?.identifier;\n return typeof identifier === 'string' ? `${index} · ${identifier}` : String(index);\n};\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-print-state': TestPrintState;\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { LitElement, nothing } from 'lit';
2
+ import type { TemplateFunction } from '@heximal/templates';
3
+ import type { ComputedContext } from '@citolab/qti-components/qti-base';
4
+ export declare class TestScoringButtons extends LitElement {
5
+ #private;
6
+ view: string;
7
+ disabled: boolean;
8
+ myTemplate: TemplateFunction | null;
9
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
10
+ connectedCallback(): void;
11
+ protected computedContext?: ComputedContext;
12
+ render(): import("lit").TemplateResult<1> | typeof nothing;
13
+ constructor();
14
+ }
15
+ declare global {
16
+ interface HTMLElementTagNameMap {
17
+ 'test-scoring-buttons': TestScoringButtons;
18
+ }
19
+ }
@@ -0,0 +1,95 @@
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 { html, LitElement, nothing } from 'lit';
8
+ import { consume } from '@lit/context';
9
+ import { property } from 'lit/decorators.js';
10
+ import { prepareTemplate } from '@heximal/templates';
11
+ import { computedContext } from '@citolab/qti-components/qti-base';
12
+ import { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';
13
+ export class TestScoringButtons extends LitElement {
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback();
19
+ const templateElement = this.querySelector('template');
20
+ if (!templateElement) {
21
+ this.myTemplate = null;
22
+ return;
23
+ }
24
+ this.myTemplate = prepareTemplate(templateElement);
25
+ }
26
+ #changeOutcomeScore(value) {
27
+ const testPart = this.computedContext?.testParts.find(testPart => testPart.active);
28
+ const sectionItems = testPart.sections.flatMap(section => section.items);
29
+ const currentItemIdentifier = sectionItems.find(item => item.active)?.identifier;
30
+ dispatchPublic(this, 'qc-test-update-outcome', {
31
+ assessmentItemRefId: currentItemIdentifier,
32
+ outcomeVariableId: 'SCORE',
33
+ value
34
+ });
35
+ }
36
+ render() {
37
+ const activeItem = this.computedContext?.testParts
38
+ .flatMap(testPart => testPart.sections.flatMap(section => section.items))
39
+ .find(item => item.active);
40
+ if (!activeItem || !activeItem.variables)
41
+ return html ``;
42
+ const maxScore = activeItem.variables.find(vr => vr.identifier == 'MAXSCORE')?.value;
43
+ const scoreOutcome = activeItem.variables.find(vr => vr.identifier == 'SCORE');
44
+ const score = scoreOutcome?.value;
45
+ const disabled = !(scoreOutcome?.externalScored === 'human');
46
+ if (!maxScore || !scoreOutcome)
47
+ return nothing;
48
+ const scores = [...Array(Number(maxScore) + 1).keys()];
49
+ return html `${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing}`;
50
+ }
51
+ constructor() {
52
+ super();
53
+ this.view = ''; // is only an attribute, but this is here because.. react
54
+ this.disabled = false;
55
+ this.myTemplate = null;
56
+ this.addEventListener('click', e => {
57
+ const target = e.target;
58
+ const value = parseFloat(target.value);
59
+ if (target.tagName === 'INPUT') {
60
+ this.#changeOutcomeScore(value);
61
+ }
62
+ });
63
+ // return maxScore
64
+ // ? html`
65
+ // <form part="form">
66
+ // ${[...Array(Number(maxScore) + 1).keys()].map(itemIndex => {
67
+ // const identifier = `scoring-buttons${itemIndex}${activeItem.identifier}`;
68
+ // return html` <input
69
+ // part="input"
70
+ // type="radio"
71
+ // ?disabled=${this.disabled}
72
+ // .checked=${itemIndex === Number(score)}
73
+ // @change=${() => this._changeOutcomeScore(itemIndex)}
74
+ // id=${identifier}
75
+ // name=${`scoring-buttons-${activeItem.identifier}`}
76
+ // value=${itemIndex}
77
+ // />
78
+ // <label part="label" for=${identifier}>${itemIndex}</label>`;
79
+ // })}
80
+ // </form>
81
+ // <slot></slot>
82
+ // `
83
+ // : nothing;
84
+ }
85
+ }
86
+ __decorate([
87
+ property({ type: String, attribute: 'view' })
88
+ ], TestScoringButtons.prototype, "view", void 0);
89
+ __decorate([
90
+ property({ type: Boolean })
91
+ ], TestScoringButtons.prototype, "disabled", void 0);
92
+ __decorate([
93
+ consume({ context: computedContext, subscribe: true })
94
+ ], TestScoringButtons.prototype, "computedContext", void 0);
95
+ //# sourceMappingURL=test-scoring-buttons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-scoring-buttons.js","sourceRoot":"","sources":["../../src/test-scoring-buttons/test-scoring-buttons.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC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EAAE;YACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAA0B,CAAC;YAC5C,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvC,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC/B,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,kBAAkB;QAClB,YAAY;QACZ,2BAA2B;QAC3B,uEAAuE;QACvE,sFAAsF;QACtF,gCAAgC;QAChC,6BAA6B;QAC7B,6BAA6B;QAC7B,2CAA2C;QAC3C,wDAAwD;QACxD,qEAAqE;QACrE,iCAAiC;QACjC,mEAAmE;QACnE,mCAAmC;QACnC,iBAAiB;QAEjB,2EAA2E;QAC3E,cAAc;QACd,gBAAgB;QAChB,sBAAsB;QACtB,QAAQ;QACR,eAAe;IACjB,CAAC;CACF;AAtFgD;IAA9C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;gDAAW;AAC5B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAA2B;AAkB7C;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;2DACX","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { consume } from '@lit/context';\nimport { property } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { computedContext } from '@citolab/qti-components/qti-base';\nimport { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';\n\nimport type { TemplateFunction } from '@heximal/templates';\nimport type { OutcomeVariable } from '@citolab/qti-components/qti-base';\nimport type { ComputedContext } from '@citolab/qti-components/qti-base';\n\nexport class TestScoringButtons extends LitElement {\n @property({ type: String, attribute: 'view' }) view = ''; // is only an attribute, but this is here because.. react\n @property({ type: Boolean }) disabled: boolean = false;\n myTemplate: TemplateFunction | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n #changeOutcomeScore(value: number) {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const currentItemIdentifier = sectionItems.find(item => item.active)?.identifier;\n\n dispatchPublic(this, 'qc-test-update-outcome', {\n assessmentItemRefId: currentItemIdentifier,\n outcomeVariableId: 'SCORE',\n value\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 maxScore = activeItem.variables.find(vr => vr.identifier == 'MAXSCORE')?.value;\n const scoreOutcome = activeItem.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n\n const score = scoreOutcome?.value;\n\n const disabled = !(scoreOutcome?.externalScored === 'human');\n\n if (!maxScore || !scoreOutcome) return nothing;\n const scores = [...Array(Number(maxScore) + 1).keys()];\n\n return html`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing}`;\n }\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n const target = e.target as HTMLInputElement;\n const value = parseFloat(target.value);\n if (target.tagName === 'INPUT') {\n this.#changeOutcomeScore(value);\n }\n });\n\n // return maxScore\n // ? html`\n // <form part=\"form\">\n // ${[...Array(Number(maxScore) + 1).keys()].map(itemIndex => {\n // const identifier = `scoring-buttons${itemIndex}${activeItem.identifier}`;\n // return html` <input\n // part=\"input\"\n // type=\"radio\"\n // ?disabled=${this.disabled}\n // .checked=${itemIndex === Number(score)}\n // @change=${() => this._changeOutcomeScore(itemIndex)}\n // id=${identifier}\n // name=${`scoring-buttons-${activeItem.identifier}`}\n // value=${itemIndex}\n // />\n\n // <label part=\"label\" for=${identifier}>${itemIndex}</label>`;\n // })}\n // </form>\n // <slot></slot>\n // `\n // : nothing;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-scoring-buttons': TestScoringButtons;\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { LitElement } from 'lit';
2
+ import type { View } from '@citolab/qti-components/qti-base';
3
+ import type { ComputedContext } from '@citolab/qti-components/qti-base';
4
+ export declare class TestScoringFeedback extends LitElement {
5
+ protected computedContext?: ComputedContext;
6
+ view: View;
7
+ render(): import("lit").TemplateResult<1>;
8
+ }
9
+ declare global {
10
+ interface HTMLElementTagNameMap {
11
+ 'test-scoring-feedback': TestScoringFeedback;
12
+ }
13
+ }
@@ -0,0 +1,54 @@
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 { html, LitElement } from 'lit';
9
+ import { property } from 'lit/decorators.js';
10
+ import { computedContext } from '@citolab/qti-components/qti-base';
11
+ export class TestScoringFeedback extends LitElement {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.view = null;
15
+ }
16
+ render() {
17
+ const activeItem = this.computedContext?.testParts
18
+ .flatMap(testPart => testPart.sections.flatMap(section => section.items))
19
+ .find(item => item.active);
20
+ if (!activeItem || !activeItem.variables)
21
+ return html ``;
22
+ if (activeItem['category'] === 'dep-informational')
23
+ return html `<div>${this.dataset.informational}</div>`;
24
+ const scoreOutcome = activeItem?.variables.find(vr => vr.identifier == 'SCORE');
25
+ const score = parseFloat(scoreOutcome?.value);
26
+ const externalScored = activeItem['externalScored'];
27
+ const feedbackText = () => {
28
+ // No (valid) answer: completionStatus is QTI's, set by response processing, not "answered".
29
+ if (activeItem.valid === false || activeItem.isDefaultResponse) {
30
+ return this.dataset.textNoResponse;
31
+ }
32
+ if (!externalScored && score !== undefined && !Number.isNaN(score)) {
33
+ return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
34
+ }
35
+ if (externalScored === 'externalMachine') {
36
+ return Number.isNaN(score) || score === undefined
37
+ ? this.dataset.scoreUnknown
38
+ : `We hebben je antwoord ${score === 0 ? 'geen punten' : score == 1 ? 'één punt' : `${score} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`;
39
+ }
40
+ if (externalScored === 'human') {
41
+ return Number.isNaN(score) ? '' : 'Deze score heb je zelf toegekend.';
42
+ }
43
+ return this.dataset.inProgress;
44
+ };
45
+ return html `<div>${feedbackText()}</div>`;
46
+ }
47
+ }
48
+ __decorate([
49
+ consume({ context: computedContext, subscribe: true })
50
+ ], TestScoringFeedback.prototype, "computedContext", void 0);
51
+ __decorate([
52
+ property({ type: String, attribute: 'view' })
53
+ ], TestScoringFeedback.prototype, "view", void 0);
54
+ //# sourceMappingURL=test-scoring-feedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-scoring-feedback.js","sourceRoot":"","sources":["../../src/test-scoring-feedback/test-scoring-feedback.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMnE,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAAnD;;Q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E,CAAC;YAED,IAAI,cAAc,KAAK,iBAAiB,EAAE,CAAC;gBACzC,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,SAAS;oBAC/C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY;oBAC3B,CAAC,CAAC,yBAAyB,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,4EAA4E,CAAC;YACrL,CAAC;YAED,IAAI,cAAc,KAAK,OAAO,EAAE,CAAC;gBAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mCAAmC,CAAC;YACxE,CAAC;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACjC,CAAC,CAAC;QAEF,OAAO,IAAI,CAAA,QAAQ,YAAY,EAAE,QAAQ,CAAC;IAC5C,CAAC;CACF;AA5CW;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;4DACX;AAGrC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;iDACrB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { computedContext } from '@citolab/qti-components/qti-base';\n\nimport type { View } from '@citolab/qti-components/qti-base';\nimport type { OutcomeVariable } from '@citolab/qti-components/qti-base';\nimport type { ComputedContext } from '@citolab/qti-components/qti-base';\n\nexport class TestScoringFeedback extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n @property({ type: String, attribute: 'view' })\n public view: View = null;\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 if ((activeItem as any)['category'] === 'dep-informational') return html`<div>${this.dataset.informational}</div>`;\n\n const scoreOutcome = activeItem?.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n\n const score = parseFloat(scoreOutcome?.value as string);\n const externalScored = (activeItem as any)['externalScored'];\n\n const feedbackText = () => {\n // No (valid) answer: completionStatus is QTI's, set by response processing, not \"answered\".\n if (activeItem.valid === false || activeItem.isDefaultResponse) {\n return this.dataset.textNoResponse;\n }\n\n if (!externalScored && score !== undefined && !Number.isNaN(score)) {\n return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;\n }\n\n if (externalScored === 'externalMachine') {\n return Number.isNaN(score) || score === undefined\n ? this.dataset.scoreUnknown\n : `We hebben je antwoord ${score === 0 ? 'geen punten' : score == 1 ? 'één punt' : `${score} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`;\n }\n\n if (externalScored === 'human') {\n return Number.isNaN(score) ? '' : 'Deze score heb je zelf toegekend.';\n }\n\n return this.dataset.inProgress;\n };\n\n return html`<div>${feedbackText()}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-scoring-feedback': TestScoringFeedback;\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class TestSectionLink extends LitElement {
3
+ #private;
4
+ static styles: import("lit").CSSResult;
5
+ private sectionId;
6
+ constructor();
7
+ render(): import("lit").TemplateResult<1>;
8
+ }
9
+ declare global {
10
+ interface HTMLElementTagNameMap {
11
+ 'test-section-link': TestSectionLink;
12
+ }
13
+ }
@@ -0,0 +1,28 @@
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 { LitElement } from 'lit';
8
+ import { property } from 'lit/decorators.js';
9
+ import { controlStyles as styles } from '@citolab/qti-components/qti-test/plugin-api';
10
+ import { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';
11
+ export class TestSectionLink extends LitElement {
12
+ static { this.styles = styles.button; }
13
+ #requestItem(identifier) {
14
+ dispatchPublic(this, 'qc-test-navigate', { type: 'section', id: identifier });
15
+ }
16
+ constructor() {
17
+ super();
18
+ this.sectionId = null;
19
+ this.addEventListener('click', () => this.#requestItem(this.sectionId));
20
+ }
21
+ render() {
22
+ return styles.control;
23
+ }
24
+ }
25
+ __decorate([
26
+ property({ type: String, attribute: 'section-id' })
27
+ ], TestSectionLink.prototype, "sectionId", void 0);
28
+ //# sourceMappingURL=test-section-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-section-link.js","sourceRoot":"","sources":["../../src/test-section-link/test-section-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG,MAAM,CAAC,MAAM,AAAhB,CAAiB;IAKvC,YAAY,CAAC,UAAkB;QAC7B,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAPF,cAAS,GAAW,IAAI,CAAC;QAQ/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACnB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { controlStyles as styles } from '@citolab/qti-components/qti-test/plugin-api';\nimport { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';\n\nexport class TestSectionLink extends LitElement {\n static override styles = styles.button;\n\n @property({ type: String, attribute: 'section-id' })\n private sectionId: string = null;\n\n #requestItem(identifier: string) {\n dispatchPublic(this, 'qc-test-navigate', { type: 'section', id: identifier });\n }\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#requestItem(this.sectionId));\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-link': TestSectionLink;\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { LitElement } from 'lit';
2
+ import type { PropertyValues } from 'lit';
3
+ import type { TemplateFunction } from '@heximal/templates';
4
+ /**
5
+ * The stamp plugin: renders its `<template>` child with the state of the test (`test`,
6
+ * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player
7
+ * can show progress or numbered navigation without writing a component.
8
+ * @customElement
9
+ * @extends {LitElement}
10
+ */
11
+ export declare class TestStamp extends LitElement {
12
+ /**
13
+ * Indicates whether the component is in debug mode.
14
+ * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.
15
+ */
16
+ debug: boolean;
17
+ private computedContext;
18
+ private stampContext;
19
+ myTemplate: TemplateFunction;
20
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
21
+ connectedCallback(): void;
22
+ protected willUpdate(_changedProperties: PropertyValues): void;
23
+ render(): import("lit").TemplateResult<1>;
24
+ }
25
+ declare global {
26
+ interface HTMLElementTagNameMap {
27
+ 'test-stamp': TestStamp;
28
+ }
29
+ }
@@ -0,0 +1,105 @@
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 { html, LitElement, nothing } from 'lit';
8
+ import { property, state } from 'lit/decorators.js';
9
+ import { prepareTemplate } from '@heximal/templates';
10
+ import { consume } from '@lit/context';
11
+ import { computedContext } from '@citolab/qti-components/qti-base';
12
+ /**
13
+ * The stamp plugin: renders its `<template>` child with the state of the test (`test`,
14
+ * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player
15
+ * can show progress or numbered navigation without writing a component.
16
+ * @customElement
17
+ * @extends {LitElement}
18
+ */
19
+ export class TestStamp extends LitElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ /**
23
+ * Indicates whether the component is in debug mode.
24
+ * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.
25
+ */
26
+ this.debug = false;
27
+ this.stampContext = {
28
+ view: 'candidate',
29
+ activeItem: {},
30
+ activeSection: {
31
+ items: []
32
+ },
33
+ activeTestpart: {
34
+ items: [],
35
+ sections: []
36
+ },
37
+ test: {}
38
+ };
39
+ }
40
+ createRenderRoot() {
41
+ return this;
42
+ }
43
+ connectedCallback() {
44
+ super.connectedCallback();
45
+ const templateElement = this.querySelector('template');
46
+ if (!templateElement) {
47
+ this.myTemplate = null;
48
+ return;
49
+ }
50
+ this.myTemplate = prepareTemplate(templateElement);
51
+ }
52
+ willUpdate(_changedProperties) {
53
+ if (!this.computedContext) {
54
+ return;
55
+ }
56
+ const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);
57
+ const activeSection = activeTestPart?.sections.find(section => section.active);
58
+ const activeItem = activeSection?.items.find(item => item.active);
59
+ // In `navigate="section"` the test shows a section, not one item, so there may be no active item.
60
+ const { variables, ...augmentedItem } = activeItem || {};
61
+ if (!activeTestPart) {
62
+ return;
63
+ }
64
+ const augmentedTestPart = {
65
+ ...activeTestPart,
66
+ items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),
67
+ sections: activeTestPart.sections.map(section => ({
68
+ ...section,
69
+ items: section.items.map(({ variables, ...rest }) => rest)
70
+ }))
71
+ };
72
+ const augmentedSection = {
73
+ ...activeSection,
74
+ items: (activeSection?.items ?? []).map(({ variables, ...rest }) => rest)
75
+ };
76
+ const { testParts, ...activeTest } = this.computedContext;
77
+ this.stampContext = {
78
+ view: this.computedContext.view,
79
+ activeItem: augmentedItem,
80
+ activeSection: augmentedSection,
81
+ activeTestpart: augmentedTestPart,
82
+ test: activeTest
83
+ };
84
+ this.dispatchEvent(new CustomEvent('qti-stamp-context-updated', {
85
+ detail: this.stampContext,
86
+ bubbles: true
87
+ }));
88
+ }
89
+ render() {
90
+ // if (!this.stampContext) return nothing;
91
+ return html ` ${this.debug ? html `<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}
92
+ ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
93
+ }
94
+ }
95
+ __decorate([
96
+ property({ type: Boolean, reflect: true })
97
+ ], TestStamp.prototype, "debug", void 0);
98
+ __decorate([
99
+ state(),
100
+ consume({ context: computedContext, subscribe: true })
101
+ ], TestStamp.prototype, "computedContext", void 0);
102
+ __decorate([
103
+ state()
104
+ ], TestStamp.prototype, "stampContext", void 0);
105
+ //# sourceMappingURL=test-stamp.js.map
@@ -0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AC;QAE1D,IAAI,CAAC,YAAY,GAAG;YAClB,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;YAC/B,UAAU,EAAE,aAAa;YACzB,aAAa,EAAE,gBAAgB;YAC/B,cAAc,EAAE,iBAAiB;YACjC,IAAI,EAAE,UAAU;SACjB,CAAC;QACF,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,2BAA2B,EAAE;YAC3C,MAAM,EAAE,IAAI,CAAC,YAAY;YACzB,OAAO,EAAE,IAAI;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,0CAA0C;QAC1C,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA,eAAe,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO;MACjH,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;CACF;AA3FQ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCACtB;AAIb;IAFP,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDACd;AAGjC;IADP,KAAK,EAAE;+CAkBN","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\nimport { computedContext } from '@citolab/qti-components/qti-base';\n\nimport type { View } from '@citolab/qti-components/qti-base';\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@citolab/qti-components/qti-base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * The stamp plugin: renders its `<template>` child with the state of the test (`test`,\n * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player\n * can show progress or numbered navigation without writing a component.\n * @customElement\n * @extends {LitElement}\n */\n\nexport class TestStamp extends LitElement {\n /**\n * Indicates whether the component is in debug mode.\n * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.\n */\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n view?: View;\n test?: unknown;\n activeTestpart?: unknown;\n activeSection?: unknown;\n activeItem?: unknown;\n } = {\n view: 'candidate',\n activeItem: {},\n activeSection: {\n items: []\n },\n activeTestpart: {\n items: [],\n sections: []\n },\n test: {}\n };\n\n myTemplate: TemplateFunction;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n return;\n }\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = activeTestPart?.sections.find(section => section.active);\n const activeItem = activeSection?.items.find(item => item.active);\n // In `navigate=\"section\"` the test shows a section, not one item, so there may be no active item.\n const { variables, ...augmentedItem } = activeItem || {};\n\n if (!activeTestPart) {\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),\n sections: activeTestPart.sections.map(section => ({\n ...section,\n items: section.items.map(({ variables, ...rest }) => rest)\n }))\n };\n\n const augmentedSection = {\n ...activeSection,\n items: (activeSection?.items ?? []).map(({ variables, ...rest }) => rest)\n };\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n view: this.computedContext.view,\n activeItem: augmentedItem,\n activeSection: augmentedSection,\n activeTestpart: augmentedTestPart,\n test: activeTest\n };\n this.dispatchEvent(\n new CustomEvent('qti-stamp-context-updated', {\n detail: this.stampContext,\n bubbles: true\n })\n );\n }\n\n override render() {\n // if (!this.stampContext) return nothing;\n return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}\n ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { LitElement } from 'lit';
2
+ import type { PropertyValues } from 'lit';
3
+ export declare class TestViewToggle extends LitElement {
4
+ myTemplate: any;
5
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
6
+ private computedContext?;
7
+ connectedCallback(): void;
8
+ _switchView(view: string): void;
9
+ protected firstUpdated(_changedProperties: PropertyValues): void;
10
+ render(): import("lit").TemplateResult<1>;
11
+ }
12
+ declare global {
13
+ interface HTMLElementTagNameMap {
14
+ 'test-view-toggle': TestViewToggle;
15
+ }
16
+ }
@@ -0,0 +1,49 @@
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 { html, LitElement, nothing } from 'lit';
9
+ import { prepareTemplate } from '@heximal/templates';
10
+ import { computedContext } from '@citolab/qti-components/qti-base';
11
+ import { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';
12
+ export class TestViewToggle extends LitElement {
13
+ createRenderRoot() {
14
+ return this;
15
+ }
16
+ connectedCallback() {
17
+ super.connectedCallback();
18
+ const templateElement = this.querySelector('template');
19
+ if (!templateElement) {
20
+ this.myTemplate = null;
21
+ return;
22
+ }
23
+ this.myTemplate = prepareTemplate(templateElement);
24
+ }
25
+ _switchView(view) {
26
+ dispatchPublic(this, 'qc-test-switch-view', view);
27
+ }
28
+ firstUpdated(_changedProperties) {
29
+ this.addEventListener('click', () => {
30
+ if (this.computedContext?.view === 'scorer') {
31
+ this._switchView('candidate');
32
+ }
33
+ else {
34
+ this._switchView('scorer');
35
+ }
36
+ });
37
+ }
38
+ render() {
39
+ return html `${this.myTemplate
40
+ ? this.myTemplate({
41
+ view: this.computedContext?.view
42
+ })
43
+ : nothing}`;
44
+ }
45
+ }
46
+ __decorate([
47
+ consume({ context: computedContext, subscribe: true })
48
+ ], TestViewToggle.prototype, "computedContext", void 0);
49
+ //# sourceMappingURL=test-view-toggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-view-toggle.js","sourceRoot":"","sources":["../../src/test-view-toggle/test-view-toggle.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAM7E,MAAM,OAAO,cAAe,SAAQ,UAAU;IAGzB,gBAAgB;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAKQ,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAsB,UAAU,CAAC,CAAC;QAC5E,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC;IACrD,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,cAAc,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAY,CAAC,CAAC;IAC5D,CAAC;IAEkB,YAAY,CAAC,kBAAkC;QAChE,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,IAAI,IAAI,CAAC,eAAe,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5C,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,UAAU;YAC3B,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;gBACd,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI;aACjC,CAAC;YACJ,CAAC,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF;AAjCS;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACb","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, nothing } from 'lit';\nimport { prepareTemplate } from '@heximal/templates';\nimport { computedContext } from '@citolab/qti-components/qti-base';\nimport { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@citolab/qti-components/qti-base';\nimport type { View } from '@citolab/qti-components/qti-base';\n\nexport class TestViewToggle extends LitElement {\n myTemplate: any;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext?: ComputedContext;\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n _switchView(view: string) {\n dispatchPublic(this, 'qc-test-switch-view', view as View);\n }\n\n protected override firstUpdated(_changedProperties: PropertyValues): void {\n this.addEventListener('click', () => {\n if (this.computedContext?.view === 'scorer') {\n this._switchView('candidate');\n } else {\n this._switchView('scorer');\n }\n });\n }\n\n override render() {\n return html`${this.myTemplate\n ? this.myTemplate({\n view: this.computedContext?.view\n })\n : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-view-toggle': TestViewToggle;\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class TestView extends LitElement {
3
+ #private;
4
+ static DEFAULT_VIEW_OPTIONS: string[];
5
+ private computedContext?;
6
+ /** label accompanying the select view dropdown */
7
+ label: string;
8
+ /** The options to display in the dropdown, default: ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'] */
9
+ viewOptions: string;
10
+ protected _handleViewOptionsChange: () => void;
11
+ connectedCallback(): void;
12
+ private _viewOptions;
13
+ protected _switchView(view: string): void;
14
+ render(): import("lit").TemplateResult<1>;
15
+ }
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ 'test-view': TestView;
19
+ }
20
+ }
@@ -0,0 +1,73 @@
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
+ var _a;
8
+ import { html, LitElement } from 'lit';
9
+ import { property, state } from 'lit/decorators.js';
10
+ import { consume } from '@lit/context';
11
+ import { computedContext } from '@citolab/qti-components/qti-base';
12
+ import { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';
13
+ import { watch } from '@qti-components/utilities';
14
+ export class TestView extends LitElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ /** label accompanying the select view dropdown */
18
+ this.label = 'view';
19
+ this._handleViewOptionsChange = () => {
20
+ this.#updateViewOptions();
21
+ };
22
+ this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
23
+ }
24
+ static { this.DEFAULT_VIEW_OPTIONS = ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor']; }
25
+ connectedCallback() {
26
+ super.connectedCallback();
27
+ this.#updateViewOptions();
28
+ }
29
+ #updateViewOptions() {
30
+ if (this.viewOptions) {
31
+ const options = this.viewOptions.split(',').map(opt => opt.trim());
32
+ this._viewOptions = options.filter(opt => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
33
+ }
34
+ else {
35
+ this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
36
+ }
37
+ }
38
+ _switchView(view) {
39
+ dispatchPublic(this, 'qc-test-switch-view', view);
40
+ }
41
+ render() {
42
+ return html `
43
+ <label part="label" for="viewSelect">${this.label}</label>
44
+ <select
45
+ part="select"
46
+ id="viewSelect"
47
+ @change=${(e) => {
48
+ const el = e.target;
49
+ this._switchView(el.value);
50
+ }}
51
+ >
52
+ ${this._viewOptions.map(v => html `<option value="${v}" ?selected=${v === this.computedContext?.view}>${v}</option>`)}
53
+ </select>
54
+ `;
55
+ }
56
+ }
57
+ _a = TestView;
58
+ __decorate([
59
+ consume({ context: computedContext, subscribe: true })
60
+ ], TestView.prototype, "computedContext", void 0);
61
+ __decorate([
62
+ property({ type: String })
63
+ ], TestView.prototype, "label", void 0);
64
+ __decorate([
65
+ property({ type: String, attribute: 'view-options' })
66
+ ], TestView.prototype, "viewOptions", void 0);
67
+ __decorate([
68
+ watch('viewOptions', { waitUntilFirstUpdate: true })
69
+ ], TestView.prototype, "_handleViewOptionsChange", void 0);
70
+ __decorate([
71
+ state()
72
+ ], TestView.prototype, "_viewOptions", void 0);
73
+ //# sourceMappingURL=test-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-view.js","sourceRoot":"","sources":["../../src/test-view-toggle/test-view.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAKlD,MAAM,OAAO,QAAS,SAAQ,UAAU;IAAxC;;QAME,mDAAmD;QAEnD,UAAK,GAAG,MAAM,CAAC;QAKL,6BAAwB,GAAG,GAAG,EAAE;YACxC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC5B,CAAC,CAAC;QAQM,iBAAY,GAAa,EAAQ,CAAC,oBAAoB,CAAC;IAgCjE,CAAC;aAtDQ,yBAAoB,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,CAAC,AAA3E,CAA4E;IAgB9F,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;IAKD,kBAAkB;QAChB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAA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it/context';\nimport { computedContext } from '@citolab/qti-components/qti-base';\nimport { dispatchPublic } from '@citolab/qti-components/qti-test/plugin-api';\n\nimport { watch } from '@qti-components/utilities';\n\nimport type { ComputedContext } from '@citolab/qti-components/qti-base';\nimport type { View } from '@citolab/qti-components/qti-base';\n\nexport class TestView extends LitElement {\n static DEFAULT_VIEW_OPTIONS = ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'];\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext?: ComputedContext;\n\n /** label accompanying the select view dropdown */\n @property({ type: String })\n label = 'view';\n\n /** The options to display in the dropdown, default: ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'] */\n @property({ type: String, attribute: 'view-options' }) viewOptions: string;\n @watch('viewOptions', { waitUntilFirstUpdate: true })\n protected _handleViewOptionsChange = () => {\n this.#updateViewOptions();\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#updateViewOptions();\n }\n\n @state()\n private _viewOptions: string[] = TestView.DEFAULT_VIEW_OPTIONS;\n\n #updateViewOptions() {\n if (this.viewOptions) {\n const options = this.viewOptions.split(',').map(opt => opt.trim());\n this._viewOptions = options.filter(opt => TestView.DEFAULT_VIEW_OPTIONS.includes(opt));\n } else {\n this._viewOptions = TestView.DEFAULT_VIEW_OPTIONS;\n }\n }\n\n protected _switchView(view: string) {\n dispatchPublic(this, 'qc-test-switch-view', view as View);\n }\n\n override render() {\n return html`\n <label part=\"label\" for=\"viewSelect\">${this.label}</label>\n <select\n part=\"select\"\n id=\"viewSelect\"\n @change=${(e: Event) => {\n const el = e.target as HTMLSelectElement;\n this._switchView(el.value);\n }}\n >\n ${this._viewOptions.map(\n v => html`<option value=\"${v}\" ?selected=${v === this.computedContext?.view}>${v}</option>`\n )}\n </select>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-view': TestView;\n }\n}\n"]}