math-exercises 2.2.92 → 2.2.94
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/lib/exercises/math/calcul/fractions/fractionSquare.d.ts +8 -0
- package/lib/exercises/math/calcul/fractions/fractionSquare.d.ts.map +1 -0
- package/lib/exercises/math/calcul/fractions/fractionSquare.js +106 -0
- package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
- package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/index.js +1 -0
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts +9 -0
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +160 -126
- package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.js +75 -41
- package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.js +70 -40
- package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.js +78 -47
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +0 -1
- package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineExpressionReading.js +45 -23
- package/lib/exercises/math/percent/findRightCalcul.d.ts +10 -0
- package/lib/exercises/math/percent/findRightCalcul.d.ts.map +1 -0
- package/lib/exercises/math/percent/findRightCalcul.js +116 -0
- package/lib/exercises/math/percent/htToTTC.d.ts.map +1 -1
- package/lib/exercises/math/percent/htToTTC.js +34 -12
- package/lib/exercises/math/percent/index.d.ts +1 -0
- package/lib/exercises/math/percent/index.d.ts.map +1 -1
- package/lib/exercises/math/percent/index.js +2 -0
- package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
- package/lib/exercises/math/percent/percentToDecimal.js +6 -2
- package/lib/exercises/math/percent/percentWritings.d.ts +8 -0
- package/lib/exercises/math/percent/percentWritings.d.ts.map +1 -0
- package/lib/exercises/math/percent/percentWritings.js +136 -0
- package/lib/exercises/math/percent/ttcToHT.d.ts.map +1 -1
- package/lib/exercises/math/percent/ttcToHT.js +33 -12
- package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.js +54 -23
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +4 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +6 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +4 -0
- package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.js +14 -0
- package/package.json +1 -1
|
@@ -12,31 +12,39 @@ const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
|
12
12
|
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
13
13
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
14
14
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const latexParser_1 = require("../../../../tree/parsers/latexParser");
|
|
16
|
+
const getInstruction = (identifiers) => {
|
|
17
|
+
return `Factoriser :
|
|
18
|
+
|
|
19
|
+
$$
|
|
20
|
+
${getStartStatement(identifiers)}
|
|
21
|
+
$$`;
|
|
22
|
+
};
|
|
23
|
+
const getAnswer = (identifiers) => {
|
|
24
|
+
const affine = new affine_1.Affine(identifiers.a, identifiers.b);
|
|
23
25
|
const answerTree = new powerNode_1.PowerNode(affine.toTree(), new numberNode_1.NumberNode(2));
|
|
24
|
-
const answer = answerTree.toTex();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
answer,
|
|
30
|
-
keys: ["x"],
|
|
31
|
-
answerFormat: "tex",
|
|
32
|
-
identifiers: { a: affine.a, b: affine.b },
|
|
33
|
-
hint: `Essaie de réécrire cette expression sous la forme
|
|
26
|
+
const answer = answerTree.simplify().toTex();
|
|
27
|
+
return answer;
|
|
28
|
+
};
|
|
29
|
+
const getHint = (identifiers) => {
|
|
30
|
+
return `Essaie de réécrire cette expression sous la forme
|
|
34
31
|
|
|
35
32
|
$$
|
|
36
33
|
a^2 - 2ab+b^2
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
$$`;
|
|
35
|
+
};
|
|
36
|
+
const getStartStatement = (identifiers) => {
|
|
37
|
+
const affine = new affine_1.Affine(identifiers.a, identifiers.b);
|
|
38
|
+
const statementTree = affine.multiply(affine).toTree();
|
|
39
|
+
const statementTex = statementTree.toTex();
|
|
40
|
+
return statementTex;
|
|
41
|
+
};
|
|
42
|
+
const getCorrection = (identifiers) => {
|
|
43
|
+
const affine = new affine_1.Affine(identifiers.a, identifiers.b);
|
|
44
|
+
const answer = getAnswer(identifiers);
|
|
45
|
+
const statementTex = getStartStatement(identifiers);
|
|
46
|
+
const aMonom = new affine_1.Affine(affine.a, 0).toTree();
|
|
47
|
+
return `On utilise l'identité remarquable
|
|
40
48
|
|
|
41
49
|
$$
|
|
42
50
|
a^2 - 2ab+b^2 = (a-b)^2
|
|
@@ -45,14 +53,30 @@ $$
|
|
|
45
53
|
en prenant $a=${aMonom.toTex()}$ et $b=${-affine.b}$ :
|
|
46
54
|
|
|
47
55
|
${(0, alignTex_1.alignTex)([
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
[
|
|
57
|
+
statementTex,
|
|
58
|
+
"=",
|
|
59
|
+
new addNode_1.AddNode(new substractNode_1.SubstractNode(new powerNode_1.SquareNode(aMonom), new multiplyNode_1.MultiplyNode((2).toTree(), new multiplyNode_1.MultiplyNode(aMonom, (-affine.b).toTree()))), new powerNode_1.SquareNode((-affine.b).toTree())).toTex(),
|
|
60
|
+
],
|
|
61
|
+
["", "=", answer],
|
|
62
|
+
])}
|
|
63
|
+
`;
|
|
64
|
+
};
|
|
65
|
+
const getFactoType1Question = () => {
|
|
66
|
+
const affine = affine_1.AffineConstructor.random({
|
|
67
|
+
min: 1,
|
|
68
|
+
max: 10,
|
|
69
|
+
}, { min: -9, max: 0 });
|
|
70
|
+
const identifiers = { a: affine.a, b: affine.b };
|
|
71
|
+
const question = {
|
|
72
|
+
instruction: getInstruction(identifiers),
|
|
73
|
+
startStatement: getStartStatement(identifiers),
|
|
74
|
+
answer: getAnswer(identifiers),
|
|
75
|
+
keys: ["x"],
|
|
76
|
+
answerFormat: "tex",
|
|
77
|
+
identifiers,
|
|
78
|
+
hint: getHint(identifiers),
|
|
79
|
+
correction: getCorrection(identifiers),
|
|
56
80
|
};
|
|
57
81
|
return question;
|
|
58
82
|
};
|
|
@@ -67,18 +91,20 @@ const getPropositions = (n, { answer, a, b }) => {
|
|
|
67
91
|
}
|
|
68
92
|
return (0, shuffle_1.shuffle)(propositions);
|
|
69
93
|
};
|
|
70
|
-
const isAnswerValid = (ans, { a, b }) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
const isAnswerValid = (ans, { answer, a, b }) => {
|
|
95
|
+
try {
|
|
96
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
97
|
+
if (!parsed)
|
|
98
|
+
return false;
|
|
99
|
+
if (!(0, multiplyNode_1.isMultiplyNode)(parsed) &&
|
|
100
|
+
!(0, powerNode_1.isSquareNode)(parsed) &&
|
|
101
|
+
!(0, powerNode_1.isPowerNode)(parsed))
|
|
102
|
+
return false;
|
|
103
|
+
return parsed.simplify().toTex() === answer;
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
return false;
|
|
80
107
|
}
|
|
81
|
-
return validLatexs.includes(ans);
|
|
82
108
|
};
|
|
83
109
|
exports.factoIdRmq2 = {
|
|
84
110
|
id: "factoIdRmq2",
|
|
@@ -94,4 +120,8 @@ exports.factoIdRmq2 = {
|
|
|
94
120
|
isAnswerValid,
|
|
95
121
|
subject: "Mathématiques",
|
|
96
122
|
hasHintAndCorrection: true,
|
|
123
|
+
getAnswer,
|
|
124
|
+
getCorrection,
|
|
125
|
+
getHint,
|
|
126
|
+
getInstruction,
|
|
97
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factoIdRmq3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoIdRmq3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"factoIdRmq3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoIdRmq3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAkBlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAmKF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAkB7C,CAAC"}
|
|
@@ -4,41 +4,41 @@ exports.factoIdRmq3 = void 0;
|
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
6
|
const affine_1 = require("../../../../math/polynomials/affine");
|
|
7
|
-
const gcd_1 = require("../../../../math/utils/arithmetic/gcd");
|
|
8
7
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
8
|
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
10
9
|
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
11
10
|
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
11
|
+
const latexParser_1 = require("../../../../tree/parsers/latexParser");
|
|
12
12
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
13
|
-
const
|
|
14
|
-
const affine = affine_1.
|
|
15
|
-
|
|
16
|
-
max: 11,
|
|
17
|
-
}, { excludes: [0] });
|
|
18
|
-
const affine2 = new affine_1.Affine(affine.a, -affine.b);
|
|
19
|
-
const statementTree = affine.multiply(affine2).toTree();
|
|
20
|
-
const statementTex = statementTree.toTex();
|
|
21
|
-
const bPositive = Math.abs(affine.b);
|
|
22
|
-
const aMonom = new multiplyNode_1.MultiplyNode(affine.a.toTree(), "x".toTree());
|
|
13
|
+
const getAnswer = (identifiers) => {
|
|
14
|
+
const affine = new affine_1.Affine(identifiers.affine1Coeffs[1], identifiers.affine1Coeffs[0]);
|
|
15
|
+
const affine2 = new affine_1.Affine(identifiers.affine2Coeffs[1], identifiers.affine2Coeffs[0]);
|
|
23
16
|
const answerTree = new multiplyNode_1.MultiplyNode(affine.toTree(), affine2.toTree());
|
|
24
|
-
const answer = answerTree.toTex();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
const answer = answerTree.simplify().toTex();
|
|
18
|
+
return answer;
|
|
19
|
+
};
|
|
20
|
+
const getInstruction = (identifiers) => {
|
|
21
|
+
return `Factoriser :
|
|
22
|
+
|
|
23
|
+
$$
|
|
24
|
+
${getStartStatement(identifiers)}
|
|
25
|
+
$$`;
|
|
26
|
+
};
|
|
27
|
+
const getHint = (identifiers) => {
|
|
28
|
+
return `Utilise l'identité remarquable
|
|
36
29
|
|
|
37
30
|
$$
|
|
38
31
|
a^2 - b^2 = (a-b)(a+b)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
$$`;
|
|
33
|
+
};
|
|
34
|
+
const getCorrection = (identifiers) => {
|
|
35
|
+
const affine = new affine_1.Affine(identifiers.affine1Coeffs[1], identifiers.affine1Coeffs[0]);
|
|
36
|
+
const affine2 = new affine_1.Affine(identifiers.affine2Coeffs[1], identifiers.affine2Coeffs[0]);
|
|
37
|
+
const statementTex = getStartStatement(identifiers);
|
|
38
|
+
const answer = getAnswer(identifiers);
|
|
39
|
+
const bPositive = Math.abs(affine.b);
|
|
40
|
+
const aMonom = new multiplyNode_1.MultiplyNode(affine.a.toTree(), "x".toTree());
|
|
41
|
+
return `On utilise l'identité remarquable
|
|
42
42
|
|
|
43
43
|
$$
|
|
44
44
|
a^2 - b^2=(a-b)(a+b)
|
|
@@ -47,13 +47,39 @@ $$
|
|
|
47
47
|
en prenant $a=${aMonom.toTex()}$ et $b=${bPositive}$ :
|
|
48
48
|
|
|
49
49
|
${(0, alignTex_1.alignTex)([
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
[
|
|
51
|
+
statementTex,
|
|
52
|
+
"=",
|
|
53
|
+
new substractNode_1.SubstractNode(new powerNode_1.SquareNode(aMonom), new powerNode_1.SquareNode(bPositive.toTree())).toTex(),
|
|
54
|
+
],
|
|
55
|
+
["", "=", answer],
|
|
56
|
+
])}`;
|
|
57
|
+
};
|
|
58
|
+
const getStartStatement = (identifiers) => {
|
|
59
|
+
const affine = new affine_1.Affine(identifiers.affine1Coeffs[1], identifiers.affine1Coeffs[0]);
|
|
60
|
+
const affine2 = new affine_1.Affine(identifiers.affine2Coeffs[1], identifiers.affine2Coeffs[0]);
|
|
61
|
+
const statementTree = affine.multiply(affine2).toTree();
|
|
62
|
+
return statementTree.toTex();
|
|
63
|
+
};
|
|
64
|
+
const getFactoType1Question = () => {
|
|
65
|
+
const affine = affine_1.AffineConstructor.random({
|
|
66
|
+
min: 1,
|
|
67
|
+
max: 11,
|
|
68
|
+
}, { excludes: [0] });
|
|
69
|
+
const affine2 = new affine_1.Affine(affine.a, -affine.b);
|
|
70
|
+
const identifiers = {
|
|
71
|
+
affine1Coeffs: affine.coefficients,
|
|
72
|
+
affine2Coeffs: affine2.coefficients,
|
|
73
|
+
};
|
|
74
|
+
const question = {
|
|
75
|
+
instruction: getInstruction(identifiers),
|
|
76
|
+
startStatement: getStartStatement(identifiers),
|
|
77
|
+
answer: getAnswer(identifiers),
|
|
78
|
+
keys: ["x"],
|
|
79
|
+
answerFormat: "tex",
|
|
80
|
+
identifiers,
|
|
81
|
+
hint: getHint(identifiers),
|
|
82
|
+
correction: getCorrection(identifiers),
|
|
57
83
|
};
|
|
58
84
|
return question;
|
|
59
85
|
};
|
|
@@ -72,21 +98,22 @@ const getPropositions = (n, { answer, affine1Coeffs, affine2Coeffs }) => {
|
|
|
72
98
|
}
|
|
73
99
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
74
100
|
};
|
|
75
|
-
const isAnswerValid = (ans, {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
102
|
+
try {
|
|
103
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
104
|
+
if (!parsed)
|
|
105
|
+
return false;
|
|
106
|
+
if (!(0, multiplyNode_1.isMultiplyNode)(parsed) &&
|
|
107
|
+
!(0, powerNode_1.isSquareNode)(parsed) &&
|
|
108
|
+
!(0, powerNode_1.isPowerNode)(parsed))
|
|
109
|
+
return false;
|
|
110
|
+
return (parsed
|
|
111
|
+
.simplify({ towardsDistribute: true, forbidFactorize: true })
|
|
112
|
+
.toTex() === getStartStatement(identifiers));
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
return false;
|
|
88
116
|
}
|
|
89
|
-
return validLatexs.includes(ans);
|
|
90
117
|
};
|
|
91
118
|
exports.factoIdRmq3 = {
|
|
92
119
|
id: "factoIdRmq3",
|
|
@@ -102,4 +129,8 @@ exports.factoIdRmq3 = {
|
|
|
102
129
|
isAnswerValid,
|
|
103
130
|
subject: "Mathématiques",
|
|
104
131
|
hasHintAndCorrection: true,
|
|
132
|
+
getInstruction,
|
|
133
|
+
getHint,
|
|
134
|
+
getAnswer,
|
|
135
|
+
getCorrection,
|
|
105
136
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factoType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType1Exercise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAkBlC;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"factoType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType1Exercise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAkBlC;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAgKF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
|
|
@@ -102,7 +102,6 @@ const getPropositions = (n, { answer, affinesCoeffs, operation }) => {
|
|
|
102
102
|
};
|
|
103
103
|
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
104
104
|
try {
|
|
105
|
-
console.log(ans, answer, identifiers);
|
|
106
105
|
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
107
106
|
if (!parsed)
|
|
108
107
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineExpressionReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"affineExpressionReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAkIF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAezD,CAAC"}
|
|
@@ -13,13 +13,12 @@ const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
|
13
13
|
const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
14
14
|
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
15
15
|
const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("f(x)"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(leadingCoeff, new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(b)).simplify({ forceDistributeFractions: true, forbidFactorize: true })).toTex();
|
|
16
|
+
const latexParser_1 = require("../../../../tree/parsers/latexParser");
|
|
17
|
+
const getInstruction = () => {
|
|
18
|
+
return `Ci-dessous est tracée la courbe représentative d'une fonction affine $f$. Déterminer graphiquement l'expression algébrique de $f(x)$.`;
|
|
19
|
+
};
|
|
20
|
+
const getGGBOptions = (identifiers) => {
|
|
21
|
+
const { b, secondPoint } = identifiers;
|
|
23
22
|
let xMin = Math.min(0, secondPoint[0]);
|
|
24
23
|
let xMax = Math.max(0, secondPoint[0]);
|
|
25
24
|
let yMin = Math.min(b, secondPoint[1]);
|
|
@@ -32,15 +31,29 @@ const getAffineExpressionReadingQuestion = () => {
|
|
|
32
31
|
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
33
32
|
commands,
|
|
34
33
|
});
|
|
34
|
+
return ggb.getOptions({
|
|
35
|
+
coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const getAnswer = (identifiers) => {
|
|
39
|
+
const { b, secondPoint } = identifiers;
|
|
40
|
+
const leadingCoeff = new rational_1.Rational(secondPoint[1] - b, secondPoint[0])
|
|
41
|
+
.simplify()
|
|
42
|
+
.toTree();
|
|
43
|
+
const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("f(x)"), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(leadingCoeff, new variableNode_1.VariableNode("x")), new numberNode_1.NumberNode(b)).simplify({ forceDistributeFractions: true, forbidFactorize: true })).toTex();
|
|
44
|
+
return answer;
|
|
45
|
+
};
|
|
46
|
+
const getAffineExpressionReadingQuestion = () => {
|
|
47
|
+
const b = (0, randint_1.randint)(-5, 6);
|
|
48
|
+
const secondPoint = [(0, randint_1.randint)(-5, 6, [0]), (0, randint_1.randint)(-5, 6)];
|
|
49
|
+
const identifiers = { b, secondPoint };
|
|
35
50
|
const question = {
|
|
36
|
-
answer,
|
|
37
|
-
instruction:
|
|
51
|
+
answer: getAnswer(identifiers),
|
|
52
|
+
instruction: getInstruction(identifiers),
|
|
38
53
|
keys: ["fx", "equal", "x"],
|
|
39
|
-
ggbOptions:
|
|
40
|
-
coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
|
|
41
|
-
}),
|
|
54
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
42
55
|
answerFormat: "tex",
|
|
43
|
-
identifiers
|
|
56
|
+
identifiers,
|
|
44
57
|
};
|
|
45
58
|
return question;
|
|
46
59
|
};
|
|
@@ -70,16 +83,25 @@ const getPropositions = (n, { answer, b, secondPoint }) => {
|
|
|
70
83
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
71
84
|
};
|
|
72
85
|
const isAnswerValid = (ans, { answer, secondPoint, b }) => {
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
try {
|
|
87
|
+
const formated = ans.replaceAll("f(x)", "").replaceAll("=", "");
|
|
88
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(formated);
|
|
89
|
+
if (!parsed)
|
|
90
|
+
return false;
|
|
91
|
+
return ("f(x)=" +
|
|
92
|
+
parsed
|
|
93
|
+
.simplify({
|
|
94
|
+
forbidFactorize: true,
|
|
95
|
+
forceIsolateMonomCoeffs: true,
|
|
96
|
+
decimalToFractions: true,
|
|
97
|
+
forceDistributeFractions: true,
|
|
98
|
+
})
|
|
99
|
+
.toTex() ===
|
|
100
|
+
answer);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
83
105
|
};
|
|
84
106
|
exports.affineExpressionReading = {
|
|
85
107
|
id: "affineExpressionReading",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
type: number;
|
|
4
|
+
price: number;
|
|
5
|
+
evolution: number;
|
|
6
|
+
askingFinalPrice: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const findRightCalculForPriceEvolution: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=findRightCalcul.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findRightCalcul.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/findRightCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAoIF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAiBlE,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findRightCalculForPriceEvolution = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
7
|
+
const addNode_1 = require("../../../tree/nodes/operators/addNode");
|
|
8
|
+
const divideNode_1 = require("../../../tree/nodes/operators/divideNode");
|
|
9
|
+
const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
|
|
10
|
+
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
11
|
+
const substractNode_1 = require("../../../tree/nodes/operators/substractNode");
|
|
12
|
+
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
13
|
+
const random_1 = require("../../../utils/alea/random");
|
|
14
|
+
const getPropositions = (n, { answer, evolution, price, type }) => {
|
|
15
|
+
const propositions = [];
|
|
16
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
17
|
+
if (evolution > 0) {
|
|
18
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(price, (0, addNode_1.add)(1, (0, fractionNode_1.frac)(Math.abs(evolution), 100))).toTex());
|
|
19
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(price, Math.abs(evolution) / 100).toTex());
|
|
20
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, divideNode_1.divide)(price, Math.abs(evolution)).toTex());
|
|
21
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, divideNode_1.divide)(price, (0, addNode_1.add)(1, (0, fractionNode_1.frac)(Math.abs(evolution), 100))).toTex());
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(price, (0, substractNode_1.substract)(1, (0, fractionNode_1.frac)(Math.abs(evolution), 100))).toTex());
|
|
25
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(price, Math.abs(evolution) / 100).toTex());
|
|
26
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, divideNode_1.divide)(price, Math.abs(evolution)).toTex());
|
|
27
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, divideNode_1.divide)(price, (0, substractNode_1.substract)(1, (0, fractionNode_1.frac)(Math.abs(evolution), 100))).toTex());
|
|
28
|
+
}
|
|
29
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
30
|
+
};
|
|
31
|
+
const getAnswer = (identifiers) => {
|
|
32
|
+
const { type, price, evolution, askingFinalPrice } = identifiers;
|
|
33
|
+
if (askingFinalPrice)
|
|
34
|
+
return (0, multiplyNode_1.multiply)(price, (evolution > 0 ? addNode_1.add : substractNode_1.substract)(1, (0, fractionNode_1.frac)(Math.abs(evolution), 100))).toTex();
|
|
35
|
+
else
|
|
36
|
+
return (0, multiplyNode_1.multiply)(price, Math.abs(evolution) / 100).toTex();
|
|
37
|
+
};
|
|
38
|
+
const getInstruction = (identifiers) => {
|
|
39
|
+
const { type, price, evolution, askingFinalPrice } = identifiers;
|
|
40
|
+
switch (type) {
|
|
41
|
+
case 1:
|
|
42
|
+
return `Un manteau coûte $${price}€$. Le magasin propose une réduction de $${Math.abs(evolution)}\\%$ sur cet article. Quel calcul peut-on faire pour trouver le ${askingFinalPrice
|
|
43
|
+
? "nouveau prix de l'article"
|
|
44
|
+
: "montant de la réduction"} ?`;
|
|
45
|
+
case 2:
|
|
46
|
+
return `Le budget d'un club de sport est de $${price}€$. Suite à des pertes d'abonnés, ce budget diminuera de $${Math.abs(evolution)}\\%$ l'année prochaine. Quel calcul peut-on faire pour trouver le ${askingFinalPrice
|
|
47
|
+
? "budget du club l'an prochain"
|
|
48
|
+
: "montant de la diminution"} ?`;
|
|
49
|
+
case 3:
|
|
50
|
+
return `L'abonnement à une plateforme de streaming coûte $${price}€$. Le mois prochain, ce prix augmentera de $${evolution}\\%$. Quel calcul peut-on faire pour trouver le ${askingFinalPrice
|
|
51
|
+
? "nouveau prix de l'abonnement"
|
|
52
|
+
: "montant de l'augmentation"} ?`;
|
|
53
|
+
case 4:
|
|
54
|
+
return `Le salaire de M. Moulin est de $${price}€$. Le mois prochain, il recevra une augmentation de $${evolution}\\%$. Quel calcul peut-on faire pour trouver le ${askingFinalPrice
|
|
55
|
+
? "nouveau salaire de M. Moulin"
|
|
56
|
+
: "montant de l'augmentation"} ?`;
|
|
57
|
+
}
|
|
58
|
+
return "";
|
|
59
|
+
};
|
|
60
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {
|
|
61
|
+
// return "";
|
|
62
|
+
// };
|
|
63
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
|
|
64
|
+
// return "";
|
|
65
|
+
// };
|
|
66
|
+
const getKeys = (identifiers) => {
|
|
67
|
+
return [];
|
|
68
|
+
};
|
|
69
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
70
|
+
throw Error("VEA not implemented");
|
|
71
|
+
};
|
|
72
|
+
const getFindRightCalculQuestion = (ops) => {
|
|
73
|
+
const evolution = (0, randint_1.randint)(-6, 7, [0]) * 10;
|
|
74
|
+
const type = evolution < 0 ? (0, random_1.random)([1, 2]) : (0, random_1.random)([3, 4]);
|
|
75
|
+
const price = type === 1
|
|
76
|
+
? (0, randint_1.randint)(30, 400)
|
|
77
|
+
: type === 2
|
|
78
|
+
? 10000 * (0, randint_1.randint)(5, 20)
|
|
79
|
+
: type === 3
|
|
80
|
+
? (0, randint_1.randint)(10, 50)
|
|
81
|
+
: (0, randint_1.randint)(1300, 2000);
|
|
82
|
+
const askingFinalPrice = (0, coinFlip_1.coinFlip)();
|
|
83
|
+
const identifiers = {
|
|
84
|
+
type,
|
|
85
|
+
price,
|
|
86
|
+
evolution,
|
|
87
|
+
askingFinalPrice,
|
|
88
|
+
};
|
|
89
|
+
const question = {
|
|
90
|
+
answer: getAnswer(identifiers),
|
|
91
|
+
instruction: getInstruction(identifiers),
|
|
92
|
+
keys: getKeys(identifiers),
|
|
93
|
+
answerFormat: "tex",
|
|
94
|
+
identifiers,
|
|
95
|
+
// hint: getHint(identifiers),
|
|
96
|
+
// correction: getCorrection(identifiers),
|
|
97
|
+
};
|
|
98
|
+
return question;
|
|
99
|
+
};
|
|
100
|
+
exports.findRightCalculForPriceEvolution = {
|
|
101
|
+
id: "findRightCalculForPriceEvolution",
|
|
102
|
+
connector: "=",
|
|
103
|
+
label: "Choisir le bon calcul pour appliquer une évolution en pourcentage",
|
|
104
|
+
isSingleStep: true,
|
|
105
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getFindRightCalculQuestion(opts), nb),
|
|
106
|
+
qcmTimer: 60,
|
|
107
|
+
freeTimer: 60,
|
|
108
|
+
getPropositions,
|
|
109
|
+
isAnswerValid,
|
|
110
|
+
subject: "Mathématiques",
|
|
111
|
+
getInstruction,
|
|
112
|
+
// getHint,
|
|
113
|
+
// getCorrection,
|
|
114
|
+
getAnswer,
|
|
115
|
+
answerType: "QCU",
|
|
116
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htToTTC.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/htToTTC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"htToTTC.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/htToTTC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAmEF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAkBzC,CAAC"}
|
|
@@ -9,18 +9,23 @@ const round_1 = require("../../../math/utils/round");
|
|
|
9
9
|
const numberParser_1 = require("../../../tree/parsers/numberParser");
|
|
10
10
|
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
11
11
|
const random_1 = require("../../../utils/alea/random");
|
|
12
|
-
const
|
|
13
|
-
const TVA
|
|
14
|
-
const ht = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(50, 1000) : (0, randfloat_1.randfloat)(20, 200, 2);
|
|
12
|
+
const getAnswer = (identifiers) => {
|
|
13
|
+
const { TVA, ht } = identifiers;
|
|
15
14
|
const answer = (0, round_1.round)(ht * (1 + TVA / 100), 2).frenchify();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
return answer;
|
|
16
|
+
};
|
|
17
|
+
const getInstruction = (identifiers) => {
|
|
18
|
+
const { TVA, ht } = identifiers;
|
|
19
|
+
return `Un objet coûte $${ht.frenchify()}€$ en HT. Quel est son prix TTC, sachant que la TVA est de $${TVA.frenchify()}\\%$ ? (arrondir au centième)`;
|
|
20
|
+
};
|
|
21
|
+
const getHint = (identifiers) => {
|
|
22
|
+
const { TVA, ht } = identifiers;
|
|
23
|
+
return `Pour augmenter un prix de $t\\%$, on le multiplie par $1 + \\frac{t}{100}$.`;
|
|
24
|
+
};
|
|
25
|
+
const getCorrection = (identifiers) => {
|
|
26
|
+
const { TVA, ht } = identifiers;
|
|
27
|
+
const answer = getAnswer(identifiers);
|
|
28
|
+
return `Pour augmenter $${ht.frenchify()}$ de $${TVA.frenchify()}\\%$, on le multiplie par :
|
|
24
29
|
|
|
25
30
|
$$
|
|
26
31
|
1 + \\frac{${TVA.frenchify()}}{100} = ${(0, round_1.round)(1 + TVA / 100, 3).frenchify()}
|
|
@@ -31,7 +36,20 @@ Le prix TTC est donc :
|
|
|
31
36
|
$$
|
|
32
37
|
${ht.frenchify()} \\times ${(0, round_1.round)(1 + TVA / 100, 3).frenchify()} = ${answer}
|
|
33
38
|
$$
|
|
34
|
-
|
|
39
|
+
`;
|
|
40
|
+
};
|
|
41
|
+
const getHtToTtcQuestion = () => {
|
|
42
|
+
const TVA = (0, random_1.random)([20, 5.5]);
|
|
43
|
+
const ht = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(50, 1000) : (0, randfloat_1.randfloat)(20, 200, 2);
|
|
44
|
+
const identifiers = { TVA, ht };
|
|
45
|
+
const question = {
|
|
46
|
+
answer: getAnswer(identifiers),
|
|
47
|
+
instruction: getInstruction(identifiers),
|
|
48
|
+
keys: [],
|
|
49
|
+
answerFormat: "tex",
|
|
50
|
+
identifiers,
|
|
51
|
+
hint: getHint(identifiers),
|
|
52
|
+
correction: getCorrection(identifiers),
|
|
35
53
|
};
|
|
36
54
|
return question;
|
|
37
55
|
};
|
|
@@ -62,4 +80,8 @@ exports.htToTTC = {
|
|
|
62
80
|
isAnswerValid,
|
|
63
81
|
subject: "Mathématiques",
|
|
64
82
|
hasHintAndCorrection: true,
|
|
83
|
+
getAnswer,
|
|
84
|
+
getInstruction,
|
|
85
|
+
getHint,
|
|
86
|
+
getCorrection,
|
|
65
87
|
};
|
|
@@ -15,4 +15,5 @@ export * from "./findStartValueAfterEvolution";
|
|
|
15
15
|
export * from "./subPopulationEffectifFromPercent";
|
|
16
16
|
export * from "./populationEffectifFromSubPopulation";
|
|
17
17
|
export * from "./findEndValueAfterEvolution";
|
|
18
|
+
export * from "./findRightCalcul";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC"}
|
|
@@ -31,3 +31,5 @@ __exportStar(require("./findStartValueAfterEvolution"), exports);
|
|
|
31
31
|
__exportStar(require("./subPopulationEffectifFromPercent"), exports);
|
|
32
32
|
__exportStar(require("./populationEffectifFromSubPopulation"), exports);
|
|
33
33
|
__exportStar(require("./findEndValueAfterEvolution"), exports);
|
|
34
|
+
__exportStar(require("./findRightCalcul"), exports);
|
|
35
|
+
// export * from "./percentWritings";
|