math-exercises 2.2.95 → 2.2.96
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/calculLitteral/distributivity/firstIdentity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.js +82 -34
- package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.js +86 -36
- package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.js +82 -32
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +1 -0
- package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.js +38 -16
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts +3 -3
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.js +171 -75
- package/lib/exercises/math/dataReading/index.d.ts +2 -0
- package/lib/exercises/math/dataReading/index.d.ts.map +1 -0
- package/lib/exercises/math/dataReading/index.js +17 -0
- package/lib/exercises/math/dataReading/tableReading.d.ts +8 -0
- package/lib/exercises/math/dataReading/tableReading.d.ts.map +1 -0
- package/lib/exercises/math/dataReading/tableReading.js +105 -0
- package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.js +75 -11
- package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +0 -1
- package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
- package/lib/exercises/math/index.d.ts +1 -0
- package/lib/exercises/math/index.d.ts.map +1 -1
- package/lib/exercises/math/index.js +1 -0
- package/lib/exercises/math/probaStat/diceBasicProbas.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/diceBasicProbas.js +72 -20
- package/lib/exercises/vea/rationalVEA.js +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/tree/nodes/algebraicNode.d.ts +1 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts +2 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +21 -3
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts +2 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +12 -0
- package/lib/tree/nodes/operators/operatorNode.d.ts +5 -0
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/operatorNode.js +5 -1
- package/lib/tree/nodes/polynomials/monomNode.d.ts +2 -6
- package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -1
- package/lib/tree/nodes/polynomials/monomNode.js +102 -94
- package/lib/tree/parsers/affineParser.d.ts +1 -1
- package/lib/tree/parsers/affineParser.d.ts.map +1 -1
- package/lib/tree/parsers/affineParser.js +16 -21
- package/lib/tree/parsers/polynomialParser.d.ts +5 -1
- package/lib/tree/parsers/polynomialParser.d.ts.map +1 -1
- package/lib/tree/parsers/polynomialParser.js +3 -3
- package/lib/tree/parsers/purifyLatex.d.ts +1 -1
- package/lib/tree/parsers/purifyLatex.js +1 -1
- package/lib/utils/alea/shuffle.js +1 -1
- package/package.json +1 -1
|
@@ -3,100 +3,193 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.reduceExpression = void 0;
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
-
const
|
|
6
|
+
const affine_1 = require("../../../../math/polynomials/affine");
|
|
7
|
+
const trinom_1 = require("../../../../math/polynomials/trinom");
|
|
7
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
8
9
|
const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
10
|
+
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
11
|
+
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
12
|
+
const polynomialParser_1 = require("../../../../tree/parsers/polynomialParser");
|
|
13
|
+
const operatorComposition_1 = require("../../../../tree/utilities/operatorComposition");
|
|
14
|
+
const random_1 = require("../../../../utils/alea/random");
|
|
9
15
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
16
|
+
const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
|
|
17
|
+
const rebuildIdentifiers = (oldids) => {
|
|
18
|
+
if (oldids.variable)
|
|
19
|
+
return oldids;
|
|
20
|
+
const { polynome1Coeffs, polynome2Coeffs } = oldids;
|
|
21
|
+
const nbTerms = polynome1Coeffs.filter((e) => e === 0 || !!e).length +
|
|
22
|
+
polynome2Coeffs.filter((e) => e === 0 || !!e).length;
|
|
23
|
+
return {
|
|
24
|
+
variable: "x",
|
|
25
|
+
coeffs: [
|
|
26
|
+
[polynome1Coeffs[0], polynome2Coeffs[0]].filter((e) => e === 0 || !!e),
|
|
27
|
+
[polynome1Coeffs[1], polynome2Coeffs[1]].filter((e) => e === 0 || !!e),
|
|
28
|
+
[polynome1Coeffs[2], polynome2Coeffs[2]].filter((e) => e === 0 || !!e),
|
|
29
|
+
],
|
|
30
|
+
order: (0, shuffle_1.shuffle)(Array.from({ length: nbTerms }, (_, i) => i)),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const getStatementNode = (identifiers) => {
|
|
34
|
+
const { variable, coeffs, order } = identifiers;
|
|
35
|
+
const nodes = coeffs.flatMap((coeff, i) => coeff.map((c) => {
|
|
36
|
+
if (i === 0)
|
|
37
|
+
return c.toTree();
|
|
38
|
+
if (i === 1)
|
|
39
|
+
return (0, multiplyNode_1.multiply)(c, variable);
|
|
40
|
+
else
|
|
41
|
+
return (0, multiplyNode_1.multiply)(c, (0, powerNode_1.square)(variable));
|
|
42
|
+
}));
|
|
43
|
+
const shuffled = order.map((i) => nodes[i]);
|
|
44
|
+
// const polynome1 = new Polynomial(polynome1Coeffs, variable);
|
|
45
|
+
// const polynome2 = new Polynomial(polynome2Coeffs, variable);
|
|
46
|
+
return (0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, shuffled);
|
|
47
|
+
// const statement = new AddNode(polynome1.toTree(), polynome2.toTree());
|
|
48
|
+
// return statement.deepShuffle({ nodeIdsToShuffle: [OperatorIds.add] });
|
|
49
|
+
};
|
|
50
|
+
const getStartStatement = (identifiers) => {
|
|
51
|
+
return getStatementNode(identifiers).toTex();
|
|
52
|
+
};
|
|
53
|
+
const getAnswer = (identifiers) => {
|
|
54
|
+
const answer = getStatementNode(identifiers)
|
|
55
|
+
.simplify({
|
|
56
|
+
forbidFactorize: true,
|
|
57
|
+
towardsDistribute: true,
|
|
58
|
+
})
|
|
59
|
+
.toTex();
|
|
60
|
+
return answer;
|
|
61
|
+
};
|
|
62
|
+
const getInstruction = (identifiers) => {
|
|
63
|
+
return `Réduire l'expression suivante :
|
|
64
|
+
|
|
65
|
+
$$
|
|
66
|
+
${getStartStatement(identifiers)}
|
|
67
|
+
$$`;
|
|
68
|
+
};
|
|
10
69
|
const getReduceExpression = () => {
|
|
11
70
|
const rand = (0, randint_1.randint)(0, 7);
|
|
12
71
|
let polynome1;
|
|
13
72
|
let polynome2;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
polynome1 = new polynomial_1.Polynomial([
|
|
29
|
-
(0, randint_1.randint)(-9, 10),
|
|
30
|
-
(0, randint_1.randint)(-9, 10),
|
|
31
|
-
(0, randint_1.randint)(-9, 10, [0]),
|
|
32
|
-
]);
|
|
33
|
-
polynome2 = new polynomial_1.Polynomial([0, (0, randint_1.randint)(-5, 6), (0, randint_1.randint)(-5, 6, [0])]);
|
|
34
|
-
break;
|
|
35
|
-
case 4:
|
|
36
|
-
polynome1 = new polynomial_1.Polynomial([
|
|
37
|
-
(0, randint_1.randint)(-9, 10),
|
|
38
|
-
(0, randint_1.randint)(-9, 10),
|
|
39
|
-
(0, randint_1.randint)(-9, 10, [0]),
|
|
40
|
-
]);
|
|
41
|
-
polynome2 = new polynomial_1.Polynomial([0, 0, (0, randint_1.randint)(-5, 6, [0])]);
|
|
42
|
-
break;
|
|
43
|
-
case 5:
|
|
44
|
-
polynome1 = new polynomial_1.Polynomial([
|
|
45
|
-
(0, randint_1.randint)(-9, 10),
|
|
46
|
-
(0, randint_1.randint)(-9, 10),
|
|
47
|
-
(0, randint_1.randint)(-9, 10, [0]),
|
|
48
|
-
]);
|
|
49
|
-
polynome2 = new polynomial_1.Polynomial([0, (0, randint_1.randint)(-5, 6, [0])]);
|
|
50
|
-
break;
|
|
51
|
-
case 6:
|
|
52
|
-
polynome1 = new polynomial_1.Polynomial([
|
|
53
|
-
(0, randint_1.randint)(-9, 10),
|
|
54
|
-
(0, randint_1.randint)(-9, 10),
|
|
55
|
-
(0, randint_1.randint)(-9, 10, [0]),
|
|
56
|
-
]);
|
|
57
|
-
polynome2 = new polynomial_1.Polynomial([(0, randint_1.randint)(-5, 6, [0])]);
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
throw Error("something went wrong");
|
|
73
|
+
//coeffs[0] est degré 0, coeffs[1] est degré 1, coeffs[2] degré 2
|
|
74
|
+
const coeffs = [[], [], []];
|
|
75
|
+
const nbTerms = (0, randint_1.randint)(4, 6);
|
|
76
|
+
for (let i = 0; i < nbTerms; i++) {
|
|
77
|
+
if (i === nbTerms - 1) {
|
|
78
|
+
let availableDegree = coeffs.findIndex((coeff) => coeff.length === 0);
|
|
79
|
+
if (availableDegree === -1)
|
|
80
|
+
availableDegree = (0, randint_1.randint)(0, 3);
|
|
81
|
+
coeffs[availableDegree].push((0, randint_1.randint)(-9, 10, [0]));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const degree = (0, randint_1.randint)(0, 3);
|
|
85
|
+
coeffs[degree].push((0, randint_1.randint)(-9, 10, [0]));
|
|
86
|
+
}
|
|
61
87
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
88
|
+
const order = (0, shuffle_1.shuffle)(Array.from({ length: nbTerms }, (_, i) => i));
|
|
89
|
+
// switch (rand) {
|
|
90
|
+
// case 0: // ax + b + cx + d
|
|
91
|
+
// polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
|
|
92
|
+
// polynome2 = new Polynomial([randint(-5, 6, [0]), randint(-5, 6, [0])]);
|
|
93
|
+
// break;
|
|
94
|
+
// case 1: //ax+b + cx
|
|
95
|
+
// polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
|
|
96
|
+
// polynome2 = new Polynomial([0, randint(-5, 6, [0])]);
|
|
97
|
+
// break;
|
|
98
|
+
// case 2: //ax+b+c
|
|
99
|
+
// polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
|
|
100
|
+
// polynome2 = new Polynomial([randint(-5, 6, [0])]);
|
|
101
|
+
// break;
|
|
102
|
+
// case 3: //ax^2+bx+c + ax^2+bx
|
|
103
|
+
// polynome1 = new Polynomial([
|
|
104
|
+
// randint(-9, 10),
|
|
105
|
+
// randint(-9, 10),
|
|
106
|
+
// randint(-9, 10, [0]),
|
|
107
|
+
// ]);
|
|
108
|
+
// polynome2 = new Polynomial([0, randint(-5, 6), randint(-5, 6, [0])]);
|
|
109
|
+
// break;
|
|
110
|
+
// case 4: //ax^2+bx+c + ax^2
|
|
111
|
+
// polynome1 = new Polynomial([
|
|
112
|
+
// randint(-9, 10),
|
|
113
|
+
// randint(-9, 10),
|
|
114
|
+
// randint(-9, 10, [0]),
|
|
115
|
+
// ]);
|
|
116
|
+
// polynome2 = new Polynomial([0, 0, randint(-5, 6, [0])]);
|
|
117
|
+
// break;
|
|
118
|
+
// case 5: //ax^2+bx+c + ax
|
|
119
|
+
// polynome1 = new Polynomial([
|
|
120
|
+
// randint(-9, 10),
|
|
121
|
+
// randint(-9, 10),
|
|
122
|
+
// randint(-9, 10, [0]),
|
|
123
|
+
// ]);
|
|
124
|
+
// polynome2 = new Polynomial([0, randint(-5, 6, [0])]);
|
|
125
|
+
// break;
|
|
126
|
+
// case 6: //ax^2 +bx+c + c
|
|
127
|
+
// polynome1 = new Polynomial([
|
|
128
|
+
// randint(-9, 10),
|
|
129
|
+
// randint(-9, 10),
|
|
130
|
+
// randint(-9, 10, [0]),
|
|
131
|
+
// ]);
|
|
132
|
+
// polynome2 = new Polynomial([randint(-5, 6, [0])]);
|
|
133
|
+
// break;
|
|
134
|
+
// default:
|
|
135
|
+
// throw Error("something went wrong");
|
|
136
|
+
// }
|
|
137
|
+
const variable = (0, random_1.random)(["x", "n", "a", "y", "t"]);
|
|
138
|
+
const identifiers = {
|
|
139
|
+
// rand,
|
|
140
|
+
// polynome1Coeffs: polynome1.coefficients,
|
|
141
|
+
// polynome2Coeffs: polynome2.coefficients,
|
|
142
|
+
coeffs,
|
|
143
|
+
variable,
|
|
144
|
+
order,
|
|
145
|
+
};
|
|
66
146
|
const question = {
|
|
67
|
-
instruction:
|
|
68
|
-
startStatement:
|
|
69
|
-
answer,
|
|
70
|
-
keys: [
|
|
147
|
+
instruction: getInstruction(identifiers),
|
|
148
|
+
startStatement: getStartStatement(identifiers),
|
|
149
|
+
answer: getAnswer(identifiers),
|
|
150
|
+
keys: [variable],
|
|
71
151
|
answerFormat: "tex",
|
|
72
|
-
identifiers
|
|
73
|
-
rand,
|
|
74
|
-
polynome1Coeffs: polynome1.coefficients,
|
|
75
|
-
polynome2Coeffs: polynome2.coefficients,
|
|
76
|
-
},
|
|
152
|
+
identifiers,
|
|
77
153
|
};
|
|
78
154
|
return question;
|
|
79
155
|
};
|
|
80
|
-
const getPropositions = (n, { answer,
|
|
156
|
+
const getPropositions = (n, { answer, coeffs, variable }) => {
|
|
81
157
|
const propositions = [];
|
|
82
158
|
(0, exercise_1.addValidProp)(propositions, answer);
|
|
83
|
-
|
|
159
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, coeffs
|
|
160
|
+
.flatMap((e) => e)
|
|
161
|
+
.reduce((acc, curr) => acc + curr, 0)
|
|
162
|
+
.frenchify());
|
|
84
163
|
while (propositions.length < n) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
164
|
+
if (coeffs[2].length) {
|
|
165
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, new trinom_1.Trinom((0, randint_1.randint)(-9, 10, [0]), (0, randint_1.randint)(-9, 10), (0, randint_1.randint)(-9, 10), {
|
|
166
|
+
variable,
|
|
167
|
+
})
|
|
168
|
+
.toTree()
|
|
169
|
+
.toTex());
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, new affine_1.Affine((0, randint_1.randint)(-9, 10, [0]), (0, randint_1.randint)(-9, 10)).toTree().toTex());
|
|
173
|
+
}
|
|
89
174
|
}
|
|
90
175
|
return (0, shuffle_1.shuffle)(propositions);
|
|
91
176
|
};
|
|
92
|
-
const isAnswerValid = (ans, {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
177
|
+
const isAnswerValid = (ans, { variable, answer }) => {
|
|
178
|
+
try {
|
|
179
|
+
const parsed = (0, polynomialParser_1.polynomialParser)(ans, { variable });
|
|
180
|
+
if (!parsed)
|
|
181
|
+
return false;
|
|
182
|
+
return (parsed
|
|
183
|
+
.simplify({
|
|
184
|
+
forbidFactorize: true,
|
|
185
|
+
towardsDistribute: true,
|
|
186
|
+
forbidAdditions: true,
|
|
187
|
+
})
|
|
188
|
+
.toTex() === answer);
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
192
|
+
}
|
|
100
193
|
};
|
|
101
194
|
exports.reduceExpression = {
|
|
102
195
|
id: "reduceExpression",
|
|
@@ -111,4 +204,7 @@ exports.reduceExpression = {
|
|
|
111
204
|
getPropositions,
|
|
112
205
|
isAnswerValid,
|
|
113
206
|
subject: "Mathématiques",
|
|
207
|
+
rebuildIdentifiers,
|
|
208
|
+
getAnswer,
|
|
209
|
+
getInstruction,
|
|
114
210
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataReading/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./tableReading"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataReading/tableReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IAIjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4FF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAgB9C,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableReading = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const numberVEA_1 = require("../../../exercises/vea/numberVEA");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const random_1 = require("../../../utils/alea/random");
|
|
9
|
+
const handleVEAError_1 = require("../../../utils/errors/handleVEAError");
|
|
10
|
+
const dollarize_1 = require("../../../utils/latex/dollarize");
|
|
11
|
+
const mdTable_1 = require("../../../utils/markdown/mdTable");
|
|
12
|
+
const getPropositions = (n, { answer, values, caseAsked }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
15
|
+
while (propositions.length < n) {
|
|
16
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, random_1.random)(values.flat()).frenchify());
|
|
17
|
+
}
|
|
18
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
19
|
+
};
|
|
20
|
+
const getAnswer = (identifiers) => {
|
|
21
|
+
const { values, caseAsked } = identifiers;
|
|
22
|
+
const flatValues = values.flat();
|
|
23
|
+
return flatValues[caseAsked].frenchify();
|
|
24
|
+
};
|
|
25
|
+
const getInstruction = (identifiers) => {
|
|
26
|
+
const { values, caseAsked } = identifiers;
|
|
27
|
+
let population = caseAsked % 3 === 0
|
|
28
|
+
? "de la $6^e$ A"
|
|
29
|
+
: caseAsked % 3 === 1
|
|
30
|
+
? "de la $6^e$ B"
|
|
31
|
+
: "";
|
|
32
|
+
let caractere = caseAsked < 3
|
|
33
|
+
? "préfèrent le jeu Minecraft"
|
|
34
|
+
: caseAsked < 6
|
|
35
|
+
? "préfèrent le jeu The Legend of Zelda"
|
|
36
|
+
: "ont répondu au sondage";
|
|
37
|
+
return `Un sondage a été réalisé auprès des élèves de deux classes de $6^e$ pour connaître leur jeu vidéo préféré. Voici leurs réponses :
|
|
38
|
+
|
|
39
|
+
${(0, mdTable_1.mdTable)([
|
|
40
|
+
["", "$6^e$ A", "$6^e$ B", "Total"],
|
|
41
|
+
["Minecraft", ...values[0].map(dollarize_1.dollarize)],
|
|
42
|
+
["The Legend of Zelda", ...values[1].map(dollarize_1.dollarize)],
|
|
43
|
+
["Total", ...values[2].map(dollarize_1.dollarize)],
|
|
44
|
+
])}
|
|
45
|
+
|
|
46
|
+
Combien d'élèves ${population} ${caractere} ?
|
|
47
|
+
`;
|
|
48
|
+
};
|
|
49
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
50
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
51
|
+
const getKeys = (identifiers) => {
|
|
52
|
+
return [];
|
|
53
|
+
};
|
|
54
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
55
|
+
try {
|
|
56
|
+
return (0, numberVEA_1.numberVEA)(ans, answer);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const getTableReadingQuestion = (ops) => {
|
|
63
|
+
const caseAsked = (0, randint_1.randint)(0, 9);
|
|
64
|
+
const totalA = (0, randint_1.randint)(20, 30);
|
|
65
|
+
const totalB = (0, randint_1.randint)(20, 30, [totalA]);
|
|
66
|
+
const case0 = (0, randint_1.randint)(3, totalA - 5);
|
|
67
|
+
const case1 = (0, randint_1.randint)(3, totalB - 5, [case0]);
|
|
68
|
+
const case3 = totalA - case0;
|
|
69
|
+
const case4 = totalB - case1;
|
|
70
|
+
const values = [
|
|
71
|
+
[case0, case1, case0 + case1],
|
|
72
|
+
[case3, case4, case3 + case4],
|
|
73
|
+
[totalA, totalB, totalA + totalB],
|
|
74
|
+
];
|
|
75
|
+
const identifiers = {
|
|
76
|
+
caseAsked,
|
|
77
|
+
values,
|
|
78
|
+
};
|
|
79
|
+
const question = {
|
|
80
|
+
answer: getAnswer(identifiers),
|
|
81
|
+
instruction: getInstruction(identifiers),
|
|
82
|
+
keys: getKeys(identifiers),
|
|
83
|
+
answerFormat: "tex",
|
|
84
|
+
identifiers,
|
|
85
|
+
// hint: getHint(identifiers),
|
|
86
|
+
// correction: getCorrection(identifiers),
|
|
87
|
+
};
|
|
88
|
+
return question;
|
|
89
|
+
};
|
|
90
|
+
exports.tableReading = {
|
|
91
|
+
id: "tableReading",
|
|
92
|
+
connector: "=",
|
|
93
|
+
label: "Lire un tableau à double entrée",
|
|
94
|
+
isSingleStep: true,
|
|
95
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTableReadingQuestion(opts), nb),
|
|
96
|
+
qcmTimer: 60,
|
|
97
|
+
freeTimer: 60,
|
|
98
|
+
getPropositions,
|
|
99
|
+
isAnswerValid,
|
|
100
|
+
subject: "Mathématiques",
|
|
101
|
+
getInstruction,
|
|
102
|
+
// getHint,
|
|
103
|
+
// getCorrection,
|
|
104
|
+
getAnswer,
|
|
105
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoIF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAmB5D,CAAC"}
|
|
@@ -7,19 +7,73 @@ const affine_1 = require("../../../../math/polynomials/affine");
|
|
|
7
7
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
8
8
|
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
9
9
|
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
11
|
+
const latexParser_1 = require("../../../../tree/parsers/latexParser");
|
|
12
|
+
const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
|
|
13
|
+
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
14
|
+
const getInstruction = (identifiers) => {
|
|
15
|
+
const { affineA, affineB, power } = identifiers;
|
|
16
|
+
const affine = new affine_1.Affine(affineA, affineB);
|
|
14
17
|
const powerTree = power.toTree();
|
|
18
|
+
const affineTree = affine.toTree();
|
|
15
19
|
const fct = new powerNode_1.PowerNode(affineTree, powerTree);
|
|
20
|
+
return `Déterminer la fonction dérivée de la fonction $f$ définie par :
|
|
21
|
+
$$
|
|
22
|
+
f(x) = ${fct.toTex()}
|
|
23
|
+
$$`;
|
|
24
|
+
};
|
|
25
|
+
const getAnswer = (identifiers) => {
|
|
26
|
+
const { affineA, affineB, power } = identifiers;
|
|
27
|
+
const affine = new affine_1.Affine(affineA, affineB);
|
|
28
|
+
const affineTree = affine.toTree();
|
|
16
29
|
const deriv = new multiplyNode_1.MultiplyNode((power * affine.a).toTree(), new powerNode_1.PowerNode(affineTree, (power - 1).toTree()));
|
|
30
|
+
return deriv.toTex();
|
|
31
|
+
};
|
|
32
|
+
const getHint = (identifiers) => {
|
|
33
|
+
return `On rappelle la règle de dérivation suivante :
|
|
34
|
+
|
|
35
|
+
$$
|
|
36
|
+
\\left(u^n \\right)' = n \\times u' \\times u^{n-1}
|
|
37
|
+
$$
|
|
38
|
+
`;
|
|
39
|
+
};
|
|
40
|
+
const getCorrection = (identifiers) => {
|
|
41
|
+
const { affineA, affineB, power: pow } = identifiers;
|
|
42
|
+
const affine = new affine_1.Affine(affineA, affineB).toTree();
|
|
43
|
+
const affineTex = affine.toTex();
|
|
44
|
+
const answer = getAnswer(identifiers);
|
|
45
|
+
return `On sait que :
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
\\left(u^n \\right)' = n \\times u' \\times u^{n-1}
|
|
49
|
+
$$
|
|
50
|
+
|
|
51
|
+
Ici, on a $n = ${pow}$, et $u(x) = ${affineTex}$, donc $u'(x) = ${affineA}$.
|
|
52
|
+
|
|
53
|
+
Ainsi,
|
|
54
|
+
|
|
55
|
+
${(0, alignTex_1.alignTex)([
|
|
56
|
+
[
|
|
57
|
+
"f'(x)",
|
|
58
|
+
"=",
|
|
59
|
+
(0, multiplyNode_1.multiply)(pow, (0, multiplyNode_1.multiply)(affineA, (0, powerNode_1.power)(affine, (0, substractNode_1.substract)(pow, 1)))).toTex(),
|
|
60
|
+
],
|
|
61
|
+
["", "=", answer],
|
|
62
|
+
])}
|
|
63
|
+
`;
|
|
64
|
+
};
|
|
65
|
+
const getPowerCompositionDerivationQuestion = () => {
|
|
66
|
+
const affine = affine_1.AffineConstructor.random(undefined, { excludes: [0] });
|
|
67
|
+
const power = (0, randint_1.randint)(3, 10);
|
|
68
|
+
const identifiers = { affineA: affine.a, affineB: affine.b, power };
|
|
17
69
|
const question = {
|
|
18
|
-
answer:
|
|
19
|
-
instruction:
|
|
70
|
+
answer: getAnswer(identifiers),
|
|
71
|
+
instruction: getInstruction(identifiers),
|
|
72
|
+
hint: getHint(identifiers),
|
|
73
|
+
correction: getCorrection(identifiers),
|
|
20
74
|
keys: ["x"],
|
|
21
75
|
answerFormat: "tex",
|
|
22
|
-
identifiers
|
|
76
|
+
identifiers,
|
|
23
77
|
};
|
|
24
78
|
return question;
|
|
25
79
|
};
|
|
@@ -39,10 +93,15 @@ const getPropositions = (n, { answer, affineA, affineB, power }) => {
|
|
|
39
93
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
40
94
|
};
|
|
41
95
|
const isAnswerValid = (ans, { answer, power, affineA, affineB }) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
96
|
+
try {
|
|
97
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
98
|
+
if (!parsed)
|
|
99
|
+
return false;
|
|
100
|
+
return parsed.simplify({ forbidFactorize: true }).toTex() === answer;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
104
|
+
}
|
|
46
105
|
};
|
|
47
106
|
exports.powerCompositionDerivation = {
|
|
48
107
|
id: "powerCompositionDerivation",
|
|
@@ -57,4 +116,9 @@ exports.powerCompositionDerivation = {
|
|
|
57
116
|
getPropositions,
|
|
58
117
|
isAnswerValid,
|
|
59
118
|
subject: "Mathématiques",
|
|
119
|
+
getAnswer,
|
|
120
|
+
getInstruction,
|
|
121
|
+
getHint,
|
|
122
|
+
getCorrection,
|
|
123
|
+
hasHintAndCorrection: true,
|
|
60
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA+IF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAgB/D,CAAC"}
|
|
@@ -96,7 +96,6 @@ const getPropositions = (n, { answer, xA, xB, yA, yB }) => {
|
|
|
96
96
|
};
|
|
97
97
|
const isAnswerValid = (ans, { xA, xB, yA, yB }) => {
|
|
98
98
|
try {
|
|
99
|
-
// const parsed = affineParser(ans);
|
|
100
99
|
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
101
100
|
if (!parsed)
|
|
102
101
|
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,EAYT,MAAM,0BAA0B,CAAC;
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diceBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/diceBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,
|
|
1
|
+
{"version":3,"file":"diceBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/diceBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAwIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAiBjD,CAAC"}
|