math-exercises 3.0.65 → 3.0.67

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 (202) hide show
  1. package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.d.ts +1 -0
  2. package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.js +41 -20
  4. package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/simplifyFraction.js +4 -4
  6. package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/rounding/rounding.js +13 -21
  8. package/lib/exercises/math/calculLitteral/distributivity/canonicalFormDevelopment.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/distributivity/canonicalFormDevelopment.js +4 -0
  10. package/lib/exercises/math/calculLitteral/distributivity/doubleDistri.d.ts.map +1 -1
  11. package/lib/exercises/math/calculLitteral/distributivity/doubleDistri.js +5 -6
  12. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -1
  13. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +4 -4
  14. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.d.ts.map +1 -1
  15. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.js +4 -4
  16. package/lib/exercises/math/calculLitteral/distributivity/idRmq1.d.ts.map +1 -1
  17. package/lib/exercises/math/calculLitteral/distributivity/idRmq1.js +4 -7
  18. package/lib/exercises/math/calculLitteral/distributivity/idRmq2.d.ts.map +1 -1
  19. package/lib/exercises/math/calculLitteral/distributivity/idRmq2.js +4 -5
  20. package/lib/exercises/math/calculLitteral/distributivity/idRmq3.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/distributivity/idRmq3.js +4 -5
  22. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts.map +1 -1
  23. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.js +4 -4
  24. package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.d.ts.map +1 -1
  25. package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.js +4 -4
  26. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  27. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +4 -6
  28. package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.d.ts.map +1 -1
  29. package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.js +4 -3
  30. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.d.ts.map +1 -1
  31. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.js +4 -6
  32. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.d.ts.map +1 -1
  33. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +4 -4
  34. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts.map +1 -1
  35. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.js +4 -6
  36. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts.map +1 -1
  37. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.js +4 -4
  38. package/lib/exercises/math/calculLitteral/equation/fractionEquation.d.ts.map +1 -1
  39. package/lib/exercises/math/calculLitteral/equation/fractionEquation.js +4 -4
  40. package/lib/exercises/math/calculLitteral/factorisation/factoByX.d.ts.map +1 -1
  41. package/lib/exercises/math/calculLitteral/factorisation/factoByX.js +4 -4
  42. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
  43. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.js +4 -6
  44. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
  45. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.js +4 -6
  46. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
  47. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.js +4 -6
  48. package/lib/exercises/math/calculLitteral/factorisation/factoType2.d.ts.map +1 -1
  49. package/lib/exercises/math/calculLitteral/factorisation/factoType2.js +4 -3
  50. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalForm.d.ts.map +1 -1
  51. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalForm.js +4 -4
  52. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.d.ts.map +1 -1
  53. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.js +4 -4
  54. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.d.ts.map +1 -1
  55. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.js +4 -7
  56. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -1
  57. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType2.js +4 -3
  58. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
  59. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.js +4 -5
  60. package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.d.ts.map +1 -1
  61. package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.js +4 -4
  62. package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.d.ts.map +1 -1
  63. package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.js +4 -2
  64. package/lib/exercises/math/calculLitteral/simplifying/evaluateExpression.d.ts.map +1 -1
  65. package/lib/exercises/math/calculLitteral/simplifying/evaluateExpression.js +4 -4
  66. package/lib/exercises/math/functions/variations/varTableExtremaReading.d.ts.map +1 -1
  67. package/lib/exercises/math/functions/variations/varTableExtremaReading.js +4 -5
  68. package/lib/exercises/math/geometry/angles/recognizeAngleType.d.ts.map +1 -1
  69. package/lib/exercises/math/geometry/angles/recognizeAngleType.js +4 -5
  70. package/lib/exercises/math/geometry/areas/circleRadiusFromArea.d.ts.map +1 -1
  71. package/lib/exercises/math/geometry/areas/circleRadiusFromArea.js +3 -0
  72. package/lib/exercises/math/geometry/areas/rectangleArea.d.ts.map +1 -1
  73. package/lib/exercises/math/geometry/areas/rectangleArea.js +4 -7
  74. package/lib/exercises/math/geometry/areas/rectangleSideFromArea.d.ts.map +1 -1
  75. package/lib/exercises/math/geometry/areas/rectangleSideFromArea.js +4 -3
  76. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  77. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +32 -16
  78. package/lib/exercises/math/geometry/areas/squareSideFromArea.d.ts.map +1 -1
  79. package/lib/exercises/math/geometry/areas/squareSideFromArea.js +3 -0
  80. package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.d.ts.map +1 -1
  81. package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.js +4 -4
  82. package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
  83. package/lib/exercises/math/geometry/cartesian/midpoint.js +4 -4
  84. package/lib/exercises/math/geometry/cartesian/placeAPoint.d.ts.map +1 -1
  85. package/lib/exercises/math/geometry/cartesian/placeAPoint.js +25 -11
  86. package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.d.ts.map +1 -1
  87. package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.js +4 -0
  88. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
  89. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +4 -4
  90. package/lib/exercises/math/geometry/cartesian/pointCoordinates.d.ts.map +1 -1
  91. package/lib/exercises/math/geometry/cartesian/pointCoordinates.js +4 -0
  92. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoAxisNumbers.d.ts.map +1 -1
  93. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoAxisNumbers.js +4 -0
  94. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoOrthonorm.d.ts.map +1 -1
  95. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoOrthonorm.js +33 -17
  96. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.d.ts.map +1 -1
  97. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.js +4 -5
  98. package/lib/exercises/math/geometry/convexity/convexityTrinomialsGeo.d.ts.map +1 -1
  99. package/lib/exercises/math/geometry/convexity/convexityTrinomialsGeo.js +4 -3
  100. package/lib/exercises/math/matrices/matrixGeneralTerm.d.ts.map +1 -1
  101. package/lib/exercises/math/matrices/matrixGeneralTerm.js +0 -2
  102. package/lib/exercises/math/percent/evolutions/index.d.ts +0 -1
  103. package/lib/exercises/math/percent/evolutions/index.d.ts.map +1 -1
  104. package/lib/exercises/math/percent/evolutions/index.js +0 -1
  105. package/lib/exercises/math/percent/findProportion.d.ts.map +1 -1
  106. package/lib/exercises/math/percent/findProportion.js +21 -1
  107. package/lib/exercises/math/percent/interests/compoundInterest.d.ts +12 -0
  108. package/lib/exercises/math/percent/interests/compoundInterest.d.ts.map +1 -0
  109. package/lib/exercises/math/percent/interests/compoundInterest.js +127 -0
  110. package/lib/exercises/math/percent/interests/compoundInterestDuration.d.ts +2 -0
  111. package/lib/exercises/math/percent/interests/compoundInterestDuration.d.ts.map +1 -0
  112. package/lib/exercises/math/percent/interests/compoundInterestDuration.js +166 -0
  113. package/lib/exercises/math/percent/interests/compoundInterestStartValue.d.ts +12 -0
  114. package/lib/exercises/math/percent/interests/compoundInterestStartValue.d.ts.map +1 -0
  115. package/lib/exercises/math/percent/interests/compoundInterestStartValue.js +132 -0
  116. package/lib/exercises/math/percent/interests/index.d.ts +3 -0
  117. package/lib/exercises/math/percent/interests/index.d.ts.map +1 -0
  118. package/lib/exercises/math/percent/interests/index.js +2 -0
  119. package/lib/exercises/math/primitive/constantPrimitive.d.ts.map +1 -1
  120. package/lib/exercises/math/primitive/constantPrimitive.js +0 -2
  121. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  122. package/lib/exercises/math/primitive/polynomialPrimitive.js +4 -0
  123. package/lib/exercises/math/primitive/sinCosPrimitive.d.ts.map +1 -1
  124. package/lib/exercises/math/primitive/sinCosPrimitive.js +25 -12
  125. package/lib/exercises/math/probaStat/binomial/binomialInequation.d.ts.map +1 -1
  126. package/lib/exercises/math/probaStat/binomial/binomialInequation.js +4 -3
  127. package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.d.ts.map +1 -1
  128. package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.js +52 -28
  129. package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.d.ts.map +1 -1
  130. package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.js +59 -39
  131. package/lib/exercises/math/probaStat/diceBasicProbas.d.ts.map +1 -1
  132. package/lib/exercises/math/probaStat/diceBasicProbas.js +1 -4
  133. package/lib/exercises/math/sequences/sequencePlot.d.ts.map +1 -1
  134. package/lib/exercises/math/sequences/sequencePlot.js +59 -32
  135. package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.d.ts.map +1 -1
  136. package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.js +23 -7
  137. package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.d.ts.map +1 -1
  138. package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.js +23 -8
  139. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts +6 -1
  140. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts.map +1 -1
  141. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.js +61 -27
  142. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.d.ts.map +1 -1
  143. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.js +28 -10
  144. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.d.ts.map +1 -1
  145. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.js +43 -17
  146. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.d.ts.map +1 -1
  147. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.js +23 -8
  148. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.d.ts.map +1 -1
  149. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.js +22 -8
  150. package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.d.ts.map +1 -1
  151. package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.js +18 -5
  152. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.d.ts +1 -0
  153. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.d.ts.map +1 -1
  154. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.js +49 -24
  155. package/lib/exercises/pc/chemicalElements/weightPercent.d.ts.map +1 -1
  156. package/lib/exercises/pc/chemicalElements/weightPercent.js +42 -13
  157. package/lib/exercises/pc/chemicalReactions/calculateCombustionEnergy.d.ts.map +1 -1
  158. package/lib/exercises/pc/chemicalReactions/calculateCombustionEnergy.js +26 -9
  159. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.d.ts.map +1 -1
  160. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.js +48 -15
  161. package/lib/exercises/pc/chemicalReactions/identifyLimitingReagent.d.ts.map +1 -1
  162. package/lib/exercises/pc/chemicalReactions/identifyLimitingReagent.js +22 -9
  163. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.d.ts +1 -0
  164. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.d.ts.map +1 -1
  165. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.js +30 -15
  166. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts +7 -2
  167. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts.map +1 -1
  168. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.js +49 -33
  169. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.d.ts +1 -2
  170. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.d.ts.map +1 -1
  171. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.js +104 -67
  172. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts +1 -1
  173. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
  174. package/lib/exercises/pc/dosage/beerLambertRandomValue.js +99 -82
  175. package/lib/exercises/pc/dosage/concentrationCalculation.d.ts.map +1 -1
  176. package/lib/exercises/pc/dosage/concentrationCalculation.js +69 -40
  177. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
  178. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +78 -40
  179. package/lib/exercises/pc/electricity/calculateIntensity.d.ts.map +1 -1
  180. package/lib/exercises/pc/electricity/calculateIntensity.js +23 -19
  181. package/lib/exercises/pc/electricity/calculateIntensityInSerieOrParallel.d.ts.map +1 -1
  182. package/lib/exercises/pc/electricity/calculateIntensityInSerieOrParallel.js +51 -43
  183. package/lib/exercises/pc/electricity/calculateVoltage.d.ts.map +1 -1
  184. package/lib/exercises/pc/electricity/calculateVoltage.js +0 -2
  185. package/lib/exercises/pc/electricity/electricChargeFromIntensity.d.ts.map +1 -1
  186. package/lib/exercises/pc/electricity/electricChargeFromIntensity.js +19 -6
  187. package/lib/exercises/pc/electricity/electricEnergyFromPower.d.ts.map +1 -1
  188. package/lib/exercises/pc/electricity/electricEnergyFromPower.js +16 -6
  189. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.d.ts +1 -0
  190. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.d.ts.map +1 -1
  191. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.js +54 -24
  192. package/lib/exercises/pc/electricity/kirchhoffVoltageLaw.d.ts.map +1 -1
  193. package/lib/exercises/pc/electricity/kirchhoffVoltageLaw.js +44 -44
  194. package/lib/exercises/pc/electricity/ohmLaw.d.ts.map +1 -1
  195. package/lib/exercises/pc/electricity/ohmLaw.js +67 -24
  196. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts +1 -1
  197. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts.map +1 -1
  198. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.js +36 -43
  199. package/lib/index.d.ts +19 -12
  200. package/lib/index.d.ts.map +1 -1
  201. package/lib/latexTester.js +2 -0
  202. package/package.json +1 -1
@@ -1,36 +1,62 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
3
4
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
5
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
7
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
7
8
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
10
  import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { nX, a, b } = identifiers;
13
+ const p = new Rational(a, b);
14
+ return `Soit $X$ une variable aléatoire qui suit une loi binomiale de paramètres $n=${nX}$ et $p=${p
15
+ .toTree()
16
+ .simplify()
17
+ .toTex()}$.
18
+
19
+ Calculez l'espérance de $X$.`;
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { nX, a, b } = identifiers;
23
+ const p = new Rational(a, b);
24
+ const nNode = new NumberNode(nX);
25
+ const node = new MultiplyNode(nNode, p.toTree().simplify()).simplify();
26
+ const answer = node.toTex();
27
+ return answer;
28
+ };
29
+ const getHint = (identifiers) => {
30
+ return `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par $E(X) = np$.`;
31
+ };
32
+ const getCorrection = (identifiers) => {
33
+ const { nX, a, b } = identifiers;
34
+ const p = new Rational(a, b);
35
+ return `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par $E(X) = np$.
36
+
37
+ Ici, on a donc :
38
+
39
+ ${alignTex([
40
+ ["E(X)", "=", new MultiplyNode(nX.toTree(), p.toTree()).toTex()],
41
+ ["", "=", getAnswer(identifiers)],
42
+ ])}`;
43
+ };
9
44
  const getExpectedValueOfBinomialProbaQuestion = () => {
10
45
  const nX = randint(1, 9);
11
46
  const b = randint(2, 11);
12
47
  const a = randint(1, b);
13
- const p = new Rational(a, b);
14
- const node = getCorrectAnswer(nX, p);
15
- const answer = node.toTex();
48
+ const identifiers = { nX, a, b };
49
+ return getQuestionFromIdentifiers(identifiers);
50
+ };
51
+ const getQuestionFromIdentifiers = (identifiers) => {
16
52
  const question = {
17
- answer,
18
- instruction: `Soit $X$ une variable aléatoire qui suit une loi binomiale de paramètres $n=${nX}$ et $p=${p
19
- .toTree()
20
- .simplify()
21
- .toTex()}$. Calculez l'espérance de $X$.`,
53
+ answer: getAnswer(identifiers),
54
+ instruction: getInstruction(identifiers),
22
55
  keys: [],
23
56
  answerFormat: "tex",
24
- identifiers: { nX, a, b },
25
- hint: `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par $E(X) = np$.`,
26
- correction: `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par $E(X) = np$.
27
-
28
- Ici, on a donc :
29
-
30
- ${alignTex([
31
- ["E(X)", "=", new MultiplyNode(nX.toTree(), p.toTree()).toTex()],
32
- ["", "=", answer],
33
- ])}`,
57
+ identifiers,
58
+ hint: getHint(identifiers),
59
+ correction: getCorrection(identifiers),
34
60
  };
35
61
  return question;
36
62
  };
@@ -46,12 +72,13 @@ const getPropositions = (n, { answer, nX, a, b }) => {
46
72
  }
47
73
  return shuffleProps(propositions, n);
48
74
  };
49
- const isAnswerValid = (ans, { nX, a, b }) => {
50
- const p = new Rational(a, b);
51
- const correctAns = getCorrectAnswer(nX, p);
52
- return correctAns
53
- .toAllValidTexs({ allowFractionToDecimal: true })
54
- .includes(ans);
75
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
76
+ try {
77
+ return rationalVEA(ans, answer);
78
+ }
79
+ catch (err) {
80
+ return handleVEAError(err);
81
+ }
55
82
  };
56
83
  const generatePropositions = (n, p) => {
57
84
  const pTree = p.toTree().simplify();
@@ -66,10 +93,6 @@ const generatePropositions = (n, p) => {
66
93
  thirdProposition.toTex(),
67
94
  ];
68
95
  };
69
- const getCorrectAnswer = (n, p) => {
70
- const nNode = new NumberNode(n);
71
- return new MultiplyNode(nNode, p.toTree().simplify()).simplify();
72
- };
73
96
  export const expectedValueOfBinomialProba = {
74
97
  id: "expectedValueOfBinomialProba",
75
98
  label: "Calcul de l'espérance d'une loi binomiale",
@@ -83,4 +106,5 @@ export const expectedValueOfBinomialProba = {
83
106
  isAnswerValid,
84
107
  subject: "Mathématiques",
85
108
  hasHintAndCorrection: true,
109
+ getQuestionFromIdentifiers,
86
110
  };
@@ -1 +1 @@
1
- {"version":3,"file":"varianceOfBinomialProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/binomial/varianceOfBinomialProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+FF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
1
+ {"version":3,"file":"varianceOfBinomialProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/binomial/varianceOfBinomialProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqHF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAYzD,CAAC"}
@@ -1,46 +1,72 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
3
4
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
5
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
7
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
7
8
  import { PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
8
9
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
9
11
  import { alignTex } from "../../../../utils/latex/alignTex.js";
10
- const nbOneNode = new NumberNode(1);
11
- const getVarianceOfBinomialProbaQuestion = () => {
12
- const nX = randint(1, 9);
13
- const b = randint(2, 11);
14
- const a = randint(1, b);
12
+ const getAnswer = (identifiers) => {
13
+ const { nX, a, b } = identifiers;
15
14
  const p = new Rational(a, b);
16
- const correctAns = getCorrectAnswer(nX, p);
17
- const answer = correctAns.toTex();
18
- const question = {
19
- answer,
20
- instruction: `Soit $X$ une variable aléatoire qui suit une loi binomiale de paramètres $n=${nX}$ et $p=${p
21
- .toTree()
22
- .simplify()
23
- .toTex()}$. Calculez la variance de $X$.`,
24
- keys: [],
25
- answerFormat: "tex",
26
- identifiers: { nX, a, b },
27
- hint: `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par :
15
+ const pTree = p.toTree().simplify();
16
+ const oneMinusP = new SubstractNode((1).toTree(), pTree);
17
+ return new MultiplyNode(new NumberNode(nX), new MultiplyNode(pTree, oneMinusP).simplify())
18
+ .simplify()
19
+ .toTex();
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ const { nX, a, b } = identifiers;
23
+ const p = new Rational(a, b);
24
+ return `Soit $X$ une variable aléatoire qui suit une loi binomiale de paramètres $n=${nX}$ et $p=${p
25
+ .toTree()
26
+ .simplify()
27
+ .toTex()}$. Calculez la variance de $X$.`;
28
+ };
29
+ const getHint = (identifiers) => {
30
+ return `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par :
28
31
 
29
- $V(X) = np(1-p)$.`,
30
- correction: `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par :
32
+ $$
33
+ V(X) = np(1-p)
34
+ $$`;
35
+ };
36
+ const getCorrection = (identifiers) => {
37
+ const { nX, a, b } = identifiers;
38
+ const p = new Rational(a, b);
39
+ return `L'espérance d'une variable aléatoire $X$ qui suit une loi binomiale de paramètres $n$ et $p$ est donnée par :
31
40
 
32
41
  $V(X) = np(1-p)$.
33
42
 
34
43
  Ici, on a donc :
35
44
 
36
45
  ${alignTex([
37
- [
38
- "V(X)",
39
- "=",
40
- new MultiplyNode(nX.toTree(), new MultiplyNode(p.toTree(), new SubstractNode((1).toTree(), p.toTree())), { forceTimesSign: true }).toTex(),
41
- ],
42
- ["", "=", answer],
43
- ])}`,
46
+ [
47
+ "V(X)",
48
+ "=",
49
+ new MultiplyNode(nX.toTree(), new MultiplyNode(p.toTree(), new SubstractNode((1).toTree(), p.toTree())), { forceTimesSign: true }).toTex(),
50
+ ],
51
+ ["", "=", getAnswer(identifiers)],
52
+ ])}`;
53
+ };
54
+ const getVarianceOfBinomialProbaQuestion = () => {
55
+ const nX = randint(1, 9);
56
+ const b = randint(2, 11);
57
+ const a = randint(1, b);
58
+ const identifiers = { nX, a, b };
59
+ return getQuestionFromIdentifiers(identifiers);
60
+ };
61
+ const getQuestionFromIdentifiers = (identifiers) => {
62
+ const question = {
63
+ answer: getAnswer(identifiers),
64
+ instruction: getInstruction(identifiers),
65
+ keys: [],
66
+ answerFormat: "tex",
67
+ identifiers,
68
+ hint: getHint(identifiers),
69
+ correction: getCorrection(identifiers),
44
70
  };
45
71
  return question;
46
72
  };
@@ -56,12 +82,13 @@ const getPropositions = (n, { answer, nX, a, b }) => {
56
82
  }
57
83
  return shuffleProps(propositions, n);
58
84
  };
59
- const isAnswerValid = (ans, { nX, a, b }) => {
60
- const p = new Rational(a, b);
61
- const correctAns = getCorrectAnswer(nX, p);
62
- return correctAns
63
- .toAllValidTexs({ allowFractionToDecimal: true })
64
- .includes(ans);
85
+ const isAnswerValid = (ans, { answer, nX, a, b }) => {
86
+ try {
87
+ return rationalVEA(ans, answer);
88
+ }
89
+ catch (err) {
90
+ return handleVEAError(err);
91
+ }
65
92
  };
66
93
  const generatePropositions = (n, p) => {
67
94
  const pTree = p.toTree().simplify();
@@ -70,17 +97,10 @@ const generatePropositions = (n, p) => {
70
97
  const secondProposition = new MultiplyNode(nNode, new PowerNode(pTree, new NumberNode(2)).simplify()).simplify();
71
98
  return [firstProposition.toTex(), secondProposition.toTex()];
72
99
  };
73
- const getCorrectAnswer = (n, p) => {
74
- const pTree = p.toTree().simplify();
75
- const oneMinusP = new SubstractNode(nbOneNode, pTree);
76
- return new MultiplyNode(new NumberNode(n), new MultiplyNode(pTree, oneMinusP).simplify()).simplify();
77
- };
78
100
  export const varianceOfBinomialProba = {
79
101
  id: "varianceOfBinomialProba",
80
102
  label: "Calcul de la variance d'une loi binomiale",
81
- levels: ["TermTech"],
82
103
  isSingleStep: true,
83
- sections: ["Probabilités"],
84
104
  generator: (nb) => getDistinctQuestions(getVarianceOfBinomialProbaQuestion, nb),
85
105
  qcmTimer: 60,
86
106
  freeTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"diceBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/diceBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA8IF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAgBjD,CAAC"}
1
+ {"version":3,"file":"diceBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/diceBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA8IF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
@@ -125,9 +125,6 @@ export const diceBasicProbas = {
125
125
  getPropositions,
126
126
  isAnswerValid,
127
127
  subject: "Mathématiques",
128
- getAnswer,
129
- getHint,
130
- getInstruction,
131
- getCorrection,
128
+ getQuestionFromIdentifiers,
132
129
  hasHintAndCorrection: true,
133
130
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sequencePlot.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sequences/sequencePlot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AA0FF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAe9C,CAAC"}
1
+ {"version":3,"file":"sequencePlot.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sequences/sequencePlot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AA0HF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAc9C,CAAC"}
@@ -4,6 +4,54 @@ import { randfloat } from "../../../math/utils/random/randfloat.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { GeogebraConstructor } from "../../../geogebra/geogebraConstructor.js";
6
6
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { nValue, points, isArithmetic } = identifiers;
9
+ return `Ci-dessous est tracé un nuage de points représentant les valeurs d'une suite $(u_n)$. Quelle est la valeur de $u_{${nValue}}$ ?`;
10
+ };
11
+ const getAnswer = (identifiers) => {
12
+ const { nValue, points, isArithmetic } = identifiers;
13
+ const u_nValue = points[nValue][1];
14
+ const answer = u_nValue.toString();
15
+ return answer;
16
+ };
17
+ const getGGBOptions = (identifiers) => {
18
+ const { nValue, points, isArithmetic } = identifiers;
19
+ const commands = points.map((point, index) => {
20
+ return `A${index}=(${point[0]},${point[1]})`;
21
+ });
22
+ commands.push(...points.map((_, index) => {
23
+ return `SetFixed(A${index},true)`;
24
+ }), ...points.map((_, index) => {
25
+ return `SetLabelMode(A${index},1)`;
26
+ }));
27
+ const ggb = new GeogebraConstructor({
28
+ commands,
29
+ xAxis: { natural: true },
30
+ });
31
+ return ggb.getOptions({
32
+ coords: ggb.getAdaptedCoords({
33
+ xMin: 0,
34
+ xMax: 10,
35
+ yMin: Math.min(...points.map((p) => p[1])) - 2,
36
+ yMax: Math.max(...points.map((p) => p[1])) + 2,
37
+ }),
38
+ });
39
+ };
40
+ const getHint = (identifiers) => {
41
+ const { nValue, points, isArithmetic } = identifiers;
42
+ return `$u_{${nValue}}$ est l'ordonnée du point d'absicsse $${nValue}$ dans le nuage de points.`;
43
+ };
44
+ const getCorrection = (identifiers) => {
45
+ const { nValue, points, isArithmetic } = identifiers;
46
+ return `$u_{${nValue}}$ est l'ordonnée du point d'absicsse $${nValue}$ dans le nuage de points.
47
+
48
+ On lit donc :
49
+
50
+ $$
51
+ u_{${nValue}}=${getAnswer(identifiers)}
52
+ $$
53
+ `;
54
+ };
7
55
  const getSequencePlotQuestion = () => {
8
56
  const isArithmetic = coinFlip();
9
57
  const a = isArithmetic ? randfloat(0.1, 0.5, 1) : randfloat(1.01, 1.1, 2);
@@ -23,39 +71,19 @@ const getSequencePlotQuestion = () => {
23
71
  points.push([n, Math.round(u_n)]);
24
72
  }
25
73
  const nValue = randint(0, nMax);
26
- const u_nValue = points[nValue][1];
27
- const commands = points.map((point, index) => {
28
- return `A${index}=(${point[0]},${point[1]})`;
29
- });
30
- commands.push(...points.map((_, index) => {
31
- return `SetFixed(A${index},true)`;
32
- }), ...points.map((_, index) => {
33
- return `SetLabelMode(A${index},1)`;
34
- }));
35
- const ggb = new GeogebraConstructor({
36
- commands,
37
- xAxis: { natural: true },
38
- });
39
- const answer = u_nValue.toString();
74
+ const identifiers = { nValue, points, isArithmetic };
75
+ return getQuestionFromIdentifiers(identifiers);
76
+ };
77
+ const getQuestionFromIdentifiers = (identifiers) => {
40
78
  const question = {
41
- answer,
42
- instruction: `Ci-dessous est tracé un nuage de points représentant les valeurs d'une suite $(u_n)$. Quelle est la valeur de $u_{${nValue}}$ ?`,
43
- ggbOptions: ggb.getOptions({
44
- coords: ggb.getAdaptedCoords({
45
- xMin: 0,
46
- xMax: nMax,
47
- yMin: Math.min(...points.map((p) => p[1])) - 2,
48
- yMax: Math.max(...points.map((p) => p[1])) + 2,
49
- }),
50
- }),
79
+ answer: getAnswer(identifiers),
80
+ instruction: getInstruction(identifiers),
81
+ ggbOptions: getGGBOptions(identifiers),
51
82
  keys: [],
52
83
  answerFormat: "raw",
53
- identifiers: { nValue, points, isArithmetic },
54
- hint: `$u_{${nValue}}$ est l'ordonnée du point d'absicsse $${nValue}$ dans le nuage de points.`,
55
- correction: `$u_{${nValue}}$ est l'ordonnée du point d'absicsse $${nValue}$ dans le nuage de points.
56
-
57
- On lit donc : $u_{${nValue}}=${answer}$.
58
- `,
84
+ identifiers,
85
+ hint: getHint(identifiers),
86
+ correction: getCorrection(identifiers),
59
87
  };
60
88
  return question;
61
89
  };
@@ -75,10 +103,8 @@ const isAnswerValid = (ans, { answer }) => {
75
103
  export const sequencePlot = {
76
104
  id: "sequencePlot",
77
105
  label: "Lire graphiquement un terme d'une suite à partir d'un nuage de points",
78
- levels: ["1reSpé"],
79
106
  isSingleStep: true,
80
107
  hasGeogebra: true,
81
- sections: ["Suites"],
82
108
  generator: (nb) => getDistinctQuestions(getSequencePlotQuestion, nb),
83
109
  qcmTimer: 60,
84
110
  freeTimer: 60,
@@ -86,4 +112,5 @@ export const sequencePlot = {
86
112
  isAnswerValid,
87
113
  subject: "Mathématiques",
88
114
  hasHintAndCorrection: true,
115
+ getQuestionFromIdentifiers,
89
116
  };
@@ -1 +1 @@
1
- {"version":3,"file":"atomicStructureOfNucleus.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/chemicalElements/atomicStructureOfNucleus.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAKnF,KAAK,WAAW,GAAG;IAAE,UAAU,EAAE,WAAW,CAAA;CAAE,CAAC;AAoE/C,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}
1
+ {"version":3,"file":"atomicStructureOfNucleus.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/chemicalElements/atomicStructureOfNucleus.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAKnF,KAAK,WAAW,GAAG;IAAE,UAAU,EAAE,WAAW,CAAA;CAAE,CAAC;AA0F/C,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
@@ -5,16 +5,33 @@ import { round } from "../../../math/utils/round.js";
5
5
  import { atomes } from "../../../pc/constants/molecularChemistry/atome.js";
6
6
  import { random } from "../../../utils/alea/random.js";
7
7
  import { requiresApostropheBefore } from "../../../utils/strings/requiresApostropheBefore.js";
8
+ const getAnswer = (identifiers) => {
9
+ const { atomSymbol } = identifiers;
10
+ const atom = atomes.find((a) => a.symbole === atomSymbol);
11
+ const mass = round(atom.masseAtomique, 0);
12
+ return `^{${mass}}_{${atom.numeroAtomique}}${atom.symbole}`;
13
+ };
14
+ const getInstruction = (identifiers) => {
15
+ const { atomSymbol } = identifiers;
16
+ const atom = atomes.find((a) => a.symbole === atomSymbol);
17
+ const mass = round(atom.masseAtomique, 0);
18
+ const instruction = `Le noyau d'un atome ${requiresApostropheBefore(atom.name) ? "d'" : "de "}${atom.name} possède $${mass}$ nucléons, $${mass - atom.numeroAtomique}$ neutrons et $${atom.numeroAtomique}$ protons.
19
+
20
+ Quelle est son écriture conventionnelle ?`;
21
+ return instruction;
22
+ };
8
23
  const getAtomicStructureOfNucleusQuestion = () => {
9
24
  const atom = random(atomes.slice(0, 50));
10
- const mass = round(atom.masseAtomique, 0);
11
- const instruction = `Le noyau d'un atome ${requiresApostropheBefore(atom.name) ? "d'" : "de "}${atom.name} possède $${mass}$ nucléons, $${mass - atom.numeroAtomique}$ neutrons et $${atom.numeroAtomique}$ protons. Quelle est son écriture conventionnelle ?`;
25
+ const identifiers = { atomSymbol: atom.symbole };
26
+ return getQuestionFromIdentifiers(identifiers);
27
+ };
28
+ const getQuestionFromIdentifiers = (identifiers) => {
12
29
  const question = {
13
- answer: `^{${mass}}_{${atom.numeroAtomique}}${atom.symbole}`,
14
- instruction: instruction,
30
+ answer: getAnswer(identifiers),
31
+ instruction: getInstruction(identifiers),
15
32
  keys: [],
16
33
  answerFormat: "tex",
17
- identifiers: { atomSymbol: atom.symbole },
34
+ identifiers,
18
35
  };
19
36
  return question;
20
37
  };
@@ -42,9 +59,7 @@ const isAnswerValid = (ans, { answer }) => {
42
59
  export const atomicStructureOfNucleus = {
43
60
  id: "atomicStructureOfNucleus",
44
61
  label: "Trouver l'écriture conventionnelle d'un atome",
45
- levels: ["2nde"],
46
62
  isSingleStep: true,
47
- sections: ["Chimie organique"],
48
63
  generator: (nb) => getDistinctQuestions(getAtomicStructureOfNucleusQuestion, nb),
49
64
  qcmTimer: 60,
50
65
  freeTimer: 60,
@@ -52,4 +67,5 @@ export const atomicStructureOfNucleus = {
52
67
  isAnswerValid,
53
68
  subject: "Chimie",
54
69
  answerType: "QCU",
70
+ getQuestionFromIdentifiers,
55
71
  };
@@ -1 +1 @@
1
- {"version":3,"file":"calculateProtonsNumberFromMass.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAQnF,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AA+DF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAahE,CAAC"}
1
+ {"version":3,"file":"calculateProtonsNumberFromMass.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAQnF,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AAqFF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAYhE,CAAC"}
@@ -7,22 +7,38 @@ import { atomes } from "../../../pc/constants/molecularChemistry/atome.js";
7
7
  import { random } from "../../../utils/alea/random.js";
8
8
  import { requiresApostropheBefore } from "../../../utils/strings/requiresApostropheBefore.js";
9
9
  import { randint } from "../../../math/utils/random/randint.js";
10
- const getCalculateProtonsNumberFromMassQuestion = () => {
11
- const atom = random(atomes.slice(0, 50));
10
+ const getInstruction = (identifiers) => {
11
+ const { atomSymbol } = identifiers;
12
+ const atom = atomes.find((a) => a.symbole === atomSymbol);
12
13
  const atomNucleusMass = nucleonMass.value.times(atom.masseAtomique);
13
14
  const instruction = `Le noyau d'un atome ${requiresApostropheBefore(atom.name) ? "d'" : "de "}${atom.name} a pour masse $m = ${atomNucleusMass.toTex({
14
15
  scientific: 2,
15
- })}$ et possède $${round(atom.masseAtomique, 0) - atom.numeroAtomique}$ neutrons. Déterminer le nombre de protons de cet atome.`;
16
+ })}$ et possède $${round(atom.masseAtomique, 0) - atom.numeroAtomique}$ neutrons.
17
+
18
+ Déterminer le nombre de protons de cet atome.`;
19
+ return instruction;
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { atomSymbol } = identifiers;
23
+ const atom = atomes.find((a) => a.symbole === atomSymbol);
24
+ return `${atom.numeroAtomique}`;
25
+ };
26
+ const getCalculateProtonsNumberFromMassQuestion = () => {
27
+ const atom = random(atomes.slice(0, 50));
16
28
  // const help = ` $m_{\\text{nucléon}} = ${nucleonMass.value.toTex({
17
29
  // scientific: 2,
18
30
  // })}\\ ${nucleonMass.unit}$`;
31
+ const identifiers = { atomSymbol: atom.symbole };
32
+ return getQuestionFromIdentifiers(identifiers);
33
+ };
34
+ const getQuestionFromIdentifiers = (identifiers) => {
19
35
  const question = {
20
- answer: `${atom.numeroAtomique}`,
21
- instruction: instruction,
36
+ answer: getAnswer(identifiers),
37
+ instruction: getInstruction(identifiers),
22
38
  // instruction: instruction + help,
23
39
  keys: [],
24
40
  answerFormat: "tex",
25
- identifiers: { atomSymbol: atom.symbole },
41
+ identifiers,
26
42
  };
27
43
  return question;
28
44
  };
@@ -48,13 +64,12 @@ const isAnswerValid = (ans, { answer }) => {
48
64
  export const calculateProtonsNumberFromMass = {
49
65
  id: "calculateProtonsNumberFromMass",
50
66
  label: "Déterminer le nombre de protons par la masse",
51
- levels: ["2nde"],
52
67
  isSingleStep: true,
53
- sections: ["Chimie organique"],
54
68
  generator: (nb) => getDistinctQuestions(getCalculateProtonsNumberFromMassQuestion, nb),
55
69
  qcmTimer: 60,
56
70
  freeTimer: 60,
57
71
  getPropositions,
58
72
  isAnswerValid,
59
73
  subject: "Chimie",
74
+ getQuestionFromIdentifiers,
60
75
  };
@@ -1,5 +1,10 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
- type Identifiers = {};
2
+ type Identifiers = {
3
+ m: number;
4
+ t: number;
5
+ v: number;
6
+ type: number;
7
+ };
3
8
  export declare const calculateVolumetricMass: Exercise<Identifiers>;
4
9
  export {};
5
10
  //# sourceMappingURL=calculateVolumetricMass.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"calculateVolumetricMass.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/chemicalElements/calculateVolumetricMass.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG,EAAE,CAAC;AAoFtB,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
1
+ {"version":3,"file":"calculateVolumetricMass.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/chemicalElements/calculateVolumetricMass.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AA4HrE,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAazD,CAAC"}