math-exercises 3.0.145 → 3.0.147

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.
Files changed (113) hide show
  1. package/lib/exercises/math/calcul/addAndSub.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/addAndSub.js +20 -1
  3. package/lib/exercises/math/calcul/index.d.ts +1 -0
  4. package/lib/exercises/math/calcul/index.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/index.js +1 -0
  6. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +2 -0
  7. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/mentalCaluls/index.js +2 -0
  9. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +22 -0
  11. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.d.ts +9 -0
  12. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.d.ts.map +1 -0
  13. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.js +152 -0
  14. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.d.ts +15 -0
  15. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.d.ts.map +1 -0
  16. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.js +412 -0
  17. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  18. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +37 -7
  19. package/lib/exercises/math/calcul/ratio/index.d.ts +2 -0
  20. package/lib/exercises/math/calcul/ratio/index.d.ts.map +1 -0
  21. package/lib/exercises/math/calcul/ratio/index.js +2 -0
  22. package/lib/exercises/math/calcul/ratio/partUsingRatio.d.ts +14 -0
  23. package/lib/exercises/math/calcul/ratio/partUsingRatio.d.ts.map +1 -0
  24. package/lib/exercises/math/calcul/ratio/partUsingRatio.js +388 -0
  25. package/lib/exercises/math/calcul/ratio/ratioFromParts.d.ts +10 -0
  26. package/lib/exercises/math/calcul/ratio/ratioFromParts.d.ts.map +1 -0
  27. package/lib/exercises/math/calcul/ratio/ratioFromParts.js +198 -0
  28. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.d.ts.map +1 -1
  29. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.js +50 -0
  30. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +1 -1
  31. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts +6 -1
  32. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
  33. package/lib/exercises/math/functions/affines/affineExpressionReading.js +166 -52
  34. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts +5 -1
  35. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts.map +1 -1
  36. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.js +59 -17
  37. package/lib/exercises/math/functions/basics/graphicInequation.js +1 -1
  38. package/lib/exercises/math/functions/index.d.ts +1 -0
  39. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  40. package/lib/exercises/math/functions/index.js +1 -0
  41. package/lib/exercises/math/functions/linear/index.d.ts +3 -0
  42. package/lib/exercises/math/functions/linear/index.d.ts.map +1 -0
  43. package/lib/exercises/math/functions/linear/index.js +2 -0
  44. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts +9 -0
  45. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts.map +1 -0
  46. package/lib/exercises/math/functions/linear/linearFromExercise.js +355 -0
  47. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts +8 -0
  48. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts.map +1 -0
  49. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.js +233 -0
  50. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts.map +1 -1
  51. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.js +2 -5
  52. package/lib/exercises/math/index.d.ts +1 -0
  53. package/lib/exercises/math/index.d.ts.map +1 -1
  54. package/lib/exercises/math/index.js +1 -0
  55. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +1 -0
  56. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
  57. package/lib/exercises/math/probaStat/basicProbas/index.js +1 -0
  58. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.d.ts +10 -0
  59. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.d.ts.map +1 -0
  60. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.js +113 -0
  61. package/lib/exercises/math/probaStat/index.d.ts +1 -0
  62. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  63. package/lib/exercises/math/probaStat/index.js +1 -0
  64. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts +8 -0
  65. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts.map +1 -0
  66. package/lib/exercises/math/probaStat/stats1var/etendueTable.js +89 -0
  67. package/lib/exercises/math/probaStat/stats1var/index.d.ts +1 -0
  68. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  69. package/lib/exercises/math/probaStat/stats1var/index.js +1 -0
  70. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.d.ts +8 -0
  71. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.d.ts.map +1 -0
  72. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.js +244 -0
  73. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts +3 -0
  74. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts.map +1 -0
  75. package/lib/exercises/math/probaStat/twoStepExperiments/index.js +2 -0
  76. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.d.ts +8 -0
  77. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.d.ts.map +1 -0
  78. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.js +452 -0
  79. package/lib/exercises/math/scratch/index.d.ts +2 -0
  80. package/lib/exercises/math/scratch/index.d.ts.map +1 -0
  81. package/lib/exercises/math/scratch/index.js +1 -0
  82. package/lib/exercises/math/scratch/scratchLoopStepsCount.d.ts +8 -0
  83. package/lib/exercises/math/scratch/scratchLoopStepsCount.d.ts.map +1 -0
  84. package/lib/exercises/math/scratch/scratchLoopStepsCount.js +85 -0
  85. package/lib/exercises/math/scratch/testScratch.d.ts +8 -0
  86. package/lib/exercises/math/scratch/testScratch.d.ts.map +1 -0
  87. package/lib/exercises/math/scratch/testScratch.js +79 -0
  88. package/lib/exercises/math/trigonometry/index.d.ts +3 -0
  89. package/lib/exercises/math/trigonometry/index.d.ts.map +1 -1
  90. package/lib/exercises/math/trigonometry/index.js +3 -0
  91. package/lib/exercises/math/trigonometry/trigonometrySideName.d.ts +13 -0
  92. package/lib/exercises/math/trigonometry/trigonometrySideName.d.ts.map +1 -0
  93. package/lib/exercises/math/trigonometry/trigonometrySideName.js +189 -0
  94. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.d.ts +13 -0
  95. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.d.ts.map +1 -0
  96. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.js +290 -0
  97. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.d.ts +18 -0
  98. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.d.ts.map +1 -0
  99. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.js +386 -0
  100. package/lib/index.d.ts +76 -3
  101. package/lib/index.d.ts.map +1 -1
  102. package/lib/latexTester.d.ts.map +1 -1
  103. package/lib/latexTester.js +5 -0
  104. package/lib/math/geometry/triangles/triangle.d.ts +1 -0
  105. package/lib/math/geometry/triangles/triangle.d.ts.map +1 -1
  106. package/lib/math/geometry/triangles/triangle.js +1 -0
  107. package/lib/math/numbers/fractions/isDecimalFraction.d.ts +3 -0
  108. package/lib/math/numbers/fractions/isDecimalFraction.d.ts.map +1 -0
  109. package/lib/math/numbers/fractions/isDecimalFraction.js +14 -0
  110. package/lib/math/polynomials/polynomial.js +1 -1
  111. package/lib/types/keyIds.d.ts +1 -1
  112. package/lib/types/keyIds.d.ts.map +1 -1
  113. package/package.json +1 -1
@@ -0,0 +1,388 @@
1
+ import { shuffleProps, GeneratorOptionType, GeneratorOptionTarget, tryToAddWrongProp, addValidProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { primes } from "../../../../math/numbers/integer/primes.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { round } from "../../../../math/utils/round.js";
6
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
10
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
12
+ import { random, randomMany } from "../../../../utils/alea/random.js";
13
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
14
+ const getStrRatio = (ratio) => {
15
+ return `${ratio.join(" : ")}`;
16
+ };
17
+ const getFractionNodeFromRatio = (ratio, indexPart) => {
18
+ const denNode = ratio
19
+ .map((v) => v.toTree())
20
+ .reduce((acc, x) => add(acc, x));
21
+ return frac(ratio[indexPart], denNode);
22
+ };
23
+ const situationsDict = {
24
+ "2": [
25
+ //tulipes
26
+ {
27
+ instruction: (total, ratio, indexPart) => `Issa et Jérémie vont planter des tulipes.
28
+ Ils en ont $${total}$ à planter.
29
+ Ils se sont mis d'accord pour se partager la tâche suivant le ratio $${getStrRatio(ratio)}$.
30
+ Combien ${indexPart === 0 ? `Issa` : `Jérémie`} a-t-il de tulipes à planter ?`,
31
+ correction: (total, ratio, indexPart) => {
32
+ const fractionNode = getFractionNodeFromRatio(ratio, indexPart);
33
+ const partNode = multiply(fractionNode, total).simplify();
34
+ return `Le ratio est $${getStrRatio(ratio)}$. La fraction du total que ${indexPart === 0 ? `Issa` : `Jérémie`} doit planter est donc :
35
+
36
+ $$
37
+ ${fractionNode.toTex()} = ${fractionNode.simplify().toTex()}
38
+ $$
39
+
40
+ On calcule la part qu'il lui revient en multipliant cette fraction par la quantité totale :
41
+
42
+ $$
43
+ ${fractionNode
44
+ .simplify()
45
+ .toTex()} \\times ${total.frenchify()} = ${partNode.toTex()}
46
+ $$
47
+
48
+ ${indexPart === 0 ? `Issa` : `Jérémie`} doit planter $${partNode.toTex()}$ tulipes.
49
+ `;
50
+ },
51
+ randValues: () => {
52
+ const primePool = primes.filter((n) => 10 < n && n < 60);
53
+ const indexPrime1 = randint(0, primePool.length - 2);
54
+ const [num1, num2] = shuffle([
55
+ primePool[indexPrime1],
56
+ primePool[indexPrime1 + randint(1, 3)],
57
+ ]);
58
+ const divisor = num1 + num2;
59
+ const total = randint(5, 30) * divisor;
60
+ const indexPart = randint(0, 2);
61
+ return {
62
+ ratio: [num1, num2],
63
+ total,
64
+ indexPart,
65
+ };
66
+ },
67
+ },
68
+ //frites
69
+ {
70
+ instruction: (total, ratio, indexPart) => `Dany et Guy se partagent des frites.
71
+ Ils ont compté qu'ils en avaient au total $${total}$.
72
+ Ils se sont mis d'accord pour se les partager suivant le ratio $${getStrRatio(ratio)}$.
73
+ Combien ${indexPart === 0 ? `Dany` : `Guy`} a-t-il de frites à manger ?`,
74
+ correction: (total, ratio, indexPart) => {
75
+ const fractionNode = getFractionNodeFromRatio(ratio, indexPart);
76
+ const partNode = multiply(fractionNode, total).simplify();
77
+ return `Le ratio est $${getStrRatio(ratio)}$. La fraction du total que ${indexPart === 0 ? `Dany` : `Guy`} a est donc :
78
+
79
+ $$
80
+ ${fractionNode.toTex()} = ${fractionNode.simplify().toTex()}
81
+ $$
82
+
83
+ On calcule la part qu'il lui revient en multipliant cette fraction par la quantité totale :
84
+
85
+ $$
86
+ ${fractionNode
87
+ .simplify()
88
+ .toTex()} \\times ${total.frenchify()} = ${partNode.toTex()}
89
+ $$
90
+
91
+ ${indexPart === 0 ? `Dany` : `Guy`} a $${partNode.toTex()}$ frites.
92
+ `;
93
+ },
94
+ randValues: () => {
95
+ const primePool = primes.filter((n) => n < 30);
96
+ const indexPrime1 = randint(0, primePool.length - 3);
97
+ const [num1, num2] = shuffle([
98
+ primePool[indexPrime1],
99
+ primePool[indexPrime1 + randint(2, 4)],
100
+ ]);
101
+ const divisor = num1 + num2;
102
+ const total = randint(5, 20) * divisor;
103
+ const indexPart = randint(0, 2);
104
+ return {
105
+ ratio: [num1, num2],
106
+ total,
107
+ indexPart,
108
+ };
109
+ },
110
+ },
111
+ //supporters
112
+ {
113
+ instruction: (total, ratio, indexPart) => `Dans un stade, l'équipe bleue et l'équipe rouge se rencontrent.
114
+ Il y a $${total}$ supporters au total dans les gradins.
115
+ Les supporters de chaque équipe sont présents suivant le ratio $${getStrRatio(ratio)}$.
116
+ Combien y a-t-il de supporters ${indexPart === 0 ? `bleus` : `rouges`} ?`,
117
+ correction: (total, ratio, indexPart) => {
118
+ const fractionNode = getFractionNodeFromRatio(ratio, indexPart);
119
+ const partNode = multiply(fractionNode, total).simplify();
120
+ return `Le ratio est $${getStrRatio(ratio)}$. La fraction du total que représentent les ${indexPart === 0 ? `bleus` : `rouges`} est donc :
121
+
122
+ $$
123
+ ${fractionNode.toTex()} = ${fractionNode.simplify().toTex()}
124
+ $$
125
+
126
+ On calcule le nombre qu'ils sont en multipliant cette fraction par la quantité totale :
127
+
128
+ $$
129
+ ${fractionNode
130
+ .simplify()
131
+ .toTex()} \\times ${total.frenchify()} = ${partNode.toTex()}
132
+ $$
133
+
134
+ Les ${indexPart === 0 ? `bleus` : `rouges`} sont au nombre de $${partNode.toTex()}$.
135
+ `;
136
+ },
137
+ randValues: () => {
138
+ const primePool = primes;
139
+ const [num1, num2] = randomMany(primePool, 2);
140
+ const divisor = num1 + num2;
141
+ const total = randint(50, 300) * divisor;
142
+ const indexPart = randint(0, 2);
143
+ return {
144
+ ratio: [num1, num2],
145
+ total,
146
+ indexPart,
147
+ };
148
+ },
149
+ },
150
+ ],
151
+ "3": [
152
+ //rgb
153
+ {
154
+ instruction: (total, ratio, indexPart) => `Aline crée une image en pixel art en utilisant uniquement trois couleurs : rouge, vert et bleu.
155
+ L'image est composée de $${total}$ pixels.
156
+ Les couleurs sont distribuées suivant le ratio $${getStrRatio(ratio)}$.
157
+ Combien y a-t-il de pixels ${[`rouges`, `verts`, `bleus`][indexPart]} ?`,
158
+ correction: (total, ratio, indexPart) => {
159
+ const fractionNode = getFractionNodeFromRatio(ratio, indexPart);
160
+ const partNode = multiply(fractionNode, total).simplify();
161
+ return `Le ratio est $${getStrRatio(ratio)}$. La fraction du total que représentent les pixels ${[`rouges`, `verts`, `bleus`][indexPart]} est donc :
162
+
163
+ $$
164
+ ${fractionNode.toTex()} = ${fractionNode.simplify().toTex()}
165
+ $$
166
+
167
+ On calcule leur nombre en multipliant cette fraction par la quantité totale :
168
+
169
+ $$
170
+ ${fractionNode
171
+ .simplify()
172
+ .toTex()} \\times ${total.frenchify()} = ${partNode.toTex()}
173
+ $$
174
+
175
+ Il y a $${partNode.toTex()}$ pixels ${[`rouges`, `verts`, `bleus`][indexPart]}.
176
+ `;
177
+ },
178
+ randValues: () => {
179
+ const primePool = primes;
180
+ const [num1, num2, num3] = randomMany(primePool, 3);
181
+ const divisor = num1 + num2 + num3;
182
+ const total = power(randint(5, 30), 2).evaluate() * divisor;
183
+ const indexPart = randint(0, 3);
184
+ return {
185
+ ratio: [num1, num2, num3],
186
+ total,
187
+ indexPart,
188
+ };
189
+ },
190
+ },
191
+ //salade de fruits
192
+ {
193
+ instruction: (total, ratio, indexPart) => `Un industriel produit de la salade de fruits en mélangeant des morceaux de poire, d'abricot et de cerise.
194
+ Dans un pot standard pour la restauration collective, il y a $${total}$ morceaux.
195
+ Les morceaux sont distribués suivant le ratio $${getStrRatio(ratio)}$.
196
+ Combien y a-t-il de morceaux ${[`de poire`, `d'abricot`, `de cerise`][indexPart]} ?`,
197
+ correction: (total, ratio, indexPart) => {
198
+ const fractionNode = getFractionNodeFromRatio(ratio, indexPart);
199
+ const partNode = multiply(fractionNode, total).simplify();
200
+ return `Le ratio est $${getStrRatio(ratio)}$. La fraction du total que représentent les morceaux ${[`de poire`, `d'abricot`, `de cerise`][indexPart]} est donc :
201
+
202
+ $$
203
+ ${fractionNode.toTex()} = ${fractionNode.simplify().toTex()}
204
+ $$
205
+
206
+ On calcule leur nombre en multipliant cette fraction par la quantité totale :
207
+
208
+ $$
209
+ ${fractionNode
210
+ .simplify()
211
+ .toTex()} \\times ${total.frenchify()} = ${partNode.toTex()}
212
+ $$
213
+
214
+ Il y a $${partNode.toTex()}$ morceaux ${[`de poire`, `d'abricot`, `de cerise`][indexPart]}.
215
+ `;
216
+ },
217
+ randValues: () => {
218
+ const primePool = primes.filter((n) => n > 30);
219
+ const indexPrime1 = randint(0, primePool.length - 3);
220
+ const [num1, num2] = shuffle([
221
+ primePool[indexPrime1],
222
+ primePool[indexPrime1 + randint(1, 4)],
223
+ ]);
224
+ const num3 = random(primes.filter((n) => n < 10));
225
+ const divisor = num1 + num2 + num3;
226
+ const total = randint(50, 100) * divisor;
227
+ const indexPart = randint(0, 3);
228
+ return {
229
+ ratio: [num1, num2, num3],
230
+ total,
231
+ indexPart,
232
+ };
233
+ },
234
+ },
235
+ //clé usb
236
+ {
237
+ instruction: (total, ratio, indexPart) => `Danièle a $${total}$ fichiers multimédia sur sa clé USB.
238
+ Les musiques, photos, vidéos sont distribuées suivant le ratio $${getStrRatio(ratio)}$.
239
+ Combien y a-t-il de ${[`musiques`, `photos`, `vidéos`][indexPart]} sur sa clé ?`,
240
+ correction: (total, ratio, indexPart) => {
241
+ const fractionNode = getFractionNodeFromRatio(ratio, indexPart);
242
+ const partNode = multiply(fractionNode, total).simplify();
243
+ return `Le ratio est $${getStrRatio(ratio)}$. La fraction du total que représentent les ${[`musiques`, `photos`, `vidéos`][indexPart]} est donc :
244
+
245
+ $$
246
+ ${fractionNode.toTex()} = ${fractionNode.simplify().toTex()}
247
+ $$
248
+
249
+ On calcule leur nombre en multipliant cette fraction par la quantité totale :
250
+
251
+ $$
252
+ ${fractionNode
253
+ .simplify()
254
+ .toTex()} \\times ${total.frenchify()} = ${partNode.toTex()}
255
+ $$
256
+
257
+ Il y a $${partNode.toTex()}$ ${[`musiques`, `photos`, `vidéos`][indexPart]}.
258
+ `;
259
+ },
260
+ randValues: () => {
261
+ const [num1, num2, num3] = randomMany(primes, 3);
262
+ const divisor = num1 + num2 + num3;
263
+ const total = randint(10, 20) * divisor;
264
+ const indexPart = randint(0, 3);
265
+ return {
266
+ ratio: [num1, num2, num3],
267
+ total,
268
+ indexPart,
269
+ };
270
+ },
271
+ },
272
+ ],
273
+ };
274
+ const getPropositions = (n, { answer, ...identifiers }) => {
275
+ const { ratio, total, indexPart, ratioType } = identifiers;
276
+ const propositions = [];
277
+ const answerNode = getAnswerNode(identifiers);
278
+ addValidProp(propositions, answerNode.toTex());
279
+ //wrong indexPart
280
+ const arrIndexPart = ratioType === "2" ? [0, 1] : [0, 1, 2];
281
+ arrIndexPart
282
+ .filter((i) => i !== indexPart)
283
+ .forEach((i) => {
284
+ const fractionNode = getFractionNodeFromRatio(ratio, i);
285
+ const nodeWrong = multiply(fractionNode, total).simplify();
286
+ tryToAddWrongProp(propositions, nodeWrong.toTex());
287
+ });
288
+ //ratio[indexPart] is percentage
289
+ ratio.map((v) => {
290
+ const fractionNode = frac(v, 100);
291
+ const nodeWrong = round(multiply(fractionNode, total).simplify().evaluate(), 0).toTree();
292
+ tryToAddWrongProp(propositions, nodeWrong.toTex());
293
+ });
294
+ //random around
295
+ const valueAnswer = answerNode.evaluate();
296
+ const vWrong = randint(valueAnswer, valueAnswer + (total - valueAnswer) * 0.2);
297
+ tryToAddWrongProp(propositions, vWrong.frenchify());
298
+ return shuffleProps(propositions, n);
299
+ };
300
+ const getAnswerNode = (identifiers) => {
301
+ const { ratio, total, indexPart } = identifiers;
302
+ const fractionNode = getFractionNodeFromRatio(ratio, indexPart);
303
+ return multiply(fractionNode, total).simplify();
304
+ };
305
+ const getAnswer = (identifiers) => {
306
+ return getAnswerNode(identifiers).toTex();
307
+ };
308
+ const getInstruction = (identifiers) => {
309
+ const { ratioType, situationIndex, total, ratio, indexPart } = identifiers;
310
+ const situation = situationsDict[ratioType][situationIndex];
311
+ return situation.instruction(total, ratio, indexPart);
312
+ };
313
+ const getHint = () => {
314
+ return `Cherche à quelle fraction du total correspond chaque part.`;
315
+ };
316
+ const getCorrection = (identifiers) => {
317
+ const { ratioType, situationIndex, total, ratio, indexPart } = identifiers;
318
+ const situation = situationsDict[ratioType][situationIndex];
319
+ return situation.correction(total, ratio, indexPart);
320
+ };
321
+ const isAnswerValid = (ans, { answer }) => {
322
+ try {
323
+ const [nodeAns, nodeAnswer] = [ans, answer].map((str) => parseAlgebraic(str));
324
+ return substract(nodeAns, nodeAnswer).simplify().evaluate() === 0;
325
+ }
326
+ catch (_) {
327
+ return false;
328
+ }
329
+ };
330
+ const getPartUsingRatioQuestion = (optsIn) => {
331
+ const opts = optsIn ?? optsDefault;
332
+ const ratioType = random(opts.ratioTypes);
333
+ const arrSituation = situationsDict[ratioType];
334
+ const situationIndex = randint(0, arrSituation.length);
335
+ const situation = arrSituation[situationIndex];
336
+ const { total, ratio, indexPart } = situation.randValues();
337
+ const identifiers = {
338
+ ratioType,
339
+ situationIndex,
340
+ total,
341
+ ratio,
342
+ indexPart,
343
+ };
344
+ return getQuestionFromIdentifiers(identifiers, opts);
345
+ };
346
+ const getQuestionFromIdentifiers = (identifiers, options) => {
347
+ return {
348
+ answer: getAnswer(identifiers, options),
349
+ instruction: getInstruction(identifiers, options),
350
+ keys: [],
351
+ answerFormat: "tex",
352
+ identifiers,
353
+ hint: getHint(identifiers, options),
354
+ correction: getCorrection(identifiers, options),
355
+ options,
356
+ };
357
+ };
358
+ const options = [
359
+ {
360
+ id: "ratioTypes",
361
+ label: "Longueur du ratio",
362
+ type: GeneratorOptionType.multiselect,
363
+ target: GeneratorOptionTarget.generation,
364
+ values: ["2", "3"],
365
+ defaultValue: ["2", "3"],
366
+ },
367
+ ];
368
+ const optsDefault = {
369
+ ratioTypes: ["2", "3"],
370
+ };
371
+ export const partUsingRatio = {
372
+ id: "partUsingRatio",
373
+ label: "Calculer une partie en utilisant un ratio",
374
+ isSingleStep: true,
375
+ generator: (nb, opts) => getDistinctQuestions(() => getPartUsingRatioQuestion(opts), nb),
376
+ options,
377
+ qcmTimer: 60,
378
+ freeTimer: 60,
379
+ getPropositions,
380
+ subject: "Mathématiques",
381
+ getInstruction,
382
+ getHint,
383
+ getCorrection,
384
+ getAnswer,
385
+ getQuestionFromIdentifiers,
386
+ hasHintAndCorrection: true,
387
+ isAnswerValid,
388
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ parts: number[];
4
+ };
5
+ type Options = {
6
+ ratioTypes: string[];
7
+ };
8
+ export declare const ratioFromParts: Exercise<Identifiers, Options>;
9
+ export {};
10
+ //# sourceMappingURL=ratioFromParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ratioFromParts.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ratio/ratioFromParts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AA2DrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAiLF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAiBF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBzD,CAAC"}
@@ -0,0 +1,198 @@
1
+ import { shuffleProps, GeneratorOptionType, GeneratorOptionTarget, tryToAddWrongProp, addValidProp, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
5
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
7
+ import { random, randomMany } from "../../../../utils/alea/random.js";
8
+ const isEquivalentRatios = (ratio1, ratio2) => {
9
+ const fractionNode0 = frac(ratio1[0], ratio2[0]).simplify();
10
+ return ratio1.slice(1).every((n1, i) => {
11
+ const fractionNodeI = frac(n1, ratio2[i]).simplify();
12
+ return substract(fractionNode0, fractionNodeI).simplify().evaluate() === 0;
13
+ });
14
+ };
15
+ const getRatioFromParts = (parts) => {
16
+ const minPart = Math.min(...parts);
17
+ const nodesAfterFrac = parts.map((v) => frac(v, minPart).simplify());
18
+ const densDistinctSortedDesc = [
19
+ ...new Set(nodesAfterFrac
20
+ .filter((node) => isFractionNode(node))
21
+ .map((fractionNode) => fractionNode.rightChild.evaluate())),
22
+ ].toSorted((den1, den2) => -(den1 - den2));
23
+ if (densDistinctSortedDesc.length > 0) {
24
+ const arrNodes = densDistinctSortedDesc
25
+ .reduce((acc, den) => {
26
+ const nodesLatest = acc[acc.length - 1];
27
+ return [
28
+ ...acc,
29
+ nodesLatest.map((node) => multiply(den, node).simplify()),
30
+ ];
31
+ }, [nodesAfterFrac])
32
+ .slice(1);
33
+ const ratio = arrNodes
34
+ .find((nodes) => nodes.every((node) => !isFractionNode(node)))
35
+ .map((node) => node.evaluate());
36
+ return ratio;
37
+ }
38
+ else {
39
+ return nodesAfterFrac.map((node) => node.evaluate());
40
+ }
41
+ };
42
+ const getInstruction = (identifiers) => {
43
+ const { parts } = identifiers;
44
+ return `À quel ratio obéissent les valeurs ci-dessous ?
45
+
46
+ - ${parts.map((v) => `$${v}$`).join(" ; ")}
47
+
48
+ `;
49
+ };
50
+ const getHint = () => {
51
+ return `Cherche le rapport entre chaque valeur et la plus petite des valeurs.`;
52
+ };
53
+ const getCorrection = (identifiers) => {
54
+ const { parts } = identifiers;
55
+ const minPart = Math.min(...parts);
56
+ const nodesAfterFrac = parts.map((v) => frac(v, minPart).simplify());
57
+ const densDistinctSortedDesc = [
58
+ ...new Set(nodesAfterFrac
59
+ .filter((node) => isFractionNode(node))
60
+ .map((fractionNode) => fractionNode.rightChild.evaluate())),
61
+ ].toSorted((den1, den2) => -(den1 - den2));
62
+ const arrNodes = densDistinctSortedDesc
63
+ .reduce((acc, den) => {
64
+ const nodesLatest = acc[acc.length - 1];
65
+ return [
66
+ ...acc,
67
+ nodesLatest.map((node) => multiply(den, node).simplify()),
68
+ ];
69
+ }, [nodesAfterFrac])
70
+ .slice(1);
71
+ return `On calcule le rapport entre chaque valeur et la plus petite :
72
+
73
+ $$
74
+ ${nodesAfterFrac.map((node) => node.toTex()).join("\\text{ ; }")}
75
+ $$
76
+
77
+ ${(() => {
78
+ if (densDistinctSortedDesc.length > 0) {
79
+ const indexRatio = [...Array(arrNodes.length).keys()].find((i) => arrNodes[i].every((node) => !isFractionNode(node)));
80
+ const arrNodesSteps = arrNodes.filter((_, i) => i <= indexRatio);
81
+ return `On classe les dénominateurs par ordre décroissant : $${densDistinctSortedDesc
82
+ .map((den) => den.frenchify())
83
+ .join(">")}$
84
+
85
+ Avec chaque dénominateur, on multiplie tous les nombres jusqu'à ne plus avoir que des entiers :
86
+
87
+ ${arrNodesSteps.map((nodes) => `
88
+
89
+ $$
90
+ ${nodes.map((node) => node.toTex()).join("\\text{ ; }")}
91
+ $$
92
+
93
+ `).join(`
94
+
95
+ `)}
96
+
97
+ Le ratio recherché est $${arrNodes[indexRatio]
98
+ .map((node) => node.toTex())
99
+ .join(`:`)}$.`;
100
+ }
101
+ else {
102
+ return `Le ratio recherché est $${nodesAfterFrac
103
+ .map((node) => node.toTex())
104
+ .join(`:`)}$.`;
105
+ }
106
+ })()}
107
+
108
+ `;
109
+ };
110
+ const getAnswer = (identifiers) => {
111
+ const { parts } = identifiers;
112
+ return getRatioFromParts(parts)
113
+ .map((n) => n.frenchify())
114
+ .join(":");
115
+ };
116
+ const getPropositions = (n, { answer, ...identifiers }) => {
117
+ const { parts } = identifiers;
118
+ const propositions = [];
119
+ const ratio = getRatioFromParts(parts);
120
+ addValidProp(propositions, ratio.map((n) => n.frenchify()).join(":"));
121
+ const arrOffsetsExcluded = parts.map(() => [0]);
122
+ propWhile(propositions, n, () => {
123
+ const offsets = parts.map((_, i) => randint(-10, 11, arrOffsetsExcluded[i]));
124
+ offsets.forEach((offset, i) => {
125
+ arrOffsetsExcluded[i].push(offset);
126
+ });
127
+ const ratioWrongCandidate = ratio.map((n, i) => n + offsets[i]);
128
+ if (ratioWrongCandidate.some((v) => v < 1) ||
129
+ isEquivalentRatios(ratioWrongCandidate, ratio)) {
130
+ //ignore
131
+ }
132
+ else {
133
+ const ratioWrong = ratioWrongCandidate;
134
+ tryToAddWrongProp(propositions, ratioWrong.map((n) => n.frenchify()).join(":"));
135
+ }
136
+ });
137
+ return shuffleProps(propositions, n);
138
+ };
139
+ const isAnswerValid = (ans, { answer }) => {
140
+ return ans === answer;
141
+ };
142
+ const getKeys = () => {
143
+ return ["colon"];
144
+ };
145
+ const getRatioFromPartsQuestion = (optsIn) => {
146
+ const opts = optsIn ?? optsDefault;
147
+ const ratioType = random(opts.ratioTypes);
148
+ const ratio = randomMany([...Array(100).keys()].map((i) => i + 1), +ratioType);
149
+ const k = randint(20, 50);
150
+ const parts = ratio.map((n) => n * k);
151
+ const identifiers = {
152
+ parts,
153
+ };
154
+ return getQuestionFromIdentifiers(identifiers, opts);
155
+ };
156
+ const getQuestionFromIdentifiers = (identifiers, options) => {
157
+ return {
158
+ answer: getAnswer(identifiers, options),
159
+ instruction: getInstruction(identifiers, options),
160
+ keys: getKeys(identifiers),
161
+ answerFormat: "tex",
162
+ identifiers,
163
+ hint: getHint(identifiers, options),
164
+ correction: getCorrection(identifiers, options),
165
+ options,
166
+ };
167
+ };
168
+ const options = [
169
+ {
170
+ id: "ratioTypes",
171
+ label: "Longueur du ratio",
172
+ type: GeneratorOptionType.multiselect,
173
+ target: GeneratorOptionTarget.generation,
174
+ values: ["2", "3"],
175
+ defaultValue: ["2", "3"],
176
+ },
177
+ ];
178
+ const optsDefault = {
179
+ ratioTypes: ["2", "3"],
180
+ };
181
+ export const ratioFromParts = {
182
+ id: "ratioFromParts",
183
+ label: "Calculer un ratio",
184
+ isSingleStep: true,
185
+ generator: (nb, opts) => getDistinctQuestions(() => getRatioFromPartsQuestion(opts), nb),
186
+ options,
187
+ qcmTimer: 60,
188
+ freeTimer: 60,
189
+ getPropositions,
190
+ subject: "Mathématiques",
191
+ getInstruction,
192
+ getHint,
193
+ getCorrection,
194
+ getAnswer,
195
+ getQuestionFromIdentifiers,
196
+ hasHintAndCorrection: true,
197
+ isAnswerValid,
198
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"equationFromSentenceExercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationFromSentenceExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AA2PF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAY9D,CAAC"}
1
+ {"version":3,"file":"equationFromSentenceExercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationFromSentenceExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAkTF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAa9D,CAAC"}
@@ -84,6 +84,53 @@ const getEquationFromSentenceExerciseQuestion = () => {
84
84
  };
85
85
  return getQuestionFromIdentifiers(identifiers);
86
86
  };
87
+ const getHint = () => {
88
+ return `Cherche à traduire chaque mot de la phrase en une opération mathématiques, en partant d'un nombre $x$.`;
89
+ };
90
+ const getCorrection = (identifiers) => {
91
+ const { type, vars } = identifiers;
92
+ const { flip, randAdd, op2 } = vars;
93
+ switch (type) {
94
+ case 1:
95
+ return `${flip ? `Le double` : `La moitié`} de $x$ se note :
96
+
97
+ $$
98
+ ${flip ? "2x" : "\\frac{x}{2}"}
99
+ $$
100
+
101
+ La phrase se traduit donc par l'équation suivante :
102
+
103
+ $$
104
+ ${getAnswer(identifiers)}
105
+ $$`;
106
+ case 2:
107
+ return `${flip ? `La somme` : `La différence`} de $x$ et de $${randAdd}$ se note :
108
+
109
+ $$
110
+ x${flip ? "+" : "-"}${randAdd}
111
+ $$
112
+
113
+ La phrase se traduit donc par l'équation suivante :
114
+
115
+ $$
116
+ ${getAnswer(identifiers)}
117
+ $$
118
+ `;
119
+ case 3:
120
+ default:
121
+ return `${flip ? `Le double` : `La moitié`} de $x$ ${flip ? op2 : op2 + "e"} de $${randAdd}$ se note :
122
+
123
+ $$
124
+ ${flip ? "2x" : "\\frac{x}{2}"}${flip ? "-" : "+"}${randAdd}
125
+ $$
126
+
127
+ La phrase se traduit donc par l'équation suivante :
128
+
129
+ $$
130
+ ${getAnswer(identifiers)}
131
+ $$`;
132
+ }
133
+ };
87
134
  const getQuestionFromIdentifiers = (identifiers) => {
88
135
  const question = {
89
136
  answer: getAnswer(identifiers),
@@ -91,6 +138,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
91
138
  keys: ["x", "equal"],
92
139
  answerFormat: "tex",
93
140
  identifiers,
141
+ hint: getHint(identifiers),
142
+ correction: getCorrection(identifiers),
94
143
  };
95
144
  return question;
96
145
  };
@@ -169,4 +218,5 @@ export const equationFromSentenceExericse = {
169
218
  isAnswerValid,
170
219
  subject: "Mathématiques",
171
220
  getQuestionFromIdentifiers,
221
+ hasHintAndCorrection: true,
172
222
  };
@@ -14,7 +14,7 @@ const getCorrection = () => {
14
14
  return `
15
15
 
16
16
  $$
17
- -a = (1) \\times a = a \\times (1) = \\frac{a}{-1} = -\\frac{a}{1}
17
+ -a = (-1) \\times a = a \\times (-1) = \\frac{a}{-1} = -\\frac{a}{1}
18
18
  $$
19
19
 
20
20
  `;