math-exercises 3.0.81 → 3.0.83
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isNumberDecimal.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/isNumberDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"isNumberDecimal.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/isNumberDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAa7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE;QACP,CAAC,EAAE,eAAe,CAAC;QACnB,SAAS,EAAE,OAAO,CAAC;KACpB,EAAE,CAAC;CACL,CAAC;AAqIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAmBjD,CAAC"}
|
|
@@ -4,10 +4,12 @@ import { RationalConstructor } from "../../../../math/numbers/rationals/rational
|
|
|
4
4
|
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
5
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
6
|
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
7
|
+
import { isConstantNode } from "../../../../tree/nodes/numbers/constantNode.js";
|
|
7
8
|
import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
|
|
8
9
|
import { isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
9
10
|
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
11
|
import { random } from "../../../../utils/alea/random.js";
|
|
12
|
+
import { doWhile } from "../../../../utils/doWhile.js";
|
|
11
13
|
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
14
|
const getPropositions = (n, { answer, options }) => {
|
|
13
15
|
const propositions = [];
|
|
@@ -37,7 +39,10 @@ const getCorrection = (identifiers) => {
|
|
|
37
39
|
for (const { a, isDecimal } of options) {
|
|
38
40
|
const node = reifyAlgebraic(a);
|
|
39
41
|
const tex = node.toTex();
|
|
40
|
-
if (
|
|
42
|
+
if (isConstantNode(node)) {
|
|
43
|
+
correction += `- $${tex}$ n'est pas un nombre décimal, car il s'écrit avec un nombre infini de chiffres après la virgule.\n\n`;
|
|
44
|
+
}
|
|
45
|
+
else if (isFractionNode(node)) {
|
|
41
46
|
const denom = node.rightChild.toTex();
|
|
42
47
|
if (isDecimal) {
|
|
43
48
|
correction += `- $${tex} = ${node
|
|
@@ -75,15 +80,15 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
75
80
|
};
|
|
76
81
|
const generateNonDecimalNumber = () => {
|
|
77
82
|
const nonDecimals = [];
|
|
78
|
-
nonDecimals.push(RationalConstructor.randomPureRational().toTree()
|
|
79
|
-
nonDecimals.push(PiNode
|
|
83
|
+
nonDecimals.push(RationalConstructor.randomPureRational().toTree());
|
|
84
|
+
nonDecimals.push(PiNode);
|
|
80
85
|
return random(nonDecimals);
|
|
81
86
|
};
|
|
82
87
|
const generateDecimalNumber = () => {
|
|
83
88
|
const decimals = [];
|
|
84
|
-
decimals.push(randint(0, 100).toTree()
|
|
85
|
-
decimals.push(randfloat(0, 100, 2).toTree()
|
|
86
|
-
decimals.push(RationalConstructor.randomDecimal().toTree()
|
|
89
|
+
decimals.push(randint(0, 100).toTree());
|
|
90
|
+
decimals.push(randfloat(0, 100, 2).toTree());
|
|
91
|
+
decimals.push(RationalConstructor.randomDecimal().toTree());
|
|
87
92
|
return random(decimals);
|
|
88
93
|
};
|
|
89
94
|
const getIsNumberdecimalQuestion = (ops) => {
|
|
@@ -94,12 +99,17 @@ const getIsNumberdecimalQuestion = (ops) => {
|
|
|
94
99
|
choices.push({ a: nonDecimal, isDecimal: false });
|
|
95
100
|
for (let i = 0; i < 2; i++) {
|
|
96
101
|
const isDecimal = coinFlip();
|
|
97
|
-
const randomNumber = isDecimal
|
|
98
|
-
? generateDecimalNumber()
|
|
99
|
-
: generateNonDecimalNumber();
|
|
102
|
+
const randomNumber = doWhile(() => (isDecimal ? generateDecimalNumber() : generateNonDecimalNumber()), (a) => choices.some((c) => c.a.toTex() === a.toTex()));
|
|
100
103
|
choices.push({ a: randomNumber, isDecimal });
|
|
101
104
|
}
|
|
102
|
-
const identifiers = {
|
|
105
|
+
const identifiers = {
|
|
106
|
+
options: choices.map((c) => {
|
|
107
|
+
return {
|
|
108
|
+
a: c.a.toIdentifiers(),
|
|
109
|
+
isDecimal: c.isDecimal,
|
|
110
|
+
};
|
|
111
|
+
}),
|
|
112
|
+
};
|
|
103
113
|
return getQuestionFromIdentifiers(identifiers);
|
|
104
114
|
};
|
|
105
115
|
const getQuestionFromIdentifiers = (identifiers) => {
|