@longsightgroup/qti3-core 0.9.10 → 0.10.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 (50) hide show
  1. package/dist/attempt-state.d.ts.map +1 -1
  2. package/dist/attempt-state.js +8 -2
  3. package/dist/attempt-state.js.map +1 -1
  4. package/dist/delivery-redaction.d.ts +0 -1
  5. package/dist/delivery-redaction.d.ts.map +1 -1
  6. package/dist/delivery-redaction.js +0 -10
  7. package/dist/delivery-redaction.js.map +1 -1
  8. package/dist/delivery-security.d.ts.map +1 -1
  9. package/dist/delivery-security.js +2 -1
  10. package/dist/delivery-security.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/parser-declarations.d.ts.map +1 -1
  16. package/dist/parser-declarations.js +2 -2
  17. package/dist/parser-declarations.js.map +1 -1
  18. package/dist/parser-item-metadata.d.ts.map +1 -1
  19. package/dist/parser-item-metadata.js +2 -1
  20. package/dist/parser-item-metadata.js.map +1 -1
  21. package/dist/parser-processing.js +4 -4
  22. package/dist/parser-processing.js.map +1 -1
  23. package/dist/parser-values.d.ts.map +1 -1
  24. package/dist/parser-values.js +9 -6
  25. package/dist/parser-values.js.map +1 -1
  26. package/dist/response-validation-policy.d.ts.map +1 -1
  27. package/dist/response-validation-policy.js +2 -1
  28. package/dist/response-validation-policy.js.map +1 -1
  29. package/dist/validation-primitives.d.ts.map +1 -1
  30. package/dist/validation-primitives.js +2 -1
  31. package/dist/validation-primitives.js.map +1 -1
  32. package/dist/validation-processing.d.ts.map +1 -1
  33. package/dist/validation-processing.js +2 -2
  34. package/dist/validation-processing.js.map +1 -1
  35. package/dist/validation.d.ts.map +1 -1
  36. package/dist/validation.js +18 -6
  37. package/dist/validation.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/attempt-state.ts +6 -2
  40. package/src/delivery-redaction.ts +0 -8
  41. package/src/delivery-security.ts +1 -1
  42. package/src/index.ts +1 -1
  43. package/src/parser-declarations.ts +2 -1
  44. package/src/parser-item-metadata.ts +2 -1
  45. package/src/parser-processing.ts +4 -4
  46. package/src/parser-values.ts +7 -4
  47. package/src/response-validation-policy.ts +2 -1
  48. package/src/validation-primitives.ts +2 -1
  49. package/src/validation-processing.ts +7 -2
  50. package/src/validation.ts +22 -6
package/src/validation.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  } from "./validation-geometry.js";
24
24
  import {
25
25
  isBaseType,
26
+ isBooleanAttribute,
26
27
  isCardinality,
27
28
  isFiniteNumber,
28
29
  isInteger,
@@ -82,7 +83,7 @@ function validateAssessmentItemRoot(item: QtiAssessmentItem, diagnostics: QtiDia
82
83
  path: item.source?.path,
83
84
  source: item.source,
84
85
  });
85
- } else if (!isXmlBoolean(timeDependent)) {
86
+ } else if (!isBooleanAttribute(timeDependent)) {
86
87
  diagnostics.push({
87
88
  code: "assessmentItem.timeDependent.boolean",
88
89
  severity: "error",
@@ -93,10 +94,6 @@ function validateAssessmentItemRoot(item: QtiAssessmentItem, diagnostics: QtiDia
93
94
  }
94
95
  }
95
96
 
96
- function isXmlBoolean(value: string): boolean {
97
- return value === "true" || value === "false" || value === "1" || value === "0";
98
- }
99
-
100
97
  function validateItemBody(item: QtiAssessmentItem, diagnostics: QtiDiagnostic[]): void {
101
98
  if (item.itemBodySource) return;
102
99
  diagnostics.push({
@@ -219,7 +216,7 @@ function isValidDeclarationBaseValue(value: string, baseType: QtiBaseType): bool
219
216
  case "float":
220
217
  return isFiniteNumber(value);
221
218
  case "boolean":
222
- return value === "true" || value === "false";
219
+ return isBooleanAttribute(value);
223
220
  case "point":
224
221
  return isPoint(value);
225
222
  case "pair":
@@ -669,6 +666,19 @@ function validateCatalogCard(
669
666
  });
670
667
  }
671
668
 
669
+ if (isCatalogCardEntry(card)) {
670
+ const defaultAttribute = card.attributes.default;
671
+ if (defaultAttribute !== undefined && !isBooleanAttribute(defaultAttribute)) {
672
+ diagnostics.push({
673
+ code: "catalog.cardEntry.default.boolean",
674
+ severity: "error",
675
+ message: `qti-card-entry default must be an XML boolean, found ${defaultAttribute}.`,
676
+ path: card.source?.path,
677
+ source: card.source,
678
+ });
679
+ }
680
+ }
681
+
672
682
  const defaultEntries = entries.filter((entry) => entry.default);
673
683
  if (defaultEntries.length > 1) {
674
684
  diagnostics.push({
@@ -698,6 +708,12 @@ function validateCatalogCard(
698
708
  }
699
709
  }
700
710
 
711
+ function isCatalogCardEntry(
712
+ card: QtiCatalogCard | QtiCatalogCardEntry,
713
+ ): card is QtiCatalogCardEntry {
714
+ return !("entries" in card);
715
+ }
716
+
701
717
  function validateCatalogHtmlContent(nodes: QtiContentNode[], diagnostics: QtiDiagnostic[]): void {
702
718
  for (const node of nodes) {
703
719
  if (node.kind === "element") {