math-exercises 3.0.30 → 3.0.32

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 (189) hide show
  1. package/lib/exercises/math/calcul/arithmetics/euclideanDivision.js +2 -2
  2. package/lib/exercises/math/calcul/fractions/fractionsProduct.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionsProduct.js +1 -3
  4. package/lib/exercises/math/calcul/fractions/fractionsSubstraction.js +2 -2
  5. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +1 -1
  6. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +1 -1
  7. package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.js +1 -1
  8. package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/fractions/simplifyFraction.js +19 -10
  10. package/lib/exercises/math/calculLitteral/distributivity/allIdentities.js +3 -3
  11. package/lib/exercises/math/calculLitteral/distributivity/doubleDistri.d.ts +8 -0
  12. package/lib/exercises/math/calculLitteral/distributivity/doubleDistri.d.ts.map +1 -0
  13. package/lib/exercises/math/calculLitteral/distributivity/doubleDistri.js +155 -0
  14. package/lib/exercises/math/calculLitteral/distributivity/idRmq1.d.ts +11 -0
  15. package/lib/exercises/math/calculLitteral/distributivity/idRmq1.d.ts.map +1 -0
  16. package/lib/exercises/math/calculLitteral/distributivity/idRmq1.js +147 -0
  17. package/lib/exercises/math/calculLitteral/distributivity/idRmq2.d.ts +11 -0
  18. package/lib/exercises/math/calculLitteral/distributivity/idRmq2.d.ts.map +1 -0
  19. package/lib/exercises/math/calculLitteral/distributivity/idRmq2.js +150 -0
  20. package/lib/exercises/math/calculLitteral/distributivity/idRmq3.d.ts +11 -0
  21. package/lib/exercises/math/calculLitteral/distributivity/idRmq3.d.ts.map +1 -0
  22. package/lib/exercises/math/calculLitteral/distributivity/idRmq3.js +143 -0
  23. package/lib/exercises/math/calculLitteral/distributivity/index.d.ts +4 -4
  24. package/lib/exercises/math/calculLitteral/distributivity/index.d.ts.map +1 -1
  25. package/lib/exercises/math/calculLitteral/distributivity/index.js +4 -4
  26. package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.d.ts.map +1 -1
  27. package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.js +1 -0
  28. package/lib/exercises/math/calculLitteral/equation/equa1.d.ts +11 -0
  29. package/lib/exercises/math/calculLitteral/equation/equa1.d.ts.map +1 -0
  30. package/lib/exercises/math/calculLitteral/equation/equa1.js +111 -0
  31. package/lib/exercises/math/calculLitteral/equation/equa2.d.ts +17 -0
  32. package/lib/exercises/math/calculLitteral/equation/equa2.d.ts.map +1 -0
  33. package/lib/exercises/math/calculLitteral/equation/equa2.js +164 -0
  34. package/lib/exercises/math/calculLitteral/equation/equa3.d.ts +12 -0
  35. package/lib/exercises/math/calculLitteral/equation/equa3.d.ts.map +1 -0
  36. package/lib/exercises/math/calculLitteral/equation/equa3.js +113 -0
  37. package/lib/exercises/math/calculLitteral/equation/equa4.d.ts +13 -0
  38. package/lib/exercises/math/calculLitteral/equation/equa4.d.ts.map +1 -0
  39. package/lib/exercises/math/calculLitteral/equation/equa4.js +106 -0
  40. package/lib/exercises/math/calculLitteral/equation/index.d.ts +4 -4
  41. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  42. package/lib/exercises/math/calculLitteral/equation/index.js +4 -4
  43. package/lib/exercises/math/derivation/derivative/expDerivativeOne.d.ts.map +1 -1
  44. package/lib/exercises/math/derivation/derivative/expDerivativeOne.js +0 -6
  45. package/lib/exercises/math/derivation/derivative/powerFunctionDerivative.d.ts.map +1 -1
  46. package/lib/exercises/math/derivation/derivative/powerFunctionDerivative.js +30 -0
  47. package/lib/exercises/math/functions/affines/leadingCoefficient.d.ts.map +1 -1
  48. package/lib/exercises/math/functions/affines/leadingCoefficient.js +26 -11
  49. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
  50. package/lib/exercises/math/functions/logarithm/logSimplifiying.js +1 -1
  51. package/lib/exercises/math/functions/sign/affineProductSign.d.ts.map +1 -1
  52. package/lib/exercises/math/functions/sign/affineProductSign.js +3 -0
  53. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts.map +1 -1
  54. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.js +64 -72
  55. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.d.ts.map +1 -1
  56. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.js +1 -1
  57. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.d.ts.map +1 -1
  58. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.js +31 -14
  59. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
  60. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +1 -2
  61. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts.map +1 -1
  62. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.js +3 -0
  63. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.d.ts.map +1 -1
  64. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.js +3 -0
  65. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts +1 -1
  66. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  67. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +1 -1
  68. package/lib/exercises/math/geometry/areas/triangleArea.d.ts +1 -1
  69. package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
  70. package/lib/exercises/math/geometry/areas/triangleArea.js +1 -1
  71. package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
  72. package/lib/exercises/math/geometry/cartesian/midpoint.js +19 -6
  73. package/lib/exercises/math/geometry/cartesian/pointCoordinates.d.ts.map +1 -1
  74. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoAxisNumbers.d.ts.map +1 -1
  75. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoOrthonorm.d.ts.map +1 -1
  76. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +2 -2
  77. package/lib/exercises/math/geometry/index.d.ts +1 -0
  78. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  79. package/lib/exercises/math/geometry/index.js +1 -1
  80. package/lib/exercises/math/geometry/pythagore/pythagore.d.ts +1 -1
  81. package/lib/exercises/math/geometry/pythagore/pythagore.d.ts.map +1 -1
  82. package/lib/exercises/math/geometry/pythagore/pythagore.js +1 -1
  83. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts +1 -1
  84. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts.map +1 -1
  85. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +1 -1
  86. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.d.ts +4 -4
  87. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.d.ts.map +1 -1
  88. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.js +4 -4
  89. package/lib/exercises/math/geometry/thales/thales.d.ts +1 -1
  90. package/lib/exercises/math/geometry/thales/thales.d.ts.map +1 -1
  91. package/lib/exercises/math/geometry/thales/thales.js +1 -1
  92. package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts +1 -1
  93. package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
  94. package/lib/exercises/math/geometry/thales/thalesCalcul.js +1 -1
  95. package/lib/exercises/math/geometry/triangles/index.d.ts +1 -1
  96. package/lib/exercises/math/geometry/triangles/index.d.ts.map +1 -1
  97. package/lib/exercises/math/geometry/triangles/index.js +2 -1
  98. package/lib/exercises/math/geometry/triangles/triangleNature.d.ts +9 -0
  99. package/lib/exercises/math/geometry/triangles/triangleNature.d.ts.map +1 -0
  100. package/lib/exercises/math/geometry/triangles/triangleNature.js +121 -0
  101. package/lib/exercises/math/geometry/triangles/triangleThirdAngleValue.d.ts +9 -0
  102. package/lib/exercises/math/geometry/triangles/triangleThirdAngleValue.d.ts.map +1 -0
  103. package/lib/exercises/math/geometry/triangles/triangleThirdAngleValue.js +134 -0
  104. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaNorms.d.ts +1 -1
  105. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaNorms.d.ts.map +1 -1
  106. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaNorms.js +1 -1
  107. package/lib/exercises/math/percent/percentToDecimal.js +2 -2
  108. package/lib/exercises/math/probaStat/ballsBasicProbas.d.ts.map +1 -1
  109. package/lib/exercises/math/probaStat/ballsBasicProbas.js +29 -16
  110. package/lib/exercises/math/probaStat/cardBasicProbas.d.ts.map +1 -1
  111. package/lib/exercises/math/probaStat/cardBasicProbas.js +44 -32
  112. package/lib/exercises/math/probaStat/stats1var/median.js +2 -2
  113. package/lib/exercises/math/probaStat/stats1var/medianList.d.ts.map +1 -1
  114. package/lib/exercises/math/probaStat/stats1var/medianList.js +28 -12
  115. package/lib/exercises/math/squareRoots/simpifySquareRoot.js +1 -1
  116. package/lib/exercises/math/squareRoots/squareRootsProducts.js +1 -1
  117. package/lib/exercises/math/trigonometry/trigonometry.d.ts +1 -1
  118. package/lib/exercises/math/trigonometry/trigonometry.d.ts.map +1 -1
  119. package/lib/exercises/math/trigonometry/trigonometry.js +1 -1
  120. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts +1 -1
  121. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts.map +1 -1
  122. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +1 -1
  123. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts +1 -1
  124. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts.map +1 -1
  125. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.js +2 -2
  126. package/lib/exercises/pc/index.d.ts +4 -4
  127. package/lib/exercises/pc/index.d.ts.map +1 -1
  128. package/lib/exercises/pc/index.js +4 -4
  129. package/lib/index.d.ts +18 -15
  130. package/lib/index.d.ts.map +1 -1
  131. package/lib/math/geometry/angle.d.ts +6 -0
  132. package/lib/math/geometry/angle.d.ts.map +1 -1
  133. package/lib/math/geometry/angle.js +20 -7
  134. package/lib/math/geometry/quadrilaterals/parallelogram.d.ts +23 -0
  135. package/lib/math/geometry/quadrilaterals/parallelogram.d.ts.map +1 -0
  136. package/lib/math/geometry/quadrilaterals/parallelogram.js +65 -0
  137. package/lib/math/geometry/quadrilaterals/quadrilateral.d.ts +15 -0
  138. package/lib/math/geometry/quadrilaterals/quadrilateral.d.ts.map +1 -0
  139. package/lib/math/geometry/quadrilaterals/quadrilateral.js +38 -0
  140. package/lib/math/geometry/quadrilaterals/rectangle.d.ts +24 -0
  141. package/lib/math/geometry/quadrilaterals/rectangle.d.ts.map +1 -0
  142. package/lib/math/geometry/quadrilaterals/rectangle.js +59 -0
  143. package/lib/math/geometry/quadrilaterals/rhombus.d.ts +19 -0
  144. package/lib/math/geometry/quadrilaterals/rhombus.d.ts.map +1 -0
  145. package/lib/math/geometry/quadrilaterals/rhombus.js +41 -0
  146. package/lib/math/geometry/quadrilaterals/square.d.ts +22 -0
  147. package/lib/math/geometry/quadrilaterals/square.d.ts.map +1 -0
  148. package/lib/math/geometry/quadrilaterals/square.js +38 -0
  149. package/lib/math/geometry/triangles/equilateralTriangle.d.ts +21 -0
  150. package/lib/math/geometry/triangles/equilateralTriangle.d.ts.map +1 -0
  151. package/lib/math/geometry/triangles/equilateralTriangle.js +52 -0
  152. package/lib/math/geometry/triangles/isoceleTriangle.d.ts +23 -0
  153. package/lib/math/geometry/triangles/isoceleTriangle.d.ts.map +1 -0
  154. package/lib/math/geometry/triangles/isoceleTriangle.js +66 -0
  155. package/lib/math/geometry/triangles/rightTriangle.d.ts +31 -0
  156. package/lib/math/geometry/triangles/rightTriangle.d.ts.map +1 -0
  157. package/lib/math/geometry/triangles/rightTriangle.js +108 -0
  158. package/lib/math/geometry/triangles/triangle.d.ts +68 -0
  159. package/lib/math/geometry/triangles/triangle.d.ts.map +1 -0
  160. package/lib/math/geometry/triangles/triangle.js +240 -0
  161. package/lib/math/geometry/vector.d.ts.map +1 -1
  162. package/lib/math/geometry/vector.js +0 -11
  163. package/lib/math/polynomials/trinom.d.ts +1 -1
  164. package/lib/math/polynomials/trinom.d.ts.map +1 -1
  165. package/lib/math/polynomials/trinom.js +7 -17
  166. package/lib/tree/nodes/complex/complexNode.d.ts +9 -3
  167. package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
  168. package/lib/tree/nodes/complex/complexNode.js +18 -1
  169. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  170. package/lib/tree/nodes/node.d.ts +2 -1
  171. package/lib/tree/nodes/node.d.ts.map +1 -1
  172. package/lib/tree/nodes/node.js +1 -0
  173. package/lib/tree/nodes/sets/belongsNode.d.ts +0 -1
  174. package/lib/tree/nodes/sets/belongsNode.d.ts.map +1 -1
  175. package/lib/tree/nodes/sets/belongsNode.js +0 -3
  176. package/lib/tree/nodes/sets/discreteSetNode.d.ts +8 -2
  177. package/lib/tree/nodes/sets/discreteSetNode.d.ts.map +1 -1
  178. package/lib/tree/nodes/sets/discreteSetNode.js +20 -2
  179. package/lib/tree/nodes/sets/intervalNode.d.ts +6 -2
  180. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  181. package/lib/tree/nodes/sets/intervalNode.js +15 -1
  182. package/lib/tree/nodes/sets/setNode.d.ts +3 -1
  183. package/lib/tree/nodes/sets/setNode.d.ts.map +1 -1
  184. package/lib/tree/nodes/sets/unionIntervalNode.d.ts +8 -2
  185. package/lib/tree/nodes/sets/unionIntervalNode.d.ts.map +1 -1
  186. package/lib/tree/nodes/sets/unionIntervalNode.js +16 -0
  187. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
  188. package/lib/tree/parsers/discreteSetParser.js +0 -2
  189. package/package.json +1 -1
@@ -17,7 +17,7 @@ const getEuclideanDivisionQuestions = () => {
17
17
  const answer = new EqualNode(new NumberNode(dividend), new AddNode(new MultiplyNode(new NumberNode(divisor), new NumberNode(quotient)), new NumberNode(remainder)));
18
18
  const answerTex = answer.toTex();
19
19
  const question = {
20
- instruction: `Ecrire la division euclidienne de $${dividend}$ par $${divisor}$.`,
20
+ instruction: `Écrire la division euclidienne de $${dividend}$ par $${divisor}$.`,
21
21
  answer: answerTex,
22
22
  keys: ["equal"],
23
23
  answerFormat: "tex",
@@ -45,7 +45,7 @@ const getPropositions = (n, { answer, dividend }) => {
45
45
  export const euclideanDivision = {
46
46
  id: "euclideanDivision",
47
47
  connector: "=",
48
- label: "Ecrire une division euclidienne",
48
+ label: "Écrire une division euclidienne",
49
49
  levels: ["6ème", "5ème", "4ème"],
50
50
  sections: ["Arithmétique"],
51
51
  isSingleStep: true,
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsProduct.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAiIF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqB3D,CAAC"}
1
+ {"version":3,"file":"fractionsProduct.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAiIF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmB3D,CAAC"}
@@ -62,7 +62,7 @@ const getFractionsProduct = (opts) => {
62
62
  rationalNum: [rational.num, rational.denum],
63
63
  rationalDenum: [rational2.num, rational2.denum],
64
64
  };
65
- return getQuestionFromIdentifiers(identifiers);
65
+ return getQuestionFromIdentifiers(identifiers, opts);
66
66
  };
67
67
  const getQuestionFromIdentifiers = (identifiers, opts) => {
68
68
  const question = {
@@ -108,8 +108,6 @@ export const fractionsProduct = {
108
108
  id: "fractionsProduct",
109
109
  connector: "=",
110
110
  label: "Produits de fractions",
111
- levels: ["4ème", "3ème", "2nde", "CAP", "2ndPro", "1rePro"],
112
- sections: ["Fractions"],
113
111
  isSingleStep: false,
114
112
  generator: (nb, opts) => getDistinctQuestions(() => getFractionsProduct(opts), nb),
115
113
  qcmTimer: 60,
@@ -52,7 +52,7 @@ const isAnswerValid = (ans, { answer }, opts) => {
52
52
  const parsed = rationalParser(ans);
53
53
  if (!parsed)
54
54
  return false;
55
- return parsed.simplify().toTex() === answer;
55
+ return parsed.simplify({ decimalToFractions: true }).toTex() === answer;
56
56
  }
57
57
  else {
58
58
  return ans === answer;
@@ -72,7 +72,7 @@ const getFractionsSubstractionQuestion = (opts) => {
72
72
  frac1: [ratio1.num, ratio1.denum],
73
73
  frac2: [ratio2.num, ratio2.denum],
74
74
  };
75
- return getQuestionFromIdentifiers(identifiers);
75
+ return getQuestionFromIdentifiers(identifiers, opts);
76
76
  };
77
77
  const getQuestionFromIdentifiers = (identifiers, opts) => {
78
78
  const question = {
@@ -74,7 +74,7 @@ const options = [
74
74
  export const fractionsSumsPrimeDenominators = {
75
75
  id: "fractionsSumsPrimeDenominators",
76
76
  connector: "=",
77
- label: "Sommes de fractions (dénominateurs premiers entre eux)",
77
+ label: "Sommes de fractions (avec dénominateurs premiers entre eux)",
78
78
  levels: [],
79
79
  isSingleStep: true,
80
80
  sections: [],
@@ -101,7 +101,7 @@ const options = [
101
101
  export const fractionsSumsSameDenominators = {
102
102
  id: "fractionsSumsSameDenominators",
103
103
  connector: "=",
104
- label: "Sommes de fractions (avec même dénominateurs)",
104
+ label: "Sommes de fractions (avec même dénominateur)",
105
105
  levels: [],
106
106
  isSingleStep: true,
107
107
  sections: [],
@@ -34,7 +34,7 @@ const getPeriodicWritingToFractionQuestion = () => {
34
34
  .toTex();
35
35
  const question = {
36
36
  answer,
37
- instruction: `Ecrire sous forme de fraction : $${x}$`,
37
+ instruction: `Écrire sous forme de fraction : $${x}$`,
38
38
  keys: [],
39
39
  answerFormat: "tex",
40
40
  identifiers: { num, denum, leadingPart: leadingPart.value },
@@ -1 +1 @@
1
- {"version":3,"file":"simplifyFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/simplifyFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqDF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
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,25 +1,36 @@
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 { frac } from "../../../../tree/nodes/operators/fractionNode.js";
5
4
  import { shuffle } from "../../../../utils/alea/shuffle.js";
5
+ const getStatementNode = (identifiers) => {
6
+ const { num, denum } = identifiers;
7
+ const rational = new Rational(num, denum).toTree();
8
+ return rational;
9
+ };
10
+ const getStartStatement = (identifiers) => {
11
+ const rationalTex = getStatementNode(identifiers).toTex();
12
+ return rationalTex;
13
+ };
6
14
  const getInstruction = (identifiers) => {
7
- const rational = frac(identifiers.num, identifiers.denum);
8
15
  return `Simplifier le plus possible :
9
16
 
10
17
  $$
11
- ${rational.toTex()}
18
+ ${getStartStatement(identifiers)}
12
19
  $$`;
13
20
  };
21
+ const getAnswer = (identifiers) => {
22
+ const { num, denum } = identifiers;
23
+ const rational = new Rational(num, denum);
24
+ const answer = rational.simplify().toTree().toTex();
25
+ return answer;
26
+ };
14
27
  const getSimplifyFraction = () => {
15
28
  const rational = RationalConstructor.randomSimplifiable(10);
16
- const rationalTex = rational.toTree().toTex();
17
- const answer = rational.simplify().toTree().toTex();
18
29
  const identifiers = { num: rational.num, denum: rational.denum };
19
30
  const question = {
20
31
  instruction: getInstruction(identifiers),
21
- startStatement: rationalTex,
22
- answer,
32
+ startStatement: getStartStatement(identifiers),
33
+ answer: getAnswer(identifiers),
23
34
  keys: [],
24
35
  answerFormat: "tex",
25
36
  identifiers,
@@ -46,9 +57,7 @@ const isAnswerValid = (ans, { num, denum }) => {
46
57
  export const simplifyFraction = {
47
58
  id: "simplifyFrac",
48
59
  connector: "=",
49
- label: "Simplification de fractions",
50
- levels: ["4ème", "3ème", "2nde", "CAP", "2ndPro", "1rePro"],
51
- sections: ["Fractions"],
60
+ label: "Simplifier une fraction",
52
61
  isSingleStep: false,
53
62
  generator: (nb) => getDistinctQuestions(getSimplifyFraction, nb),
54
63
  qcmTimer: 60,
@@ -1,8 +1,8 @@
1
1
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
2
  import { random } from "../../../../utils/alea/random.js";
3
- import { getFirstIdentityPropositions, getFirstIdentityQuestion, isFirstIdentityAnswerValid, } from "./firstIdentity.js";
4
- import { getSecondIdentityPropositions, getSecondIdentityQuestion, isSecondIdentityAnswerValid, } from "./secondIdentity.js";
5
- import { getThirdIdentityPropositions, getThirdIdentityQuestion, isThirdIdentityAnswerValid, } from "./thirdIdentity.js";
3
+ import { getFirstIdentityPropositions, getFirstIdentityQuestion, isFirstIdentityAnswerValid, } from "./idRmq1.js";
4
+ import { getSecondIdentityPropositions, getSecondIdentityQuestion, isSecondIdentityAnswerValid, } from "./idRmq2.js";
5
+ import { getThirdIdentityPropositions, getThirdIdentityQuestion, isThirdIdentityAnswerValid, } from "./idRmq3.js";
6
6
  const getAllIdentitiesQuestion = () => {
7
7
  const type = random([1, 2, 3]);
8
8
  let question;
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ affine1Coeffs: number[];
4
+ affine2Coeffs: number[];
5
+ };
6
+ export declare const doubleDistributivity: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=doubleDistri.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doubleDistri.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/doubleDistri.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA+JF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAmBtD,CAAC"}
@@ -0,0 +1,155 @@
1
+ import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
8
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
9
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
+ import { polynomialParser } from "../../../../tree/parsers/polynomialParser.js";
12
+ const getStatementNode = (identifiers) => {
13
+ const { affine1Coeffs, affine2Coeffs } = identifiers;
14
+ const affines = [
15
+ new Affine(affine1Coeffs[1], affine1Coeffs[0]),
16
+ new Affine(affine2Coeffs[1], affine2Coeffs[0]),
17
+ ];
18
+ const statementTree = new MultiplyNode(affines[0].toTree(), affines[1].toTree());
19
+ return statementTree;
20
+ };
21
+ const getStartStatement = (identifiers) => {
22
+ return getStatementNode(identifiers).toTex();
23
+ };
24
+ const getInstruction = (identifiers) => {
25
+ return `Développer et réduire :
26
+
27
+ $$
28
+ ${getStartStatement(identifiers)}
29
+ $$`;
30
+ };
31
+ const getAnswer = (identifiers) => {
32
+ const { affine1Coeffs, affine2Coeffs } = identifiers;
33
+ const affines = [
34
+ new Affine(affine1Coeffs[1], affine1Coeffs[0]),
35
+ new Affine(affine2Coeffs[1], affine2Coeffs[0]),
36
+ ];
37
+ const answer = affines[0].multiply(affines[1]).toTree().toTex();
38
+ return answer;
39
+ };
40
+ const getHint = (identifiers) => {
41
+ return "Multiplie chaque terme du premier facteur par chaque terme du second facteur, puis regroupe les termes similaires.";
42
+ };
43
+ const getCorrection = (identifiers) => {
44
+ const statementTex = getStartStatement(identifiers);
45
+ const answer = getAnswer(identifiers);
46
+ const { affine1Coeffs, affine2Coeffs } = identifiers;
47
+ const affines = [
48
+ new Affine(affine1Coeffs[1], affine1Coeffs[0]),
49
+ new Affine(affine2Coeffs[1], affine2Coeffs[0]),
50
+ ];
51
+ const subTerms = [
52
+ new MultiplyNode(affines[0].a.toTree(), "x".toTree()),
53
+ affines[0].b.toTree(),
54
+ new MultiplyNode(affines[1].a.toTree(), "x".toTree()),
55
+ affines[1].b.toTree(),
56
+ ];
57
+ const subMultiplications = [
58
+ new MultiplyNode(subTerms[0], subTerms[2], { forceTimesSign: true }),
59
+ new MultiplyNode(subTerms[0], subTerms[3], { forceTimesSign: true }),
60
+ new MultiplyNode(subTerms[1], subTerms[2], { forceTimesSign: true }),
61
+ new MultiplyNode(subTerms[1], subTerms[3], { forceTimesSign: true }),
62
+ ];
63
+ return `
64
+ ${alignTex([
65
+ [statementTex, "=", operatorComposition(AddNode, subMultiplications).toTex()],
66
+ [
67
+ "",
68
+ "=",
69
+ operatorComposition(AddNode, subMultiplications.map((e) => e.simplify())).toTex(),
70
+ ],
71
+ ["", "=", answer],
72
+ ])}
73
+
74
+ `;
75
+ };
76
+ const getDoubleDistributivityQuestion = () => {
77
+ const affines = AffineConstructor.differentRandoms(2, undefined, {
78
+ excludes: [0],
79
+ });
80
+ const statementTree = new MultiplyNode(affines[0].toTree(), affines[1].toTree());
81
+ const identifiers = {
82
+ affine1Coeffs: affines[0].coefficients,
83
+ affine2Coeffs: affines[1].coefficients,
84
+ };
85
+ const question = {
86
+ instruction: getInstruction(identifiers),
87
+ startStatement: statementTree.toTex(),
88
+ answer: getAnswer(identifiers),
89
+ keys: ["x"],
90
+ answerFormat: "tex",
91
+ identifiers,
92
+ hint: getHint(identifiers),
93
+ correction: getCorrection(identifiers),
94
+ };
95
+ return question;
96
+ };
97
+ const getPropositions = (n, { answer, affine1Coeffs, affine2Coeffs }) => {
98
+ const propositions = [];
99
+ addValidProp(propositions, answer);
100
+ const affines = [
101
+ new Affine(affine1Coeffs[1], affine1Coeffs[0]),
102
+ new Affine(affine2Coeffs[1], affine2Coeffs[0]),
103
+ ];
104
+ tryToAddWrongProp(propositions, affines[0]
105
+ .multiply(new Affine(-affines[1].a, randint(-9, 10, [affines[1].b])))
106
+ .toTree()
107
+ .toTex());
108
+ tryToAddWrongProp(propositions, affines[1]
109
+ .multiply(new Affine(randint(-9, 10, [affines[0].a, 0]), affines[0].b))
110
+ .toTree()
111
+ .toTex());
112
+ while (propositions.length < n) {
113
+ const affinesTemps = AffineConstructor.differentRandoms(2, undefined, {
114
+ excludes: [0],
115
+ });
116
+ const wrongAnswer = affinesTemps[0].multiply(affinesTemps[1]).toTree();
117
+ tryToAddWrongProp(propositions, wrongAnswer.toTex());
118
+ }
119
+ return shuffle(propositions);
120
+ };
121
+ const isAnswerValid = (ans, { answer }) => {
122
+ try {
123
+ const parsed = polynomialParser(ans);
124
+ if (!parsed)
125
+ return false;
126
+ return (parsed
127
+ .simplify({
128
+ forbidFactorize: true,
129
+ towardsDistribute: true,
130
+ })
131
+ .toTex() === answer);
132
+ }
133
+ catch (err) {
134
+ return handleVEAError(err);
135
+ }
136
+ };
137
+ export const doubleDistributivity = {
138
+ id: "doubleDistri",
139
+ connector: "=",
140
+ label: "Distributivité double",
141
+ levels: ["3ème", "2nde", "1reTech"],
142
+ sections: ["Calcul littéral"],
143
+ isSingleStep: false,
144
+ generator: (nb) => getDistinctQuestions(getDoubleDistributivityQuestion, nb),
145
+ qcmTimer: 60,
146
+ freeTimer: 60,
147
+ getPropositions,
148
+ isAnswerValid,
149
+ subject: "Mathématiques",
150
+ hasHintAndCorrection: true,
151
+ getInstruction,
152
+ getAnswer,
153
+ getCorrection,
154
+ getHint,
155
+ };
@@ -0,0 +1,11 @@
1
+ import { Exercise, QCMGenerator, QuestionGenerator, VEA } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const getFirstIdentityQuestion: QuestionGenerator<Identifiers>;
7
+ export declare const getFirstIdentityPropositions: QCMGenerator<Identifiers>;
8
+ export declare const isFirstIdentityAnswerValid: VEA<Identifiers>;
9
+ export declare const firstIdentity: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=idRmq1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idRmq1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/idRmq1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAOR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2EF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,WAAW,CAwBnE,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,YAAY,CAAC,WAAW,CAkClE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,GAAG,CAAC,WAAW,CAgBvD,CAAC;AAMF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAmB/C,CAAC"}
@@ -0,0 +1,147 @@
1
+ import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
4
+ import { Polynomial } from "../../../../math/polynomials/polynomial.js";
5
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
+ import { AddNode, isAddNode } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { PowerNode, SquareNode } from "../../../../tree/nodes/operators/powerNode.js";
9
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
10
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
11
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
13
+ import { isSubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
14
+ const getStatementNode = (identifiers) => {
15
+ const { a, b } = identifiers;
16
+ const affine = new Affine(a, b);
17
+ const statementTree = new PowerNode(affine.toTree(), new NumberNode(2));
18
+ return statementTree;
19
+ };
20
+ const getStartStatement = (identifiers) => {
21
+ return getStatementNode(identifiers).toTex();
22
+ };
23
+ const getInstruction = (identifiers) => {
24
+ return `Développer et réduire :
25
+
26
+ $$
27
+ ${getStartStatement(identifiers)}
28
+ $$`;
29
+ };
30
+ const getHint = (identifiers) => {
31
+ const affine = new Affine(identifiers.a, identifiers.b);
32
+ const aMonom = new MultiplyNode(affine.a.toTree(), "x".toTree());
33
+ return `Utilise l'identité remarquable :
34
+
35
+ $$
36
+ (a+b)^2 = a^2 + 2ab+b^2
37
+ $$
38
+
39
+ en prenant $a=${aMonom.toTex()}$ et $b=${affine.b}$.`;
40
+ };
41
+ const getCorrection = (identifiers) => {
42
+ const affine = new Affine(identifiers.a, identifiers.b);
43
+ const statementTex = getStartStatement(identifiers);
44
+ const answer = getAnswer(identifiers);
45
+ const aMonom = new MultiplyNode(affine.a.toTree(), "x".toTree());
46
+ return `On utilise l'identité remarquable :
47
+
48
+ $$
49
+ (a+b)^2 = a^2 + 2ab+b^2
50
+ $$
51
+
52
+ en prenant $a=${aMonom.toTex()}$ et $b=${affine.b}$.
53
+
54
+ Cela donne donc :
55
+
56
+ ${alignTex([
57
+ [
58
+ statementTex,
59
+ "=",
60
+ new AddNode(new AddNode(new SquareNode(aMonom), new MultiplyNode((2).toTree(), new MultiplyNode(aMonom, affine.b.toTree()))), new SquareNode(affine.b.toTree())).toTex(),
61
+ ],
62
+ ["", "=", answer],
63
+ ])}
64
+ `;
65
+ };
66
+ const getAnswer = (identifiers) => {
67
+ const affine = new Affine(identifiers.a, identifiers.b);
68
+ const answer = affine.multiply(affine).toTree().toTex();
69
+ return answer;
70
+ };
71
+ export const getFirstIdentityQuestion = () => {
72
+ const affine = AffineConstructor.random({
73
+ min: 1,
74
+ max: 11,
75
+ }, {
76
+ min: 1,
77
+ max: 11,
78
+ });
79
+ const identifiers = { a: affine.a, b: affine.b };
80
+ const question = {
81
+ instruction: getInstruction(identifiers),
82
+ startStatement: getStartStatement(identifiers),
83
+ answer: getAnswer(identifiers),
84
+ keys: ["x"],
85
+ answerFormat: "tex",
86
+ identifiers,
87
+ hint: getHint(identifiers),
88
+ correction: getCorrection(identifiers),
89
+ };
90
+ return question;
91
+ };
92
+ export const getFirstIdentityPropositions = (n, { answer, a, b }) => {
93
+ const propositions = [];
94
+ addValidProp(propositions, answer);
95
+ tryToAddWrongProp(propositions, new Polynomial([b ** 2, 0, a ** 2]).toTree().toTex());
96
+ tryToAddWrongProp(propositions, new Polynomial([b ** 2, a * b, a ** 2]).toTree().toTex());
97
+ tryToAddWrongProp(propositions, new Polynomial([b ** 2, a ** 2 + b ** 2, a ** 2]).toTree().toTex());
98
+ const affine = new Affine(a, b);
99
+ while (propositions.length < n) {
100
+ const affineTemp = AffineConstructor.random({
101
+ excludes: [0],
102
+ }, {
103
+ excludes: [0],
104
+ });
105
+ const wrongAnswer = affine.multiply(affineTemp).toTree();
106
+ tryToAddWrongProp(propositions, wrongAnswer.toTex());
107
+ }
108
+ return shuffle(propositions);
109
+ };
110
+ export const isFirstIdentityAnswerValid = (ans, { answer, a, b }) => {
111
+ try {
112
+ const parsed = parseAlgebraic(ans);
113
+ if (!parsed)
114
+ return false;
115
+ if (!isAddNode(parsed) && !isSubstractNode(parsed))
116
+ return false;
117
+ return (parsed
118
+ .simplify({ forbidFactorize: true, towardsDistribute: true })
119
+ .toTex() === answer);
120
+ }
121
+ catch (err) {
122
+ return handleVEAError(err);
123
+ }
124
+ };
125
+ const tests = () => {
126
+ //si identifiers = x,y alors questions devrait etre x,y et vea devrait accepter x,y,z
127
+ };
128
+ export const firstIdentity = {
129
+ id: "idRmq1",
130
+ connector: "=",
131
+ label: "Identité remarquable $(a+b)^2$",
132
+ levels: ["3ème", "2nde"],
133
+ sections: ["Calcul littéral"],
134
+ isSingleStep: false,
135
+ generator: (nb) => getDistinctQuestions(getFirstIdentityQuestion, nb),
136
+ qcmTimer: 60,
137
+ freeTimer: 60,
138
+ getPropositions: getFirstIdentityPropositions,
139
+ isAnswerValid: isFirstIdentityAnswerValid,
140
+ subject: "Mathématiques",
141
+ hasHintAndCorrection: true,
142
+ getAnswer,
143
+ getInstruction,
144
+ getCorrection,
145
+ getHint,
146
+ getStartStatement,
147
+ };
@@ -0,0 +1,11 @@
1
+ import { Exercise, QCMGenerator, QuestionGenerator, VEA } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const getSecondIdentityQuestion: QuestionGenerator<Identifiers>;
7
+ export declare const getSecondIdentityPropositions: QCMGenerator<Identifiers>;
8
+ export declare const isSecondIdentityAnswerValid: VEA<Identifiers>;
9
+ export declare const secondIdentity: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=idRmq2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idRmq2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/idRmq2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAOR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiFF,eAAO,MAAM,yBAAyB,EAAE,iBAAiB,CAAC,WAAW,CAuBpE,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,YAAY,CAAC,WAAW,CAqCnE,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,GAAG,CAAC,WAAW,CAgBxD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAkBhD,CAAC"}
@@ -0,0 +1,150 @@
1
+ import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
4
+ import { Polynomial } from "../../../../math/polynomials/polynomial.js";
5
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
+ import { AddNode, isAddNode } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { PowerNode, SquareNode } from "../../../../tree/nodes/operators/powerNode.js";
9
+ import { SubstractNode, isSubstractNode, } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
12
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ const getStatementNode = (identifiers) => {
15
+ const { a, b } = identifiers;
16
+ const affine = new Affine(a, b);
17
+ const statementTree = new PowerNode(affine.toTree(), new NumberNode(2));
18
+ return statementTree;
19
+ };
20
+ const getStartStatement = (identifiers) => {
21
+ const statementTree = getStatementNode(identifiers);
22
+ const statementTex = statementTree.toTex();
23
+ return statementTex;
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { a, b } = identifiers;
27
+ return `Développer et réduire :
28
+
29
+ $$
30
+ ${getStartStatement(identifiers)}
31
+ $$`;
32
+ };
33
+ const getHint = (identifiers) => {
34
+ const { a, b } = identifiers;
35
+ const affine = new Affine(a, b);
36
+ const aMonom = new MultiplyNode(affine.a.toTree(), "x".toTree());
37
+ const bPositive = -affine.b;
38
+ return `Utilise l'identité remarquable
39
+
40
+ $$
41
+ (a-b)^2 = a^2 - 2ab+b^2
42
+ $$
43
+
44
+ en prenant $a=${aMonom.toTex()}$ et $b=${bPositive}$`;
45
+ };
46
+ const getAnswer = (identifiers) => {
47
+ const { a, b } = identifiers;
48
+ const affine = new Affine(a, b);
49
+ const answer = affine.multiply(affine).toTree().toTex();
50
+ return answer;
51
+ };
52
+ const getCorrection = (identifiers) => {
53
+ const { a, b } = identifiers;
54
+ const affine = new Affine(a, b);
55
+ const aMonom = new MultiplyNode(affine.a.toTree(), "x".toTree());
56
+ const bPositive = -affine.b;
57
+ const statementTex = getStartStatement(identifiers);
58
+ const answer = getAnswer(identifiers);
59
+ return `On utilise l'identité remarquable
60
+
61
+ $$
62
+ (a-b)^2 = a^2 - 2ab+b^2
63
+ $$
64
+
65
+ en prenant $a=${aMonom.toTex()}$ et $b=${bPositive}$ :
66
+
67
+ ${alignTex([
68
+ [
69
+ statementTex,
70
+ "=",
71
+ new AddNode(new SubstractNode(new SquareNode(aMonom), new MultiplyNode((2).toTree(), new MultiplyNode(aMonom, bPositive.toTree()))), new SquareNode(bPositive.toTree())).toTex(),
72
+ ],
73
+ ["", "=", answer],
74
+ ])}
75
+ `;
76
+ };
77
+ export const getSecondIdentityQuestion = () => {
78
+ const affine = AffineConstructor.random({
79
+ min: 1,
80
+ max: 11,
81
+ }, {
82
+ min: -10,
83
+ max: 0,
84
+ });
85
+ const identifiers = { a: affine.a, b: affine.b };
86
+ const question = {
87
+ instruction: getInstruction(identifiers),
88
+ startStatement: getStartStatement(identifiers),
89
+ answer: getAnswer(identifiers),
90
+ keys: ["x"],
91
+ answerFormat: "tex",
92
+ identifiers,
93
+ hint: getHint(identifiers),
94
+ correction: getCorrection(identifiers),
95
+ };
96
+ return question;
97
+ };
98
+ export const getSecondIdentityPropositions = (n, { answer, a, b }) => {
99
+ const propositions = [];
100
+ addValidProp(propositions, answer);
101
+ tryToAddWrongProp(propositions, new Polynomial([-(b ** 2), 0, a ** 2]).toTree().toTex());
102
+ tryToAddWrongProp(propositions, new Polynomial([b ** 2, a * b, a ** 2]).toTree().toTex());
103
+ tryToAddWrongProp(propositions, new Polynomial([-(b ** 2), -(a ** 2 + b ** 2), a ** 2]).toTree().toTex());
104
+ const affine = new Affine(a, b);
105
+ while (propositions.length < n) {
106
+ const affineTemp = AffineConstructor.random({
107
+ min: 1,
108
+ max: 11,
109
+ }, {
110
+ min: -10,
111
+ max: 0,
112
+ });
113
+ const wrongAnswer = affine.multiply(affineTemp).toTree();
114
+ tryToAddWrongProp(propositions, wrongAnswer.toTex());
115
+ }
116
+ return shuffle(propositions);
117
+ };
118
+ export const isSecondIdentityAnswerValid = (ans, { a, b, answer }) => {
119
+ try {
120
+ const parsed = parseAlgebraic(ans);
121
+ if (!parsed)
122
+ return false;
123
+ if (!isAddNode(parsed) && !isSubstractNode(parsed))
124
+ return false;
125
+ return (parsed
126
+ .simplify({ forbidFactorize: true, towardsDistribute: true })
127
+ .toTex() === answer);
128
+ }
129
+ catch (err) {
130
+ return handleVEAError(err);
131
+ }
132
+ };
133
+ export const secondIdentity = {
134
+ id: "idRmq2",
135
+ connector: "=",
136
+ label: "Identité remarquable $(a-b)^2$",
137
+ isSingleStep: false,
138
+ generator: (nb) => getDistinctQuestions(getSecondIdentityQuestion, nb),
139
+ getPropositions: getSecondIdentityPropositions,
140
+ isAnswerValid: isSecondIdentityAnswerValid,
141
+ qcmTimer: 60,
142
+ freeTimer: 60,
143
+ subject: "Mathématiques",
144
+ hasHintAndCorrection: true,
145
+ getInstruction,
146
+ getCorrection,
147
+ getHint,
148
+ getAnswer,
149
+ getStartStatement,
150
+ };