math-exercises 3.0.66 → 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 (200) 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/interests/compoundInterest.d.ts +12 -0
  106. package/lib/exercises/math/percent/interests/compoundInterest.d.ts.map +1 -0
  107. package/lib/exercises/math/percent/interests/compoundInterest.js +127 -0
  108. package/lib/exercises/math/percent/interests/compoundInterestDuration.d.ts +2 -0
  109. package/lib/exercises/math/percent/interests/compoundInterestDuration.d.ts.map +1 -0
  110. package/lib/exercises/math/percent/interests/compoundInterestDuration.js +166 -0
  111. package/lib/exercises/math/percent/interests/compoundInterestStartValue.d.ts +12 -0
  112. package/lib/exercises/math/percent/interests/compoundInterestStartValue.d.ts.map +1 -0
  113. package/lib/exercises/math/percent/interests/compoundInterestStartValue.js +132 -0
  114. package/lib/exercises/math/percent/interests/index.d.ts +3 -0
  115. package/lib/exercises/math/percent/interests/index.d.ts.map +1 -0
  116. package/lib/exercises/math/percent/interests/index.js +2 -0
  117. package/lib/exercises/math/primitive/constantPrimitive.d.ts.map +1 -1
  118. package/lib/exercises/math/primitive/constantPrimitive.js +0 -2
  119. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  120. package/lib/exercises/math/primitive/polynomialPrimitive.js +4 -0
  121. package/lib/exercises/math/primitive/sinCosPrimitive.d.ts.map +1 -1
  122. package/lib/exercises/math/primitive/sinCosPrimitive.js +25 -12
  123. package/lib/exercises/math/probaStat/binomial/binomialInequation.d.ts.map +1 -1
  124. package/lib/exercises/math/probaStat/binomial/binomialInequation.js +4 -3
  125. package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.d.ts.map +1 -1
  126. package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.js +52 -28
  127. package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.d.ts.map +1 -1
  128. package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.js +59 -39
  129. package/lib/exercises/math/probaStat/diceBasicProbas.d.ts.map +1 -1
  130. package/lib/exercises/math/probaStat/diceBasicProbas.js +1 -4
  131. package/lib/exercises/math/sequences/sequencePlot.d.ts.map +1 -1
  132. package/lib/exercises/math/sequences/sequencePlot.js +59 -32
  133. package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.d.ts.map +1 -1
  134. package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.js +23 -7
  135. package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.d.ts.map +1 -1
  136. package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.js +23 -8
  137. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts +6 -1
  138. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts.map +1 -1
  139. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.js +61 -27
  140. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.d.ts.map +1 -1
  141. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.js +28 -10
  142. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.d.ts.map +1 -1
  143. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.js +43 -17
  144. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.d.ts.map +1 -1
  145. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.js +23 -8
  146. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.d.ts.map +1 -1
  147. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.js +22 -8
  148. package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.d.ts.map +1 -1
  149. package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.js +18 -5
  150. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.d.ts +1 -0
  151. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.d.ts.map +1 -1
  152. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.js +49 -24
  153. package/lib/exercises/pc/chemicalElements/weightPercent.d.ts.map +1 -1
  154. package/lib/exercises/pc/chemicalElements/weightPercent.js +42 -13
  155. package/lib/exercises/pc/chemicalReactions/calculateCombustionEnergy.d.ts.map +1 -1
  156. package/lib/exercises/pc/chemicalReactions/calculateCombustionEnergy.js +26 -9
  157. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.d.ts.map +1 -1
  158. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.js +48 -15
  159. package/lib/exercises/pc/chemicalReactions/identifyLimitingReagent.d.ts.map +1 -1
  160. package/lib/exercises/pc/chemicalReactions/identifyLimitingReagent.js +22 -9
  161. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.d.ts +1 -0
  162. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.d.ts.map +1 -1
  163. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.js +30 -15
  164. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts +7 -2
  165. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts.map +1 -1
  166. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.js +49 -33
  167. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.d.ts +1 -2
  168. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.d.ts.map +1 -1
  169. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.js +104 -67
  170. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts +1 -1
  171. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
  172. package/lib/exercises/pc/dosage/beerLambertRandomValue.js +99 -82
  173. package/lib/exercises/pc/dosage/concentrationCalculation.d.ts.map +1 -1
  174. package/lib/exercises/pc/dosage/concentrationCalculation.js +69 -40
  175. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
  176. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +78 -40
  177. package/lib/exercises/pc/electricity/calculateIntensity.d.ts.map +1 -1
  178. package/lib/exercises/pc/electricity/calculateIntensity.js +23 -19
  179. package/lib/exercises/pc/electricity/calculateIntensityInSerieOrParallel.d.ts.map +1 -1
  180. package/lib/exercises/pc/electricity/calculateIntensityInSerieOrParallel.js +51 -43
  181. package/lib/exercises/pc/electricity/calculateVoltage.d.ts.map +1 -1
  182. package/lib/exercises/pc/electricity/calculateVoltage.js +0 -2
  183. package/lib/exercises/pc/electricity/electricChargeFromIntensity.d.ts.map +1 -1
  184. package/lib/exercises/pc/electricity/electricChargeFromIntensity.js +19 -6
  185. package/lib/exercises/pc/electricity/electricEnergyFromPower.d.ts.map +1 -1
  186. package/lib/exercises/pc/electricity/electricEnergyFromPower.js +16 -6
  187. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.d.ts +1 -0
  188. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.d.ts.map +1 -1
  189. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.js +54 -24
  190. package/lib/exercises/pc/electricity/kirchhoffVoltageLaw.d.ts.map +1 -1
  191. package/lib/exercises/pc/electricity/kirchhoffVoltageLaw.js +44 -44
  192. package/lib/exercises/pc/electricity/ohmLaw.d.ts.map +1 -1
  193. package/lib/exercises/pc/electricity/ohmLaw.js +67 -24
  194. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts +1 -1
  195. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts.map +1 -1
  196. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.js +36 -43
  197. package/lib/index.d.ts +19 -12
  198. package/lib/index.d.ts.map +1 -1
  199. package/lib/latexTester.js +2 -0
  200. package/package.json +1 -1
@@ -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"}
@@ -4,61 +4,100 @@ 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 getConcentrationFromMassCalculationQuestion = () => {
8
- const concentration = round(randfloat(0.1, 2), 2); // Concentration en mol/L
9
- const mass = round(randfloat(0.1, 5), 2); // Concentration en masse en g/L
10
- const molarMass = round(randfloat(10, 200), 2); // Masse molaire en g/mol
11
- const variableIndex = randint(0, 3);
12
- const variables = ["C", "t", "M"];
13
- const variable = variables[variableIndex];
14
- let questionText, answer;
7
+ const getInstruction = (identifiers) => {
8
+ const { concentration, mass, molarMass, variable } = identifiers;
15
9
  switch (variable) {
16
10
  case "C":
17
- questionText = `Vous avez une solution avec une concentration en masse $t = ${frenchify(mass)}\\ \\text{g.L}^{-1}$ et une masse molaire $M = ${frenchify(molarMass)}\\ \\text{g.mol}^{-1}$. Déterminez la concentration $C$ en $\\text{mol.L}^{-1}$ de cette solution.`;
18
- answer = round(mass / molarMass, 2);
19
- break;
11
+ return `Vous avez une solution avec une concentration en masse $t = ${frenchify(mass)}\\ \\textrm{g.L}^{-1}$ et une masse molaire $M = ${frenchify(molarMass)}\\ \\textrm{g.mol}^{-1}$.
12
+
13
+ Déterminez la concentration $C$ en $\\textrm{mol.L}^{-1}$ de cette solution.`;
20
14
  case "t":
21
- questionText = `Vous avez une solution avec une concentration $C = ${frenchify(concentration)}\\ \\text{mol.L}^{-1}$ et une masse molaire $M = ${frenchify(molarMass)}\\ \\text{g.mol}^{-1}$. Déterminez la concentration en masse $t$ en $\\text{g.L}^{-1}$ de cette solution.`;
22
- answer = round(concentration * molarMass, 2);
23
- break;
15
+ return `Vous avez une solution avec une concentration $C = ${frenchify(concentration)}\\ \\textrm{mol.L}^{-1}$ et une masse molaire $M = ${frenchify(molarMass)}\\ \\textrm{g.mol}^{-1}$.
16
+
17
+ Déterminez la concentration en masse $t$ en $\\textrm{g.L}^{-1}$ de cette solution.`;
24
18
  case "M":
25
- questionText = `Vous avez une solution avec une concentration en masse $t = ${frenchify(mass)}\\ \\text{g.L}^{-1}$ et une concentration $C = ${frenchify(concentration)}\\ \\text{mol.L}^{-1}$. Déterminez la masse molaire $M$ en $\\text{g.mol}^{-1}$ de cette solution.`;
26
- answer = round(mass / concentration, 2);
27
- break;
19
+ default:
20
+ return `Vous avez une solution avec une concentration en masse $t = ${frenchify(mass)}\\ \\textrm{g.L}^{-1}$ et une concentration $C = ${frenchify(concentration)}\\ \\textrm{mol.L}^{-1}$.
21
+
22
+ Déterminez la masse molaire $M$ en $\\textrm{g.mol}^{-1}$ de cette solution.`;
28
23
  }
24
+ };
25
+ const getAnswer = (identifiers) => {
26
+ const { concentration, mass, molarMass, variable } = identifiers;
27
+ switch (variable) {
28
+ case "C":
29
+ return round(mass / molarMass, 2).frenchify();
30
+ case "t":
31
+ return round(concentration * molarMass, 2).frenchify();
32
+ case "M":
33
+ default:
34
+ return round(mass / concentration, 2).frenchify();
35
+ }
36
+ };
37
+ const getHint = (identifiers) => {
29
38
  const hint = `La relation entre la concentration en quantité de matière $C$, la concentration en masse $t$, et la masse molaire $M$ est donnée par :
30
- $$
31
- C = \\frac{t}{M}
32
- $$
33
- Réarrangez cette formule pour isoler la variable à trouver.`;
39
+
40
+ $$
41
+ C = \\frac{t}{M}
42
+ $$
43
+
44
+ Réarrange cette formule pour isoler la variable à trouver.`;
45
+ return hint;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { concentration, mass, molarMass, variable } = identifiers;
49
+ const answer = getAnswer(identifiers);
34
50
  const correction = `La relation entre la concentration en quantité de matière, la concentration en masse et la masse molaire est :
35
- $$
36
- C = \\frac{t}{M}
37
- $$
38
51
 
52
+ $$
53
+ C = \\frac{t}{M}
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
- ? `$$C = \\frac{t}{M} = \\frac{${frenchify(mass)}}{${frenchify(molarMass)}} = ${frenchify(answer)}\\ \\text{mol.L}^{-1}$$`
59
+ ? `
60
+ $$
61
+ C = \\frac{t}{M} = \\frac{${frenchify(mass)}}{${frenchify(molarMass)}} = ${answer}\\ \\textrm{mol.L}^{-1}
62
+ $$`
43
63
  : variable === "t"
44
- ? `$$t = C \\times M = ${frenchify(concentration)} \\times ${frenchify(molarMass)} = ${frenchify(answer)}\\ \\text{g.L}^{-1}$$`
45
- : `$$M = \\frac{t}{C} = \\frac{${frenchify(mass)}}{${frenchify(concentration)}} = ${frenchify(answer)}\\ \\text{g.mol}^{-1}$$`}`;
64
+ ? `
65
+ $$
66
+ t = C \\times M = ${frenchify(concentration)} \\times ${frenchify(molarMass)} = ${answer}\\ \\textrm{g.L}^{-1}
67
+ $$`
68
+ : `
69
+ $$
70
+ M = \\frac{t}{C} = \\frac{${frenchify(mass)}}{${frenchify(concentration)}} = ${answer}\\ \\textrm{g.mol}^{-1}
71
+ $$`}`;
72
+ return correction;
73
+ };
74
+ const getQuestionFromIdentifiers = (identifiers) => {
46
75
  const question = {
47
- answer: answer.toTree().toTex(),
48
- instruction: questionText,
49
- hint,
50
- correction,
76
+ answer: getAnswer(identifiers),
77
+ instruction: getInstruction(identifiers),
78
+ hint: getHint(identifiers),
79
+ correction: getCorrection(identifiers),
51
80
  keys: ["C", "t", "M"],
52
81
  answerFormat: "tex",
53
- identifiers: {
54
- concentration,
55
- mass,
56
- molarMass,
57
- variable,
58
- },
82
+ identifiers,
59
83
  };
60
84
  return question;
61
85
  };
86
+ const getConcentrationFromMassCalculationQuestion = () => {
87
+ const concentration = round(randfloat(0.1, 2), 2); // Concentration en mol/L
88
+ const mass = round(randfloat(0.1, 5), 2); // Concentration en masse en g/L
89
+ const molarMass = round(randfloat(10, 200), 2); // Masse molaire en g/mol
90
+ const variableIndex = randint(0, 3);
91
+ const variables = ["C", "t", "M"];
92
+ const variable = variables[variableIndex];
93
+ const identifiers = {
94
+ concentration,
95
+ mass,
96
+ molarMass,
97
+ variable,
98
+ };
99
+ return getQuestionFromIdentifiers(identifiers);
100
+ };
62
101
  const getPropositions = (n, { answer, concentration, mass, molarMass, variable }) => {
63
102
  const propositions = [];
64
103
  addValidProp(propositions, answer);
@@ -101,9 +140,7 @@ const isAnswerValid = (ans, { answer, variable, mass, molarMass, concentration }
101
140
  export const concentrationFromMassCalculation = {
102
141
  id: "concentrationFromMassCalculation",
103
142
  label: "Calculer la concentration à partir de la concentration en masse et la masse molaire",
104
- levels: ["1reSpé"],
105
143
  isSingleStep: true,
106
- sections: ["Chimie des solutions"],
107
144
  generator: (nb) => getDistinctQuestions(getConcentrationFromMassCalculationQuestion, nb),
108
145
  qcmTimer: 60,
109
146
  freeTimer: 60,
@@ -111,4 +148,5 @@ export const concentrationFromMassCalculation = {
111
148
  isAnswerValid,
112
149
  subject: "Chimie",
113
150
  hasHintAndCorrection: true,
151
+ getQuestionFromIdentifiers,
114
152
  };
@@ -1 +1 @@
1
- {"version":3,"file":"calculateIntensity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/calculateIntensity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAqDF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
1
+ {"version":3,"file":"calculateIntensity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/calculateIntensity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4DF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAYpD,CAAC"}
@@ -1,16 +1,33 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../math/utils/random/randint.js";
4
+ const getInstruction = (identifiers) => {
5
+ const { l1, l2 } = identifiers;
6
+ const instruction = `Pour ce circuit schématisé, l'intensité du courant qui traverse la lampe $L_1$ est de $${l1}\\ \\textrm{mA}$, celle traversant la lampe $L_2$ est de $${l2}\\ \\textrm{mA}$.
7
+
8
+ Calculer l'intensité du courant qui traverse la pile.
9
+
10
+ ![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/xpliveV2/activities/quizzes/generator/electricCircuit2.png)`;
11
+ return instruction;
12
+ };
13
+ const getAnswer = (identifiers) => {
14
+ const { l1, l2 } = identifiers;
15
+ return l1 + l2 + "";
16
+ };
4
17
  const getCalculateIntensityQuestion = () => {
5
- const exo = generateExercise();
18
+ const l1 = randint(10, 60);
19
+ const l2 = randint(10, 60);
20
+ const identifiers = { l1, l2 };
21
+ return getQuestionFromIdentifiers(identifiers);
22
+ };
23
+ const getQuestionFromIdentifiers = (identifiers) => {
6
24
  const question = {
7
- answer: exo.answer + "",
8
- instruction: exo.instruction +
9
- `![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/xpliveV2/activities/quizzes/generator/electricCircuit2.png)`,
25
+ answer: getAnswer(identifiers),
26
+ instruction: getInstruction(identifiers),
10
27
  keys: [],
11
28
  // correction: `1 - Calculer l'instensité au bord de la lampe à l'aide de la loi des noeuds : $L_1+L_2=L$ $\\Rightarrow$ $${exo.l1}+${exo.l2}=${exo.answer}$ $mA$`,
12
29
  answerFormat: "tex",
13
- identifiers: { l1: exo.l1, l2: exo.l2 },
30
+ identifiers,
14
31
  };
15
32
  return question;
16
33
  };
@@ -27,31 +44,18 @@ const getPropositions = (n, { answer, l1, l2 }) => {
27
44
  const isAnswerValid = (ans, { answer }) => {
28
45
  return ans === answer;
29
46
  };
30
- const generateExercise = () => {
31
- const l1 = randint(10, 60);
32
- const l2 = randint(10, 60);
33
- const instruction = `Pour ce circuit schématisé, l'intensité du courant qui traverse la lampe $L_1$ est de $${l1}$ $mA$, celle traversant la lampe $L_2$ est de $${l2}$ $mA$. \n \\
34
- Calculer l'intensité du courant qui traverse la pile.`;
35
- return {
36
- instruction,
37
- answer: l1 + l2,
38
- l1,
39
- l2,
40
- };
41
- };
42
47
  const generatePropositions = (l1, l2) => {
43
48
  return [l1 - l2, l1, l2];
44
49
  };
45
50
  export const calculateIntensity = {
46
51
  id: "calculateIntensity",
47
52
  label: "Calcul d'intnsité dans un circuit électrique en parallèle",
48
- levels: ["2nde"],
49
53
  isSingleStep: true,
50
- sections: ["Électricité"],
51
54
  generator: (nb) => getDistinctQuestions(getCalculateIntensityQuestion, nb),
52
55
  qcmTimer: 60,
53
56
  freeTimer: 60,
54
57
  getPropositions,
55
58
  isAnswerValid,
56
59
  subject: "Physique",
60
+ getQuestionFromIdentifiers,
57
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"calculateIntensityInSerieOrParallel.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/calculateIntensityInSerieOrParallel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAkHF,eAAO,MAAM,mCAAmC,EAAE,QAAQ,CAAC,WAAW,CAarE,CAAC"}
1
+ {"version":3,"file":"calculateIntensityInSerieOrParallel.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/calculateIntensityInSerieOrParallel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA4HF,eAAO,MAAM,mCAAmC,EAAE,QAAQ,CAAC,WAAW,CAYrE,CAAC"}