@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 @@
|
|
|
1
|
+
{"version":3,"file":"qti-multiple.js","sourceRoot":"","sources":["../../../src/components/qti-multiple/qti-multiple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,OAAO,WAAY,SAAQ,aAAuD;IACtE,SAAS;QACvB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;QAE5D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,QAAQ,CAAC,WAAW,KAAK,UAAU,IAAI,QAAQ,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;gBAC7E,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;gBACxD,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QAED,8CAA8C;QAC9C,0BAA0B;QAC1B,sFAAsF;QACtF,kEAAkE;QAClE,UAAU;QACV,yBAAyB;QAEzB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nimport type { ResponseVariable, VariableDeclaration } from '@qti-components/base';\nexport class QtiMultiple extends QtiExpression<VariableDeclaration<string | string[]>[]> {\n public override getResult(): ResponseVariable[] {\n console.debug('qti-multiple getResult called', this.innerHTML);\n const variables = this.getVariables() as ResponseVariable[];\n\n if (variables.length === 0) {\n console.error('unexpected number of children in qti multiple');\n return null;\n }\n for (const variable of variables) {\n if (variable.cardinality !== 'multiple' && variable.cardinality !== 'single') {\n console.error('unexpected cardinality in qti multiple');\n return [];\n }\n }\n\n // const values = variables.map(v => v.value);\n // console.log(variables);\n // const flattenedArray = values.reduce((acc: string[], value: string | string[]) => {\n // return acc.concat(Array.isArray(value) ? [...value] : value);\n // }, []);\n // return flattenedArray;\n\n return variables;\n }\n}\n\ncustomElements.define('qti-multiple', QtiMultiple);\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { QtiExpression } from '@qti-components/base';
|
|
3
|
+
export class QtiNot extends QtiExpression {
|
|
4
|
+
render() {
|
|
5
|
+
return html `${super.render()}`;
|
|
6
|
+
}
|
|
7
|
+
getResult() {
|
|
8
|
+
const expression = this.firstElementChild;
|
|
9
|
+
const result = expression.calculate();
|
|
10
|
+
return !result;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
customElements.define('qti-not', QtiNot);
|
|
14
|
+
//# sourceMappingURL=qti-not.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-not.js","sourceRoot":"","sources":["../../../src/components/qti-not/qti-not.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,OAAO,MAAO,SAAQ,aAAsB;IACvC,MAAM;QACb,OAAO,IAAI,CAAA,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;IACjC,CAAC;IAEe,SAAS;QACvB,MAAM,UAAU,GAAG,IAAI,CAAC,iBAA2C,CAAC;QACpE,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,EAAa,CAAC;QACjD,OAAO,CAAC,MAAM,CAAC;IACjB,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\n\nimport { QtiExpression } from '@qti-components/base';\n\nexport class QtiNot extends QtiExpression<boolean> {\n override render() {\n return html`${super.render()}`;\n }\n\n public override getResult() {\n const expression = this.firstElementChild as QtiExpression<boolean>;\n const result = expression.calculate() as boolean;\n return !result;\n }\n}\n\ncustomElements.define('qti-not', QtiNot);\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary The qti-null expression returns the NULL value.
|
|
4
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.null
|
|
5
|
+
*
|
|
6
|
+
* A simple expression that returns the NULL value. The null value is treated
|
|
7
|
+
* as if it is of any desired base-type.
|
|
8
|
+
*/
|
|
9
|
+
export declare class QtiNull extends QtiExpression<null> {
|
|
10
|
+
getResult(): null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary The qti-null expression returns the NULL value.
|
|
4
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.null
|
|
5
|
+
*
|
|
6
|
+
* A simple expression that returns the NULL value. The null value is treated
|
|
7
|
+
* as if it is of any desired base-type.
|
|
8
|
+
*/
|
|
9
|
+
export class QtiNull extends QtiExpression {
|
|
10
|
+
getResult() {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
customElements.define('qti-null', QtiNull);
|
|
15
|
+
//# sourceMappingURL=qti-null.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-null.js","sourceRoot":"","sources":["../../../src/components/qti-null/qti-null.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,OAAO,OAAQ,SAAQ,aAAmB;IAC9B,SAAS;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\n/**\n * @summary The qti-null expression returns the NULL value.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.null\n *\n * A simple expression that returns the NULL value. The null value is treated\n * as if it is of any desired base-type.\n */\nexport class QtiNull extends QtiExpression<null> {\n public override getResult(): null {\n return null;\n }\n}\n\ncustomElements.define('qti-null', QtiNull);\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { QtiConditionExpression } from '@qti-components/base';
|
|
2
|
+
export class QtiOr extends QtiConditionExpression {
|
|
3
|
+
getResult() {
|
|
4
|
+
// children can be a mix of qti-expression and qti-condition-expression
|
|
5
|
+
const values = Array.from(this.children).map(c => {
|
|
6
|
+
const condition = c;
|
|
7
|
+
if (!condition.calculate) {
|
|
8
|
+
console.error("Element doesn't implement QtiConditionExpression");
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const value = condition.calculate();
|
|
12
|
+
let val = false;
|
|
13
|
+
// convert string value to boolean and return null if not possible
|
|
14
|
+
if (typeof value === 'string') {
|
|
15
|
+
if (value === 'true') {
|
|
16
|
+
val = true;
|
|
17
|
+
}
|
|
18
|
+
else if (value === 'false') {
|
|
19
|
+
val = false;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.error('unexpected val in qti-or, expected boolean');
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (typeof value === 'boolean') {
|
|
28
|
+
val = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return val;
|
|
32
|
+
});
|
|
33
|
+
return values.some(e => {
|
|
34
|
+
return typeof e === 'boolean' && e;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
customElements.define('qti-or', QtiOr);
|
|
39
|
+
//# sourceMappingURL=qti-or.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-or.js","sourceRoot":"","sources":["../../../src/components/qti-or/qti-or.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,MAAM,OAAO,KAAM,SAAQ,sBAAsB;IAC/B,SAAS;QACvB,uEAAuE;QACvE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC/C,MAAM,SAAS,GAAG,CAAuB,CAAC;YAC1C,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;gBAClE,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;YACpC,IAAI,GAAG,GAAG,KAAK,CAAC;YAChB,kEAAkE;YAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBACrB,GAAG,GAAG,IAAI,CAAC;gBACb,CAAC;qBAAM,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;oBAC7B,GAAG,GAAG,KAAK,CAAC;gBACd,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;oBAC5D,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC/B,GAAG,GAAG,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,OAAO,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC","sourcesContent":["import { QtiConditionExpression } from '@qti-components/base';\n\nimport type { QtiExpression } from '@qti-components/base';\n\nexport class QtiOr extends QtiConditionExpression {\n public override getResult() {\n // children can be a mix of qti-expression and qti-condition-expression\n const values = Array.from(this.children).map(c => {\n const condition = c as QtiExpression<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.some(e => {\n return typeof e === 'boolean' && e;\n });\n }\n}\n\ncustomElements.define('qti-or', QtiOr);\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
export class QtiOrdered extends QtiExpression {
|
|
3
|
+
getResult() {
|
|
4
|
+
const variables = this.getVariables();
|
|
5
|
+
if (variables.length === 0) {
|
|
6
|
+
console.error('unexpected number of children in qti multiple');
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
for (const variable of variables) {
|
|
10
|
+
if (variable.cardinality !== 'ordered' && variable.cardinality !== 'single') {
|
|
11
|
+
console.error('unexpected cardinality in qti ordered');
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return variables;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
customElements.define('qti-ordered', QtiOrdered);
|
|
19
|
+
//# sourceMappingURL=qti-ordered.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-ordered.js","sourceRoot":"","sources":["../../../src/components/qti-ordered/qti-ordered.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,OAAO,UAAW,SAAQ,aAAiC;IAC/C,SAAS;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;QAC5D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS,IAAI,QAAQ,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;gBAC5E,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;gBACvD,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,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';\nexport class QtiOrdered extends QtiExpression<ResponseVariable[]> {\n public override getResult(): ResponseVariable[] {\n const variables = this.getVariables() as ResponseVariable[];\n if (variables.length === 0) {\n console.error('unexpected number of children in qti multiple');\n return null;\n }\n for (const variable of variables) {\n if (variable.cardinality !== 'ordered' && variable.cardinality !== 'single') {\n console.error('unexpected cardinality in qti ordered');\n return [];\n }\n }\n return variables;\n }\n}\n\ncustomElements.define('qti-ordered', QtiOrdered);\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary The qti-power operator raises the first expression to the power of the second.
|
|
4
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.power
|
|
5
|
+
*
|
|
6
|
+
* Takes 2 sub-expressions with single cardinality and numerical base-types.
|
|
7
|
+
* Returns a single float corresponding to the first expression raised to the power of the second.
|
|
8
|
+
* Returns NULL if either expression is NULL or if the result is outside the float value set.
|
|
9
|
+
*/
|
|
10
|
+
export declare class QtiPower extends QtiExpression<number | null> {
|
|
11
|
+
getResult(): number | null;
|
|
12
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary The qti-power operator raises the first expression to the power of the second.
|
|
4
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.power
|
|
5
|
+
*
|
|
6
|
+
* Takes 2 sub-expressions with single cardinality and numerical base-types.
|
|
7
|
+
* Returns a single float corresponding to the first expression raised to the power of the second.
|
|
8
|
+
* Returns NULL if either expression is NULL or if the result is outside the float value set.
|
|
9
|
+
*/
|
|
10
|
+
export class QtiPower extends QtiExpression {
|
|
11
|
+
getResult() {
|
|
12
|
+
if (this.children.length !== 2) {
|
|
13
|
+
console.error('qti-power must have exactly two child expressions');
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const variables = this.getVariables();
|
|
17
|
+
if (!variables || variables.length !== 2) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const [base, exponent] = variables;
|
|
21
|
+
// Check cardinality for both expressions
|
|
22
|
+
if (base.cardinality !== 'single' || exponent.cardinality !== 'single') {
|
|
23
|
+
console.error('qti-power requires single cardinality for both expressions');
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
// Check if values are arrays (shouldn't be for single cardinality)
|
|
27
|
+
if (Array.isArray(base.value) || Array.isArray(exponent.value)) {
|
|
28
|
+
console.error('qti-power unexpected array value for single cardinality');
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
// Handle null values
|
|
32
|
+
if (base.value === null || base.value === undefined || exponent.value === null || exponent.value === undefined) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
// Check base types
|
|
36
|
+
if ((base.baseType !== 'integer' && base.baseType !== 'float') ||
|
|
37
|
+
(exponent.baseType !== 'integer' && exponent.baseType !== 'float')) {
|
|
38
|
+
console.error('qti-power requires numerical base-types');
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
// Convert to numbers
|
|
42
|
+
const baseValue = parseFloat(base.value);
|
|
43
|
+
const exponentValue = parseFloat(exponent.value);
|
|
44
|
+
// Check for NaN values
|
|
45
|
+
if (isNaN(baseValue) || isNaN(exponentValue)) {
|
|
46
|
+
console.error('qti-power: non-numerical values encountered');
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
// Handle special cases that should return NULL according to mathematical rules
|
|
50
|
+
if (baseValue === 0 && exponentValue <= 0) {
|
|
51
|
+
// 0^0, 0^(-n) are undefined
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (baseValue < 0 && !Number.isInteger(exponentValue)) {
|
|
55
|
+
// Negative base with non-integer exponent results in complex number
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
// Calculate the power
|
|
59
|
+
let result;
|
|
60
|
+
try {
|
|
61
|
+
result = Math.pow(baseValue, exponentValue);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error('qti-power: error calculating power:', error);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Check if result is within valid float range
|
|
68
|
+
if (isNaN(result)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
// Allow positive and negative infinity as per spec
|
|
72
|
+
if (result === Infinity || result === -Infinity) {
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
// Check if result is within JavaScript's safe number range
|
|
76
|
+
// This is a practical limit for what can be represented as a float
|
|
77
|
+
if (!isFinite(result)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
// Additional check for extremely large or small numbers that might cause issues
|
|
81
|
+
if (Math.abs(result) > Number.MAX_VALUE) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
// Check for underflow (extremely small numbers that round to 0)
|
|
85
|
+
if (result !== 0 && Math.abs(result) < Number.MIN_VALUE) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (isFinite(result) && result !== 0) {
|
|
89
|
+
// Determine appropriate precision based on the magnitude of the result
|
|
90
|
+
const magnitude = Math.floor(Math.log10(Math.abs(result)));
|
|
91
|
+
const precision = Math.max(0, 14 - magnitude); // Maintain 14 significant digits
|
|
92
|
+
const factor = Math.pow(10, precision);
|
|
93
|
+
result = Math.round(result * factor) / factor;
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
customElements.define('qti-power', QtiPower);
|
|
99
|
+
//# sourceMappingURL=qti-power.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-power.js","sourceRoot":"","sources":["../../../src/components/qti-power/qti-power.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD;;;;;;;GAOG;AACH,MAAM,OAAO,QAAS,SAAQ,aAA4B;IACxC,SAAS;QACvB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACnE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;QAC5D,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K,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;YACxD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,uEAAuE;YACvE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,iCAAiC;YAChF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YACvC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\n\n/**\n * @summary The qti-power operator raises the first expression to the power of the second.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.power\n *\n * Takes 2 sub-expressions with single cardinality and numerical base-types.\n * Returns a single float corresponding to the first expression raised to the power of the second.\n * Returns NULL if either expression is NULL or if the result is outside the float value set.\n */\nexport class QtiPower extends QtiExpression<number | null> {\n public override getResult(): number | null {\n if (this.children.length !== 2) {\n console.error('qti-power must have exactly two child expressions');\n return null;\n }\n\n const variables = this.getVariables() as ResponseVariable[];\n if (!variables || variables.length !== 2) {\n return null;\n }\n\n const [base, exponent] = variables;\n\n // Check cardinality for both expressions\n if (base.cardinality !== 'single' || exponent.cardinality !== 'single') {\n console.error('qti-power requires single cardinality for both expressions');\n return null;\n }\n\n // Check if values are arrays (shouldn't be for single cardinality)\n if (Array.isArray(base.value) || Array.isArray(exponent.value)) {\n console.error('qti-power unexpected array value for single cardinality');\n return null;\n }\n\n // Handle null values\n if (base.value === null || base.value === undefined || exponent.value === null || exponent.value === undefined) {\n return null;\n }\n\n // Check base types\n if (\n (base.baseType !== 'integer' && base.baseType !== 'float') ||\n (exponent.baseType !== 'integer' && exponent.baseType !== 'float')\n ) {\n console.error('qti-power requires numerical base-types');\n return null;\n }\n\n // Convert to numbers\n const baseValue = parseFloat(base.value as string);\n const exponentValue = parseFloat(exponent.value as string);\n\n // Check for NaN values\n if (isNaN(baseValue) || isNaN(exponentValue)) {\n console.error('qti-power: non-numerical values encountered');\n return null;\n }\n\n // Handle special cases that should return NULL according to mathematical rules\n if (baseValue === 0 && exponentValue <= 0) {\n // 0^0, 0^(-n) are undefined\n return null;\n }\n\n if (baseValue < 0 && !Number.isInteger(exponentValue)) {\n // Negative base with non-integer exponent results in complex number\n return null;\n }\n\n // Calculate the power\n let result: number;\n try {\n result = Math.pow(baseValue, exponentValue);\n } catch (error) {\n console.error('qti-power: error calculating power:', error);\n return null;\n }\n\n // Check if result is within valid float range\n if (isNaN(result)) {\n return null;\n }\n\n // Allow positive and negative infinity as per spec\n if (result === Infinity || result === -Infinity) {\n return result;\n }\n\n // Check if result is within JavaScript's safe number range\n // This is a practical limit for what can be represented as a float\n if (!isFinite(result)) {\n return null;\n }\n\n // Additional check for extremely large or small numbers that might cause issues\n if (Math.abs(result) > Number.MAX_VALUE) {\n return null;\n }\n\n // Check for underflow (extremely small numbers that round to 0)\n if (result !== 0 && Math.abs(result) < Number.MIN_VALUE) {\n return null;\n }\n if (isFinite(result) && result !== 0) {\n // Determine appropriate precision based on the magnitude of the result\n const magnitude = Math.floor(Math.log10(Math.abs(result)));\n const precision = Math.max(0, 14 - magnitude); // Maintain 14 significant digits\n const factor = Math.pow(10, precision);\n result = Math.round(result * factor) / factor;\n }\n\n return result;\n }\n}\n\ncustomElements.define('qti-power', QtiPower);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LitElement, nothing } from 'lit';
|
|
2
|
+
import type { VariableDeclaration } from '@qti-components/base';
|
|
3
|
+
import type { ItemContext } from '@qti-components/base';
|
|
4
|
+
export declare class QtiPrintedVariable extends LitElement {
|
|
5
|
+
identifier: string;
|
|
6
|
+
protected context?: ItemContext;
|
|
7
|
+
render(): import("lit").TemplateResult<1> | typeof nothing;
|
|
8
|
+
calculate(): VariableDeclaration<string | string[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { consume } from '@lit/context';
|
|
8
|
+
import { LitElement, html, nothing } from 'lit';
|
|
9
|
+
import { property, state } from 'lit/decorators.js';
|
|
10
|
+
import { itemContext } from '@qti-components/base';
|
|
11
|
+
export class QtiPrintedVariable extends LitElement {
|
|
12
|
+
render() {
|
|
13
|
+
const value = this.context?.variables.find(v => v.identifier === this.identifier)?.value;
|
|
14
|
+
return value === null ? nothing : html `${JSON.stringify(value, null, 2)}`;
|
|
15
|
+
}
|
|
16
|
+
calculate() {
|
|
17
|
+
const result = this.context.variables.find(v => v.identifier === this.identifier) || null;
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
__decorate([
|
|
22
|
+
property({ type: String })
|
|
23
|
+
], QtiPrintedVariable.prototype, "identifier", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
consume({ context: itemContext, subscribe: true }),
|
|
26
|
+
state()
|
|
27
|
+
], QtiPrintedVariable.prototype, "context", void 0);
|
|
28
|
+
customElements.define('qti-printed-variable', QtiPrintedVariable);
|
|
29
|
+
//# sourceMappingURL=qti-printed-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-printed-variable.js","sourceRoot":"","sources":["../../../src/components/qti-printed-variable/qti-printed-variable.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKnD,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAQvC,MAAM;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;QACzF,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IAC5E,CAAC;IAEM,SAAS;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC;QAC1F,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAfC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDACR;AAIT;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClD,KAAK,EAAE;mDACwB;AAalC,cAAc,CAAC,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { consume } from '@lit/context';\nimport { LitElement, html, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { itemContext } from '@qti-components/base';\n\nimport type { VariableDeclaration } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\nexport class QtiPrintedVariable extends LitElement {\n @property({ type: String })\n identifier: string;\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n protected context?: ItemContext;\n\n override render() {\n const value = this.context?.variables.find(v => v.identifier === this.identifier)?.value;\n return value === null ? nothing : html`${JSON.stringify(value, null, 2)}`;\n }\n\n public calculate(): VariableDeclaration<string | string[]> {\n const result = this.context.variables.find(v => v.identifier === this.identifier) || null;\n return result;\n }\n}\n\ncustomElements.define('qti-printed-variable', QtiPrintedVariable);\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
export class QtiProduct extends QtiExpression {
|
|
3
|
+
getResult() {
|
|
4
|
+
const values = this.getVariables();
|
|
5
|
+
const product = values.reduce((accumulator, currentValue) => {
|
|
6
|
+
if (currentValue.baseType == 'float' || currentValue.baseType == 'integer') {
|
|
7
|
+
try {
|
|
8
|
+
return accumulator * parseFloat(currentValue.value.toString());
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.warn(`can not convert to number`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.warn(`has another baseType ${currentValue.baseType}`);
|
|
16
|
+
}
|
|
17
|
+
return accumulator;
|
|
18
|
+
}, 1);
|
|
19
|
+
return product;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
customElements.define('qti-product', QtiProduct);
|
|
23
|
+
//# sourceMappingURL=qti-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-product.js","sourceRoot":"","sources":["../../../src/components/qti-product/qti-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,OAAO,UAAW,SAAQ,aAAqB;IACnC,SAAS;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAwB,CAAC;QACzD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE;YAC1D,IAAI,YAAY,CAAC,QAAQ,IAAI,OAAO,IAAI,YAAY,CAAC,QAAQ,IAAI,SAAS,EAAE,CAAC;gBAC3E,IAAI,CAAC;oBACH,OAAO,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACjE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,wBAAwB,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;YAChE,CAAC;YACD,OAAO,WAAW,CAAC;QACrB,CAAC,EAAE,CAAC,CAAC,CAAC;QACN,OAAO,OAAO,CAAC;IACjB,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 QtiProduct extends QtiExpression<number> {\n public override getResult() {\n const values = this.getVariables() as ResponseVariable[];\n const product = values.reduce((accumulator, currentValue) => {\n if (currentValue.baseType == 'float' || currentValue.baseType == 'integer') {\n try {\n return accumulator * parseFloat(currentValue.value.toString());\n } catch (error) {\n console.warn(`can not convert to number`);\n }\n } else {\n console.warn(`has another baseType ${currentValue.baseType}`);\n }\n return accumulator;\n }, 1);\n return product;\n }\n}\n\ncustomElements.define('qti-product', QtiProduct);\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
export class QtiRandom extends QtiExpression {
|
|
3
|
+
getResult() {
|
|
4
|
+
const values = this.getVariables();
|
|
5
|
+
// console.log(values);
|
|
6
|
+
if (values.length === 1) {
|
|
7
|
+
const value = values[0].value;
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
const randomIndex = Math.floor(Math.random() * value.length);
|
|
10
|
+
return value[randomIndex];
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
console.error('unexpected number of children in match');
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
customElements.define('qti-random', QtiRandom);
|
|
19
|
+
//# sourceMappingURL=qti-random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-random.js","sourceRoot":"","sources":["../../../src/components/qti-random/qti-random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,OAAO,SAAU,SAAQ,aAAqB;IAClC,SAAS;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,uBAAuB;QAEvB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC7D,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { QtiExpression } from '@qti-components/base';\n\nexport class QtiRandom extends QtiExpression<string> {\n public override getResult() {\n const values = this.getVariables();\n // console.log(values);\n\n if (values.length === 1) {\n const value = values[0].value;\n if (Array.isArray(value)) {\n const randomIndex = Math.floor(Math.random() * value.length);\n return value[randomIndex];\n }\n return value;\n }\n console.error('unexpected number of children in match');\n return null;\n }\n}\n\ncustomElements.define('qti-random', QtiRandom);\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { QtiExpression } from '@qti-components/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary The qti-random-integer operator selects a random integer from a specified range.
|
|
4
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.random-integer
|
|
5
|
+
*
|
|
6
|
+
* Selects a random integer from the range [min,max] satisfying min + step * n for some integer n.
|
|
7
|
+
* For example, with min=2, max=11 and step=3 the values {2,5,8,11} are possible.
|
|
8
|
+
*/
|
|
9
|
+
export declare class QtiRandomInteger extends QtiExpression<number> {
|
|
10
|
+
min: number;
|
|
11
|
+
max: number;
|
|
12
|
+
step: number;
|
|
13
|
+
getResult(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Get all possible values for testing purposes
|
|
16
|
+
*/
|
|
17
|
+
getPossibleValues(): number[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* @summary The qti-random-integer operator selects a random integer from a specified range.
|
|
11
|
+
* @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.random-integer
|
|
12
|
+
*
|
|
13
|
+
* Selects a random integer from the range [min,max] satisfying min + step * n for some integer n.
|
|
14
|
+
* For example, with min=2, max=11 and step=3 the values {2,5,8,11} are possible.
|
|
15
|
+
*/
|
|
16
|
+
export class QtiRandomInteger extends QtiExpression {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.min = 0;
|
|
20
|
+
this.max = 10;
|
|
21
|
+
this.step = 1;
|
|
22
|
+
}
|
|
23
|
+
getResult() {
|
|
24
|
+
// Validate attributes
|
|
25
|
+
if (this.min > this.max) {
|
|
26
|
+
console.error('qti-random-integer: min cannot be greater than max');
|
|
27
|
+
return this.min;
|
|
28
|
+
}
|
|
29
|
+
if (this.step <= 0) {
|
|
30
|
+
console.error('qti-random-integer: step must be positive');
|
|
31
|
+
return this.min;
|
|
32
|
+
}
|
|
33
|
+
// Calculate all possible values in the range
|
|
34
|
+
const possibleValues = [];
|
|
35
|
+
// Generate values using the formula: min + step * n for integer n
|
|
36
|
+
let n = 0;
|
|
37
|
+
while (true) {
|
|
38
|
+
const value = this.min + this.step * n;
|
|
39
|
+
if (value > this.max) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
// Only add integer values
|
|
43
|
+
if (Number.isInteger(value)) {
|
|
44
|
+
possibleValues.push(value);
|
|
45
|
+
}
|
|
46
|
+
n++;
|
|
47
|
+
}
|
|
48
|
+
// If no valid integer values found, return min (if it's an integer) or floor(min)
|
|
49
|
+
if (possibleValues.length === 0) {
|
|
50
|
+
console.warn('qti-random-integer: no valid integer values in range');
|
|
51
|
+
return Number.isInteger(this.min) ? this.min : Math.floor(this.min);
|
|
52
|
+
}
|
|
53
|
+
// Select a random value from the possible values
|
|
54
|
+
const randomIndex = Math.floor(Math.random() * possibleValues.length);
|
|
55
|
+
return possibleValues[randomIndex];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get all possible values for testing purposes
|
|
59
|
+
*/
|
|
60
|
+
getPossibleValues() {
|
|
61
|
+
const possibleValues = [];
|
|
62
|
+
if (this.min > this.max || this.step <= 0) {
|
|
63
|
+
return [Number.isInteger(this.min) ? this.min : Math.floor(this.min)];
|
|
64
|
+
}
|
|
65
|
+
let n = 0;
|
|
66
|
+
while (true) {
|
|
67
|
+
const value = this.min + this.step * n;
|
|
68
|
+
if (value > this.max) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
// Only add integer values
|
|
72
|
+
if (Number.isInteger(value)) {
|
|
73
|
+
possibleValues.push(value);
|
|
74
|
+
}
|
|
75
|
+
n++;
|
|
76
|
+
}
|
|
77
|
+
return possibleValues.length > 0 ? possibleValues : [Number.isInteger(this.min) ? this.min : Math.floor(this.min)];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
__decorate([
|
|
81
|
+
property({ type: Number })
|
|
82
|
+
], QtiRandomInteger.prototype, "min", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
property({ type: Number })
|
|
85
|
+
], QtiRandomInteger.prototype, "max", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
property({ type: Number })
|
|
88
|
+
], QtiRandomInteger.prototype, "step", void 0);
|
|
89
|
+
customElements.define('qti-random-integer', QtiRandomInteger);
|
|
90
|
+
//# sourceMappingURL=qti-random-integer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-random-integer.js","sourceR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CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrH,CAAC;CACF;AArE6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAkB;AAqE/C,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { property } from 'lit/decorators.js';\n\nimport { QtiExpression } from '@qti-components/base';\n\n/**\n * @summary The qti-random-integer operator selects a random integer from a specified range.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.random-integer\n *\n * Selects a random integer from the range [min,max] satisfying min + step * n for some integer n.\n * For example, with min=2, max=11 and step=3 the values {2,5,8,11} are possible.\n */\nexport class QtiRandomInteger extends QtiExpression<number> {\n @property({ type: Number }) min: number = 0;\n @property({ type: Number }) max: number = 10;\n @property({ type: Number }) step: number = 1;\n\n public override getResult(): number {\n // Validate attributes\n if (this.min > this.max) {\n console.error('qti-random-integer: min cannot be greater than max');\n return this.min;\n }\n\n if (this.step <= 0) {\n console.error('qti-random-integer: step must be positive');\n return this.min;\n }\n\n // Calculate all possible values in the range\n const possibleValues: number[] = [];\n\n // Generate values using the formula: min + step * n for integer n\n let n = 0;\n while (true) {\n const value = this.min + this.step * n;\n if (value > this.max) {\n break;\n }\n // Only add integer values\n if (Number.isInteger(value)) {\n possibleValues.push(value);\n }\n n++;\n }\n\n // If no valid integer values found, return min (if it's an integer) or floor(min)\n if (possibleValues.length === 0) {\n console.warn('qti-random-integer: no valid integer values in range');\n return Number.isInteger(this.min) ? this.min : Math.floor(this.min);\n }\n\n // Select a random value from the possible values\n const randomIndex = Math.floor(Math.random() * possibleValues.length);\n return possibleValues[randomIndex];\n }\n\n /**\n * Get all possible values for testing purposes\n */\n public getPossibleValues(): number[] {\n const possibleValues: number[] = [];\n\n if (this.min > this.max || this.step <= 0) {\n return [Number.isInteger(this.min) ? this.min : Math.floor(this.min)];\n }\n\n let n = 0;\n while (true) {\n const value = this.min + this.step * n;\n if (value > this.max) {\n break;\n }\n // Only add integer values\n if (Number.isInteger(value)) {\n possibleValues.push(value);\n }\n n++;\n }\n\n return possibleValues.length > 0 ? possibleValues : [Number.isInteger(this.min) ? this.min : Math.floor(this.min)];\n }\n}\n\ncustomElements.define('qti-random-integer', QtiRandomInteger);\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { QtiRule } from '../qti-rule/qti-rule';
|
|
3
|
+
export class QtiResponseCondition extends QtiRule {
|
|
4
|
+
render() {
|
|
5
|
+
return html `<slot></slot>`;
|
|
6
|
+
}
|
|
7
|
+
process() {
|
|
8
|
+
const branches = [...this.children];
|
|
9
|
+
for (let i = 0; i < branches.length; i++) {
|
|
10
|
+
const branch = branches[i];
|
|
11
|
+
if (branch.calculate()) {
|
|
12
|
+
branch.process();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
customElements.define('qti-response-condition', QtiResponseCondition);
|
|
19
|
+
//# sourceMappingURL=qti-response-condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-response-condition.js","sourceRoot":"","sources":["../../../src/components/qti-response-condition/qti-response-condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAI/C,MAAM,OAAO,oBAAqB,SAAQ,OAAO;IACtC,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;IAEe,OAAO;QACrB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAyB,CAAC;QAE5D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAE3B,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;gBACtB,MAA6B,CAAC,OAAO,EAAE,CAAC;gBAEzC,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\n\nimport { QtiRule } from '../qti-rule/qti-rule';\n\nimport type { QtiExpression } from '@qti-components/base';\n\nexport class QtiResponseCondition extends QtiRule {\n override render() {\n return html`<slot></slot>`;\n }\n\n public override process() {\n const branches = [...this.children] as QtiExpression<any>[];\n\n for (let i = 0; i < branches.length; i++) {\n const branch = branches[i];\n\n if (branch.calculate()) {\n (branch as unknown as QtiRule).process();\n\n return;\n }\n }\n }\n}\n\ncustomElements.define('qti-response-condition', QtiResponseCondition);\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { QtiRule } from '../qti-rule/qti-rule';
|
|
3
|
+
export declare class QtiResponseElse extends LitElement {
|
|
4
|
+
render(): import("lit").TemplateResult<1>;
|
|
5
|
+
calculate(): boolean;
|
|
6
|
+
getSubRules(): QtiRule[];
|
|
7
|
+
process(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LitElement, html } from 'lit';
|
|
2
|
+
export class QtiResponseElse extends LitElement {
|
|
3
|
+
render() {
|
|
4
|
+
return html `<slot></slot>`;
|
|
5
|
+
}
|
|
6
|
+
calculate() {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
getSubRules() {
|
|
10
|
+
return [...this.children];
|
|
11
|
+
}
|
|
12
|
+
process() {
|
|
13
|
+
const subRules = this.getSubRules();
|
|
14
|
+
for (let i = 0; i < subRules.length; i++) {
|
|
15
|
+
const subRule = subRules[i];
|
|
16
|
+
subRule.process();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
customElements.define('qti-response-else', QtiResponseElse);
|
|
21
|
+
//# sourceMappingURL=qti-response-else.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-response-else.js","sourceRoot":"","sources":["../../../src/components/qti-response-else/qti-response-else.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAIvC,MAAM,OAAO,eAAgB,SAAQ,UAAU;IACpC,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,WAAW;QAChB,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAc,CAAC;IACzC,CAAC;IAEM,OAAO;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5B,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { LitElement, html } from 'lit';\n\nimport type { QtiRule } from '../qti-rule/qti-rule';\n\nexport class QtiResponseElse extends LitElement {\n override render() {\n return html`<slot></slot>`;\n }\n\n public calculate() {\n return true;\n }\n\n public getSubRules(): QtiRule[] {\n return [...this.children] as QtiRule[];\n }\n\n public process() {\n const subRules = this.getSubRules();\n for (let i = 0; i < subRules.length; i++) {\n const subRule = subRules[i];\n subRule.process();\n }\n }\n}\n\ncustomElements.define('qti-response-else', QtiResponseElse);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { QtiResponseIf } from '../qti-response-if/qti-response-if';
|
|
3
|
+
export class QtiResponseElseIf extends QtiResponseIf {
|
|
4
|
+
render() {
|
|
5
|
+
return html `${super.render()}`;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
customElements.define('qti-response-else-if', QtiResponseElseIf);
|
|
9
|
+
//# sourceMappingURL=qti-response-else-if.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-response-else-if.js","sourceRoot":"","sources":["../../../src/components/qti-response-else-if/qti-response-else-if.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IACzC,MAAM;QACb,OAAO,IAAI,CAAA,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;IACjC,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\n\nimport { QtiResponseIf } from '../qti-response-if/qti-response-if';\n\nexport class QtiResponseElseIf extends QtiResponseIf {\n override render() {\n return html`${super.render()}`;\n }\n}\n\ncustomElements.define('qti-response-else-if', QtiResponseElseIf);\n"]}
|