@qti-components/test 2.0.0-next.13 → 2.0.0-next.15

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/dist/components/index.d.ts +0 -2
  2. package/dist/components/index.js +0 -2
  3. package/dist/components/index.js.map +1 -1
  4. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +1 -1
  5. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
  6. package/dist/components/qti-assessment-test/qti-assessment-test.d.ts +1 -1
  7. package/dist/components/qti-assessment-test/qti-assessment-test.js +1 -1
  8. package/dist/components/qti-assessment-test/qti-assessment-test.js.map +1 -1
  9. package/dist/components/qti-number-presented/qti-number-presented.js +1 -1
  10. package/dist/components/qti-number-presented/qti-number-presented.js.map +1 -1
  11. package/dist/components/qti-number-selected/qti-number-selected.js +2 -2
  12. package/dist/components/qti-number-selected/qti-number-selected.js.map +1 -1
  13. package/dist/components/qti-test/qti-test.d.ts +2 -2
  14. package/dist/components/qti-test/qti-test.js +2 -2
  15. package/dist/components/qti-test/qti-test.js.map +1 -1
  16. package/dist/components/qti-test-variables/qti-test-variables.js +2 -2
  17. package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -1
  18. package/dist/components/styles.js +64 -34
  19. package/dist/components/styles.js.map +1 -1
  20. package/dist/components/test-container/test-container.js +1 -1
  21. package/dist/components/test-container/test-container.js.map +1 -1
  22. package/dist/components/test-end-attempt/test-end-attempt.d.ts +1 -1
  23. package/dist/components/test-end-attempt/test-end-attempt.js +2 -2
  24. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  25. package/dist/components/test-navigation/test-navigation.js +4 -4
  26. package/dist/components/test-navigation/test-navigation.js.map +1 -1
  27. package/dist/components/test-next/test-next.js +1 -1
  28. package/dist/components/test-next/test-next.js.map +1 -1
  29. package/dist/components/test-prev/test-prev.js +1 -1
  30. package/dist/components/test-prev/test-prev.js.map +1 -1
  31. package/dist/components/test-submit/test-submit.d.ts +1 -1
  32. package/dist/components/test-submit/test-submit.js +2 -2
  33. package/dist/components/test-submit/test-submit.js.map +1 -1
  34. package/dist/elements.d.ts +1 -63
  35. package/dist/elements.js +1 -5
  36. package/dist/elements.js.map +1 -1
  37. package/dist/mixins/test-base.js +3 -3
  38. package/dist/mixins/test-base.js.map +1 -1
  39. package/dist/mixins/test-navigation.mixin.js +13 -13
  40. package/dist/mixins/test-navigation.mixin.js.map +1 -1
  41. package/dist/mixins/test-processing.mixin.js +3 -3
  42. package/dist/mixins/test-processing.mixin.js.map +1 -1
  43. package/dist/mixins/test-state.mixin.d.ts +2 -7
  44. package/dist/mixins/test-state.mixin.js +6 -6
  45. package/dist/mixins/test-state.mixin.js.map +1 -1
  46. package/dist/mixins/test-view.mixin.js +2 -2
  47. package/dist/mixins/test-view.mixin.js.map +1 -1
  48. package/dist/plugin-api.d.ts +10 -0
  49. package/dist/plugin-api.js +9 -0
  50. package/dist/plugin-api.js.map +1 -0
  51. package/dist/plugin-state.d.ts +1 -1
  52. package/dist/plugin-state.js +1 -1
  53. package/dist/plugin-state.js.map +1 -1
  54. package/dist/plugins/elements.d.ts +5 -72
  55. package/dist/plugins/elements.js +6 -33
  56. package/dist/plugins/elements.js.map +1 -1
  57. package/dist/plugins/index.d.ts +1 -1
  58. package/dist/plugins/index.js +1 -1
  59. package/dist/plugins/index.js.map +1 -1
  60. package/dist/public-events.d.ts +22 -20
  61. package/dist/public-events.js +16 -20
  62. package/dist/public-events.js.map +1 -1
  63. package/dist/types/qti-test-state.d.ts +1 -1
  64. package/dist/types/qti-test-state.js.map +1 -1
  65. package/package.json +10 -6
  66. package/dist/components/test-bookmark/test-bookmark.d.ts +0 -48
  67. package/dist/components/test-bookmark/test-bookmark.js +0 -132
  68. package/dist/components/test-bookmark/test-bookmark.js.map +0 -1
  69. package/dist/components/test-check-item/test-check-item.d.ts +0 -20
  70. package/dist/components/test-check-item/test-check-item.js +0 -35
  71. package/dist/components/test-check-item/test-check-item.js.map +0 -1
  72. package/dist/components/test-item-link/test-item-link.d.ts +0 -13
  73. package/dist/components/test-item-link/test-item-link.js +0 -28
  74. package/dist/components/test-item-link/test-item-link.js.map +0 -1
  75. package/dist/components/test-print-context/test-print-context.d.ts +0 -11
  76. package/dist/components/test-print-context/test-print-context.js +0 -20
  77. package/dist/components/test-print-context/test-print-context.js.map +0 -1
  78. package/dist/components/test-print-item-variables/test-print-item-variables.d.ts +0 -17
  79. package/dist/components/test-print-item-variables/test-print-item-variables.js +0 -95
  80. package/dist/components/test-print-item-variables/test-print-item-variables.js.map +0 -1
  81. package/dist/components/test-print-state/test-print-state.d.ts +0 -27
  82. package/dist/components/test-print-state/test-print-state.js +0 -87
  83. package/dist/components/test-print-state/test-print-state.js.map +0 -1
  84. package/dist/components/test-scoring-buttons/test-scoring-buttons.d.ts +0 -19
  85. package/dist/components/test-scoring-buttons/test-scoring-buttons.js +0 -95
  86. package/dist/components/test-scoring-buttons/test-scoring-buttons.js.map +0 -1
  87. package/dist/components/test-scoring-feedback/test-scoring-feedback.d.ts +0 -13
  88. package/dist/components/test-scoring-feedback/test-scoring-feedback.js +0 -54
  89. package/dist/components/test-scoring-feedback/test-scoring-feedback.js.map +0 -1
  90. package/dist/components/test-section-link/test-section-link.d.ts +0 -13
  91. package/dist/components/test-section-link/test-section-link.js +0 -28
  92. package/dist/components/test-section-link/test-section-link.js.map +0 -1
  93. package/dist/components/test-stamp/test-stamp.d.ts +0 -29
  94. package/dist/components/test-stamp/test-stamp.js +0 -105
  95. package/dist/components/test-stamp/test-stamp.js.map +0 -1
  96. package/dist/components/test-view-toggle/test-view-toggle.d.ts +0 -16
  97. package/dist/components/test-view-toggle/test-view-toggle.js +0 -49
  98. package/dist/components/test-view-toggle/test-view-toggle.js.map +0 -1
  99. package/dist/components/test-view-toggle/test-view.d.ts +0 -20
  100. package/dist/components/test-view-toggle/test-view.js +0 -73
  101. package/dist/components/test-view-toggle/test-view.js.map +0 -1
  102. package/dist/tts/elements.d.ts +0 -28
  103. package/dist/tts/elements.js +0 -14
  104. package/dist/tts/elements.js.map +0 -1
  105. package/dist/tts/test-item-to-speech.d.ts +0 -252
  106. package/dist/tts/test-item-to-speech.js +0 -1053
  107. package/dist/tts/test-item-to-speech.js.map +0 -1
@@ -1,48 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import type { ComputedContext } from '@qti-components/base';
3
- declare module '../../types/qti-test-state' {
4
- interface QtiTestPluginState {
5
- /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */
6
- bookmarks: string[];
7
- }
8
- }
9
- /** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */
10
- export declare const bookmarkedItems: (context: Pick<ComputedContext, "plugins"> | undefined) => string[];
11
- /**
12
- * A toggle that marks the item on screen to come back to. The marks live in the test's state under
13
- * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a
14
- * reloaded test shows them again.
15
- *
16
- * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in
17
- * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button
18
- * (`role="button"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is
19
- * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads
20
- * the marks with `bookmarkedItems(computedContext)`.
21
- *
22
- * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a
23
- * stamp template that lists the items of a section, `<test-bookmark item="{{ item.identifier }}">`
24
- * puts a button next to each one.
25
- *
26
- * @slot - The label.
27
- * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.
28
- * @attr bookmarked - Reflected: the item on screen is bookmarked.
29
- * @attr disabled - Reflected: there is no item on screen.
30
- */
31
- export declare class TestBookmark extends LitElement {
32
- #private;
33
- protected computedContext?: ComputedContext;
34
- item?: string;
35
- bookmarked: boolean;
36
- disabled: boolean;
37
- static styles: import("lit").CSSResult[];
38
- constructor();
39
- connectedCallback(): void;
40
- protected willUpdate(): void;
41
- protected updated(): void;
42
- render(): import("lit").TemplateResult<1>;
43
- }
44
- declare global {
45
- interface HTMLElementTagNameMap {
46
- 'test-bookmark': TestBookmark;
47
- }
48
- }
@@ -1,132 +0,0 @@
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 { consume } from '@lit/context';
9
- import { property } from 'lit/decorators.js';
10
- import { computedContext } from '@qti-components/base';
11
- import * as styles from '../styles';
12
- import { dispatchPublic } from '../../public-events';
13
- import { pluginState } from '../../plugin-state';
14
- /** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */
15
- export const bookmarkedItems = (context) => pluginState(context, 'bookmarks') ?? [];
16
- /** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */
17
- const itemRefOf = (element) => {
18
- const itemRef = element.closest('qti-assessment-item-ref');
19
- if (itemRef)
20
- return itemRef.getAttribute('identifier') ?? undefined;
21
- const root = element.getRootNode();
22
- return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;
23
- };
24
- /**
25
- * A toggle that marks the item on screen to come back to. The marks live in the test's state under
26
- * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a
27
- * reloaded test shows them again.
28
- *
29
- * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in
30
- * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button
31
- * (`role="button"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is
32
- * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads
33
- * the marks with `bookmarkedItems(computedContext)`.
34
- *
35
- * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a
36
- * stamp template that lists the items of a section, `<test-bookmark item="{{ item.identifier }}">`
37
- * puts a button next to each one.
38
- *
39
- * @slot - The label.
40
- * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.
41
- * @attr bookmarked - Reflected: the item on screen is bookmarked.
42
- * @attr disabled - Reflected: there is no item on screen.
43
- */
44
- export class TestBookmark extends LitElement {
45
- static { this.styles = [
46
- styles.button,
47
- css `
48
- svg {
49
- width: 1.1em;
50
- height: 1.1em;
51
- flex: none;
52
- fill: none;
53
- stroke: currentColor;
54
- stroke-width: 2;
55
- stroke-linejoin: round;
56
- }
57
- :host([bookmarked]) {
58
- color: var(--qti-bookmark-color, #b45309);
59
- }
60
- :host([bookmarked]) svg {
61
- fill: currentColor;
62
- }
63
- `
64
- ]; }
65
- constructor() {
66
- super();
67
- this.bookmarked = false;
68
- this.disabled = false;
69
- this.addEventListener('click', () => this.#toggle());
70
- this.addEventListener('keydown', event => {
71
- if (event.key !== 'Enter' && event.key !== ' ')
72
- return;
73
- event.preventDefault();
74
- this.#toggle();
75
- });
76
- }
77
- connectedCallback() {
78
- super.connectedCallback();
79
- if (!this.hasAttribute('role'))
80
- this.setAttribute('role', 'button');
81
- if (!this.hasAttribute('tabindex'))
82
- this.setAttribute('tabindex', '0');
83
- }
84
- /** The item this button marks: its own, or else the one on screen. */
85
- get #activeItem() {
86
- return (this.item ||
87
- (itemRefOf(this) ??
88
- this.computedContext?.testParts
89
- ?.flatMap(part => part.sections.flatMap(section => section.items))
90
- .find(item => item.active)?.identifier));
91
- }
92
- willUpdate() {
93
- const active = this.#activeItem;
94
- this.disabled = !active;
95
- this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);
96
- }
97
- updated() {
98
- this.setAttribute('aria-pressed', String(this.bookmarked));
99
- this.setAttribute('aria-disabled', String(this.disabled));
100
- }
101
- #toggle() {
102
- const active = this.#activeItem;
103
- if (!active)
104
- return;
105
- const marked = bookmarkedItems(this.computedContext);
106
- const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];
107
- // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.
108
- dispatchPublic(this, 'cito-test-update-plugin-state', {
109
- plugin: 'bookmarks',
110
- value: next.length > 0 ? next : null
111
- });
112
- }
113
- render() {
114
- return html `<span class="control" part="button"
115
- ><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot
116
- ></span>`;
117
- }
118
- }
119
- __decorate([
120
- consume({ context: computedContext, subscribe: true }),
121
- property({ attribute: false })
122
- ], TestBookmark.prototype, "computedContext", void 0);
123
- __decorate([
124
- property({ reflect: true })
125
- ], TestBookmark.prototype, "item", void 0);
126
- __decorate([
127
- property({ type: Boolean, reflect: true })
128
- ], TestBookmark.prototype, "bookmarked", void 0);
129
- __decorate([
130
- property({ type: Boolean, reflect: true })
131
- ], TestBookmark.prototype, "disabled", void 0);
132
- //# sourceMappingURL=test-bookmark.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAq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,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;QAChG,4FAA4F;QAC5F,cAAc,CAAC,IAAI,EAAE,+BAA+B,EAAE;YACpD,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;SACrC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;;aAEF,CAAC;IACZ,CAAC;;AAnFS;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACa;AAEf;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAoB;AAEnB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { consume } from '@lit/context';\nimport { property } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { pluginState } from '../../plugin-state';\n\nimport type { ComputedContext } from '@qti-components/base';\n\ndeclare module '../../types/qti-test-state' {\n interface QtiTestPluginState {\n /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */\n bookmarks: string[];\n }\n}\n\n/** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */\nexport const bookmarkedItems = (context: Pick<ComputedContext, 'plugins'> | undefined): string[] =>\n pluginState(context, 'bookmarks') ?? [];\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A toggle that marks the item on screen to come back to. The marks live in the test's state under\n * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a\n * reloaded test shows them again.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in\n * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button\n * (`role=\"button\"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is\n * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads\n * the marks with `bookmarkedItems(computedContext)`.\n *\n * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a\n * stamp template that lists the items of a section, `<test-bookmark item=\"{{ item.identifier }}\">`\n * puts a button next to each one.\n *\n * @slot - The label.\n * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.\n * @attr bookmarked - Reflected: the item on screen is bookmarked.\n * @attr disabled - Reflected: there is no item on screen.\n */\nexport class TestBookmark extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext?: ComputedContext;\n\n @property({ reflect: true }) item?: string;\n\n @property({ type: Boolean, reflect: true }) bookmarked = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n static override styles = [\n styles.button,\n css`\n svg {\n width: 1.1em;\n height: 1.1em;\n flex: none;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n }\n :host([bookmarked]) {\n color: var(--qti-bookmark-color, #b45309);\n }\n :host([bookmarked]) svg {\n fill: currentColor;\n }\n `\n ];\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#toggle());\n this.addEventListener('keydown', event => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n this.#toggle();\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'button');\n if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', '0');\n }\n\n /** The item this button marks: its own, or else the one on screen. */\n get #activeItem(): string | undefined {\n return (\n this.item ||\n (itemRefOf(this) ??\n this.computedContext?.testParts\n ?.flatMap(part => part.sections.flatMap(section => section.items))\n .find(item => item.active)?.identifier)\n );\n }\n\n protected override willUpdate(): void {\n const active = this.#activeItem;\n this.disabled = !active;\n this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);\n }\n\n protected override updated(): void {\n this.setAttribute('aria-pressed', String(this.bookmarked));\n this.setAttribute('aria-disabled', String(this.disabled));\n }\n\n #toggle(): void {\n const active = this.#activeItem;\n if (!active) return;\n const marked = bookmarkedItems(this.computedContext);\n const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];\n // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.\n dispatchPublic(this, 'cito-test-update-plugin-state', {\n plugin: 'bookmarks',\n value: next.length > 0 ? next : null\n });\n }\n\n override render() {\n return html`<span class=\"control\" part=\"button\"\n ><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot\n ></span>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
@@ -1,20 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import type { View } from '@qti-components/base';
3
- /**
4
- * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which
5
- * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until
6
- * something switches it back (`test-view-toggle`).
7
- *
8
- * @attr view - The view to switch to after the attempt ended.
9
- */
10
- export declare class TestCheckItem extends LitElement {
11
- view: View;
12
- static styles: import("lit").CSSResult;
13
- constructor();
14
- render(): import("lit").TemplateResult<1>;
15
- }
16
- declare global {
17
- interface HTMLElementTagNameMap {
18
- 'test-check-item': TestCheckItem;
19
- }
20
- }
@@ -1,35 +0,0 @@
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 * as styles from '../styles';
10
- import { dispatchPublic } from '../../public-events';
11
- /**
12
- * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which
13
- * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until
14
- * something switches it back (`test-view-toggle`).
15
- *
16
- * @attr view - The view to switch to after the attempt ended.
17
- */
18
- export class TestCheckItem extends LitElement {
19
- static { this.styles = styles.button; }
20
- constructor() {
21
- super();
22
- this.view = 'scorer';
23
- this.addEventListener('click', () => {
24
- dispatchPublic(this, 'cito-test-end-attempt', {});
25
- dispatchPublic(this, 'cito-test-switch-view', this.view);
26
- });
27
- }
28
- render() {
29
- return styles.control;
30
- }
31
- }
32
- __decorate([
33
- property({ type: String })
34
- ], TestCheckItem.prototype, "view", void 0);
35
- //# sourceMappingURL=test-check-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;aAG3B,WAAM,GAAG,MAAM,CAAC,MAAM,AAAhB,CAAiB;IAEvC;QACE,KAAK,EAAE,CAAC;QALkB,SAAI,GAAS,QAAQ,CAAC;QAMhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAd2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { View } from '@qti-components/base';\n\n/**\n * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which\n * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until\n * something switches it back (`test-view-toggle`).\n *\n * @attr view - The view to switch to after the attempt ended.\n */\nexport class TestCheckItem extends LitElement {\n @property({ type: String }) view: View = 'scorer';\n\n static override styles = styles.button;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n dispatchPublic(this, 'cito-test-switch-view', this.view);\n });\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
@@ -1,13 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export declare class TestItemLink extends LitElement {
3
- static styles: import("lit").CSSResult;
4
- private itemId;
5
- constructor();
6
- protected _requestItem(identifier: string): void;
7
- render(): import("lit").TemplateResult<1>;
8
- }
9
- declare global {
10
- interface HTMLElementTagNameMap {
11
- 'test-item-link': TestItemLink;
12
- }
13
- }
@@ -1,28 +0,0 @@
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 * as styles from '../styles';
10
- import { dispatchPublic } from '../../public-events';
11
- export class TestItemLink extends LitElement {
12
- static { this.styles = styles.button; }
13
- constructor() {
14
- super();
15
- this.itemId = null;
16
- this.addEventListener('click', () => this._requestItem(this.itemId));
17
- }
18
- _requestItem(identifier) {
19
- dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });
20
- }
21
- render() {
22
- return styles.control;
23
- }
24
- }
25
- __decorate([
26
- property({ type: String, attribute: 'item-id' })
27
- ], TestItemLink.prototype, "itemId", void 0);
28
- //# sourceMappingURL=test-item-link.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,MAAM,CAAC,MAAM,AAAhB,CAAiB;IAKvC;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = styles.button;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import type { ComputedContext } from '@qti-components/base';
3
- export declare class TestPrintContext extends LitElement {
4
- computedContext?: ComputedContext;
5
- render(): import("lit").TemplateResult<1>;
6
- }
7
- declare global {
8
- interface HTMLElementTagNameMap {
9
- 'test-print-context': TestPrintContext;
10
- }
11
- }
@@ -1,20 +0,0 @@
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 } from 'lit';
8
- import { consume } from '@lit/context';
9
- import { state } from 'lit/decorators.js';
10
- import { computedContext } from '@qti-components/base';
11
- export class TestPrintContext extends LitElement {
12
- render() {
13
- return html ` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
14
- }
15
- }
16
- __decorate([
17
- state(),
18
- consume({ context: computedContext, subscribe: true })
19
- ], TestPrintContext.prototype, "computedContext", void 0);
20
- //# sourceMappingURL=test-print-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-print-context.js","sourceRoot":"","sources":["../../../src/components/test-print-context/test-print-context.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAKrC,MAAM;QACb,OAAO,IAAI,CAAA,gBAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,iBAAiB,CAAC;IAC5F,CAAC;CACF;AALQ;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;yDACd","sourcesContent":["import { html, LitElement } from 'lit';\nimport { consume } from '@lit/context';\nimport { state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestPrintContext extends LitElement {\n @state()\n @consume({ context: computedContext, subscribe: true })\n public computedContext?: ComputedContext;\n\n override render() {\n return html` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-print-context': TestPrintContext;\n }\n}\n"]}
@@ -1,17 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import type { ComputedContext } from '@qti-components/base';
3
- /**
4
- * A variable value as text: a list as `a, b`, a record (e.g. the response of a PCI) as `time: 3.6, point: 455 250`.
5
- * Without this a record printed as "[object Object]".
6
- */
7
- export declare const formatVariableValue: (value: unknown) => string;
8
- export declare class TestPrintVariables extends LitElement {
9
- computedContext?: ComputedContext;
10
- static styles: import("lit").CSSResult;
11
- render(): import("lit").TemplateResult<1>;
12
- }
13
- declare global {
14
- interface HTMLElementTagNameMap {
15
- 'test-print-item-variables': TestPrintVariables;
16
- }
17
- }
@@ -1,95 +0,0 @@
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, css, LitElement } from 'lit';
8
- import { consume } from '@lit/context';
9
- import { computedContext, isRecordValue } from '@qti-components/base';
10
- /**
11
- * A variable value as text: a list as `a, b`, a record (e.g. the response of a PCI) as `time: 3.6, point: 455 250`.
12
- * Without this a record printed as "[object Object]".
13
- */
14
- export const formatVariableValue = (value) => {
15
- if (value === null || value === undefined)
16
- return '';
17
- if (Array.isArray(value))
18
- return value.map(formatVariableValue).join(', ');
19
- if (isRecordValue(value)) {
20
- return Object.entries(value)
21
- .map(([field, fieldValue]) => `${field}: ${formatVariableValue(fieldValue)}`)
22
- .join(', ');
23
- }
24
- return String(value);
25
- };
26
- export class TestPrintVariables extends LitElement {
27
- static { this.styles = css `
28
- table {
29
- width: 100%;
30
- border-collapse: collapse;
31
- margin: 20px 0;
32
- font-size: 14px;
33
- text-align: left;
34
- }
35
- th,
36
- td {
37
- border: 1px solid #ddd;
38
- padding: 8px;
39
- }
40
- th {
41
- background-color: #f4f4f4;
42
- font-weight: bold;
43
- }
44
- h3 {
45
- margin-top: 20px;
46
- font-size: 16px;
47
- }
48
- `; }
49
- render() {
50
- const activeItem = this.computedContext?.testParts
51
- .flatMap(testPart => testPart.sections.flatMap(section => section.items))
52
- .find(item => item.active);
53
- if (!activeItem || !activeItem.variables)
54
- return html ``;
55
- const responseVariables = activeItem.variables.filter(v => v.type === 'response');
56
- const outcomeVariables = activeItem.variables.filter(v => v.type === 'outcome');
57
- const renderTable = (variables, title) => html `
58
- <h3>${title}</h3>
59
- <table>
60
- <thead>
61
- <tr>
62
- <th>Identifier</th>
63
- <th>Value</th>
64
- <th>Cardinality</th>
65
- <th>Base Type</th>
66
- <th>Correct Response / Mappings</th>
67
- </tr>
68
- </thead>
69
- <tbody>
70
- ${variables.map(v => {
71
- const correctResponse = formatVariableValue(v.correctResponse);
72
- const mapEntries = v.mapping?.mapEntries?.map(m => `${m.mapKey}=${m.mappedValue}pt`).join(', ') || '';
73
- const areaMapEntries = v.areaMapping?.areaMapEntries?.map(m => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(', ') || '';
74
- return html `
75
- <tr>
76
- <td>${v.identifier}</td>
77
- <td>${formatVariableValue(v.value)}</td>
78
- <td>${v.cardinality}</td>
79
- <td>${v.baseType}</td>
80
- <td>${correctResponse || mapEntries || areaMapEntries}</td>
81
- </tr>
82
- `;
83
- })}
84
- </tbody>
85
- </table>
86
- `;
87
- return html `
88
- ${renderTable(responseVariables, 'Response Variables')} ${renderTable(outcomeVariables, 'Outcome Variables')}
89
- `;
90
- }
91
- }
92
- __decorate([
93
- consume({ context: computedContext, subscribe: true })
94
- ], TestPrintVariables.prototype, "computedContext", void 0);
95
- //# sourceMappingURL=test-print-item-variables.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-print-item-variables.js","sourceRoot":"","sources":["../../../src/components/test-print-item-variables/test-print-item-variables.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKtE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAU,EAAE;IAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;aACzB,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;aAC5E,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,OAAO,kBAAmB,SAAQ,UAAU;aAIhC,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;GAqB3B,CAAC;IAEO,MAAM;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I,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAEzG,OAAO,IAAI,CAAA;;sBAED,CAAC,CAAC,UAAU;sBACZ,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;sBAC5B,CAAC,CAAC,WAAW;sBACb,CAAC,CAAC,QAAQ;sBACV,eAAe,IAAI,UAAU,IAAI,cAAc;;aAExD,CAAC;QACJ,CAAC,CAAC;;;KAGP,CAAC;QAEF,OAAO,IAAI,CAAA;QACP,WAAW,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,IAAI,WAAW,CAAC,gBAAgB,EAAE,mBAAmB,CAAC;KAC7G,CAAC;IACJ,CAAC;;AAzEM;IADN,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;2DACd","sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { consume } from '@lit/context';\n\nimport { computedContext, isRecordValue } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\nimport type { ComputedContext } from '@qti-components/base';\n\n/**\n * A variable value as text: a list as `a, b`, a record (e.g. the response of a PCI) as `time: 3.6, point: 455 250`.\n * Without this a record printed as \"[object Object]\".\n */\nexport const formatVariableValue = (value: unknown): string => {\n if (value === null || value === undefined) return '';\n if (Array.isArray(value)) return value.map(formatVariableValue).join(', ');\n if (isRecordValue(value)) {\n return Object.entries(value)\n .map(([field, fieldValue]) => `${field}: ${formatVariableValue(fieldValue)}`)\n .join(', ');\n }\n return String(value);\n};\n\nexport class TestPrintVariables extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n public computedContext?: ComputedContext;\n\n static override styles = css`\n table {\n width: 100%;\n border-collapse: collapse;\n margin: 20px 0;\n font-size: 14px;\n text-align: left;\n }\n th,\n td {\n border: 1px solid #ddd;\n padding: 8px;\n }\n th {\n background-color: #f4f4f4;\n font-weight: bold;\n }\n h3 {\n margin-top: 20px;\n font-size: 16px;\n }\n `;\n\n override render() {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const responseVariables: ResponseVariable[] = activeItem.variables.filter(v => v.type === 'response');\n const outcomeVariables = activeItem.variables.filter(v => v.type === 'outcome');\n\n const renderTable = (variables: ResponseVariable[], title: string) => html`\n <h3>${title}</h3>\n <table>\n <thead>\n <tr>\n <th>Identifier</th>\n <th>Value</th>\n <th>Cardinality</th>\n <th>Base Type</th>\n <th>Correct Response / Mappings</th>\n </tr>\n </thead>\n <tbody>\n ${variables.map(v => {\n const correctResponse = formatVariableValue(v.correctResponse);\n\n const mapEntries = v.mapping?.mapEntries?.map(m => `${m.mapKey}=${m.mappedValue}pt`).join(', ') || '';\n\n const areaMapEntries =\n v.areaMapping?.areaMapEntries?.map(m => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(', ') || '';\n\n return html`\n <tr>\n <td>${v.identifier}</td>\n <td>${formatVariableValue(v.value)}</td>\n <td>${v.cardinality}</td>\n <td>${v.baseType}</td>\n <td>${correctResponse || mapEntries || areaMapEntries}</td>\n </tr>\n `;\n })}\n </tbody>\n </table>\n `;\n\n return html`\n ${renderTable(responseVariables, 'Response Variables')} ${renderTable(outcomeVariables, 'Outcome Variables')}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-print-item-variables': TestPrintVariables;\n }\n}\n"]}
@@ -1,27 +0,0 @@
1
- import { LitElement, nothing } from 'lit';
2
- import type { TemplateResult } from 'lit';
3
- /**
4
- * Shows the test's state (`qtiTest.state`) as a tree you can fold open and shut, and keeps it current
5
- * on every `cito-test-state-changed`. A debug helper: drop it anywhere inside `<qti-test>`.
6
- *
7
- * The first two levels start open. A list entry with an `identifier` (an item, a variable) is labelled
8
- * by it. The element only lays out the tree; give it a font, colour and height from the page.
9
- *
10
- * @customElement test-print-state
11
- * @csspart key - the name of a field, or the label of a list entry
12
- * @csspart value - a value that is not an object or a list
13
- * @csspart count - the number of entries of a folded object or list
14
- */
15
- export declare class TestPrintState extends LitElement {
16
- #private;
17
- private testState?;
18
- static styles: import("lit").CSSResult;
19
- connectedCallback(): void;
20
- disconnectedCallback(): void;
21
- render(): TemplateResult<1> | typeof nothing;
22
- }
23
- declare global {
24
- interface HTMLElementTagNameMap {
25
- 'test-print-state': TestPrintState;
26
- }
27
- }
@@ -1,87 +0,0 @@
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, nothing } from 'lit';
8
- import { state } from 'lit/decorators.js';
9
- /**
10
- * Shows the test's state (`qtiTest.state`) as a tree you can fold open and shut, and keeps it current
11
- * on every `cito-test-state-changed`. A debug helper: drop it anywhere inside `<qti-test>`.
12
- *
13
- * The first two levels start open. A list entry with an `identifier` (an item, a variable) is labelled
14
- * by it. The element only lays out the tree; give it a font, colour and height from the page.
15
- *
16
- * @customElement test-print-state
17
- * @csspart key - the name of a field, or the label of a list entry
18
- * @csspart value - a value that is not an object or a list
19
- * @csspart count - the number of entries of a folded object or list
20
- */
21
- export class TestPrintState extends LitElement {
22
- #test = null;
23
- static { this.styles = css `
24
- :host {
25
- display: block;
26
- }
27
- ul {
28
- list-style: none;
29
- margin: 0;
30
- padding-inline-start: 1rem;
31
- }
32
- summary {
33
- cursor: pointer;
34
- }
35
- [part~='count'] {
36
- opacity: 0.7;
37
- }
38
- `; }
39
- #onStateChanged = (event) => {
40
- this.testState = event.detail;
41
- };
42
- connectedCallback() {
43
- super.connectedCallback();
44
- this.#test = this.closest('qti-test');
45
- this.#test?.addEventListener('cito-test-state-changed', this.#onStateChanged);
46
- this.testState = this.#test?.state;
47
- }
48
- disconnectedCallback() {
49
- super.disconnectedCallback();
50
- this.#test?.removeEventListener('cito-test-state-changed', this.#onStateChanged);
51
- this.#test = null;
52
- }
53
- render() {
54
- if (!this.testState)
55
- return nothing;
56
- return html `<ul>
57
- ${this.#renderNode('state', this.testState, 0)}
58
- </ul>`;
59
- }
60
- #renderNode(label, value, depth) {
61
- if (value === null || typeof value !== 'object') {
62
- return html `<li><span part="key">${label}</span>: <span part="value">${JSON.stringify(value)}</span></li>`;
63
- }
64
- const entries = Array.isArray(value)
65
- ? value.map((entry, index) => [entryLabel(entry, index), entry])
66
- : Object.entries(value);
67
- const count = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;
68
- // `open` is bound once per depth, so Lit leaves a node the reader folded alone on the next update.
69
- return html `<li>
70
- <details ?open=${depth < 2}>
71
- <summary><span part="key">${label}</span> <span part="count">${count}</span></summary>
72
- <ul>
73
- ${entries.map(([key, entry]) => this.#renderNode(key, entry, depth + 1))}
74
- </ul>
75
- </details>
76
- </li>`;
77
- }
78
- }
79
- __decorate([
80
- state()
81
- ], TestPrintState.prototype, "testState", void 0);
82
- /** An item or a variable is easier to find by its identifier than by its index. */
83
- const entryLabel = (entry, index) => {
84
- const identifier = entry?.identifier;
85
- return typeof identifier === 'string' ? `${index} · ${identifier}` : String(index);
86
- };
87
- //# sourceMappingURL=test-print-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-print-state.js","sourceRoot":"","sources":["../../../src/components/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;AAO1C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAG5C,KAAK,GAAuB,IA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K,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;YAChE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QACnF,mGAAmG;QACnG,OAAO,IAAI,CAAA;uBACQ,KAAK,GAAG,CAAC;oCACI,KAAK,8BAA8B,KAAK;;YAEhE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;;;UAGxE,CAAC;IACT,CAAC;;AA9DgB;IAAhB,KAAK,EAAE;iDAAkC;AAiE5C,mFAAmF;AACnF,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,KAAa,EAAU,EAAE;IAC3D,MAAM,UAAU,GAAI,KAAyC,EAAE,UAAU,CAAC;IAC1E,OAAO,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,MAAM,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,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 '../../types/qti-test-state';\n\ntype TestElement = HTMLElement & { state?: QtiTestState };\n\n/**\n * Shows the test's state (`qtiTest.state`) as a tree you can fold open and shut, and keeps it current\n * on every `cito-test-state-changed`. A debug helper: drop it anywhere inside `<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 #test: TestElement | null = null;\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 #onStateChanged = (event: Event) => {\n this.testState = (event as CustomEvent<QtiTestState>).detail;\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#test = this.closest<TestElement>('qti-test');\n this.#test?.addEventListener('cito-test-state-changed', this.#onStateChanged);\n this.testState = this.#test?.state;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#test?.removeEventListener('cito-test-state-changed', this.#onStateChanged);\n this.#test = null;\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"]}
@@ -1,19 +0,0 @@
1
- import { LitElement, nothing } from 'lit';
2
- import type { TemplateFunction } from '@heximal/templates';
3
- import type { ComputedContext } from '@qti-components/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
- }