@citolab/qti-components 10.0.0-next.3 → 10.0.0-next.30

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 (94) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +4334 -2688
  3. package/dist/base.d.ts +39 -13
  4. package/dist/base.js +14 -1
  5. package/dist/{chunk-D3BYGEQU.js → chunk-2ZT47EUK.js} +117 -92
  6. package/dist/chunk-2ZT47EUK.js.map +1 -0
  7. package/dist/{chunk-RU6332MD.js → chunk-566LB3G2.js} +4 -4
  8. package/dist/{chunk-MI7774NV.js → chunk-5BP2A7BI.js} +2 -2
  9. package/dist/{chunk-OQDBARD5.js → chunk-5KNTKBP6.js} +2 -2
  10. package/dist/chunk-7ISPUOJG.js +209 -0
  11. package/dist/chunk-7ISPUOJG.js.map +1 -0
  12. package/dist/{chunk-GBZNFSFY.js → chunk-ADTCTKXS.js} +2 -2
  13. package/dist/{chunk-FD4AB6TM.js → chunk-BBP7QV32.js} +2 -2
  14. package/dist/{chunk-LFVPS7KB.js → chunk-CFTWXYBO.js} +2 -2
  15. package/dist/{chunk-35WWWFS6.js → chunk-DAESCCLR.js} +2 -2
  16. package/dist/chunk-DJ7PB252.js +7 -0
  17. package/dist/chunk-DJ7PB252.js.map +1 -0
  18. package/dist/{chunk-6U3YPHXU.js → chunk-GAPMCYR5.js} +277 -154
  19. package/dist/chunk-GAPMCYR5.js.map +1 -0
  20. package/dist/{chunk-TDWJ6WZA.js → chunk-GPC53O7P.js} +166 -10
  21. package/dist/chunk-GPC53O7P.js.map +1 -0
  22. package/dist/{chunk-6K3QWJHH.js → chunk-LPYZVKHX.js} +48 -7
  23. package/dist/chunk-LPYZVKHX.js.map +1 -0
  24. package/dist/{chunk-TLAVOBEM.js → chunk-O2XRZPKA.js} +356 -62
  25. package/dist/chunk-O2XRZPKA.js.map +1 -0
  26. package/dist/chunk-PZ5AY32C.js +10 -0
  27. package/dist/chunk-PZ5AY32C.js.map +1 -0
  28. package/dist/{chunk-RSMYGGQK.js → chunk-TZCOXFPB.js} +1590 -610
  29. package/dist/chunk-TZCOXFPB.js.map +1 -0
  30. package/dist/chunk-UCXLDQYA.js +56 -0
  31. package/dist/chunk-UCXLDQYA.js.map +1 -0
  32. package/dist/chunk-WWY2H2YO.js +7 -0
  33. package/dist/chunk-WWY2H2YO.js.map +1 -0
  34. package/dist/{chunk-SIE3E4FG.js → chunk-YRR6D6UP.js} +753 -2095
  35. package/dist/chunk-YRR6D6UP.js.map +1 -0
  36. package/dist/computed.types.d-BPzPFX3Z.d.ts +91 -0
  37. package/dist/{config.context.d-BvU9r-Mg.d.ts → config.context.d-Dm11aAuw.d.ts} +21 -3
  38. package/dist/corrections.d.ts +137 -24
  39. package/dist/corrections.js +12 -12
  40. package/dist/corrections.js.map +1 -1
  41. package/dist/elements.d.ts +66 -73
  42. package/dist/elements.js +9 -6
  43. package/dist/index.d.ts +21 -17
  44. package/dist/index.js +50 -61
  45. package/dist/interactions.d.ts +98 -19
  46. package/dist/interactions.js +8 -3
  47. package/dist/item.css +1948 -1946
  48. package/dist/item.d.ts +8 -6
  49. package/dist/item.js +6 -5
  50. package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
  51. package/dist/loader.d.ts +5 -3
  52. package/dist/loader.js +3 -2
  53. package/dist/processing.d.ts +19 -7
  54. package/dist/processing.js +4 -3
  55. package/dist/public-events.d-3dGip9pd.d.ts +105 -0
  56. package/dist/qti-components-jsx.d.ts +1725 -1777
  57. package/dist/{qti-condition-expression.d-VJH6cWxf.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
  58. package/dist/{qti-expression.d-BPxEp8HU.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
  59. package/dist/{qti-feedback.d-wMYNVkkj.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +8 -1
  60. package/dist/{qti-item.d-DgC1AQbY.d.ts → qti-item.d-CxP6KtCH.d.ts} +3 -2
  61. package/dist/{qti-rule-base.d-Bdzg8eGH.d.ts → qti-rule-base.d-CeKP0Ooi.d.ts} +2 -2
  62. package/dist/qti-test-state-ybQ6ausy.d.ts +81 -0
  63. package/dist/qti-test-state.d-CjvdranT.d.ts +61 -0
  64. package/dist/{qti-test.d-86TlaMlI.d.ts → qti-test.d-BbtCG7A-.d.ts} +91 -487
  65. package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-m0EFv9no.d.ts} +221 -73
  66. package/dist/{qti-transform-test.d-BL7GGFJj.d.ts → qti-transform-test.d-CtNaWJr8.d.ts} +9 -0
  67. package/dist/{interaction.d-g6XG0T0Z.d.ts → record.d-N1Bq7e1f.d.ts} +67 -4
  68. package/dist/{session.context.d-D5080LVx.d.ts → session.context.d-9gRdGK4T.d.ts} +7 -1
  69. package/dist/test-plugin-api.d.ts +143 -0
  70. package/dist/test-plugin-api.js +21 -0
  71. package/dist/test-plugin-api.js.map +1 -0
  72. package/dist/test.d.ts +72 -57
  73. package/dist/test.js +22 -48
  74. package/dist/transformers.d.ts +1 -1
  75. package/dist/transformers.js +2 -1
  76. package/dist/{item.types.d-B55QkJ92.d.ts → variables.d-DWHlTszN.d.ts} +8 -24
  77. package/package.json +16 -11
  78. package/dist/chunk-6K3QWJHH.js.map +0 -1
  79. package/dist/chunk-6U3YPHXU.js.map +0 -1
  80. package/dist/chunk-D3BYGEQU.js.map +0 -1
  81. package/dist/chunk-RSMYGGQK.js.map +0 -1
  82. package/dist/chunk-SIE3E4FG.js.map +0 -1
  83. package/dist/chunk-TDWJ6WZA.js.map +0 -1
  84. package/dist/chunk-TLAVOBEM.js.map +0 -1
  85. package/dist/chunk-ZP6QQYSU.js +0 -7
  86. package/dist/chunk-ZP6QQYSU.js.map +0 -1
  87. package/dist/computed.types.d-gJrBeUMG.d.ts +0 -42
  88. /package/dist/{chunk-RU6332MD.js.map → chunk-566LB3G2.js.map} +0 -0
  89. /package/dist/{chunk-MI7774NV.js.map → chunk-5BP2A7BI.js.map} +0 -0
  90. /package/dist/{chunk-OQDBARD5.js.map → chunk-5KNTKBP6.js.map} +0 -0
  91. /package/dist/{chunk-GBZNFSFY.js.map → chunk-ADTCTKXS.js.map} +0 -0
  92. /package/dist/{chunk-FD4AB6TM.js.map → chunk-BBP7QV32.js.map} +0 -0
  93. /package/dist/{chunk-LFVPS7KB.js.map → chunk-CFTWXYBO.js.map} +0 -0
  94. /package/dist/{chunk-35WWWFS6.js.map → chunk-DAESCCLR.js.map} +0 -0
package/dist/base.d.ts CHANGED
@@ -1,19 +1,21 @@
1
- import { C as ComputedItemContext } from './session.context.d-D5080LVx.js';
2
- export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-D5080LVx.js';
3
- import { C as ComputedContext } from './computed.types.d-gJrBeUMG.js';
4
- export { a as ComputedItem } from './computed.types.d-gJrBeUMG.js';
5
- export { C as ConfigContext, V as ValidationDisplayMode, c as configContext } from './config.context.d-BvU9r-Mg.js';
6
- export { C as ChoiceRole, I as Interaction, a as InteractionContext, i as interactionContext } from './interaction.d-g6XG0T0Z.js';
7
- import { b as ItemContext, B as BaseType } from './item.types.d-B55QkJ92.js';
8
- export { C as Calculate, a as Cardinality, I as InterpolationTableEntry, M as Multiple, O as Ordered, c as OutcomeVariable, Q as QtiAreaMapEntry, d as QtiAreaMapping, e as QtiMapEntry, f as QtiMapping, R as ResponseInteraction, g as ResponseVariable, T as TemplateVariable, V as VariableDeclaration, h as VariableValue, i as areaShape, j as directedPair, k as float, l as integer, m as itemContextVariables } from './item.types.d-B55QkJ92.js';
1
+ import { C as ComputedItemContext } from './session.context.d-9gRdGK4T.js';
2
+ export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-9gRdGK4T.js';
3
+ import { C as ComputedContext } from './computed.types.d-BPzPFX3Z.js';
4
+ export { a as ComputedItem, S as SessionControl } from './computed.types.d-BPzPFX3Z.js';
5
+ export { C as ConfigContext, V as ValidationDisplayMode, c as configContext } from './config.context.d-Dm11aAuw.js';
6
+ export { C as ChoiceRole, I as Interaction, a as InteractionContext, R as RecordFieldValues, b as RecordValue, V as ValidityKind, c as ValidityTrigger, i as inferRecordFieldBaseType, d as interactionContext, e as isRecordValue, r as readRecordFieldValues } from './record.d-N1Bq7e1f.js';
7
+ import { I as ItemContext } from './item.types.d-Zc6ZQDhu.js';
8
+ export { i as itemContextVariables } from './item.types.d-Zc6ZQDhu.js';
9
9
  export { Q as QtiContext, a as QtiContextType, S as Seed, b as asSeed, i as isSeed, q as qtiContext } from './qti.context.d-CejJMlfZ.js';
10
- export { I as INITIAL_TEST_CONTEXT, Q as QtiExpression, a as QtiExpressionBase, T as TestContext, t as testContext } from './qti-expression.d-BPxEp8HU.js';
10
+ export { I as INITIAL_TEST_CONTEXT, Q as QtiExpression, a as QtiExpressionBase, T as TestContext, t as testContext } from './qti-expression.d-iH3w6mqf.js';
11
11
  import * as lit from 'lit';
12
- export { Q as QtiFeedback, a as QtiVariableDeclaration } from './qti-feedback.d-wMYNVkkj.js';
13
- export { Q as QtiConditionExpression } from './qti-condition-expression.d-VJH6cWxf.js';
12
+ export { Q as QtiFeedback, a as QtiVariableDeclaration } from './qti-feedback.d-CT0W-8Gm.js';
13
+ export { Q as QtiConditionExpression } from './qti-condition-expression.d-7Kd4LBxn.js';
14
14
  export { D as DirectedPair, I as Identifier, P as Point, R as ResponseValue, i as iterResponseValues, p as parsePair, a as parsePoint, b as parseResponseAttribute, r as responseAttributeConverter, s as serializePair, c as serializePoint, d as serializeResponseAttribute } from './response.d-_8y4kjGP.js';
15
+ import { B as BaseType } from './variables.d-DWHlTszN.js';
16
+ export { C as Calculate, a as Cardinality, I as InterpolationTableEntry, M as Multiple, O as Ordered, b as OutcomeVariable, Q as QtiAreaMapEntry, c as QtiAreaMapping, d as QtiMapEntry, e as QtiMapping, R as ResponseInteraction, f as ResponseVariable, T as TemplateVariable, V as VariableDeclaration, g as VariableValue, h as areaShape, i as directedPair, j as float, k as integer } from './variables.d-DWHlTszN.js';
15
17
  export { F as FormAssociatedInteraction, I as IInteraction, R as ReadonlyInteraction, a as RegisteredInteraction, b as ResettableInteraction, c as ResponseIdentifiedInteraction, d as ResponseInteractionElement, V as ValidatableInteraction } from './interaction.interface.d-CvjHM2bi.js';
16
- export { Q as QtiExitResponseSignal, a as QtiExitTestSignal, b as QtiRuleBase, c as QtiRuleElement } from './qti-rule-base.d-Bdzg8eGH.js';
18
+ export { Q as QtiExitResponseSignal, a as QtiExitTestSignal, b as QtiRuleBase, c as QtiRuleElement } from './qti-rule-base.d-CeKP0Ooi.js';
17
19
 
18
20
  declare const computedItemContext: {
19
21
  __context__: Readonly<ComputedItemContext>;
@@ -192,6 +194,30 @@ declare function classifyCustomStateSupport(attachInternals: (this: HTMLElement)
192
194
  */
193
195
  declare function installCustomStateSetFallback(): CustomStateSupport | 'already-installed';
194
196
 
197
+ /**
198
+ * The vocabulary of custom states (CONTRACT.md §3 in qti-theme), with the names it replaced.
199
+ *
200
+ * A state is set under the name the contract uses. For one major the old name is set too, so a
201
+ * host that still reads `:state(drag)` keeps working while the theme reads `:state(chip)`. When the
202
+ * alias period ends, empty the table; every call site then sets only the new name.
203
+ *
204
+ * Not in the table, because the old name meant something else on another element:
205
+ * - a drop target's `drag-active` replaced `active` + `enabled`; the interaction host's `drag-active`
206
+ * replaced `dragzone-active` + `dragzone-enabled`. Each call site names its own old pair.
207
+ * - a drop target's `full` replaced the attribute `disabled`, which stays as an attribute.
208
+ * - `answer-key` replaced `show-correct-response` on an interaction host and `correct-response` on a
209
+ * choice; the corrections package passes the one that applies.
210
+ */
211
+ declare const STATE_ALIASES: Readonly<Record<string, readonly string[]>>;
212
+ type StateSet = Pick<Set<string>, 'add' | 'delete' | 'has'>;
213
+ /**
214
+ * Set or clear a state and its aliases. `states` may be undefined on an element without internals;
215
+ * then nothing happens, as before.
216
+ */
217
+ declare function setState(states: StateSet | undefined | null, name: string, on: boolean, oldNames?: readonly string[]): void;
218
+ /** Whether a state is set, under its contract name or an alias. */
219
+ declare function hasState(states: StateSet | undefined | null, name: string): boolean;
220
+
195
221
  declare class ScoringHelper {
196
222
  /**
197
223
  * Checks if a given point is within a specified area.
@@ -232,4 +258,4 @@ declare const convertNumberToUniversalFormat: (number: number | string) => strin
232
258
  declare function IsNullOrUndefined(value: unknown): boolean;
233
259
  declare function removeDoubleSlashes(str: string): string;
234
260
 
235
- export { BaseType, ComputedContext, ComputedItemContext, type CustomOperator, type CustomOperatorValue, CustomStateSetShim, type CustomStateSupport, IsNullOrUndefined, ItemContext, ScoringHelper, boxSizing, classifyCustomStateSupport, computedContext, computedItemContext, convertNumberToUniversalFormat, decimalSeparator, dropRegion, getCustomOperator, installCustomStateSetFallback, itemContext, registerCustomOperator, removeDoubleSlashes, unregisterCustomOperator, validationMessage };
261
+ export { BaseType, ComputedContext, ComputedItemContext, type CustomOperator, type CustomOperatorValue, CustomStateSetShim, type CustomStateSupport, IsNullOrUndefined, ItemContext, STATE_ALIASES, ScoringHelper, boxSizing, classifyCustomStateSupport, computedContext, computedItemContext, convertNumberToUniversalFormat, decimalSeparator, dropRegion, getCustomOperator, hasState, installCustomStateSetFallback, itemContext, registerCustomOperator, removeDoubleSlashes, setState, unregisterCustomOperator, validationMessage };
package/dist/base.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  QtiFeedback,
12
12
  QtiRuleElement,
13
13
  QtiVariableDeclaration,
14
+ STATE_ALIASES,
14
15
  ScoringHelper,
15
16
  asSeed,
16
17
  boxSizing,
@@ -22,8 +23,11 @@ import {
22
23
  decimalSeparator,
23
24
  dropRegion,
24
25
  getCustomOperator,
26
+ hasState,
27
+ inferRecordFieldBaseType,
25
28
  installCustomStateSetFallback,
26
29
  interactionContext,
30
+ isRecordValue,
27
31
  isSeed,
28
32
  itemContext,
29
33
  itemContextVariables,
@@ -32,6 +36,7 @@ import {
32
36
  parsePoint,
33
37
  parseResponseAttribute,
34
38
  qtiContext,
39
+ readRecordFieldValues,
35
40
  registerCustomOperator,
36
41
  removeDoubleSlashes,
37
42
  responseAttributeConverter,
@@ -39,10 +44,12 @@ import {
39
44
  serializePoint,
40
45
  serializeResponseAttribute,
41
46
  sessionContext,
47
+ setState,
42
48
  testContext,
43
49
  unregisterCustomOperator,
44
50
  validationMessage
45
- } from "./chunk-TDWJ6WZA.js";
51
+ } from "./chunk-GPC53O7P.js";
52
+ import "./chunk-PZ5AY32C.js";
46
53
  export {
47
54
  CustomStateSetShim,
48
55
  INITIAL_SESSION_CONTEXT,
@@ -56,6 +63,7 @@ export {
56
63
  QtiFeedback,
57
64
  QtiRuleElement,
58
65
  QtiVariableDeclaration,
66
+ STATE_ALIASES,
59
67
  ScoringHelper,
60
68
  asSeed,
61
69
  boxSizing,
@@ -67,8 +75,11 @@ export {
67
75
  decimalSeparator,
68
76
  dropRegion,
69
77
  getCustomOperator,
78
+ hasState,
79
+ inferRecordFieldBaseType,
70
80
  installCustomStateSetFallback,
71
81
  interactionContext,
82
+ isRecordValue,
72
83
  isSeed,
73
84
  itemContext,
74
85
  itemContextVariables,
@@ -77,6 +88,7 @@ export {
77
88
  parsePoint,
78
89
  parseResponseAttribute,
79
90
  qtiContext,
91
+ readRecordFieldValues,
80
92
  registerCustomOperator,
81
93
  removeDoubleSlashes,
82
94
  responseAttributeConverter,
@@ -84,6 +96,7 @@ export {
84
96
  serializePoint,
85
97
  serializeResponseAttribute,
86
98
  sessionContext,
99
+ setState,
87
100
  testContext,
88
101
  unregisterCustomOperator,
89
102
  validationMessage
@@ -1,11 +1,10 @@
1
1
  import {
2
2
  QtiTest,
3
- TestCheckItem,
4
3
  TestNavigation
5
- } from "./chunk-SIE3E4FG.js";
4
+ } from "./chunk-YRR6D6UP.js";
6
5
  import {
7
6
  QtiAssessmentItem
8
- } from "./chunk-6U3YPHXU.js";
7
+ } from "./chunk-GAPMCYR5.js";
9
8
  import {
10
9
  QtiAssociateInteraction,
11
10
  QtiChoiceInteraction,
@@ -28,10 +27,10 @@ import {
28
27
  QtiSimpleChoice,
29
28
  QtiSliderInteraction,
30
29
  QtiTextEntryInteraction
31
- } from "./chunk-RSMYGGQK.js";
30
+ } from "./chunk-TZCOXFPB.js";
32
31
  import {
33
32
  QtiItem
34
- } from "./chunk-RU6332MD.js";
33
+ } from "./chunk-566LB3G2.js";
35
34
  import {
36
35
  watch
37
36
  } from "./chunk-4DB4SC5K.js";
@@ -40,8 +39,10 @@ import {
40
39
  computedContext,
41
40
  computedItemContext,
42
41
  configContext,
43
- responseAttributeConverter
44
- } from "./chunk-TDWJ6WZA.js";
42
+ hasState,
43
+ responseAttributeConverter,
44
+ setState
45
+ } from "./chunk-GPC53O7P.js";
45
46
 
46
47
  // ../qti-corrections/dist/components/item-correct-response-mode/item-correct-response-mode.js
47
48
  import { html, LitElement } from "lit";
@@ -103,8 +104,15 @@ import { consume as consume2 } from "@lit/context";
103
104
 
104
105
  // ../qti-corrections/dist/components/styles.js
105
106
  import { css } from "lit";
106
- var form = css`
107
+ var hostBox = css`
107
108
  display: inline-flex;
109
+ cursor: pointer;
110
+ border-radius: 0.25rem;
111
+ user-select: none;
112
+ `;
113
+ var form = css`
114
+ display: flex;
115
+ flex: 1 1 auto;
108
116
  align-items: center;
109
117
  cursor: pointer;
110
118
  padding: 0.5rem 1rem;
@@ -135,6 +143,9 @@ var ItemShowCandidateCorrection = class extends LitElement2 {
135
143
  static {
136
144
  this.styles = css2`
137
145
  :host {
146
+ ${hostBox};
147
+ }
148
+ div {
138
149
  ${btn};
139
150
  }
140
151
  :host([disabled]) {
@@ -225,6 +236,9 @@ var ItemShowCorrectResponse = class extends LitElement3 {
225
236
  static {
226
237
  this.styles = css3`
227
238
  :host {
239
+ ${hostBox};
240
+ }
241
+ div {
228
242
  ${btn};
229
243
  }
230
244
  :host([disabled]) {
@@ -292,31 +306,53 @@ var __decorate4 = function(decorators, target, key, desc) {
292
306
  return c > 3 && r && Object.defineProperty(target, key, r), r;
293
307
  };
294
308
  var TestShowCorrectResponse = class extends LitElement4 {
295
- constructor() {
296
- super(...arguments);
297
- this.shown = false;
298
- this.disabled = false;
299
- this.showCorrectText = "Show correct response";
300
- this.hideCorrectText = "Hide correct response";
301
- this.noCorrectResponseText = "No correct response specified";
302
- }
303
309
  static {
304
310
  this.styles = css4`
305
311
  :host {
312
+ ${hostBox};
313
+ }
314
+ div {
306
315
  ${btn};
307
316
  }
317
+ :host(:focus-visible) {
318
+ outline: 2px solid currentColor;
319
+ outline-offset: 2px;
320
+ }
308
321
  :host([disabled]) {
309
322
  ${dis};
310
323
  }
311
324
  `;
312
325
  }
326
+ #internals;
327
+ constructor() {
328
+ super();
329
+ this.shown = false;
330
+ this.disabled = false;
331
+ this.showCorrectText = "Show correct response";
332
+ this.hideCorrectText = "Hide correct response";
333
+ this.noCorrectResponseText = "No correct response specified";
334
+ this.#internals = this.attachInternals();
335
+ this.#internals.role = "button";
336
+ this.addEventListener("click", () => this.#toggleState());
337
+ this.addEventListener("keydown", (event) => {
338
+ if (event.key !== "Enter" && event.key !== " ")
339
+ return;
340
+ event.preventDefault();
341
+ this.#toggleState();
342
+ });
343
+ }
344
+ connectedCallback() {
345
+ super.connectedCallback();
346
+ if (!this.hasAttribute("tabindex"))
347
+ this.tabIndex = 0;
348
+ }
313
349
  #previousActiveItem;
314
- // Store previous active item reference
350
+ // The identifier of the item the control last showed
315
351
  willUpdate(_changedProperties) {
316
352
  const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
317
- if (this.#previousActiveItem !== activeItem) {
353
+ if (this.#previousActiveItem !== activeItem?.identifier) {
318
354
  this.shown = false;
319
- this.#previousActiveItem = activeItem;
355
+ this.#previousActiveItem = activeItem?.identifier;
320
356
  }
321
357
  if (activeItem) {
322
358
  const containsCorrectResponse = !!activeItem?.variables?.some((v) => v["correctResponse"]);
@@ -327,6 +363,8 @@ var TestShowCorrectResponse = class extends LitElement4 {
327
363
  } else {
328
364
  this.disabled = true;
329
365
  }
366
+ this.#internals.ariaDisabled = String(this.disabled);
367
+ this.#internals.ariaPressed = String(this.shown);
330
368
  }
331
369
  #toggleState() {
332
370
  if (this.disabled)
@@ -341,7 +379,7 @@ var TestShowCorrectResponse = class extends LitElement4 {
341
379
  return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;
342
380
  }
343
381
  render() {
344
- return html4` <div @click="${this.#toggleState}">${this.#getDisplayedText()}</div> `;
382
+ return html4`<div part="button">${this.#getDisplayedText()}</div>`;
345
383
  }
346
384
  };
347
385
  __decorate4([
@@ -371,9 +409,9 @@ var correctionPart = css5`
371
409
  display: none;
372
410
  }
373
411
 
374
- [part~='correction-correct'],
375
- [part~='correction-incorrect'],
376
- [part~='correction-partially-correct'] {
412
+ [part~='correction'][part~='candidate-correct'],
413
+ [part~='correction'][part~='candidate-incorrect'],
414
+ [part~='correction'][part~='candidate-partial'] {
377
415
  display: inline-flex;
378
416
  flex: 0 0 auto;
379
417
 
@@ -404,6 +442,15 @@ var correctionPart = css5`
404
442
  import { html as html5 } from "lit";
405
443
 
406
444
  // ../qti-corrections/dist/mixins/active-element-correction.mixin.js
445
+ var verdictState = (value) => value === "partially-correct" ? "candidate-partial" : `candidate-${value}`;
446
+ var VERDICT_STATES = ["candidate-correct", "candidate-incorrect", "candidate-partial"];
447
+ var correctionPartFor = (value) => value ? `correction ${verdictState(value)} correction-${value}` : "correction";
448
+ var applyVerdictStates = (states, value) => {
449
+ for (const name of VERDICT_STATES)
450
+ setState(states, name, false);
451
+ if (value)
452
+ setState(states, verdictState(value), true);
453
+ };
407
454
  var ActiveElementCorrectionMixin = (superClass) => {
408
455
  class ActiveElementCorrectionMixinClass extends superClass {
409
456
  #candidateCorrection = null;
@@ -415,16 +462,11 @@ var ActiveElementCorrectionMixin = (superClass) => {
415
462
  return;
416
463
  const previous = this.#candidateCorrection;
417
464
  this.#candidateCorrection = value;
418
- const states = this.internals.states;
419
- states.delete("candidate-correct");
420
- states.delete("candidate-incorrect");
421
- states.delete("candidate-partially-correct");
422
- if (value)
423
- states.add(`candidate-${value}`);
465
+ applyVerdictStates(this.internals.states, value);
424
466
  this.requestUpdate("candidateCorrection", previous);
425
467
  }
426
468
  get correctionPart() {
427
- return this.#candidateCorrection ? `correction correction-${this.#candidateCorrection}` : "correction";
469
+ return correctionPartFor(this.#candidateCorrection);
428
470
  }
429
471
  }
430
472
  return ActiveElementCorrectionMixinClass;
@@ -455,6 +497,15 @@ var QtiHotspotChoiceCorrection = class extends ActiveElementCorrectionMixin(QtiH
455
497
  super(...arguments);
456
498
  this.orderCorrect = null;
457
499
  }
500
+ updated(changed) {
501
+ super.updated(changed);
502
+ if (!changed.has("orderCorrect"))
503
+ return;
504
+ if (this.orderCorrect == null)
505
+ this.removeAttribute("data-order-correct");
506
+ else
507
+ this.setAttribute("data-order-correct", String(this.orderCorrect));
508
+ }
458
509
  };
459
510
  __decorate5([
460
511
  property5({ attribute: "aria-ordercorrectvalue", type: Number, reflect: true })
@@ -498,8 +549,10 @@ var QtiSimpleChoiceCorrection = class extends ActiveElementCorrectionMixin(QtiSi
498
549
  static {
499
550
  this.styles = [QtiSimpleChoice.styles, correctionPart];
500
551
  }
552
+ // Same template as QtiSimpleChoice plus the badge. No tabindex on the control: the choice takes
553
+ // focus on its host, and a focusable control made every choice two Tab stops.
501
554
  render() {
502
- return html8`<div part="control" tabindex="0"><div part="control-mark"></div></div>
555
+ return html8`<div part="control"><div part="control-mark"></div></div>
503
556
  ${this.marker ? html8`<div id="label" part="marker">${this.marker}</div>` : nothing}
504
557
  <slot part="label"></slot>
505
558
  <span part=${this.correctionPart} aria-hidden="true"></span>`;
@@ -565,6 +618,7 @@ var CorrectResponseMixin = (superClass) => {
565
618
  this.setAttribute("inert", "");
566
619
  this.setAttribute("response-identifier", this.responseIdentifier + "_cr");
567
620
  this.setAttribute("answer-key", "");
621
+ setState(this._internals.states, "answer-key", true, []);
568
622
  }
569
623
  }
570
624
  get correctResponse() {
@@ -673,10 +727,9 @@ var CorrectResponseMixin = (superClass) => {
673
727
  clone.response = Array.isArray(correctResponse) ? [...correctResponse] : correctResponse;
674
728
  }
675
729
  toggleInternalCorrectResponse(show) {
676
- this._internals.states.delete("show-correct-response");
677
- if (show && this.correctResponse) {
678
- this._internals.states.add("show-correct-response");
679
- }
730
+ setState(this._internals.states, "answer-key-shown", Boolean(show && this.correctResponse), [
731
+ "show-correct-response"
732
+ ]);
680
733
  }
681
734
  toggleCandidateCorrection(show) {
682
735
  if (!show) {
@@ -746,7 +799,7 @@ var CandidateCorrectionMixin = (superClass) => {
746
799
  this._candidateCorrection = null;
747
800
  }
748
801
  get correctionPart() {
749
- return this._candidateCorrection ? `correction correction-${this._candidateCorrection}` : "correction";
802
+ return correctionPartFor(this._candidateCorrection);
750
803
  }
751
804
  toggleCandidateCorrection(show) {
752
805
  if (this.showCandidateCorrection !== show) {
@@ -754,24 +807,16 @@ var CandidateCorrectionMixin = (superClass) => {
754
807
  }
755
808
  super.toggleCandidateCorrection(show);
756
809
  const internals = this._internals;
757
- internals.states.delete("candidate-correct");
758
- internals.states.delete("candidate-partially-correct");
759
- internals.states.delete("candidate-incorrect");
760
810
  let verdict = null;
761
811
  if (show) {
762
- if (this.correctness === Correctness.Correct) {
763
- internals.states.add("candidate-correct");
812
+ if (this.correctness === Correctness.Correct)
764
813
  verdict = "correct";
765
- }
766
- if (this.correctness === Correctness.PartiallyCorrect) {
767
- internals.states.add("candidate-partially-correct");
814
+ if (this.correctness === Correctness.PartiallyCorrect)
768
815
  verdict = "partially-correct";
769
- }
770
- if (this.correctness === Correctness.Incorrect) {
771
- internals.states.add("candidate-incorrect");
816
+ if (this.correctness === Correctness.Incorrect)
772
817
  verdict = "incorrect";
773
- }
774
818
  }
819
+ applyVerdictStates(internals.states, verdict);
775
820
  if (this._candidateCorrection !== verdict) {
776
821
  this._candidateCorrection = verdict;
777
822
  }
@@ -827,11 +872,8 @@ var ChoiceCorrectionMixin = (superClass) => {
827
872
  const correctResponse = this.correctResponse;
828
873
  const correctResponses = correctResponse ? Array.isArray(correctResponse) ? correctResponse : [correctResponse] : [];
829
874
  for (const choice of this._choiceElements) {
830
- choice.internals.states.delete("correct-response");
831
- choice.internals.states.delete("incorrect-response");
832
- if (show && correctResponses.length > 0) {
833
- choice.internals.states.add(correctResponses.includes(choice.identifier) ? "correct-response" : "incorrect-response");
834
- }
875
+ const inKey = show && correctResponses.includes(choice.identifier);
876
+ setState(choice.internals.states, "answer-key", inKey, ["correct-response"]);
835
877
  }
836
878
  }
837
879
  toggleCandidateCorrection(show) {
@@ -879,9 +921,9 @@ var QtiExtendedTextInteractionCorrection = class extends ActiveElementCorrection
879
921
  * is the contract in correction.styles.ts, which deliberately leaves the shared badge in flow
880
922
  * and invites a component to lift it out if it wants a corner badge.
881
923
  *
882
- * A textarea is a box the candidate writes in, so the badge goes over its top-left corner
883
- * rather than trailing the text the way a chip's does, and the theme reserves the gutter for it
884
- * (padding-left on ::part(textarea)).
924
+ * A textarea is a box the candidate writes in, so the badge goes in its top end corner (top
925
+ * right in a left-to-right text) rather than trailing the text the way a chip's does, and the
926
+ * theme reserves the gutter for it (the end padding on ::part(textarea)).
885
927
  *
886
928
  * Anchored to the TEXTAREA, not to the host. The badge's containing block is :host, and the
887
929
  * host also contains the prompt slot — so a plain top: 0.85rem measured from the host lands on
@@ -910,9 +952,10 @@ var QtiExtendedTextInteractionCorrection = class extends ActiveElementCorrection
910
952
  */
911
953
  height: calc(var(--qti-correction-size) * var(--qti-field-line-height));
912
954
 
913
- /* Inset exactly as the text is: the same trailing token the two field-shaped interactions
914
- use, read here as a LEADING inset because this badge lives in a left gutter. */
915
- left: var(--qti-correction-inset);
955
+ /* In the gutter at the end of the line, inset exactly as the text is from the other side:
956
+ the same trailing token the two field-shaped interactions use. The gutter was on the start
957
+ side once, which left every answer indented by the badge's room even when ungraded. */
958
+ inset-inline-end: var(--qti-correction-inset);
916
959
 
917
960
  /* Anchored to the field's first line: its top edge plus the field's own padding-top. */
918
961
  top: calc(anchor(top) + var(--qti-spacing));
@@ -994,7 +1037,7 @@ var QtiGraphicAssociateInteractionCorrection = class extends CandidateCorrection
994
1037
  renderSupplementalLines() {
995
1038
  return repeat2(this.#correctLines, (line) => line, (line) => svg`
996
1039
  <line
997
- part="correct-line"
1040
+ part="line answer-key correct-line"
998
1041
  x1=${parseInt(this.querySelector(`[identifier=${line.split(" ")[0]}]`).style.left)}
999
1042
  y1=${parseInt(this.querySelector(`[identifier=${line.split(" ")[0]}]`).style.top)}
1000
1043
  x2=${parseInt(this.querySelector(`[identifier=${line.split(" ")[1]}]`).style.left)}
@@ -1014,13 +1057,11 @@ var QtiGraphicGapMatchInteractionCorrection = class extends DragDropCorrectionMi
1014
1057
  // ../qti-corrections/dist/interactions/qti-graphic-order-interaction-correction.js
1015
1058
  var QtiGraphicOrderInteractionCorrection = class extends CandidateCorrectionMixin(QtiGraphicOrderInteraction) {
1016
1059
  resolvePinColor(choice) {
1017
- const correctableChoice = choice;
1018
- if (correctableChoice.matches(":state(candidate-incorrect)"))
1060
+ const { internals } = choice;
1061
+ if (hasState(internals.states, "candidate-incorrect"))
1019
1062
  return "var(--qti-incorrect)";
1020
- if (correctableChoice.matches(":state(candidate-correct)"))
1063
+ if (hasState(internals.states, "candidate-correct"))
1021
1064
  return "var(--qti-correct)";
1022
- if (correctableChoice.matches(":state(correct-response)"))
1023
- return "var(--qti-answer-border)";
1024
1065
  return super.resolvePinColor(choice);
1025
1066
  }
1026
1067
  toggleInternalCorrectResponse(show) {
@@ -1145,7 +1186,7 @@ var QtiMatchInteractionCorrection = class extends DragDropCorrectionMixin(QtiMat
1145
1186
  getCellStateVariant(value, checked) {
1146
1187
  if (!this.showCandidateCorrection || !checked)
1147
1188
  return "";
1148
- return this.#correctPairs.has(value) ? "correct" : "incorrect";
1189
+ return this.#correctPairs.has(value) ? "candidate-correct correct" : "candidate-incorrect incorrect";
1149
1190
  }
1150
1191
  };
1151
1192
 
@@ -1287,10 +1328,10 @@ var QtiSelectPointInteractionCorrection = class extends CandidateCorrectionMixin
1287
1328
  this.styles = [
1288
1329
  QtiSelectPointInteraction.styles,
1289
1330
  css8`
1290
- [part~='correct'] {
1331
+ [part~='candidate-correct'] {
1291
1332
  --qti-select-point-marker-color: var(--qti-correct);
1292
1333
  }
1293
- [part~='incorrect'] {
1334
+ [part~='candidate-incorrect'] {
1294
1335
  --qti-select-point-marker-color: var(--qti-incorrect);
1295
1336
  }
1296
1337
  `
@@ -1349,7 +1390,9 @@ var QtiSelectPointInteractionCorrection = class extends CandidateCorrectionMixin
1349
1390
  }
1350
1391
  pointPart(_point, index) {
1351
1392
  const verdict = this.#responseCorrection[index];
1352
- return verdict === void 0 ? "point" : `point ${verdict ? "correct" : "incorrect"}`;
1393
+ if (verdict === void 0)
1394
+ return "point";
1395
+ return verdict ? "point candidate-correct correct" : "point candidate-incorrect incorrect";
1353
1396
  }
1354
1397
  renderSupplementalLayer() {
1355
1398
  return repeat3(this.#correctAreas, (area) => `${area.shape}:${area.coords}`, (area, index) => html11`<div
@@ -1381,7 +1424,7 @@ var QtiSliderInteractionCorrection = class extends CandidateCorrectionMixin(QtiS
1381
1424
  this.styles = [
1382
1425
  QtiSliderInteraction.styles,
1383
1426
  css9`
1384
- [part='knob-correct'] {
1427
+ [part~='knob'][part~='answer-key'] {
1385
1428
  background-color: var(--qti-correct-light);
1386
1429
  border: 2px solid var(--qti-correct);
1387
1430
  position: relative;
@@ -1412,7 +1455,7 @@ var QtiSliderInteractionCorrection = class extends CandidateCorrectionMixin(QtiS
1412
1455
  this.requestUpdate("correctResponseNumber", previous);
1413
1456
  }
1414
1457
  renderRailSupplement() {
1415
- return this.#correctResponseNumber === null ? nothing2 : html12`<div id="knob-correct" part="knob-correct">
1458
+ return this.#correctResponseNumber === null ? nothing2 : html12`<div id="knob-correct" part="knob answer-key knob-correct">
1416
1459
  <div id="value" part="value">${this.#correctResponseNumber}</div>
1417
1460
  </div>`;
1418
1461
  }
@@ -1445,15 +1488,6 @@ var QtiTextEntryInteractionCorrection = class extends CandidateCorrectionMixin(Q
1445
1488
  position: relative;
1446
1489
  anchor-name: --text-entry-host, --qti-correction-anchor;
1447
1490
  }
1448
- [part='correct'] {
1449
- position: absolute;
1450
- position-anchor: --text-entry-host;
1451
- position-area: top span-right;
1452
- margin-bottom: 0.25rem;
1453
- padding: var(--qti-padding-box);
1454
- background-color: var(--qti-bg);
1455
- white-space: nowrap;
1456
- }
1457
1491
  `
1458
1492
  ];
1459
1493
  }
@@ -1603,7 +1637,7 @@ var TestNavigationCorrection = class extends TestNavigation {
1603
1637
  * the candidate reached the optimal outcome, or ran out of attempts.
1604
1638
  */
1605
1639
  afterAttemptEnded(assessmentItem, computedItem, done) {
1606
- if (!assessmentItem || !computedItem?.showSolution)
1640
+ if (!assessmentItem || !computedItem?.sessionControl?.showSolution)
1607
1641
  return;
1608
1642
  const correctable = assessmentItem;
1609
1643
  correctable.showCandidateCorrection?.(true);
@@ -1615,14 +1649,6 @@ var QtiTestCorrection = class extends QtiTest {
1615
1649
  assessmentItem.showCorrectResponse?.(view === "scorer");
1616
1650
  }
1617
1651
  };
1618
- var TestCheckItemCorrection = class extends TestCheckItem {
1619
- constructor() {
1620
- super();
1621
- this.addEventListener("click", () => {
1622
- this.dispatchEvent(new CustomEvent("test-show-correct-response", { detail: true, bubbles: true }));
1623
- });
1624
- }
1625
- };
1626
1652
 
1627
1653
  export {
1628
1654
  ItemCorrectResponseMode,
@@ -1658,7 +1684,6 @@ export {
1658
1684
  QtiAssessmentItemCorrection,
1659
1685
  QtiItemCorrection,
1660
1686
  TestNavigationCorrection,
1661
- QtiTestCorrection,
1662
- TestCheckItemCorrection
1687
+ QtiTestCorrection
1663
1688
  };
1664
- //# sourceMappingURL=chunk-D3BYGEQU.js.map
1689
+ //# sourceMappingURL=chunk-2ZT47EUK.js.map