@longsightgroup/qti3-core 0.9.1 → 0.9.3

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 (244) hide show
  1. package/README.md +59 -3
  2. package/dist/adaptive-turn-materializer.d.ts +14 -0
  3. package/dist/adaptive-turn-materializer.d.ts.map +1 -0
  4. package/dist/adaptive-turn-materializer.js +56 -0
  5. package/dist/adaptive-turn-materializer.js.map +1 -0
  6. package/dist/adaptive-turn.d.ts +23 -0
  7. package/dist/adaptive-turn.d.ts.map +1 -0
  8. package/dist/adaptive-turn.js +60 -0
  9. package/dist/adaptive-turn.js.map +1 -0
  10. package/dist/assert-never.d.ts +3 -0
  11. package/dist/assert-never.d.ts.map +1 -0
  12. package/dist/assert-never.js +5 -0
  13. package/dist/assert-never.js.map +1 -0
  14. package/dist/attempt-state-constants.d.ts +6 -0
  15. package/dist/attempt-state-constants.d.ts.map +1 -0
  16. package/dist/attempt-state-constants.js +6 -0
  17. package/dist/attempt-state-constants.js.map +1 -0
  18. package/dist/attempt-state.d.ts +5 -0
  19. package/dist/attempt-state.d.ts.map +1 -0
  20. package/dist/attempt-state.js +190 -0
  21. package/dist/attempt-state.js.map +1 -0
  22. package/dist/catalog.js +1 -1
  23. package/dist/catalog.js.map +1 -1
  24. package/dist/content-text.d.ts.map +1 -1
  25. package/dist/content-text.js +3 -0
  26. package/dist/content-text.js.map +1 -1
  27. package/dist/custom-operators.d.ts +13 -0
  28. package/dist/custom-operators.d.ts.map +1 -0
  29. package/dist/custom-operators.js +2 -0
  30. package/dist/custom-operators.js.map +1 -0
  31. package/dist/delivery-redaction.d.ts +50 -0
  32. package/dist/delivery-redaction.d.ts.map +1 -0
  33. package/dist/delivery-redaction.js +176 -0
  34. package/dist/delivery-redaction.js.map +1 -0
  35. package/dist/delivery-security.d.ts +3 -18
  36. package/dist/delivery-security.d.ts.map +1 -1
  37. package/dist/delivery-security.js +35 -189
  38. package/dist/delivery-security.js.map +1 -1
  39. package/dist/index.d.ts +4 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +3 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/parser-custom-interactions.js +1 -1
  44. package/dist/parser-custom-interactions.js.map +1 -1
  45. package/dist/parser-declarations.d.ts.map +1 -1
  46. package/dist/parser-declarations.js +4 -4
  47. package/dist/parser-declarations.js.map +1 -1
  48. package/dist/parser-item-metadata.d.ts.map +1 -1
  49. package/dist/parser-item-metadata.js +8 -7
  50. package/dist/parser-item-metadata.js.map +1 -1
  51. package/dist/parser-processing.js +2 -2
  52. package/dist/parser-processing.js.map +1 -1
  53. package/dist/parser-values.d.ts +5 -1
  54. package/dist/parser-values.d.ts.map +1 -1
  55. package/dist/parser-values.js +33 -0
  56. package/dist/parser-values.js.map +1 -1
  57. package/dist/processing-evaluator-boolean.d.ts +8 -0
  58. package/dist/processing-evaluator-boolean.d.ts.map +1 -0
  59. package/dist/processing-evaluator-boolean.js +47 -0
  60. package/dist/processing-evaluator-boolean.js.map +1 -0
  61. package/dist/processing-evaluator-collection.d.ts +12 -0
  62. package/dist/processing-evaluator-collection.d.ts.map +1 -0
  63. package/dist/processing-evaluator-collection.js +35 -0
  64. package/dist/processing-evaluator-collection.js.map +1 -0
  65. package/dist/processing-evaluator-comparison.d.ts +8 -0
  66. package/dist/processing-evaluator-comparison.d.ts.map +1 -0
  67. package/dist/processing-evaluator-comparison.js +88 -0
  68. package/dist/processing-evaluator-comparison.js.map +1 -0
  69. package/dist/processing-evaluator-custom.d.ts +8 -0
  70. package/dist/processing-evaluator-custom.d.ts.map +1 -0
  71. package/dist/processing-evaluator-custom.js +14 -0
  72. package/dist/processing-evaluator-custom.js.map +1 -0
  73. package/dist/processing-evaluator-geometry.d.ts +8 -0
  74. package/dist/processing-evaluator-geometry.d.ts.map +1 -0
  75. package/dist/processing-evaluator-geometry.js +21 -0
  76. package/dist/processing-evaluator-geometry.js.map +1 -0
  77. package/dist/processing-evaluator-numeric.d.ts +8 -0
  78. package/dist/processing-evaluator-numeric.d.ts.map +1 -0
  79. package/dist/processing-evaluator-numeric.js +112 -0
  80. package/dist/processing-evaluator-numeric.js.map +1 -0
  81. package/dist/processing-evaluator-string.d.ts +8 -0
  82. package/dist/processing-evaluator-string.d.ts.map +1 -0
  83. package/dist/processing-evaluator-string.js +33 -0
  84. package/dist/processing-evaluator-string.js.map +1 -0
  85. package/dist/processing-evaluator-variable.d.ts +8 -0
  86. package/dist/processing-evaluator-variable.d.ts.map +1 -0
  87. package/dist/processing-evaluator-variable.js +39 -0
  88. package/dist/processing-evaluator-variable.js.map +1 -0
  89. package/dist/processing-evaluator.d.ts +22 -0
  90. package/dist/processing-evaluator.d.ts.map +1 -0
  91. package/dist/processing-evaluator.js +137 -0
  92. package/dist/processing-evaluator.js.map +1 -0
  93. package/dist/processing-expression-children.d.ts +3 -0
  94. package/dist/processing-expression-children.d.ts.map +1 -0
  95. package/dist/processing-expression-children.js +68 -0
  96. package/dist/processing-expression-children.js.map +1 -0
  97. package/dist/processing-mapping.d.ts +13 -0
  98. package/dist/processing-mapping.d.ts.map +1 -0
  99. package/dist/processing-mapping.js +120 -0
  100. package/dist/processing-mapping.js.map +1 -0
  101. package/dist/processing-operators.d.ts +11 -0
  102. package/dist/processing-operators.d.ts.map +1 -0
  103. package/dist/processing-operators.js +178 -0
  104. package/dist/processing-operators.js.map +1 -0
  105. package/dist/processing-random.d.ts +2 -0
  106. package/dist/processing-random.d.ts.map +1 -0
  107. package/dist/processing-random.js +16 -0
  108. package/dist/processing-random.js.map +1 -0
  109. package/dist/processing-state.d.ts +8 -0
  110. package/dist/processing-state.d.ts.map +1 -0
  111. package/dist/processing-state.js +44 -0
  112. package/dist/processing-state.js.map +1 -0
  113. package/dist/processing-templates.d.ts +3 -0
  114. package/dist/processing-templates.d.ts.map +1 -0
  115. package/dist/processing-templates.js +12 -0
  116. package/dist/processing-templates.js.map +1 -0
  117. package/dist/processing-values.d.ts +15 -0
  118. package/dist/processing-values.d.ts.map +1 -0
  119. package/dist/processing-values.js +150 -0
  120. package/dist/processing-values.js.map +1 -0
  121. package/dist/processing-variables.d.ts +7 -0
  122. package/dist/processing-variables.d.ts.map +1 -0
  123. package/dist/processing-variables.js +40 -0
  124. package/dist/processing-variables.js.map +1 -0
  125. package/dist/serializer-processing-expressions.d.ts.map +1 -1
  126. package/dist/serializer-processing-expressions.js +2 -8
  127. package/dist/serializer-processing-expressions.js.map +1 -1
  128. package/dist/serializer-processing-xml.js +2 -2
  129. package/dist/serializer-processing-xml.js.map +1 -1
  130. package/dist/serializer-processing.d.ts.map +1 -1
  131. package/dist/serializer-processing.js +3 -0
  132. package/dist/serializer-processing.js.map +1 -1
  133. package/dist/server-scoring.d.ts +4 -14
  134. package/dist/server-scoring.d.ts.map +1 -1
  135. package/dist/server-scoring.js +19 -157
  136. package/dist/server-scoring.js.map +1 -1
  137. package/dist/session.d.ts +5 -14
  138. package/dist/session.d.ts.map +1 -1
  139. package/dist/session.js +76 -1158
  140. package/dist/session.js.map +1 -1
  141. package/dist/shared-vocabulary-coverage-policy.js +1 -1
  142. package/dist/shared-vocabulary-coverage-policy.js.map +1 -1
  143. package/dist/shared-vocabulary-generated-families.js +1 -1
  144. package/dist/shared-vocabulary-generated-families.js.map +1 -1
  145. package/dist/shared-vocabulary-support.js +3 -3
  146. package/dist/shared-vocabulary-support.js.map +1 -1
  147. package/dist/shared-vocabulary.d.ts.map +1 -1
  148. package/dist/shared-vocabulary.js +4 -3
  149. package/dist/shared-vocabulary.js.map +1 -1
  150. package/dist/support-evidence.d.ts +22 -0
  151. package/dist/support-evidence.d.ts.map +1 -0
  152. package/dist/support-evidence.js +93 -0
  153. package/dist/support-evidence.js.map +1 -0
  154. package/dist/support.d.ts.map +1 -1
  155. package/dist/support.js +38 -47
  156. package/dist/support.js.map +1 -1
  157. package/dist/trusted-item-session.d.ts +49 -0
  158. package/dist/trusted-item-session.d.ts.map +1 -0
  159. package/dist/trusted-item-session.js +261 -0
  160. package/dist/trusted-item-session.js.map +1 -0
  161. package/dist/tts.d.ts.map +1 -1
  162. package/dist/tts.js +16 -2
  163. package/dist/tts.js.map +1 -1
  164. package/dist/validation-geometry.d.ts +8 -0
  165. package/dist/validation-geometry.d.ts.map +1 -0
  166. package/dist/validation-geometry.js +187 -0
  167. package/dist/validation-geometry.js.map +1 -0
  168. package/dist/validation-interactions.d.ts +3 -0
  169. package/dist/validation-interactions.d.ts.map +1 -0
  170. package/dist/validation-interactions.js +644 -0
  171. package/dist/validation-interactions.js.map +1 -0
  172. package/dist/validation-primitives.d.ts +11 -0
  173. package/dist/validation-primitives.d.ts.map +1 -0
  174. package/dist/validation-primitives.js +48 -0
  175. package/dist/validation-primitives.js.map +1 -0
  176. package/dist/validation-processing.d.ts +4 -0
  177. package/dist/validation-processing.d.ts.map +1 -0
  178. package/dist/validation-processing.js +569 -0
  179. package/dist/validation-processing.js.map +1 -0
  180. package/dist/validation-shared-vocabulary-layout.d.ts +10 -0
  181. package/dist/validation-shared-vocabulary-layout.d.ts.map +1 -0
  182. package/dist/validation-shared-vocabulary-layout.js +102 -0
  183. package/dist/validation-shared-vocabulary-layout.js.map +1 -0
  184. package/dist/validation.d.ts.map +1 -1
  185. package/dist/validation.js +27 -1641
  186. package/dist/validation.js.map +1 -1
  187. package/dist/xml.js +1 -1
  188. package/dist/xml.js.map +1 -1
  189. package/package.json +4 -2
  190. package/src/adaptive-turn-materializer.ts +85 -0
  191. package/src/adaptive-turn.ts +109 -0
  192. package/src/assert-never.ts +4 -0
  193. package/src/attempt-state-constants.ts +5 -0
  194. package/src/attempt-state.ts +245 -0
  195. package/src/catalog.ts +1 -1
  196. package/src/content-text.ts +3 -0
  197. package/src/custom-operators.ts +12 -0
  198. package/src/delivery-redaction.ts +268 -0
  199. package/src/delivery-security.ts +59 -245
  200. package/src/index.ts +9 -0
  201. package/src/parser-custom-interactions.ts +1 -1
  202. package/src/parser-declarations.ts +4 -3
  203. package/src/parser-item-metadata.ts +8 -7
  204. package/src/parser-processing.ts +2 -2
  205. package/src/parser-values.ts +36 -0
  206. package/src/processing-evaluator-boolean.ts +48 -0
  207. package/src/processing-evaluator-collection.ts +50 -0
  208. package/src/processing-evaluator-comparison.ts +106 -0
  209. package/src/processing-evaluator-custom.ts +20 -0
  210. package/src/processing-evaluator-geometry.ts +26 -0
  211. package/src/processing-evaluator-numeric.ts +155 -0
  212. package/src/processing-evaluator-string.ts +60 -0
  213. package/src/processing-evaluator-variable.ts +81 -0
  214. package/src/processing-evaluator.ts +173 -0
  215. package/src/processing-expression-children.ts +69 -0
  216. package/src/processing-mapping.ts +153 -0
  217. package/src/processing-operators.ts +184 -0
  218. package/src/processing-random.ts +16 -0
  219. package/src/processing-state.ts +69 -0
  220. package/src/processing-templates.ts +12 -0
  221. package/src/processing-values.ts +162 -0
  222. package/src/processing-variables.ts +83 -0
  223. package/src/serializer-processing-expressions.ts +2 -12
  224. package/src/serializer-processing-xml.ts +2 -2
  225. package/src/serializer-processing.ts +3 -0
  226. package/src/server-scoring.ts +30 -226
  227. package/src/session.ts +128 -2006
  228. package/src/shared-vocabulary-coverage-policy.ts +1 -1
  229. package/src/shared-vocabulary-generated-families.ts +1 -1
  230. package/src/shared-vocabulary-support.ts +3 -3
  231. package/src/shared-vocabulary.ts +3 -2
  232. package/src/support-evidence.ts +107 -0
  233. package/src/support.ts +68 -54
  234. package/src/trusted-item-session.ts +429 -0
  235. package/src/tts.ts +29 -15
  236. package/src/validation-geometry.ts +204 -0
  237. package/src/validation-interactions.ts +831 -0
  238. package/src/validation-primitives.ts +63 -0
  239. package/src/validation-processing.ts +785 -0
  240. package/src/validation-shared-vocabulary-layout.ts +117 -0
  241. package/src/validation.ts +44 -2077
  242. package/src/xml.ts +1 -1
  243. package/src/interaction-test-fixtures.ts +0 -44
  244. package/src/serializer-processing.fixtures.ts +0 -469
package/src/xml.ts CHANGED
@@ -165,7 +165,7 @@ export function parseXmlTree(xml: string): { root: XmlNode | undefined; errors:
165
165
  offset = endOffset + 1;
166
166
  }
167
167
 
168
- for (const node of [...state.stack].reverse()) {
168
+ for (const node of state.stack.toReversed()) {
169
169
  state.errors.push(
170
170
  new Error(`Unexpected end of document. Missing closing tag for <${node.name}>.`),
171
171
  );
@@ -1,44 +0,0 @@
1
- import {
2
- deprecatedInteractionSupport,
3
- interactionRegistryStatus,
4
- interactionSupport,
5
- } from "./support.js";
6
- import type { QtiInteraction, QtiSourceLocation } from "./types.js";
7
-
8
- const defaultSource: QtiSourceLocation = {
9
- line: 1,
10
- column: 1,
11
- offset: 0,
12
- path: "item",
13
- };
14
-
15
- const qtiNameByInteractionType = new Map(
16
- [...interactionSupport, ...deprecatedInteractionSupport].map((entry) => [
17
- entry.interactionType,
18
- entry.qtiName,
19
- ]),
20
- );
21
-
22
- export function testInteraction(
23
- overrides: Partial<QtiInteraction> & Pick<QtiInteraction, "type">,
24
- ): QtiInteraction {
25
- const qtiName =
26
- overrides.qtiName ?? qtiNameByInteractionType.get(overrides.type) ?? `qti-${overrides.type}`;
27
- const interaction = {
28
- registryStatus: interactionRegistryStatus(qtiName),
29
- qtiName,
30
- responseIdentifier: "RESPONSE",
31
- responseCardinality: "single" as const,
32
- responseBaseType: "identifier" as const,
33
- choices: [],
34
- attributes: {},
35
- childElements: [],
36
- text: "",
37
- source: defaultSource,
38
- ...overrides,
39
- };
40
- return {
41
- ...interaction,
42
- registryStatus: overrides.registryStatus ?? interactionRegistryStatus(interaction.qtiName),
43
- };
44
- }
@@ -1,469 +0,0 @@
1
- import type { QtiProcessingExpression } from "./types.js";
2
-
3
- const baseOne = {
4
- type: "baseValue",
5
- baseType: "integer",
6
- value: 1,
7
- } satisfies QtiProcessingExpression;
8
- const baseTwo = {
9
- type: "baseValue",
10
- baseType: "integer",
11
- value: 2,
12
- } satisfies QtiProcessingExpression;
13
- const variableScore = { type: "variable", identifier: "SCORE" } satisfies QtiProcessingExpression;
14
- const variableResponse = {
15
- type: "variable",
16
- identifier: "RESPONSE",
17
- } satisfies QtiProcessingExpression;
18
-
19
- export type ExpressionCoverage = {
20
- [K in QtiProcessingExpression["type"]]: {
21
- expression: Extract<QtiProcessingExpression, { type: K }>;
22
- xml: string;
23
- };
24
- };
25
-
26
- export const expressionCoverage = {
27
- baseValue: {
28
- expression: baseOne,
29
- xml: ' <qti-base-value base-type="integer">1</qti-base-value>',
30
- },
31
- null: { expression: { type: "null" }, xml: " <qti-null/>" },
32
- isNull: {
33
- expression: { type: "isNull", identifier: "RESPONSE" },
34
- xml: [
35
- " <qti-is-null>",
36
- ' <qti-variable identifier="RESPONSE"/>',
37
- " </qti-is-null>",
38
- ].join("\n"),
39
- },
40
- matchCorrect: {
41
- expression: {
42
- type: "matchCorrect",
43
- identifier: "RESPONSE",
44
- correctIdentifier: "RESPONSE",
45
- },
46
- xml: [
47
- " <qti-match>",
48
- ' <qti-variable identifier="RESPONSE"/>',
49
- ' <qti-correct identifier="RESPONSE"/>',
50
- " </qti-match>",
51
- ].join("\n"),
52
- },
53
- match: {
54
- expression: { type: "match", left: variableResponse, right: baseOne },
55
- xml: [
56
- " <qti-match>",
57
- ' <qti-variable identifier="RESPONSE"/>',
58
- ' <qti-base-value base-type="integer">1</qti-base-value>',
59
- " </qti-match>",
60
- ].join("\n"),
61
- },
62
- correct: {
63
- expression: { type: "correct", identifier: "RESPONSE" },
64
- xml: ' <qti-correct identifier="RESPONSE"/>',
65
- },
66
- default: {
67
- expression: { type: "default", identifier: "SCORE" },
68
- xml: ' <qti-default identifier="SCORE"/>',
69
- },
70
- mapResponse: {
71
- expression: { type: "mapResponse", identifier: "RESPONSE" },
72
- xml: ' <qti-map-response identifier="RESPONSE"/>',
73
- },
74
- mapResponsePoint: {
75
- expression: { type: "mapResponsePoint", identifier: "RESPONSE" },
76
- xml: ' <qti-map-response-point identifier="RESPONSE"/>',
77
- },
78
- variable: {
79
- expression: variableResponse,
80
- xml: ' <qti-variable identifier="RESPONSE"/>',
81
- },
82
- randomInteger: {
83
- expression: { type: "randomInteger", min: 1, max: 10, step: 1, attributes: {} },
84
- xml: ' <qti-random-integer min="1" max="10" step="1"/>',
85
- },
86
- randomFloat: {
87
- expression: { type: "randomFloat", min: 0, max: 1, attributes: {} },
88
- xml: ' <qti-random-float min="0" max="1"/>',
89
- },
90
- random: {
91
- expression: { type: "random", values: [baseOne, baseTwo] },
92
- xml: [
93
- " <qti-random>",
94
- ' <qti-base-value base-type="integer">1</qti-base-value>',
95
- ' <qti-base-value base-type="integer">2</qti-base-value>',
96
- " </qti-random>",
97
- ].join("\n"),
98
- },
99
- multiple: {
100
- expression: { type: "multiple", expressions: [baseOne, baseTwo] },
101
- xml: [
102
- " <qti-multiple>",
103
- ' <qti-base-value base-type="integer">1</qti-base-value>',
104
- ' <qti-base-value base-type="integer">2</qti-base-value>',
105
- " </qti-multiple>",
106
- ].join("\n"),
107
- },
108
- ordered: {
109
- expression: { type: "ordered", expressions: [baseOne, baseTwo] },
110
- xml: [
111
- " <qti-ordered>",
112
- ' <qti-base-value base-type="integer">1</qti-base-value>',
113
- ' <qti-base-value base-type="integer">2</qti-base-value>',
114
- " </qti-ordered>",
115
- ].join("\n"),
116
- },
117
- index: {
118
- expression: { type: "index", expression: variableResponse, n: "1" },
119
- xml: [
120
- ' <qti-index n="1">',
121
- ' <qti-variable identifier="RESPONSE"/>',
122
- " </qti-index>",
123
- ].join("\n"),
124
- },
125
- containerSize: {
126
- expression: { type: "containerSize", expression: variableResponse },
127
- xml: [
128
- " <qti-container-size>",
129
- ' <qti-variable identifier="RESPONSE"/>',
130
- " </qti-container-size>",
131
- ].join("\n"),
132
- },
133
- sum: {
134
- expression: { type: "sum", expressions: [baseOne, baseTwo] },
135
- xml: [
136
- " <qti-sum>",
137
- ' <qti-base-value base-type="integer">1</qti-base-value>',
138
- ' <qti-base-value base-type="integer">2</qti-base-value>',
139
- " </qti-sum>",
140
- ].join("\n"),
141
- },
142
- product: {
143
- expression: { type: "product", expressions: [baseOne, baseTwo] },
144
- xml: [
145
- " <qti-product>",
146
- ' <qti-base-value base-type="integer">1</qti-base-value>',
147
- ' <qti-base-value base-type="integer">2</qti-base-value>',
148
- " </qti-product>",
149
- ].join("\n"),
150
- },
151
- min: {
152
- expression: { type: "min", expressions: [baseOne, baseTwo] },
153
- xml: [
154
- " <qti-min>",
155
- ' <qti-base-value base-type="integer">1</qti-base-value>',
156
- ' <qti-base-value base-type="integer">2</qti-base-value>',
157
- " </qti-min>",
158
- ].join("\n"),
159
- },
160
- max: {
161
- expression: { type: "max", expressions: [baseOne, baseTwo] },
162
- xml: [
163
- " <qti-max>",
164
- ' <qti-base-value base-type="integer">1</qti-base-value>',
165
- ' <qti-base-value base-type="integer">2</qti-base-value>',
166
- " </qti-max>",
167
- ].join("\n"),
168
- },
169
- subtract: {
170
- expression: { type: "subtract", left: baseTwo, right: baseOne },
171
- xml: [
172
- " <qti-subtract>",
173
- ' <qti-base-value base-type="integer">2</qti-base-value>',
174
- ' <qti-base-value base-type="integer">1</qti-base-value>',
175
- " </qti-subtract>",
176
- ].join("\n"),
177
- },
178
- divide: {
179
- expression: { type: "divide", left: baseTwo, right: baseOne },
180
- xml: [
181
- " <qti-divide>",
182
- ' <qti-base-value base-type="integer">2</qti-base-value>',
183
- ' <qti-base-value base-type="integer">1</qti-base-value>',
184
- " </qti-divide>",
185
- ].join("\n"),
186
- },
187
- power: {
188
- expression: { type: "power", left: baseTwo, right: baseOne },
189
- xml: [
190
- " <qti-power>",
191
- ' <qti-base-value base-type="integer">2</qti-base-value>',
192
- ' <qti-base-value base-type="integer">1</qti-base-value>',
193
- " </qti-power>",
194
- ].join("\n"),
195
- },
196
- integerDivide: {
197
- expression: { type: "integerDivide", left: baseTwo, right: baseOne },
198
- xml: [
199
- " <qti-integer-divide>",
200
- ' <qti-base-value base-type="integer">2</qti-base-value>',
201
- ' <qti-base-value base-type="integer">1</qti-base-value>',
202
- " </qti-integer-divide>",
203
- ].join("\n"),
204
- },
205
- integerModulus: {
206
- expression: { type: "integerModulus", left: baseTwo, right: baseOne },
207
- xml: [
208
- " <qti-integer-modulus>",
209
- ' <qti-base-value base-type="integer">2</qti-base-value>',
210
- ' <qti-base-value base-type="integer">1</qti-base-value>',
211
- " </qti-integer-modulus>",
212
- ].join("\n"),
213
- },
214
- round: {
215
- expression: { type: "round", expression: baseOne },
216
- xml: [
217
- " <qti-round>",
218
- ' <qti-base-value base-type="integer">1</qti-base-value>',
219
- " </qti-round>",
220
- ].join("\n"),
221
- },
222
- roundTo: {
223
- expression: {
224
- type: "roundTo",
225
- expression: baseOne,
226
- roundingMode: "decimalPlaces",
227
- figures: 1,
228
- },
229
- xml: [
230
- ' <qti-round-to rounding-mode="decimalPlaces" figures="1">',
231
- ' <qti-base-value base-type="integer">1</qti-base-value>',
232
- " </qti-round-to>",
233
- ].join("\n"),
234
- },
235
- truncate: {
236
- expression: { type: "truncate", expression: baseOne },
237
- xml: [
238
- " <qti-truncate>",
239
- ' <qti-base-value base-type="integer">1</qti-base-value>',
240
- " </qti-truncate>",
241
- ].join("\n"),
242
- },
243
- integerToFloat: {
244
- expression: { type: "integerToFloat", expression: baseOne },
245
- xml: [
246
- " <qti-integer-to-float>",
247
- ' <qti-base-value base-type="integer">1</qti-base-value>',
248
- " </qti-integer-to-float>",
249
- ].join("\n"),
250
- },
251
- and: {
252
- expression: { type: "and", expressions: [variableScore] },
253
- xml: [" <qti-and>", ' <qti-variable identifier="SCORE"/>', " </qti-and>"].join("\n"),
254
- },
255
- anyN: {
256
- expression: { type: "anyN", min: "1", max: "2", expressions: [variableScore] },
257
- xml: [
258
- ' <qti-any-n min="1" max="2">',
259
- ' <qti-variable identifier="SCORE"/>',
260
- " </qti-any-n>",
261
- ].join("\n"),
262
- },
263
- or: {
264
- expression: { type: "or", expressions: [variableScore] },
265
- xml: [" <qti-or>", ' <qti-variable identifier="SCORE"/>', " </qti-or>"].join("\n"),
266
- },
267
- not: {
268
- expression: { type: "not", expression: variableScore },
269
- xml: [" <qti-not>", ' <qti-variable identifier="SCORE"/>', " </qti-not>"].join("\n"),
270
- },
271
- equal: {
272
- expression: { type: "equal", left: baseOne, right: baseOne },
273
- xml: [
274
- " <qti-equal>",
275
- ' <qti-base-value base-type="integer">1</qti-base-value>',
276
- ' <qti-base-value base-type="integer">1</qti-base-value>',
277
- " </qti-equal>",
278
- ].join("\n"),
279
- },
280
- equalRounded: {
281
- expression: {
282
- type: "equalRounded",
283
- left: baseOne,
284
- right: baseOne,
285
- roundingMode: "decimalPlaces",
286
- figures: 1,
287
- },
288
- xml: [
289
- ' <qti-equal-rounded rounding-mode="decimalPlaces" figures="1">',
290
- ' <qti-base-value base-type="integer">1</qti-base-value>',
291
- ' <qti-base-value base-type="integer">1</qti-base-value>',
292
- " </qti-equal-rounded>",
293
- ].join("\n"),
294
- },
295
- numericCompare: {
296
- expression: { type: "numericCompare", operator: "gte", left: variableScore, right: baseOne },
297
- xml: [
298
- " <qti-gte>",
299
- ' <qti-variable identifier="SCORE"/>',
300
- ' <qti-base-value base-type="integer">1</qti-base-value>',
301
- " </qti-gte>",
302
- ].join("\n"),
303
- },
304
- durationCompare: {
305
- expression: { type: "durationCompare", operator: "lt", left: variableScore, right: baseOne },
306
- xml: [
307
- " <qti-duration-lt>",
308
- ' <qti-variable identifier="SCORE"/>',
309
- ' <qti-base-value base-type="integer">1</qti-base-value>',
310
- " </qti-duration-lt>",
311
- ].join("\n"),
312
- },
313
- stringMatch: {
314
- expression: {
315
- type: "stringMatch",
316
- left: variableResponse,
317
- right: { type: "baseValue", baseType: "string", value: "A" },
318
- caseSensitive: false,
319
- substring: true,
320
- },
321
- xml: [
322
- ' <qti-string-match case-sensitive="false" substring="true">',
323
- ' <qti-variable identifier="RESPONSE"/>',
324
- ' <qti-base-value base-type="string">A</qti-base-value>',
325
- " </qti-string-match>",
326
- ].join("\n"),
327
- },
328
- substring: {
329
- expression: {
330
- type: "substring",
331
- left: variableResponse,
332
- right: { type: "baseValue", baseType: "string", value: "A" },
333
- caseSensitive: true,
334
- },
335
- xml: [
336
- ' <qti-substring case-sensitive="true">',
337
- ' <qti-variable identifier="RESPONSE"/>',
338
- ' <qti-base-value base-type="string">A</qti-base-value>',
339
- " </qti-substring>",
340
- ].join("\n"),
341
- },
342
- patternMatch: {
343
- expression: { type: "patternMatch", expression: variableResponse, pattern: "[A-Z]+" },
344
- xml: [
345
- ' <qti-pattern-match pattern="[A-Z]+">',
346
- ' <qti-variable identifier="RESPONSE"/>',
347
- " </qti-pattern-match>",
348
- ].join("\n"),
349
- },
350
- fieldValue: {
351
- expression: { type: "fieldValue", fieldIdentifier: "candidate", expression: variableResponse },
352
- xml: [
353
- ' <qti-field-value field-identifier="candidate">',
354
- ' <qti-variable identifier="RESPONSE"/>',
355
- " </qti-field-value>",
356
- ].join("\n"),
357
- },
358
- member: {
359
- expression: { type: "member", value: baseOne, collection: variableResponse },
360
- xml: [
361
- " <qti-member>",
362
- ' <qti-base-value base-type="integer">1</qti-base-value>',
363
- ' <qti-variable identifier="RESPONSE"/>',
364
- " </qti-member>",
365
- ].join("\n"),
366
- },
367
- delete: {
368
- expression: { type: "delete", value: baseOne, collection: variableResponse },
369
- xml: [
370
- " <qti-delete>",
371
- ' <qti-base-value base-type="integer">1</qti-base-value>',
372
- ' <qti-variable identifier="RESPONSE"/>',
373
- " </qti-delete>",
374
- ].join("\n"),
375
- },
376
- contains: {
377
- expression: { type: "contains", collection: variableResponse, values: baseOne },
378
- xml: [
379
- " <qti-contains>",
380
- ' <qti-variable identifier="RESPONSE"/>',
381
- ' <qti-base-value base-type="integer">1</qti-base-value>',
382
- " </qti-contains>",
383
- ].join("\n"),
384
- },
385
- gcd: {
386
- expression: { type: "gcd", expressions: [baseOne, baseTwo] },
387
- xml: [
388
- " <qti-gcd>",
389
- ' <qti-base-value base-type="integer">1</qti-base-value>',
390
- ' <qti-base-value base-type="integer">2</qti-base-value>',
391
- " </qti-gcd>",
392
- ].join("\n"),
393
- },
394
- inside: {
395
- expression: {
396
- type: "inside",
397
- shape: "circle",
398
- coords: [10, 20, 5],
399
- attributes: { coords: "0,0,0", shape: "rect", tolerance: "2" },
400
- expression: variableResponse,
401
- },
402
- xml: [
403
- ' <qti-inside shape="rect" coords="0,0,0" tolerance="2">',
404
- ' <qti-variable identifier="RESPONSE"/>',
405
- " </qti-inside>",
406
- ].join("\n"),
407
- },
408
- lcm: {
409
- expression: { type: "lcm", expressions: [baseOne, baseTwo] },
410
- xml: [
411
- " <qti-lcm>",
412
- ' <qti-base-value base-type="integer">1</qti-base-value>',
413
- ' <qti-base-value base-type="integer">2</qti-base-value>',
414
- " </qti-lcm>",
415
- ].join("\n"),
416
- },
417
- mathConstant: {
418
- expression: { type: "mathConstant", name: "pi" },
419
- xml: ' <qti-math-constant name="pi"/>',
420
- },
421
- mathOperator: {
422
- expression: { type: "mathOperator", name: "sin", expressions: [baseOne] },
423
- xml: [
424
- ' <qti-math-operator name="sin">',
425
- ' <qti-base-value base-type="integer">1</qti-base-value>',
426
- " </qti-math-operator>",
427
- ].join("\n"),
428
- },
429
- repeat: {
430
- expression: { type: "repeat", numberRepeats: "2", expressions: [baseOne] },
431
- xml: [
432
- ' <qti-repeat number-repeats="2">',
433
- ' <qti-base-value base-type="integer">1</qti-base-value>',
434
- " </qti-repeat>",
435
- ].join("\n"),
436
- },
437
- statsOperator: {
438
- expression: { type: "statsOperator", name: "mean", expression: variableResponse },
439
- xml: [
440
- ' <qti-stats-operator name="mean">',
441
- ' <qti-variable identifier="RESPONSE"/>',
442
- " </qti-stats-operator>",
443
- ].join("\n"),
444
- },
445
- customOperator: {
446
- expression: {
447
- type: "customOperator",
448
- definition: "https://example.invalid/operator?a=1&b=2",
449
- className: "demo",
450
- attributes: { "data-extra": `"quoted"` },
451
- expressions: [{ type: "null" }],
452
- },
453
- xml: [
454
- ' <qti-custom-operator class="demo" data-extra="&quot;quoted&quot;" definition="https://example.invalid/operator?a=1&amp;b=2">',
455
- " <qti-null/>",
456
- " </qti-custom-operator>",
457
- ].join("\n"),
458
- },
459
- } satisfies ExpressionCoverage;
460
-
461
- export function expressionCoverageXml(expressionType: QtiProcessingExpression["type"]): string {
462
- return [
463
- "<qti-response-processing>",
464
- ' <qti-set-outcome-value identifier="SCORE">',
465
- expressionCoverage[expressionType].xml,
466
- " </qti-set-outcome-value>",
467
- "</qti-response-processing>",
468
- ].join("\n");
469
- }