@citolab/qti-components 10.0.0-next.5 → 10.0.0-next.7

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 (63) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +1758 -201
  3. package/dist/base.d.ts +10 -10
  4. package/dist/base.js +7 -1
  5. package/dist/{chunk-JNZ3HSFI.js → chunk-3TUGZHKB.js} +3 -3
  6. package/dist/{chunk-A2AP6CUL.js → chunk-6PCCBSPB.js} +4 -4
  7. package/dist/{chunk-WVDQLBMT.js → chunk-DJHH5D3E.js} +2 -2
  8. package/dist/{chunk-R7ZCUQU2.js → chunk-LCGPLQLE.js} +40 -4
  9. package/dist/chunk-LCGPLQLE.js.map +1 -0
  10. package/dist/{chunk-CXTHPEUN.js → chunk-M7X6TWSX.js} +2 -2
  11. package/dist/{chunk-F7QDRKCR.js → chunk-Q3C7XFVS.js} +2 -2
  12. package/dist/chunk-QVZLJY75.js +7 -0
  13. package/dist/chunk-QVZLJY75.js.map +1 -0
  14. package/dist/{chunk-WV53LUE3.js → chunk-RN3MD444.js} +2 -2
  15. package/dist/{chunk-WC3P4KCV.js → chunk-RSSEBILM.js} +386 -241
  16. package/dist/chunk-RSSEBILM.js.map +1 -0
  17. package/dist/{chunk-O5HGNYB2.js → chunk-RWMY7KRT.js} +2 -2
  18. package/dist/{chunk-JZZMY3FA.js → chunk-T7YSBBAA.js} +37 -1
  19. package/dist/chunk-T7YSBBAA.js.map +1 -0
  20. package/dist/{chunk-KB2NJTSD.js → chunk-VG5YI2OB.js} +6 -6
  21. package/dist/{chunk-QU23PPEZ.js → chunk-YOCOLMGB.js} +40 -5
  22. package/dist/{chunk-QU23PPEZ.js.map → chunk-YOCOLMGB.js.map} +1 -1
  23. package/dist/{computed.types.d-DvxBgnze.d.ts → computed.types.d-IXACuBr7.d.ts} +1 -1
  24. package/dist/corrections.d.ts +9 -9
  25. package/dist/corrections.js +8 -8
  26. package/dist/elements.d.ts +2 -2
  27. package/dist/elements.js +3 -3
  28. package/dist/index.d.ts +10 -10
  29. package/dist/index.js +23 -13
  30. package/dist/interactions.d.ts +4 -4
  31. package/dist/interactions.js +7 -3
  32. package/dist/item.css +2 -1
  33. package/dist/item.d.ts +4 -4
  34. package/dist/item.js +4 -4
  35. package/dist/{item.types.d-B55QkJ92.d.ts → item.types.d-DuVR0ZVK.d.ts} +7 -1
  36. package/dist/loader.d.ts +2 -2
  37. package/dist/processing.d.ts +10 -3
  38. package/dist/processing.js +3 -3
  39. package/dist/qti-components-jsx.d.ts +46 -26
  40. package/dist/{qti-condition-expression.d-VJH6cWxf.d.ts → qti-condition-expression.d-B-T1NNl0.d.ts} +1 -1
  41. package/dist/{qti-expression.d-BPxEp8HU.d.ts → qti-expression.d-B-Cfbqlb.d.ts} +1 -1
  42. package/dist/{qti-feedback.d-wMYNVkkj.d.ts → qti-feedback.d-DbzPSJuK.d.ts} +1 -1
  43. package/dist/{qti-item.d-klsgIEKQ.d.ts → qti-item.d-B1gffYCL.d.ts} +1 -1
  44. package/dist/{qti-test.d-Cra3sS-2.d.ts → qti-test.d-CHIATIDg.d.ts} +4 -4
  45. package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-utFyp1DH.d.ts} +28 -18
  46. package/dist/{interaction.d-g6XG0T0Z.d.ts → record.d-wB9uYs-j.d.ts} +34 -2
  47. package/dist/{session.context.d-DYAdqSer.d.ts → session.context.d-DW09Lrie.d.ts} +1 -1
  48. package/dist/test.d.ts +7 -7
  49. package/dist/test.js +5 -5
  50. package/package.json +9 -9
  51. package/dist/chunk-JZZMY3FA.js.map +0 -1
  52. package/dist/chunk-R7ZCUQU2.js.map +0 -1
  53. package/dist/chunk-WC3P4KCV.js.map +0 -1
  54. package/dist/chunk-ZP6QQYSU.js +0 -7
  55. package/dist/chunk-ZP6QQYSU.js.map +0 -1
  56. /package/dist/{chunk-JNZ3HSFI.js.map → chunk-3TUGZHKB.js.map} +0 -0
  57. /package/dist/{chunk-A2AP6CUL.js.map → chunk-6PCCBSPB.js.map} +0 -0
  58. /package/dist/{chunk-WVDQLBMT.js.map → chunk-DJHH5D3E.js.map} +0 -0
  59. /package/dist/{chunk-CXTHPEUN.js.map → chunk-M7X6TWSX.js.map} +0 -0
  60. /package/dist/{chunk-F7QDRKCR.js.map → chunk-Q3C7XFVS.js.map} +0 -0
  61. /package/dist/{chunk-WV53LUE3.js.map → chunk-RN3MD444.js.map} +0 -0
  62. /package/dist/{chunk-O5HGNYB2.js.map → chunk-RWMY7KRT.js.map} +0 -0
  63. /package/dist/{chunk-KB2NJTSD.js.map → chunk-VG5YI2OB.js.map} +0 -0
package/dist/base.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import { C as ComputedItemContext } from './session.context.d-DYAdqSer.js';
2
- export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-DYAdqSer.js';
3
- import { C as ComputedContext } from './computed.types.d-DvxBgnze.js';
4
- export { a as ComputedItem } from './computed.types.d-DvxBgnze.js';
1
+ import { C as ComputedItemContext } from './session.context.d-DW09Lrie.js';
2
+ export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-DW09Lrie.js';
3
+ import { C as ComputedContext } from './computed.types.d-IXACuBr7.js';
4
+ export { a as ComputedItem } from './computed.types.d-IXACuBr7.js';
5
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';
6
+ export { C as ChoiceRole, I as Interaction, a as InteractionContext, R as RecordFieldValues, b as RecordValue, i as inferRecordFieldBaseType, c as interactionContext, d as isRecordValue, r as readRecordFieldValues } from './record.d-wB9uYs-j.js';
7
+ import { b as ItemContext, B as BaseType } from './item.types.d-DuVR0ZVK.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-DuVR0ZVK.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-B-Cfbqlb.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-DbzPSJuK.js';
13
+ export { Q as QtiConditionExpression } from './qti-condition-expression.d-B-T1NNl0.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
15
  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
16
  export { Q as QtiExitResponseSignal, a as QtiExitTestSignal, b as QtiRuleBase, c as QtiRuleElement } from './qti-rule-base.d-Bdzg8eGH.js';
package/dist/base.js CHANGED
@@ -22,8 +22,10 @@ import {
22
22
  decimalSeparator,
23
23
  dropRegion,
24
24
  getCustomOperator,
25
+ inferRecordFieldBaseType,
25
26
  installCustomStateSetFallback,
26
27
  interactionContext,
28
+ isRecordValue,
27
29
  isSeed,
28
30
  itemContext,
29
31
  itemContextVariables,
@@ -32,6 +34,7 @@ import {
32
34
  parsePoint,
33
35
  parseResponseAttribute,
34
36
  qtiContext,
37
+ readRecordFieldValues,
35
38
  registerCustomOperator,
36
39
  removeDoubleSlashes,
37
40
  responseAttributeConverter,
@@ -42,7 +45,7 @@ import {
42
45
  testContext,
43
46
  unregisterCustomOperator,
44
47
  validationMessage
45
- } from "./chunk-JZZMY3FA.js";
48
+ } from "./chunk-T7YSBBAA.js";
46
49
  export {
47
50
  CustomStateSetShim,
48
51
  INITIAL_SESSION_CONTEXT,
@@ -67,8 +70,10 @@ export {
67
70
  decimalSeparator,
68
71
  dropRegion,
69
72
  getCustomOperator,
73
+ inferRecordFieldBaseType,
70
74
  installCustomStateSetFallback,
71
75
  interactionContext,
76
+ isRecordValue,
72
77
  isSeed,
73
78
  itemContext,
74
79
  itemContextVariables,
@@ -77,6 +82,7 @@ export {
77
82
  parsePoint,
78
83
  parseResponseAttribute,
79
84
  qtiContext,
85
+ readRecordFieldValues,
80
86
  registerCustomOperator,
81
87
  removeDoubleSlashes,
82
88
  responseAttributeConverter,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  item_css_default
3
- } from "./chunk-ZP6QQYSU.js";
3
+ } from "./chunk-QVZLJY75.js";
4
4
  import {
5
5
  watch
6
6
  } from "./chunk-4DB4SC5K.js";
@@ -11,7 +11,7 @@ import {
11
11
  computedItemContext,
12
12
  configContext,
13
13
  qtiContext
14
- } from "./chunk-JZZMY3FA.js";
14
+ } from "./chunk-T7YSBBAA.js";
15
15
 
16
16
  // ../qti-item/dist/components/item-container/item-container.js
17
17
  import { consume } from "@lit/context";
@@ -349,4 +349,4 @@ export {
349
349
  QtiItem,
350
350
  qtiItemElements
351
351
  };
352
- //# sourceMappingURL=chunk-JNZ3HSFI.js.map
352
+ //# sourceMappingURL=chunk-3TUGZHKB.js.map
@@ -3,10 +3,10 @@ import {
3
3
  dispatchDeclared,
4
4
  listenDeclared,
5
5
  listenPublic
6
- } from "./chunk-QU23PPEZ.js";
6
+ } from "./chunk-YOCOLMGB.js";
7
7
  import {
8
8
  item_css_default
9
- } from "./chunk-ZP6QQYSU.js";
9
+ } from "./chunk-QVZLJY75.js";
10
10
  import {
11
11
  watch
12
12
  } from "./chunk-4DB4SC5K.js";
@@ -24,7 +24,7 @@ import {
24
24
  qtiContext,
25
25
  sessionContext,
26
26
  testContext
27
- } from "./chunk-JZZMY3FA.js";
27
+ } from "./chunk-T7YSBBAA.js";
28
28
 
29
29
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
30
30
  import { LitElement, nothing as nothing2 } from "lit";
@@ -5455,4 +5455,4 @@ export {
5455
5455
  * Portions Copyright (c) 2013, the Dart project authors.
5456
5456
  *)
5457
5457
  */
5458
- //# sourceMappingURL=chunk-A2AP6CUL.js.map
5458
+ //# sourceMappingURL=chunk-6PCCBSPB.js.map
@@ -21,7 +21,7 @@ import {
21
21
  elements8,
22
22
  elements9,
23
23
  qtiInteractionElements
24
- } from "./chunk-WC3P4KCV.js";
24
+ } from "./chunk-RSSEBILM.js";
25
25
 
26
26
  // ../qti-interactions/dist/register-all.js
27
27
  for (const { tag, ctor } of qtiInteractionElements) {
@@ -176,4 +176,4 @@ for (const { tag, ctor } of elements21) {
176
176
  customElements.define(tag, ctor);
177
177
  }
178
178
  }
179
- //# sourceMappingURL=chunk-WVDQLBMT.js.map
179
+ //# sourceMappingURL=chunk-DJHH5D3E.js.map
@@ -5,9 +5,11 @@ import {
5
5
  QtiExpression,
6
6
  ScoringHelper,
7
7
  convertNumberToUniversalFormat,
8
+ inferRecordFieldBaseType,
9
+ isRecordValue,
8
10
  itemContext,
9
11
  testContext
10
- } from "./chunk-JZZMY3FA.js";
12
+ } from "./chunk-T7YSBBAA.js";
11
13
 
12
14
  // ../qti-processing/dist/components/qti-and/qti-and.js
13
15
  var QtiAnd = class extends qtiAndMixin(QtiConditionExpression) {
@@ -222,6 +224,9 @@ var QtiCorrect = class extends QtiExpression {
222
224
  getResult() {
223
225
  const identifier = this.getAttribute("identifier") || "";
224
226
  const responseVariable = this.context.variables.find((v) => v.identifier === identifier) || null;
227
+ if (responseVariable.cardinality === "record") {
228
+ return responseVariable.correctResponse ?? null;
229
+ }
225
230
  if (responseVariable.cardinality !== "single") {
226
231
  return responseVariable.correctResponse.length > 0 ? responseVariable.correctResponse[0] : "";
227
232
  } else {
@@ -631,6 +636,15 @@ var QtiExitTest = class extends QtiRule {
631
636
 
632
637
  // ../qti-processing/dist/components/qti-field-value/qti-field-value.js
633
638
  var QtiFieldValue = class extends QtiExpression {
639
+ #fieldBaseType;
640
+ /**
641
+ * The base type of the field last read: as declared on the record's correct response when it
642
+ * is, otherwise read off the value. The value alone is a string like `"4.1"` or `"455 250"`, and
643
+ * an operator reading it as text would refuse to compare it as a number or test it as a point.
644
+ */
645
+ get resultBaseType() {
646
+ return this.#fieldBaseType;
647
+ }
634
648
  /**
635
649
  * Every failure here is NULL rather than a thrown error. `qti-is-null` over a
636
650
  * `qti-field-value` is the specified way to ask whether a record carries a
@@ -638,6 +652,7 @@ var QtiFieldValue = class extends QtiExpression {
638
652
  * aborted the whole response processing run instead.
639
653
  */
640
654
  getResult() {
655
+ this.#fieldBaseType = void 0;
641
656
  const fieldIdentifier = this.getAttribute("field-identifier");
642
657
  if (!fieldIdentifier) {
643
658
  console.error("qti-field-value requires a field-identifier attribute");
@@ -648,12 +663,18 @@ var QtiFieldValue = class extends QtiExpression {
648
663
  return null;
649
664
  }
650
665
  const variable = this.getVariables()[0];
651
- if (!variable || variable.baseType !== "record" || variable.value === null || variable.value === void 0) {
666
+ const isRecord = variable?.cardinality === "record" || variable?.baseType === "record";
667
+ if (isRecord && (variable.value === null || variable.value === void 0))
668
+ return null;
669
+ if (!variable || !isRecord || !isRecordValue(variable.value)) {
652
670
  console.warn("qti-field-value child expression must return a record");
653
671
  return null;
654
672
  }
655
673
  const fieldValue = variable.value[fieldIdentifier];
656
- return fieldValue === void 0 ? null : fieldValue;
674
+ if (fieldValue === void 0 || fieldValue === null)
675
+ return null;
676
+ this.#fieldBaseType = variable.fieldBaseTypes?.[fieldIdentifier] ?? inferRecordFieldBaseType(Array.isArray(fieldValue) ? fieldValue[0] : fieldValue);
677
+ return fieldValue;
657
678
  }
658
679
  };
659
680
 
@@ -755,6 +776,9 @@ var QtiGcd = class extends QtiExpression {
755
776
  }
756
777
  };
757
778
 
779
+ // ../qti-processing/dist/is-null-value.js
780
+ var isNullValue = (value) => value === null || value === void 0 || value === "";
781
+
758
782
  // ../qti-processing/dist/components/qti-gt/qti-gt.js
759
783
  var QtiGt = class extends QtiExpression {
760
784
  getResult() {
@@ -762,6 +786,9 @@ var QtiGt = class extends QtiExpression {
762
786
  const values = this.getVariables();
763
787
  const value1 = values[0];
764
788
  const value2 = values[1];
789
+ if (isNullValue(value1?.value) || isNullValue(value2?.value)) {
790
+ return null;
791
+ }
765
792
  if ((value1.baseType === "integer" || value1.baseType === "float") && (value2.baseType === "integer" || value2.baseType === "float")) {
766
793
  return +value1.value > +value2.value;
767
794
  } else {
@@ -780,6 +807,9 @@ var QtiGte = class extends QtiConditionExpression {
780
807
  const values = this.getVariables();
781
808
  const value1 = values[0];
782
809
  const value2 = values[1];
810
+ if (isNullValue(value1?.value) || isNullValue(value2?.value)) {
811
+ return null;
812
+ }
783
813
  if ((value1.baseType === "integer" || value1.baseType === "float") && (value2.baseType === "integer" || value2.baseType === "float")) {
784
814
  return +value1.value >= +value2.value;
785
815
  } else {
@@ -1257,6 +1287,9 @@ var QtiLt = class extends QtiExpression {
1257
1287
  const values = this.getVariables();
1258
1288
  const value1 = values[0];
1259
1289
  const value2 = values[1];
1290
+ if (isNullValue(value1?.value) || isNullValue(value2?.value)) {
1291
+ return null;
1292
+ }
1260
1293
  if ((value1.baseType === "integer" || value1.baseType === "float") && (value2.baseType === "integer" || value2.baseType === "float")) {
1261
1294
  return +value1.value < +value2.value;
1262
1295
  } else {
@@ -1275,6 +1308,9 @@ var QtiLte = class extends QtiConditionExpression {
1275
1308
  const values = this.getVariables();
1276
1309
  const value1 = values[0];
1277
1310
  const value2 = values[1];
1311
+ if (isNullValue(value1?.value) || isNullValue(value2?.value)) {
1312
+ return null;
1313
+ }
1278
1314
  if ((value1.baseType === "integer" || value1.baseType === "float") && (value2.baseType === "integer" || value2.baseType === "float")) {
1279
1315
  return +value1.value <= +value2.value;
1280
1316
  } else {
@@ -3344,4 +3380,4 @@ export {
3344
3380
  QtiVariable,
3345
3381
  qtiProcessingElements
3346
3382
  };
3347
- //# sourceMappingURL=chunk-R7ZCUQU2.js.map
3383
+ //# sourceMappingURL=chunk-LCGPLQLE.js.map