@qti-components/test 1.2.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 (107) hide show
  1. package/LICENSE.md +674 -0
  2. package/dist/components/index.d.ts +24 -0
  3. package/dist/components/index.js +26 -0
  4. package/dist/components/index.js.map +1 -0
  5. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.d.ts +22 -0
  6. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +78 -0
  7. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -0
  8. package/dist/components/qti-assessment-section/qti-assessment-section.d.ts +20 -0
  9. package/dist/components/qti-assessment-section/qti-assessment-section.js +64 -0
  10. package/dist/components/qti-assessment-section/qti-assessment-section.js.map +1 -0
  11. package/dist/components/qti-assessment-test/qti-assessment-test.d.ts +16 -0
  12. package/dist/components/qti-assessment-test/qti-assessment-test.js +47 -0
  13. package/dist/components/qti-assessment-test/qti-assessment-test.js.map +1 -0
  14. package/dist/components/qti-outcome-processing/qti-outcome-processing.d.ts +15 -0
  15. package/dist/components/qti-outcome-processing/qti-outcome-processing.js +37 -0
  16. package/dist/components/qti-outcome-processing/qti-outcome-processing.js.map +1 -0
  17. package/dist/components/qti-test/qti-test.d.ts +69 -0
  18. package/dist/components/qti-test/qti-test.js +80 -0
  19. package/dist/components/qti-test/qti-test.js.map +1 -0
  20. package/dist/components/qti-test-feedback/qti-test-feedback.d.ts +10 -0
  21. package/dist/components/qti-test-feedback/qti-test-feedback.js +24 -0
  22. package/dist/components/qti-test-feedback/qti-test-feedback.js.map +1 -0
  23. package/dist/components/qti-test-part/qti-test-part.d.ts +17 -0
  24. package/dist/components/qti-test-part/qti-test-part.js +58 -0
  25. package/dist/components/qti-test-part/qti-test-part.js.map +1 -0
  26. package/dist/components/qti-test-variables/qti-test-variables.d.ts +25 -0
  27. package/dist/components/qti-test-variables/qti-test-variables.js +79 -0
  28. package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -0
  29. package/dist/components/styles.d.ts +4 -0
  30. package/dist/components/styles.js +23 -0
  31. package/dist/components/styles.js.map +1 -0
  32. package/dist/components/test-check-item/test-check-item.d.ts +11 -0
  33. package/dist/components/test-check-item/test-check-item.js +43 -0
  34. package/dist/components/test-check-item/test-check-item.js.map +1 -0
  35. package/dist/components/test-container/test-container.d.ts +33 -0
  36. package/dist/components/test-container/test-container.js +122 -0
  37. package/dist/components/test-container/test-container.js.map +1 -0
  38. package/dist/components/test-end-attempt/test-end-attempt.d.ts +11 -0
  39. package/dist/components/test-end-attempt/test-end-attempt.js +31 -0
  40. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -0
  41. package/dist/components/test-item-link/test-item-link.d.ts +13 -0
  42. package/dist/components/test-item-link/test-item-link.js +45 -0
  43. package/dist/components/test-item-link/test-item-link.js.map +1 -0
  44. package/dist/components/test-navigation/test-navigation.d.ts +35 -0
  45. package/dist/components/test-navigation/test-navigation.js +401 -0
  46. package/dist/components/test-navigation/test-navigation.js.map +1 -0
  47. package/dist/components/test-next/test-next.d.ts +33 -0
  48. package/dist/components/test-next/test-next.js +96 -0
  49. package/dist/components/test-next/test-next.js.map +1 -0
  50. package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.d.ts +19 -0
  51. package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js +44 -0
  52. package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js.map +1 -0
  53. package/dist/components/test-prev/test-prev.d.ts +31 -0
  54. package/dist/components/test-prev/test-prev.js +87 -0
  55. package/dist/components/test-prev/test-prev.js.map +1 -0
  56. package/dist/components/test-print-context/test-print-context.d.ts +11 -0
  57. package/dist/components/test-print-context/test-print-context.js +24 -0
  58. package/dist/components/test-print-context/test-print-context.js.map +1 -0
  59. package/dist/components/test-print-item-variables/test-print-item-variables.d.ts +12 -0
  60. package/dist/components/test-print-item-variables/test-print-item-variables.js +88 -0
  61. package/dist/components/test-print-item-variables/test-print-item-variables.js.map +1 -0
  62. package/dist/components/test-scoring-buttons/test-scoring-buttons.d.ts +19 -0
  63. package/dist/components/test-scoring-buttons/test-scoring-buttons.js +101 -0
  64. package/dist/components/test-scoring-buttons/test-scoring-buttons.js.map +1 -0
  65. package/dist/components/test-scoring-feedback/test-scoring-feedback.d.ts +13 -0
  66. package/dist/components/test-scoring-feedback/test-scoring-feedback.js +58 -0
  67. package/dist/components/test-scoring-feedback/test-scoring-feedback.js.map +1 -0
  68. package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.d.ts +19 -0
  69. package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js +44 -0
  70. package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js.map +1 -0
  71. package/dist/components/test-section-link/test-section-link.d.ts +13 -0
  72. package/dist/components/test-section-link/test-section-link.js +45 -0
  73. package/dist/components/test-section-link/test-section-link.js.map +1 -0
  74. package/dist/components/test-show-correct-response/test-show-correct-response.d.ts +22 -0
  75. package/dist/components/test-show-correct-response/test-show-correct-response.js +91 -0
  76. package/dist/components/test-show-correct-response/test-show-correct-response.js.map +1 -0
  77. package/dist/components/test-stamp/test-stamp.d.ts +28 -0
  78. package/dist/components/test-stamp/test-stamp.js +104 -0
  79. package/dist/components/test-stamp/test-stamp.js.map +1 -0
  80. package/dist/components/test-view-toggle/test-view-toggle.d.ts +16 -0
  81. package/dist/components/test-view-toggle/test-view-toggle.js +57 -0
  82. package/dist/components/test-view-toggle/test-view-toggle.js.map +1 -0
  83. package/dist/components/test-view-toggle/test-view.d.ts +20 -0
  84. package/dist/components/test-view-toggle/test-view.js +81 -0
  85. package/dist/components/test-view-toggle/test-view.js.map +1 -0
  86. package/dist/index.d.ts +2 -0
  87. package/dist/index.js +3 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/mixins/index.d.ts +3 -0
  90. package/dist/mixins/index.js +4 -0
  91. package/dist/mixins/index.js.map +1 -0
  92. package/dist/mixins/test-base.d.ts +17 -0
  93. package/dist/mixins/test-base.js +153 -0
  94. package/dist/mixins/test-base.js.map +1 -0
  95. package/dist/mixins/test-navigation.mixin.d.ts +26 -0
  96. package/dist/mixins/test-navigation.mixin.js +502 -0
  97. package/dist/mixins/test-navigation.mixin.js.map +1 -0
  98. package/dist/mixins/test-processing.mixin.d.ts +11 -0
  99. package/dist/mixins/test-processing.mixin.js +55 -0
  100. package/dist/mixins/test-processing.mixin.js.map +1 -0
  101. package/dist/mixins/test-view.mixin.d.ts +6 -0
  102. package/dist/mixins/test-view.mixin.js +45 -0
  103. package/dist/mixins/test-view.mixin.js.map +1 -0
  104. package/dist/types/iqti-test.d.ts +28 -0
  105. package/dist/types/iqti-test.js +2 -0
  106. package/dist/types/iqti-test.js.map +1 -0
  107. package/package.json +51 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-section-buttons-stamp.js","sourceRoot":"","sources":["../../../src/components/test-section-buttons-stamp/test-section-buttons-stamp.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD;;GAEG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAU;IAKrD,UAAU,CAAmB;IAEV,gBAAgB;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,YAAY,CAAC;IAC3C,CAAC;IAEQ,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAsB,UAAU,CAAC,CAAC;QAC5E,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC;IACrD,CAAC;IAEQ,MAAM;QACb,IAAI,CAAC,IAAI,CAAC,eAAe;YAAE,OAAO,IAAI,CAAA,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEvF,OAAO,IAAI,CAAA,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC;IACpE,CAAC;CACF,CAAA;AA3BS;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;gEACd;AAF9B,uBAAuB;IADnC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,uBAAuB,CA6BnC","sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * @deprecated test-section-buttons-stamp is deprecated and will be removed in the future.\n */\n@customElement('test-section-buttons-stamp')\nexport class TestSectionButtonsStamp extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n myTemplate: TemplateFunction;\n #internals: ElementInternals;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n constructor() {\n super();\n this.#internals = this.attachInternals();\n this.#internals.ariaLabel = 'pagination';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n override render() {\n if (!this.computedContext) return html``;\n const sections = this.computedContext.testParts.flatMap(testPart => testPart.sections);\n\n return html` ${sections.map(item => this.myTemplate({ item }))} `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-buttons-stamp': TestSectionButtonsStamp;\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,45 @@
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 { css, html, LitElement } from 'lit';
8
+ import { customElement, property } from 'lit/decorators.js';
9
+ import * as styles from '../styles';
10
+ let TestSectionLink = class TestSectionLink extends LitElement {
11
+ static { this.styles = css `
12
+ :host {
13
+ ${styles.btn};
14
+ }
15
+ :host([disabled]) {
16
+ ${styles.dis};
17
+ }
18
+ `; }
19
+ #requestItem(identifier) {
20
+ this.dispatchEvent(new CustomEvent('qti-request-navigation', {
21
+ composed: true,
22
+ bubbles: true,
23
+ detail: {
24
+ type: 'section',
25
+ id: identifier
26
+ }
27
+ }));
28
+ }
29
+ constructor() {
30
+ super();
31
+ this.sectionId = null;
32
+ this.addEventListener('click', () => this.#requestItem(this.sectionId));
33
+ }
34
+ render() {
35
+ return html ` <slot></slot> `;
36
+ }
37
+ };
38
+ __decorate([
39
+ property({ type: String, attribute: 'section-id' })
40
+ ], TestSectionLink.prototype, "sectionId", void 0);
41
+ TestSectionLink = __decorate([
42
+ customElement('test-section-link')
43
+ ], TestSectionLink);
44
+ export { TestSectionLink };
45
+ //# sourceMappingURL=test-section-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-section-link.js","sourceRoot":"","sources":["../../../src/components/test-section-link/test-section-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAG7B,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,GAAG;;GAEf,AAPqB,CAOpB;IAKF,YAAY,CAAC,UAAkB;QAC7B,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,wBAAwB,EAAE;YACxC,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,EAAE,EAAE,UAAU;aACf;SACF,CAAC,CACH,CAAC;IACJ,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAhBF,cAAS,GAAW,IAAI,CAAC;QAiB/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,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAtBO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACnB;AAXtB,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAkC3B","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\n\n@customElement('test-section-link')\nexport class TestSectionLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'section-id' })\n private sectionId: string = null;\n\n #requestItem(identifier: string) {\n this.dispatchEvent(\n new CustomEvent('qti-request-navigation', {\n composed: true,\n bubbles: true,\n detail: {\n type: 'section',\n id: identifier\n }\n })\n );\n }\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#requestItem(this.sectionId));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-link': TestSectionLink;\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { LitElement } from 'lit';
2
+ import type { ComputedContext } from '@qti-components/base';
3
+ /**
4
+ * @deprecated test-show-correct-response is deprecated and will be removed in the future.
5
+ */
6
+ export declare class TestShowCorrectResponse extends LitElement {
7
+ #private;
8
+ computedContext?: ComputedContext;
9
+ static styles: import("lit").CSSResult;
10
+ shown: boolean;
11
+ disabled: boolean;
12
+ showCorrectText: string;
13
+ hideCorrectText: string;
14
+ noCorrectResponseText: string;
15
+ willUpdate(_changedProperties: Map<string | number | symbol, unknown>): void;
16
+ render(): import("lit").TemplateResult<1>;
17
+ }
18
+ declare global {
19
+ interface HTMLElementTagNameMap {
20
+ 'test-show-correct-response': TestShowCorrectResponse;
21
+ }
22
+ }
@@ -0,0 +1,91 @@
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 { css, html, LitElement } from 'lit';
8
+ import { customElement, property } from 'lit/decorators.js';
9
+ import { consume } from '@lit/context';
10
+ import { computedContext } from '@qti-components/base';
11
+ import * as styles from '../styles';
12
+ /**
13
+ * @deprecated test-show-correct-response is deprecated and will be removed in the future.
14
+ */
15
+ let TestShowCorrectResponse = class TestShowCorrectResponse extends LitElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.shown = false;
19
+ this.disabled = false;
20
+ this.showCorrectText = 'Show correct response';
21
+ this.hideCorrectText = 'Hide correct response';
22
+ this.noCorrectResponseText = 'No correct response specified';
23
+ }
24
+ static { this.styles = css `
25
+ :host {
26
+ ${styles.btn};
27
+ }
28
+ :host([disabled]) {
29
+ ${styles.dis};
30
+ }
31
+ `; }
32
+ #previousActiveItem; // Store previous active item reference
33
+ willUpdate(_changedProperties) {
34
+ const activeItem = this.computedContext?.testParts
35
+ .flatMap(testPart => testPart.sections.flatMap(section => section.items))
36
+ .find(item => item.active);
37
+ // If active item changed, reset shown before the update
38
+ if (this.#previousActiveItem !== activeItem) {
39
+ this.shown = false;
40
+ this.#previousActiveItem = activeItem; // Update previous active item
41
+ }
42
+ if (activeItem) {
43
+ const containsCorrectResponse = !!activeItem?.variables?.some(v => v['correctResponse']);
44
+ const containsMapping = !!activeItem?.variables?.some(v => {
45
+ return v['mapping']?.mapEntries?.length > 0 || v['areaMapping']?.areaMapEntries?.length > 0;
46
+ });
47
+ this.disabled = !containsCorrectResponse && !containsMapping;
48
+ }
49
+ else {
50
+ this.disabled = true;
51
+ }
52
+ }
53
+ #toggleState() {
54
+ if (this.disabled)
55
+ return;
56
+ this.shown = !this.shown;
57
+ this.dispatchEvent(new CustomEvent('test-show-correct-response', {
58
+ detail: this.shown,
59
+ bubbles: true
60
+ }));
61
+ }
62
+ #getDisplayedText() {
63
+ return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;
64
+ }
65
+ render() {
66
+ return html ` <div @click="${this.#toggleState}">${this.#getDisplayedText()}</div> `;
67
+ }
68
+ };
69
+ __decorate([
70
+ consume({ context: computedContext, subscribe: true })
71
+ ], TestShowCorrectResponse.prototype, "computedContext", void 0);
72
+ __decorate([
73
+ property({ type: Boolean, reflect: true })
74
+ ], TestShowCorrectResponse.prototype, "shown", void 0);
75
+ __decorate([
76
+ property({ type: Boolean, reflect: true })
77
+ ], TestShowCorrectResponse.prototype, "disabled", void 0);
78
+ __decorate([
79
+ property({ type: String })
80
+ ], TestShowCorrectResponse.prototype, "showCorrectText", void 0);
81
+ __decorate([
82
+ property({ type: String })
83
+ ], TestShowCorrectResponse.prototype, "hideCorrectText", void 0);
84
+ __decorate([
85
+ property({ type: String })
86
+ ], TestShowCorrectResponse.prototype, "noCorrectResponseText", void 0);
87
+ TestShowCorrectResponse = __decorate([
88
+ customElement('test-show-correct-response')
89
+ ], TestShowCorrectResponse);
90
+ export { TestShowCorrectResponse };
91
+ //# sourceMappingURL=test-show-correct-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-show-correct-response.js","sourceRoot":"","sources":["../../../src/components/test-show-correct-response/test-show-correct-response.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAIpC;;GAEG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,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AAE,MAAM,EAAE,CAAC;sEAAyD;AAjBzE,uBAAuB;IADnC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,uBAAuB,CA6DnC","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\n\nimport type { ComputedContext } from '@qti-components/base';\n\n/**\n * @deprecated test-show-correct-response is deprecated and will be removed in the future.\n */\n@customElement('test-show-correct-response')\nexport class TestShowCorrectResponse extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n public computedContext?: ComputedContext;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: Boolean, reflect: true }) shown = false;\n @property({ type: Boolean, reflect: true }) disabled = false;\n @property({ type: String }) showCorrectText = 'Show correct response';\n @property({ type: String }) hideCorrectText = 'Hide correct response';\n @property({ type: String }) noCorrectResponseText = 'No correct response specified';\n\n #previousActiveItem?: unknown; // Store previous active item reference\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n // If active item changed, reset shown before the update\n if (this.#previousActiveItem !== activeItem) {\n this.shown = false;\n this.#previousActiveItem = activeItem; // Update previous active item\n }\n\n if (activeItem) {\n const containsCorrectResponse = !!activeItem?.variables?.some(v => (v as any)['correctResponse']);\n const containsMapping = !!activeItem?.variables?.some(v => {\n return (v as any)['mapping']?.mapEntries?.length > 0 || (v as any)['areaMapping']?.areaMapEntries?.length > 0;\n });\n this.disabled = !containsCorrectResponse && !containsMapping;\n } else {\n this.disabled = true;\n }\n }\n #toggleState() {\n if (this.disabled) return;\n this.shown = !this.shown;\n\n this.dispatchEvent(\n new CustomEvent('test-show-correct-response', {\n detail: this.shown,\n bubbles: true\n })\n );\n }\n\n #getDisplayedText(): string {\n return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;\n }\n\n override render() {\n return html` <div @click=\"${this.#toggleState}\">${this.#getDisplayedText()}</div> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-show-correct-response': TestShowCorrectResponse;\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { LitElement } from 'lit';
2
+ import type { PropertyValues } from 'lit';
3
+ import type { TemplateFunction } from '@heximal/templates';
4
+ /**
5
+ * A custom web component that renders a test stamp using the Lit framework.
6
+ * This component is deprecated and will be removed in the future.
7
+ * @customElement
8
+ * @extends {LitElement}
9
+ */
10
+ export declare class TestStamp extends LitElement {
11
+ /**
12
+ * Indicates whether the component is in debug mode.
13
+ * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.
14
+ */
15
+ debug: boolean;
16
+ private computedContext;
17
+ private stampContext;
18
+ myTemplate: TemplateFunction;
19
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
20
+ connectedCallback(): void;
21
+ protected willUpdate(_changedProperties: PropertyValues): void;
22
+ render(): import("lit").TemplateResult<1>;
23
+ }
24
+ declare global {
25
+ interface HTMLElementTagNameMap {
26
+ 'test-stamp': TestStamp;
27
+ }
28
+ }
@@ -0,0 +1,104 @@
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 { customElement, property, state } from 'lit/decorators.js';
9
+ import { prepareTemplate } from '@heximal/templates';
10
+ import { consume } from '@lit/context';
11
+ import { computedContext } from '@qti-components/base';
12
+ /**
13
+ * A custom web component that renders a test stamp using the Lit framework.
14
+ * This component is deprecated and will be removed in the future.
15
+ * @customElement
16
+ * @extends {LitElement}
17
+ */
18
+ let TestStamp = class TestStamp extends LitElement {
19
+ constructor() {
20
+ super(...arguments);
21
+ /**
22
+ * Indicates whether the component is in debug mode.
23
+ * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.
24
+ */
25
+ this.debug = false;
26
+ this.stampContext = {
27
+ view: 'candidate',
28
+ activeItem: {},
29
+ activeSection: {
30
+ items: []
31
+ },
32
+ activeTestpart: {
33
+ items: [],
34
+ sections: []
35
+ },
36
+ test: {}
37
+ };
38
+ }
39
+ createRenderRoot() {
40
+ return this;
41
+ }
42
+ connectedCallback() {
43
+ super.connectedCallback();
44
+ const templateElement = this.querySelector('template');
45
+ if (!templateElement) {
46
+ this.myTemplate = null;
47
+ return;
48
+ }
49
+ this.myTemplate = prepareTemplate(templateElement);
50
+ }
51
+ willUpdate(_changedProperties) {
52
+ if (!this.computedContext) {
53
+ return;
54
+ }
55
+ const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);
56
+ const activeSection = activeTestPart?.sections.find(section => section.active);
57
+ const activeItem = activeSection?.items.find(item => item.active);
58
+ const { variables, ...augmentedItem } = activeItem || {};
59
+ if (!activeTestPart || !activeSection || !activeItem) {
60
+ return;
61
+ }
62
+ const augmentedTestPart = {
63
+ ...activeTestPart,
64
+ items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),
65
+ sections: activeTestPart.sections.map(section => ({
66
+ ...section,
67
+ items: section.items.map(({ variables, ...rest }) => rest)
68
+ }))
69
+ };
70
+ const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables, ...rest }) => rest) };
71
+ const { testParts, ...activeTest } = this.computedContext;
72
+ this.stampContext = {
73
+ view: this.computedContext.view,
74
+ activeItem: augmentedItem,
75
+ activeSection: augmentedSection,
76
+ activeTestpart: augmentedTestPart,
77
+ test: activeTest
78
+ };
79
+ this.dispatchEvent(new CustomEvent('qti-stamp-context-updated', {
80
+ detail: this.stampContext,
81
+ bubbles: true
82
+ }));
83
+ }
84
+ render() {
85
+ // if (!this.stampContext) return nothing;
86
+ return html ` ${this.debug ? html `<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}
87
+ ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
88
+ }
89
+ };
90
+ __decorate([
91
+ property({ type: Boolean, reflect: true })
92
+ ], TestStamp.prototype, "debug", void 0);
93
+ __decorate([
94
+ state(),
95
+ consume({ context: computedContext, subscribe: true })
96
+ ], TestStamp.prototype, "computedContext", void 0);
97
+ __decorate([
98
+ state()
99
+ ], TestStamp.prototype, "stampContext", void 0);
100
+ TestStamp = __decorate([
101
+ customElement('test-stamp')
102
+ ], TestStamp);
103
+ export { TestStamp };
104
+ //# sourceMappingURL=test-stamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-stamp.js","sourceRoot":"","sources":["../../../src/components/test-stamp/test-stamp.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOvD;;;;;GAKG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,UAAU;IAAlC;;QACL;;;WAGG;QAEI,UAAK,GAAG,KAAK,CAAC;QAOb,iBAAY,GAMhB;YACF,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE,EAAE;YACd,aAAa,EAAE;gBACb,KAAK,EAAE,EAAE;aACV;YACD,cAAc,EAAE;gBAC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UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;CACF,CAAA;AAvFQ;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;AA9BS,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CA6FrB","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { View } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * A custom web component that renders a test stamp using the Lit framework.\n * This component is deprecated and will be removed in the future.\n * @customElement\n * @extends {LitElement}\n */\n@customElement('test-stamp')\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 const { variables, ...augmentedItem } = activeItem || {};\n\n if (!activeTestPart || !activeSection || !activeItem) {\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 = { ...activeSection, items: activeSection.items.map(({ variables, ...rest }) => rest) };\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 sessionContext;
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,57 @@
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 { customElement } from 'lit/decorators.js';
10
+ import { prepareTemplate } from '@heximal/templates';
11
+ import { sessionContext } from '@qti-components/base';
12
+ let TestViewToggle = 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
+ this.dispatchEvent(new CustomEvent('on-test-switch-view', {
27
+ composed: true,
28
+ bubbles: true,
29
+ detail: view
30
+ }));
31
+ }
32
+ firstUpdated(_changedProperties) {
33
+ this.addEventListener('click', () => {
34
+ if (this.sessionContext?.view === 'scorer') {
35
+ this._switchView('candidate');
36
+ }
37
+ else {
38
+ this._switchView('scorer');
39
+ }
40
+ });
41
+ }
42
+ render() {
43
+ return html `${this.myTemplate
44
+ ? this.myTemplate({
45
+ view: this.sessionContext?.view
46
+ })
47
+ : nothing}`;
48
+ }
49
+ };
50
+ __decorate([
51
+ consume({ context: sessionContext, subscribe: true })
52
+ ], TestViewToggle.prototype, "sessionContext", void 0);
53
+ TestViewToggle = __decorate([
54
+ customElement('test-view-toggle')
55
+ ], TestViewToggle);
56
+ export { TestViewToggle };
57
+ //# sourceMappingURL=test-view-toggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-view-toggle.js","sourceRoot":"","sources":["../../../src/components/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,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM/C,IAAM,cAAc,GAApB,MAAM,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,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,qBAAqB,EAAE;YACrC,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI;SACb,CAAC,CACH,CAAC;IACJ,CAAC;IAEkB,YAAY,CAAC,kBAAkC;QAChE,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,IAAI,IAAI,CAAC,cAAc,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC3C,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,cAAc,EAAE,IAAI;aAChC,CAAC;YACJ,CAAC,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF,CAAA;AAvCS;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sDACf;AAR5B,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA+C1B","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, nothing } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { sessionContext } from '@qti-components/base';\n\nimport type { PropertyValues } from 'lit';\nimport type { SessionContext } from '@qti-components/base';\n\n@customElement('test-view-toggle')\nexport class TestViewToggle extends LitElement {\n myTemplate: any;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n @consume({ context: sessionContext, subscribe: true })\n private sessionContext: SessionContext;\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 this.dispatchEvent(\n new CustomEvent('on-test-switch-view', {\n composed: true,\n bubbles: true,\n detail: view\n })\n );\n }\n\n protected override firstUpdated(_changedProperties: PropertyValues): void {\n this.addEventListener('click', () => {\n if (this.sessionContext?.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.sessionContext?.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 sessionContext;
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,81 @@
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
+ var TestView_1;
9
+ import { html, LitElement } from 'lit';
10
+ import { customElement, property, state } from 'lit/decorators.js';
11
+ import { consume } from '@lit/context';
12
+ import { watch } from '@qti-components/utilities';
13
+ import { sessionContext } from '@qti-components/base';
14
+ let TestView = 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 = TestView_1.DEFAULT_VIEW_OPTIONS;
23
+ }
24
+ static { TestView_1 = this; }
25
+ static { this.DEFAULT_VIEW_OPTIONS = ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor']; }
26
+ connectedCallback() {
27
+ super.connectedCallback();
28
+ this.#updateViewOptions();
29
+ }
30
+ #updateViewOptions() {
31
+ if (this.viewOptions) {
32
+ const options = this.viewOptions.split(',').map(opt => opt.trim());
33
+ this._viewOptions = options.filter(opt => TestView_1.DEFAULT_VIEW_OPTIONS.includes(opt));
34
+ }
35
+ else {
36
+ this._viewOptions = TestView_1.DEFAULT_VIEW_OPTIONS;
37
+ }
38
+ }
39
+ _switchView(view) {
40
+ this.dispatchEvent(new CustomEvent('on-test-switch-view', {
41
+ composed: true,
42
+ bubbles: true,
43
+ detail: view
44
+ }));
45
+ }
46
+ render() {
47
+ return html `
48
+ <label part="label" for="viewSelect">${this.label}</label>
49
+ <select
50
+ part="select"
51
+ id="viewSelect"
52
+ @change=${(e) => {
53
+ const el = e.target;
54
+ this._switchView(el.value);
55
+ }}
56
+ >
57
+ ${this._viewOptions.map(v => html `<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
58
+ </select>
59
+ `;
60
+ }
61
+ };
62
+ __decorate([
63
+ consume({ context: sessionContext, subscribe: true })
64
+ ], TestView.prototype, "sessionContext", void 0);
65
+ __decorate([
66
+ property({ type: String })
67
+ ], TestView.prototype, "label", void 0);
68
+ __decorate([
69
+ property({ type: String, attribute: 'view-options' })
70
+ ], TestView.prototype, "viewOptions", void 0);
71
+ __decorate([
72
+ watch('viewOptions', { waitUntilFirstUpdate: true })
73
+ ], TestView.prototype, "_handleViewOptionsChange", void 0);
74
+ __decorate([
75
+ state()
76
+ ], TestView.prototype, "_viewOptions", void 0);
77
+ TestView = TestView_1 = __decorate([
78
+ customElement('test-view')
79
+ ], TestView);
80
+ export { TestView };
81
+ //# sourceMappingURL=test-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-view.js","sourceRoot":"","sources":["../../../src/components/test-view-toggle/test-view.ts"],"names":[],"mappings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AAC;IAES,WAAW,CAAC,IAAY;QAChC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,qBAAqB,EAAE;YACrC,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI;SACb,CAAC,CACH,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;6CAC8B,IAAI,CAAC,KAAK;;;;kBAIrC,CAAC,CAAQ,EAAE,EAAE;YACrB,MAAM,EAAE,GAAG,CAAC,CAAC,MAA2B,CAAC;YACzC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;;UAEC,IAAI,CAAC,YAAY,CAAC,GAAG,CACrB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAA,kBAAkB,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,WAAW,CAC1F;;KAEJ,CAAC;IACJ,CAAC;;AAxDO;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;gDACf;AAIvC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACZ;AAGwC;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAqB;AAEjE;IADT,KAAK,CAAC,aAAa,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;0DAGnD;AAQM;IADP,KAAK,EAAE;8CACuD;AAvBpD,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA6DpB","sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { sessionContext } from '@qti-components/base';\n\nimport type { SessionContext } from '@qti-components/base';\n\n@customElement('test-view')\nexport class TestView extends LitElement {\n static DEFAULT_VIEW_OPTIONS = ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'];\n\n @consume({ context: sessionContext, subscribe: true })\n private sessionContext: SessionContext;\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 this.dispatchEvent(\n new CustomEvent('on-test-switch-view', {\n composed: true,\n bubbles: true,\n detail: view\n })\n );\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.sessionContext.view}>${v}</option>`\n )}\n </select>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-view': TestView;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './components/index.js';
2
+ export * from './types/iqti-test.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './components/index.js';
2
+ export * from './types/iqti-test.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './components/index.js';\nexport * from './types/iqti-test.js';\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './test-navigation.mixin';
2
+ export * from './test-view.mixin';
3
+ export * from './test-base';
@@ -0,0 +1,4 @@
1
+ export * from './test-navigation.mixin';
2
+ export * from './test-view.mixin';
3
+ export * from './test-base';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mixins/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC","sourcesContent":["export * from './test-navigation.mixin';\nexport * from './test-view.mixin';\nexport * from './test-base';\n"]}
@@ -0,0 +1,17 @@
1
+ import { LitElement } from 'lit';
2
+ import { type SessionContext } from '@qti-components/base';
3
+ import type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';
4
+ import type { TestContext } from '@qti-components/base';
5
+ import type { VariableValue } from '@qti-components/base';
6
+ type Constructor<T = {}> = abstract new (...args: any[]) => T;
7
+ export interface TestBaseInterface extends LitElement {
8
+ testContext: Readonly<TestContext>;
9
+ sessionContext: Readonly<SessionContext>;
10
+ _testElement: QtiAssessmentTest;
11
+ updateItemVariables(itemRefID: string, variables: VariableValue<string | string[] | null>[]): void;
12
+ }
13
+ export declare const TestBaseMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<TestBaseInterface> & T;
14
+ declare const TestBase_base: Constructor<TestBaseInterface> & typeof LitElement;
15
+ export declare abstract class TestBase extends TestBase_base {
16
+ }
17
+ export {};