@citolab/qti-components 7.0.11 → 7.0.12

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 (120) hide show
  1. package/cdn/chunks/chunk-34HKCUN3.js +1 -0
  2. package/cdn/chunks/chunk-4HUJGZW6.js +1 -0
  3. package/cdn/chunks/chunk-7HFMTJAH.js +1 -0
  4. package/cdn/chunks/chunk-ARBRHQDY.js +951 -0
  5. package/cdn/chunks/chunk-BGM3IB5N.js +8 -0
  6. package/cdn/chunks/chunk-CIN2QCYB.js +3537 -0
  7. package/cdn/chunks/chunk-DJM7EUKM.js +1 -0
  8. package/cdn/chunks/chunk-F7RWORNK.js +951 -0
  9. package/cdn/chunks/chunk-HD7EMR2A.js +1 -0
  10. package/cdn/chunks/chunk-HEKMMOBI.js +1 -0
  11. package/cdn/chunks/chunk-I76GONMP.js +951 -0
  12. package/cdn/chunks/chunk-KVCXK3CQ.js +8 -0
  13. package/cdn/chunks/chunk-LICVWYUY.js +3537 -0
  14. package/cdn/chunks/chunk-LWN3NRJE.js +3560 -0
  15. package/cdn/chunks/chunk-MBWNNFLY.js +951 -0
  16. package/cdn/chunks/chunk-MCTQZZG4.js +1 -0
  17. package/cdn/chunks/chunk-NGC3MISE.js +1 -0
  18. package/cdn/chunks/chunk-NP3JIBVS.js +1 -0
  19. package/cdn/chunks/chunk-NTR5PVWP.js +3560 -0
  20. package/cdn/chunks/chunk-P2YEZLMB.js +951 -0
  21. package/cdn/chunks/chunk-QWJABXM7.js +951 -0
  22. package/cdn/chunks/chunk-TCHROQU3.js +1 -0
  23. package/cdn/chunks/chunk-TSTGSXP2.js +951 -0
  24. package/cdn/chunks/chunk-V6G6L6I3.js +3537 -0
  25. package/cdn/exports/computed-item.context.js +1 -0
  26. package/cdn/exports/qti-condition-expression.js +1 -1
  27. package/cdn/exports/qti-expression.js +1 -1
  28. package/cdn/index.global.js +1 -1
  29. package/cdn/index.js +1 -1
  30. package/cdn/qti-components/index.js +1 -1
  31. package/cdn/qti-item/core/index.js +1 -1
  32. package/cdn/qti-test/components/index.js +1 -1
  33. package/cdn/qti-test/components/test-navigation.js +1 -1
  34. package/cdn/qti-test/components/test-next.js +1 -1
  35. package/cdn/qti-test/components/test-paging-buttons-stamp.js +1 -1
  36. package/cdn/qti-test/components/test-prev.js +1 -1
  37. package/cdn/qti-test/components/test-print-item-variables.js +1 -1
  38. package/cdn/qti-test/components/test-section-buttons-stamp.js +1 -1
  39. package/cdn/qti-test/components/test-view.js +1 -1
  40. package/cdn/qti-test/core/index.js +1 -1
  41. package/dist/chunks/chunk-4QYZHR36.js +6541 -0
  42. package/dist/chunks/chunk-4QYZHR36.js.map +1 -0
  43. package/dist/chunks/chunk-5QYVCPUS.js +3775 -0
  44. package/dist/chunks/chunk-5QYVCPUS.js.map +1 -0
  45. package/dist/chunks/chunk-6Z5YR5U2.js +8 -0
  46. package/dist/chunks/chunk-6Z5YR5U2.js.map +1 -0
  47. package/dist/chunks/chunk-7YUCREDM.js +3783 -0
  48. package/dist/chunks/chunk-7YUCREDM.js.map +1 -0
  49. package/dist/chunks/chunk-BIQNE2L4.js +6558 -0
  50. package/dist/chunks/chunk-BIQNE2L4.js.map +1 -0
  51. package/dist/chunks/chunk-CBSVVXVJ.js +6558 -0
  52. package/dist/chunks/chunk-CBSVVXVJ.js.map +1 -0
  53. package/dist/chunks/chunk-D4QP2AIX.js +222 -0
  54. package/dist/chunks/chunk-D4QP2AIX.js.map +1 -0
  55. package/dist/chunks/chunk-DACJEGD7.js +95 -0
  56. package/dist/chunks/chunk-DACJEGD7.js.map +1 -0
  57. package/dist/chunks/chunk-EFTOJP3Z.js +99 -0
  58. package/dist/chunks/chunk-EFTOJP3Z.js.map +1 -0
  59. package/dist/chunks/chunk-FSIQI3KQ.js +6541 -0
  60. package/dist/chunks/chunk-FSIQI3KQ.js.map +1 -0
  61. package/dist/chunks/chunk-KOQLAE5C.js +211 -0
  62. package/dist/chunks/chunk-KOQLAE5C.js.map +1 -0
  63. package/dist/chunks/chunk-KX5XK2I2.js +636 -0
  64. package/dist/chunks/chunk-KX5XK2I2.js.map +1 -0
  65. package/dist/chunks/chunk-LUJE2OUT.js +637 -0
  66. package/dist/chunks/chunk-LUJE2OUT.js.map +1 -0
  67. package/dist/chunks/chunk-M3ODN2LD.js +30 -0
  68. package/dist/chunks/chunk-M3ODN2LD.js.map +1 -0
  69. package/dist/chunks/chunk-O233FYKS.js +45 -0
  70. package/dist/chunks/chunk-O233FYKS.js.map +1 -0
  71. package/dist/chunks/chunk-STT3B34J.js +43 -0
  72. package/dist/chunks/chunk-STT3B34J.js.map +1 -0
  73. package/dist/chunks/chunk-TYV2BDMU.js +8 -0
  74. package/dist/chunks/chunk-TYV2BDMU.js.map +1 -0
  75. package/dist/chunks/chunk-UDUW5VX5.js +6545 -0
  76. package/dist/chunks/chunk-UDUW5VX5.js.map +1 -0
  77. package/dist/chunks/chunk-UIVMRBML.js +230 -0
  78. package/dist/chunks/chunk-UIVMRBML.js.map +1 -0
  79. package/dist/chunks/chunk-VYXSKCOZ.js +3706 -0
  80. package/dist/chunks/chunk-VYXSKCOZ.js.map +1 -0
  81. package/dist/chunks/chunk-X4BXOQJA.js +6558 -0
  82. package/dist/chunks/chunk-X4BXOQJA.js.map +1 -0
  83. package/dist/exports/computed-item.context.d.ts +16 -0
  84. package/dist/exports/computed-item.context.js +8 -0
  85. package/dist/exports/computed-item.context.js.map +1 -0
  86. package/dist/exports/computed.context.d.ts +4 -11
  87. package/dist/exports/computed.context.js +1 -1
  88. package/dist/exports/session.context.d.ts +2 -2
  89. package/dist/index.d.ts +5 -4
  90. package/dist/index.js +21 -16
  91. package/dist/qti-components/index.d.ts +2 -2
  92. package/dist/qti-components/index.js +2 -2
  93. package/dist/qti-components-jsx.d.ts +27 -1
  94. package/dist/qti-item/core/index.d.ts +35 -1
  95. package/dist/qti-item/core/index.js +6 -1
  96. package/dist/qti-loader/index.d.ts +2 -2
  97. package/dist/qti-response-declaration-CBb7rZqd.d.ts +1054 -0
  98. package/dist/qti-response-declaration-CgrlodE6.d.ts +1052 -0
  99. package/dist/qti-response-declaration-DZzGH8xM.d.ts +1057 -0
  100. package/dist/qti-response-declaration-DbMCe0zZ.d.ts +1052 -0
  101. package/dist/qti-test/components/index.d.ts +3 -2
  102. package/dist/qti-test/components/index.js +12 -12
  103. package/dist/qti-test/components/test-navigation.d.ts +4 -3
  104. package/dist/qti-test/components/test-navigation.js +2 -2
  105. package/dist/qti-test/components/test-next.d.ts +1 -0
  106. package/dist/qti-test/components/test-next.js +2 -2
  107. package/dist/qti-test/components/test-paging-buttons-stamp.js +2 -2
  108. package/dist/qti-test/components/test-prev.d.ts +1 -0
  109. package/dist/qti-test/components/test-prev.js +2 -2
  110. package/dist/qti-test/components/test-print-item-variables.d.ts +1 -0
  111. package/dist/qti-test/components/test-print-item-variables.js +2 -2
  112. package/dist/qti-test/components/test-section-buttons-stamp.js +2 -2
  113. package/dist/qti-test/core/index.d.ts +4 -4
  114. package/dist/qti-test/core/index.js +1 -1
  115. package/dist/qti-test-part-B8Dq08t9.d.ts +85 -0
  116. package/dist/qti-test-part-BYdORfcD.d.ts +85 -0
  117. package/dist/qti-test-part-CQycFqJC.d.ts +85 -0
  118. package/dist/qti-test-part-a-IuoG8-.d.ts +85 -0
  119. package/dist/vscode.html-custom-data.json +12 -0
  120. package/package.json +1 -1
@@ -0,0 +1,222 @@
1
+ import {
2
+ sessionContext
3
+ } from "./chunk-QTH3WLGY.js";
4
+ import {
5
+ testContext
6
+ } from "./chunk-ODLYMQOS.js";
7
+ import {
8
+ computedContext
9
+ } from "./chunk-6Z5YR5U2.js";
10
+ import {
11
+ __decorateClass
12
+ } from "./chunk-H2JE6IVU.js";
13
+
14
+ // src/lib/qti-test/components/test-navigation.ts
15
+ import { consume, provide } from "@lit/context";
16
+ import { html, LitElement } from "lit";
17
+ import { customElement, property, state } from "lit/decorators.js";
18
+ var TestNavigation = class extends LitElement {
19
+ constructor() {
20
+ super();
21
+ this.identifier = void 0;
22
+ this.initContext = [];
23
+ this.configContext = {};
24
+ this.autoScoreItems = false;
25
+ this.addEventListener("qti-assessment-test-connected", this._handleTestConnected.bind(this));
26
+ this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
27
+ this.addEventListener("qti-interaction-changed", this._handleInteractionChanged.bind(this));
28
+ this.addEventListener("test-end-attempt", this._handleTestEndAttempt.bind(this));
29
+ this.addEventListener("test-show-correct-response", this._handleTestShowCorrectResponse.bind(this));
30
+ }
31
+ _handleTestEndAttempt(_event) {
32
+ const qtiItemEl = this._testElement.querySelector(
33
+ `qti-assessment-item-ref[identifier="${this._sessionContext.navItemId}"]`
34
+ );
35
+ const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
36
+ const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
37
+ qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
38
+ }
39
+ _handleTestShowCorrectResponse(event) {
40
+ const qtiItemEl = this._testElement.querySelector(
41
+ `qti-assessment-item-ref[identifier="${this._sessionContext.navItemId}"]`
42
+ );
43
+ const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
44
+ qtiAssessmentItemEl.showCorrectResponse(event.detail);
45
+ }
46
+ _handleInteractionChanged(_event) {
47
+ if (this.autoScoreItems) {
48
+ const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
49
+ const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
50
+ if (scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
51
+ assessmentItem.processResponse();
52
+ }
53
+ }
54
+ }
55
+ render() {
56
+ return html`<slot></slot>`;
57
+ }
58
+ /* PK: on test connected we can build the computed context */
59
+ _handleTestConnected(event) {
60
+ this._testElement = event.detail;
61
+ const testPartElements = Array.from(this._testElement?.querySelectorAll(`qti-test-part`) || []);
62
+ this.computedContext = {
63
+ testParts: testPartElements.map((testPart) => {
64
+ const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
65
+ return {
66
+ active: false,
67
+ identifier: testPart.identifier,
68
+ sections: sectionElements.map((section) => {
69
+ const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
70
+ return {
71
+ active: false,
72
+ identifier: section.identifier,
73
+ title: section.title,
74
+ items: itemElements.map((item) => {
75
+ return {
76
+ active: false,
77
+ identifier: item.identifier,
78
+ href: item.href
79
+ };
80
+ })
81
+ };
82
+ })
83
+ };
84
+ })
85
+ };
86
+ }
87
+ /* PK: on item connected we can add item only properties in the xml */
88
+ _handleItemConnected(event) {
89
+ const itemElement = event.detail;
90
+ this.computedContext = {
91
+ ...this.computedContext,
92
+ testParts: this.computedContext.testParts.map((testPart) => {
93
+ return {
94
+ ...testPart,
95
+ sections: testPart.sections.map((section) => {
96
+ return {
97
+ ...section,
98
+ items: section.items.map(
99
+ (item) => item.identifier === itemElement.identifier ? {
100
+ ...item,
101
+ title: itemElement.title,
102
+ adaptive: itemElement.adaptive == "true" || false,
103
+ timeDependent: itemElement.timeDependent == "true" || false
104
+ } : item
105
+ )
106
+ };
107
+ })
108
+ };
109
+ })
110
+ };
111
+ }
112
+ /* PK: on every change of the candidate we will recomputed the computedContext */
113
+ willUpdate(_changedProperties) {
114
+ if (!this.computedContext) return;
115
+ let itemIndex = 1;
116
+ this.computedContext = {
117
+ ...this.computedContext,
118
+ testParts: this.computedContext.testParts.map((testPart) => {
119
+ return {
120
+ ...testPart,
121
+ active: this._sessionContext?.navPartId === testPart.identifier || false,
122
+ sections: testPart.sections.map((section) => {
123
+ return {
124
+ ...section,
125
+ active: this._sessionContext?.navSectionId === section.identifier || false,
126
+ completed: section.items.every(
127
+ (item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"
128
+ ),
129
+ items: section.items.map((item) => {
130
+ const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
131
+ let computedItem;
132
+ if (this.initContext) {
133
+ const initContext = this.initContext.find((i) => i.identifier === item.identifier);
134
+ computedItem = { ...item, ...itemContext, ...initContext };
135
+ } else {
136
+ computedItem = { ...item, ...itemContext };
137
+ }
138
+ const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
139
+ const score = parseInt(rawscore?.toString());
140
+ const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
141
+ const categories = computedItem.category ? computedItem.category?.split(" ") : [];
142
+ const type = categories.includes(this.configContext?.infoItemCategory) ? "info" : "regular";
143
+ const active = this._sessionContext?.navItemId === computedItem.identifier || false;
144
+ const correct = (
145
+ // this._testContext.view === 'scorer' &&
146
+ type == "regular" && score !== void 0 && !isNaN(score) && score > 0 || false
147
+ );
148
+ const incorrect = (
149
+ // this._testContext.view === 'scorer' &&
150
+ type == "regular" && score !== void 0 && !isNaN(score) && score <= 0 || false
151
+ );
152
+ const completed = (
153
+ // this._testContext.view === 'candidate' &&
154
+ completionStatus === "completed"
155
+ );
156
+ const responseVariables = computedItem.variables?.filter(
157
+ (v) => v.type === "response" && v.identifier.toLowerCase().startsWith("response")
158
+ );
159
+ const sortedResponseVariables = responseVariables?.sort(
160
+ (a, b) => a.identifier.localeCompare(b.identifier)
161
+ );
162
+ const response = sortedResponseVariables.length === 0 ? "" : sortedResponseVariables?.map((v) => {
163
+ if (Array.isArray(v.value)) {
164
+ return v.value.join("&");
165
+ }
166
+ return v.value;
167
+ }).join("#");
168
+ const index = categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
169
+ return {
170
+ ...computedItem,
171
+ // rawscore, // not necessary for outside world
172
+ // score, // not necessary for outside world
173
+ // completionStatus, // not necessary for outside world
174
+ // categories, // not necessary for outside world
175
+ type,
176
+ active,
177
+ correct,
178
+ incorrect,
179
+ completed,
180
+ index,
181
+ response
182
+ };
183
+ })
184
+ };
185
+ })
186
+ };
187
+ })
188
+ };
189
+ }
190
+ };
191
+ __decorateClass([
192
+ property({ type: String })
193
+ ], TestNavigation.prototype, "identifier", 2);
194
+ __decorateClass([
195
+ state()
196
+ ], TestNavigation.prototype, "initContext", 2);
197
+ __decorateClass([
198
+ state(),
199
+ consume({ context: testContext, subscribe: true })
200
+ ], TestNavigation.prototype, "_testContext", 2);
201
+ __decorateClass([
202
+ state(),
203
+ consume({ context: sessionContext, subscribe: true })
204
+ ], TestNavigation.prototype, "_sessionContext", 2);
205
+ __decorateClass([
206
+ state()
207
+ ], TestNavigation.prototype, "configContext", 2);
208
+ __decorateClass([
209
+ state(),
210
+ provide({ context: computedContext })
211
+ ], TestNavigation.prototype, "computedContext", 2);
212
+ __decorateClass([
213
+ property({ type: Boolean, attribute: "auto-score-items" })
214
+ ], TestNavigation.prototype, "autoScoreItems", 2);
215
+ TestNavigation = __decorateClass([
216
+ customElement("test-navigation")
217
+ ], TestNavigation);
218
+
219
+ export {
220
+ TestNavigation
221
+ };
222
+ //# sourceMappingURL=chunk-D4QP2AIX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/qti-test/components/test-navigation.ts"],"sourcesContent":["import { consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\nimport { testContext } from '../../exports/test.context';\nimport { sessionContext } from '../../exports/session.context';\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { QtiAssessmentItem } from '../../qti-components';\nimport type { OutcomeVariable } from '../../exports/variables';\nimport type { ComputedContext } from '../../exports/computed.context';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef, QtiAssessmentSection, QtiAssessmentTest, QtiTestPart } from '../core';\nimport type { ConfigContext } from '../../exports/config.context';\nimport type { SessionContext } from '../../exports/session.context';\nimport type { TestContext } from '../../exports/test.context';\n\ntype CustomEventMap = {\n 'test-end-attempt': CustomEvent;\n 'test-show-correct-response': CustomEvent<{ value: boolean }>;\n};\n\ndeclare global {\n interface GlobalEventHandlersEventMap extends CustomEventMap {}\n}\n\n@customElement('test-navigation')\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier = undefined;\n\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n @state()\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n public _sessionContext?: SessionContext;\n\n @state()\n public configContext: ConfigContext = {};\n\n @state()\n @provide({ context: computedContext })\n public computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n private _testElement: QtiAssessmentTest;\n\n constructor() {\n super();\n this.addEventListener('qti-assessment-test-connected', this._handleTestConnected.bind(this));\n this.addEventListener('qti-assessment-item-connected', this._handleItemConnected.bind(this));\n\n this.addEventListener('qti-interaction-changed', this._handleInteractionChanged.bind(this));\n\n this.addEventListener('test-end-attempt', this._handleTestEndAttempt.bind(this));\n this.addEventListener('test-show-correct-response', this._handleTestShowCorrectResponse.bind(this));\n }\n\n private _handleTestEndAttempt(_event: CustomEvent) {\n const qtiItemEl = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemId}\"]`\n );\n const qtiAssessmentItemEl = qtiItemEl.assessmentItem;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n private _handleTestShowCorrectResponse(event: CustomEvent) {\n const qtiItemEl = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemId}\"]`\n );\n const qtiAssessmentItemEl = qtiItemEl.assessmentItem;\n qtiAssessmentItemEl.showCorrectResponse(event.detail);\n }\n\n private _handleInteractionChanged(_event: CustomEvent) {\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest('qti-assessment-item');\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === 'false') {\n assessmentItem.processResponse();\n }\n }\n }\n\n render() {\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n _handleTestConnected(event: CustomEvent) {\n this._testElement = event.detail as QtiAssessmentTest;\n const testPartElements = Array.from(this._testElement?.querySelectorAll<QtiTestPart>(`qti-test-part`) || []);\n this.computedContext = {\n testParts: testPartElements.map(testPart => {\n const sectionElements = [...testPart.querySelectorAll<QtiAssessmentSection>(`qti-assessment-section`)];\n return {\n active: false,\n identifier: testPart.identifier,\n sections: sectionElements.map(section => {\n const itemElements = [...section.querySelectorAll<QtiAssessmentItemRef>(`qti-assessment-item-ref`)];\n return {\n active: false,\n identifier: section.identifier,\n title: section.title,\n items: itemElements.map(item => {\n return {\n active: false,\n identifier: item.identifier,\n href: item.href\n };\n })\n };\n })\n };\n })\n };\n\n // const sections = this.computedContext?.testParts.flatMap(testPart => testPart.sections);\n\n // let id;\n // if (this.navigate === 'section') {\n // id = sections.find(section => section.active).identifier;\n // }\n // if (this.navigate === 'item') {\n // id = sections.flatMap(section => section.items).find(item => item.active).identifier;\n // }\n\n // if (id) {\n // this.dispatchEvent(\n // new CustomEvent('qti-request-navigation', {\n // detail: { type: this.navigate, id },\n // bubbles: true,\n // composed: true\n // })\n // );\n // }\n }\n\n /* PK: on item connected we can add item only properties in the xml */\n _handleItemConnected(event: CustomEvent) {\n const itemElement = event.detail as QtiAssessmentItem;\n this.computedContext = {\n ...this.computedContext,\n testParts: this.computedContext.testParts.map(testPart => {\n return {\n ...testPart,\n sections: testPart.sections.map(section => {\n return {\n ...section,\n items: section.items.map(item =>\n item.identifier === itemElement.identifier\n ? {\n ...item,\n title: itemElement.title,\n adaptive: itemElement.adaptive == 'true' || false,\n timeDependent: itemElement.timeDependent == 'true' || false\n }\n : item\n )\n };\n })\n };\n })\n };\n }\n\n /* PK: on every change of the candidate we will recomputed the computedContext */\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) return;\n\n let itemIndex = 1;\n this.computedContext = {\n ...this.computedContext,\n testParts: this.computedContext.testParts.map(testPart => {\n return {\n ...testPart,\n active: this._sessionContext?.navPartId === testPart.identifier || false,\n sections: testPart.sections.map(section => {\n return {\n ...section,\n active: this._sessionContext?.navSectionId === section.identifier || false,\n completed: section.items.every(\n item =>\n this._testContext.items\n .find(i => i.identifier === item.identifier)\n ?.variables.find(v => v.identifier === 'completionStatus').value === 'completed'\n ),\n\n items: section.items.map(item => {\n const itemContext = this._testContext?.items.find(i => i.identifier === item.identifier);\n let computedItem;\n\n if (this.initContext) {\n const initContext = this.initContext.find(i => i.identifier === item.identifier);\n computedItem = { ...item, ...itemContext, ...initContext };\n } else {\n computedItem = { ...item, ...itemContext };\n }\n\n const rawscore = computedItem.variables?.find(vr => vr.identifier == 'SCORE')?.value;\n const score = parseInt(rawscore?.toString());\n const completionStatus = computedItem.variables?.find(v => v.identifier === 'completionStatus')?.value;\n const categories = computedItem.category ? computedItem.category?.split(' ') : [];\n\n const type = categories.includes(this.configContext?.infoItemCategory) ? 'info' : 'regular'; // rounded-full\n const active = this._sessionContext?.navItemId === computedItem.identifier || false; // !border-sky-600\n\n const correct =\n // this._testContext.view === 'scorer' &&\n (type == 'regular' && score !== undefined && !isNaN(score) && score > 0) || false; // bg-green-100 border-green-400\n const incorrect =\n // this._testContext.view === 'scorer' &&\n (type == 'regular' && score !== undefined && !isNaN(score) && score <= 0) || false; // bg-red-100 border-red-400\n const completed =\n // this._testContext.view === 'candidate' &&\n completionStatus === 'completed';\n // || item.category === this.host._configContext?.infoItemCategory || false\n const responseVariables = computedItem.variables?.filter(\n v => v.type === 'response' && v.identifier.toLowerCase().startsWith('response')\n );\n // sort the response variables by the order of the string: identifier\n const sortedResponseVariables = responseVariables?.sort((a, b) =>\n a.identifier.localeCompare(b.identifier)\n );\n const response =\n sortedResponseVariables.length === 0\n ? ''\n : sortedResponseVariables\n ?.map(v => {\n if (Array.isArray(v.value)) {\n return v.value.join('&');\n }\n return v.value;\n })\n .join('#');\n\n const index = categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;\n\n return {\n ...computedItem,\n // rawscore, // not necessary for outside world\n // score, // not necessary for outside world\n // completionStatus, // not necessary for outside world\n // categories, // not necessary for outside world\n type,\n active,\n correct,\n incorrect,\n completed,\n index,\n response\n };\n })\n };\n })\n };\n })\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,SAAS,eAAe;AACjC,SAAS,MAAM,kBAAkB;AACjC,SAAS,eAAe,UAAU,aAAa;AAyBxC,IAAM,iBAAN,cAA6B,WAAW;AAAA,EAyB7C,cAAc;AACZ,UAAM;AAzBoB,sBAAa;AAGzC,SAAO,cAA4D,CAAC;AAWpE,SAAO,gBAA+B,CAAC;AAMqB,0BAAiB;AAM3E,SAAK,iBAAiB,iCAAiC,KAAK,qBAAqB,KAAK,IAAI,CAAC;AAC3F,SAAK,iBAAiB,iCAAiC,KAAK,qBAAqB,KAAK,IAAI,CAAC;AAE3F,SAAK,iBAAiB,2BAA2B,KAAK,0BAA0B,KAAK,IAAI,CAAC;AAE1F,SAAK,iBAAiB,oBAAoB,KAAK,sBAAsB,KAAK,IAAI,CAAC;AAC/E,SAAK,iBAAiB,8BAA8B,KAAK,+BAA+B,KAAK,IAAI,CAAC;AAAA,EACpG;AAAA,EAEQ,sBAAsB,QAAqB;AACjD,UAAM,YAAY,KAAK,aAAa;AAAA,MAClC,uCAAuC,KAAK,gBAAgB,SAAS;AAAA,IACvE;AACA,UAAM,sBAAsB,UAAU;AACtC,UAAM,6BAA6B,KAAK,eAAe,+BAA+B,OAAO,OAAO;AACpG,wBAAoB,gBAAgB,MAAM,0BAA0B;AAAA,EACtE;AAAA,EAEQ,+BAA+B,OAAoB;AACzD,UAAM,YAAY,KAAK,aAAa;AAAA,MAClC,uCAAuC,KAAK,gBAAgB,SAAS;AAAA,IACvE;AACA,UAAM,sBAAsB,UAAU;AACtC,wBAAoB,oBAAoB,MAAM,MAAM;AAAA,EACtD;AAA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AAA;AAAA;AAAA,kBAKH;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,gBACF;AAAA,cACF,CAAC;AAAA,YACH;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AA7O8B;AAAA,EAA3B,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GADf,eACiB;AAGrB;AAAA,EADN,MAAM;AAAA,GAHI,eAIJ;AAIA;AAAA,EAFN,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,aAAa,WAAW,KAAK,CAAC;AAAA,GAPvC,eAQJ;AAIA;AAAA,EAFN,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,gBAAgB,WAAW,KAAK,CAAC;AAAA,GAX1C,eAYJ;AAGA;AAAA,EADN,MAAM;AAAA,GAdI,eAeJ;AAIA;AAAA,EAFN,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,gBAAgB,CAAC;AAAA,GAlB1B,eAmBJ;AAEqD;AAAA,EAA3D,SAAS,EAAE,MAAM,SAAS,WAAW,mBAAmB,CAAC;AAAA,GArB/C,eAqBiD;AArBjD,iBAAN;AAAA,EADN,cAAc,iBAAiB;AAAA,GACnB;","names":[]}
@@ -0,0 +1,95 @@
1
+ import {
2
+ propInternalState
3
+ } from "./chunk-K6EUKFNW.js";
4
+ import {
5
+ btn,
6
+ dis
7
+ } from "./chunk-4O5F7WV7.js";
8
+ import {
9
+ watch
10
+ } from "./chunk-ELDMXTUQ.js";
11
+ import {
12
+ computedContext
13
+ } from "./chunk-6Z5YR5U2.js";
14
+ import {
15
+ __decorateClass
16
+ } from "./chunk-H2JE6IVU.js";
17
+
18
+ // src/lib/qti-test/components/test-prev.ts
19
+ import { css, html, LitElement } from "lit";
20
+ import { customElement } from "lit/decorators.js";
21
+ import { consume } from "@lit/context";
22
+ var TestPrev = class extends LitElement {
23
+ constructor() {
24
+ super();
25
+ this.disabled = true;
26
+ this._internals = this.attachInternals();
27
+ this._internals.role = "button";
28
+ this._internals.ariaLabel = "Next item";
29
+ this.addEventListener("click", (e) => {
30
+ e.preventDefault();
31
+ if (!this.disabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);
32
+ });
33
+ }
34
+ _handleTestElementChange(_oldValue, newValue) {
35
+ if (newValue) {
36
+ this.disabled = false;
37
+ }
38
+ }
39
+ willUpdate(_changedProperties) {
40
+ if (!this.computedContext) return;
41
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
42
+ if (!testPart) return;
43
+ this.sectionItems = testPart.sections.flatMap((section) => section.items);
44
+ this.itemIndex = this.sectionItems.findIndex((item) => item.active);
45
+ this.checkDisabled();
46
+ }
47
+ checkDisabled() {
48
+ this.disabled = !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
49
+ }
50
+ _requestItem(identifier) {
51
+ this.dispatchEvent(
52
+ new CustomEvent("qti-request-navigation", {
53
+ composed: true,
54
+ bubbles: true,
55
+ detail: {
56
+ type: "item",
57
+ id: identifier
58
+ }
59
+ })
60
+ );
61
+ }
62
+ render() {
63
+ return html`<slot></slot>`;
64
+ }
65
+ };
66
+ TestPrev.styles = css`
67
+ :host {
68
+ ${btn};
69
+ }
70
+ :host([disabled]) {
71
+ ${dis};
72
+ }
73
+ `;
74
+ __decorateClass([
75
+ propInternalState({
76
+ type: Boolean,
77
+ reflect: true,
78
+ aria: "ariaDisabled"
79
+ // Maps to `aria-disabled` attribute
80
+ })
81
+ ], TestPrev.prototype, "disabled", 2);
82
+ __decorateClass([
83
+ consume({ context: computedContext, subscribe: true })
84
+ ], TestPrev.prototype, "computedContext", 2);
85
+ __decorateClass([
86
+ watch("computedContext")
87
+ ], TestPrev.prototype, "_handleTestElementChange", 1);
88
+ TestPrev = __decorateClass([
89
+ customElement("test-prev")
90
+ ], TestPrev);
91
+
92
+ export {
93
+ TestPrev
94
+ };
95
+ //# sourceMappingURL=chunk-DACJEGD7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/qti-test/components/test-prev.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport * as styles from './styles';\nimport { propInternalState, watch } from '../../decorators';\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { ComputedContext, ComputedItem } from '../../exports/computed.context';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n@customElement('test-prev')\nexport class TestPrev extends LitElement {\n @propInternalState({\n type: Boolean,\n reflect: true,\n aria: 'ariaDisabled' // Maps to `aria-disabled` attribute\n })\n public disabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.disabled = false;\n }\n }\n\n static styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n private _internals: ElementInternals;\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n this._internals.role = 'button';\n this._internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this.disabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);\n });\n }\n\n willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n this.disabled = !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;\n }\n\n protected _requestItem(identifier: string): void {\n this.dispatchEvent(\n new CustomEvent('qti-request-navigation', {\n composed: true,\n bubbles: true,\n detail: {\n type: 'item',\n id: identifier\n }\n })\n );\n }\n\n render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-previous': TestPrev;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,KAAK,MAAM,kBAAkB;AACtC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AAoBjB,IAAM,WAAN,cAAuB,WAAW;AAAA,EA+BvC,cAAc;AACZ,UAAM;AA1BR,SAAO,WAAW;AA2BhB,SAAK,aAAa,KAAK,gBAAgB;AACvC,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,YAAY;AAE5B,SAAK,iBAAiB,SAAS,OAAK;AAClC,QAAE,eAAe;AACjB,UAAI,CAAC,KAAK,SAAU,MAAK,aAAa,KAAK,aAAa,KAAK,YAAY,CAAC,EAAE,UAAU;AAAA,IACxF,CAAC;AAAA,EACH;AAAA,EA1BA,yBAAyB,WAA4B,UAA2B;AAC9E,QAAI,UAAU;AACZ,WAAK,WAAW;AAAA,IAClB;AAAA,EACF;AAAA,EAwBA,WAAW,oBAA4D;AACrE,QAAI,CAAC,KAAK,gBAAiB;AAC3B,UAAM,WAAW,KAAK,iBAAiB,UAAU,KAAK,CAAAA,cAAYA,UAAS,MAAM;AACjF,QAAI,CAAC,SAAU;AACf,SAAK,eAAe,SAAS,SAAS,QAAQ,aAAW,QAAQ,KAAK;AACtE,SAAK,YAAY,KAAK,aAAa,UAAU,UAAQ,KAAK,MAAM;AAChE,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,gBAAgB;AACd,SAAK,WAAW,CAAC,KAAK,mBAAmB,KAAK,cAAc,KAAK,KAAK,cAAc;AAAA,EACtF;AAAA,EAEU,aAAa,YAA0B;AAC/C,SAAK;AAAA,MACH,IAAI,YAAY,0BAA0B;AAAA,QACxC,UAAU;AAAA,QACV,SAAS;AAAA,QACT,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,IAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,EACT;AACF;AAxEa,SAqBJ,SAAS;AAAA;AAAA,QAEH,GAAG;AAAA;AAAA;AAAA,QAGH,GAAG;AAAA;AAAA;AApBT;AAAA,EALN,kBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA;AAAA,EACR,CAAC;AAAA,GALU,SAMJ;AAGC;AAAA,EADP,QAAQ,EAAE,SAAS,iBAAiB,WAAW,KAAK,CAAC;AAAA,GAR3C,SASH;AAMR;AAAA,EADC,MAAM,iBAAiB;AAAA,GAdb,SAeX;AAfW,WAAN;AAAA,EADN,cAAc,WAAW;AAAA,GACb;","names":["testPart"]}
@@ -0,0 +1,99 @@
1
+ import {
2
+ propInternalState
3
+ } from "./chunk-K6EUKFNW.js";
4
+ import {
5
+ btn,
6
+ dis
7
+ } from "./chunk-4O5F7WV7.js";
8
+ import {
9
+ watch
10
+ } from "./chunk-ELDMXTUQ.js";
11
+ import {
12
+ computedContext
13
+ } from "./chunk-6Z5YR5U2.js";
14
+ import {
15
+ __decorateClass
16
+ } from "./chunk-H2JE6IVU.js";
17
+
18
+ // src/lib/qti-test/components/test-next.ts
19
+ import { css, html, LitElement } from "lit";
20
+ import { customElement } from "lit/decorators.js";
21
+ import { consume } from "@lit/context";
22
+ var TestNext = class extends LitElement {
23
+ constructor() {
24
+ super();
25
+ this.disabled = true;
26
+ this._internals = this.attachInternals();
27
+ this._internals.role = "button";
28
+ this._internals.ariaLabel = "Next item";
29
+ this.addEventListener("click", (e) => {
30
+ e.preventDefault();
31
+ if (!this.disabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);
32
+ });
33
+ }
34
+ _handleTestElementChange(_oldValue, newValue) {
35
+ if (newValue) {
36
+ this.disabled = false;
37
+ }
38
+ }
39
+ connectedCallback() {
40
+ super.connectedCallback();
41
+ this.checkDisabled();
42
+ }
43
+ willUpdate(_changedProperties) {
44
+ if (!this.computedContext) return;
45
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
46
+ if (!testPart) return;
47
+ this.sectionItems = testPart.sections.flatMap((section) => section.items);
48
+ this.itemIndex = this.sectionItems.findIndex((item) => item.active);
49
+ this.checkDisabled();
50
+ }
51
+ checkDisabled() {
52
+ this.disabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= this.sectionItems.length - 1;
53
+ }
54
+ _requestItem(identifier) {
55
+ this.dispatchEvent(
56
+ new CustomEvent("qti-request-navigation", {
57
+ composed: true,
58
+ bubbles: true,
59
+ detail: {
60
+ type: "item",
61
+ id: identifier
62
+ }
63
+ })
64
+ );
65
+ }
66
+ render() {
67
+ return html`<slot></slot>`;
68
+ }
69
+ };
70
+ TestNext.styles = css`
71
+ :host {
72
+ ${btn};
73
+ }
74
+ :host([disabled]) {
75
+ ${dis};
76
+ }
77
+ `;
78
+ __decorateClass([
79
+ propInternalState({
80
+ type: Boolean,
81
+ reflect: true,
82
+ aria: "ariaDisabled"
83
+ // Maps to `aria-disabled` attribute
84
+ })
85
+ ], TestNext.prototype, "disabled", 2);
86
+ __decorateClass([
87
+ consume({ context: computedContext, subscribe: true })
88
+ ], TestNext.prototype, "computedContext", 2);
89
+ __decorateClass([
90
+ watch("computedContext")
91
+ ], TestNext.prototype, "_handleTestElementChange", 1);
92
+ TestNext = __decorateClass([
93
+ customElement("test-next")
94
+ ], TestNext);
95
+
96
+ export {
97
+ TestNext
98
+ };
99
+ //# sourceMappingURL=chunk-EFTOJP3Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/qti-test/components/test-next.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport * as styles from './styles';\nimport { propInternalState, watch } from '../../decorators';\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { ComputedContext, ComputedItem } from '../../exports/computed.context';\n\n/**\n * Represents a custom element for navigating to the next test item.\n *\n * @remarks\n * This element provides functionality for navigating to the next test item.\n *\n * @example\n * ```html\n * <test-next></test-next>\n * ```\n */\n@customElement('test-next')\nexport class TestNext extends LitElement {\n @propInternalState({\n type: Boolean,\n reflect: true,\n aria: 'ariaDisabled' // Maps to `aria-disabled` attribute\n })\n public disabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.disabled = false;\n }\n }\n\n static styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n private _internals: ElementInternals;\n\n constructor() {\n super();\n\n this._internals = this.attachInternals();\n this._internals.role = 'button';\n this._internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this.disabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);\n });\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.checkDisabled();\n }\n\n willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n this.disabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= this.sectionItems.length - 1;\n }\n\n protected _requestItem(identifier: string): void {\n this.dispatchEvent(\n new CustomEvent('qti-request-navigation', {\n composed: true,\n bubbles: true,\n detail: {\n type: 'item',\n id: identifier\n }\n })\n );\n }\n\n render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-next': TestNext;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,KAAK,MAAM,kBAAkB;AACtC,S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