@longsightgroup/qti3-core 0.7.3 → 0.8.1
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.
- package/README.md +41 -10
- package/dist/content-text.d.ts +7 -1
- package/dist/content-text.d.ts.map +1 -1
- package/dist/content-text.js +14 -0
- package/dist/content-text.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/package-xml.d.ts +12 -0
- package/dist/package-xml.d.ts.map +1 -0
- package/dist/package-xml.js +17 -0
- package/dist/package-xml.js.map +1 -0
- package/dist/parser-custom-interactions.d.ts +8 -0
- package/dist/parser-custom-interactions.d.ts.map +1 -0
- package/dist/parser-custom-interactions.js +178 -0
- package/dist/parser-custom-interactions.js.map +1 -0
- package/dist/parser-declarations.d.ts +6 -0
- package/dist/parser-declarations.d.ts.map +1 -0
- package/dist/parser-declarations.js +136 -0
- package/dist/parser-declarations.js.map +1 -0
- package/dist/parser-item-metadata.d.ts +9 -0
- package/dist/parser-item-metadata.d.ts.map +1 -0
- package/dist/parser-item-metadata.js +158 -0
- package/dist/parser-item-metadata.js.map +1 -0
- package/dist/parser-processing.d.ts +5 -0
- package/dist/parser-processing.d.ts.map +1 -0
- package/dist/parser-processing.js +642 -0
- package/dist/parser-processing.js.map +1 -0
- package/dist/parser-values.d.ts +8 -0
- package/dist/parser-values.d.ts.map +1 -0
- package/dist/parser-values.js +49 -0
- package/dist/parser-values.js.map +1 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +15 -1083
- package/dist/parser.js.map +1 -1
- package/dist/processing-expression-tags.d.ts +56 -0
- package/dist/processing-expression-tags.d.ts.map +1 -0
- package/dist/processing-expression-tags.js +52 -0
- package/dist/processing-expression-tags.js.map +1 -0
- package/dist/processing-rules.d.ts +3 -0
- package/dist/processing-rules.d.ts.map +1 -0
- package/dist/processing-rules.js +10 -0
- package/dist/processing-rules.js.map +1 -0
- package/dist/serializer-processing-expressions.d.ts +8 -0
- package/dist/serializer-processing-expressions.d.ts.map +1 -0
- package/dist/serializer-processing-expressions.js +198 -0
- package/dist/serializer-processing-expressions.js.map +1 -0
- package/dist/serializer-processing-xml.d.ts +15 -0
- package/dist/serializer-processing-xml.d.ts.map +1 -0
- package/dist/serializer-processing-xml.js +46 -0
- package/dist/serializer-processing-xml.js.map +1 -0
- package/dist/serializer-processing.d.ts +8 -0
- package/dist/serializer-processing.d.ts.map +1 -0
- package/dist/serializer-processing.js +106 -0
- package/dist/serializer-processing.js.map +1 -0
- package/dist/shared-vocabulary-authoring.d.ts +52 -0
- package/dist/shared-vocabulary-authoring.d.ts.map +1 -0
- package/dist/shared-vocabulary-authoring.js +327 -0
- package/dist/shared-vocabulary-authoring.js.map +1 -0
- package/dist/shared-vocabulary-interaction-sets.d.ts +6 -0
- package/dist/shared-vocabulary-interaction-sets.d.ts.map +1 -0
- package/dist/shared-vocabulary-interaction-sets.js +23 -0
- package/dist/shared-vocabulary-interaction-sets.js.map +1 -0
- package/dist/shared-vocabulary-interaction-validation.d.ts +3 -0
- package/dist/shared-vocabulary-interaction-validation.d.ts.map +1 -0
- package/dist/shared-vocabulary-interaction-validation.js +99 -0
- package/dist/shared-vocabulary-interaction-validation.js.map +1 -0
- package/dist/shared-vocabulary-registry-validation.d.ts +5 -0
- package/dist/shared-vocabulary-registry-validation.d.ts.map +1 -0
- package/dist/shared-vocabulary-registry-validation.js +147 -0
- package/dist/shared-vocabulary-registry-validation.js.map +1 -0
- package/dist/shared-vocabulary-support.d.ts.map +1 -1
- package/dist/shared-vocabulary-support.js +160 -67
- package/dist/shared-vocabulary-support.js.map +1 -1
- package/dist/shared-vocabulary.d.ts +6 -0
- package/dist/shared-vocabulary.d.ts.map +1 -1
- package/dist/shared-vocabulary.js +12 -0
- package/dist/shared-vocabulary.js.map +1 -1
- package/dist/support.d.ts +4 -1
- package/dist/support.d.ts.map +1 -1
- package/dist/support.js +130 -0
- package/dist/support.js.map +1 -1
- package/dist/types.d.ts +32 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +29 -250
- package/dist/validation.js.map +1 -1
- package/dist/xml.d.ts +10 -0
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +321 -272
- package/dist/xml.js.map +1 -1
- package/package.json +1 -4
- package/src/content-text.ts +20 -1
- package/src/index.ts +68 -0
- package/src/interaction-test-fixtures.ts +44 -0
- package/src/package-xml.ts +30 -0
- package/src/parser-custom-interactions.ts +309 -0
- package/src/parser-declarations.ts +174 -0
- package/src/parser-item-metadata.ts +194 -0
- package/src/parser-processing.ts +701 -0
- package/src/parser-values.ts +61 -0
- package/src/parser.ts +36 -1227
- package/src/processing-expression-tags.ts +65 -0
- package/src/processing-rules.ts +11 -0
- package/src/serializer-processing-expressions.ts +456 -0
- package/src/serializer-processing-xml.ts +67 -0
- package/src/serializer-processing.fixtures.ts +469 -0
- package/src/serializer-processing.ts +196 -0
- package/src/shared-vocabulary-authoring.ts +438 -0
- package/src/shared-vocabulary-interaction-sets.ts +28 -0
- package/src/shared-vocabulary-interaction-validation.ts +143 -0
- package/src/shared-vocabulary-registry-validation.ts +210 -0
- package/src/shared-vocabulary-support.ts +200 -127
- package/src/shared-vocabulary.ts +18 -0
- package/src/support.ts +144 -0
- package/src/types.ts +42 -7
- package/src/validation.ts +33 -341
- package/src/xml.ts +376 -276
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
QtiCardinality,
|
|
3
|
+
QtiRecordValue,
|
|
4
|
+
QtiResponseDeclaration,
|
|
5
|
+
QtiScalarValue,
|
|
6
|
+
QtiValue,
|
|
7
|
+
} from "./types.js";
|
|
8
|
+
|
|
9
|
+
export function coerceValue(value: string, baseType: string | undefined): QtiScalarValue {
|
|
10
|
+
if (baseType === "integer") return Number.parseInt(value, 10);
|
|
11
|
+
if (baseType === "float") return Number.parseFloat(value);
|
|
12
|
+
if (baseType === "boolean") {
|
|
13
|
+
if (value === "true") return true;
|
|
14
|
+
if (value === "false") return false;
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function parseCardinality(value: string | undefined): QtiCardinality {
|
|
20
|
+
if (value === "multiple" || value === "ordered" || value === "record") return value;
|
|
21
|
+
return "single";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function parseXmlBoolean(value: string | undefined): boolean | undefined {
|
|
25
|
+
if (value === "true" || value === "1") return true;
|
|
26
|
+
if (value === "false" || value === "0") return false;
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function normalizeValueForCardinality(
|
|
31
|
+
value: QtiValue,
|
|
32
|
+
cardinality: QtiCardinality,
|
|
33
|
+
): QtiValue {
|
|
34
|
+
if (
|
|
35
|
+
(cardinality === "multiple" || cardinality === "ordered") &&
|
|
36
|
+
value !== null &&
|
|
37
|
+
!Array.isArray(value) &&
|
|
38
|
+
!isRecordValue(value)
|
|
39
|
+
) {
|
|
40
|
+
return [value];
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function parseShape(
|
|
46
|
+
shape: string | undefined,
|
|
47
|
+
): NonNullable<QtiResponseDeclaration["areaMapping"]>["entries"][number]["shape"] {
|
|
48
|
+
if (shape === "circle" || shape === "rect" || shape === "poly") return shape;
|
|
49
|
+
return "default";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function parseCoords(value: string | undefined): number[] {
|
|
53
|
+
return (value ?? "")
|
|
54
|
+
.split(",")
|
|
55
|
+
.map((part) => Number(part.trim()))
|
|
56
|
+
.filter((part) => Number.isFinite(part));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isRecordValue(value: QtiValue): value is QtiRecordValue {
|
|
60
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61
|
+
}
|