@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,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describeSharedVocabularyPrecedence,
|
|
3
|
+
formatSharedVocabularyClassValueRange,
|
|
4
|
+
matchedSharedVocabularyClassNames,
|
|
5
|
+
parseClassValue,
|
|
6
|
+
parseSharedVocabularyAttributes,
|
|
7
|
+
sharedVocabularyFieldById,
|
|
8
|
+
sharedVocabularyFieldsForInteraction,
|
|
9
|
+
sharedVocabularyFixedClassName,
|
|
10
|
+
type QtiSharedVocabularyField,
|
|
11
|
+
} from "./shared-vocabulary-authoring.js";
|
|
12
|
+
import type { QtiDiagnostic, QtiInteraction } from "./types.js";
|
|
13
|
+
|
|
14
|
+
const LEGACY_CLASS_VALUE_CONFLICT_CODES: Record<string, string> = {
|
|
15
|
+
"labels-style": "interaction.sharedVocabulary.labelsConflict",
|
|
16
|
+
"labels-suffix": "interaction.sharedVocabulary.labelSuffixConflict",
|
|
17
|
+
orientation: "interaction.sharedVocabulary.orientationConflict",
|
|
18
|
+
"choices-stacking": "interaction.sharedVocabulary.stackingConflict",
|
|
19
|
+
"choices-position": "interaction.sharedVocabulary.orderChoicesPositionConflict",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const LEGACY_CLASS_VALUE_INVALID_CODES: Record<string, string> = {
|
|
23
|
+
"choices-stacking": "interaction.sharedVocabulary.stackingInvalid",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function validateRegistrySharedVocabularyClasses(
|
|
27
|
+
interaction: QtiInteraction,
|
|
28
|
+
classNames: string[],
|
|
29
|
+
diagnostics: QtiDiagnostic[],
|
|
30
|
+
): void {
|
|
31
|
+
for (const field of sharedVocabularyFieldsForInteraction(interaction.type)) {
|
|
32
|
+
if (field.kind !== "class-value") continue;
|
|
33
|
+
validateClassValueFieldConflicts(interaction, field, classNames, diagnostics);
|
|
34
|
+
validateUnsupportedClassValueClasses(interaction, field, classNames, diagnostics);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function validateClassValueFieldConflicts(
|
|
39
|
+
interaction: QtiInteraction,
|
|
40
|
+
field: Extract<QtiSharedVocabularyField, { kind: "class-value" }>,
|
|
41
|
+
classNames: string[],
|
|
42
|
+
diagnostics: QtiDiagnostic[],
|
|
43
|
+
): void {
|
|
44
|
+
const matched = matchedSharedVocabularyClassNames(field, classNames);
|
|
45
|
+
if (new Set(matched).size <= 1) return;
|
|
46
|
+
|
|
47
|
+
diagnostics.push({
|
|
48
|
+
code: classValueConflictCode(field.id),
|
|
49
|
+
severity: "warning",
|
|
50
|
+
message: conflictMessage(interaction, field, matched),
|
|
51
|
+
path: interaction.source?.path,
|
|
52
|
+
source: interaction.source,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function classValueConflictCode(fieldId: string): string {
|
|
57
|
+
return (
|
|
58
|
+
LEGACY_CLASS_VALUE_CONFLICT_CODES[fieldId] ??
|
|
59
|
+
`interaction.sharedVocabulary.${fieldIdToDiagnosticSuffix(fieldId)}Conflict`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function classValueInvalidCode(fieldId: string): string {
|
|
64
|
+
return (
|
|
65
|
+
LEGACY_CLASS_VALUE_INVALID_CODES[fieldId] ??
|
|
66
|
+
`interaction.sharedVocabulary.${fieldIdToDiagnosticSuffix(fieldId)}Invalid`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function fieldIdToDiagnosticSuffix(fieldId: string): string {
|
|
71
|
+
return fieldId.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function conflictMessage(
|
|
75
|
+
interaction: QtiInteraction,
|
|
76
|
+
field: Extract<QtiSharedVocabularyField, { kind: "class-value" }>,
|
|
77
|
+
matchedClassNames: string[],
|
|
78
|
+
): string {
|
|
79
|
+
const uniqueMatched = [...new Set(matchedClassNames)];
|
|
80
|
+
const precedence = describeSharedVocabularyPrecedence(field, uniqueMatched);
|
|
81
|
+
|
|
82
|
+
switch (field.id) {
|
|
83
|
+
case "labels-style":
|
|
84
|
+
return `${interaction.qtiName} should not include multiple qti-labels-* style classes: ${uniqueMatched.join(", ")}. ${precedence} at runtime.`;
|
|
85
|
+
case "labels-suffix":
|
|
86
|
+
return `${interaction.qtiName} should not include multiple qti-labels-suffix-* classes: ${uniqueMatched.join(", ")}. ${precedence} at runtime.`;
|
|
87
|
+
case "orientation":
|
|
88
|
+
return `${interaction.qtiName} should not include both qti-orientation-horizontal and qti-orientation-vertical; ${precedence} at runtime.`;
|
|
89
|
+
case "choices-stacking":
|
|
90
|
+
return `qti-choice-interaction should not include multiple qti-choices-stacking-* classes: ${uniqueMatched.join(", ")}. The first valid stacking class in class attribute order takes precedence at runtime.`;
|
|
91
|
+
case "choices-position":
|
|
92
|
+
return `${interaction.qtiName} should not include multiple qti-choices-* position classes: ${uniqueMatched.join(", ")}. The first position class in class attribute order takes precedence at runtime.`;
|
|
93
|
+
default:
|
|
94
|
+
return `${interaction.qtiName} should not include multiple ${field.classPrefix}* classes: ${uniqueMatched.join(", ")}. ${precedence} at runtime.`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function validateUnsupportedClassValueClasses(
|
|
99
|
+
interaction: QtiInteraction,
|
|
100
|
+
field: Extract<QtiSharedVocabularyField, { kind: "class-value" }>,
|
|
101
|
+
classNames: string[],
|
|
102
|
+
diagnostics: QtiDiagnostic[],
|
|
103
|
+
): void {
|
|
104
|
+
for (const className of classNames) {
|
|
105
|
+
if (!className.startsWith(field.classPrefix)) continue;
|
|
106
|
+
if (parseClassValue(field, className) !== undefined) continue;
|
|
107
|
+
diagnostics.push({
|
|
108
|
+
code: classValueInvalidCode(field.id),
|
|
109
|
+
severity: "warning",
|
|
110
|
+
message: unsupportedClassValueMessage(interaction, field, className),
|
|
111
|
+
path: interaction.source?.path,
|
|
112
|
+
source: interaction.source,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function unsupportedClassValueMessage(
|
|
118
|
+
interaction: QtiInteraction,
|
|
119
|
+
field: Extract<QtiSharedVocabularyField, { kind: "class-value" }>,
|
|
120
|
+
className: string,
|
|
121
|
+
): string {
|
|
122
|
+
if (field.id === "choices-stacking") {
|
|
123
|
+
return `qti-choice-interaction shared vocabulary class ${className} is not supported; expected ${formatSharedVocabularyClassValueRange(field)}.`;
|
|
124
|
+
}
|
|
125
|
+
return `${interaction.qtiName} shared vocabulary class ${className} is not supported; expected ${formatSharedVocabularyClassValueRange(field)}.`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function validateChoicesContainerWidthSharedVocabulary(
|
|
129
|
+
interaction: QtiInteraction,
|
|
130
|
+
diagnostics: QtiDiagnostic[],
|
|
131
|
+
): void {
|
|
132
|
+
const width = interaction.attributes["data-choices-container-width"];
|
|
133
|
+
if (width === undefined) return;
|
|
134
|
+
const parsed = parseSharedVocabularyAttributes(
|
|
135
|
+
{ "data-choices-container-width": width },
|
|
136
|
+
interaction.type,
|
|
137
|
+
)["choices-container-width"];
|
|
138
|
+
if (parsed !== undefined) return;
|
|
139
|
+
diagnostics.push({
|
|
140
|
+
code: "interaction.sharedVocabulary.orderChoicesContainerWidth",
|
|
141
|
+
severity: "warning",
|
|
142
|
+
message: `${interaction.qtiName} data-choices-container-width must be a positive pixel value; the invalid value is ignored at runtime.`,
|
|
143
|
+
path: interaction.source?.path,
|
|
144
|
+
source: interaction.source,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function validateMatchInteractionSharedVocabulary(
|
|
149
|
+
interaction: QtiInteraction,
|
|
150
|
+
classNames: string[],
|
|
151
|
+
diagnostics: QtiDiagnostic[],
|
|
152
|
+
): void {
|
|
153
|
+
const matchTabularClass = sharedVocabularyFixedClassName("match-tabular");
|
|
154
|
+
const headerHiddenClass = sharedVocabularyFixedClassName("header-hidden");
|
|
155
|
+
const hasTabular =
|
|
156
|
+
matchTabularClass === undefined ? false : classNames.includes(matchTabularClass);
|
|
157
|
+
const hasHeaderHidden =
|
|
158
|
+
headerHiddenClass === undefined ? false : classNames.includes(headerHiddenClass);
|
|
159
|
+
const firstColumnHeader = interaction.attributes["data-first-column-header"];
|
|
160
|
+
if (!hasTabular && (hasHeaderHidden || firstColumnHeader !== undefined)) {
|
|
161
|
+
diagnostics.push({
|
|
162
|
+
code: "interaction.sharedVocabulary.matchTabularContext",
|
|
163
|
+
severity: "warning",
|
|
164
|
+
message:
|
|
165
|
+
"qti-match-interaction shared vocabulary class qti-header-hidden and data-first-column-header are only relevant when qti-match-tabular is specified; they are ignored at runtime.",
|
|
166
|
+
path: interaction.source?.path,
|
|
167
|
+
source: interaction.source,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (hasTabular && hasHeaderHidden && firstColumnHeader !== undefined) {
|
|
171
|
+
diagnostics.push({
|
|
172
|
+
code: "interaction.sharedVocabulary.matchTabularHeaderHidden",
|
|
173
|
+
severity: "warning",
|
|
174
|
+
message:
|
|
175
|
+
"qti-match-interaction data-first-column-header is ignored when qti-header-hidden suppresses the tabular header row.",
|
|
176
|
+
path: interaction.source?.path,
|
|
177
|
+
source: interaction.source,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (!hasTabular) return;
|
|
181
|
+
|
|
182
|
+
const choicesPositionField = sharedVocabularyFieldById("choices-position");
|
|
183
|
+
const choicesPositionClasses =
|
|
184
|
+
choicesPositionField?.kind === "class-value"
|
|
185
|
+
? matchedSharedVocabularyClassNames(choicesPositionField, classNames)
|
|
186
|
+
: [];
|
|
187
|
+
if (
|
|
188
|
+
choicesPositionClasses.length > 0 ||
|
|
189
|
+
interaction.attributes["data-choices-container-width"] !== undefined
|
|
190
|
+
) {
|
|
191
|
+
diagnostics.push({
|
|
192
|
+
code: "interaction.sharedVocabulary.matchTabularChoicesConflict",
|
|
193
|
+
severity: "warning",
|
|
194
|
+
message:
|
|
195
|
+
"qti-match-interaction qti-match-tabular uses a matrix layout; qti-choices-* position classes and data-choices-container-width are ignored at runtime.",
|
|
196
|
+
path: interaction.source?.path,
|
|
197
|
+
source: interaction.source,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (!hasHeaderHidden && (firstColumnHeader === undefined || firstColumnHeader === "")) {
|
|
201
|
+
diagnostics.push({
|
|
202
|
+
code: "interaction.sharedVocabulary.matchTabularFirstColumnHeader",
|
|
203
|
+
severity: "warning",
|
|
204
|
+
message:
|
|
205
|
+
"qti-match-interaction with qti-match-tabular should specify data-first-column-header for the top-left table header when the tabular header row is shown.",
|
|
206
|
+
path: interaction.source?.path,
|
|
207
|
+
source: interaction.source,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
SHARED_VOCABULARY_CHOICE_WRITING_ORIENTATIONS,
|
|
3
2
|
SHARED_VOCABULARY_CONTENT_ALIGNMENTS,
|
|
4
3
|
SHARED_VOCABULARY_CONTENT_FLOAT_SUFFIXES,
|
|
5
4
|
SHARED_VOCABULARY_CONTENT_LIST_STYLE_TYPES,
|
|
@@ -9,11 +8,17 @@ import {
|
|
|
9
8
|
SHARED_VOCABULARY_LAYOUT_COLUMN_SPAN_COUNT,
|
|
10
9
|
SHARED_VOCABULARY_LAYOUT_OFFSET_COUNT,
|
|
11
10
|
} from "./shared-vocabulary-generated-families.js";
|
|
11
|
+
import {
|
|
12
|
+
sharedVocabularyFixedClassName,
|
|
13
|
+
sharedVocabularyInteractionFields,
|
|
14
|
+
type QtiSharedVocabularyField,
|
|
15
|
+
} from "./shared-vocabulary-authoring.js";
|
|
12
16
|
import {
|
|
13
17
|
SHARED_VOCABULARY_EXTENDED_TEXT_COUNTER_CLASSES,
|
|
14
18
|
SHARED_VOCABULARY_EXTENDED_TEXT_HEIGHT_LINES,
|
|
15
19
|
SHARED_VOCABULARY_INPUT_WIDTHS,
|
|
16
20
|
} from "./shared-vocabulary.js";
|
|
21
|
+
import { SHARED_VOCABULARY_CHOICE_AND_ORDER_INTERACTIONS } from "./shared-vocabulary-interaction-sets.js";
|
|
17
22
|
import type { QtiInteractionType, SharedVocabularyClassSupport } from "./types.js";
|
|
18
23
|
|
|
19
24
|
const sharedVocabularyFixture = [
|
|
@@ -34,7 +39,10 @@ const sharedVocabularyUnitTests = [
|
|
|
34
39
|
const sharedVocabularyValidationTests = [
|
|
35
40
|
"packages/core/src/core.test.ts",
|
|
36
41
|
"packages/core/src/shared-vocabulary-validation.test.ts",
|
|
42
|
+
"packages/core/src/shared-vocabulary-registry-validation.test.ts",
|
|
43
|
+
"packages/core/src/shared-vocabulary-interaction-validation.test.ts",
|
|
37
44
|
];
|
|
45
|
+
const choiceLayoutTests = ["packages/player/src/interactions/choice-layout.test.ts"];
|
|
38
46
|
const browserBehaviorTests = [
|
|
39
47
|
"tests/browser/player-dom-behavior.spec.ts",
|
|
40
48
|
...sharedVocabularyMatrixTests,
|
|
@@ -53,19 +61,179 @@ const interactionInputWidthFixtures = [
|
|
|
53
61
|
const orderMinMaxMessagesFixture =
|
|
54
62
|
"packages/fixtures/packages/sv-matrix/items/order-min-max-messages.xml";
|
|
55
63
|
|
|
56
|
-
const choiceAndOrder
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const choiceAndOrder = SHARED_VOCABULARY_CHOICE_AND_ORDER_INTERACTIONS;
|
|
65
|
+
|
|
66
|
+
function registryClassValueSupportProfile(fieldId: string): {
|
|
67
|
+
level: "full" | "stylesheet";
|
|
68
|
+
tests: string[];
|
|
69
|
+
} {
|
|
70
|
+
switch (fieldId) {
|
|
71
|
+
case "labels-style":
|
|
72
|
+
case "labels-suffix":
|
|
73
|
+
return { level: "full", tests: [...sharedVocabularyUnitTests, ...browserBehaviorTests] };
|
|
74
|
+
case "orientation":
|
|
75
|
+
return {
|
|
76
|
+
level: "full",
|
|
77
|
+
tests: [...choiceLayoutTests, ...sharedVocabularyUnitTests, ...browserBehaviorTests],
|
|
78
|
+
};
|
|
79
|
+
case "choices-stacking":
|
|
80
|
+
return {
|
|
81
|
+
level: "full",
|
|
82
|
+
tests: [...choiceLayoutTests, "packages/core/src/core.test.ts", ...browserBehaviorTests],
|
|
83
|
+
};
|
|
84
|
+
case "choices-position":
|
|
85
|
+
return {
|
|
86
|
+
level: "full",
|
|
87
|
+
tests: [...sharedVocabularyUnitTests, ...browserBehaviorTests, ...graphicBrowserTests],
|
|
88
|
+
};
|
|
89
|
+
case "selections-tone":
|
|
90
|
+
return { level: "stylesheet", tests: [...browserBehaviorTests, ...graphicBrowserTests] };
|
|
91
|
+
case "writing-orientation":
|
|
92
|
+
return { level: "stylesheet", tests: [...browserBehaviorTests] };
|
|
93
|
+
default:
|
|
94
|
+
return { level: "full", tests: [...sharedVocabularyUnitTests, ...browserBehaviorTests] };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function registryClassValueSupportEntries(): SharedVocabularyClassSupport[] {
|
|
99
|
+
return sharedVocabularyInteractionFields.flatMap((field) => {
|
|
100
|
+
if (field.kind !== "class-value") return [];
|
|
101
|
+
const profile = registryClassValueSupportProfile(field.id);
|
|
102
|
+
const createEntry =
|
|
103
|
+
profile.level === "stylesheet" ? interactionStylesheetEntry : interactionFullEntry;
|
|
104
|
+
return field.values.map((value) =>
|
|
105
|
+
createEntry(`${field.classPrefix}${String(value)}`, field.interactions, profile.tests),
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function registryClassFixedSupportProfile(fieldId: string): {
|
|
111
|
+
level: "full" | "stylesheet";
|
|
112
|
+
tests: string[];
|
|
113
|
+
} {
|
|
114
|
+
switch (fieldId) {
|
|
115
|
+
case "input-control-hidden":
|
|
116
|
+
return {
|
|
117
|
+
level: "stylesheet",
|
|
118
|
+
tests: [...browserBehaviorTests, "tests/browser/player-keyboard-a11y.spec.ts"],
|
|
119
|
+
};
|
|
120
|
+
case "unselected-hidden":
|
|
121
|
+
return { level: "stylesheet", tests: [...browserBehaviorTests, ...graphicBrowserTests] };
|
|
122
|
+
case "match-tabular":
|
|
123
|
+
return {
|
|
124
|
+
level: "full",
|
|
125
|
+
tests: [
|
|
126
|
+
"packages/core/src/core.test.ts",
|
|
127
|
+
...browserBehaviorTests,
|
|
128
|
+
"tests/browser/player-keyboard-a11y.spec.ts",
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
case "gap-placement":
|
|
132
|
+
return {
|
|
133
|
+
level: "full",
|
|
134
|
+
tests: [
|
|
135
|
+
...sharedVocabularyUnitTests,
|
|
136
|
+
"packages/core/src/core.test.ts",
|
|
137
|
+
...browserBehaviorTests,
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
default:
|
|
141
|
+
return { level: "full", tests: [...browserBehaviorTests] };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const registryClassFixedSupportIds = [
|
|
146
|
+
"input-control-hidden",
|
|
147
|
+
"unselected-hidden",
|
|
148
|
+
"match-tabular",
|
|
149
|
+
"gap-placement",
|
|
150
|
+
] as const;
|
|
151
|
+
|
|
152
|
+
function registryClassFixedSupportEntries(): SharedVocabularyClassSupport[] {
|
|
153
|
+
return registryClassFixedSupportIds.flatMap((fieldId) => {
|
|
154
|
+
const field = sharedVocabularyInteractionFields.find(
|
|
155
|
+
(candidate): candidate is Extract<QtiSharedVocabularyField, { kind: "class-fixed" }> =>
|
|
156
|
+
candidate.kind === "class-fixed" && candidate.id === fieldId,
|
|
157
|
+
);
|
|
158
|
+
if (field === undefined) return [];
|
|
159
|
+
const profile = registryClassFixedSupportProfile(field.id);
|
|
160
|
+
const createEntry =
|
|
161
|
+
profile.level === "stylesheet" ? interactionStylesheetEntry : interactionFullEntry;
|
|
162
|
+
return [createEntry(field.className, field.interactions, profile.tests)];
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function registryAttributeSupportProfile(fieldId: string): {
|
|
167
|
+
fixtures: string[];
|
|
168
|
+
tests: string[];
|
|
169
|
+
notes?: string;
|
|
170
|
+
} {
|
|
171
|
+
switch (fieldId) {
|
|
172
|
+
case "choices-container-width":
|
|
173
|
+
return {
|
|
174
|
+
fixtures: sharedVocabularyFixture,
|
|
175
|
+
tests: [
|
|
176
|
+
"packages/core/src/core.test.ts",
|
|
177
|
+
"packages/player/src/interactions/shared-vocabulary.test.ts",
|
|
178
|
+
...browserBehaviorTests,
|
|
179
|
+
...graphicBrowserTests,
|
|
180
|
+
],
|
|
181
|
+
notes:
|
|
182
|
+
"Sets the authored choices-bank width for interactions that support qti-choices-* layout classes.",
|
|
183
|
+
};
|
|
184
|
+
case "first-column-header":
|
|
185
|
+
return {
|
|
186
|
+
fixtures: sharedVocabularyFixture,
|
|
187
|
+
tests: [
|
|
188
|
+
"packages/core/src/core.test.ts",
|
|
189
|
+
...browserBehaviorTests,
|
|
190
|
+
"tests/browser/player-keyboard-a11y.spec.ts",
|
|
191
|
+
],
|
|
192
|
+
notes: "Provides the top-left header text for qti-match-tabular table rendering.",
|
|
193
|
+
};
|
|
194
|
+
case "media-player-controls":
|
|
195
|
+
return {
|
|
196
|
+
fixtures: [mediaPlayerFixture],
|
|
197
|
+
tests: [...mediaBrowserTests, "packages/core/src/shared-vocabulary-validation.test.ts"],
|
|
198
|
+
notes:
|
|
199
|
+
"Supports tokens none, default, play, rewind, captions, and audioDescription on media interactions and rendered media assets.",
|
|
200
|
+
};
|
|
201
|
+
case "media-player-pause-delay":
|
|
202
|
+
return {
|
|
203
|
+
fixtures: [mediaPlayerFixture],
|
|
204
|
+
tests: mediaBrowserTests,
|
|
205
|
+
notes:
|
|
206
|
+
"Reflects authored pause-delay values on rendered media assets. Pause timer behavior is covered in tests/browser/player.spec.ts.",
|
|
207
|
+
};
|
|
208
|
+
case "media-player-pause-duration":
|
|
209
|
+
return {
|
|
210
|
+
fixtures: [mediaPlayerFixture],
|
|
211
|
+
tests: mediaBrowserTests,
|
|
212
|
+
notes:
|
|
213
|
+
"Reflects authored pause-duration values on rendered media assets. Pause timer behavior is covered in tests/browser/player.spec.ts.",
|
|
214
|
+
};
|
|
215
|
+
default:
|
|
216
|
+
return {
|
|
217
|
+
fixtures: sharedVocabularyFixture,
|
|
218
|
+
tests: [...sharedVocabularyUnitTests, ...browserBehaviorTests],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function registryAttributeSupportEntries(): SharedVocabularyClassSupport[] {
|
|
224
|
+
return sharedVocabularyInteractionFields.flatMap((field) => {
|
|
225
|
+
if (field.kind !== "attribute") return [];
|
|
226
|
+
const profile = registryAttributeSupportProfile(field.id);
|
|
227
|
+
return [
|
|
228
|
+
svEntry(field.attributeName, "interaction", "full", {
|
|
229
|
+
interactions: [...field.interactions],
|
|
230
|
+
fixtures: profile.fixtures,
|
|
231
|
+
tests: profile.tests,
|
|
232
|
+
...(profile.notes === undefined ? {} : { notes: profile.notes }),
|
|
233
|
+
}),
|
|
234
|
+
];
|
|
235
|
+
});
|
|
236
|
+
}
|
|
69
237
|
|
|
70
238
|
function svEntry(
|
|
71
239
|
className: string,
|
|
@@ -91,12 +259,12 @@ function contentStylesheetEntry(className: string, notes?: string): SharedVocabu
|
|
|
91
259
|
|
|
92
260
|
function interactionFullEntry(
|
|
93
261
|
className: string,
|
|
94
|
-
interactions: QtiInteractionType[],
|
|
262
|
+
interactions: readonly QtiInteractionType[],
|
|
95
263
|
tests: string[],
|
|
96
264
|
notes?: string,
|
|
97
265
|
): SharedVocabularyClassSupport {
|
|
98
266
|
return svEntry(className, "interaction", "full", {
|
|
99
|
-
interactions,
|
|
267
|
+
interactions: [...interactions],
|
|
100
268
|
fixtures: sharedVocabularyFixture,
|
|
101
269
|
tests,
|
|
102
270
|
notes,
|
|
@@ -105,31 +273,18 @@ function interactionFullEntry(
|
|
|
105
273
|
|
|
106
274
|
function interactionStylesheetEntry(
|
|
107
275
|
className: string,
|
|
108
|
-
interactions: QtiInteractionType[],
|
|
276
|
+
interactions: readonly QtiInteractionType[],
|
|
109
277
|
tests: string[],
|
|
110
278
|
notes?: string,
|
|
111
279
|
): SharedVocabularyClassSupport {
|
|
112
280
|
return svEntry(className, "interaction", "stylesheet", {
|
|
113
|
-
interactions,
|
|
281
|
+
interactions: [...interactions],
|
|
114
282
|
fixtures: sharedVocabularyFixture,
|
|
115
283
|
tests,
|
|
116
284
|
notes,
|
|
117
285
|
});
|
|
118
286
|
}
|
|
119
287
|
|
|
120
|
-
function mediaPlayerSvEntry(
|
|
121
|
-
className: string,
|
|
122
|
-
notes: string,
|
|
123
|
-
tests: string[] = mediaBrowserTests,
|
|
124
|
-
): SharedVocabularyClassSupport {
|
|
125
|
-
return svEntry(className, "interaction", "full", {
|
|
126
|
-
interactions: ["media"],
|
|
127
|
-
fixtures: [mediaPlayerFixture],
|
|
128
|
-
tests,
|
|
129
|
-
notes,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
288
|
export const sharedVocabularyClassSupport: SharedVocabularyClassSupport[] = [
|
|
134
289
|
contentStylesheetEntry(
|
|
135
290
|
"qti-layout-row",
|
|
@@ -187,69 +342,9 @@ export const sharedVocabularyClassSupport: SharedVocabularyClassSupport[] = [
|
|
|
187
342
|
contentStylesheetEntry("qti-italic"),
|
|
188
343
|
contentStylesheetEntry("qti-display-inline-block"),
|
|
189
344
|
|
|
190
|
-
...
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
...browserBehaviorTests,
|
|
194
|
-
]),
|
|
195
|
-
),
|
|
196
|
-
...["none", "period", "parenthesis"].map((suffix) =>
|
|
197
|
-
interactionFullEntry(`qti-labels-suffix-${suffix}`, choiceAndOrder, [
|
|
198
|
-
...sharedVocabularyUnitTests,
|
|
199
|
-
...browserBehaviorTests,
|
|
200
|
-
]),
|
|
201
|
-
),
|
|
202
|
-
...["horizontal", "vertical"].map((orientation) =>
|
|
203
|
-
interactionFullEntry(
|
|
204
|
-
`qti-orientation-${orientation}`,
|
|
205
|
-
["choice", "order"],
|
|
206
|
-
[
|
|
207
|
-
"packages/player/src/interactions/choice-layout.test.ts",
|
|
208
|
-
...sharedVocabularyUnitTests,
|
|
209
|
-
...browserBehaviorTests,
|
|
210
|
-
],
|
|
211
|
-
),
|
|
212
|
-
),
|
|
213
|
-
...Array.from({ length: 5 }, (_, index) => index + 1).map((stacking) =>
|
|
214
|
-
interactionFullEntry(
|
|
215
|
-
`qti-choices-stacking-${stacking}`,
|
|
216
|
-
["choice"],
|
|
217
|
-
[
|
|
218
|
-
"packages/player/src/interactions/choice-layout.test.ts",
|
|
219
|
-
"packages/core/src/core.test.ts",
|
|
220
|
-
...browserBehaviorTests,
|
|
221
|
-
],
|
|
222
|
-
),
|
|
223
|
-
),
|
|
224
|
-
interactionStylesheetEntry(
|
|
225
|
-
"qti-input-control-hidden",
|
|
226
|
-
["choice", "hottext"],
|
|
227
|
-
[...browserBehaviorTests, "tests/browser/player-keyboard-a11y.spec.ts"],
|
|
228
|
-
),
|
|
229
|
-
...SHARED_VOCABULARY_CHOICE_WRITING_ORIENTATIONS.map((orientation) =>
|
|
230
|
-
interactionStylesheetEntry(
|
|
231
|
-
`qti-writing-orientation-${orientation}`,
|
|
232
|
-
["choice", "inlineChoice"],
|
|
233
|
-
[...browserBehaviorTests],
|
|
234
|
-
),
|
|
235
|
-
),
|
|
236
|
-
...["light", "dark"].map((tone) =>
|
|
237
|
-
interactionStylesheetEntry(`qti-selections-${tone}`, selectionPresentationInteractions, [
|
|
238
|
-
...browserBehaviorTests,
|
|
239
|
-
...graphicBrowserTests,
|
|
240
|
-
]),
|
|
241
|
-
),
|
|
242
|
-
interactionStylesheetEntry("qti-unselected-hidden", selectionPresentationInteractions, [
|
|
243
|
-
...browserBehaviorTests,
|
|
244
|
-
...graphicBrowserTests,
|
|
245
|
-
]),
|
|
246
|
-
...["top", "bottom", "left", "right"].map((position) =>
|
|
247
|
-
interactionFullEntry(`qti-choices-${position}`, choicesLayoutInteractions, [
|
|
248
|
-
...sharedVocabularyUnitTests,
|
|
249
|
-
...browserBehaviorTests,
|
|
250
|
-
...graphicBrowserTests,
|
|
251
|
-
]),
|
|
252
|
-
),
|
|
345
|
+
...registryClassValueSupportEntries(),
|
|
346
|
+
...registryClassFixedSupportEntries(),
|
|
347
|
+
...registryAttributeSupportEntries(),
|
|
253
348
|
svEntry("data-min-selections-message", "interaction", "full", {
|
|
254
349
|
interactions: ["order"],
|
|
255
350
|
fixtures: [orderMinMaxMessagesFixture],
|
|
@@ -257,30 +352,21 @@ export const sharedVocabularyClassSupport: SharedVocabularyClassSupport[] = [
|
|
|
257
352
|
notes: "Overrides minimum response validation text for order interactions.",
|
|
258
353
|
}),
|
|
259
354
|
svEntry("data-max-selections-message", "interaction", "full", {
|
|
260
|
-
interactions: [
|
|
355
|
+
interactions: [...choiceAndOrder],
|
|
261
356
|
fixtures: [orderMinMaxMessagesFixture],
|
|
262
357
|
tests: ["tests/browser/player-validation.spec.ts", ...sharedVocabularyMatrixTests],
|
|
263
358
|
notes: "Overrides maximum response validation text for choice and order interactions.",
|
|
264
359
|
}),
|
|
265
|
-
|
|
266
|
-
"qti-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
interactions: ["match"],
|
|
276
|
-
fixtures: sharedVocabularyFixture,
|
|
277
|
-
tests: ["packages/core/src/core.test.ts", ...browserBehaviorTests],
|
|
278
|
-
notes: "Applied when qti-match-tabular selects the tabular match renderer.",
|
|
279
|
-
}),
|
|
280
|
-
interactionFullEntry(
|
|
281
|
-
"qti-gap-placement",
|
|
282
|
-
["gapMatch"],
|
|
283
|
-
[...sharedVocabularyUnitTests, "packages/core/src/core.test.ts", ...browserBehaviorTests],
|
|
360
|
+
svEntry(
|
|
361
|
+
sharedVocabularyFixedClassName("header-hidden") ?? "qti-header-hidden",
|
|
362
|
+
"interaction",
|
|
363
|
+
"conditional",
|
|
364
|
+
{
|
|
365
|
+
interactions: ["match"],
|
|
366
|
+
fixtures: sharedVocabularyFixture,
|
|
367
|
+
tests: ["packages/core/src/core.test.ts", ...browserBehaviorTests],
|
|
368
|
+
notes: "Applied when qti-match-tabular selects the tabular match renderer.",
|
|
369
|
+
},
|
|
284
370
|
),
|
|
285
371
|
...SHARED_VOCABULARY_INPUT_WIDTHS.map((width) =>
|
|
286
372
|
svEntry(`qti-input-width-${width}`, "interaction", "full", {
|
|
@@ -327,17 +413,4 @@ export const sharedVocabularyClassSupport: SharedVocabularyClassSupport[] = [
|
|
|
327
413
|
],
|
|
328
414
|
),
|
|
329
415
|
),
|
|
330
|
-
mediaPlayerSvEntry(
|
|
331
|
-
"data-qti-media-player-controls",
|
|
332
|
-
"Supports tokens none, default, play, rewind, captions, and audioDescription on media interactions and rendered media assets.",
|
|
333
|
-
[...mediaBrowserTests, "packages/core/src/shared-vocabulary-validation.test.ts"],
|
|
334
|
-
),
|
|
335
|
-
mediaPlayerSvEntry(
|
|
336
|
-
"data-qti-media-player-pause-delay",
|
|
337
|
-
"Reflects authored pause-delay values on rendered media assets. Pause timer behavior is covered in tests/browser/player.spec.ts.",
|
|
338
|
-
),
|
|
339
|
-
mediaPlayerSvEntry(
|
|
340
|
-
"data-qti-media-player-pause-duration",
|
|
341
|
-
"Reflects authored pause-duration values on rendered media assets. Pause timer behavior is covered in tests/browser/player.spec.ts.",
|
|
342
|
-
),
|
|
343
416
|
];
|
package/src/shared-vocabulary.ts
CHANGED
|
@@ -7,6 +7,24 @@ export const SHARED_VOCABULARY_INPUT_WIDTHS = [
|
|
|
7
7
|
|
|
8
8
|
export const SHARED_VOCABULARY_GAP_INPUT_WIDTHS = SHARED_VOCABULARY_INPUT_WIDTHS;
|
|
9
9
|
|
|
10
|
+
export const SHARED_VOCABULARY_LABEL_STYLES = [
|
|
11
|
+
"none",
|
|
12
|
+
"decimal",
|
|
13
|
+
"cjk-ideographic",
|
|
14
|
+
"lower-alpha",
|
|
15
|
+
"upper-alpha",
|
|
16
|
+
] as const;
|
|
17
|
+
|
|
18
|
+
export const SHARED_VOCABULARY_LABEL_SUFFIXES = ["none", "period", "parenthesis"] as const;
|
|
19
|
+
|
|
20
|
+
export const SHARED_VOCABULARY_ORIENTATIONS = ["horizontal", "vertical"] as const;
|
|
21
|
+
|
|
22
|
+
export const SHARED_VOCABULARY_CHOICES_STACKING = [1, 2, 3, 4, 5] as const;
|
|
23
|
+
|
|
24
|
+
export const SHARED_VOCABULARY_CHOICES_POSITIONS = ["top", "bottom", "left", "right"] as const;
|
|
25
|
+
|
|
26
|
+
export const SHARED_VOCABULARY_SELECTION_TONES = ["light", "dark"] as const;
|
|
27
|
+
|
|
10
28
|
/** Normative QTI 3 shared vocabulary extended text height token values (1EdTech vocab). */
|
|
11
29
|
export const SHARED_VOCABULARY_EXTENDED_TEXT_HEIGHT_LINES = [3, 6, 15] as const;
|
|
12
30
|
|