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
@@ -4,16 +4,56 @@ import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.j
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { polynomialParser } from "../../../../tree/parsers/polynomialParser.js";
6
6
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { a, b } = identifiers;
9
+ return `Soit une fonction affine $f$ dont le coefficient directeur vaut $${a}$ et l'ordonnée à l'origine vaut $${b}$.
10
+
11
+ Écrire l'expression algébrique de $f(x)$.`;
12
+ };
13
+ const getAnswer = (identifiers) => {
14
+ const f = new Affine(identifiers.a, identifiers.b);
15
+ return f.toTex();
16
+ };
17
+ const getHint = (identifiers) => {
18
+ return `L'expression algébrique d'une fonction affine est :
19
+
20
+ $$
21
+ f(x) = ax+b
22
+ $$
23
+
24
+ où $a$ est le coefficient directeur et $b$ l'ordonnée à l'origine.`;
25
+ };
26
+ const getCorrection = (identifiers) => {
27
+ const { a, b } = identifiers;
28
+ return `L'expression algébrique d'une fonction affine est :
29
+
30
+ $$
31
+ f(x) = ax+b
32
+ $$
33
+
34
+ où $a$ est le coefficient directeur et $b$ l'ordonnée à l'origine.
35
+
36
+ Ici, $a = ${a}$ et $b = ${b}$.
37
+
38
+ Donc, l'expression algébrique de $f$ est :
39
+
40
+ $$
41
+ f(x)=${getAnswer(identifiers)}
42
+ $$`;
43
+ };
7
44
  const getAlgebricExpressionOfAffineQuestion = () => {
8
45
  const f = AffineConstructor.random();
9
46
  const a = f.a;
10
47
  const b = f.b;
48
+ const identifiers = { a, b };
11
49
  const question = {
12
- answer: f.toTex(),
13
- instruction: `Soit une fonction affine $f$ dont le coefficient directeur vaut $${a}$ et l'ordonnée à l'origine vaut $${b}$. Écrire l'expression algébrique de $f(x)$.`,
50
+ answer: getAnswer(identifiers),
51
+ instruction: getInstruction(identifiers),
14
52
  keys: ["x"],
15
53
  answerFormat: "tex",
16
- identifiers: { a, b },
54
+ identifiers,
55
+ hint: getHint(identifiers),
56
+ correction: getCorrection(identifiers),
17
57
  };
18
58
  return question;
19
59
  };
@@ -52,13 +92,16 @@ const generatePropositions = (a, b) => {
52
92
  export const algebricExpressionOfAffine = {
53
93
  id: "algebricExpressionOfAffine",
54
94
  label: "Écrire l'expression algébrique d'une fonction affine",
55
- levels: ["2nde"],
56
95
  isSingleStep: true,
57
- sections: ["Fonctions affines"],
58
96
  generator: (nb) => getDistinctQuestions(getAlgebricExpressionOfAffineQuestion, nb),
59
97
  qcmTimer: 60,
60
98
  freeTimer: 60,
61
99
  getPropositions,
62
100
  isAnswerValid,
63
101
  subject: "Mathématiques",
102
+ getAnswer,
103
+ getInstruction,
104
+ getHint,
105
+ getCorrection,
106
+ hasHintAndCorrection: true,
64
107
  };
@@ -1 +1 @@
1
- {"version":3,"file":"leadingCoefficient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/leadingCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAiFF,KAAK,OAAO,GAAG;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAYF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB7D,CAAC"}
1
+ {"version":3,"file":"leadingCoefficient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/leadingCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAkHF,KAAK,OAAO,GAAG;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAYF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoB7D,CAAC"}
@@ -3,14 +3,35 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
4
  import { randomColor } from "../../../../geogebra/colors.js";
5
5
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
6
- import { Rational } from "../../../../math/numbers/rationals/rational.js";
6
+ import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
7
7
  import { randint } from "../../../../math/utils/random/randint.js";
8
8
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
9
9
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
10
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
12
  import { shuffle } from "../../../../utils/alea/shuffle.js";
11
13
  const getInstruction = (identifiers) => {
12
14
  return "Déterminer le coefficient directeur de la droite représentée ci-dessous : ";
13
15
  };
16
+ const getHint = (identifiers) => {
17
+ return `Le coefficient directeur d'une droite passant par deux points $A(x_A; y_A)$ et $B(x_B; y_B)$ est :
18
+
19
+ $$
20
+ \\frac{y_B - y_A}{x_B - x_A}
21
+ $$
22
+
23
+ Repère donc deux points appartenant à la droite, et utilise cette formule.`;
24
+ };
25
+ const getCorrection = (identifiers) => {
26
+ const { xA, yA, xB, yB } = identifiers;
27
+ return `On lit graphiquement que la droite passe par les deux points $A(${xA},${yA})$ et $B(${xB},${yB})$.
28
+
29
+ Le coefficient directeur est donc :
30
+
31
+ $$
32
+ ${frac(substract(yB, yA), substract(xB, xA)).toSimplificationTex()}
33
+ $$`;
34
+ };
14
35
  const getAnswer = (identifiers) => {
15
36
  const { xA, yA, xB, yB } = identifiers;
16
37
  const a = frac(yB - yA, xB - xA).simplify();
@@ -32,7 +53,13 @@ const getGGBOptions = (identifiers) => {
32
53
  commands,
33
54
  });
34
55
  return ggb.getOptions({
35
- coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
56
+ coords: ggb.getAdaptedCoords({
57
+ xMin,
58
+ xMax,
59
+ yMin,
60
+ yMax,
61
+ ratio: 2,
62
+ }),
36
63
  });
37
64
  };
38
65
  const getLeadingCoefficientQuestion = (opts) => {
@@ -43,8 +70,14 @@ const getLeadingCoefficientQuestion = (opts) => {
43
70
  }
44
71
  else
45
72
  [xA, yA] = [1, 2].map((el) => randint(-5, 6));
46
- xB = xA > 0 ? randint(xA - 4, 6, [xA]) : randint(-4, xA + 5, [xA]); // l'écart entre les deux points ne soit pas grand
47
- yB = yA > 0 ? randint(yA - 4, 6) : randint(-4, yA + 5);
73
+ const aIsInt = coinFlip();
74
+ const a = aIsInt
75
+ ? [randint(-3, 3, [0])]
76
+ : RationalConstructor.randomIrreductible(5).toArray();
77
+ xB = xA + (aIsInt ? 1 : a[0]);
78
+ yB = yA + (aIsInt ? a[0] : a[1]);
79
+ // xB = xA > 0 ? randint(xA - 4, 6, [xA]) : randint(-4, xA + 5, [xA]); // l'écart entre les deux points ne soit pas grand
80
+ // yB = yA > 0 ? randint(yA - 4, 6) : randint(-4, yA + 5);
48
81
  const identifiers = { xA, xB, yA, yB };
49
82
  const question = {
50
83
  instruction: getInstruction(identifiers),
@@ -53,6 +86,8 @@ const getLeadingCoefficientQuestion = (opts) => {
53
86
  ggbOptions: getGGBOptions(identifiers),
54
87
  answerFormat: "tex",
55
88
  identifiers,
89
+ hint: getHint(identifiers),
90
+ correction: getCorrection(identifiers),
56
91
  };
57
92
  return question;
58
93
  };
@@ -96,4 +131,7 @@ export const leadingCoefficient = {
96
131
  getInstruction,
97
132
  getGGBOptions,
98
133
  options,
134
+ getHint,
135
+ getCorrection,
136
+ hasHintAndCorrection: true,
99
137
  };
@@ -1 +1 @@
1
- {"version":3,"file":"integralAffines.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/integral/integralAffines.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAiFF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
1
+ {"version":3,"file":"integralAffines.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/integral/integralAffines.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA6FF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
@@ -1,31 +1,47 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
3
4
  import { Trinom, TrinomConstructor } from "../../../../math/polynomials/trinom.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
5
6
  import { IntegralNode } from "../../../../tree/nodes/functions/integralNode.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { lowerBound, upperBound, trinomial } = identifiers;
9
+ const trinom = new Trinom(trinomial[0], trinomial[1], trinomial[2]);
10
+ const affine = trinom.derivate();
11
+ const integral = new IntegralNode(affine.toTree(), lowerBound.toTree(), upperBound.toTree(), "x").toTex();
12
+ return `Calculer :
13
+
14
+ $$
15
+ ${integral}
16
+ $$`;
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { lowerBound, upperBound, trinomial } = identifiers;
20
+ const trinom = new Trinom(trinomial[0], trinomial[1], trinomial[2]);
21
+ const answer = (trinom.calculate(upperBound) - trinom.calculate(lowerBound))
22
+ .toTree()
23
+ .toTex();
24
+ return answer;
25
+ };
6
26
  const getIntegralAffinesQuestion = () => {
7
27
  const trinomial = TrinomConstructor.random();
8
- const affine = trinomial.derivate();
9
28
  let lowerBound = randint(-5, 5);
10
29
  let upperBound = randint(-5, 5);
11
30
  while (lowerBound >= upperBound) {
12
31
  lowerBound = randint(-5, 5);
13
32
  upperBound = randint(-5, 5);
14
33
  }
15
- const integral = new IntegralNode(affine.toTree(), lowerBound.toTree(), upperBound.toTree(), "x").toTex();
16
- const answer = (trinomial.calculate(upperBound) - trinomial.calculate(lowerBound))
17
- .toTree()
18
- .toTex();
34
+ const identifiers = {
35
+ lowerBound,
36
+ upperBound,
37
+ trinomial: [trinomial.a, trinomial.b, trinomial.c],
38
+ };
19
39
  const question = {
20
- answer: answer,
21
- instruction: `Calculer : $${integral}$`,
40
+ answer: getAnswer(identifiers),
41
+ instruction: getInstruction(identifiers),
22
42
  keys: [],
23
43
  answerFormat: "tex",
24
- identifiers: {
25
- lowerBound,
26
- upperBound,
27
- trinomial: [trinomial.a, trinomial.b, trinomial.c],
28
- },
44
+ identifiers,
29
45
  };
30
46
  return question;
31
47
  };
@@ -52,18 +68,18 @@ const getPropositions = (n, { answer, lowerBound, upperBound, trinomial }) => {
52
68
  return shuffleProps(propositions, n);
53
69
  };
54
70
  const isAnswerValid = (ans, { answer }) => {
55
- return ans === answer;
71
+ return numberVEA(ans, answer);
56
72
  };
57
73
  export const integralAffines = {
58
74
  id: "integralAffines",
59
75
  label: "Calcul d'intégrales de fonctions affines",
60
- levels: ["TermSpé"],
61
76
  isSingleStep: true,
62
- sections: ["Intégration"],
63
77
  generator: (nb) => getDistinctQuestions(getIntegralAffinesQuestion, nb),
64
78
  qcmTimer: 60,
65
79
  freeTimer: 60,
66
80
  getPropositions,
67
81
  isAnswerValid,
68
82
  subject: "Mathématiques",
83
+ getAnswer,
84
+ getInstruction,
69
85
  };
@@ -1 +1 @@
1
- {"version":3,"file":"integralTrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/integral/integralTrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAuFF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
1
+ {"version":3,"file":"integralTrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/integral/integralTrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAoGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
@@ -1,8 +1,28 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
3
4
  import { Polynomial, } from "../../../../math/polynomials/polynomial.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
5
6
  import { IntegralNode } from "../../../../tree/nodes/functions/integralNode.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { lowerBound, upperBound, quadrinomial } = identifiers;
9
+ const quadrinomial1 = new Polynomial(quadrinomial);
10
+ const trinomial = quadrinomial1.derivate();
11
+ const integral = new IntegralNode(trinomial.toTree(), lowerBound.toTree(), upperBound.toTree(), "x").toTex();
12
+ return `Calculer :
13
+
14
+ $$
15
+ ${integral}
16
+ $$`;
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { lowerBound, upperBound, quadrinomial } = identifiers;
20
+ const quadrinomial1 = new Polynomial(quadrinomial);
21
+ const answer = (quadrinomial1.calculate(upperBound) - quadrinomial1.calculate(lowerBound))
22
+ .toTree()
23
+ .toTex();
24
+ return answer;
25
+ };
6
26
  const getIntegralTrinomialsQuestion = () => {
7
27
  const quadCoeffs = [
8
28
  randint(-5, 5),
@@ -10,28 +30,23 @@ const getIntegralTrinomialsQuestion = () => {
10
30
  randint(-2, 3),
11
31
  randint(-5, 5, [0]),
12
32
  ];
13
- const quadrinomial = new Polynomial(quadCoeffs);
14
- const trinomial = quadrinomial.derivate();
15
33
  let lowerBound = randint(-3, 4);
16
34
  let upperBound = randint(-3, 4);
17
35
  while (lowerBound >= upperBound) {
18
36
  lowerBound = randint(-3, 4);
19
37
  upperBound = randint(-3, 4);
20
38
  }
21
- const integral = new IntegralNode(trinomial.toTree(), lowerBound.toTree(), upperBound.toTree(), "x").toTex();
22
- const answer = (quadrinomial.calculate(upperBound) - quadrinomial.calculate(lowerBound))
23
- .toTree()
24
- .toTex();
39
+ const identifiers = {
40
+ lowerBound,
41
+ upperBound,
42
+ quadrinomial: quadCoeffs,
43
+ };
25
44
  const question = {
26
- answer: answer,
27
- instruction: `Calculer : $${integral}$`,
45
+ answer: getAnswer(identifiers),
46
+ instruction: getInstruction(identifiers),
28
47
  keys: [],
29
48
  answerFormat: "tex",
30
- identifiers: {
31
- lowerBound,
32
- upperBound,
33
- quadrinomial: quadrinomial.coefficients,
34
- },
49
+ identifiers,
35
50
  };
36
51
  return question;
37
52
  };
@@ -58,18 +73,18 @@ const getPropositions = (n, { answer, lowerBound, upperBound, quadrinomial }) =>
58
73
  return shuffleProps(propositions, n);
59
74
  };
60
75
  const isAnswerValid = (ans, { answer }) => {
61
- return ans === answer;
76
+ return numberVEA(ans, answer);
62
77
  };
63
78
  export const integralTrinomials = {
64
79
  id: "integralTrinomials",
65
80
  label: "Calcul d'intégrales de fonctions trinômes",
66
- levels: ["TermSpé"],
67
81
  isSingleStep: true,
68
- sections: ["Intégration"],
69
82
  generator: (nb) => getDistinctQuestions(getIntegralTrinomialsQuestion, nb),
70
83
  qcmTimer: 60,
71
84
  freeTimer: 60,
72
85
  getPropositions,
73
86
  isAnswerValid,
74
87
  subject: "Mathématiques",
88
+ getAnswer,
89
+ getInstruction,
75
90
  };
@@ -1 +1 @@
1
- {"version":3,"file":"factorizedFormFromRoots.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoGF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
1
+ {"version":3,"file":"factorizedFormFromRoots.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuJF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAiBzD,CAAC"}
@@ -8,6 +8,7 @@ import { substract } from "../../../../../tree/nodes/operators/substractNode.js"
8
8
  import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
9
9
  import { probaFlip } from "../../../../../utils/alea/probaFlip.js";
10
10
  import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
11
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
11
12
  const getAnswerNode = (identifiers) => {
12
13
  const { a, roots } = identifiers;
13
14
  const isSingleRoot = roots.length === 1;
@@ -28,6 +29,49 @@ const getInstruction = (identifiers) => {
28
29
 
29
30
  Déterminer la forme factorisée de $f$.`;
30
31
  };
32
+ const getHint = (identifiers) => {
33
+ return `Soit $f$ un polynôme du second degré de la forme
34
+
35
+ $$
36
+ f(x)=ax^2+bx+c
37
+ $$
38
+
39
+ Si $f$ admet deux racines $x_1$ et $x_2$, alors la forme factorisée de $f$ est :
40
+
41
+ $$
42
+ f(x)=a(x-x_1)(x-x_2)
43
+ $$
44
+
45
+ Si $f$ n'admet qu'une racine $x_0$, alors sa forme factorisée est :
46
+
47
+ $$
48
+ f(x) = a(x-x_0)^2
49
+ $$
50
+
51
+ Si $f$ n'admet pas de racine, alors il n'admet pas de forme factorisée.`;
52
+ };
53
+ const getCorrection = (identifiers) => {
54
+ const { a, roots } = identifiers;
55
+ const rawForm = roots.length === 1
56
+ ? multiply(a, square(substract("x", roots[0])))
57
+ : multiply(a, multiply(substract("x", roots[0]), substract("x", roots[1])));
58
+ const simpForm = rawForm.simplify();
59
+ const hasSimplified = rawForm.toTex() !== simpForm.toTex();
60
+ return roots.length === 1
61
+ ? `Puisque $f$ n'admet qu'une racine, sa forme factorisée est :
62
+
63
+ ${alignTex([
64
+ ["f(x)", "=", rawForm.toTex()],
65
+ hasSimplified ? ["", "=", simpForm.toTex()] : [],
66
+ ])}
67
+ `
68
+ : `Puisque $f$ admet deux racines distinctes, sa forme factorisée est :
69
+
70
+ ${alignTex([
71
+ ["f(x)", "=", rawForm.toTex()],
72
+ hasSimplified ? ["", "=", simpForm.toTex()] : [],
73
+ ])}`;
74
+ };
31
75
  const getFactorizedFormFromRootsQuestion = () => {
32
76
  const a = randint(-10, 10, [0]);
33
77
  const firstRoot = randint(-10, 10);
@@ -43,6 +87,8 @@ const getFactorizedFormFromRootsQuestion = () => {
43
87
  keys: ["x"],
44
88
  answerFormat: "tex",
45
89
  identifiers,
90
+ hint: getHint(identifiers),
91
+ correction: getCorrection(identifiers),
46
92
  };
47
93
  return question;
48
94
  };
@@ -92,4 +138,7 @@ export const factorizedFormFromRoots = {
92
138
  subject: "Mathématiques",
93
139
  getInstruction,
94
140
  getAnswer,
141
+ getHint,
142
+ getCorrection,
143
+ hasHintAndCorrection: true,
95
144
  };
@@ -53,7 +53,7 @@ const getCorrection = (identifiers) => {
53
53
  L'axe de symétrie de la parabole représentant $f$ a donc pour équation :
54
54
 
55
55
  $$
56
- x=${fraction.toTex()}=${frac(x1 + x2, 2).toSimplificationString()}
56
+ x=${fraction.toTex()}=${frac(x1 + x2, 2).toSimplificationTex()}
57
57
  $$`;
58
58
  };
59
59
  const getKeys = (identifiers) => {
@@ -63,7 +63,7 @@ $$
63
63
  Or on sait que $x_1 = ${firstRoot.toTex()}$. On a donc :
64
64
 
65
65
  $$
66
- x_2 = ${frac(cOverA, firstRoot).toSimplificationString()}
66
+ x_2 = ${frac(cOverA, firstRoot).toSimplificationTex()}
67
67
  $$
68
68
  `;
69
69
  };
@@ -59,7 +59,7 @@ $$
59
59
  Ici, on a $a = ${aTex}$ et $c = ${cTex}$, donc :
60
60
 
61
61
  $$
62
- P = ${ans.toSimplificationString()}
62
+ P = ${ans.toSimplificationTex()}
63
63
  $$
64
64
  `;
65
65
  };
@@ -59,7 +59,7 @@ $$
59
59
  Ici, on a $a = ${aTex}$ et $b = ${bTex}$, donc :
60
60
 
61
61
  $$
62
- S = ${ans.toSimplificationString()}
62
+ S = ${ans.toSimplificationTex()}
63
63
  $$
64
64
  `;
65
65
  };
@@ -1 +1 @@
1
- {"version":3,"file":"distanceBetweenTwoPoints.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAkHF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}
1
+ {"version":3,"file":"distanceBetweenTwoPoints.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAsKF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAiB1D,CAAC"}
@@ -4,25 +4,70 @@ import { Point } from "../../../../math/geometry/point.js";
4
4
  import { SquareRoot, } from "../../../../math/numbers/reals/real.js";
5
5
  import { distinctRandTupleInt } from "../../../../math/utils/random/randTupleInt.js";
6
6
  import { round } from "../../../../math/utils/round.js";
7
- import { SqrtNode } from "../../../../tree/nodes/functions/sqrtNode.js";
8
7
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
9
- const getDistanceBetweenTwoPoints = () => {
10
- const [coords1, coords2] = distinctRandTupleInt(2, 2, { from: -9, to: 10 });
8
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { coords1, coords2 } = identifiers;
13
+ let A = new Point("A", new NumberNode(coords1[0]), new NumberNode(coords1[1]));
14
+ let B = new Point("B", new NumberNode(coords2[0]), new NumberNode(coords2[1]));
15
+ return `Dans un repère orthonormé, soit deux points $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$.
16
+
17
+ Calculer la distance $AB$.`;
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { coords1, coords2 } = identifiers;
11
21
  let A = new Point("A", new NumberNode(coords1[0]), new NumberNode(coords1[1]));
12
22
  let B = new Point("B", new NumberNode(coords2[0]), new NumberNode(coords2[1]));
13
23
  const answer = new SquareRoot(round(A.distanceTo(B) ** 2, 0))
14
24
  .simplify()
15
25
  .toTree()
16
26
  .toTex();
27
+ return answer;
28
+ };
29
+ const getHint = (identifiers) => {
30
+ const A = new Point("A", "x_A".toTree(), "y_A".toTree());
31
+ const B = new Point("B", "x_B".toTree(), "y_B".toTree());
32
+ return `Dans un repère orthonormé, la distance entre deux points $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$ est :
33
+
34
+ $$
35
+ AB = ${A.distanceToNode(B).toTex()}
36
+ $$
37
+ `;
38
+ };
39
+ const getCorrection = (identifiers) => {
40
+ const { coords1, coords2 } = identifiers;
41
+ let A = new Point("A", new NumberNode(coords1[0]), new NumberNode(coords1[1]));
42
+ let B = new Point("B", new NumberNode(coords2[0]), new NumberNode(coords2[1]));
43
+ const Ax = new Point("A", "x_A".toTree(), "y_A".toTree());
44
+ const Bx = new Point("B", "x_B".toTree(), "y_B".toTree());
45
+ return `Dans un repère orthonormé, la distance entre deux points $${Ax.toTexWithCoords()}$ et $${Bx.toTexWithCoords()}$ est :
46
+
47
+ $$
48
+ AB = ${Ax.distanceToNode(Bx).toTex()}
49
+ $$
50
+
51
+ Ici, on a donc :
52
+
53
+ ${alignTex([
54
+ ["AB", "=", A.distanceToNode(B).toTex()],
55
+ ["", "=", getAnswer(identifiers)],
56
+ ])}
57
+ `;
58
+ };
59
+ const getDistanceBetweenTwoPoints = () => {
60
+ const [coords1, coords2] = distinctRandTupleInt(2, 2, { from: -9, to: 10 });
61
+ const identifiers = { coords1, coords2 };
17
62
  const question = {
18
- instruction: `Dans un repère orthonormé, soit deux points $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$.
19
-
20
- Calculer la distance $AB$.`,
63
+ instruction: getInstruction(identifiers),
21
64
  startStatement: "AB",
22
- answer,
65
+ answer: getAnswer(identifiers),
23
66
  keys: [],
24
67
  answerFormat: "tex",
25
- identifiers: { coords1, coords2 },
68
+ identifiers,
69
+ hint: getHint(identifiers),
70
+ correction: getCorrection(identifiers),
26
71
  };
27
72
  return question;
28
73
  };
@@ -69,21 +114,19 @@ const getPropositions = (n, { answer, coords1, coords2 }) => {
69
114
  }
70
115
  return shuffleProps(propositions, n);
71
116
  };
72
- const isAnswerValid = (ans, { coords1, coords2 }) => {
73
- const A = new Point("A", new NumberNode(coords1[0]), new NumberNode(coords1[1]));
74
- const B = new Point("B", new NumberNode(coords2[0]), new NumberNode(coords2[1]));
75
- const answer = new SqrtNode(new NumberNode(round(A.distanceTo(B) ** 2, 0)), {
76
- allowSimplifySqrt: true,
77
- });
78
- const texs = answer.toAllValidTexs();
79
- return texs.includes(ans);
117
+ const isAnswerValid = (ans, { answer, coords1, coords2 }) => {
118
+ try {
119
+ const parsed = parseAlgebraic(ans);
120
+ return parsed.simplify().toTex() === answer;
121
+ }
122
+ catch (err) {
123
+ return handleVEAError(err);
124
+ }
80
125
  };
81
126
  export const distanceBetweenTwoPoints = {
82
127
  id: "distanceBetweenTwoPoints",
83
128
  connector: "=",
84
129
  label: "Distance entre deux points",
85
- levels: ["2nde", "1reESM"],
86
- sections: ["Géométrie cartésienne"],
87
130
  isSingleStep: false,
88
131
  generator: (nb) => getDistinctQuestions(getDistanceBetweenTwoPoints, nb),
89
132
  qcmTimer: 60,
@@ -91,4 +134,9 @@ export const distanceBetweenTwoPoints = {
91
134
  getPropositions,
92
135
  isAnswerValid,
93
136
  subject: "Mathématiques",
137
+ getAnswer,
138
+ getInstruction,
139
+ getCorrection,
140
+ getHint,
141
+ hasHintAndCorrection: true,
94
142
  };
@@ -1 +1 @@
1
- {"version":3,"file":"midpoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/midpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAmFF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAa1C,CAAC"}
1
+ {"version":3,"file":"midpoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/midpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA2IF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAgB1C,CAAC"}