@qti-components/elements 1.3.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 (71) hide show
  1. package/LICENSE.md +674 -0
  2. package/dist/components/qti-assessment-item/qti-assessment-item.d.ts +91 -0
  3. package/dist/components/qti-assessment-item/qti-assessment-item.js +427 -0
  4. package/dist/components/qti-assessment-item/qti-assessment-item.js.map +1 -0
  5. package/dist/components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref.d.ts +31 -0
  6. package/dist/components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref.js +70 -0
  7. package/dist/components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref.js.map +1 -0
  8. package/dist/components/qti-companion-materials-info/qti-companion-materials-info.d.ts +8 -0
  9. package/dist/components/qti-companion-materials-info/qti-companion-materials-info.js +15 -0
  10. package/dist/components/qti-companion-materials-info/qti-companion-materials-info.js.map +1 -0
  11. package/dist/components/qti-content-body/qti-content-body.d.ts +9 -0
  12. package/dist/components/qti-content-body/qti-content-body.js +18 -0
  13. package/dist/components/qti-content-body/qti-content-body.js.map +1 -0
  14. package/dist/components/qti-context-declaration/qti-context-declaration.d.ts +16 -0
  15. package/dist/components/qti-context-declaration/qti-context-declaration.js +40 -0
  16. package/dist/components/qti-context-declaration/qti-context-declaration.js.map +1 -0
  17. package/dist/components/qti-custom-operator/qti-custom-operator.d.ts +25 -0
  18. package/dist/components/qti-custom-operator/qti-custom-operator.js +78 -0
  19. package/dist/components/qti-custom-operator/qti-custom-operator.js.map +1 -0
  20. package/dist/components/qti-feedback-block/qti-feedback-block.d.ts +11 -0
  21. package/dist/components/qti-feedback-block/qti-feedback-block.js +34 -0
  22. package/dist/components/qti-feedback-block/qti-feedback-block.js.map +1 -0
  23. package/dist/components/qti-feedback-inline/qti-feedback-inline.d.ts +11 -0
  24. package/dist/components/qti-feedback-inline/qti-feedback-inline.js +33 -0
  25. package/dist/components/qti-feedback-inline/qti-feedback-inline.js.map +1 -0
  26. package/dist/components/qti-item-body/qti-item-body.d.ts +21 -0
  27. package/dist/components/qti-item-body/qti-item-body.js +30 -0
  28. package/dist/components/qti-item-body/qti-item-body.js.map +1 -0
  29. package/dist/components/qti-item-body/qti-item-body.styles.d.ts +2 -0
  30. package/dist/components/qti-item-body/qti-item-body.styles.js +7 -0
  31. package/dist/components/qti-item-body/qti-item-body.styles.js.map +1 -0
  32. package/dist/components/qti-modal-feedback/qti-modal-feedback.d.ts +14 -0
  33. package/dist/components/qti-modal-feedback/qti-modal-feedback.js +95 -0
  34. package/dist/components/qti-modal-feedback/qti-modal-feedback.js.map +1 -0
  35. package/dist/components/qti-outcome-declaration/qti-outcome-declaration.d.ts +19 -0
  36. package/dist/components/qti-outcome-declaration/qti-outcome-declaration.js +95 -0
  37. package/dist/components/qti-outcome-declaration/qti-outcome-declaration.js.map +1 -0
  38. package/dist/components/qti-response-declaration/qti-response-declaration.d.ts +18 -0
  39. package/dist/components/qti-response-declaration/qti-response-declaration.js +117 -0
  40. package/dist/components/qti-response-declaration/qti-response-declaration.js.map +1 -0
  41. package/dist/components/qti-response-processing/qti-response-processing.d.ts +14 -0
  42. package/dist/components/qti-response-processing/qti-response-processing.js +58 -0
  43. package/dist/components/qti-response-processing/qti-response-processing.js.map +1 -0
  44. package/dist/components/qti-rubric-block/qti-rubric-block.d.ts +15 -0
  45. package/dist/components/qti-rubric-block/qti-rubric-block.js +65 -0
  46. package/dist/components/qti-rubric-block/qti-rubric-block.js.map +1 -0
  47. package/dist/components/qti-stylesheet/qti-stylesheet.d.ts +12 -0
  48. package/dist/components/qti-stylesheet/qti-stylesheet.js +77 -0
  49. package/dist/components/qti-stylesheet/qti-stylesheet.js.map +1 -0
  50. package/dist/components/qti-template-constraint/qti-template-constraint.d.ts +33 -0
  51. package/dist/components/qti-template-constraint/qti-template-constraint.js +63 -0
  52. package/dist/components/qti-template-constraint/qti-template-constraint.js.map +1 -0
  53. package/dist/components/qti-template-declaration/qti-template-declaration.d.ts +27 -0
  54. package/dist/components/qti-template-declaration/qti-template-declaration.js +129 -0
  55. package/dist/components/qti-template-declaration/qti-template-declaration.js.map +1 -0
  56. package/dist/components/qti-template-processing/qti-template-processing.d.ts +21 -0
  57. package/dist/components/qti-template-processing/qti-template-processing.js +84 -0
  58. package/dist/components/qti-template-processing/qti-template-processing.js.map +1 -0
  59. package/dist/index.d.ts +16 -0
  60. package/dist/index.js +17 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/internal/event-types.d.ts +9 -0
  63. package/dist/internal/event-types.js +2 -0
  64. package/dist/internal/event-types.js.map +1 -0
  65. package/dist/internal/events/qti-register-variable.d.ts +10 -0
  66. package/dist/internal/events/qti-register-variable.js +2 -0
  67. package/dist/internal/events/qti-register-variable.js.map +1 -0
  68. package/dist/internal/template-strings.d.ts +3 -0
  69. package/dist/internal/template-strings.js +53 -0
  70. package/dist/internal/template-strings.js.map +1 -0
  71. package/package.json +45 -0
@@ -0,0 +1,91 @@
1
+ import { LitElement } from 'lit';
2
+ import type { ResponseInteraction } from '@qti-components/base';
3
+ import type { VariableDeclaration, VariableValue } from '@qti-components/base';
4
+ import type { OutcomeVariable, ResponseVariable } from '@qti-components/base';
5
+ import type { ItemContext } from '@qti-components/base';
6
+ /**
7
+ * @summary The qti-assessment-item element contains all the other QTI 3 item structures.
8
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.dltnnj87l0yj
9
+ *
10
+ * @dependency qti-feedback
11
+ * @dependency qti-responseprocessing
12
+ *
13
+ * @event qti-item-context-updated - Emitted when through a user action the itemContext is updated,
14
+ * typically on interaction with the interactions, or calling response processing.
15
+ */
16
+ export declare class QtiAssessmentItem extends LitElement {
17
+ #private;
18
+ identifier: string;
19
+ adaptive: 'true' | 'false';
20
+ timeDependent: 'true' | 'false' | null;
21
+ get title(): string;
22
+ set title(value: string);
23
+ disabled: boolean;
24
+ protected _handleDisabledChange: (_: boolean, disabled: boolean) => void;
25
+ readonly: boolean;
26
+ protected _handleReadonlyChange: (_: boolean, readonly: boolean) => void;
27
+ private _context;
28
+ /**
29
+ * Sets the identifier for the assessment item reference if this item is in a test.
30
+ *
31
+ * @param identifier - The identifier for the assessment item reference.
32
+ */
33
+ set assessmentItemRefId(identifier: string);
34
+ get assessmentItemRefId(): string;
35
+ get variables(): VariableValue<string | string[] | null>[];
36
+ set variables(value: VariableValue<string | string[] | null>[]);
37
+ get state(): ItemContext['state'];
38
+ set state(value: ItemContext['state']);
39
+ /** @deprecated use variables property instead */
40
+ set responses(myResponses: ResponseInteraction[]);
41
+ render(): import("lit").TemplateResult<1>;
42
+ connectedCallback(): void;
43
+ disconnectedCallback(): void;
44
+ /**
45
+ * Toggles the display of correct responses for all interactions.
46
+ * @param show - A boolean indicating whether to show or hide correct responses.
47
+ */
48
+ showCorrectResponse(show: boolean): void;
49
+ /**
50
+ * Toggles the display of the candidate correction for all interactions.
51
+ * @param show - A boolean indicating whether to show or hide candidate correction.
52
+ */
53
+ showCandidateCorrection(show: boolean): void;
54
+ processResponse(countNumAttempts?: boolean, reportValidityAfterScoring?: boolean): boolean;
55
+ resetResponses(): void;
56
+ protected getResponse(identifier: string): Readonly<ResponseVariable>;
57
+ getOutcome(identifier: string): Readonly<OutcomeVariable>;
58
+ protected getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;
59
+ /**
60
+ * Updates the response variable with the specified identifier to the given value.
61
+ *
62
+ * @protected
63
+ *
64
+ * This method is intended for internal use within the class and subclasses.
65
+ * It should not be called externally by third parties.
66
+ *
67
+ * @param identifier - The identifier of the response variable to update.
68
+ * @param value - The new value for the response variable.
69
+ */
70
+ updateResponseVariable(identifier: string, value: string | string[] | undefined): void;
71
+ setOutcomeVariable(identifier: string, value: string | string[] | undefined): void;
72
+ /**
73
+ * Updates the outcome variable with the specified identifier to the given value.
74
+ *
75
+ * @protected
76
+ *
77
+ * This method is intended for internal use within the class and subclasses.
78
+ * It should not be called externally by third parties.
79
+ *
80
+ * @param identifier - The identifier of the response variable to update.
81
+ * @param value - The new value for the response variable.
82
+ */
83
+ updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;
84
+ validate(reportValidity?: boolean): boolean;
85
+ reportValidity(): void;
86
+ }
87
+ declare global {
88
+ interface HTMLElementTagNameMap {
89
+ 'qti-assessment-item': QtiAssessmentItem;
90
+ }
91
+ }
@@ -0,0 +1,427 @@
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 { provide } from '@lit/context';
8
+ import { LitElement, html } from 'lit';
9
+ import { customElement, property } from 'lit/decorators.js';
10
+ import { itemContext, itemContextVariables } from '@qti-components/base';
11
+ import { watch } from '@qti-components/utilities';
12
+ // import type { ItemShowCandidateCorrection } from '../../qti-item/components/item-show-candidate-correction.ts';
13
+ // import type { ItemShowCorrectResponse } from '../../qti-item/components/item-show-correct-response.ts';
14
+ /**
15
+ * @summary The qti-assessment-item element contains all the other QTI 3 item structures.
16
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.dltnnj87l0yj
17
+ *
18
+ * @dependency qti-feedback
19
+ * @dependency qti-responseprocessing
20
+ *
21
+ * @event qti-item-context-updated - Emitted when through a user action the itemContext is updated,
22
+ * typically on interaction with the interactions, or calling response processing.
23
+ */
24
+ let QtiAssessmentItem = class QtiAssessmentItem extends LitElement {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.#templateProcessing = null;
28
+ this.identifier = '';
29
+ this.adaptive = 'false';
30
+ this.timeDependent = null;
31
+ this._handleDisabledChange = (_, disabled) => {
32
+ this.#interactionElements.forEach(ch => (ch.disabled = disabled));
33
+ };
34
+ this._handleReadonlyChange = (_, readonly) => this.#interactionElements.forEach(ch => (ch.readonly = readonly));
35
+ this._context = {
36
+ variables: itemContextVariables
37
+ };
38
+ this.#initialContext = { ...this._context, variables: this._context.variables };
39
+ this.#feedbackElements = [];
40
+ this.#interactionElements = [];
41
+ this.#handleRegisterVariable = (e) => {
42
+ e.stopImmediatePropagation();
43
+ this._context = { ...this._context, variables: [...this._context.variables, e.detail.variable] };
44
+ this.#initialContext = this._context;
45
+ e.stopPropagation();
46
+ };
47
+ this.#handleRegisterFeedback = (e) => {
48
+ e.stopImmediatePropagation();
49
+ const feedbackElement = e.detail;
50
+ this.#feedbackElements.push(feedbackElement);
51
+ const numAttempts = Number(this._context.variables.find(v => v.identifier === 'numAttempts')?.value) || 0;
52
+ if (numAttempts > 0) {
53
+ feedbackElement.checkShowFeedback(feedbackElement.outcomeIdentifier);
54
+ }
55
+ };
56
+ this.#handleRegisterInteraction = (e) => {
57
+ e.stopImmediatePropagation();
58
+ this.#interactionElements.push(e.detail.interactionElement);
59
+ };
60
+ this.#handleEndAttempt = (e) => {
61
+ e.stopImmediatePropagation();
62
+ const { responseIdentifier, countAttempt } = e.detail;
63
+ this.validate();
64
+ this.updateResponseVariable(responseIdentifier, 'true');
65
+ this.processResponse(countAttempt);
66
+ };
67
+ this.#handleSetOutcomeValue = (e) => {
68
+ e.stopImmediatePropagation();
69
+ const { outcomeIdentifier, value } = e.detail;
70
+ this.updateOutcomeVariable(outcomeIdentifier, value);
71
+ e.stopPropagation();
72
+ };
73
+ this.#handleUpdateResponseVariable = (e) => {
74
+ e.stopImmediatePropagation();
75
+ const { responseIdentifier, response, state } = e.detail;
76
+ this.updateResponseVariable(responseIdentifier, response);
77
+ if (state !== undefined) {
78
+ this._context = {
79
+ ...this._context,
80
+ state: {
81
+ ...(this._context.state || {}),
82
+ [responseIdentifier]: state
83
+ }
84
+ };
85
+ }
86
+ this.dispatchEvent(new CustomEvent('qti-item-context-updated', {
87
+ bubbles: true,
88
+ composed: true,
89
+ detail: { itemContext: this._context }
90
+ }));
91
+ };
92
+ }
93
+ #itemTitle;
94
+ #templateProcessing;
95
+ get title() {
96
+ return this.#itemTitle;
97
+ }
98
+ set title(value) {
99
+ this.#itemTitle = value;
100
+ this.removeAttribute('title');
101
+ this.setAttribute('data-title', value);
102
+ }
103
+ /**
104
+ * Sets the identifier for the assessment item reference if this item is in a test.
105
+ *
106
+ * @param identifier - The identifier for the assessment item reference.
107
+ */
108
+ set assessmentItemRefId(identifier) {
109
+ this._context = { ...this._context, identifier };
110
+ }
111
+ get assessmentItemRefId() {
112
+ return this._context.identifier;
113
+ }
114
+ get variables() {
115
+ return this._context.variables.map(v => ({
116
+ identifier: v.identifier,
117
+ value: v.value,
118
+ type: v.type,
119
+ // add externalscored, a fixed prop to the test, so the testcontext can read and decide how to score this item
120
+ ...(v.type === 'outcome' && v.identifier === 'SCORE'
121
+ ? { externalScored: v.externalScored }
122
+ : {})
123
+ }));
124
+ }
125
+ set variables(value) {
126
+ if (!Array.isArray(value) || value.some(v => !('identifier' in v))) {
127
+ console.warn('variables property should be an array of VariableDeclaration');
128
+ return;
129
+ }
130
+ this._context = {
131
+ ...this._context,
132
+ variables: this._context.variables.map(variable => {
133
+ const matchingValue = value.find(v => v.identifier === variable.identifier);
134
+ if (matchingValue) {
135
+ return {
136
+ ...variable,
137
+ ...matchingValue,
138
+ interpolationTable: variable.interpolationTable
139
+ };
140
+ }
141
+ return variable;
142
+ })
143
+ };
144
+ this._context.variables.forEach(variable => {
145
+ if (variable.type === 'response') {
146
+ const interactionElement = this.#interactionElements.find((el) => el.responseIdentifier === variable.identifier);
147
+ if (interactionElement) {
148
+ interactionElement.response = variable.value;
149
+ }
150
+ }
151
+ });
152
+ this.variables.forEach(variable => {
153
+ if (variable.type === 'outcome') {
154
+ this.#feedbackElements.forEach(fe => fe.checkShowFeedback(variable.identifier));
155
+ }
156
+ });
157
+ }
158
+ get state() {
159
+ return this._context.state;
160
+ }
161
+ set state(value) {
162
+ this._context = {
163
+ ...this._context,
164
+ state: value ? { ...value } : undefined
165
+ };
166
+ }
167
+ #initialContext;
168
+ #feedbackElements;
169
+ #interactionElements;
170
+ /** @deprecated use variables property instead */
171
+ set responses(myResponses) {
172
+ if (myResponses) {
173
+ for (const response of myResponses) {
174
+ const responseVariable = this.getResponse(response.responseIdentifier);
175
+ if (responseVariable) {
176
+ this.updateResponseVariable(response.responseIdentifier, response.response);
177
+ }
178
+ const interaction = this.#interactionElements.find(i => i.getAttribute('response-identifier') === response.responseIdentifier);
179
+ if (interaction) {
180
+ interaction.response = response.response;
181
+ }
182
+ }
183
+ }
184
+ }
185
+ render() {
186
+ return html `<slot></slot>`;
187
+ }
188
+ connectedCallback() {
189
+ this.#attachEventListeners();
190
+ super.connectedCallback();
191
+ this.updateComplete.then(() => {
192
+ this.dispatchEvent(new CustomEvent('qti-assessment-item-connected', {
193
+ bubbles: true,
194
+ composed: true,
195
+ detail: this
196
+ }));
197
+ this.#processTemplates();
198
+ });
199
+ }
200
+ disconnectedCallback() {
201
+ this.#removeEventListeners();
202
+ super.disconnectedCallback();
203
+ }
204
+ #attachEventListeners() {
205
+ this.addEventListener('qti-register-variable', this.#handleRegisterVariable);
206
+ this.addEventListener('qti-register-feedback', this.#handleRegisterFeedback);
207
+ this.addEventListener('qti-register-interaction', this.#handleRegisterInteraction);
208
+ this.addEventListener('end-attempt', this.#handleEndAttempt);
209
+ this.addEventListener('qti-set-outcome-value', this.#handleSetOutcomeValue);
210
+ this.addEventListener('qti-interaction-response', this.#handleUpdateResponseVariable);
211
+ }
212
+ #removeEventListeners() {
213
+ this.removeEventListener('qti-register-variable', this.#handleRegisterVariable);
214
+ this.removeEventListener('qti-register-feedback', this.#handleRegisterFeedback);
215
+ this.removeEventListener('qti-register-interaction', this.#handleRegisterInteraction);
216
+ this.removeEventListener('end-attempt', this.#handleEndAttempt);
217
+ this.removeEventListener('qti-set-outcome-value', this.#handleSetOutcomeValue);
218
+ this.removeEventListener('qti-interaction-response', this.#handleUpdateResponseVariable);
219
+ }
220
+ #handleRegisterVariable;
221
+ #handleRegisterFeedback;
222
+ #handleRegisterInteraction;
223
+ #handleEndAttempt;
224
+ #handleSetOutcomeValue;
225
+ #handleUpdateResponseVariable;
226
+ /**
227
+ * Toggles the display of correct responses for all interactions.
228
+ * @param show - A boolean indicating whether to show or hide correct responses.
229
+ */
230
+ showCorrectResponse(show) {
231
+ // Iterate through all interaction elements
232
+ for (const interaction of this.#interactionElements) {
233
+ interaction.toggleCorrectResponse(show);
234
+ }
235
+ // Update one or more toggle component states // ItemShowCorrectResponse
236
+ document.querySelectorAll('item-show-correct-response').forEach((el) => {
237
+ el.shown = show;
238
+ });
239
+ }
240
+ /**
241
+ * Toggles the display of the candidate correction for all interactions.
242
+ * @param show - A boolean indicating whether to show or hide candidate correction.
243
+ */
244
+ showCandidateCorrection(show) {
245
+ // Iterate through all interaction elements
246
+ for (const interaction of this.#interactionElements) {
247
+ interaction.toggleCandidateCorrection(show);
248
+ }
249
+ // Update one or more toggle component states // ItemShowCandidateCorrection
250
+ document.querySelectorAll('item-show-candidate-correction').forEach((el) => {
251
+ el.shown = show;
252
+ });
253
+ }
254
+ #processTemplates() {
255
+ this.#templateProcessing = this.querySelector('qti-template-processing');
256
+ if (this.#templateProcessing) {
257
+ // Run template processing before first presentation
258
+ this.#templateProcessing.process();
259
+ }
260
+ }
261
+ processResponse(countNumAttempts = true, reportValidityAfterScoring = true) {
262
+ this.validate(reportValidityAfterScoring);
263
+ if (countNumAttempts) {
264
+ this.updateOutcomeVariable('numAttempts', (+this._context.variables.find(v => v.identifier === 'numAttempts')?.value + 1).toString());
265
+ }
266
+ const responseProcessor = this.querySelector('qti-response-processing');
267
+ const canProcess = !!(responseProcessor && typeof responseProcessor.process === 'function');
268
+ if (canProcess) {
269
+ responseProcessor.process();
270
+ }
271
+ if (this.adaptive === 'false') {
272
+ // if adaptive, completionStatus is set by the processing template
273
+ this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());
274
+ }
275
+ this.dispatchEvent(new CustomEvent('qti-item-context-updated', {
276
+ bubbles: true,
277
+ composed: true,
278
+ detail: { itemContext: this._context }
279
+ }));
280
+ return canProcess;
281
+ }
282
+ resetResponses() {
283
+ this._context = this.#initialContext;
284
+ }
285
+ getResponse(identifier) {
286
+ return this.getVariable(identifier);
287
+ }
288
+ getOutcome(identifier) {
289
+ return this.getVariable(identifier);
290
+ }
291
+ getVariable(identifier) {
292
+ return this._context.variables.find(v => v.identifier === identifier) || null;
293
+ }
294
+ // saving privates here: ------------------------------------------------------------------------------
295
+ /**
296
+ * Updates the response variable with the specified identifier to the given value.
297
+ *
298
+ * @protected
299
+ *
300
+ * This method is intended for internal use within the class and subclasses.
301
+ * It should not be called externally by third parties.
302
+ *
303
+ * @param identifier - The identifier of the response variable to update.
304
+ * @param value - The new value for the response variable.
305
+ */
306
+ updateResponseVariable(identifier, value) {
307
+ this._context = {
308
+ ...this._context,
309
+ variables: this._context.variables.map(v => (v.identifier !== identifier ? v : { ...v, value: value }))
310
+ };
311
+ // Turn off candidate correction after change of response variable
312
+ this.showCandidateCorrection(false);
313
+ this.dispatchEvent(new CustomEvent('qti-interaction-changed', {
314
+ bubbles: true,
315
+ composed: true,
316
+ detail: {
317
+ item: this.identifier,
318
+ responseIdentifier: identifier,
319
+ response: Array.isArray(value) ? [...value] : value
320
+ }
321
+ }));
322
+ if (this.adaptive === 'false') {
323
+ // if adaptive, completionStatus is set by the processing template
324
+ this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());
325
+ }
326
+ }
327
+ setOutcomeVariable(identifier, value) {
328
+ this.updateOutcomeVariable(identifier, value);
329
+ this.dispatchEvent(new CustomEvent('qti-item-context-updated', {
330
+ bubbles: true,
331
+ composed: true,
332
+ detail: { itemContext: this._context }
333
+ }));
334
+ }
335
+ /**
336
+ * Updates the outcome variable with the specified identifier to the given value.
337
+ *
338
+ * @protected
339
+ *
340
+ * This method is intended for internal use within the class and subclasses.
341
+ * It should not be called externally by third parties.
342
+ *
343
+ * @param identifier - The identifier of the response variable to update.
344
+ * @param value - The new value for the response variable.
345
+ */
346
+ updateOutcomeVariable(identifier, value) {
347
+ const outcomeVariable = this.getOutcome(identifier);
348
+ if (!outcomeVariable) {
349
+ console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);
350
+ return;
351
+ }
352
+ this._context = {
353
+ ...this._context,
354
+ variables: this._context.variables.map(v => {
355
+ if (v.identifier !== identifier) {
356
+ return v;
357
+ }
358
+ return {
359
+ ...v,
360
+ value: outcomeVariable.cardinality === 'single' ? value : Array.isArray(value) ? value : [value]
361
+ };
362
+ })
363
+ };
364
+ this.#feedbackElements.forEach(fe => fe.checkShowFeedback(identifier));
365
+ this.dispatchEvent(new CustomEvent('qti-outcome-changed', {
366
+ bubbles: true,
367
+ composed: true,
368
+ detail: {
369
+ item: this.identifier,
370
+ outcomeIdentifier: identifier,
371
+ value: this._context.variables.find(v => v.identifier === identifier)?.value
372
+ }
373
+ }));
374
+ }
375
+ validate(reportValidity = true) {
376
+ const isValid = this.#interactionElements.every(interactionElement => interactionElement.validate());
377
+ if (reportValidity) {
378
+ this.reportValidity();
379
+ }
380
+ return isValid;
381
+ }
382
+ reportValidity() {
383
+ for (const interactionElement of this.#interactionElements) {
384
+ interactionElement.reportValidity();
385
+ }
386
+ }
387
+ #getCompletionStatus() {
388
+ const valid = this.validate(false);
389
+ if (valid === true)
390
+ return 'completed';
391
+ if (valid === false)
392
+ return 'incomplete';
393
+ return 'not_attempted';
394
+ }
395
+ };
396
+ __decorate([
397
+ property({ type: String })
398
+ ], QtiAssessmentItem.prototype, "identifier", void 0);
399
+ __decorate([
400
+ property({ type: String })
401
+ ], QtiAssessmentItem.prototype, "adaptive", void 0);
402
+ __decorate([
403
+ property({ type: String })
404
+ ], QtiAssessmentItem.prototype, "timeDependent", void 0);
405
+ __decorate([
406
+ property({ type: String })
407
+ ], QtiAssessmentItem.prototype, "title", null);
408
+ __decorate([
409
+ property({ type: Boolean })
410
+ ], QtiAssessmentItem.prototype, "disabled", void 0);
411
+ __decorate([
412
+ watch('disabled', { waitUntilFirstUpdate: true })
413
+ ], QtiAssessmentItem.prototype, "_handleDisabledChange", void 0);
414
+ __decorate([
415
+ property({ type: Boolean })
416
+ ], QtiAssessmentItem.prototype, "readonly", void 0);
417
+ __decorate([
418
+ watch('readonly', { waitUntilFirstUpdate: true })
419
+ ], QtiAssessmentItem.prototype, "_handleReadonlyChange", void 0);
420
+ __decorate([
421
+ provide({ context: itemContext })
422
+ ], QtiAssessmentItem.prototype, "_context", void 0);
423
+ QtiAssessmentItem = __decorate([
424
+ customElement('qti-assessment-item')
425
+ ], QtiAssessmentItem);
426
+ export { QtiAssessmentItem };
427
+ //# sourceMappingURL=qti-assessment-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qti-assessment-item.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item/qti-assessment-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAWlD,kHAAkH;AAClH,0GAA0G;AAE1G;;;;;;;;;GASG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAEL,wBAAmB,GAAiC,IAAI,CAAC;QAE7B,eAAU,GAAW,EAAE,CAAC;QACxB,aAAQ,GAAqB,OAAO,CAAC;QACrC,kBAAa,GAA4B,IAAI,CAAC;QAchE,0BAAqB,GAAG,CAAC,CAAU,EAAE,QAAiB,EAAE,EAAE;YACl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B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,WAAW,CAAC;QACvC,IAAI,KAAK,KAAK,KAAK;YAAE,OAAO,YAAY,CAAC;QACzC,OAAO,eAAe,CAAC;IACzB,CAAC;CACF,CAAA;AApb6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAsC;AACrC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAA+C;AAG1E;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAG1B;AAO4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAmB;AAErC;IADT,KAAK,CAAC,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;gEAGhD;AAE2B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAmB;AAErC;IADT,KAAK,CAAC,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;gEAEkB;AAG5D;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;mDAGhC;AAhCS,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAwb7B","sourcesContent":["import { provide } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport { itemContext, itemContextVariables } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport type { QtiTemplateProcessing } from '../qti-template-processing/qti-template-processing.js';\nimport type { InteractionChangedDetails, OutcomeChangedDetails } from '../../internal/event-types.ts';\nimport type { QtiFeedback, ResponseInteraction } from '@qti-components/base';\nimport type { VariableDeclaration, VariableValue } from '@qti-components/base';\nimport type { OutcomeVariable, ResponseVariable } from '@qti-components/base';\nimport type { QtiResponseProcessing } from '../qti-response-processing/qti-response-processing.ts';\nimport type QtiRegisterVariable from '../../internal/events/qti-register-variable.ts';\nimport type { ItemContext } from '@qti-components/base';\nimport type { Interaction } from '@qti-components/base';\n// import type { ItemShowCandidateCorrection } from '../../qti-item/components/item-show-candidate-correction.ts';\n// import type { ItemShowCorrectResponse } from '../../qti-item/components/item-show-correct-response.ts';\n\n/**\n * @summary The qti-assessment-item element contains all the other QTI 3 item structures.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.dltnnj87l0yj\n *\n * @dependency qti-feedback\n * @dependency qti-responseprocessing\n *\n * @event qti-item-context-updated - Emitted when through a user action the itemContext is updated,\n * typically on interaction with the interactions, or calling response processing.\n */\n@customElement('qti-assessment-item')\nexport class QtiAssessmentItem extends LitElement {\n #itemTitle: string | undefined;\n #templateProcessing: QtiTemplateProcessing | null = null;\n\n @property({ type: String }) identifier: string = '';\n @property({ type: String }) adaptive: 'true' | 'false' = 'false';\n @property({ type: String }) timeDependent: 'true' | 'false' | null = null;\n\n @property({ type: String })\n override get title(): string {\n return this.#itemTitle;\n }\n override set title(value: string) {\n this.#itemTitle = value;\n this.removeAttribute('title');\n this.setAttribute('data-title', value);\n }\n\n @property({ type: Boolean }) disabled: boolean;\n @watch('disabled', { waitUntilFirstUpdate: true })\n protected _handleDisabledChange = (_: boolean, disabled: boolean) => {\n this.#interactionElements.forEach(ch => (ch.disabled = disabled));\n };\n\n @property({ type: Boolean }) readonly: boolean;\n @watch('readonly', { waitUntilFirstUpdate: true })\n protected _handleReadonlyChange = (_: boolean, readonly: boolean) =>\n this.#interactionElements.forEach(ch => (ch.readonly = readonly));\n\n @provide({ context: itemContext })\n private _context: ItemContext = {\n variables: itemContextVariables\n };\n\n /**\n * Sets the identifier for the assessment item reference if this item is in a test.\n *\n * @param identifier - The identifier for the assessment item reference.\n */\n public set assessmentItemRefId(identifier: string) {\n this._context = { ...this._context, identifier };\n }\n\n public get assessmentItemRefId(): string {\n return this._context.identifier;\n }\n\n public get variables(): VariableValue<string | string[] | null>[] {\n return this._context.variables.map(v => ({\n identifier: v.identifier,\n value: v.value,\n type: v.type,\n // add externalscored, a fixed prop to the test, so the testcontext can read and decide how to score this item\n ...(v.type === 'outcome' && v.identifier === 'SCORE'\n ? { externalScored: (v as OutcomeVariable).externalScored }\n : {})\n }));\n }\n\n public set variables(value: VariableValue<string | string[] | null>[]) {\n if (!Array.isArray(value) || value.some(v => !('identifier' in v))) {\n console.warn('variables property should be an array of VariableDeclaration');\n return;\n }\n this._context = {\n ...this._context,\n variables: this._context.variables.map(variable => {\n const matchingValue = value.find(v => v.identifier === variable.identifier);\n if (matchingValue) {\n return {\n ...variable,\n ...matchingValue,\n interpolationTable: (variable as OutcomeVariable).interpolationTable\n };\n }\n return variable;\n })\n };\n\n this._context.variables.forEach(variable => {\n if (variable.type === 'response') {\n const interactionElement = this.#interactionElements.find(\n (el: Interaction) => el.responseIdentifier === variable.identifier\n );\n if (interactionElement) {\n interactionElement.response = variable.value as string | string[];\n }\n }\n });\n\n this.variables.forEach(variable => {\n if (variable.type === 'outcome') {\n this.#feedbackElements.forEach(fe => fe.checkShowFeedback(variable.identifier));\n }\n });\n }\n\n public get state(): ItemContext['state'] {\n return this._context.state;\n }\n\n public set state(value: ItemContext['state']) {\n this._context = {\n ...this._context,\n state: value ? { ...value } : undefined\n };\n }\n\n #initialContext: Readonly<ItemContext> = { ...this._context, variables: this._context.variables };\n #feedbackElements: QtiFeedback[] = [];\n #interactionElements: Interaction[] = [];\n\n /** @deprecated use variables property instead */\n set responses(myResponses: ResponseInteraction[]) {\n if (myResponses) {\n for (const response of myResponses) {\n const responseVariable = this.getResponse(response.responseIdentifier);\n if (responseVariable) {\n this.updateResponseVariable(response.responseIdentifier, response.response);\n }\n\n const interaction: Interaction | undefined = this.#interactionElements.find(\n i => i.getAttribute('response-identifier') === response.responseIdentifier\n );\n if (interaction) {\n interaction.response = response.response;\n }\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n override connectedCallback(): void {\n this.#attachEventListeners();\n super.connectedCallback();\n this.updateComplete.then(() => {\n this.dispatchEvent(\n new CustomEvent<QtiAssessmentItem>('qti-assessment-item-connected', {\n bubbles: true,\n composed: true,\n detail: this\n })\n );\n this.#processTemplates();\n });\n }\n\n override disconnectedCallback(): void {\n this.#removeEventListeners();\n super.disconnectedCallback();\n }\n\n #attachEventListeners() {\n this.addEventListener('qti-register-variable', this.#handleRegisterVariable);\n this.addEventListener('qti-register-feedback', this.#handleRegisterFeedback);\n this.addEventListener('qti-register-interaction', this.#handleRegisterInteraction);\n this.addEventListener('end-attempt', this.#handleEndAttempt);\n this.addEventListener('qti-set-outcome-value', this.#handleSetOutcomeValue);\n this.addEventListener('qti-interaction-response', this.#handleUpdateResponseVariable);\n }\n\n #removeEventListeners() {\n this.removeEventListener('qti-register-variable', this.#handleRegisterVariable);\n this.removeEventListener('qti-register-feedback', this.#handleRegisterFeedback);\n this.removeEventListener('qti-register-interaction', this.#handleRegisterInteraction);\n this.removeEventListener('end-attempt', this.#handleEndAttempt);\n this.removeEventListener('qti-set-outcome-value', this.#handleSetOutcomeValue);\n this.removeEventListener('qti-interaction-response', this.#handleUpdateResponseVariable);\n }\n\n #handleRegisterVariable = (e: QtiRegisterVariable) => {\n e.stopImmediatePropagation();\n this._context = { ...this._context, variables: [...this._context.variables, e.detail.variable] };\n this.#initialContext = this._context;\n e.stopPropagation();\n };\n\n #handleRegisterFeedback = (e: CustomEvent<QtiFeedback>) => {\n e.stopImmediatePropagation();\n const feedbackElement = e.detail;\n this.#feedbackElements.push(feedbackElement);\n const numAttempts = Number(this._context.variables.find(v => v.identifier === 'numAttempts')?.value) || 0;\n if (numAttempts > 0) {\n feedbackElement.checkShowFeedback(feedbackElement.outcomeIdentifier);\n }\n };\n\n #handleRegisterInteraction = (e: CustomEvent<{ interaction: string; interactionElement: Interaction }>) => {\n e.stopImmediatePropagation();\n this.#interactionElements.push(e.detail.interactionElement);\n };\n\n #handleEndAttempt = (e: CustomEvent<{ responseIdentifier: string; countAttempt: boolean }>) => {\n e.stopImmediatePropagation();\n const { responseIdentifier, countAttempt } = e.detail;\n this.validate();\n this.updateResponseVariable(responseIdentifier, 'true');\n this.processResponse(countAttempt);\n };\n\n #handleSetOutcomeValue = (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n e.stopImmediatePropagation();\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n };\n\n #handleUpdateResponseVariable = (e: CustomEvent<ResponseInteraction>) => {\n e.stopImmediatePropagation();\n\n const { responseIdentifier, response, state } = e.detail;\n this.updateResponseVariable(responseIdentifier, response);\n if (state !== undefined) {\n this._context = {\n ...this._context,\n state: {\n ...(this._context.state || {}),\n [responseIdentifier]: state\n }\n };\n }\n\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n };\n\n /**\n * Toggles the display of correct responses for all interactions.\n * @param show - A boolean indicating whether to show or hide correct responses.\n */\n public showCorrectResponse(show: boolean): void {\n // Iterate through all interaction elements\n for (const interaction of this.#interactionElements) {\n interaction.toggleCorrectResponse(show);\n }\n\n // Update one or more toggle component states // ItemShowCorrectResponse\n document.querySelectorAll('item-show-correct-response').forEach((el: HTMLElement & { shown: boolean }) => {\n el.shown = show;\n });\n }\n\n /**\n * Toggles the display of the candidate correction for all interactions.\n * @param show - A boolean indicating whether to show or hide candidate correction.\n */\n public showCandidateCorrection(show: boolean): void {\n // Iterate through all interaction elements\n for (const interaction of this.#interactionElements) {\n interaction.toggleCandidateCorrection(show);\n }\n\n // Update one or more toggle component states // ItemShowCandidateCorrection\n document.querySelectorAll('item-show-candidate-correction').forEach((el: HTMLElement & { shown: boolean }) => {\n el.shown = show;\n });\n }\n\n #processTemplates(): void {\n this.#templateProcessing = this.querySelector<QtiTemplateProcessing>('qti-template-processing');\n if (this.#templateProcessing) {\n // Run template processing before first presentation\n this.#templateProcessing.process();\n }\n }\n\n public processResponse(countNumAttempts = true, reportValidityAfterScoring = true): boolean {\n this.validate(reportValidityAfterScoring);\n\n if (countNumAttempts) {\n this.updateOutcomeVariable(\n 'numAttempts',\n (+this._context.variables.find(v => v.identifier === 'numAttempts')?.value + 1).toString()\n );\n }\n\n const responseProcessor = this.querySelector<QtiResponseProcessing>('qti-response-processing');\n const canProcess = !!(responseProcessor && typeof responseProcessor.process === 'function');\n if (canProcess) {\n responseProcessor.process();\n }\n if (this.adaptive === 'false') {\n // if adaptive, completionStatus is set by the processing template\n this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());\n }\n\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n\n return canProcess;\n }\n\n public resetResponses() {\n this._context = this.#initialContext;\n }\n\n protected getResponse(identifier: string): Readonly<ResponseVariable> {\n return this.getVariable(identifier) as ResponseVariable;\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n\n protected getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this._context.variables.find(v => v.identifier === identifier) || null;\n }\n\n // saving privates here: ------------------------------------------------------------------------------\n\n /**\n * Updates the response variable with the specified identifier to the given value.\n *\n * @protected\n *\n * This method is intended for internal use within the class and subclasses.\n * It should not be called externally by third parties.\n *\n * @param identifier - The identifier of the response variable to update.\n * @param value - The new value for the response variable.\n */\n public updateResponseVariable(identifier: string, value: string | string[] | undefined) {\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v => (v.identifier !== identifier ? v : { ...v, value: value }))\n };\n\n // Turn off candidate correction after change of response variable\n this.showCandidateCorrection(false);\n\n this.dispatchEvent(\n new CustomEvent<InteractionChangedDetails>('qti-interaction-changed', {\n bubbles: true,\n composed: true,\n detail: {\n item: this.identifier,\n responseIdentifier: identifier,\n response: Array.isArray(value) ? [...value] : value\n }\n })\n );\n\n if (this.adaptive === 'false') {\n // if adaptive, completionStatus is set by the processing template\n this.updateOutcomeVariable('completionStatus', this.#getCompletionStatus());\n }\n }\n\n public setOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n this.updateOutcomeVariable(identifier, value);\n this.dispatchEvent(\n new CustomEvent<{ itemContext: ItemContext }>('qti-item-context-updated', {\n bubbles: true,\n composed: true,\n detail: { itemContext: this._context }\n })\n );\n }\n\n /**\n * Updates the outcome variable with the specified identifier to the given value.\n *\n * @protected\n *\n * This method is intended for internal use within the class and subclasses.\n * It should not be called externally by third parties.\n *\n * @param identifier - The identifier of the response variable to update.\n * @param value - The new value for the response variable.\n */\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n\n this._context = {\n ...this._context,\n variables: this._context.variables.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : Array.isArray(value) ? value : [value]\n };\n })\n };\n this.#feedbackElements.forEach(fe => fe.checkShowFeedback(identifier));\n\n this.dispatchEvent(\n new CustomEvent<OutcomeChangedDetails>('qti-outcome-changed', {\n bubbles: true,\n composed: true,\n detail: {\n item: this.identifier,\n outcomeIdentifier: identifier,\n value: this._context.variables.find(v => v.identifier === identifier)?.value\n }\n })\n );\n }\n\n public validate(reportValidity = true): boolean {\n const isValid = this.#interactionElements.every(interactionElement => interactionElement.validate());\n\n if (reportValidity) {\n this.reportValidity();\n }\n\n return isValid;\n }\n\n public reportValidity() {\n for (const interactionElement of this.#interactionElements) {\n interactionElement.reportValidity();\n }\n }\n\n #getCompletionStatus(): 'completed' | 'incomplete' | 'not_attempted' | 'unknown' {\n const valid = this.validate(false);\n if (valid === true) return 'completed';\n if (valid === false) return 'incomplete';\n return 'not_attempted';\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item': QtiAssessmentItem;\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { LitElement } from 'lit';
2
+ import type { QtiAssessmentItem } from '../qti-assessment-item/qti-assessment-item';
3
+ export declare class QtiAssessmentStimulusRefConnectedEvent extends Event {
4
+ element: QtiAssessmentStimulusRef;
5
+ item: QtiAssessmentItem;
6
+ static eventName: string;
7
+ constructor(element: QtiAssessmentStimulusRef, item: QtiAssessmentItem);
8
+ }
9
+ /**
10
+ * Represents a custom element for referencing an assessment stimulus.
11
+ */
12
+ export declare class QtiAssessmentStimulusRef extends LitElement {
13
+ identifier: string;
14
+ href: string;
15
+ /**
16
+ * Lifecycle method called when the element is connected to the DOM.
17
+ * First checks if there's a data-stimulus-idref element. If found, loads the stimulus directly.
18
+ * If not found, delegates to the delivery platform via an event.
19
+ */
20
+ connectedCallback(): Promise<void>;
21
+ /**
22
+ * Loads and appends the stimulus to the specified element.
23
+ * @param stimulusRef - The element to which the stimulus will be appended.
24
+ */
25
+ updateStimulusRef(stimulusRef: Element): Promise<void>;
26
+ }
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'qti-assessment-stimulus-ref': QtiAssessmentStimulusRef;
30
+ }
31
+ }