math-exercises 3.0.146 → 3.0.148

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 (69) hide show
  1. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.js +1 -1
  2. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +1 -0
  3. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/mentalCaluls/index.js +1 -0
  5. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +28 -4
  7. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.js +50 -23
  9. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.d.ts +9 -0
  10. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.d.ts.map +1 -0
  11. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.js +423 -0
  12. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +48 -24
  14. package/lib/exercises/math/calcul/mentalCaluls/mentalPercentage.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/mentalCaluls/mentalPercentage.js +236 -22
  16. package/lib/exercises/math/calcul/operations/operationsPriorities.d.ts.map +1 -1
  17. package/lib/exercises/math/calcul/operations/operationsPriorities.js +48 -20
  18. package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.js +47 -19
  20. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  21. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +26 -6
  22. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts.map +1 -1
  23. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +92 -16
  24. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts.map +1 -1
  25. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.js +1 -0
  26. package/lib/exercises/math/conversion/volumeCapacityConversion.d.ts.map +1 -1
  27. package/lib/exercises/math/conversion/volumeCapacityConversion.js +171 -0
  28. package/lib/exercises/math/dataRepresentations/barChartReading.d.ts.map +1 -1
  29. package/lib/exercises/math/dataRepresentations/barChartReading.js +17 -8
  30. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts.map +1 -1
  31. package/lib/exercises/math/dataRepresentations/functionGraphReading.js +94 -8
  32. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts +6 -1
  33. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/affines/affineExpressionReading.js +166 -52
  35. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts +5 -1
  36. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.js +59 -17
  38. package/lib/exercises/math/functions/basics/graphicInequation.js +1 -1
  39. package/lib/exercises/math/functions/index.d.ts +1 -0
  40. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/index.js +1 -0
  42. package/lib/exercises/math/functions/linear/index.d.ts +3 -0
  43. package/lib/exercises/math/functions/linear/index.d.ts.map +1 -0
  44. package/lib/exercises/math/functions/linear/index.js +2 -0
  45. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts +9 -0
  46. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts.map +1 -0
  47. package/lib/exercises/math/functions/linear/linearFromExercise.js +354 -0
  48. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts +8 -0
  49. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts.map +1 -0
  50. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.js +233 -0
  51. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts.map +1 -1
  52. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.js +2 -5
  53. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.d.ts +22 -0
  54. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.d.ts.map +1 -0
  55. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.js +647 -0
  56. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.d.ts +23 -0
  57. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.d.ts.map +1 -0
  58. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.js +540 -0
  59. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.d.ts.map +1 -1
  60. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.js +75 -6
  61. package/lib/index.d.ts +22 -3
  62. package/lib/index.d.ts.map +1 -1
  63. package/lib/tree/nodes/equations/notEqualNode.d.ts +35 -0
  64. package/lib/tree/nodes/equations/notEqualNode.d.ts.map +1 -0
  65. package/lib/tree/nodes/equations/notEqualNode.js +84 -0
  66. package/lib/tree/utilities/nodeSimplifier.d.ts +16 -0
  67. package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -0
  68. package/lib/tree/utilities/nodeSimplifier.js +283 -0
  69. package/package.json +1 -1
@@ -4,9 +4,11 @@ import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { round } from "../../../../math/utils/round.js";
5
5
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
6
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { NodeSimplifier } from "../../../../tree/utilities/nodeSimplifier.js";
7
8
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
8
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
9
10
  import { shuffle } from "../../../../utils/alea/shuffle.js";
11
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
10
12
  const getInstruction = (identifiers) => {
11
13
  return `Calculer :
12
14
 
@@ -25,16 +27,37 @@ const getAnswer = (identifiers) => {
25
27
  const statement = getStatementNode(identifiers);
26
28
  return statement.simplify().toTex();
27
29
  };
28
- const getQuestionFromIdentifiers = (identifiers) => {
29
- const question = {
30
- instruction: getInstruction(identifiers),
31
- startStatement: getStartStatement(identifiers),
32
- answer: getAnswer(identifiers),
33
- keys: [],
34
- answerFormat: "tex",
35
- identifiers,
36
- };
37
- return question;
30
+ const getHint = () => {
31
+ return `Il n'y a que des multiplications :
32
+ Tu peux effectuer les calculs de gauche à droite.`;
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const node = getStatementNode(identifiers);
36
+ const arrTexNodeStepByStep = NodeSimplifier.arrTexStepByStep(node);
37
+ return `Il n'y a que des multiplications :
38
+ On va effectuer les calculs de gauche à droite.
39
+
40
+ ${alignTex([
41
+ [node.toTex(), "=", arrTexNodeStepByStep[0]],
42
+ ...arrTexNodeStepByStep.slice(1).map((tex) => ["", "=", tex]),
43
+ ])}
44
+
45
+ `;
46
+ };
47
+ const getPropositions = (n, { answer }) => {
48
+ const propositions = [];
49
+ addValidProp(propositions, answer);
50
+ const result = answer.unfrenchify();
51
+ propWhile(propositions, n, () => {
52
+ const incorrectAnswer = round(result + (coinFlip() ? 1 : -1) * Math.random() * 10, 2);
53
+ tryToAddWrongProp(propositions, incorrectAnswer.toString().replace(".", ","));
54
+ });
55
+ return shuffle(propositions);
56
+ };
57
+ const isAnswerValid = (studentAns, { answer }) => {
58
+ const answerTree = new NumberNode(Number(answer.replace(",", ".")));
59
+ const texs = answerTree.toAllValidTexs();
60
+ return texs.includes(studentAns);
38
61
  };
39
62
  const getMentalMultiplications = () => {
40
63
  let numbers = [];
@@ -62,20 +85,18 @@ const getMentalMultiplications = () => {
62
85
  const identifiers = { numbers };
63
86
  return getQuestionFromIdentifiers(identifiers);
64
87
  };
65
- const getPropositions = (n, { answer }) => {
66
- const propositions = [];
67
- addValidProp(propositions, answer);
68
- const result = answer.unfrenchify();
69
- propWhile(propositions, n, () => {
70
- const incorrectAnswer = round(result + (coinFlip() ? 1 : -1) * Math.random() * 10, 2);
71
- tryToAddWrongProp(propositions, incorrectAnswer.toString().replace(".", ","));
72
- });
73
- return shuffle(propositions);
74
- };
75
- const isAnswerValid = (studentAns, { answer }) => {
76
- const answerTree = new NumberNode(Number(answer.replace(",", ".")));
77
- const texs = answerTree.toAllValidTexs();
78
- return texs.includes(studentAns);
88
+ const getQuestionFromIdentifiers = (identifiers) => {
89
+ const question = {
90
+ instruction: getInstruction(identifiers),
91
+ startStatement: getStartStatement(identifiers),
92
+ answer: getAnswer(identifiers),
93
+ keys: [],
94
+ answerFormat: "tex",
95
+ identifiers,
96
+ hint: getHint(identifiers),
97
+ correction: getCorrection(identifiers),
98
+ };
99
+ return question;
79
100
  };
80
101
  export const mentalMultiplications = {
81
102
  id: "mentalMultiplications",
@@ -89,4 +110,7 @@ export const mentalMultiplications = {
89
110
  isAnswerValid,
90
111
  subject: "Mathématiques",
91
112
  getQuestionFromIdentifiers,
113
+ getHint,
114
+ getCorrection,
115
+ hasHintAndCorrection: true,
92
116
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mentalPercentage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalPercentage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0JF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAYlD,CAAC"}
1
+ {"version":3,"file":"mentalPercentage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalPercentage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwXF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
@@ -2,26 +2,231 @@ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercis
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
5
7
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
6
8
  import { shuffle } from "../../../../utils/alea/shuffle.js";
9
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
7
10
  const getInstruction = (identifiers) => {
8
11
  const { a, b } = identifiers;
9
- return `Que vaut $${String(a).replace(".", ",")}\\%$ de $${b}$ ?`;
12
+ return `Que vaut $${a.frenchify()}\\%$ de $${b}$ ?`;
10
13
  };
11
14
  const getAnswer = (identifiers) => {
12
15
  const { a, b } = identifiers;
13
16
  const answer = ((a * b) / 100).frenchify();
14
17
  return answer;
15
18
  };
16
- const getQuestionFromIdentifiers = (identifiers) => {
17
- const question = {
18
- instruction: getInstruction(identifiers),
19
- answer: getAnswer(identifiers),
20
- keys: [],
21
- answerFormat: "tex",
22
- identifiers,
23
- };
24
- return question;
19
+ const getHint = () => {
20
+ return `Pour prendre un pourcentage d'un nombre, il faut effectuer une multiplication.
21
+
22
+ Essaye de rendre la multiplication plus facile à faire en la transformant en une expression équivalente
23
+ (transformer les facteurs ou même transformer la multiplication en division).
24
+
25
+ À la fin, n'oublie par de diviser par $10$ ou par $100$ selon le cas, si nécessaire.`;
26
+ };
27
+ const getCorrection = (identifiers) => {
28
+ const { rand, a, b } = identifiers;
29
+ const texAnswer = multiply(frac(a, 100), b)
30
+ .simplify({ fractionsToDecimal: true })
31
+ .toTex();
32
+ if (b === 100) {
33
+ return `
34
+
35
+ ${alignTex([
36
+ [
37
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
38
+ "=",
39
+ `\\frac{${a.frenchify()}}{100} \\times ${b.frenchify()}`,
40
+ ],
41
+ ["", "=", `${texAnswer}`],
42
+ ])}
43
+
44
+ `;
45
+ }
46
+ if (a === 200) {
47
+ return `
48
+
49
+ ${alignTex([
50
+ [
51
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
52
+ "=",
53
+ `2 \\times ${b.frenchify()}`,
54
+ ],
55
+ ["", "=", `${texAnswer}`],
56
+ ])}
57
+
58
+ `;
59
+ }
60
+ switch (rand) {
61
+ case 1: // 10% de 70%
62
+ return `
63
+
64
+ ${alignTex([
65
+ [
66
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
67
+ "=",
68
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
69
+ ],
70
+ ["", "=", `${texAnswer}`],
71
+ ])}
72
+
73
+ `;
74
+ case 2: // 30% de 9
75
+ return `
76
+
77
+ $$
78
+ ${a.frenchify()}\\% \\times ${b.frenchify()} = \\frac{${a.frenchify()}}{100} \\times ${b.frenchify()} = \\frac{1}{10} \\times ${(a / 10).frenchify()} \\times ${b.frenchify()}
79
+ $$
80
+
81
+ Or :
82
+
83
+ $$
84
+ ${(a / 10).frenchify()} \\times ${b.frenchify()} = ${((a / 10) * b).frenchify()}
85
+ $$
86
+
87
+ Donc :
88
+
89
+ $$
90
+ ${a.frenchify()}\\% \\times ${b.frenchify()} = ${texAnswer}
91
+ $$
92
+
93
+ `;
94
+ case 3: // 32% de 10
95
+ return `
96
+
97
+ ${alignTex([
98
+ [
99
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
100
+ "=",
101
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
102
+ ],
103
+ ["", "=", `${a.frenchify()} \\times \\frac{${b.frenchify()}}{100}`],
104
+ ["", "=", `${a.frenchify()} \\times \\frac{${(b / 10).frenchify()}}{10}`],
105
+ ["", "=", `${texAnswer}`],
106
+ ])}
107
+
108
+ `;
109
+ case 4: {
110
+ // 14% de 50 ou 230% de 20
111
+ return `
112
+
113
+ ${alignTex([
114
+ [
115
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
116
+ "=",
117
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
118
+ ],
119
+ ["", "=", `${texAnswer}`],
120
+ ])}
121
+
122
+ `;
123
+ }
124
+ case 5: // 12.5% de 72
125
+ if (a === 12.5) {
126
+ return `
127
+
128
+ ${alignTex([
129
+ [
130
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
131
+ "=",
132
+ `\\frac{1}{8} \\times ${b.frenchify()}`,
133
+ ],
134
+ ["", "=", `${(b / 8).frenchify()}`],
135
+ ["", "=", `${texAnswer}`],
136
+ ])}
137
+
138
+ `;
139
+ }
140
+ else {
141
+ return `
142
+
143
+ ${alignTex([
144
+ [
145
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
146
+ "=",
147
+ `\\frac{9}{8} \\times ${b.frenchify()}`,
148
+ ],
149
+ ["", "=", `9 \\times ${(b / 8).frenchify()}`],
150
+ ["", "=", `${texAnswer}`],
151
+ ])}
152
+
153
+ `;
154
+ }
155
+ case 6: // 15% de 90
156
+ return `
157
+
158
+ ${alignTex([
159
+ [
160
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
161
+ "=",
162
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
163
+ ],
164
+ [
165
+ "",
166
+ "=",
167
+ `\\frac{${a.frenchify()}}{100} \\times ${(b / 10).frenchify()} \\times 10`,
168
+ ],
169
+ ["", "=", `${(a / 10).frenchify()} \\times ${(b / 10).frenchify()}`],
170
+ ["", "=", `${texAnswer}`],
171
+ ])}
172
+
173
+ `;
174
+ case 7: // 20% de x
175
+ return `
176
+
177
+ ${alignTex([
178
+ [
179
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
180
+ "=",
181
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
182
+ ],
183
+ ["", "=", `\\frac{${(a / 20).frenchify()}}{5} \\times ${b.frenchify()}`],
184
+ ["", "=", `${(a / 20).frenchify()} \\times \\frac{${b.frenchify()}}{5}`],
185
+ ["", "=", `${texAnswer}`],
186
+ ])}
187
+
188
+ `;
189
+ case 8: // 75% de x
190
+ return `
191
+
192
+ ${alignTex([
193
+ [
194
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
195
+ "=",
196
+ `${(a / 25).frenchify()} \\times 25\\% \\times ${b.frenchify()}`,
197
+ ],
198
+ [
199
+ "",
200
+ "=",
201
+ `${(a / 25).frenchify()} \\times \\frac{1}{4} \\times ${b.frenchify()}`,
202
+ ],
203
+ ["", "=", `${(a / 25).frenchify()} \\times ${(b / 4).frenchify()}`],
204
+ ["", "=", `${texAnswer}`],
205
+ ])}
206
+
207
+ `;
208
+ case 9: //0.5 % de 1000
209
+ return `
210
+
211
+ ${alignTex([
212
+ [
213
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
214
+ "=",
215
+ `${(a * 10).frenchify()}\\% \\times \\frac{1}{10} \\times 1000`,
216
+ ],
217
+ ["", "=", `${(a * 10).frenchify()}\\% \\times 100`],
218
+ ["", "=", `${texAnswer}`],
219
+ ])}
220
+
221
+ `;
222
+ }
223
+ throw new Error("Unsupported rand: " + rand);
224
+ };
225
+ const isAnswerValid = (studentAns, { answer }) => {
226
+ return rationalVEA(studentAns, answer, {
227
+ allowNonIrreductible: true,
228
+ allowDecimal: true,
229
+ });
25
230
  };
26
231
  const getMentalPercentage = () => {
27
232
  let a = 1, b = 1;
@@ -29,11 +234,11 @@ const getMentalPercentage = () => {
29
234
  switch (rand) {
30
235
  case 1: // 10% de 70%
31
236
  a = 10 * randint(1, 3);
32
- b = randint(1, 200);
237
+ b = randint(1, 100);
33
238
  break;
34
239
  case 2: // 30% de 9
35
240
  a = randint(1, 10);
36
- b = randint(1, 10) * a;
241
+ b = randint(1, 5) * a;
37
242
  a *= 10;
38
243
  break;
39
244
  case 3: // 32% de 10
@@ -46,19 +251,19 @@ const getMentalPercentage = () => {
46
251
  break;
47
252
  case 5: // 12.5% de 72
48
253
  a = coinFlip() ? 12.5 : 12.5 + 100;
49
- b = 8 * randint(1, 25);
254
+ b = 8 * randint(1, 10);
50
255
  break;
51
256
  case 6: // 15% de 90
52
257
  a = coinFlip() ? 15 * randint(1, 6) : 30 * randint(1, 4, [2]) + 100;
53
- b = 3 * randint(1, 10) * 10;
258
+ b = 3 * randint(1, 5) * 10;
54
259
  break;
55
260
  case 7: // 20% de x
56
261
  a = 20 * randint(1, 12, [5]);
57
- b = 5 * randint(1, 21);
262
+ b = 5 * randint(1, 11);
58
263
  break;
59
264
  case 8: // 75% de x
60
265
  a = 25 * randint(1, 8, [4]);
61
- b = 4 * randint(1, 75);
266
+ b = 4 * randint(1, 11);
62
267
  break;
63
268
  case 9: //0.5 % de 1000
64
269
  a = randint(1, 10) / 10;
@@ -94,7 +299,7 @@ const getPropositions = (n, { answer, rand }) => {
94
299
  break;
95
300
  case 5: // 12.5% de 72
96
301
  a = coinFlip() ? 12.5 : 12.5 + 100;
97
- b = 8 * randint(1, 25);
302
+ b = 8 * randint(1, 11);
98
303
  break;
99
304
  case 6: // 15% de 90
100
305
  a = coinFlip() ? 15 * randint(1, 6) : 30 * randint(1, 4, [2]) + 100;
@@ -118,11 +323,17 @@ const getPropositions = (n, { answer, rand }) => {
118
323
  });
119
324
  return shuffle(propositions);
120
325
  };
121
- const isAnswerValid = (studentAns, { answer }) => {
122
- return rationalVEA(studentAns, answer, {
123
- allowNonIrreductible: true,
124
- allowDecimal: true,
125
- });
326
+ const getQuestionFromIdentifiers = (identifiers) => {
327
+ const question = {
328
+ instruction: getInstruction(identifiers),
329
+ hint: getHint(identifiers),
330
+ correction: getCorrection(identifiers),
331
+ answer: getAnswer(identifiers),
332
+ keys: [],
333
+ answerFormat: "tex",
334
+ identifiers,
335
+ };
336
+ return question;
126
337
  };
127
338
  export const mentalPercentage = {
128
339
  id: "mentalPercentage",
@@ -136,4 +347,7 @@ export const mentalPercentage = {
136
347
  isAnswerValid,
137
348
  subject: "Mathématiques",
138
349
  getQuestionFromIdentifiers,
350
+ getHint,
351
+ getCorrection,
352
+ hasHintAndCorrection: true,
139
353
  };
@@ -1 +1 @@
1
- {"version":3,"file":"operationsPriorities.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPriorities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEtB,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAC;AAwJF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAYtD,CAAC"}
1
+ {"version":3,"file":"operationsPriorities.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPriorities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEtB,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAC;AAkLF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAetD,CAAC"}
@@ -14,8 +14,10 @@ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
14
14
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
15
15
  import { DivideNode } from "../../../../tree/nodes/operators/divideNode.js";
16
16
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
17
+ import { NodeSimplifier } from "../../../../tree/utilities/nodeSimplifier.js";
17
18
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
18
19
  import { shuffle } from "../../../../utils/alea/shuffle.js";
20
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
19
21
  const getStartStatement = (identifiers) => {
20
22
  const { statementIds } = identifiers;
21
23
  return reifyAlgebraic(statementIds).toTex();
@@ -31,16 +33,37 @@ const getAnswer = (identifiers) => {
31
33
  const { statementIds } = identifiers;
32
34
  return reifyAlgebraic(statementIds).simplify().toTex();
33
35
  };
34
- const getQuestionFromIdentifiers = (identifiers) => {
35
- const question = {
36
- instruction: getInstruction(identifiers),
37
- startStatement: getStartStatement(identifiers),
38
- answer: getAnswer(identifiers),
39
- keys: [],
40
- answerFormat: "tex",
41
- identifiers,
42
- };
43
- return question;
36
+ const getHint = () => {
37
+ return `Tu peux retenir le moyen mnémotechnique "PEMDAS" pour retenir l'ordre dans lequel effectuer les calculs :
38
+ - Parenthèses
39
+ - Multiplications
40
+ - Divisions
41
+ - Additions
42
+ - Soustractions
43
+ `;
44
+ };
45
+ const getCorrection = (identifiers) => {
46
+ const node = reifyAlgebraic(identifiers.statementIds);
47
+ const arrTexNodeStepByStep = NodeSimplifier.arrTexStepByStep(node);
48
+ return `
49
+
50
+ ${alignTex([
51
+ [node.toTex(), "=", arrTexNodeStepByStep[0]],
52
+ ...arrTexNodeStepByStep.slice(1).map((tex) => ["", "=", tex]),
53
+ ])}
54
+
55
+ `;
56
+ };
57
+ const getPropositions = (n, { answer }) => {
58
+ const propositions = [];
59
+ addValidProp(propositions, answer);
60
+ propWhile(propositions, n, () => {
61
+ tryToAddWrongProp(propositions, randint(-100, 100) + "");
62
+ });
63
+ return shuffle(propositions);
64
+ };
65
+ const isAnswerValid = (ans, { answer }) => {
66
+ return numberVEA(ans, answer);
44
67
  };
45
68
  const getPriorityQuestions = () => {
46
69
  const type = randint(1, 9);
@@ -111,16 +134,18 @@ const getPriorityQuestions = () => {
111
134
  };
112
135
  return getQuestionFromIdentifiers(identifiers);
113
136
  };
114
- const getPropositions = (n, { answer }) => {
115
- const propositions = [];
116
- addValidProp(propositions, answer);
117
- propWhile(propositions, n, () => {
118
- tryToAddWrongProp(propositions, randint(-100, 100) + "");
119
- });
120
- return shuffle(propositions);
121
- };
122
- const isAnswerValid = (ans, { answer }) => {
123
- return numberVEA(ans, answer);
137
+ const getQuestionFromIdentifiers = (identifiers) => {
138
+ const question = {
139
+ instruction: getInstruction(identifiers),
140
+ startStatement: getStartStatement(identifiers),
141
+ answer: getAnswer(identifiers),
142
+ keys: [],
143
+ answerFormat: "tex",
144
+ identifiers,
145
+ hint: getHint(identifiers),
146
+ correction: getCorrection(identifiers),
147
+ };
148
+ return question;
124
149
  };
125
150
  export const operationsPriorities = {
126
151
  id: "operationsPriorities",
@@ -134,4 +159,7 @@ export const operationsPriorities = {
134
159
  isAnswerValid,
135
160
  subject: "Mathématiques",
136
161
  getQuestionFromIdentifiers,
162
+ getHint,
163
+ getCorrection,
164
+ hasHintAndCorrection: true,
137
165
  };
@@ -1 +1 @@
1
- {"version":3,"file":"operationsPrioritiesParenthesis.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesParenthesis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAkIF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"operationsPrioritiesParenthesis.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesParenthesis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAS7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA4JF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAgBjE,CAAC"}
@@ -6,7 +6,9 @@ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
6
  import { DivideNode } from "../../../../tree/nodes/operators/divideNode.js";
7
7
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
9
+ import { NodeSimplifier } from "../../../../tree/utilities/nodeSimplifier.js";
9
10
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
10
12
  const getInstruction = (identifiers) => {
11
13
  const statement = reifyAlgebraic(identifiers.nodeIds);
12
14
  return `Calculer :
@@ -19,15 +21,37 @@ const getAnswer = (identifiers) => {
19
21
  const statement = reifyAlgebraic(identifiers.nodeIds);
20
22
  return statement.simplify().toTex();
21
23
  };
22
- const getQuestionFromIdentifiers = (identifiers) => {
23
- const question = {
24
- answer: getAnswer(identifiers),
25
- instruction: getInstruction(identifiers),
26
- keys: [],
27
- answerFormat: "tex",
28
- identifiers,
29
- };
30
- return question;
24
+ const getHint = () => {
25
+ return `Tu peux retenir le moyen mnémotechnique "PEMDAS" pour retenir l'ordre dans lequel effectuer les calculs :
26
+ - Parenthèses
27
+ - Multiplications
28
+ - Divisions
29
+ - Additions
30
+ - Soustractions
31
+ `;
32
+ };
33
+ const getCorrection = (identifiers) => {
34
+ const node = reifyAlgebraic(identifiers.nodeIds);
35
+ const arrTexNodeStepByStep = NodeSimplifier.arrTexStepByStep(node);
36
+ return `
37
+
38
+ ${alignTex([
39
+ [node.toTex(), "=", arrTexNodeStepByStep[0]],
40
+ ...arrTexNodeStepByStep.slice(1).map((tex) => ["", "=", tex]),
41
+ ])}
42
+
43
+ `;
44
+ };
45
+ const getPropositions = (n, { answer }) => {
46
+ const propositions = [];
47
+ addValidProp(propositions, answer);
48
+ propWhile(propositions, n, () => {
49
+ tryToAddWrongProp(propositions, randint(-100, 100) + "");
50
+ });
51
+ return shuffleProps(propositions, n);
52
+ };
53
+ const isAnswerValid = (ans, { answer }) => {
54
+ return ans === answer;
31
55
  };
32
56
  const getOperationsPrioritiesParenthesisQuestion = () => {
33
57
  const type = randint(1, 5);
@@ -93,16 +117,17 @@ const getOperationsPrioritiesParenthesisQuestion = () => {
93
117
  const identifiers = { nodeIds: statement.toIdentifiers(), type };
94
118
  return getQuestionFromIdentifiers(identifiers);
95
119
  };
96
- const getPropositions = (n, { answer }) => {
97
- const propositions = [];
98
- addValidProp(propositions, answer);
99
- propWhile(propositions, n, () => {
100
- tryToAddWrongProp(propositions, randint(-100, 100) + "");
101
- });
102
- return shuffleProps(propositions, n);
103
- };
104
- const isAnswerValid = (ans, { answer }) => {
105
- return ans === answer;
120
+ const getQuestionFromIdentifiers = (identifiers) => {
121
+ const question = {
122
+ answer: getAnswer(identifiers),
123
+ instruction: getInstruction(identifiers),
124
+ keys: [],
125
+ answerFormat: "tex",
126
+ identifiers,
127
+ hint: getHint(identifiers),
128
+ correction: getCorrection(identifiers),
129
+ };
130
+ return question;
106
131
  };
107
132
  export const operationsPrioritiesParenthesis = {
108
133
  id: "operationsPrioritiesParenthesis",
@@ -116,4 +141,7 @@ export const operationsPrioritiesParenthesis = {
116
141
  isAnswerValid,
117
142
  getQuestionFromIdentifiers,
118
143
  subject: "Mathématiques",
144
+ getHint,
145
+ getCorrection,
146
+ hasHintAndCorrection: true,
119
147
  };
@@ -1 +1 @@
1
- {"version":3,"file":"findCoeffInProportionalTableNonIntegers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAS7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA+HF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAoBF,eAAO,MAAM,uCAAuC,EAAE,QAAQ,CAC5D,WAAW,EACX,OAAO,CAsBR,CAAC"}
1
+ {"version":3,"file":"findCoeffInProportionalTableNonIntegers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAuJF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAoBF,eAAO,MAAM,uCAAuC,EAAE,QAAQ,CAC5D,WAAW,EACX,OAAO,CAuBR,CAAC"}