@qti-components/processing 1.1.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/LICENSE.md +674 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.js +44 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/qti-and/qti-and.d.ts +20 -0
- package/dist/components/qti-and/qti-and.js +56 -0
- package/dist/components/qti-and/qti-and.js.map +1 -0
- package/dist/components/qti-basevalue/qti-basevalue.d.ts +6 -0
- package/dist/components/qti-basevalue/qti-basevalue.js +23 -0
- package/dist/components/qti-basevalue/qti-basevalue.js.map +1 -0
- package/dist/components/qti-container-size/qti-container-size.d.ts +12 -0
- package/dist/components/qti-container-size/qti-container-size.js +40 -0
- package/dist/components/qti-container-size/qti-container-size.js.map +1 -0
- package/dist/components/qti-contains/qti-contains.d.ts +4 -0
- package/dist/components/qti-contains/qti-contains.js +38 -0
- package/dist/components/qti-contains/qti-contains.js.map +1 -0
- package/dist/components/qti-correct/qti-correct.d.ts +5 -0
- package/dist/components/qti-correct/qti-correct.js +18 -0
- package/dist/components/qti-correct/qti-correct.js.map +1 -0
- package/dist/components/qti-default/qti-default.d.ts +17 -0
- package/dist/components/qti-default/qti-default.js +87 -0
- package/dist/components/qti-default/qti-default.js.map +1 -0
- package/dist/components/qti-delete/qti-delete.d.ts +4 -0
- package/dist/components/qti-delete/qti-delete.js +23 -0
- package/dist/components/qti-delete/qti-delete.js.map +1 -0
- package/dist/components/qti-equal/qti-equal.d.ts +5 -0
- package/dist/components/qti-equal/qti-equal.js +41 -0
- package/dist/components/qti-equal/qti-equal.js.map +1 -0
- package/dist/components/qti-equal-rounded/qti-equal-rounded.d.ts +6 -0
- package/dist/components/qti-equal-rounded/qti-equal-rounded.js +84 -0
- package/dist/components/qti-equal-rounded/qti-equal-rounded.js.map +1 -0
- package/dist/components/qti-field-value/qti-field-value.d.ts +4 -0
- package/dist/components/qti-field-value/qti-field-value.js +27 -0
- package/dist/components/qti-field-value/qti-field-value.js.map +1 -0
- package/dist/components/qti-gcd/qti.gcd.d.ts +13 -0
- package/dist/components/qti-gcd/qti.gcd.js +119 -0
- package/dist/components/qti-gcd/qti.gcd.js.map +1 -0
- package/dist/components/qti-gt/qti-gt.d.ts +4 -0
- package/dist/components/qti-gt/qti-gt.js +21 -0
- package/dist/components/qti-gt/qti-gt.js.map +1 -0
- package/dist/components/qti-gte/qti-gte.d.ts +4 -0
- package/dist/components/qti-gte/qti-gte.js +24 -0
- package/dist/components/qti-gte/qti-gte.js.map +1 -0
- package/dist/components/qti-index/qti-index.d.ts +6 -0
- package/dist/components/qti-index/qti-index.js +82 -0
- package/dist/components/qti-index/qti-index.js.map +1 -0
- package/dist/components/qti-is-null/qti-is-null.d.ts +4 -0
- package/dist/components/qti-is-null/qti-is-null.js +19 -0
- package/dist/components/qti-is-null/qti-is-null.js.map +1 -0
- package/dist/components/qti-lookup-outcome-value/qti-lookup-outcome-value.d.ts +19 -0
- package/dist/components/qti-lookup-outcome-value/qti-lookup-outcome-value.js +51 -0
- package/dist/components/qti-lookup-outcome-value/qti-lookup-outcome-value.js.map +1 -0
- package/dist/components/qti-lt/qti-lt.d.ts +4 -0
- package/dist/components/qti-lt/qti-lt.js +21 -0
- package/dist/components/qti-lt/qti-lt.js.map +1 -0
- package/dist/components/qti-lte/qti-lte.d.ts +4 -0
- package/dist/components/qti-lte/qti-lte.js +24 -0
- package/dist/components/qti-lte/qti-lte.js.map +1 -0
- package/dist/components/qti-map-response/qti-map-response.d.ts +5 -0
- package/dist/components/qti-map-response/qti-map-response.js +52 -0
- package/dist/components/qti-map-response/qti-map-response.js.map +1 -0
- package/dist/components/qti-map-response-point/qti-map-response-point.d.ts +5 -0
- package/dist/components/qti-map-response-point/qti-map-response-point.js +60 -0
- package/dist/components/qti-map-response-point/qti-map-response-point.js.map +1 -0
- package/dist/components/qti-match/qti-match.d.ts +6 -0
- package/dist/components/qti-match/qti-match.js +84 -0
- package/dist/components/qti-match/qti-match.js.map +1 -0
- package/dist/components/qti-math-operator/qti-math-operator.d.ts +14 -0
- package/dist/components/qti-math-operator/qti-math-operator.js +213 -0
- package/dist/components/qti-math-operator/qti-math-operator.js.map +1 -0
- package/dist/components/qti-member/qti-member.d.ts +4 -0
- package/dist/components/qti-member/qti-member.js +34 -0
- package/dist/components/qti-member/qti-member.js.map +1 -0
- package/dist/components/qti-multiple/qti-multiple.d.ts +5 -0
- package/dist/components/qti-multiple/qti-multiple.js +26 -0
- package/dist/components/qti-multiple/qti-multiple.js.map +1 -0
- package/dist/components/qti-not/qti-not.d.ts +5 -0
- package/dist/components/qti-not/qti-not.js +14 -0
- package/dist/components/qti-not/qti-not.js.map +1 -0
- package/dist/components/qti-null/qti-null.d.ts +11 -0
- package/dist/components/qti-null/qti-null.js +15 -0
- package/dist/components/qti-null/qti-null.js.map +1 -0
- package/dist/components/qti-or/qti-or.d.ts +4 -0
- package/dist/components/qti-or/qti-or.js +39 -0
- package/dist/components/qti-or/qti-or.js.map +1 -0
- package/dist/components/qti-ordered/qti-ordered.d.ts +5 -0
- package/dist/components/qti-ordered/qti-ordered.js +19 -0
- package/dist/components/qti-ordered/qti-ordered.js.map +1 -0
- package/dist/components/qti-power/qti-power.d.ts +12 -0
- package/dist/components/qti-power/qti-power.js +99 -0
- package/dist/components/qti-power/qti-power.js.map +1 -0
- package/dist/components/qti-printed-variable/qti-printed-variable.d.ts +9 -0
- package/dist/components/qti-printed-variable/qti-printed-variable.js +29 -0
- package/dist/components/qti-printed-variable/qti-printed-variable.js.map +1 -0
- package/dist/components/qti-product/qti-product.d.ts +4 -0
- package/dist/components/qti-product/qti-product.js +23 -0
- package/dist/components/qti-product/qti-product.js.map +1 -0
- package/dist/components/qti-random/qti-random.d.ts +4 -0
- package/dist/components/qti-random/qti-random.js +19 -0
- package/dist/components/qti-random/qti-random.js.map +1 -0
- package/dist/components/qti-random-integer/qti-random-integer.d.ts +18 -0
- package/dist/components/qti-random-integer/qti-random-integer.js +90 -0
- package/dist/components/qti-random-integer/qti-random-integer.js.map +1 -0
- package/dist/components/qti-response-condition/qti-response-condition.d.ts +5 -0
- package/dist/components/qti-response-condition/qti-response-condition.js +19 -0
- package/dist/components/qti-response-condition/qti-response-condition.js.map +1 -0
- package/dist/components/qti-response-else/qti-response-else.d.ts +8 -0
- package/dist/components/qti-response-else/qti-response-else.js +21 -0
- package/dist/components/qti-response-else/qti-response-else.js.map +1 -0
- package/dist/components/qti-response-else-if/qti-response-else-if.d.ts +4 -0
- package/dist/components/qti-response-else-if/qti-response-else-if.js +9 -0
- package/dist/components/qti-response-else-if/qti-response-else-if.js.map +1 -0
- package/dist/components/qti-response-if/qti-response-if.d.ts +6 -0
- package/dist/components/qti-response-if/qti-response-if.js +17 -0
- package/dist/components/qti-response-if/qti-response-if.js.map +1 -0
- package/dist/components/qti-round/qti-round.d.ts +13 -0
- package/dist/components/qti-round/qti-round.js +66 -0
- package/dist/components/qti-round/qti-round.js.map +1 -0
- package/dist/components/qti-round-to/qti-round-to.d.ts +15 -0
- package/dist/components/qti-round-to/qti-round-to.js +117 -0
- package/dist/components/qti-round-to/qti-round-to.js.map +1 -0
- package/dist/components/qti-rule/qti-rule.d.ts +11 -0
- package/dist/components/qti-rule/qti-rule.js +21 -0
- package/dist/components/qti-rule/qti-rule.js.map +1 -0
- package/dist/components/qti-set-outcome-value/qti-set-outcome-value.d.ts +24 -0
- package/dist/components/qti-set-outcome-value/qti-set-outcome-value.js +63 -0
- package/dist/components/qti-set-outcome-value/qti-set-outcome-value.js.map +1 -0
- package/dist/components/qti-string-match/qti-string-match.d.ts +5 -0
- package/dist/components/qti-string-match/qti-string-match.js +39 -0
- package/dist/components/qti-string-match/qti-string-match.js.map +1 -0
- package/dist/components/qti-subtract/index.d.ts +7 -0
- package/dist/components/qti-subtract/index.js +4 -0
- package/dist/components/qti-subtract/index.js.map +1 -0
- package/dist/components/qti-subtract/qti-subtract.d.ts +20 -0
- package/dist/components/qti-subtract/qti-subtract.js +34 -0
- package/dist/components/qti-subtract/qti-subtract.js.map +1 -0
- package/dist/components/qti-sum/qti-sum.d.ts +12 -0
- package/dist/components/qti-sum/qti-sum.js +36 -0
- package/dist/components/qti-sum/qti-sum.js.map +1 -0
- package/dist/components/qti-variable/qti-variable.d.ts +4 -0
- package/dist/components/qti-variable/qti-variable.js +10 -0
- package/dist/components/qti-variable/qti-variable.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * from './qti-and/qti-and';
|
|
2
|
+
export * from './qti-basevalue/qti-basevalue';
|
|
3
|
+
export * from './qti-container-size/qti-container-size';
|
|
4
|
+
export * from './qti-contains/qti-contains';
|
|
5
|
+
export * from './qti-correct/qti-correct';
|
|
6
|
+
export * from './qti-default/qti-default';
|
|
7
|
+
export * from './qti-equal-rounded/qti-equal-rounded';
|
|
8
|
+
export * from './qti-round/qti-round';
|
|
9
|
+
export * from './qti-round-to/qti-round-to';
|
|
10
|
+
export * from './qti-equal/qti-equal';
|
|
11
|
+
export * from './qti-gcd/qti.gcd';
|
|
12
|
+
export * from './qti-gt/qti-gt';
|
|
13
|
+
export * from './qti-gte/qti-gte';
|
|
14
|
+
export * from './qti-null/qti-null';
|
|
15
|
+
export * from './qti-is-null/qti-is-null';
|
|
16
|
+
export * from './qti-field-value/qti-field-value';
|
|
17
|
+
export * from './qti-lt/qti-lt';
|
|
18
|
+
export * from './qti-lte/qti-lte';
|
|
19
|
+
export * from './qti-map-response/qti-map-response';
|
|
20
|
+
export * from './qti-map-response-point/qti-map-response-point';
|
|
21
|
+
export * from './qti-math-operator/qti-math-operator';
|
|
22
|
+
export * from './qti-match/qti-match';
|
|
23
|
+
export * from './qti-member/qti-member';
|
|
24
|
+
export * from './qti-multiple/qti-multiple';
|
|
25
|
+
export * from './qti-not/qti-not';
|
|
26
|
+
export * from './qti-or/qti-or';
|
|
27
|
+
export * from './qti-ordered/qti-ordered';
|
|
28
|
+
export * from './qti-power/qti-power';
|
|
29
|
+
export * from './qti-printed-variable/qti-printed-variable';
|
|
30
|
+
export * from './qti-product/qti-product';
|
|
31
|
+
export * from './qti-subtract';
|
|
32
|
+
export * from './qti-string-match/qti-string-match';
|
|
33
|
+
export * from './qti-sum/qti-sum';
|
|
34
|
+
export * from './qti-variable/qti-variable';
|
|
35
|
+
export * from './qti-random-integer/qti-random-integer';
|
|
36
|
+
export * from './qti-random/qti-random';
|
|
37
|
+
export * from './qti-delete/qti-delete';
|
|
38
|
+
export * from './qti-index/qti-index';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export * from './qti-and/qti-and';
|
|
2
|
+
export * from './qti-basevalue/qti-basevalue';
|
|
3
|
+
export * from './qti-container-size/qti-container-size';
|
|
4
|
+
export * from './qti-contains/qti-contains';
|
|
5
|
+
export * from './qti-correct/qti-correct';
|
|
6
|
+
export * from './qti-default/qti-default';
|
|
7
|
+
export * from './qti-equal-rounded/qti-equal-rounded';
|
|
8
|
+
export * from './qti-round/qti-round';
|
|
9
|
+
export * from './qti-round-to/qti-round-to';
|
|
10
|
+
export * from './qti-equal/qti-equal';
|
|
11
|
+
export * from './qti-gcd/qti.gcd';
|
|
12
|
+
export * from './qti-gt/qti-gt';
|
|
13
|
+
export * from './qti-gte/qti-gte';
|
|
14
|
+
export * from './qti-null/qti-null';
|
|
15
|
+
export * from './qti-is-null/qti-is-null';
|
|
16
|
+
export * from './qti-field-value/qti-field-value';
|
|
17
|
+
export * from './qti-lt/qti-lt';
|
|
18
|
+
export * from './qti-lte/qti-lte';
|
|
19
|
+
export * from './qti-map-response/qti-map-response';
|
|
20
|
+
export * from './qti-map-response-point/qti-map-response-point';
|
|
21
|
+
export * from './qti-math-operator/qti-math-operator';
|
|
22
|
+
export * from './qti-match/qti-match';
|
|
23
|
+
export * from './qti-member/qti-member';
|
|
24
|
+
export * from './qti-multiple/qti-multiple';
|
|
25
|
+
export * from './qti-not/qti-not';
|
|
26
|
+
export * from './qti-or/qti-or';
|
|
27
|
+
export * from './qti-ordered/qti-ordered';
|
|
28
|
+
export * from './qti-power/qti-power';
|
|
29
|
+
export * from './qti-printed-variable/qti-printed-variable';
|
|
30
|
+
export * from './qti-product/qti-product';
|
|
31
|
+
export * from './qti-subtract';
|
|
32
|
+
export * from './qti-string-match/qti-string-match';
|
|
33
|
+
export * from './qti-sum/qti-sum';
|
|
34
|
+
export * from './qti-variable/qti-variable';
|
|
35
|
+
export * from './qti-random-integer/qti-random-integer';
|
|
36
|
+
export * from './qti-random/qti-random';
|
|
37
|
+
export * from './qti-delete/qti-delete';
|
|
38
|
+
export * from './qti-index/qti-index';
|
|
39
|
+
// FIXME are internal and abstract
|
|
40
|
+
// export * from './qti-mapping/qti-mapping';
|
|
41
|
+
// export * from './qti-area-mapping/qti-area-mapping';
|
|
42
|
+
// export * from './qti-expression';
|
|
43
|
+
// export * from './qti-condition-expression';
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AAEtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qCAAqC,CAAC;AACpD,cAAc,iDAAiD,CAAC;AAEhE,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qCAAqC,CAAC;AACpD,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,kCAAkC;AAElC,6CAA6C;AAC7C,uDAAuD;AAEvD,oCAAoC;AACpC,8CAA8C","sourcesContent":["export * from './qti-and/qti-and';\nexport * from './qti-basevalue/qti-basevalue';\n\nexport * from './qti-container-size/qti-container-size';\nexport * from './qti-contains/qti-contains';\nexport * from './qti-correct/qti-correct';\nexport * from './qti-default/qti-default';\nexport * from './qti-equal-rounded/qti-equal-rounded';\nexport * from './qti-round/qti-round';\nexport * from './qti-round-to/qti-round-to';\nexport * from './qti-equal/qti-equal';\n\nexport * from './qti-gcd/qti.gcd';\nexport * from './qti-gt/qti-gt';\nexport * from './qti-gte/qti-gte';\nexport * from './qti-null/qti-null';\nexport * from './qti-is-null/qti-is-null';\nexport * from './qti-field-value/qti-field-value';\nexport * from './qti-lt/qti-lt';\nexport * from './qti-lte/qti-lte';\nexport * from './qti-map-response/qti-map-response';\nexport * from './qti-map-response-point/qti-map-response-point';\n\nexport * from './qti-math-operator/qti-math-operator';\nexport * from './qti-match/qti-match';\nexport * from './qti-member/qti-member';\nexport * from './qti-multiple/qti-multiple';\nexport * from './qti-not/qti-not';\nexport * from './qti-or/qti-or';\nexport * from './qti-ordered/qti-ordered';\nexport * from './qti-power/qti-power';\nexport * from './qti-printed-variable/qti-printed-variable';\nexport * from './qti-product/qti-product';\nexport * from './qti-subtract';\nexport * from './qti-string-match/qti-string-match';\nexport * from './qti-sum/qti-sum';\nexport * from './qti-variable/qti-variable';\nexport * from './qti-random-integer/qti-random-integer';\nexport * from './qti-random/qti-random';\nexport * from './qti-delete/qti-delete';\nexport * from './qti-index/qti-index';\n// FIXME are internal and abstract\n\n// export * from './qti-mapping/qti-mapping';\n// export * from './qti-area-mapping/qti-area-mapping';\n\n// export * from './qti-expression';\n// export * from './qti-condition-expression';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { QtiConditionExpression } from '@qti-components/base';
|
|
2
|
+
type Constructor<T> = new (...args: any[]) => T;
|
|
3
|
+
declare const QtiAnd_base: {
|
|
4
|
+
new (...args: any[]): {
|
|
5
|
+
calculateChildren(children: Array<MockQtiExpression<any>>): boolean;
|
|
6
|
+
};
|
|
7
|
+
} & Constructor<QtiConditionExpression>;
|
|
8
|
+
export declare class QtiAnd extends QtiAnd_base {
|
|
9
|
+
calculate(): boolean;
|
|
10
|
+
}
|
|
11
|
+
type MockQtiExpression<T> = {
|
|
12
|
+
calculate: () => T;
|
|
13
|
+
};
|
|
14
|
+
type MockConstructor = new (...args: any[]) => {};
|
|
15
|
+
export declare function qtiAndMixin<TBase extends MockConstructor>(Base: TBase): {
|
|
16
|
+
new (...args: any[]): {
|
|
17
|
+
calculateChildren(children: Array<MockQtiExpression<any>>): boolean;
|
|
18
|
+
};
|
|
19
|
+
} & TBase;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { QtiConditionExpression } from '@qti-components/base';
|
|
9
|
+
let QtiAnd = class QtiAnd extends qtiAndMixin(QtiConditionExpression) {
|
|
10
|
+
calculate() {
|
|
11
|
+
return this.calculateChildren(Array.from(this.children));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
QtiAnd = __decorate([
|
|
15
|
+
customElement('qti-and')
|
|
16
|
+
], QtiAnd);
|
|
17
|
+
export { QtiAnd };
|
|
18
|
+
export function qtiAndMixin(Base) {
|
|
19
|
+
return class MockQtiAnd extends Base {
|
|
20
|
+
calculateChildren(children) {
|
|
21
|
+
// children can be a mix of qti-expression and qti-condition-expression
|
|
22
|
+
const values = children.map(c => {
|
|
23
|
+
const condition = c;
|
|
24
|
+
if (!condition.calculate) {
|
|
25
|
+
console.error("Element doesn't implement QtiConditionExpression");
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const value = condition.calculate();
|
|
29
|
+
let val = false;
|
|
30
|
+
// convert string value to boolean and return null if not possible
|
|
31
|
+
if (typeof value === 'string') {
|
|
32
|
+
if (value === 'true') {
|
|
33
|
+
val = true;
|
|
34
|
+
}
|
|
35
|
+
else if (value === 'false') {
|
|
36
|
+
val = false;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.error('unexpected val in qti-or, expected boolean');
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (typeof value === 'boolean') {
|
|
45
|
+
val = value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return val;
|
|
49
|
+
});
|
|
50
|
+
return values.every(e => {
|
|
51
|
+
return typeof e === 'boolean' && e;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=qti-and.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-and.js","sourceRoot":"","sources":["../../../src/components/qti-and/qti-and.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAOvD,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,WAAW,CAAC,sBAAwE,CAAC;IAC/F,SAAS;QACvB,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAA2C,CAAC,CAAC,CAAC;IAC9F,CAAC;CACF,CAAA;AAJY,MAAM;IADlB,aAAa,CAAC,SAAS,CAAC;GACZ,MAAM,CAIlB;;AAID,MAAM,UAAU,WAAW,CAAgC,IAAW;IACpE,OAAO,MAAM,UAAW,SAAQ,IAAI;QAC3B,iBAAiB,CAAC,QAAuC;YAC9D,uEAAuE;YACvE,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBAC9B,MAAM,SAAS,GAAG,CAA2B,CAAC;gBAC9C,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;oBAClE,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;gBACpC,IAAI,GAAG,GAAG,KAAK,CAAC;gBAChB,kEAAkE;gBAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAC9B,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;wBACrB,GAAG,GAAG,IAAI,CAAC;oBACb,CAAC;yBAAM,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;wBAC7B,GAAG,GAAG,KAAK,CAAC;oBACd,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;wBAC5D,OAAO,IAAI,CAAC;oBACd,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;wBAC/B,GAAG,GAAG,KAAK,CAAC;oBACd,CAAC;gBACH,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;gBACtB,OAAO,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { customElement } from 'lit/decorators.js';\n\nimport { QtiConditionExpression } from '@qti-components/base';\n\nimport type { QtiExpression } from '@qti-components/base';\n\ntype Constructor<T> = new (...args: any[]) => T;\n\n@customElement('qti-and')\nexport class QtiAnd extends qtiAndMixin(QtiConditionExpression as unknown as Constructor<QtiConditionExpression>) {\n public override calculate() {\n return this.calculateChildren(Array.from(this.children as unknown as QtiExpression<any>[]));\n }\n}\n\ntype MockQtiExpression<T> = { calculate: () => T };\ntype MockConstructor = new (...args: any[]) => {};\nexport function qtiAndMixin<TBase extends MockConstructor>(Base: TBase) {\n return class MockQtiAnd extends Base {\n public calculateChildren(children: Array<MockQtiExpression<any>>) {\n // children can be a mix of qti-expression and qti-condition-expression\n const values = children.map(c => {\n const condition = c as MockQtiExpression<any>;\n if (!condition.calculate) {\n console.error(\"Element doesn't implement QtiConditionExpression\");\n return null;\n }\n const value = condition.calculate();\n let val = false;\n // convert string value to boolean and return null if not possible\n if (typeof value === 'string') {\n if (value === 'true') {\n val = true;\n } else if (value === 'false') {\n val = false;\n } else {\n console.error('unexpected val in qti-or, expected boolean');\n return null;\n }\n } else {\n if (typeof value === 'boolean') {\n val = value;\n }\n }\n return val;\n });\n return values.every(e => {\n return typeof e === 'boolean' && e;\n });\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { property } from 'lit/decorators.js';
|
|
8
|
+
import { QtiExpression } from '@qti-components/base';
|
|
9
|
+
export class QtiBaseValue extends QtiExpression {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.baseType = 'string';
|
|
13
|
+
}
|
|
14
|
+
getResult() {
|
|
15
|
+
const value = this.textContent.trim();
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
property({ type: String, attribute: 'base-type' })
|
|
21
|
+
], QtiBaseValue.prototype, "baseType", void 0);
|
|
22
|
+
customElements.define('qti-base-value', QtiBaseValue);
|
|
23
|
+
//# sourceMappingURL=qti-basevalue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-basevalue.js","sourceRoot":"","sources":["../../../src/components/qti-basevalue/qti-basevalue.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,OAAO,YAAa,SAAQ,aAAqB;IAAvD;;QACsD,aAAQ,GAAa,QAAQ,CAAC;IAMpF,CAAC;IAJiB,SAAS;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AANqD;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;8CAA+B;AAQpF,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import { property } from 'lit/decorators.js';\n\nimport { QtiExpression } from '@qti-components/base';\n\nimport type { BaseType } from '@qti-components/base';\n\nexport class QtiBaseValue extends QtiExpression<string> {\n @property({ type: String, attribute: 'base-type' }) baseType: BaseType = 'string';\n\n public override getResult(): string {\n const value = this.textContent.trim();\n return value;\n }\n}\n\ncustomElements.define('qti-base-value', QtiBaseValue);\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary The qti-container-size operator returns the number of values in a container.
|
|
4
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.container-size
|
|
5
|
+
*
|
|
6
|
+
* Takes a sub-expression with any base-type and either multiple or ordered cardinality.
|
|
7
|
+
* Returns an integer giving the number of values in the container.
|
|
8
|
+
* Returns 0 if the sub-expression is NULL.
|
|
9
|
+
*/
|
|
10
|
+
export declare class QtiContainerSize extends QtiExpression<number> {
|
|
11
|
+
getResult(): number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary The qti-container-size operator returns the number of values in a container.
|
|
4
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.container-size
|
|
5
|
+
*
|
|
6
|
+
* Takes a sub-expression with any base-type and either multiple or ordered cardinality.
|
|
7
|
+
* Returns an integer giving the number of values in the container.
|
|
8
|
+
* Returns 0 if the sub-expression is NULL.
|
|
9
|
+
*/
|
|
10
|
+
export class QtiContainerSize extends QtiExpression {
|
|
11
|
+
getResult() {
|
|
12
|
+
if (this.children?.length !== 1) {
|
|
13
|
+
console.error('qti-container-size must have exactly one child expression');
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
const variables = this.getVariables();
|
|
17
|
+
if (!variables || variables?.length === 0) {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
const variable = variables[0];
|
|
21
|
+
// Handle null values - return 0 as per spec
|
|
22
|
+
if (variable.value === null || variable.value === undefined) {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
// Check cardinality - must be multiple or ordered
|
|
26
|
+
if (variable.cardinality !== 'multiple' && variable.cardinality !== 'ordered') {
|
|
27
|
+
console.error('qti-container-size requires multiple or ordered cardinality');
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
// The value should be an array for multiple/ordered cardinality
|
|
31
|
+
if (!Array.isArray(variable.value)) {
|
|
32
|
+
console.error('qti-container-size: expected array value for multiple/ordered cardinality');
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
// Return the size of the container
|
|
36
|
+
return variable.value.length;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
customElements.define('qti-container-size', QtiContainerSize);
|
|
40
|
+
//# sourceMappingURL=qti-container-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-container-size.js","sourceRoot":"","sources":["../../../src/components/qti-container-size/qti-container-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAiB,SAAQ,aAAqB;IACzC,SAAS;QACvB,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;YAC3E,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;QAE5D,IAAI,CAAC,SAAS,IAAI,SAAS,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAE9B,4CAA4C;QAC5C,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC5D,OAAO,CAAC,CAAC;QACX,CAAC;QAED,kDAAkD;QAClD,IAAI,QAAQ,CAAC,WAAW,KAAK,UAAU,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9E,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;YAC7E,OAAO,CAAC,CAAC;QACX,CAAC;QAED,gEAAgE;QAChE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;YAC3F,OAAO,CAAC,CAAC;QACX,CAAC;QAED,mCAAmC;QACnC,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;IAC/B,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\n\n/**\n * @summary The qti-container-size operator returns the number of values in a container.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.container-size\n *\n * Takes a sub-expression with any base-type and either multiple or ordered cardinality.\n * Returns an integer giving the number of values in the container.\n * Returns 0 if the sub-expression is NULL.\n */\nexport class QtiContainerSize extends QtiExpression<number> {\n public override getResult(): number {\n if (this.children?.length !== 1) {\n console.error('qti-container-size must have exactly one child expression');\n return 0;\n }\n\n const variables = this.getVariables() as ResponseVariable[];\n\n if (!variables || variables?.length === 0) {\n return 0;\n }\n\n const variable = variables[0];\n\n // Handle null values - return 0 as per spec\n if (variable.value === null || variable.value === undefined) {\n return 0;\n }\n\n // Check cardinality - must be multiple or ordered\n if (variable.cardinality !== 'multiple' && variable.cardinality !== 'ordered') {\n console.error('qti-container-size requires multiple or ordered cardinality');\n return 0;\n }\n\n // The value should be an array for multiple/ordered cardinality\n if (!Array.isArray(variable.value)) {\n console.error('qti-container-size: expected array value for multiple/ordered cardinality');\n return 0;\n }\n\n // Return the size of the container\n return variable.value.length;\n }\n}\n\ncustomElements.define('qti-container-size', QtiContainerSize);\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { QtiConditionExpression } from '@qti-components/base';
|
|
2
|
+
// PK: For the contains we assume the expressions to calculate are all directedPairs
|
|
3
|
+
// I don't know it this in QTI is always the case however?
|
|
4
|
+
export class QtiContains extends QtiConditionExpression {
|
|
5
|
+
getResult() {
|
|
6
|
+
// TODO: implement this for other types than directedPair
|
|
7
|
+
const values = this.getVariables();
|
|
8
|
+
if (this.children.length === 2) {
|
|
9
|
+
const value1 = values[0];
|
|
10
|
+
const value2 = values[1];
|
|
11
|
+
if (value1.baseType === 'directedPair' &&
|
|
12
|
+
value2.baseType === 'directedPair' &&
|
|
13
|
+
value1.cardinality === 'multiple') {
|
|
14
|
+
const projection1 = value1.value;
|
|
15
|
+
const projection2 = value2.value;
|
|
16
|
+
const enumerable = projection1.filter(x => projection2.includes(x));
|
|
17
|
+
const result = enumerable.length > 0;
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
else if (value1.baseType === 'directedPair' &&
|
|
21
|
+
value2.baseType === 'directedPair' &&
|
|
22
|
+
value1.cardinality === 'single') {
|
|
23
|
+
const projection1 = value1.value;
|
|
24
|
+
const projection2 = value2.value;
|
|
25
|
+
return projection2.includes(projection1);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.error('unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.error('unexpected number of children in qti contains');
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
customElements.define('qti-contains', QtiContains);
|
|
38
|
+
//# sourceMappingURL=qti-contains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-contains.js","sourceRoot":"","sources":["../../../src/components/qti-contains/qti-contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,oFAAoF;AACpF,0DAA0D;AAC1D,MAAM,OAAO,WAAY,SAAQ,sBAAsB;IACrC,SAAS;QACvB,yDAAyD;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;QACzD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACzB,IACE,MAAM,CAAC,QAAQ,KAAK,cAAc;gBAClC,MAAM,CAAC,QAAQ,KAAK,cAAc;gBAClC,MAAM,CAAC,WAAW,KAAK,UAAU,EACjC,CAAC;gBACD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAiB,CAAC;gBAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAiB,CAAC;gBAC7C,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEpE,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;gBACrC,OAAO,MAAM,CAAC;YAChB,CAAC;iBAAM,IACL,MAAM,CAAC,QAAQ,KAAK,cAAc;gBAClC,MAAM,CAAC,QAAQ,KAAK,cAAc;gBAClC,MAAM,CAAC,WAAW,KAAK,QAAQ,EAC/B,CAAC;gBACD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAe,CAAC;gBAC3C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAiB,CAAC;gBAC7C,OAAO,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CACX,yHAAyH,CAC1H,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { QtiConditionExpression } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\n\n// PK: For the contains we assume the expressions to calculate are all directedPairs\n// I don't know it this in QTI is always the case however?\nexport class QtiContains extends QtiConditionExpression {\n public override getResult() {\n // TODO: implement this for other types than directedPair\n const values = this.getVariables() as ResponseVariable[];\n if (this.children.length === 2) {\n const value1 = values[0];\n const value2 = values[1];\n if (\n value1.baseType === 'directedPair' &&\n value2.baseType === 'directedPair' &&\n value1.cardinality === 'multiple'\n ) {\n const projection1 = value1.value as string[];\n const projection2 = value2.value as string[];\n const enumerable = projection1.filter(x => projection2.includes(x));\n\n const result = enumerable.length > 0;\n return result;\n } else if (\n value1.baseType === 'directedPair' &&\n value2.baseType === 'directedPair' &&\n value1.cardinality === 'single'\n ) {\n const projection1 = value1.value as string;\n const projection2 = value2.value as string[];\n return projection2.includes(projection1);\n } else {\n console.error(\n 'unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported'\n );\n }\n } else {\n console.error('unexpected number of children in qti contains');\n }\n return false;\n }\n}\n\ncustomElements.define('qti-contains', QtiContains);\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
export class QtiCorrect extends QtiExpression {
|
|
3
|
+
get interpretation() {
|
|
4
|
+
return this.getAttribute('interpretation') || '';
|
|
5
|
+
}
|
|
6
|
+
getResult() {
|
|
7
|
+
const identifier = this.getAttribute('identifier') || '';
|
|
8
|
+
const responseVariable = this.context.variables.find(v => v.identifier === identifier) || null;
|
|
9
|
+
if (responseVariable.cardinality !== 'single') {
|
|
10
|
+
return responseVariable.correctResponse.length > 0 ? responseVariable.correctResponse[0] : '';
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return responseVariable.correctResponse;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
customElements.define('qti-correct', QtiCorrect);
|
|
18
|
+
//# sourceMappingURL=qti-correct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-correct.js","sourceRoot":"","sources":["../../../src/components/qti-correct/qti-correct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,OAAO,UAAW,SAAQ,aAAgC;IAC9D,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;IACnD,CAAC;IAEQ,SAAS;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QACzD,MAAM,gBAAgB,GAAqB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;QACjH,IAAI,gBAAgB,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC9C,OAAO,gBAAgB,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAChG,CAAC;aAAM,CAAC;YACN,OAAO,gBAAgB,CAAC,eAAe,CAAC;QAC1C,CAAC;IACH,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\n\nexport class QtiCorrect extends QtiExpression<string | string[]> {\n get interpretation() {\n return this.getAttribute('interpretation') || '';\n }\n\n override getResult() {\n const identifier = this.getAttribute('identifier') || '';\n const responseVariable: ResponseVariable = this.context.variables.find(v => v.identifier === identifier) || null;\n if (responseVariable.cardinality !== 'single') {\n return responseVariable.correctResponse.length > 0 ? responseVariable.correctResponse[0] : '';\n } else {\n return responseVariable.correctResponse;\n }\n }\n}\n\ncustomElements.define('qti-correct', QtiCorrect);\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
import type { ItemContext } from '@qti-components/base';
|
|
3
|
+
import type { TestContext } from '@qti-components/base';
|
|
4
|
+
/**
|
|
5
|
+
* @summary The qti-default expression returns the default value of a declared variable.
|
|
6
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.default
|
|
7
|
+
*
|
|
8
|
+
* Looks up the declaration of an itemVariable and returns the associated defaultValue
|
|
9
|
+
* or NULL if no default value was declared. Supports item identifier prefixing
|
|
10
|
+
* for obtaining default values from individual items in outcomes processing.
|
|
11
|
+
*/
|
|
12
|
+
export declare class QtiDefault extends QtiExpression<any> {
|
|
13
|
+
identifier: string;
|
|
14
|
+
protected context?: ItemContext;
|
|
15
|
+
protected _testContext?: TestContext;
|
|
16
|
+
getResult(): any;
|
|
17
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { property, state } from 'lit/decorators.js';
|
|
8
|
+
import { consume } from '@lit/context';
|
|
9
|
+
import { QtiExpression } from '@qti-components/base';
|
|
10
|
+
import { itemContext } from '@qti-components/base';
|
|
11
|
+
import { testContext } from '@qti-components/base';
|
|
12
|
+
/**
|
|
13
|
+
* @summary The qti-default expression returns the default value of a declared variable.
|
|
14
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.default
|
|
15
|
+
*
|
|
16
|
+
* Looks up the declaration of an itemVariable and returns the associated defaultValue
|
|
17
|
+
* or NULL if no default value was declared. Supports item identifier prefixing
|
|
18
|
+
* for obtaining default values from individual items in outcomes processing.
|
|
19
|
+
*/
|
|
20
|
+
export class QtiDefault extends QtiExpression {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.identifier = '';
|
|
24
|
+
}
|
|
25
|
+
getResult() {
|
|
26
|
+
if (!this.identifier) {
|
|
27
|
+
console.error('qti-default requires an identifier attribute');
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
// Check for item identifier prefixing (format: "itemId.variableId")
|
|
31
|
+
const parts = this.identifier.split('.');
|
|
32
|
+
let itemId = null;
|
|
33
|
+
let variableId;
|
|
34
|
+
if (parts.length === 2) {
|
|
35
|
+
itemId = parts[0];
|
|
36
|
+
variableId = parts[1];
|
|
37
|
+
}
|
|
38
|
+
else if (parts.length === 1) {
|
|
39
|
+
variableId = parts[0];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.error('qti-default: invalid identifier format');
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
// If item identifier is specified, look in that specific item
|
|
46
|
+
if (itemId) {
|
|
47
|
+
const itemContext = this._testContext.items.find(item => item.identifier === itemId);
|
|
48
|
+
console.debug(`itemContext: ${JSON.stringify(itemContext)}`);
|
|
49
|
+
if (!this._testContext || !itemContext) {
|
|
50
|
+
console.warn(`qti-default: item "${itemId}" not found in test context`);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const variable = this._testContext.items
|
|
54
|
+
.find(item => item.identifier === itemId)
|
|
55
|
+
?.variables.find(v => v.identifier === variableId);
|
|
56
|
+
if (!variable) {
|
|
57
|
+
console.warn(`qti-default: variable "${variableId}" not found in item "${itemId}"`);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return variable.defaultValue || null;
|
|
61
|
+
}
|
|
62
|
+
// Otherwise, look in the current item context
|
|
63
|
+
if (!this.context?.variables) {
|
|
64
|
+
console.warn('qti-default: no variables found in item context');
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const variable = this.context.variables.find(v => v.identifier === variableId);
|
|
68
|
+
if (!variable) {
|
|
69
|
+
console.warn(`qti-default: variable "${variableId}" not found in item context`);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return variable.defaultValue || null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
__decorate([
|
|
76
|
+
property({ type: String })
|
|
77
|
+
], QtiDefault.prototype, "identifier", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
consume({ context: itemContext, subscribe: true }),
|
|
80
|
+
state()
|
|
81
|
+
], QtiDefault.prototype, "context", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
state(),
|
|
84
|
+
consume({ context: testContext, subscribe: true })
|
|
85
|
+
], QtiDefault.prototype, "_testContext", void 0);
|
|
86
|
+
customElements.define('qti-default', QtiDefault);
|
|
87
|
+
//# sourceMappingURL=qti-default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-default.js","sourceRoot":"","sources":["../../../src/components/qti-default/qti-default.ts"],"names":[],"mappings":"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","sourcesContent":["import { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { QtiExpression } from '@qti-components/base';\nimport { itemContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\n\nimport type { ItemContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\n\n/**\n * @summary The qti-default expression returns the default value of a declared variable.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.default\n *\n * Looks up the declaration of an itemVariable and returns the associated defaultValue\n * or NULL if no default value was declared. Supports item identifier prefixing\n * for obtaining default values from individual items in outcomes processing.\n */\nexport class QtiDefault extends QtiExpression<any> {\n @property({ type: String }) identifier: string = '';\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n protected override context?: ItemContext;\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n public override getResult(): any {\n if (!this.identifier) {\n console.error('qti-default requires an identifier attribute');\n return null;\n }\n\n // Check for item identifier prefixing (format: \"itemId.variableId\")\n const parts = this.identifier.split('.');\n\n let itemId: string | null = null;\n let variableId: string;\n\n if (parts.length === 2) {\n itemId = parts[0];\n variableId = parts[1];\n } else if (parts.length === 1) {\n variableId = parts[0];\n } else {\n console.error('qti-default: invalid identifier format');\n return null;\n }\n\n // If item identifier is specified, look in that specific item\n if (itemId) {\n const itemContext = this._testContext.items.find(item => item.identifier === itemId);\n console.debug(`itemContext: ${JSON.stringify(itemContext)}`);\n if (!this._testContext || !itemContext) {\n console.warn(`qti-default: item \"${itemId}\" not found in test context`);\n return null;\n }\n const variable = this._testContext.items\n .find(item => item.identifier === itemId)\n ?.variables.find(v => v.identifier === variableId);\n if (!variable) {\n console.warn(`qti-default: variable \"${variableId}\" not found in item \"${itemId}\"`);\n return null;\n }\n return variable.defaultValue || null;\n }\n\n // Otherwise, look in the current item context\n if (!this.context?.variables) {\n console.warn('qti-default: no variables found in item context');\n return null;\n }\n const variable = this.context.variables.find(v => v.identifier === variableId);\n if (!variable) {\n console.warn(`qti-default: variable \"${variableId}\" not found in item context`);\n return null;\n }\n return variable.defaultValue || null;\n }\n}\n\ncustomElements.define('qti-default', QtiDefault);\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
export class QtiDelete extends QtiExpression {
|
|
3
|
+
getResult() {
|
|
4
|
+
if (this.children.length === 2) {
|
|
5
|
+
const values = this.getVariables();
|
|
6
|
+
const value1 = values[0];
|
|
7
|
+
const value2 = values[1];
|
|
8
|
+
if (value1.cardinality !== 'single' || !Array.isArray(value2.value)) {
|
|
9
|
+
console.error('unexpected cardinality in qti equal');
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (values[0].baseType !== values[1].baseType) {
|
|
13
|
+
console.error('The baseType of the two variables is different');
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const filtered = value2.value.filter(v => !value1.value.includes(v));
|
|
17
|
+
return filtered;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
customElements.define('qti-delete', QtiDelete);
|
|
23
|
+
//# sourceMappingURL=qti-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-delete.js","sourceRoot":"","sources":["../../../src/components/qti-delete/qti-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,OAAO,SAAU,SAAQ,aAA8B;IAClD,SAAS;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;YACzD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAEzB,IAAI,MAAM,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpE,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;gBACrD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAC9C,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;gBAChE,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAErE,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\n\nexport class QtiDelete extends QtiExpression<string[] | null> {\n override getResult(): string[] | null {\n if (this.children.length === 2) {\n const values = this.getVariables() as ResponseVariable[];\n const value1 = values[0];\n const value2 = values[1];\n\n if (value1.cardinality !== 'single' || !Array.isArray(value2.value)) {\n console.error('unexpected cardinality in qti equal');\n return null;\n }\n\n if (values[0].baseType !== values[1].baseType) {\n console.error('The baseType of the two variables is different');\n return null;\n }\n\n const filtered = value2.value.filter(v => !value1.value.includes(v));\n\n return filtered;\n }\n\n return null;\n }\n}\n\ncustomElements.define('qti-delete', QtiDelete);\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { property } from 'lit/decorators.js';
|
|
8
|
+
import { QtiExpression } from '@qti-components/base';
|
|
9
|
+
import { ScoringHelper } from '@qti-components/base';
|
|
10
|
+
export class QtiEqual extends QtiExpression {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.toleranceMode = 'exact';
|
|
14
|
+
}
|
|
15
|
+
getResult() {
|
|
16
|
+
if (this.children.length === 2) {
|
|
17
|
+
const values = this.getVariables();
|
|
18
|
+
const value1 = values[0];
|
|
19
|
+
const value2 = values[1];
|
|
20
|
+
if (this.toleranceMode !== 'exact') {
|
|
21
|
+
console.error('toleranceMode is not supported yet');
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (value1.cardinality !== 'single' ||
|
|
25
|
+
value2.cardinality !== 'single' ||
|
|
26
|
+
Array.isArray(value1.value) ||
|
|
27
|
+
Array.isArray(value2.value)) {
|
|
28
|
+
console.error('unexpected cardinality in qti equal');
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return ScoringHelper.compareSingleValues(value1.value, value2.value, value1.baseType);
|
|
32
|
+
}
|
|
33
|
+
console.error('unexpected number of children in qti-equal');
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
__decorate([
|
|
38
|
+
property({ type: String })
|
|
39
|
+
], QtiEqual.prototype, "toleranceMode", void 0);
|
|
40
|
+
customElements.define('qti-equal', QtiEqual);
|
|
41
|
+
//# sourceMappingURL=qti-equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-equal.js","sourceRoot":"","sources":["../../../src/components/qti-equal/qti-equal.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,OAAO,QAAS,SAAQ,aAAsB;IAApD;;QAC8B,kBAAa,GAAsC,OAAO,CAAC;IAyBzF,CAAC;IAvBiB,SAAS;QACvB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;YACzD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,EAAE,CAAC;gBACnC,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;gBACpD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IACE,MAAM,CAAC,WAAW,KAAK,QAAQ;gBAC/B,MAAM,CAAC,WAAW,KAAK,QAAQ;gBAC/B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC3B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAC3B,CAAC;gBACD,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;gBACrD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAe,EAAE,MAAM,CAAC,KAAe,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5G,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA4D;AA2BzF,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { property } from 'lit/decorators.js';\n\nimport { QtiExpression } from '@qti-components/base';\nimport { ScoringHelper } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\n\nexport class QtiEqual extends QtiExpression<boolean> {\n @property({ type: String }) toleranceMode: 'exact' | 'relative' | 'absolute' = 'exact';\n\n public override getResult() {\n if (this.children.length === 2) {\n const values = this.getVariables() as ResponseVariable[];\n const value1 = values[0];\n const value2 = values[1];\n if (this.toleranceMode !== 'exact') {\n console.error('toleranceMode is not supported yet');\n return false;\n }\n if (\n value1.cardinality !== 'single' ||\n value2.cardinality !== 'single' ||\n Array.isArray(value1.value) ||\n Array.isArray(value2.value)\n ) {\n console.error('unexpected cardinality in qti equal');\n return false;\n }\n return ScoringHelper.compareSingleValues(value1.value as string, value2.value as string, value1.baseType);\n }\n console.error('unexpected number of children in qti-equal');\n return null;\n }\n}\n\ncustomElements.define('qti-equal', QtiEqual);\n"]}
|