math-exercises 3.0.37 → 3.0.39

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 (100) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts +4 -1
  2. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +71 -16
  4. package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/simplifyFraction.js +37 -0
  6. package/lib/exercises/math/calcul/rounding/rounding.d.ts +8 -5
  7. package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/rounding/rounding.js +63 -31
  9. package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.js +64 -57
  11. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.d.ts.map +1 -1
  12. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.js +48 -5
  13. package/lib/exercises/math/functions/affines/leadingCoefficient.d.ts.map +1 -1
  14. package/lib/exercises/math/functions/affines/leadingCoefficient.js +42 -4
  15. package/lib/exercises/math/functions/integral/integralAffines.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/integral/integralAffines.js +31 -15
  17. package/lib/exercises/math/functions/integral/integralTrinomials.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/integral/integralTrinomials.js +31 -16
  19. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.d.ts.map +1 -1
  20. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.js +49 -0
  21. package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.js +1 -1
  22. package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.js +1 -1
  23. package/lib/exercises/math/functions/trinoms/roots/rootsProduct.js +1 -1
  24. package/lib/exercises/math/functions/trinoms/roots/rootsSum.js +1 -1
  25. package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.d.ts.map +1 -1
  26. package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.js +66 -18
  27. package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
  28. package/lib/exercises/math/geometry/cartesian/midpoint.js +45 -3
  29. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
  30. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +1 -2
  31. package/lib/exercises/math/geometry/perimeters/rectanglePerimeter.d.ts.map +1 -1
  32. package/lib/exercises/math/geometry/perimeters/rectanglePerimeter.js +0 -2
  33. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +1 -1
  34. package/lib/exercises/math/geometry/thales/thalesCalcul.js +1 -1
  35. package/lib/exercises/math/geometry/vectors/chasles.d.ts.map +1 -1
  36. package/lib/exercises/math/geometry/vectors/chasles.js +0 -2
  37. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCoords.d.ts.map +1 -1
  38. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCoords.js +68 -15
  39. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.d.ts +1 -0
  40. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.d.ts.map +1 -1
  41. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.js +32 -14
  42. package/lib/exercises/math/probaStat/diceBasicProbas.js +1 -1
  43. package/lib/exercises/math/sequences/arithmetic/arithmeticFindReason.d.ts.map +1 -1
  44. package/lib/exercises/math/sequences/arithmetic/arithmeticFindReason.js +43 -8
  45. package/lib/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.d.ts.map +1 -1
  46. package/lib/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.js +0 -2
  47. package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.d.ts.map +1 -1
  48. package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.js +51 -8
  49. package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.d.ts.map +1 -1
  50. package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.js +36 -5
  51. package/lib/exercises/math/sequences/geometric/geometricRecognizeReasonFromFirstTerms.d.ts.map +1 -1
  52. package/lib/exercises/math/sequences/geometric/geometricRecognizeReasonFromFirstTerms.js +36 -5
  53. package/lib/exercises/math/trigonometry/associatePoint.d.ts.map +1 -1
  54. package/lib/exercises/math/trigonometry/associatePoint.js +5 -2
  55. package/lib/exercises/math/trigonometry/mainRemarkableValues.js +1 -1
  56. package/lib/exercises/math/trigonometry/remarkableValues.js +2 -2
  57. package/lib/geogebra/geogebraConstructor.d.ts +3 -1
  58. package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
  59. package/lib/geogebra/geogebraConstructor.js +5 -2
  60. package/lib/index.d.ts +8 -2
  61. package/lib/index.d.ts.map +1 -1
  62. package/lib/latexTester.js +1 -0
  63. package/lib/math/geometry/point.d.ts +2 -0
  64. package/lib/math/geometry/point.d.ts.map +1 -1
  65. package/lib/math/geometry/point.js +10 -0
  66. package/lib/math/numbers/integer/integer.d.ts +1 -1
  67. package/lib/math/numbers/rationals/rational.d.ts +1 -0
  68. package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
  69. package/lib/math/numbers/rationals/rational.js +3 -0
  70. package/lib/math/trigonometry/remarkableValue.d.ts +1 -4
  71. package/lib/math/trigonometry/remarkableValue.d.ts.map +1 -1
  72. package/lib/math/trigonometry/remarkableValue.js +5 -6
  73. package/lib/math/utils/stats/generateAffineCloud.js +1 -1
  74. package/lib/playground.d.ts.map +1 -1
  75. package/lib/playground.js +5 -0
  76. package/lib/tests/pdfExo.test.d.ts.map +1 -1
  77. package/lib/tests/pdfExo.test.js +2 -2
  78. package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -2
  79. package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
  80. package/lib/tree/nodes/functions/sqrtNode.d.ts +2 -1
  81. package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
  82. package/lib/tree/nodes/functions/sqrtNode.js +47 -2
  83. package/lib/tree/nodes/node.d.ts +1 -0
  84. package/lib/tree/nodes/node.d.ts.map +1 -1
  85. package/lib/tree/nodes/numbers/numberNode.d.ts +1 -1
  86. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  87. package/lib/tree/nodes/numbers/numberNode.js +1 -1
  88. package/lib/tree/nodes/operators/addNode.d.ts +1 -0
  89. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  90. package/lib/tree/nodes/operators/addNode.js +6 -0
  91. package/lib/tree/nodes/operators/fractionNode.d.ts +1 -1
  92. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  93. package/lib/tree/nodes/operators/fractionNode.js +1 -1
  94. package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -0
  95. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  96. package/lib/tree/nodes/operators/multiplyNode.js +7 -0
  97. package/lib/utils/iterators/dualReturn.d.ts +2 -0
  98. package/lib/utils/iterators/dualReturn.d.ts.map +1 -0
  99. package/lib/utils/iterators/dualReturn.js +19 -0
  100. package/package.json +1 -1
@@ -5,6 +5,9 @@ type Identifiers = {
5
5
  denom1: number;
6
6
  denom2: number;
7
7
  };
8
- export declare const fractionsSumsMultiplesDenominators: Exercise<Identifiers>;
8
+ type Options = {
9
+ allowNonIrreductible?: boolean;
10
+ };
11
+ export declare const fractionsSumsMultiplesDenominators: Exercise<Identifiers, Options>;
9
12
  export {};
10
13
  //# sourceMappingURL=fractionsSumsMultiplesDenominators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsSumsMultiplesDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA2FF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAkBpE,CAAC"}
1
+ {"version":3,"file":"fractionsSumsMultiplesDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AA2JF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,WAAW,EACX,OAAO,CAsBR,CAAC"}
@@ -2,10 +2,69 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionTarget, G
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
- import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
5
+ import { round } from "../../../../math/utils/round.js";
6
+ import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
6
9
  import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
7
10
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
8
11
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
13
+ const getInstruction = (identifiers, opts) => {
14
+ const { num1, num2, denom1, denom2 } = identifiers;
15
+ const ratio1 = new Rational(num1, denom1);
16
+ const ratio2 = new Rational(num2, denom2);
17
+ const statement = new AddNode(ratio1.toTree(), ratio2.toTree()).toTex();
18
+ return `Calculer ${opts?.allowNonIrreductible
19
+ ? ""
20
+ : "et donner le résultat sous la forme la plus simplifiée possible"} :
21
+
22
+ $$
23
+ ${statement}
24
+ $$`;
25
+ };
26
+ const getAnswer = (identifiers) => {
27
+ const { num1, num2, denom1, denom2 } = identifiers;
28
+ const ratio1 = new Rational(num1, denom1);
29
+ const ratio2 = new Rational(num2, denom2);
30
+ const answer = ratio1.add(ratio2).toTree().toTex();
31
+ return answer;
32
+ };
33
+ const getHint = (identifiers) => {
34
+ const { num1, num2, denom1, denom2 } = identifiers;
35
+ return `Pour additionner deux fractions, il faut les réduire au même dénominateur. Quel est le plus petit multiple commun entre $${denom1}$ et $${denom2}$ ?`;
36
+ };
37
+ const getCorrection = (identifiers) => {
38
+ const { num1, num2, denom1, denom2 } = identifiers;
39
+ const orderedDenums = [denom1, denom2].sort((a, b) => a - b);
40
+ const orderedNums = denom1 > denom2 ? [num2, num1] : [num1, num2];
41
+ const coeff = round(orderedDenums[1] / orderedDenums[0], 0);
42
+ return `Pour additionner deux fractions, il faut les réduire au même dénominateur.
43
+
44
+ Puisque $${orderedDenums[0]}\\times ${coeff} = ${orderedDenums[1]}$, on peut mettre la fraction $${frac(orderedNums[0], orderedDenums[0]).toTex()}$ sur $${orderedDenums[1]}$ :
45
+
46
+ $$
47
+ ${multiply(frac(orderedNums[0], orderedDenums[0]), frac(coeff, coeff)).toTex()} = ${frac(orderedNums[0] * coeff, orderedDenums[1]).toTex()}
48
+ $$
49
+
50
+ On peut alors additionner les deux fractions :
51
+
52
+ ${alignTex([
53
+ ["", add(frac(num1, denom1), frac(num2, denom2)).toTex()],
54
+ [
55
+ "=",
56
+ add(denom1 > denom2
57
+ ? frac(num1, denom1)
58
+ : frac(orderedNums[0] * coeff, orderedDenums[1]), denom1 > denom2
59
+ ? frac(orderedNums[0] * coeff, orderedDenums[1])
60
+ : frac(num2, denom2)).toTex(),
61
+ ],
62
+ [
63
+ "=",
64
+ frac(orderedNums[0] * coeff + orderedNums[1], orderedDenums[1]).toSimplificationTex(),
65
+ ],
66
+ ])}`;
67
+ };
9
68
  const getFractionsSumsMultiplesDenominatorsQuestion = (opts) => {
10
69
  let denom1 = randint(2, 10);
11
70
  let denom2 = denom1 * randint(2, 10);
@@ -13,22 +72,15 @@ const getFractionsSumsMultiplesDenominatorsQuestion = (opts) => {
13
72
  [denom1, denom2] = [denom2, denom1];
14
73
  const num1 = randint(1, 10, [denom1]);
15
74
  const num2 = randint(1, 10, [denom2]);
16
- const ratio1 = new Rational(num1, denom1);
17
- const ratio2 = new Rational(num2, denom2);
18
- const statement = new AddNode(ratio1.toTree(), ratio2.toTree()).toTex();
19
- const answer = ratio1.add(ratio2).toTree().toTex();
75
+ const identifiers = { num1, num2, denom1, denom2 };
20
76
  const question = {
21
- answer,
22
- instruction: `Calculer ${opts?.allowNonIrreductible
23
- ? ""
24
- : "et donner le résultat sous la forme la plus simplifiée possible"} :
25
-
26
- $$
27
- ${statement}
28
- $$`,
77
+ answer: getAnswer(identifiers, opts),
78
+ instruction: getInstruction(identifiers, opts),
29
79
  keys: [],
30
80
  answerFormat: "tex",
31
- identifiers: { num1, num2, denom1, denom2 },
81
+ identifiers,
82
+ hint: getHint(identifiers, opts),
83
+ correction: getCorrection(identifiers, opts),
32
84
  };
33
85
  return question;
34
86
  };
@@ -74,9 +126,7 @@ export const fractionsSumsMultiplesDenominators = {
74
126
  id: "fractionsSumsMultiplesDenominators",
75
127
  connector: "=",
76
128
  label: "Sommes de fractions (avec dénominateurs multiples l'un de l'autre)",
77
- levels: [],
78
129
  isSingleStep: true,
79
- sections: [],
80
130
  generator: (nb, opts) => getDistinctQuestions(() => getFractionsSumsMultiplesDenominatorsQuestion(opts), nb),
81
131
  qcmTimer: 60,
82
132
  freeTimer: 60,
@@ -84,4 +134,9 @@ export const fractionsSumsMultiplesDenominators = {
84
134
  isAnswerValid,
85
135
  subject: "Mathématiques",
86
136
  options,
137
+ getInstruction,
138
+ getAnswer,
139
+ getHint,
140
+ getCorrection,
141
+ hasHintAndCorrection: true,
87
142
  };
@@ -1 +1 @@
1
- {"version":3,"file":"simplifyFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/simplifyFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAgEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAWlD,CAAC"}
1
+ {"version":3,"file":"simplifyFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/simplifyFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAgGF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAgBlD,CAAC"}
@@ -1,7 +1,11 @@
1
1
  import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
+ import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
5
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
4
7
  import { shuffle } from "../../../../utils/alea/shuffle.js";
8
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
5
9
  const getStatementNode = (identifiers) => {
6
10
  const { num, denum } = identifiers;
7
11
  const rational = new Rational(num, denum).toTree();
@@ -24,6 +28,32 @@ const getAnswer = (identifiers) => {
24
28
  const answer = rational.simplify().toTree().toTex();
25
29
  return answer;
26
30
  };
31
+ const getHint = (identifiers) => {
32
+ return `Détermine le plus grand diviseur commun à $${identifiers.num}$ et $${identifiers.denum}$.
33
+
34
+ On peut alors simpfier la fraction par ce nombre.`;
35
+ };
36
+ const getCorrection = (identifiers) => {
37
+ const { num, denum } = identifiers;
38
+ const pgcd = gcd(num, denum);
39
+ const numDiv = num / pgcd;
40
+ const denumDiv = denum / pgcd;
41
+ return `Le plus grand diviseur commun à $${num}$ et $${denum}$ est $${pgcd}$.
42
+
43
+ En effet, on a $${num} = ${numDiv} \\times ${pgcd}$ et $${denum} = ${denumDiv} \\times ${pgcd}$.
44
+
45
+ On peut donc simplfier la fraction par $${pgcd}$ :
46
+
47
+ ${alignTex([
48
+ [
49
+ frac(num, denum).toTex(),
50
+ "=",
51
+ frac(multiply(numDiv, pgcd.toTree({ toTexOptions: { cancel: true } })), multiply(denumDiv, pgcd.toTree({ toTexOptions: { cancel: true } }))).toTex(),
52
+ ],
53
+ ["", "=", getAnswer(identifiers)],
54
+ ])}
55
+ `;
56
+ };
27
57
  const getSimplifyFraction = () => {
28
58
  const rational = RationalConstructor.randomSimplifiable(10);
29
59
  const identifiers = { num: rational.num, denum: rational.denum };
@@ -34,6 +64,8 @@ const getSimplifyFraction = () => {
34
64
  keys: [],
35
65
  answerFormat: "tex",
36
66
  identifiers,
67
+ hint: getHint(identifiers),
68
+ correction: getCorrection(identifiers),
37
69
  };
38
70
  return question;
39
71
  };
@@ -65,4 +97,9 @@ export const simplifyFraction = {
65
97
  getPropositions,
66
98
  isAnswerValid,
67
99
  subject: "Mathématiques",
100
+ getAnswer,
101
+ getInstruction,
102
+ getCorrection,
103
+ getHint,
104
+ hasHintAndCorrection: true,
68
105
  };
@@ -1,22 +1,25 @@
1
1
  import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Options = {
3
+ precisionAsked: number;
4
+ };
2
5
  type Identifiers = {
3
6
  precisionAsked: number;
4
7
  decimal: number;
5
8
  precision: number;
6
9
  };
7
- export declare const roundToUnit: Exercise<Identifiers>;
10
+ export declare const roundToUnit: Exercise<Identifiers, Options>;
8
11
  /**
9
12
  * arrondi à l'unité
10
13
  */
11
- export declare const roundToDixieme: Exercise<Identifiers>;
14
+ export declare const roundToDixieme: Exercise<Identifiers, Options>;
12
15
  /**
13
16
  * arrondi à l'unité
14
17
  */
15
- export declare const roundToCentieme: Exercise<Identifiers>;
18
+ export declare const roundToCentieme: Exercise<Identifiers, Options>;
16
19
  /**
17
20
  * arrondi à l'unité
18
21
  */
19
- export declare const roundToMillieme: Exercise<Identifiers>;
20
- export declare const allRoundings: Exercise<Identifiers>;
22
+ export declare const roundToMillieme: Exercise<Identifiers, Options>;
23
+ export declare const allRoundings: Exercise<Identifiers, Options>;
21
24
  export {};
22
25
  //# sourceMappingURL=rounding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rounding.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/rounding/rounding.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AA6ErC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAgDF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAe7C,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAehD,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAkB9C,CAAC"}
1
+ {"version":3,"file":"rounding.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/rounding/rounding.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AACF,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4HF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBtD,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBzD,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB1D,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB1D,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBvD,CAAC"}
@@ -16,39 +16,61 @@ const instructions = [
16
16
  "Arrondir au centième :",
17
17
  "Arrondir au millième :",
18
18
  ];
19
- const getRoundQuestions = (opts) => {
20
- 244.8895;
21
- const precisionAsked = opts?.precisionAsked || 0;
22
- const precision = randint(precisionAsked + 1, precisionAsked + 5);
23
- const dec = DecimalConstructor.random(0, 1000, precision);
19
+ const getInstruction = (identifiers, opts) => {
20
+ const { precisionAsked } = identifiers;
21
+ const dec = new Decimal(identifiers.decimal);
24
22
  const decTex = dec.toTree().toTex();
23
+ return `${instructions[precisionAsked]} $${decTex}$`;
24
+ };
25
+ const getAnswer = (identifiers, opts) => {
26
+ const { precisionAsked } = identifiers;
27
+ const dec = new Decimal(identifiers.decimal);
25
28
  const answer = dec.round(precisionAsked).toTree().toTex();
29
+ return answer;
30
+ };
31
+ const getHint = (identifiers, opts) => {
32
+ const { precisionAsked } = identifiers;
33
+ return `Pour arrondir ${ranksWithAu[precisionAsked]}, on regarde le chiffre des ${ranks[precisionAsked + 1]}s. S'il est inférieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} inférieur. S'il est supérieur ou égal à $5$, on arrondit ${ranksWithAu[precisionAsked]} supérieur.`;
34
+ };
35
+ const getCorrection = (identifiers, opts) => {
36
+ const { precisionAsked } = identifiers;
37
+ const dec = new Decimal(identifiers.decimal);
38
+ const decTex = dec.toTree().toTex();
39
+ const answer = getAnswer(identifiers, opts);
26
40
  const figureToLookAt = dec.getDigitAtRank(-(precisionAsked + 1));
27
- const question = {
28
- instruction: `${instructions[precisionAsked]} $${decTex}$`,
29
- startStatement: decTex,
30
- answer,
31
- keys: [],
32
- answerFormat: "tex",
33
- identifiers: {
34
- precisionAsked,
35
- decimal: dec.value,
36
- precision,
37
- },
38
- hint: `Pour arrondir ${ranksWithAu[precisionAsked]}, on regarde le chiffre des ${ranks[precisionAsked + 1]}s. S'il est inférieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} inférieur. S'il est supérieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} supérieur.`,
39
- correction: `Le chiffre des ${ranks[precisionAsked + 1]}s est $${figureToLookAt}$.
41
+ return `Le chiffre des ${ranks[precisionAsked + 1]}s est $${figureToLookAt}$.
40
42
 
41
43
  ${figureToLookAt < 5
42
- ? `Puisque $${figureToLookAt}$ est inférieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} inférieur.
44
+ ? `Puisque $${figureToLookAt}$ est inférieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} inférieur.
43
45
 
44
46
  Ainsi, en arrondissant ${ranksWithAu[precisionAsked]}, on a $${decTex} \\approx ${answer}$`
45
- : `Puisque $${figureToLookAt}$ est supérieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} supérieur.
47
+ : `Puisque $${figureToLookAt}$ est supérieur ou égal à $5$, on arrondit ${ranksWithAu[precisionAsked]} supérieur.
46
48
 
47
49
  Ainsi, en arrondissant ${ranksWithAu[precisionAsked]}, on a
48
50
 
49
51
  $$
50
52
  ${decTex} \\approx ${answer}
51
- $$`}`,
53
+ $$`}`;
54
+ };
55
+ const getRoundQuestions = (opts) => {
56
+ const precisionAsked = opts?.precisionAsked || 0;
57
+ const precision = randint(precisionAsked + 1, precisionAsked + 5);
58
+ const dec = DecimalConstructor.random(0, 1000, precision);
59
+ const decTex = dec.toTree().toTex();
60
+ const identifiers = {
61
+ precisionAsked,
62
+ decimal: dec.value,
63
+ precision,
64
+ };
65
+ const question = {
66
+ instruction: getInstruction(identifiers, opts),
67
+ startStatement: decTex,
68
+ answer: getAnswer(identifiers, opts),
69
+ keys: [],
70
+ answerFormat: "tex",
71
+ identifiers,
72
+ hint: getHint(identifiers, opts),
73
+ correction: getCorrection(identifiers, opts),
52
74
  };
53
75
  return question;
54
76
  };
@@ -82,8 +104,6 @@ export const roundToUnit = {
82
104
  id: "roundToUnit",
83
105
  connector: "\\approx",
84
106
  label: "Arrondir à l'unité",
85
- levels: ["6ème", "5ème", "CAP", "2ndPro", "1rePro"],
86
- sections: ["Calculs"],
87
107
  isSingleStep: true,
88
108
  generator: (nb) => getDistinctQuestions(() => getRoundQuestions({ precisionAsked: 0 }), nb),
89
109
  qcmTimer: 60,
@@ -92,6 +112,10 @@ export const roundToUnit = {
92
112
  isAnswerValid,
93
113
  subject: "Mathématiques",
94
114
  hasHintAndCorrection: true,
115
+ getInstruction,
116
+ getAnswer,
117
+ getCorrection,
118
+ getHint,
95
119
  };
96
120
  /**
97
121
  * arrondi à l'unité
@@ -100,8 +124,6 @@ export const roundToDixieme = {
100
124
  id: "roundToDixieme",
101
125
  connector: "\\approx",
102
126
  label: "Arrondir au dixième",
103
- levels: ["6ème", "5ème", "CAP", "2ndPro", "1rePro"],
104
- sections: ["Calculs"],
105
127
  isSingleStep: true,
106
128
  generator: (nb) => getDistinctQuestions(() => getRoundQuestions({ precisionAsked: 1 }), nb),
107
129
  qcmTimer: 60,
@@ -110,6 +132,10 @@ export const roundToDixieme = {
110
132
  isAnswerValid,
111
133
  subject: "Mathématiques",
112
134
  hasHintAndCorrection: true,
135
+ getInstruction,
136
+ getAnswer,
137
+ getCorrection,
138
+ getHint,
113
139
  };
114
140
  /**
115
141
  * arrondi à l'unité
@@ -118,8 +144,6 @@ export const roundToCentieme = {
118
144
  id: "roundToCentieme",
119
145
  connector: "\\approx",
120
146
  label: "Arrondir au centième",
121
- levels: ["6ème", "5ème", "CAP", "2ndPro", "1rePro"],
122
- sections: ["Calculs"],
123
147
  isSingleStep: true,
124
148
  generator: (nb) => getDistinctQuestions(() => getRoundQuestions({ precisionAsked: 2 }), nb),
125
149
  qcmTimer: 60,
@@ -128,6 +152,10 @@ export const roundToCentieme = {
128
152
  isAnswerValid,
129
153
  subject: "Mathématiques",
130
154
  hasHintAndCorrection: true,
155
+ getInstruction,
156
+ getAnswer,
157
+ getCorrection,
158
+ getHint,
131
159
  };
132
160
  /**
133
161
  * arrondi à l'unité
@@ -136,8 +164,6 @@ export const roundToMillieme = {
136
164
  id: "roundToMillieme",
137
165
  connector: "\\approx",
138
166
  label: "Arrondir au millième",
139
- levels: ["6ème", "5ème", "CAP", "2ndPro", "1rePro"],
140
- sections: ["Calculs"],
141
167
  isSingleStep: true,
142
168
  generator: (nb) => getDistinctQuestions(() => getRoundQuestions({ precisionAsked: 3 }), nb),
143
169
  qcmTimer: 60,
@@ -146,13 +172,15 @@ export const roundToMillieme = {
146
172
  isAnswerValid,
147
173
  subject: "Mathématiques",
148
174
  hasHintAndCorrection: true,
175
+ getInstruction,
176
+ getAnswer,
177
+ getCorrection,
178
+ getHint,
149
179
  };
150
180
  export const allRoundings = {
151
181
  id: "allRoundings",
152
182
  connector: "\\approx",
153
183
  label: "Arrondir un nombre décimal",
154
- levels: ["6ème", "5ème", "CAP", "2ndPro", "1rePro"],
155
- sections: ["Calculs"],
156
184
  isSingleStep: true,
157
185
  generator: (nb) => getDistinctQuestions(() => getRoundQuestions({ precisionAsked: randint(0, 4) }), nb),
158
186
  qcmTimer: 60,
@@ -161,4 +189,8 @@ export const allRoundings = {
161
189
  isAnswerValid,
162
190
  subject: "Mathématiques",
163
191
  hasHintAndCorrection: true,
192
+ getInstruction,
193
+ getAnswer,
194
+ getCorrection,
195
+ getHint,
164
196
  };
@@ -1 +1 @@
1
- {"version":3,"file":"reduceExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/simplifying/reduceExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IAOjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IAGnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAqNF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}
1
+ {"version":3,"file":"reduceExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/simplifying/reduceExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IAOjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IAGnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAqOF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAkBlD,CAAC"}
@@ -6,11 +6,13 @@ import { randint } from "../../../../math/utils/random/randint.js";
6
6
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
7
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  import { square } from "../../../../tree/nodes/operators/powerNode.js";
9
+ import { monom } from "../../../../tree/nodes/polynomials/monomNode.js";
9
10
  import { polynomialParser } from "../../../../tree/parsers/polynomialParser.js";
10
11
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
11
12
  import { random } from "../../../../utils/alea/random.js";
12
13
  import { shuffle } from "../../../../utils/alea/shuffle.js";
13
14
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
15
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
14
16
  const rebuildIdentifiers = (oldids) => {
15
17
  if (oldids.variable)
16
18
  return oldids;
@@ -38,11 +40,7 @@ const getStatementNode = (identifiers) => {
38
40
  return multiply(c, square(variable));
39
41
  }));
40
42
  const shuffled = order.map((i) => nodes[i]);
41
- // const polynome1 = new Polynomial(polynome1Coeffs, variable);
42
- // const polynome2 = new Polynomial(polynome2Coeffs, variable);
43
43
  return operatorComposition(AddNode, shuffled);
44
- // const statement = new AddNode(polynome1.toTree(), polynome2.toTree());
45
- // return statement.deepShuffle({ nodeIdsToShuffle: [OperatorIds.add] });
46
44
  };
47
45
  const getStartStatement = (identifiers) => {
48
46
  return getStatementNode(identifiers).toTex();
@@ -63,6 +61,63 @@ $$
63
61
  ${getStartStatement(identifiers)}
64
62
  $$`;
65
63
  };
64
+ const getHint = (identifiers) => {
65
+ const { coeffs, order, variable } = identifiers;
66
+ return `Additionne les termes en $${variable}^2$ entre eux, puis les termes en $${variable}$ entre eux, et enfin les nombres entre eux.`;
67
+ };
68
+ const getCorrection = (identifiers) => {
69
+ const { coeffs, order, variable } = identifiers;
70
+ const x2Count = coeffs[2].length;
71
+ const xCount = coeffs[1].length;
72
+ const nbCount = coeffs[0].length;
73
+ const xSimp = xCount === 0
74
+ ? ""
75
+ : xCount === 1
76
+ ? `$${monom(coeffs[1][0], 1, {
77
+ variable,
78
+ }).toTex()}$ est le seul terme en $${variable}$, on ne peut donc l'additionner avec aucun autre terme.`
79
+ : `On additionne les $${xCount}$ termes en $${variable}$ :
80
+
81
+ $$
82
+ ${operatorComposition(AddNode, coeffs[1].map((c) => monom(c, 1, { variable }).toTree())).toSimplificationTex()}
83
+ $$`;
84
+ const x2Simp = x2Count === 0
85
+ ? ""
86
+ : x2Count === 1
87
+ ? `$${monom(coeffs[2][0], 2, {
88
+ variable,
89
+ }).toTex()}$ est le seul terme en $${square(variable).toTex()}$, on ne peut donc l'additionner avec aucun autre terme.`
90
+ : `On additionne les $${x2Count}$ termes en $${square(variable).toTex()}$ :
91
+
92
+ $$
93
+ ${operatorComposition(AddNode, coeffs[2].map((c) => monom(c, 2, { variable }).toTree())).toSimplificationTex()}
94
+ $$`;
95
+ const nbSimp = nbCount === 0
96
+ ? ""
97
+ : nbCount === 1
98
+ ? `$${coeffs[0][0]}$ est le seul nombre, on ne peut donc l'additionner avec aucun autre terme.`
99
+ : `On additionne les $${nbCount}$ nombres entre eux :
100
+
101
+ $$
102
+ ${operatorComposition(AddNode, coeffs[0].map((c) => c.toTree())).toSimplificationTex()}
103
+ $$`;
104
+ return `On additionne les termes en $${variable}^2$ entre eux, puis les termes en $${variable}$ entre eux, et enfin les nombres entre eux.
105
+
106
+ ${x2Count > 0 ? `- ${x2Simp}` : ""}
107
+
108
+ ${xCount > 0 ? `- ${xSimp}` : ""}
109
+
110
+ ${nbCount > 0 ? `- ${nbSimp}` : ""}
111
+
112
+
113
+ Ainsi, on obtient :
114
+
115
+ ${alignTex([
116
+ ["", getStartStatement(identifiers)],
117
+ ["=", getAnswer(identifiers)],
118
+ ])}
119
+ `;
120
+ };
66
121
  const getReduceExpression = () => {
67
122
  const rand = randint(0, 7);
68
123
  let polynome1;
@@ -83,59 +138,8 @@ const getReduceExpression = () => {
83
138
  }
84
139
  }
85
140
  const order = shuffle(Array.from({ length: nbTerms }, (_, i) => i));
86
- // switch (rand) {
87
- // case 0: // ax + b + cx + d
88
- // polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
89
- // polynome2 = new Polynomial([randint(-5, 6, [0]), randint(-5, 6, [0])]);
90
- // break;
91
- // case 1: //ax+b + cx
92
- // polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
93
- // polynome2 = new Polynomial([0, randint(-5, 6, [0])]);
94
- // break;
95
- // case 2: //ax+b+c
96
- // polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
97
- // polynome2 = new Polynomial([randint(-5, 6, [0])]);
98
- // break;
99
- // case 3: //ax^2+bx+c + ax^2+bx
100
- // polynome1 = new Polynomial([
101
- // randint(-9, 10),
102
- // randint(-9, 10),
103
- // randint(-9, 10, [0]),
104
- // ]);
105
- // polynome2 = new Polynomial([0, randint(-5, 6), randint(-5, 6, [0])]);
106
- // break;
107
- // case 4: //ax^2+bx+c + ax^2
108
- // polynome1 = new Polynomial([
109
- // randint(-9, 10),
110
- // randint(-9, 10),
111
- // randint(-9, 10, [0]),
112
- // ]);
113
- // polynome2 = new Polynomial([0, 0, randint(-5, 6, [0])]);
114
- // break;
115
- // case 5: //ax^2+bx+c + ax
116
- // polynome1 = new Polynomial([
117
- // randint(-9, 10),
118
- // randint(-9, 10),
119
- // randint(-9, 10, [0]),
120
- // ]);
121
- // polynome2 = new Polynomial([0, randint(-5, 6, [0])]);
122
- // break;
123
- // case 6: //ax^2 +bx+c + c
124
- // polynome1 = new Polynomial([
125
- // randint(-9, 10),
126
- // randint(-9, 10),
127
- // randint(-9, 10, [0]),
128
- // ]);
129
- // polynome2 = new Polynomial([randint(-5, 6, [0])]);
130
- // break;
131
- // default:
132
- // throw Error("something went wrong");
133
- // }
134
141
  const variable = random(["x", "n", "a", "y", "t"]);
135
142
  const identifiers = {
136
- // rand,
137
- // polynome1Coeffs: polynome1.coefficients,
138
- // polynome2Coeffs: polynome2.coefficients,
139
143
  coeffs,
140
144
  variable,
141
145
  order,
@@ -150,6 +154,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
150
154
  keys: [identifiers.variable],
151
155
  answerFormat: "tex",
152
156
  identifiers,
157
+ hint: getHint(identifiers),
158
+ correction: getCorrection(identifiers),
153
159
  };
154
160
  return question;
155
161
  };
@@ -196,8 +202,6 @@ export const reduceExpression = {
196
202
  connector: "=",
197
203
  isSingleStep: false,
198
204
  label: "Réduire une expression",
199
- levels: ["4ème", "3ème", "2nde", "CAP", "2ndPro"],
200
- sections: ["Calcul littéral"],
201
205
  generator: (nb) => getDistinctQuestions(getReduceExpression, nb),
202
206
  qcmTimer: 60,
203
207
  freeTimer: 60,
@@ -208,4 +212,7 @@ export const reduceExpression = {
208
212
  getAnswer,
209
213
  getInstruction,
210
214
  getQuestionFromIdentifiers,
215
+ getHint,
216
+ getCorrection,
217
+ hasHintAndCorrection: true,
211
218
  };
@@ -1 +1 @@
1
- {"version":3,"file":"algebricExpressionOfAffine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/algebricExpressionOfAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6DF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAa5D,CAAC"}
1
+ {"version":3,"file":"algebricExpressionOfAffine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/algebricExpressionOfAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqGF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAgB5D,CAAC"}