@citolab/qti-components 9.1.0 → 9.2.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.
- package/cdn/index.global.js +1 -1
- package/cdn/index.js +208 -200
- package/dist/base.d.ts +54 -11
- package/dist/base.js +11 -1
- package/dist/{chunk-QCPN7E6K.js → chunk-7PXUE2GR.js} +3375 -3251
- package/dist/chunk-7PXUE2GR.js.map +1 -0
- package/dist/{chunk-XE7BALDO.js → chunk-A32YH4H5.js} +2 -2
- package/dist/{chunk-XE7BALDO.js.map → chunk-A32YH4H5.js.map} +1 -1
- package/dist/{chunk-MKZ374OJ.js → chunk-FG5JAWSN.js} +2 -2
- package/dist/{chunk-3VQSUWCK.js → chunk-G5RQ5GKG.js} +407 -131
- package/dist/chunk-G5RQ5GKG.js.map +1 -0
- package/dist/{chunk-5SU3MP6Y.js → chunk-GPGUXZ3X.js} +20 -6
- package/dist/{chunk-5SU3MP6Y.js.map → chunk-GPGUXZ3X.js.map} +1 -1
- package/dist/{chunk-5BXJRO5O.js → chunk-JGPWBIVD.js} +389 -229
- package/dist/chunk-JGPWBIVD.js.map +1 -0
- package/dist/{chunk-RT6WZ3P7.js → chunk-JLZCZVRX.js} +2 -2
- package/dist/{chunk-6ITD55QE.js → chunk-LFVPS7KB.js} +2 -2
- package/dist/{chunk-DAUU2NJL.js → chunk-RAJQKCQ3.js} +66 -9
- package/dist/chunk-RAJQKCQ3.js.map +1 -0
- package/dist/{chunk-WKWCOV5P.js → chunk-REKCRWJV.js} +83 -21
- package/dist/chunk-REKCRWJV.js.map +1 -0
- package/dist/{chunk-HDEG6BAZ.js → chunk-TLAVOBEM.js} +16 -8
- package/dist/chunk-TLAVOBEM.js.map +1 -0
- package/dist/{chunk-LDY4C2OT.js → chunk-YIYHCHHM.js} +2 -2
- package/dist/{chunk-WCWJPIUQ.js → chunk-YVZWNLF4.js} +191 -52
- package/dist/chunk-YVZWNLF4.js.map +1 -0
- package/dist/{chunk-KCK27QBP.js → chunk-ZG7FBQFP.js} +2 -2
- package/dist/{chunk-XYQNTF5B.js → chunk-ZOQVTG5L.js} +2 -2
- package/dist/{computed.types.d-CJarqC6s.d.ts → computed.types.d-DB5gfOh9.d.ts} +2 -16
- package/dist/corrections.d.ts +21 -10
- package/dist/corrections.js +20 -20
- package/dist/corrections.js.map +1 -1
- package/dist/elements.d.ts +43 -11
- package/dist/elements.js +4 -4
- package/dist/index.d.ts +14 -13
- package/dist/index.js +37 -15
- package/dist/{interaction.d-CJiMv8H7.d.ts → interaction.d-DegNJ5ZA.d.ts} +1 -1
- package/dist/interactions.d.ts +35 -35
- package/dist/interactions.js +3 -3
- package/dist/item.css +11 -2
- package/dist/item.d.ts +31 -82
- package/dist/item.js +7 -5
- package/dist/{item.types.d-QU7LljEK.d.ts → item.types.d-BDFrq19E.d.ts} +18 -2
- package/dist/loader.d.ts +3 -3
- package/dist/loader.js +2 -2
- package/dist/processing.d.ts +139 -20
- package/dist/processing.js +11 -3
- package/dist/qti-components-jsx.d.ts +1947 -98
- package/dist/{qti-condition-expression.d-CYwXOUb1.d.ts → qti-condition-expression.d-DLboq8bR.d.ts} +1 -1
- package/dist/{qti-expression.d-B_-m9emA.d.ts → qti-expression.d-BksT9iLB.d.ts} +26 -3
- package/dist/{qti-feedback.d-B1EIF-fU.d.ts → qti-feedback.d-D-w6-mJv.d.ts} +1 -1
- package/dist/qti-item.d-D_-9_0e6.d.ts +101 -0
- package/dist/qti-rule-base.d-Bdzg8eGH.d.ts +41 -0
- package/dist/{qti-test.d-C6lCEMRB.d.ts → qti-test.d-BfAZE6UF.d.ts} +61 -9
- package/dist/{qti-text-entry-interaction.d-BGdfV9qG.d.ts → qti-text-entry-interaction.d-CATtcPyX.d.ts} +10 -9
- package/dist/session.context.d-Cjs0BkJB.d.ts +33 -0
- package/dist/test.d.ts +8 -8
- package/dist/test.js +8 -6
- package/dist/transformers.js +1 -1
- package/package.json +12 -11
- package/dist/chunk-3VQSUWCK.js.map +0 -1
- package/dist/chunk-5BXJRO5O.js.map +0 -1
- package/dist/chunk-DAUU2NJL.js.map +0 -1
- package/dist/chunk-HDEG6BAZ.js.map +0 -1
- package/dist/chunk-QCPN7E6K.js.map +0 -1
- package/dist/chunk-WCWJPIUQ.js.map +0 -1
- package/dist/chunk-WKWCOV5P.js.map +0 -1
- package/dist/computed-item.types.d-BKZdSLLJ.d.ts +0 -19
- package/dist/qti-rule-base.d-ajOnfGXY.d.ts +0 -16
- /package/dist/{chunk-MKZ374OJ.js.map → chunk-FG5JAWSN.js.map} +0 -0
- /package/dist/{chunk-RT6WZ3P7.js.map → chunk-JLZCZVRX.js.map} +0 -0
- /package/dist/{chunk-6ITD55QE.js.map → chunk-LFVPS7KB.js.map} +0 -0
- /package/dist/{chunk-LDY4C2OT.js.map → chunk-YIYHCHHM.js.map} +0 -0
- /package/dist/{chunk-KCK27QBP.js.map → chunk-ZG7FBQFP.js.map} +0 -0
- /package/dist/{chunk-XYQNTF5B.js.map → chunk-ZOQVTG5L.js.map} +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
QtiConditionExpression,
|
|
3
|
+
QtiExitResponseSignal,
|
|
4
|
+
QtiExitTestSignal,
|
|
3
5
|
QtiExpression,
|
|
4
6
|
ScoringHelper,
|
|
5
7
|
convertNumberToUniversalFormat,
|
|
6
8
|
itemContext,
|
|
7
9
|
testContext
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YVZWNLF4.js";
|
|
9
11
|
|
|
10
12
|
// ../qti-processing/dist/components/qti-and/qti-and.js
|
|
11
13
|
var QtiAnd = class extends qtiAndMixin(QtiConditionExpression) {
|
|
@@ -122,6 +124,9 @@ __decorate2([
|
|
|
122
124
|
|
|
123
125
|
// ../qti-processing/dist/components/qti-container-size/qti-container-size.js
|
|
124
126
|
var QtiContainerSize = class extends QtiExpression {
|
|
127
|
+
get resultBaseType() {
|
|
128
|
+
return "integer";
|
|
129
|
+
}
|
|
125
130
|
getResult() {
|
|
126
131
|
if (this.children?.length !== 1) {
|
|
127
132
|
console.error("qti-container-size must have exactly one child expression");
|
|
@@ -148,27 +153,62 @@ var QtiContainerSize = class extends QtiExpression {
|
|
|
148
153
|
};
|
|
149
154
|
|
|
150
155
|
// ../qti-processing/dist/components/qti-contains/qti-contains.js
|
|
151
|
-
var QtiContains = class extends
|
|
156
|
+
var QtiContains = class extends QtiExpression {
|
|
152
157
|
getResult() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
158
|
+
if (this.children.length !== 2) {
|
|
159
|
+
console.error("qti-contains takes two sub-expressions");
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const [container, sub] = this.getVariables();
|
|
163
|
+
if (!container || !sub) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (container.value === null || container.value === void 0 || sub.value === null || sub.value === void 0) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
if (container.baseType !== sub.baseType) {
|
|
170
|
+
console.warn("qti-contains: both sub-expressions should have the same base-type");
|
|
171
|
+
}
|
|
172
|
+
const baseType = container.baseType ?? sub.baseType;
|
|
173
|
+
if (container.cardinality === "single" && sub.cardinality !== "single") {
|
|
174
|
+
console.warn("qti-contains: first sub-expression is single; treating it as a membership test");
|
|
175
|
+
return this.#toArray(sub.value).some((candidate) => this.#equal(candidate, container.value, baseType));
|
|
176
|
+
}
|
|
177
|
+
const haystack = this.#toArray(container.value);
|
|
178
|
+
const needle = this.#toArray(sub.value);
|
|
179
|
+
if (needle.length === 0)
|
|
180
|
+
return true;
|
|
181
|
+
return container.cardinality === "ordered" && sub.cardinality === "ordered" ? this.#containsSubSequence(haystack, needle, baseType) : this.#containsSubMultiset(haystack, needle, baseType);
|
|
182
|
+
}
|
|
183
|
+
#toArray(value) {
|
|
184
|
+
return Array.isArray(value) ? [...value] : [value];
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* `ScoringHelper.compareSingleValues` knows how each base type compares — a
|
|
188
|
+
* `pair` ignoring the order within it, numbers compared numerically. It
|
|
189
|
+
* returns false for a base type it has no case for, so an unknown one falls
|
|
190
|
+
* back to comparing the values as written.
|
|
191
|
+
*/
|
|
192
|
+
#equal(a, b, baseType) {
|
|
193
|
+
return ScoringHelper.compareSingleValues(a, b, baseType) || a === b;
|
|
194
|
+
}
|
|
195
|
+
/** Every needle value present, multiplicity respected, order disregarded. */
|
|
196
|
+
#containsSubMultiset(haystack, needle, baseType) {
|
|
197
|
+
const remaining = [...haystack];
|
|
198
|
+
return needle.every((value) => {
|
|
199
|
+
const index = remaining.findIndex((candidate) => this.#equal(candidate, value, baseType));
|
|
200
|
+
if (index === -1)
|
|
201
|
+
return false;
|
|
202
|
+
remaining.splice(index, 1);
|
|
203
|
+
return true;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/** The needle appearing contiguously, in order, somewhere in the haystack. */
|
|
207
|
+
#containsSubSequence(haystack, needle, baseType) {
|
|
208
|
+
for (let start = 0; start + needle.length <= haystack.length; start++) {
|
|
209
|
+
if (needle.every((value, offset) => this.#equal(haystack[start + offset], value, baseType))) {
|
|
210
|
+
return true;
|
|
169
211
|
}
|
|
170
|
-
} else {
|
|
171
|
-
console.error("unexpected number of children in qti contains");
|
|
172
212
|
}
|
|
173
213
|
return false;
|
|
174
214
|
}
|
|
@@ -223,7 +263,6 @@ var QtiDefault = class extends QtiExpression {
|
|
|
223
263
|
}
|
|
224
264
|
if (itemId) {
|
|
225
265
|
const itemContext2 = this._testContext.items.find((item) => item.identifier === itemId);
|
|
226
|
-
console.debug(`itemContext: ${JSON.stringify(itemContext2)}`);
|
|
227
266
|
if (!this._testContext || !itemContext2) {
|
|
228
267
|
console.warn(`qti-default: item "${itemId}" not found in test context`);
|
|
229
268
|
return null;
|
|
@@ -283,6 +322,10 @@ var QtiDelete = class extends QtiExpression {
|
|
|
283
322
|
|
|
284
323
|
// ../qti-processing/dist/components/qti-divide/qti-divide.js
|
|
285
324
|
var QtiDivide = class extends QtiExpression {
|
|
325
|
+
/** Always a float, even dividing two integers exactly. */
|
|
326
|
+
get resultBaseType() {
|
|
327
|
+
return "float";
|
|
328
|
+
}
|
|
286
329
|
getResult() {
|
|
287
330
|
const values = this.#collectNumericValues(this.getVariables());
|
|
288
331
|
if (values.length !== 2) {
|
|
@@ -480,7 +523,7 @@ var QtiEqualRounded = class extends QtiExpression {
|
|
|
480
523
|
}
|
|
481
524
|
};
|
|
482
525
|
__decorate4([
|
|
483
|
-
property4({ type: String })
|
|
526
|
+
property4({ type: String, attribute: "rounding-mode" })
|
|
484
527
|
], QtiEqualRounded.prototype, "roundingMode", void 0);
|
|
485
528
|
|
|
486
529
|
// ../qti-processing/dist/components/qti-equal/qti-equal.js
|
|
@@ -495,6 +538,18 @@ var QtiEqual = class extends QtiExpression {
|
|
|
495
538
|
constructor() {
|
|
496
539
|
super(...arguments);
|
|
497
540
|
this.toleranceMode = "exact";
|
|
541
|
+
this.tolerance = "";
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Read off the attribute rather than declared as a Lit boolean property: QTI
|
|
545
|
+
* writes `include-lower-bound="false"`, and Lit's boolean converter takes the
|
|
546
|
+
* mere presence of an attribute as true. Both default to true, per the spec.
|
|
547
|
+
*/
|
|
548
|
+
get includeLowerBound() {
|
|
549
|
+
return this.getAttribute("include-lower-bound") !== "false";
|
|
550
|
+
}
|
|
551
|
+
get includeUpperBound() {
|
|
552
|
+
return this.getAttribute("include-upper-bound") !== "false";
|
|
498
553
|
}
|
|
499
554
|
getResult() {
|
|
500
555
|
if (this.children.length === 2) {
|
|
@@ -504,10 +559,6 @@ var QtiEqual = class extends QtiExpression {
|
|
|
504
559
|
if (!value1 || !value2) {
|
|
505
560
|
return null;
|
|
506
561
|
}
|
|
507
|
-
if (this.toleranceMode !== "exact") {
|
|
508
|
-
console.error("toleranceMode is not supported yet");
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
562
|
if (value1.cardinality !== "single" || value2.cardinality !== "single" || Array.isArray(value1.value) || Array.isArray(value2.value)) {
|
|
512
563
|
console.error("unexpected cardinality in qti equal");
|
|
513
564
|
return false;
|
|
@@ -515,36 +566,94 @@ var QtiEqual = class extends QtiExpression {
|
|
|
515
566
|
if (value1.value === null || value2.value === null || value1.value === void 0 || value2.value === void 0) {
|
|
516
567
|
return null;
|
|
517
568
|
}
|
|
518
|
-
|
|
569
|
+
if (this.toleranceMode === "exact") {
|
|
570
|
+
return ScoringHelper.compareSingleValues(value1.value, value2.value, value1.baseType);
|
|
571
|
+
}
|
|
572
|
+
return this.#withinTolerance(parseFloat(value1.value), parseFloat(value2.value));
|
|
519
573
|
}
|
|
520
574
|
console.error("unexpected number of children in qti-equal");
|
|
521
575
|
return null;
|
|
522
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* The tolerant comparison: the *second* expression is the reference value and
|
|
579
|
+
* the tolerance is applied around it, so `equal(x, y)` asks whether x falls in
|
|
580
|
+
* y's tolerance band rather than the other way round.
|
|
581
|
+
*
|
|
582
|
+
* `absolute` takes the tolerances as offsets, `relative` as percentages of the
|
|
583
|
+
* reference. A single tolerance is used on both sides.
|
|
584
|
+
*/
|
|
585
|
+
#withinTolerance(value, reference) {
|
|
586
|
+
if (Number.isNaN(value) || Number.isNaN(reference)) {
|
|
587
|
+
console.error("qti-equal with a tolerance needs numeric values");
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
const tolerances = this.tolerance.split(/\s+/).filter(Boolean).map((t) => parseFloat(t));
|
|
591
|
+
if (tolerances.length === 0 || tolerances.some((t) => Number.isNaN(t))) {
|
|
592
|
+
console.error(`qti-equal with tolerance-mode="${this.toleranceMode}" needs a numeric tolerance`);
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
const [lowerTolerance, upperTolerance = lowerTolerance] = tolerances;
|
|
596
|
+
const [lower, upper] = this.toleranceMode === "absolute" ? [reference - lowerTolerance, reference + upperTolerance] : [reference * (1 - lowerTolerance / 100), reference * (1 + upperTolerance / 100)];
|
|
597
|
+
return (this.includeLowerBound ? value >= lower : value > lower) && (this.includeUpperBound ? value <= upper : value < upper);
|
|
598
|
+
}
|
|
523
599
|
};
|
|
524
600
|
__decorate5([
|
|
525
|
-
property5({ type: String })
|
|
601
|
+
property5({ type: String, attribute: "tolerance-mode" })
|
|
526
602
|
], QtiEqual.prototype, "toleranceMode", void 0);
|
|
603
|
+
__decorate5([
|
|
604
|
+
property5({ type: String })
|
|
605
|
+
], QtiEqual.prototype, "tolerance", void 0);
|
|
606
|
+
|
|
607
|
+
// ../qti-processing/dist/components/qti-rule/qti-rule.js
|
|
608
|
+
import { html, LitElement } from "lit";
|
|
609
|
+
var QtiRule = class extends LitElement {
|
|
610
|
+
render() {
|
|
611
|
+
return html`<slot></slot>`;
|
|
612
|
+
}
|
|
613
|
+
process() {
|
|
614
|
+
throw new Error("Not implemented");
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// ../qti-processing/dist/components/qti-exit-response/qti-exit-response.js
|
|
619
|
+
var QtiExitResponse = class extends QtiRule {
|
|
620
|
+
process() {
|
|
621
|
+
throw new QtiExitResponseSignal();
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
// ../qti-processing/dist/components/qti-exit-test/qti-exit-test.js
|
|
626
|
+
var QtiExitTest = class extends QtiRule {
|
|
627
|
+
process() {
|
|
628
|
+
throw new QtiExitTestSignal();
|
|
629
|
+
}
|
|
630
|
+
};
|
|
527
631
|
|
|
528
632
|
// ../qti-processing/dist/components/qti-field-value/qti-field-value.js
|
|
529
633
|
var QtiFieldValue = class extends QtiExpression {
|
|
634
|
+
/**
|
|
635
|
+
* Every failure here is NULL rather than a thrown error. `qti-is-null` over a
|
|
636
|
+
* `qti-field-value` is the specified way to ask whether a record carries a
|
|
637
|
+
* field at all, so a missing one has to be an ordinary value — throwing
|
|
638
|
+
* aborted the whole response processing run instead.
|
|
639
|
+
*/
|
|
530
640
|
getResult() {
|
|
531
641
|
const fieldIdentifier = this.getAttribute("field-identifier");
|
|
532
642
|
if (!fieldIdentifier) {
|
|
533
|
-
|
|
643
|
+
console.error("qti-field-value requires a field-identifier attribute");
|
|
644
|
+
return null;
|
|
534
645
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
646
|
+
if (this.children.length !== 1) {
|
|
647
|
+
console.error("qti-field-value must have exactly one child expression");
|
|
648
|
+
return null;
|
|
538
649
|
}
|
|
539
650
|
const variable = this.getVariables()[0];
|
|
540
|
-
if (variable.baseType !== "record" || variable.value === null) {
|
|
541
|
-
|
|
651
|
+
if (!variable || variable.baseType !== "record" || variable.value === null || variable.value === void 0) {
|
|
652
|
+
console.warn("qti-field-value child expression must return a record");
|
|
653
|
+
return null;
|
|
542
654
|
}
|
|
543
655
|
const fieldValue = variable.value[fieldIdentifier];
|
|
544
|
-
|
|
545
|
-
throw new Error(`Field "${fieldIdentifier}" not found in record`);
|
|
546
|
-
}
|
|
547
|
-
return fieldValue;
|
|
656
|
+
return fieldValue === void 0 ? null : fieldValue;
|
|
548
657
|
}
|
|
549
658
|
};
|
|
550
659
|
|
|
@@ -678,7 +787,7 @@ var QtiGte = class extends QtiConditionExpression {
|
|
|
678
787
|
return null;
|
|
679
788
|
}
|
|
680
789
|
}
|
|
681
|
-
console.
|
|
790
|
+
console.error("unexpected number of children in qti gte");
|
|
682
791
|
return null;
|
|
683
792
|
}
|
|
684
793
|
};
|
|
@@ -880,6 +989,9 @@ __decorate7([
|
|
|
880
989
|
|
|
881
990
|
// ../qti-processing/dist/components/qti-integer-divide/qti-integer-divide.js
|
|
882
991
|
var QtiIntegerDivide = class extends QtiExpression {
|
|
992
|
+
get resultBaseType() {
|
|
993
|
+
return "integer";
|
|
994
|
+
}
|
|
883
995
|
getResult() {
|
|
884
996
|
const values = this.#collectIntegerValues(this.getVariables());
|
|
885
997
|
if (values.length !== 2) {
|
|
@@ -919,6 +1031,9 @@ var QtiIntegerDivide = class extends QtiExpression {
|
|
|
919
1031
|
|
|
920
1032
|
// ../qti-processing/dist/components/qti-integer-modulus/qti-integer-modulus.js
|
|
921
1033
|
var QtiIntegerModulus = class extends QtiExpression {
|
|
1034
|
+
get resultBaseType() {
|
|
1035
|
+
return "integer";
|
|
1036
|
+
}
|
|
922
1037
|
getResult() {
|
|
923
1038
|
const values = this.#collectIntegerValues(this.getVariables());
|
|
924
1039
|
if (values.length !== 2) {
|
|
@@ -929,7 +1044,7 @@ var QtiIntegerModulus = class extends QtiExpression {
|
|
|
929
1044
|
console.error("qti-integer-modulus: division by zero");
|
|
930
1045
|
return null;
|
|
931
1046
|
}
|
|
932
|
-
return values[0]
|
|
1047
|
+
return values[0] - Math.floor(values[0] / values[1]) * values[1];
|
|
933
1048
|
}
|
|
934
1049
|
#collectIntegerValues(variables) {
|
|
935
1050
|
const values = [];
|
|
@@ -958,6 +1073,9 @@ var QtiIntegerModulus = class extends QtiExpression {
|
|
|
958
1073
|
|
|
959
1074
|
// ../qti-processing/dist/components/qti-integer-to-float/qti-integer-to-float.js
|
|
960
1075
|
var QtiIntegerToFloat = class extends QtiExpression {
|
|
1076
|
+
get resultBaseType() {
|
|
1077
|
+
return "float";
|
|
1078
|
+
}
|
|
961
1079
|
getResult() {
|
|
962
1080
|
const variables = this.getVariables();
|
|
963
1081
|
if (variables.length !== 1) {
|
|
@@ -990,7 +1108,7 @@ var QtiIsNull = class extends QtiExpression {
|
|
|
990
1108
|
getResult() {
|
|
991
1109
|
if (this.children.length === 1) {
|
|
992
1110
|
const variables = this.getVariables();
|
|
993
|
-
if (!variables) {
|
|
1111
|
+
if (!variables?.length) {
|
|
994
1112
|
return true;
|
|
995
1113
|
}
|
|
996
1114
|
const value = variables[0].value;
|
|
@@ -1074,19 +1192,6 @@ var QtiLcm = class extends QtiExpression {
|
|
|
1074
1192
|
// ../qti-processing/dist/components/qti-lookup-outcome-value/qti-lookup-outcome-value.js
|
|
1075
1193
|
import { property as property8, state as state2 } from "lit/decorators.js";
|
|
1076
1194
|
import { consume as consume2 } from "@lit/context";
|
|
1077
|
-
|
|
1078
|
-
// ../qti-processing/dist/components/qti-rule/qti-rule.js
|
|
1079
|
-
import { html, LitElement } from "lit";
|
|
1080
|
-
var QtiRule = class extends LitElement {
|
|
1081
|
-
render() {
|
|
1082
|
-
return html`<slot></slot>`;
|
|
1083
|
-
}
|
|
1084
|
-
process() {
|
|
1085
|
-
throw new Error("Not implemented");
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
|
|
1089
|
-
// ../qti-processing/dist/components/qti-lookup-outcome-value/qti-lookup-outcome-value.js
|
|
1090
1195
|
var __decorate8 = function(decorators, target, key, desc) {
|
|
1091
1196
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1092
1197
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1099,14 +1204,21 @@ var QtiLookupOutcomeValue = class extends QtiRule {
|
|
|
1099
1204
|
}
|
|
1100
1205
|
process() {
|
|
1101
1206
|
const identifier = this.getAttribute("identifier");
|
|
1102
|
-
const outcomeVariable = this.context
|
|
1207
|
+
const outcomeVariable = this.context?.variables.find((v) => v.identifier === identifier) || null;
|
|
1208
|
+
if (!outcomeVariable) {
|
|
1209
|
+
console.warn(`lookupOutcomeValue: no outcome declaration for "${identifier}"`);
|
|
1210
|
+
return null;
|
|
1211
|
+
}
|
|
1212
|
+
const sourceValue = parseFloat(this.childExpression.calculate());
|
|
1103
1213
|
let value;
|
|
1104
|
-
if (outcomeVariable.
|
|
1105
|
-
value = outcomeVariable.
|
|
1214
|
+
if (outcomeVariable.matchTable?.size) {
|
|
1215
|
+
value = outcomeVariable.matchTable.get(sourceValue);
|
|
1216
|
+
} else if (outcomeVariable.interpolationTable) {
|
|
1217
|
+
value = this.#interpolate(sourceValue, outcomeVariable.interpolationTable);
|
|
1106
1218
|
}
|
|
1107
1219
|
if (value === null || value === void 0) {
|
|
1108
|
-
console.warn(
|
|
1109
|
-
return
|
|
1220
|
+
console.warn(`lookupOutcomeValue: no table entry matches ${sourceValue} for "${identifier}"`);
|
|
1221
|
+
return null;
|
|
1110
1222
|
}
|
|
1111
1223
|
this.dispatchEvent(new CustomEvent("qti-set-outcome-value", {
|
|
1112
1224
|
bubbles: true,
|
|
@@ -1118,6 +1230,17 @@ var QtiLookupOutcomeValue = class extends QtiRule {
|
|
|
1118
1230
|
}));
|
|
1119
1231
|
return value;
|
|
1120
1232
|
}
|
|
1233
|
+
/**
|
|
1234
|
+
* An interpolation table entry's `source-value` is the *lower bound* of a
|
|
1235
|
+
* range, not a value to match exactly, and the entries are tested in document
|
|
1236
|
+
* order — the first whose bound the source value clears wins. Tables are
|
|
1237
|
+
* therefore authored from the highest bound down.
|
|
1238
|
+
*/
|
|
1239
|
+
#interpolate(sourceValue, entries) {
|
|
1240
|
+
if (Number.isNaN(sourceValue))
|
|
1241
|
+
return void 0;
|
|
1242
|
+
return entries.find((entry) => entry.includeBoundary ? sourceValue >= entry.sourceValue : sourceValue > entry.sourceValue)?.targetValue;
|
|
1243
|
+
}
|
|
1121
1244
|
};
|
|
1122
1245
|
__decorate8([
|
|
1123
1246
|
property8({ type: String })
|
|
@@ -1159,7 +1282,7 @@ var QtiLte = class extends QtiConditionExpression {
|
|
|
1159
1282
|
return null;
|
|
1160
1283
|
}
|
|
1161
1284
|
}
|
|
1162
|
-
console.
|
|
1285
|
+
console.error("unexpected number of children in qti lte");
|
|
1163
1286
|
return null;
|
|
1164
1287
|
}
|
|
1165
1288
|
};
|
|
@@ -1200,6 +1323,7 @@ var QtiMapResponsePoint = class extends QtiExpression {
|
|
|
1200
1323
|
if (isPointInArea) {
|
|
1201
1324
|
result += entry.mappedValue ?? 0;
|
|
1202
1325
|
mappedAreas.add(entry.coords);
|
|
1326
|
+
break;
|
|
1203
1327
|
}
|
|
1204
1328
|
}
|
|
1205
1329
|
}
|
|
@@ -1350,7 +1474,7 @@ var QtiMatch = class _QtiMatch extends QtiExpression {
|
|
|
1350
1474
|
}
|
|
1351
1475
|
};
|
|
1352
1476
|
|
|
1353
|
-
// ../qti-processing/dist/components/qti-math-
|
|
1477
|
+
// ../qti-processing/dist/components/qti-math-constant/qti-math-constant.js
|
|
1354
1478
|
import { property as property11 } from "lit/decorators.js";
|
|
1355
1479
|
var __decorate11 = function(decorators, target, key, desc) {
|
|
1356
1480
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1358,11 +1482,50 @@ var __decorate11 = function(decorators, target, key, desc) {
|
|
|
1358
1482
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1359
1483
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1360
1484
|
};
|
|
1485
|
+
var QtiMathConstant = class extends QtiExpression {
|
|
1486
|
+
constructor() {
|
|
1487
|
+
super(...arguments);
|
|
1488
|
+
this.name = "";
|
|
1489
|
+
}
|
|
1490
|
+
get resultBaseType() {
|
|
1491
|
+
return "float";
|
|
1492
|
+
}
|
|
1493
|
+
getResult() {
|
|
1494
|
+
switch (this.name.toLowerCase()) {
|
|
1495
|
+
case "pi":
|
|
1496
|
+
return Math.PI;
|
|
1497
|
+
case "e":
|
|
1498
|
+
return Math.E;
|
|
1499
|
+
default:
|
|
1500
|
+
console.error(`qti-math-constant: unknown constant "${this.name}"`);
|
|
1501
|
+
return null;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
__decorate11([
|
|
1506
|
+
property11({ type: String })
|
|
1507
|
+
], QtiMathConstant.prototype, "name", void 0);
|
|
1508
|
+
|
|
1509
|
+
// ../qti-processing/dist/components/qti-math-operator/qti-math-operator.js
|
|
1510
|
+
import { property as property12 } from "lit/decorators.js";
|
|
1511
|
+
var __decorate12 = function(decorators, target, key, desc) {
|
|
1512
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1513
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1514
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1515
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1516
|
+
};
|
|
1361
1517
|
var QtiMathOperator = class extends QtiExpression {
|
|
1362
1518
|
constructor() {
|
|
1363
1519
|
super(...arguments);
|
|
1364
1520
|
this.name = "";
|
|
1365
1521
|
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Float for every function except the three that produce a whole number:
|
|
1524
|
+
* `floor`, `ceil` and `signum`.
|
|
1525
|
+
*/
|
|
1526
|
+
get resultBaseType() {
|
|
1527
|
+
return ["floor", "ceil", "signum"].includes(this.name?.toLowerCase()) ? "integer" : "float";
|
|
1528
|
+
}
|
|
1366
1529
|
getResult() {
|
|
1367
1530
|
if (!this.name) {
|
|
1368
1531
|
console.error("qti-math-operator requires a name attribute");
|
|
@@ -1398,6 +1561,10 @@ var QtiMathOperator = class extends QtiExpression {
|
|
|
1398
1561
|
}
|
|
1399
1562
|
return this.#performOperation(this.name, values);
|
|
1400
1563
|
}
|
|
1564
|
+
/** A function with no finite result at this argument is NULL, not Infinity. */
|
|
1565
|
+
#finite(value) {
|
|
1566
|
+
return Number.isFinite(value) ? value : null;
|
|
1567
|
+
}
|
|
1401
1568
|
#performOperation(operation, values) {
|
|
1402
1569
|
try {
|
|
1403
1570
|
switch (operation.toLowerCase()) {
|
|
@@ -1442,12 +1609,43 @@ var QtiMathOperator = class extends QtiExpression {
|
|
|
1442
1609
|
if (values.length !== 1)
|
|
1443
1610
|
return null;
|
|
1444
1611
|
return Math.tanh(values[0]);
|
|
1612
|
+
// Reciprocal trigonometric functions. Accepted under both the long
|
|
1613
|
+
// names the QTI vocabulary spells out and the short ones items use in
|
|
1614
|
+
// practice. Each is NULL where its reciprocal is undefined, which
|
|
1615
|
+
// #finite catches as a non-finite result.
|
|
1616
|
+
case "secant":
|
|
1617
|
+
case "sec":
|
|
1618
|
+
if (values.length !== 1)
|
|
1619
|
+
return null;
|
|
1620
|
+
return this.#finite(1 / Math.cos(values[0]));
|
|
1621
|
+
case "cosecant":
|
|
1622
|
+
case "csc":
|
|
1623
|
+
if (values.length !== 1)
|
|
1624
|
+
return null;
|
|
1625
|
+
return this.#finite(1 / Math.sin(values[0]));
|
|
1626
|
+
case "cotangent":
|
|
1627
|
+
case "cot":
|
|
1628
|
+
if (values.length !== 1)
|
|
1629
|
+
return null;
|
|
1630
|
+
return this.#finite(Math.cos(values[0]) / Math.sin(values[0]));
|
|
1631
|
+
// Angle conversions. Every other function here works in radians.
|
|
1632
|
+
case "todegrees":
|
|
1633
|
+
if (values.length !== 1)
|
|
1634
|
+
return null;
|
|
1635
|
+
return values[0] * 180 / Math.PI;
|
|
1636
|
+
case "toradians":
|
|
1637
|
+
if (values.length !== 1)
|
|
1638
|
+
return null;
|
|
1639
|
+
return values[0] * Math.PI / 180;
|
|
1640
|
+
// `log` is the base-10 logarithm per the QTI vocabulary; `ln` is the
|
|
1641
|
+
// natural one. They are not interchangeable — this used to return the
|
|
1642
|
+
// natural log for both.
|
|
1445
1643
|
case "log":
|
|
1446
1644
|
if (values.length !== 1)
|
|
1447
1645
|
return null;
|
|
1448
1646
|
if (values[0] <= 0)
|
|
1449
1647
|
return null;
|
|
1450
|
-
return Math.
|
|
1648
|
+
return Math.log10(values[0]);
|
|
1451
1649
|
case "ln":
|
|
1452
1650
|
if (values.length !== 1)
|
|
1453
1651
|
return null;
|
|
@@ -1544,8 +1742,8 @@ var QtiMathOperator = class extends QtiExpression {
|
|
|
1544
1742
|
}
|
|
1545
1743
|
}
|
|
1546
1744
|
};
|
|
1547
|
-
|
|
1548
|
-
|
|
1745
|
+
__decorate12([
|
|
1746
|
+
property12({ type: String })
|
|
1549
1747
|
], QtiMathOperator.prototype, "name", void 0);
|
|
1550
1748
|
|
|
1551
1749
|
// ../qti-processing/dist/components/qti-max/qti-max.js
|
|
@@ -1654,7 +1852,6 @@ var QtiMin = class extends QtiExpression {
|
|
|
1654
1852
|
// ../qti-processing/dist/components/qti-multiple/qti-multiple.js
|
|
1655
1853
|
var QtiMultiple = class extends QtiExpression {
|
|
1656
1854
|
getResult() {
|
|
1657
|
-
console.debug("qti-multiple getResult called", this.innerHTML);
|
|
1658
1855
|
const variables = this.getVariables();
|
|
1659
1856
|
if (variables.length === 0) {
|
|
1660
1857
|
console.error("unexpected number of children in qti multiple");
|
|
@@ -1808,8 +2005,8 @@ var QtiOutcomeElse = class extends QtiConditionElseBase {
|
|
|
1808
2005
|
};
|
|
1809
2006
|
|
|
1810
2007
|
// ../qti-processing/dist/components/qti-pattern-match/qti-pattern-match.js
|
|
1811
|
-
import { property as
|
|
1812
|
-
var
|
|
2008
|
+
import { property as property13 } from "lit/decorators.js";
|
|
2009
|
+
var __decorate13 = function(decorators, target, key, desc) {
|
|
1813
2010
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1814
2011
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1815
2012
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -1838,20 +2035,46 @@ var QtiPatternMatch = class extends QtiExpression {
|
|
|
1838
2035
|
if (variable.value === null || variable.value === void 0) {
|
|
1839
2036
|
return null;
|
|
1840
2037
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
} catch (error) {
|
|
1844
|
-
console.error("qti-pattern-match requires a valid regular expression", error);
|
|
2038
|
+
const anchored = this.#compile();
|
|
2039
|
+
if (!anchored) {
|
|
1845
2040
|
return null;
|
|
1846
2041
|
}
|
|
2042
|
+
return anchored.test(variable.value.toString());
|
|
2043
|
+
}
|
|
2044
|
+
/**
|
|
2045
|
+
* XML Schema pattern semantics: the pattern has to match the *whole* value,
|
|
2046
|
+
* not appear somewhere inside it. Without the anchors a pattern like `[0-9]+`
|
|
2047
|
+
* accepts "abc123". The pattern is wrapped in a group so a top-level `|`
|
|
2048
|
+
* cannot escape them — `a|b` has to anchor as `^(?:a|b)$`.
|
|
2049
|
+
*
|
|
2050
|
+
* Compiled with the unicode flag first, because XML Schema allows `\p{L}`
|
|
2051
|
+
* category escapes and those only mean anything under `u`. That flag also
|
|
2052
|
+
* rejects escapes JavaScript otherwise tolerates, so a pattern it refuses is
|
|
2053
|
+
* retried without it rather than failing the whole comparison.
|
|
2054
|
+
*/
|
|
2055
|
+
#compile() {
|
|
2056
|
+
const source = `^(?:${this.pattern})$`;
|
|
2057
|
+
try {
|
|
2058
|
+
return new RegExp(source, "u");
|
|
2059
|
+
} catch {
|
|
2060
|
+
try {
|
|
2061
|
+
return new RegExp(source);
|
|
2062
|
+
} catch (error) {
|
|
2063
|
+
console.error("qti-pattern-match requires a valid regular expression", error);
|
|
2064
|
+
return null;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
1847
2067
|
}
|
|
1848
2068
|
};
|
|
1849
|
-
|
|
1850
|
-
|
|
2069
|
+
__decorate13([
|
|
2070
|
+
property13({ type: String })
|
|
1851
2071
|
], QtiPatternMatch.prototype, "pattern", void 0);
|
|
1852
2072
|
|
|
1853
2073
|
// ../qti-processing/dist/components/qti-power/qti-power.js
|
|
1854
2074
|
var QtiPower = class extends QtiExpression {
|
|
2075
|
+
get resultBaseType() {
|
|
2076
|
+
return "float";
|
|
2077
|
+
}
|
|
1855
2078
|
getResult() {
|
|
1856
2079
|
if (this.children.length !== 2) {
|
|
1857
2080
|
console.error("qti-power must have exactly two child expressions");
|
|
@@ -1924,7 +2147,7 @@ var QtiPower = class extends QtiExpression {
|
|
|
1924
2147
|
// ../qti-processing/dist/components/qti-printed-variable/qti-printed-variable.js
|
|
1925
2148
|
import { consume as consume3 } from "@lit/context";
|
|
1926
2149
|
import { LitElement as LitElement3, html as html4, nothing } from "lit";
|
|
1927
|
-
import { property as
|
|
2150
|
+
import { property as property14, state as state3 } from "lit/decorators.js";
|
|
1928
2151
|
|
|
1929
2152
|
// ../qti-processing/dist/components/qti-printed-variable/printed-variable-format.js
|
|
1930
2153
|
var CONVERSION = /%(?:(%)|([-+ 0#]*)(\d+)?(?:\.(\d+))?([diuoxXfFeEgGsc]))/g;
|
|
@@ -2020,7 +2243,7 @@ function applyFormat(format, value) {
|
|
|
2020
2243
|
}
|
|
2021
2244
|
|
|
2022
2245
|
// ../qti-processing/dist/components/qti-printed-variable/qti-printed-variable.js
|
|
2023
|
-
var
|
|
2246
|
+
var __decorate14 = function(decorators, target, key, desc) {
|
|
2024
2247
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2025
2248
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2026
2249
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2087,31 +2310,31 @@ var QtiPrintedVariable = class extends LitElement3 {
|
|
|
2087
2310
|
return result;
|
|
2088
2311
|
}
|
|
2089
2312
|
};
|
|
2090
|
-
|
|
2091
|
-
|
|
2313
|
+
__decorate14([
|
|
2314
|
+
property14({ type: String })
|
|
2092
2315
|
], QtiPrintedVariable.prototype, "identifier", void 0);
|
|
2093
|
-
|
|
2094
|
-
|
|
2316
|
+
__decorate14([
|
|
2317
|
+
property14({ type: String })
|
|
2095
2318
|
], QtiPrintedVariable.prototype, "format", void 0);
|
|
2096
|
-
|
|
2097
|
-
|
|
2319
|
+
__decorate14([
|
|
2320
|
+
property14({ type: Number })
|
|
2098
2321
|
], QtiPrintedVariable.prototype, "base", void 0);
|
|
2099
|
-
|
|
2100
|
-
|
|
2322
|
+
__decorate14([
|
|
2323
|
+
property14({ type: Number })
|
|
2101
2324
|
], QtiPrintedVariable.prototype, "index", void 0);
|
|
2102
|
-
|
|
2103
|
-
|
|
2325
|
+
__decorate14([
|
|
2326
|
+
property14({ type: Boolean, attribute: "power-form" })
|
|
2104
2327
|
], QtiPrintedVariable.prototype, "powerForm", void 0);
|
|
2105
|
-
|
|
2106
|
-
|
|
2328
|
+
__decorate14([
|
|
2329
|
+
property14({ type: String })
|
|
2107
2330
|
], QtiPrintedVariable.prototype, "field", void 0);
|
|
2108
|
-
|
|
2109
|
-
|
|
2331
|
+
__decorate14([
|
|
2332
|
+
property14({ type: String })
|
|
2110
2333
|
], QtiPrintedVariable.prototype, "delimiter", void 0);
|
|
2111
|
-
|
|
2112
|
-
|
|
2334
|
+
__decorate14([
|
|
2335
|
+
property14({ type: String, attribute: "mapping-indicator" })
|
|
2113
2336
|
], QtiPrintedVariable.prototype, "mappingIndicator", void 0);
|
|
2114
|
-
|
|
2337
|
+
__decorate14([
|
|
2115
2338
|
consume3({ context: itemContext, subscribe: true }),
|
|
2116
2339
|
state3()
|
|
2117
2340
|
], QtiPrintedVariable.prototype, "context", void 0);
|
|
@@ -2137,8 +2360,8 @@ var QtiProduct = class extends QtiExpression {
|
|
|
2137
2360
|
};
|
|
2138
2361
|
|
|
2139
2362
|
// ../qti-processing/dist/components/qti-random-integer/qti-random-integer.js
|
|
2140
|
-
import { property as
|
|
2141
|
-
var
|
|
2363
|
+
import { property as property15 } from "lit/decorators.js";
|
|
2364
|
+
var __decorate15 = function(decorators, target, key, desc) {
|
|
2142
2365
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2143
2366
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2144
2367
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2201,14 +2424,14 @@ var QtiRandomInteger = class extends QtiExpression {
|
|
|
2201
2424
|
return possibleValues.length > 0 ? possibleValues : [Number.isInteger(this.min) ? this.min : Math.floor(this.min)];
|
|
2202
2425
|
}
|
|
2203
2426
|
};
|
|
2204
|
-
|
|
2205
|
-
|
|
2427
|
+
__decorate15([
|
|
2428
|
+
property15({ type: Number })
|
|
2206
2429
|
], QtiRandomInteger.prototype, "min", void 0);
|
|
2207
|
-
|
|
2208
|
-
|
|
2430
|
+
__decorate15([
|
|
2431
|
+
property15({ type: Number })
|
|
2209
2432
|
], QtiRandomInteger.prototype, "max", void 0);
|
|
2210
|
-
|
|
2211
|
-
|
|
2433
|
+
__decorate15([
|
|
2434
|
+
property15({ type: Number })
|
|
2212
2435
|
], QtiRandomInteger.prototype, "step", void 0);
|
|
2213
2436
|
|
|
2214
2437
|
// ../qti-processing/dist/components/qti-random/qti-random.js
|
|
@@ -2229,13 +2452,14 @@ var QtiRandom = class extends QtiExpression {
|
|
|
2229
2452
|
};
|
|
2230
2453
|
|
|
2231
2454
|
// ../qti-processing/dist/components/qti-repeat/qti-repeat.js
|
|
2232
|
-
import { property as
|
|
2233
|
-
var
|
|
2455
|
+
import { property as property16 } from "lit/decorators.js";
|
|
2456
|
+
var __decorate16 = function(decorators, target, key, desc) {
|
|
2234
2457
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2235
2458
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2236
2459
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2237
2460
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2238
2461
|
};
|
|
2462
|
+
var MAX_REPEATS = 1e3;
|
|
2239
2463
|
var QtiRepeat = class extends QtiExpression {
|
|
2240
2464
|
constructor() {
|
|
2241
2465
|
super(...arguments);
|
|
@@ -2268,7 +2492,7 @@ var QtiRepeat = class extends QtiExpression {
|
|
|
2268
2492
|
}
|
|
2269
2493
|
const numericCount = parseInt(this.numberRepeats, 10);
|
|
2270
2494
|
if (!Number.isNaN(numericCount)) {
|
|
2271
|
-
return numericCount;
|
|
2495
|
+
return this.#cap(numericCount);
|
|
2272
2496
|
}
|
|
2273
2497
|
const identifier = this.numberRepeats;
|
|
2274
2498
|
const variable = this.context?.variables?.find((v) => v.identifier === identifier);
|
|
@@ -2282,7 +2506,14 @@ var QtiRepeat = class extends QtiExpression {
|
|
|
2282
2506
|
console.warn(`qti-repeat: invalid repeat count from "${identifier}"`);
|
|
2283
2507
|
return 0;
|
|
2284
2508
|
}
|
|
2285
|
-
return resolvedCount;
|
|
2509
|
+
return this.#cap(resolvedCount);
|
|
2510
|
+
}
|
|
2511
|
+
#cap(count) {
|
|
2512
|
+
if (count > MAX_REPEATS) {
|
|
2513
|
+
console.warn(`qti-repeat: number-repeats ${count} exceeds the ${MAX_REPEATS} limit, truncating`);
|
|
2514
|
+
return MAX_REPEATS;
|
|
2515
|
+
}
|
|
2516
|
+
return count;
|
|
2286
2517
|
}
|
|
2287
2518
|
#toResponseVariable(value) {
|
|
2288
2519
|
if (value === null || value === void 0) {
|
|
@@ -2328,8 +2559,8 @@ var QtiRepeat = class extends QtiExpression {
|
|
|
2328
2559
|
};
|
|
2329
2560
|
}
|
|
2330
2561
|
};
|
|
2331
|
-
|
|
2332
|
-
|
|
2562
|
+
__decorate16([
|
|
2563
|
+
property16({ type: String, attribute: "number-repeats" })
|
|
2333
2564
|
], QtiRepeat.prototype, "numberRepeats", void 0);
|
|
2334
2565
|
|
|
2335
2566
|
// ../qti-processing/dist/components/qti-response-condition/qti-response-condition.js
|
|
@@ -2348,9 +2579,18 @@ var QtiResponseElseIf = class extends QtiResponseIf {
|
|
|
2348
2579
|
var QtiResponseElse = class extends QtiConditionElseBase {
|
|
2349
2580
|
};
|
|
2350
2581
|
|
|
2582
|
+
// ../qti-processing/dist/components/qti-response-processing-fragment/qti-response-processing-fragment.js
|
|
2583
|
+
var QtiResponseProcessingFragment = class extends QtiRule {
|
|
2584
|
+
process() {
|
|
2585
|
+
for (const rule of [...this.children]) {
|
|
2586
|
+
rule.process();
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
};
|
|
2590
|
+
|
|
2351
2591
|
// ../qti-processing/dist/components/qti-round-to/qti-round-to.js
|
|
2352
|
-
import { property as
|
|
2353
|
-
var
|
|
2592
|
+
import { property as property17 } from "lit/decorators.js";
|
|
2593
|
+
var __decorate17 = function(decorators, target, key, desc) {
|
|
2354
2594
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2355
2595
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2356
2596
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2362,6 +2602,9 @@ var QtiRoundTo = class extends QtiExpression {
|
|
|
2362
2602
|
this.roundingMode = "significantFigures";
|
|
2363
2603
|
this.figures = 3;
|
|
2364
2604
|
}
|
|
2605
|
+
get resultBaseType() {
|
|
2606
|
+
return "float";
|
|
2607
|
+
}
|
|
2365
2608
|
getResult() {
|
|
2366
2609
|
if (this.children.length !== 1) {
|
|
2367
2610
|
console.error("qti-round-to must have exactly one child expression");
|
|
@@ -2436,15 +2679,18 @@ var QtiRoundTo = class extends QtiExpression {
|
|
|
2436
2679
|
return Math.round(value * multiplier) / multiplier;
|
|
2437
2680
|
}
|
|
2438
2681
|
};
|
|
2439
|
-
|
|
2440
|
-
|
|
2682
|
+
__decorate17([
|
|
2683
|
+
property17({ type: String, attribute: "rounding-mode" })
|
|
2441
2684
|
], QtiRoundTo.prototype, "roundingMode", void 0);
|
|
2442
|
-
|
|
2443
|
-
|
|
2685
|
+
__decorate17([
|
|
2686
|
+
property17({ type: Number })
|
|
2444
2687
|
], QtiRoundTo.prototype, "figures", void 0);
|
|
2445
2688
|
|
|
2446
2689
|
// ../qti-processing/dist/components/qti-round/qti-round.js
|
|
2447
2690
|
var QtiRound = class extends QtiExpression {
|
|
2691
|
+
get resultBaseType() {
|
|
2692
|
+
return "integer";
|
|
2693
|
+
}
|
|
2448
2694
|
getResult() {
|
|
2449
2695
|
if (this.children.length !== 1) {
|
|
2450
2696
|
console.error("qti-round must have exactly one child expression");
|
|
@@ -2685,8 +2931,8 @@ var QtiSetTemplateValueRule = class {
|
|
|
2685
2931
|
};
|
|
2686
2932
|
|
|
2687
2933
|
// ../qti-processing/dist/components/qti-stats-operator/qti-stats-operator.js
|
|
2688
|
-
import { property as
|
|
2689
|
-
var
|
|
2934
|
+
import { property as property18 } from "lit/decorators.js";
|
|
2935
|
+
var __decorate18 = function(decorators, target, key, desc) {
|
|
2690
2936
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2691
2937
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2692
2938
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2697,6 +2943,9 @@ var QtiStatsOperator = class extends QtiExpression {
|
|
|
2697
2943
|
super(...arguments);
|
|
2698
2944
|
this.name = "";
|
|
2699
2945
|
}
|
|
2946
|
+
get resultBaseType() {
|
|
2947
|
+
return "float";
|
|
2948
|
+
}
|
|
2700
2949
|
getResult() {
|
|
2701
2950
|
if (!this.name) {
|
|
2702
2951
|
console.warn("qti-stats-operator: missing name attribute");
|
|
@@ -2709,18 +2958,34 @@ var QtiStatsOperator = class extends QtiExpression {
|
|
|
2709
2958
|
}
|
|
2710
2959
|
switch (this.name.toLowerCase()) {
|
|
2711
2960
|
case "mean":
|
|
2712
|
-
return values
|
|
2961
|
+
return this.#mean(values);
|
|
2962
|
+
case "median":
|
|
2963
|
+
return this.#median(values);
|
|
2964
|
+
case "popvariance":
|
|
2965
|
+
return this.#variance(values, values.length);
|
|
2713
2966
|
case "popsd":
|
|
2714
|
-
return this.#
|
|
2967
|
+
return Math.sqrt(this.#variance(values, values.length));
|
|
2968
|
+
case "samplevariance":
|
|
2969
|
+
return values.length < 2 ? null : this.#variance(values, values.length - 1);
|
|
2970
|
+
case "samplesd":
|
|
2971
|
+
return values.length < 2 ? null : Math.sqrt(this.#variance(values, values.length - 1));
|
|
2715
2972
|
default:
|
|
2716
2973
|
console.warn(`qti-stats-operator: unsupported operator "${this.name}"`);
|
|
2717
2974
|
return null;
|
|
2718
2975
|
}
|
|
2719
2976
|
}
|
|
2720
|
-
#
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2977
|
+
#mean(values) {
|
|
2978
|
+
return values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
2979
|
+
}
|
|
2980
|
+
#median(values) {
|
|
2981
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
2982
|
+
const middle = Math.floor(sorted.length / 2);
|
|
2983
|
+
return sorted.length % 2 === 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle];
|
|
2984
|
+
}
|
|
2985
|
+
/** Sum of squared deviations over `denominator` — the population or sample divisor. */
|
|
2986
|
+
#variance(values, denominator) {
|
|
2987
|
+
const mean = this.#mean(values);
|
|
2988
|
+
return values.reduce((sum, value) => sum + Math.pow(value - mean, 2), 0) / denominator;
|
|
2724
2989
|
}
|
|
2725
2990
|
#collectNumericValues(variables) {
|
|
2726
2991
|
const values = [];
|
|
@@ -2748,13 +3013,13 @@ var QtiStatsOperator = class extends QtiExpression {
|
|
|
2748
3013
|
return values;
|
|
2749
3014
|
}
|
|
2750
3015
|
};
|
|
2751
|
-
|
|
2752
|
-
|
|
3016
|
+
__decorate18([
|
|
3017
|
+
property18({ type: String })
|
|
2753
3018
|
], QtiStatsOperator.prototype, "name", void 0);
|
|
2754
3019
|
|
|
2755
3020
|
// ../qti-processing/dist/components/qti-string-match/qti-string-match.js
|
|
2756
|
-
import { property as
|
|
2757
|
-
var
|
|
3021
|
+
import { property as property19 } from "lit/decorators.js";
|
|
3022
|
+
var __decorate19 = function(decorators, target, key, desc) {
|
|
2758
3023
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2759
3024
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2760
3025
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2782,13 +3047,13 @@ var QtiStringMatch = class extends QtiExpression {
|
|
|
2782
3047
|
return null;
|
|
2783
3048
|
}
|
|
2784
3049
|
};
|
|
2785
|
-
|
|
2786
|
-
|
|
3050
|
+
__decorate19([
|
|
3051
|
+
property19({ type: String, attribute: "case-sensitive" })
|
|
2787
3052
|
], QtiStringMatch.prototype, "caseSensitive", void 0);
|
|
2788
3053
|
|
|
2789
3054
|
// ../qti-processing/dist/components/qti-substring/qti-substring.js
|
|
2790
|
-
import { property as
|
|
2791
|
-
var
|
|
3055
|
+
import { property as property20 } from "lit/decorators.js";
|
|
3056
|
+
var __decorate20 = function(decorators, target, key, desc) {
|
|
2792
3057
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2793
3058
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2794
3059
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2821,8 +3086,8 @@ var QtiSubstring = class extends QtiExpression {
|
|
|
2821
3086
|
return right.includes(left);
|
|
2822
3087
|
}
|
|
2823
3088
|
};
|
|
2824
|
-
|
|
2825
|
-
|
|
3089
|
+
__decorate20([
|
|
3090
|
+
property20({ type: String, attribute: "case-sensitive" })
|
|
2826
3091
|
], QtiSubstring.prototype, "caseSensitive", void 0);
|
|
2827
3092
|
|
|
2828
3093
|
// ../qti-processing/dist/components/qti-subtract/qti-subtract.js
|
|
@@ -2887,6 +3152,9 @@ var QtiSumExpression = class {
|
|
|
2887
3152
|
|
|
2888
3153
|
// ../qti-processing/dist/components/qti-truncate/qti-truncate.js
|
|
2889
3154
|
var QtiTruncate = class extends QtiExpression {
|
|
3155
|
+
get resultBaseType() {
|
|
3156
|
+
return "integer";
|
|
3157
|
+
}
|
|
2890
3158
|
getResult() {
|
|
2891
3159
|
const variables = this.getVariables();
|
|
2892
3160
|
if (variables.length !== 1) {
|
|
@@ -2937,6 +3205,8 @@ var qtiProcessingElements = [
|
|
|
2937
3205
|
{ tag: "qti-duration-lt", ctor: QtiDurationLt },
|
|
2938
3206
|
{ tag: "qti-equal", ctor: QtiEqual },
|
|
2939
3207
|
{ tag: "qti-equal-rounded", ctor: QtiEqualRounded },
|
|
3208
|
+
{ tag: "qti-exit-response", ctor: QtiExitResponse },
|
|
3209
|
+
{ tag: "qti-exit-test", ctor: QtiExitTest },
|
|
2940
3210
|
{ tag: "qti-field-value", ctor: QtiFieldValue },
|
|
2941
3211
|
{ tag: "qti-gcd", ctor: QtiGcd },
|
|
2942
3212
|
{ tag: "qti-gt", ctor: QtiGt },
|
|
@@ -2954,6 +3224,7 @@ var qtiProcessingElements = [
|
|
|
2954
3224
|
{ tag: "qti-map-response", ctor: QtiMapResponse },
|
|
2955
3225
|
{ tag: "qti-map-response-point", ctor: QtiMapResponsePoint },
|
|
2956
3226
|
{ tag: "qti-match", ctor: QtiMatch },
|
|
3227
|
+
{ tag: "qti-math-constant", ctor: QtiMathConstant },
|
|
2957
3228
|
{ tag: "qti-math-operator", ctor: QtiMathOperator },
|
|
2958
3229
|
{ tag: "qti-max", ctor: QtiMax },
|
|
2959
3230
|
{ tag: "qti-member", ctor: QtiMember },
|
|
@@ -2978,6 +3249,7 @@ var qtiProcessingElements = [
|
|
|
2978
3249
|
{ tag: "qti-response-else", ctor: QtiResponseElse },
|
|
2979
3250
|
{ tag: "qti-response-else-if", ctor: QtiResponseElseIf },
|
|
2980
3251
|
{ tag: "qti-response-if", ctor: QtiResponseIf },
|
|
3252
|
+
{ tag: "qti-response-processing-fragment", ctor: QtiResponseProcessingFragment },
|
|
2981
3253
|
{ tag: "qti-round", ctor: QtiRound },
|
|
2982
3254
|
{ tag: "qti-round-to", ctor: QtiRoundTo },
|
|
2983
3255
|
{ tag: "qti-rule", ctor: QtiRule },
|
|
@@ -3008,6 +3280,8 @@ export {
|
|
|
3008
3280
|
QtiDurationLt,
|
|
3009
3281
|
QtiEqualRounded,
|
|
3010
3282
|
QtiEqual,
|
|
3283
|
+
QtiExitResponse,
|
|
3284
|
+
QtiExitTest,
|
|
3011
3285
|
QtiFieldValue,
|
|
3012
3286
|
QtiGcd,
|
|
3013
3287
|
QtiGt,
|
|
@@ -3025,6 +3299,7 @@ export {
|
|
|
3025
3299
|
QtiMapResponsePoint,
|
|
3026
3300
|
QtiMapResponse,
|
|
3027
3301
|
QtiMatch,
|
|
3302
|
+
QtiMathConstant,
|
|
3028
3303
|
QtiMathOperator,
|
|
3029
3304
|
QtiMax,
|
|
3030
3305
|
QtiMember,
|
|
@@ -3049,6 +3324,7 @@ export {
|
|
|
3049
3324
|
QtiResponseIf,
|
|
3050
3325
|
QtiResponseElseIf,
|
|
3051
3326
|
QtiResponseElse,
|
|
3327
|
+
QtiResponseProcessingFragment,
|
|
3052
3328
|
QtiRoundTo,
|
|
3053
3329
|
QtiRound,
|
|
3054
3330
|
QtiSetCorrectResponse,
|
|
@@ -3068,4 +3344,4 @@ export {
|
|
|
3068
3344
|
QtiVariable,
|
|
3069
3345
|
qtiProcessingElements
|
|
3070
3346
|
};
|
|
3071
|
-
//# sourceMappingURL=chunk-
|
|
3347
|
+
//# sourceMappingURL=chunk-G5RQ5GKG.js.map
|