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
@@ -71,102 +71,138 @@ const titrationReactions = [
71
71
  coeff: [1, 1],
72
72
  },
73
73
  ];
74
- const getTitrationEquivalenceRelationQuestion = () => {
75
- const exo = generateExo();
76
- const question = {
77
- answer: exo.answer.toTex(),
78
- instruction: exo.instruction,
79
- keys: [],
80
- hint: exo.hint,
81
- correction: exo.correction,
82
- answerFormat: "tex",
83
- identifiers: {
84
- a: exo.a,
85
- b: exo.b,
86
- vA: exo.vA.getValueAsNumber(),
87
- vB: exo.vB.getValueAsNumber(),
88
- cB: exo.cB.getValueAsNumber(),
89
- },
90
- };
91
- return question;
92
- };
93
- const getPropositions = (n, { answer, a, b, vA, vB, cB }) => {
94
- const propositions = [];
95
- addValidProp(propositions, answer);
96
- const correctAns = round((b * vB * cB) / (a * vA), 2);
97
- const unit = new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL);
98
- let random;
99
- while (propositions.length < n) {
100
- random = randfloat(correctAns - 1, correctAns + 2, 2, [correctAns]);
101
- tryToAddWrongProp(propositions, new Measure(Math.abs(random), 0, unit).toTex());
102
- }
103
- return shuffleProps(propositions, n);
104
- };
105
- const isAnswerValid = (ans, { answer, a, b, vA, vB, cB }) => {
106
- const correctAns = round((b * vB * cB) / (a * vA), 2);
107
- const unit = new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL);
108
- return [
109
- answer,
110
- frenchify(correctAns),
111
- answer.replace(`\\ ${unit.toTex()}`, ""),
112
- ].includes(ans);
113
- };
114
- const generateExo = () => {
115
- const reaction = random(titrationReactions);
116
- const vA = new Measure(5 * randint(2, 11), 0, VolumeUnit.mL);
117
- const cB = new Measure(random([0.05, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0]), 0, new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL));
118
- const vB = new Measure(5 * randint(1, 11), 0, VolumeUnit.mL);
74
+ const getInstruction = (identifiers) => {
75
+ const { reactionProduct, vA, vB, cB } = identifiers;
76
+ const reaction = titrationReactions.find((r) => r.produit === reactionProduct);
77
+ const vAMeasure = new Measure(vA, 0, VolumeUnit.mL);
78
+ const cBMeasure = new Measure(cB, 0, new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL));
79
+ const vBMeasure = new Measure(vB, 0, VolumeUnit.mL);
119
80
  const reactionString = `${reaction.coeff[0] !== 1 ? reaction.coeff[0] : ""}${reaction.titré.symbol} + ${reaction.coeff[1] !== 1 ? reaction.coeff[1] : ""}${reaction.titrant.symbol} \\Rightarrow ${reaction.produit}`;
120
- const hint = `Rappel : Au point d'équivalence, les quantités de matière $${reaction.titré.name}$ et $${reaction.titrant.name}$ sont égales , c'est-à-dire :
121
-
122
- - $${reaction.coeff[0]} \\times n(${reaction.titré.symbol}) = ${reaction.coeff[1]} \\times n(${reaction.titrant.symbol})$`;
123
81
  const instruction = `On réalise un titrage entre une solution ${reaction.titré.name}$(${reaction.titré.symbol})$ et une solution ${reaction.titrant.name}$(${reaction.titrant.symbol})$.
124
82
 
125
- - On prélève un volume de $V_A=${vA.toTex({
83
+ - On prélève un volume de $V_A=${vAMeasure.toTex({
126
84
  notScientific: true,
127
85
  })}$ de la solution ${reaction.titré.name} de concentration inconnue $C_A$
128
- - On ajoute progressivement une solution ${reaction.titrant.name} de concentration connue $C_B=${cB.toTex({ notScientific: true })}$
129
- - Le volume ${reaction.titrant.name} nécessaire pour atteindre le point d'équivalence est $V_B=${vB.toTex({
86
+
87
+ - On ajoute progressivement une solution ${reaction.titrant.name} de concentration connue $C_B=${cBMeasure.toTex({ notScientific: true })}$
88
+
89
+ - Le volume ${reaction.titrant.name} nécessaire pour atteindre le point d'équivalence est $V_B=${vBMeasure.toTex({
130
90
  notScientific: true,
131
91
  })}$
92
+
132
93
  - Réaction : $${reactionString}$
133
94
 
134
95
  Calculer la concentration $C_A$ de (${reaction.titré.name}), arrondie au centiéme.
135
96
  `;
136
- const answer = cB
137
- .times(vB)
97
+ return instruction;
98
+ };
99
+ const getAnswerNode = (identifiers) => {
100
+ const { reactionProduct, vA, vB, cB } = identifiers;
101
+ const reaction = titrationReactions.find((r) => r.produit === reactionProduct);
102
+ const vAMeasure = new Measure(vA, 0, VolumeUnit.mL);
103
+ const cBMeasure = new Measure(cB, 0, new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL));
104
+ const vBMeasure = new Measure(vB, 0, VolumeUnit.mL);
105
+ const answer = cBMeasure
106
+ .times(vBMeasure)
138
107
  .times(reaction.coeff[1])
139
- .divide(vA.times(reaction.coeff[0]))
108
+ .divide(vAMeasure.times(reaction.coeff[0]))
140
109
  .toSignificant(2);
141
- const correction = `Utiliser la relation d'équivalence du titrage :
110
+ return answer;
111
+ };
112
+ const getAnswer = (identifiers) => {
113
+ return getAnswerNode(identifiers).toTex();
114
+ };
115
+ const getHint = (identifiers) => {
116
+ const { reactionProduct, vA, vB, cB } = identifiers;
117
+ const reaction = titrationReactions.find((r) => r.produit === reactionProduct);
118
+ const hint = `Au point d'équivalence, les quantités de matière $${reaction.titré.name}$ et $${reaction.titrant.name}$ sont égales , c'est-à-dire :
142
119
 
120
+ $$
121
+ ${reaction.coeff[0]} \\times n(${reaction.titré.symbol}) = ${reaction.coeff[1]} \\times n(${reaction.titrant.symbol})
122
+ $$`;
123
+ return hint;
124
+ };
125
+ const getCorrection = (identifiers) => {
126
+ const { reactionProduct, vA, vB, cB } = identifiers;
127
+ const reaction = titrationReactions.find((r) => r.produit === reactionProduct);
128
+ const vAMeasure = new Measure(vA, 0, VolumeUnit.mL);
129
+ const cBMeasure = new Measure(cB, 0, new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL));
130
+ const vBMeasure = new Measure(vB, 0, VolumeUnit.mL);
131
+ const correction = `On utilise la relation d'équivalence du titrage.
132
+
143
133
  Au point d'équivalence, les quantités de matière ${reaction.titré.name} et ${reaction.titrant.name} sont égales , c'est-à-dire :
134
+
144
135
  - $${reaction.coeff[0]} \\times n(${reaction.titré.symbol}) = ${reaction.coeff[1]} \\times n(${reaction.titrant.symbol})$
136
+
145
137
  - Or, la quantité de matière est donnée par : $n=C \\times V$
138
+
146
139
  - Donc à l'équivalence : $a \\times C_A \\times V_A =b \\times C_B \\times V_B$
147
- - Ce qui donne : $C_A = \\frac{b \\times C_B \\times V_B}{a \\times V_A} \\Rightarrow C_A = \\frac{${reaction.coeff[1]} \\times ${cB.toTex({ notScientific: true })} \\times ${vB.toTex({
140
+
141
+ - Ce qui donne : $C_A = \\frac{b \\times C_B \\times V_B}{a \\times V_A} \\Rightarrow C_A = \\frac{${reaction.coeff[1]} \\times ${cBMeasure.toTex({
148
142
  notScientific: true,
149
- })}}{${reaction.coeff[0]} \\times ${vA.toTex({
143
+ })} \\times ${vBMeasure.toTex({
150
144
  notScientific: true,
151
- })}} \\Rightarrow C_A = ${answer.toTex({ notScientific: true })}$`;
152
- return {
153
- instruction,
154
- answer,
155
- hint,
156
- correction,
145
+ })}}{${reaction.coeff[0]} \\times ${vAMeasure.toTex({
146
+ notScientific: true,
147
+ })}} \\Rightarrow C_A = ${getAnswerNode(identifiers).toTex({
148
+ notScientific: true,
149
+ })}$`;
150
+ return correction;
151
+ };
152
+ const getQuestionFromIdentifiers = (identifiers) => {
153
+ const question = {
154
+ answer: getAnswer(identifiers),
155
+ instruction: getInstruction(identifiers),
156
+ keys: [],
157
+ hint: getHint(identifiers),
158
+ correction: getCorrection(identifiers),
159
+ answerFormat: "tex",
160
+ identifiers,
161
+ };
162
+ return question;
163
+ };
164
+ const getTitrationEquivalenceRelationQuestion = () => {
165
+ const reaction = random(titrationReactions);
166
+ const vA = 5 * randint(2, 11);
167
+ const cB = random([0.05, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0]);
168
+ const vB = 5 * randint(1, 11);
169
+ const identifiers = {
170
+ reactionProduct: reaction.produit,
157
171
  vA,
158
172
  vB,
159
173
  cB,
160
- a: reaction.coeff[0],
161
- b: reaction.coeff[1],
162
174
  };
175
+ return getQuestionFromIdentifiers(identifiers);
176
+ };
177
+ const getPropositions = (n, { answer, reactionProduct, vA, vB, cB }) => {
178
+ const propositions = [];
179
+ addValidProp(propositions, answer);
180
+ const reaction = titrationReactions.find((r) => r.produit === reactionProduct);
181
+ const [a, b] = reaction.coeff;
182
+ const correctAns = round((b * vB * cB) / (a * vA), 2);
183
+ const unit = new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL);
184
+ let random;
185
+ while (propositions.length < n) {
186
+ random = randfloat(correctAns - 1, correctAns + 2, 2, [correctAns]);
187
+ tryToAddWrongProp(propositions, new Measure(Math.abs(random), 0, unit).toTex());
188
+ }
189
+ return shuffleProps(propositions, n);
190
+ };
191
+ const isAnswerValid = (ans, { answer, reactionProduct, vA, vB, cB }) => {
192
+ const reaction = titrationReactions.find((r) => r.produit === reactionProduct);
193
+ const [a, b] = reaction.coeff;
194
+ const correctAns = round((b * vB * cB) / (a * vA), 2);
195
+ const unit = new DivideUnit(AmountOfSubstance.mol, VolumeUnit.mL);
196
+ return [
197
+ answer,
198
+ frenchify(correctAns),
199
+ answer.replace(`\\ ${unit.toTex()}`, ""),
200
+ ].includes(ans);
163
201
  };
164
202
  export const titrationEquivalenceRelation = {
165
203
  id: "titrationEquivalenceRelation",
166
204
  label: "Calculer la concentration d'un element titré à l'aide d'une équation de réaction d'un mélange stœchiométrique.",
167
- levels: ["1reSpé"],
168
205
  isSingleStep: true,
169
- sections: ["Réaction chimique"],
170
206
  generator: (nb) => getDistinctQuestions(getTitrationEquivalenceRelationQuestion, nb, 10),
171
207
  qcmTimer: 60,
172
208
  freeTimer: 60,
@@ -175,4 +211,5 @@ export const titrationEquivalenceRelation = {
175
211
  maxAllowedQuestions: 10,
176
212
  subject: "Physique",
177
213
  hasHintAndCorrection: true,
214
+ getQuestionFromIdentifiers,
178
215
  };
@@ -5,7 +5,7 @@ type Identifiers = {
5
5
  molarAbsorptivity: number;
6
6
  pathLength: number;
7
7
  absorbance: number;
8
- randomIndex: number;
8
+ targetVariableName: string;
9
9
  };
10
10
  export declare const BeerLambertRandomValueExercise: Exercise<Identifiers>;
11
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"beerLambertRandomValue.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/dosage/beerLambertRandomValue.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA0NF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAchE,CAAC"}
1
+ {"version":3,"file":"beerLambertRandomValue.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/dosage/beerLambertRandomValue.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAqOF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAahE,CAAC"}
@@ -5,31 +5,24 @@ import { round } from "../../../math/utils/round.js";
5
5
  import { random } from "../../../utils/alea/random.js";
6
6
  import { requiresApostropheBefore } from "../../../utils/strings/requiresApostropheBefore.js";
7
7
  import { randfloat } from "../../../math/utils/random/randfloat.js";
8
- import { randint } from "../../../math/utils/random/randint.js";
9
8
  import { molecules } from "../../../pc/constants/molecularChemistry/molecule.js";
10
- const getBeerLambertRandomValueQuestion = () => {
11
- const molecule = random(molecules);
12
- const concentration = round(randfloat(0.01, 0.1), 2); // Concentration in mol/L
13
- const molarAbsorptivity = round(randfloat(10, 100), 1); // Molar absorptivity in L·mol^-1·cm^-1
14
- const pathLength = round(randfloat(1, 5), 1); // Path length in cm
15
- const absorbance = round(concentration * molarAbsorptivity * pathLength, 2); // Absorbance
9
+ const getInstruction = (identifiers) => {
10
+ const { moleculeName, concentration, molarAbsorptivity, pathLength, absorbance, targetVariableName, } = identifiers;
16
11
  const variables = [
17
12
  {
18
13
  name: "concentration",
19
14
  value: concentration,
20
- unit: "\\text{mol} \\cdot \\text{L}^{-1}",
15
+ unit: "\\textrm{mol} \\cdot \\textrm{L}^{-1}",
21
16
  },
22
17
  {
23
18
  name: "molarAbsorptivity",
24
19
  value: molarAbsorptivity,
25
- unit: "\\text{L} \\cdot \\text{mol}^{-1} \\cdot \\text{cm}^{-1}",
20
+ unit: "\\textrm{L} \\cdot \\textrm{mol}^{-1} \\cdot \\textrm{cm}^{-1}",
26
21
  },
27
- { name: "pathLength", value: pathLength, unit: "\\text{cm}" },
22
+ { name: "pathLength", value: pathLength, unit: "\\textrm{cm}" },
28
23
  { name: "absorbance", value: absorbance, unit: "" },
29
24
  ];
30
- const randomIndex = randint(0, variables.length);
31
- const targetVariable = variables[randomIndex];
32
- const knownVariables = variables.filter((_, index) => index !== randomIndex);
25
+ const knownVariables = variables.filter((v) => v.name !== targetVariableName);
33
26
  const knownVariablesText = knownVariables
34
27
  .map((v) => `${v.name === "concentration"
35
28
  ? "- Concentration"
@@ -45,82 +38,121 @@ const getBeerLambertRandomValueQuestion = () => {
45
38
  ? "$\\ell$"
46
39
  : "$A$"} = $${frenchify(v.value)}\\ ${v.unit}$`)
47
40
  .join(",\n");
48
- const instruction = `Vous êtes en train de réaliser l'étalonnage d'une solution ${requiresApostropheBefore(molecule.name.toLowerCase()) ? "d'" : "de "}${molecule.name.toLowerCase()} en utilisant une solution étalon. Vous avez mesuré les données suivantes :\n
41
+ const instruction = `Vous êtes en train de réaliser l'étalonnage d'une solution ${requiresApostropheBefore(moleculeName.toLowerCase()) ? "d'" : "de "}${moleculeName.toLowerCase()} en utilisant une solution étalon. Vous avez mesuré les données suivantes :\n
49
42
  ${knownVariablesText}.\n
50
43
 
51
- À partir de ces données, déterminez ${targetVariable.name === "concentration"
44
+ À partir de ces données, déterminez ${targetVariableName === "concentration"
52
45
  ? "la concentration en $\\text{mol} \\cdot \\text{L}^{-1}$"
53
- : targetVariable.name === "molarAbsorptivity"
46
+ : targetVariableName === "molarAbsorptivity"
54
47
  ? "le coefficient d'absorption molaire en $\\text{L} \\cdot \\text{mol}^{-1} \\cdot \\text{cm}^{-1}$"
55
- : targetVariable.name === "pathLength"
48
+ : targetVariableName === "pathLength"
56
49
  ? "la longueur du trajet optique en $\\text{cm}$"
57
50
  : "l'absorbance"} de cette solution.`;
58
- const hint = `Rappelez-vous la loi de Beer-Lambert : $A = \\varepsilon \\cdot C \\cdot \\ell$. Voici les éléments de cette formule :
59
- - $A$ : l'absorbance
60
- - $\\varepsilon$ : le coefficient d'absorption molaire en $\\text{L} \\cdot \\text{mol}^{-1} \\cdot \\text{cm}^{-1}$
61
- - $C$ : la concentration en $\\text{mol} \\cdot \\text{L}^{-1}$
62
- - $\\ell$ : la longueur du trajet optique en $\\text{cm}$
51
+ return instruction;
52
+ };
53
+ const getAnswer = (identifiers) => {
54
+ const { targetVariableName } = identifiers;
55
+ const value = identifiers[targetVariableName];
56
+ return Number(value).frenchify();
57
+ };
58
+ const getHint = (identifiers) => {
59
+ const hint = `La loi de Beer-Lambert est la suivante :
60
+
61
+ $$
62
+ A = \\varepsilon \\cdot C \\cdot \\ell
63
+ $$
64
+
65
+ où :
66
+
67
+ - $A$ est l'absorbance
68
+
69
+ - $\\varepsilon$ est le coefficient d'absorption molaire en $\\textrm{L} \\cdot \\textrm{mol}^{-1} \\cdot \\textrm{cm}^{-1}$
70
+
71
+ - $C$ est la concentration en $\\textrm{mol} \\cdot \\textrm{L}^{-1}$
72
+
73
+ - $\\ell$ : la longueur du trajet optique en $\\textrm{cm}$
63
74
 
64
75
  Réorganisez cette formule pour isoler la variable à trouver.`;
76
+ return hint;
77
+ };
78
+ const getCorrection = (identifiers) => {
79
+ const { moleculeName, concentration, molarAbsorptivity, pathLength, absorbance, targetVariableName, } = identifiers;
80
+ let formula;
81
+ let calcul;
82
+ switch (targetVariableName) {
83
+ case "concentration":
84
+ formula = "C = \\frac{A}{\\varepsilon \\cdot \\ell}";
85
+ calcul = `C = \\frac{${frenchify(absorbance)}}{${frenchify(molarAbsorptivity)} \\cdot ${frenchify(pathLength)}} = ${frenchify(round(absorbance / (molarAbsorptivity * pathLength), 2))}\\ \\text{mol} \\cdot \\text{L}^{-1}`;
86
+ break;
87
+ case "molarAbsorptivity":
88
+ formula = "\\varepsilon = \\frac{A}{C \\cdot \\ell}";
89
+ calcul = `\\varepsilon = \\frac{${frenchify(absorbance)}}{${frenchify(concentration)} \\cdot ${frenchify(pathLength)}} = ${frenchify(round(absorbance / (concentration * pathLength), 1))}\\ \\text{L} \\cdot \\text{mol}^{-1} \\cdot \\text{cm}^{-1}`;
90
+ break;
91
+ case "pathLength":
92
+ formula = "\\ell = \\frac{A}{\\varepsilon \\cdot C}";
93
+ calcul = `\\ell = \\frac{${frenchify(absorbance)}}{${frenchify(molarAbsorptivity)} \\cdot ${frenchify(concentration)}} = ${frenchify(round(absorbance / (molarAbsorptivity * concentration), 1))}\\ \\text{cm}`;
94
+ break;
95
+ case "absorbance":
96
+ default:
97
+ formula = "A = \\varepsilon \\cdot C \\cdot \\ell";
98
+ calcul = `A = ${frenchify(molarAbsorptivity)} \\cdot ${frenchify(concentration)} \\cdot ${frenchify(pathLength)} = ${frenchify(absorbance)}`;
99
+ break;
100
+ }
65
101
  const correction = `La loi de Beer-Lambert est donnée par :
66
102
 
67
103
  $$
68
104
  A = \\varepsilon \\cdot \\ell \\cdot C
69
105
  $$
106
+
107
+ Pour résoudre le problème, nous devons réorganiser la formule pour isoler la variable inconnue. En utilisant les valeurs fournies pour $\\varepsilon$, $C$, et $\\ell$, nous pouvons résoudre pour trouver la variable manquante.
70
108
 
71
- Pour résoudre le problème, nous devons réorganiser la formule pour isoler la variable inconnue. En utilisant les valeurs fournies pour $\\varepsilon$, $C$, et $\\ell$, nous pouvons résoudre pour trouver la variable manquante.
72
-
73
- Si $A$ est l'absorbance, $\\varepsilon$ est le coefficient d'absorption molaire, $C$ est la concentration et $\\ell$ est la longueur du trajet optique, alors:
109
+ Si $A$ est l'absorbance, $\\varepsilon$ est le coefficient d'absorption molaire, $C$ est la concentration et $\\ell$ est la longueur du trajet optique, alors:
74
110
 
75
111
  $$
76
- ${targetVariable.name === "concentration"
77
- ? "C = \\frac{A}{\\varepsilon \\cdot \\ell}"
78
- : ""}
79
- ${targetVariable.name === "molarAbsorptivity"
80
- ? "\\varepsilon = \\frac{A}{C \\cdot \\ell}"
81
- : ""}
82
- ${targetVariable.name === "pathLength"
83
- ? "\\ell = \\frac{A}{\\varepsilon \\cdot C}"
84
- : ""}
85
- ${targetVariable.name === "absorbance"
86
- ? "A = \\varepsilon \\cdot C \\cdot \\ell"
87
- : ""}
112
+ ${formula}
88
113
  $$
89
-
90
- En appliquant les valeurs:
91
-
114
+
115
+ En appliquant les valeurs:
116
+
92
117
  $$
93
- ${targetVariable.name === "concentration"
94
- ? `C = \\frac{${frenchify(absorbance)}}{${frenchify(molarAbsorptivity)} \\cdot ${frenchify(pathLength)}} = ${frenchify(round(absorbance / (molarAbsorptivity * pathLength), 2))}\\ \\text{mol} \\cdot \\text{L}^{-1}`
95
- : ""}
96
- ${targetVariable.name === "molarAbsorptivity"
97
- ? `\\varepsilon = \\frac{${frenchify(absorbance)}}{${frenchify(concentration)} \\cdot ${frenchify(pathLength)}} = ${frenchify(round(absorbance / (concentration * pathLength), 1))}\\ \\text{L} \\cdot \\text{mol}^{-1} \\cdot \\text{cm}^{-1}`
98
- : ""}
99
- ${targetVariable.name === "pathLength"
100
- ? `\\ell = \\frac{${frenchify(absorbance)}}{${frenchify(molarAbsorptivity)} \\cdot ${frenchify(concentration)}} = ${frenchify(round(absorbance / (molarAbsorptivity * concentration), 1))}\\ \\text{cm}`
101
- : ""}
102
- ${targetVariable.name === "absorbance"
103
- ? `A = ${frenchify(molarAbsorptivity)} \\cdot ${frenchify(concentration)} \\cdot ${frenchify(pathLength)} = ${frenchify(absorbance)}`
104
- : ""}
118
+ ${calcul}
105
119
  $$`;
120
+ return correction;
121
+ };
122
+ const getQuestionFromIdentifiers = (identifiers) => {
106
123
  const question = {
107
- answer: targetVariable.value.toTree().toTex(),
108
- instruction,
109
- hint,
110
- correction,
124
+ answer: getAnswer(identifiers),
125
+ instruction: getInstruction(identifiers),
126
+ hint: getHint(identifiers),
127
+ correction: getCorrection(identifiers),
111
128
  keys: [],
112
129
  answerFormat: "tex",
113
- identifiers: {
114
- moleculeName: molecule.name.toLowerCase(),
115
- concentration,
116
- molarAbsorptivity,
117
- pathLength,
118
- absorbance,
119
- randomIndex,
120
- },
130
+ identifiers,
121
131
  };
122
132
  return question;
123
133
  };
134
+ const getBeerLambertRandomValueQuestion = () => {
135
+ const molecule = random(molecules);
136
+ const concentration = round(randfloat(0.01, 0.1), 2); // Concentration in mol/L
137
+ const molarAbsorptivity = round(randfloat(10, 100), 1); // Molar absorptivity in L·mol^-1·cm^-1
138
+ const pathLength = round(randfloat(1, 5), 1); // Path length in cm
139
+ const absorbance = round(concentration * molarAbsorptivity * pathLength, 2); // Absorbance
140
+ const targetVariableName = random([
141
+ "concentration",
142
+ "molarAbsorptivity",
143
+ "pathLength",
144
+ "absorbance",
145
+ ]);
146
+ const identifiers = {
147
+ moleculeName: molecule.name.toLowerCase(),
148
+ concentration,
149
+ molarAbsorptivity,
150
+ pathLength,
151
+ absorbance,
152
+ targetVariableName,
153
+ };
154
+ return getQuestionFromIdentifiers(identifiers);
155
+ };
124
156
  const getPropositions = (n, { answer, concentration, molarAbsorptivity, pathLength, absorbance }) => {
125
157
  const propositions = [];
126
158
  addValidProp(propositions, answer);
@@ -133,31 +165,15 @@ const getPropositions = (n, { answer, concentration, molarAbsorptivity, pathLeng
133
165
  }
134
166
  return shuffleProps(propositions, n);
135
167
  };
136
- const isAnswerValid = (ans, { answer, randomIndex, concentration, molarAbsorptivity, pathLength, absorbance, }) => {
137
- const variables = [
138
- {
139
- name: "concentration",
140
- value: concentration,
141
- unit: "\\text{mol} \\cdot \\text{L}^{-1}",
142
- },
143
- {
144
- name: "molarAbsorptivity",
145
- value: molarAbsorptivity,
146
- unit: "\\text{L} \\cdot \\text{mol}^{-1} \\cdot \\text{cm}^{-1}",
147
- },
148
- { name: "pathLength", value: pathLength, unit: "\\text{cm}" },
149
- { name: "absorbance", value: absorbance, unit: "" },
150
- ];
151
- const validAnswer = variables[randomIndex].value;
168
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
169
+ const validAnswer = getAnswer(identifiers).unfrenchify();
152
170
  const latexs = validAnswer.toTree().toAllValidTexs();
153
171
  return latexs.includes(ans);
154
172
  };
155
173
  export const BeerLambertRandomValueExercise = {
156
174
  id: "beerLambertRandomValue",
157
175
  label: "Utiliser la loi de Beer-Lambert",
158
- levels: ["1reSpé"],
159
176
  isSingleStep: true,
160
- sections: ["Spectrophotométrie"],
161
177
  generator: (nb) => getDistinctQuestions(getBeerLambertRandomValueQuestion, nb),
162
178
  qcmTimer: 60,
163
179
  freeTimer: 60,
@@ -165,4 +181,5 @@ export const BeerLambertRandomValueExercise = {
165
181
  isAnswerValid,
166
182
  subject: "Chimie",
167
183
  hasHintAndCorrection: true,
184
+ getQuestionFromIdentifiers,
168
185
  };
@@ -1 +1 @@
1
- {"version":3,"file":"concentrationCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/dosage/concentrationCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC3B,CAAC;AA6IF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}
1
+ {"version":3,"file":"concentrationCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/dosage/concentrationCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC3B,CAAC;AA6KF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
@@ -4,61 +4,91 @@ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuesti
4
4
  import { round } from "../../../math/utils/round.js";
5
5
  import { randfloat } from "../../../math/utils/random/randfloat.js";
6
6
  import { randint } from "../../../math/utils/random/randint.js";
7
- const getConcentrationCalculationQuestion = () => {
8
- const concentration = round(randfloat(0.1, 2), 2); // Concentration en mol/L
9
- const quantity = round(randfloat(0.1, 5), 2); // Quantité de matière en mol
10
- const volume = round(randfloat(0.1, 2), 2); // Volume en L
11
- const variableIndex = randint(0, 3);
12
- const variables = ["C", "n", "V"];
13
- const variable = variables[variableIndex];
14
- let questionText, answer;
7
+ const getInstruction = (identifiers) => {
8
+ const { concentration, quantity, volume, variable } = identifiers;
15
9
  switch (variable) {
16
10
  case "C":
17
- questionText = `Vous avez une solution contenant une quantité de matière $n = ${frenchify(quantity)}\\ \\text{mol}$ dissoute dans un volume $V = ${frenchify(volume)}\\ \\text{L}$. Déterminez la concentration $[X_i]$ en $\\text{mol.L}^{-1}$ de cette solution.`;
18
- answer = round(quantity / volume, 2);
19
- break;
11
+ return `Vous avez une solution contenant une quantité de matière $n = ${frenchify(quantity)}\\ \\textrm{mol}$ dissoute dans un volume $V = ${frenchify(volume)}\\ \\textrm{L}$.
12
+
13
+ Déterminez la concentration $[X_i]$ en $\\textrm{mol.L}^{-1}$ de cette solution.`;
20
14
  case "n":
21
- questionText = `Vous avez une solution de concentration $[X_i] = ${frenchify(concentration)}\\ \\text{mol.L}^{-1}$ dans un volume $V = ${frenchify(volume)}\\ \\text{L}$. Déterminez la quantité de matière $n$ en $\\text{mol}$ de cette solution.`;
22
- answer = round(concentration * volume, 2);
23
- break;
15
+ return `Vous avez une solution de concentration $[X_i] = ${frenchify(concentration)}\\ \\textrm{mol.L}^{-1}$ dans un volume $V = ${frenchify(volume)}\\ \\textrm{L}$.
16
+
17
+ Déterminez la quantité de matière $n$ en $\\text{mol}$ de cette solution.`;
24
18
  case "V":
25
- questionText = `Vous avez une solution de concentration $[X_i] = ${frenchify(concentration)}\\ \\text{mol.L}^{-1}$ contenant une quantité de matière $n = ${frenchify(quantity)}\\ \\text{mol}$. Déterminez le volume $V$ en $\\text{L}$ de cette solution.`;
26
- answer = round(quantity / concentration, 2);
19
+ return `Vous avez une solution de concentration $[X_i] = ${frenchify(concentration)}\\ \\textrm{mol.L}^{-1}$ contenant une quantité de matière $n = ${frenchify(quantity)}\\ \\textrm{mol}$.
20
+
21
+ Déterminez le volume $V$ en $\\textrm{L}$ de cette solution.`;
27
22
  break;
28
23
  }
24
+ };
25
+ const getAnswer = (identifiers) => {
26
+ const { concentration, quantity, volume, variable } = identifiers;
27
+ switch (variable) {
28
+ case "C":
29
+ return round(quantity / volume, 2).frenchify();
30
+ case "n":
31
+ return round(concentration * volume, 2).frenchify();
32
+ case "V":
33
+ default:
34
+ return round(quantity / concentration, 2).frenchify();
35
+ }
36
+ };
37
+ const getHint = (identifiers) => {
29
38
  const hint = `La concentration en quantité de matière $[X_i]$ d'une espèce chimique en solution est le quotient de la quantité de matière $n$ de soluté par le volume $V_{\\text{solution}}$ de la solution :
30
- $$
31
- [X_i] = \\frac{n}{V_{\\text{solution}}}
32
- $$
33
- Réarrangez cette formule pour isoler la variable à trouver.`;
39
+
40
+ $$
41
+ [X_i] = \\frac{n}{V_{\\text{solution}}}
42
+ $$
43
+
44
+ Réarrange cette formule pour isoler la variable à trouver.`;
45
+ return hint;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { concentration, quantity, volume, variable } = identifiers;
49
+ const answer = getAnswer(identifiers);
34
50
  const correction = `La formule de la concentration est :
35
- $$
36
- [X_i] = \\frac{n}{V}
37
- $$
38
-
51
+
52
+ $$
53
+ [X_i] = \\frac{n}{V}
54
+ $$
55
+
39
56
  Pour résoudre ce problème, nous devons réorganiser la formule pour isoler la variable inconnue.
40
-
57
+
41
58
  ${variable === "C"
42
- ? `$$[X_i] = \\frac{n}{V} = \\frac{${frenchify(quantity)}}{${frenchify(volume)}} = ${frenchify(answer)}\\ \\text{mol.L}^{-1}$$`
59
+ ? `$$[X_i] = \\frac{n}{V} = \\frac{${frenchify(quantity)}}{${frenchify(volume)}} = ${answer}\\ \\text{mol.L}^{-1}$$`
43
60
  : variable === "n"
44
- ? `$$n = [X_i] \\times V = ${frenchify(concentration)} \\times ${frenchify(volume)} = ${frenchify(answer)}\\ \\text{mol}$$`
45
- : `$$V = \\frac{n}{[X_i]} = \\frac{${frenchify(quantity)}}{${frenchify(concentration)}} = ${frenchify(answer)}\\ \\text{L}$$`}`;
61
+ ? `$$n = [X_i] \\times V = ${frenchify(concentration)} \\times ${frenchify(volume)} = ${answer}\\ \\text{mol}$$`
62
+ : `$$V = \\frac{n}{[X_i]} = \\frac{${frenchify(quantity)}}{${frenchify(concentration)}} = ${answer}\\ \\text{L}$$`}`;
63
+ return correction;
64
+ };
65
+ const getQuestionFromIdentifiers = (identifiers) => {
46
66
  const question = {
47
- answer: answer.toTree().toTex(),
48
- instruction: questionText,
49
- hint,
50
- correction,
67
+ answer: getAnswer(identifiers),
68
+ instruction: getInstruction(identifiers),
69
+ hint: getHint(identifiers),
70
+ correction: getCorrection(identifiers),
51
71
  keys: ["C", "n", "V"],
52
72
  answerFormat: "tex",
53
- identifiers: {
54
- concentration,
55
- quantity,
56
- volume,
57
- variable,
58
- },
73
+ identifiers,
59
74
  };
60
75
  return question;
61
76
  };
77
+ const getConcentrationCalculationQuestion = () => {
78
+ const concentration = round(randfloat(0.1, 2), 2); // Concentration en mol/L
79
+ const quantity = round(randfloat(0.1, 5), 2); // Quantité de matière en mol
80
+ const volume = round(randfloat(0.1, 2), 2); // Volume en L
81
+ const variableIndex = randint(0, 3);
82
+ const variables = ["C", "n", "V"];
83
+ const variable = variables[variableIndex];
84
+ const identifiers = {
85
+ concentration,
86
+ quantity,
87
+ volume,
88
+ variable,
89
+ };
90
+ return getQuestionFromIdentifiers(identifiers);
91
+ };
62
92
  const getPropositions = (n, { answer, concentration, quantity, volume, variable }) => {
63
93
  const propositions = [];
64
94
  addValidProp(propositions, answer);
@@ -103,9 +133,7 @@ const isAnswerValid = (ans, { answer, variable, concentration, quantity, volume
103
133
  export const concentrationCalculation = {
104
134
  id: "concentrationCalculation",
105
135
  label: "Calculer la concentration d'un élément dans une solution",
106
- levels: ["1reSpé"],
107
136
  isSingleStep: true,
108
- sections: ["Chimie des solutions"],
109
137
  generator: (nb) => getDistinctQuestions(getConcentrationCalculationQuestion, nb),
110
138
  qcmTimer: 60,
111
139
  freeTimer: 60,
@@ -113,4 +141,5 @@ export const concentrationCalculation = {
113
141
  isAnswerValid,
114
142
  subject: "Chimie",
115
143
  hasHintAndCorrection: true,
144
+ getQuestionFromIdentifiers,
116
145
  };
@@ -1 +1 @@
1
- {"version":3,"file":"concentrationFromMassCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/dosage/concentrationFromMassCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC3B,CAAC;AA2IF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAelE,CAAC"}
1
+ {"version":3,"file":"concentrationFromMassCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/dosage/concentrationFromMassCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC3B,CAAC;AAkLF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAclE,CAAC"}