math-exercises 3.0.66 → 3.0.68

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 (203) 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/index.d.ts +1 -0
  106. package/lib/exercises/math/percent/index.d.ts.map +1 -1
  107. package/lib/exercises/math/percent/index.js +1 -0
  108. package/lib/exercises/math/percent/interests/compoundInterest.d.ts +12 -0
  109. package/lib/exercises/math/percent/interests/compoundInterest.d.ts.map +1 -0
  110. package/lib/exercises/math/percent/interests/compoundInterest.js +127 -0
  111. package/lib/exercises/math/percent/interests/compoundInterestDuration.d.ts +2 -0
  112. package/lib/exercises/math/percent/interests/compoundInterestDuration.d.ts.map +1 -0
  113. package/lib/exercises/math/percent/interests/compoundInterestDuration.js +166 -0
  114. package/lib/exercises/math/percent/interests/compoundInterestStartValue.d.ts +12 -0
  115. package/lib/exercises/math/percent/interests/compoundInterestStartValue.d.ts.map +1 -0
  116. package/lib/exercises/math/percent/interests/compoundInterestStartValue.js +132 -0
  117. package/lib/exercises/math/percent/interests/index.d.ts +3 -0
  118. package/lib/exercises/math/percent/interests/index.d.ts.map +1 -0
  119. package/lib/exercises/math/percent/interests/index.js +2 -0
  120. package/lib/exercises/math/primitive/constantPrimitive.d.ts.map +1 -1
  121. package/lib/exercises/math/primitive/constantPrimitive.js +0 -2
  122. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  123. package/lib/exercises/math/primitive/polynomialPrimitive.js +4 -0
  124. package/lib/exercises/math/primitive/sinCosPrimitive.d.ts.map +1 -1
  125. package/lib/exercises/math/primitive/sinCosPrimitive.js +25 -12
  126. package/lib/exercises/math/probaStat/binomial/binomialInequation.d.ts.map +1 -1
  127. package/lib/exercises/math/probaStat/binomial/binomialInequation.js +4 -3
  128. package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.d.ts.map +1 -1
  129. package/lib/exercises/math/probaStat/binomial/expectedValueOfBinomialProba.js +52 -28
  130. package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.d.ts.map +1 -1
  131. package/lib/exercises/math/probaStat/binomial/varianceOfBinomialProba.js +59 -39
  132. package/lib/exercises/math/probaStat/diceBasicProbas.d.ts.map +1 -1
  133. package/lib/exercises/math/probaStat/diceBasicProbas.js +1 -4
  134. package/lib/exercises/math/sequences/sequencePlot.d.ts.map +1 -1
  135. package/lib/exercises/math/sequences/sequencePlot.js +59 -32
  136. package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.d.ts.map +1 -1
  137. package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.js +23 -7
  138. package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.d.ts.map +1 -1
  139. package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.js +23 -8
  140. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts +6 -1
  141. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts.map +1 -1
  142. package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.js +61 -27
  143. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.d.ts.map +1 -1
  144. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.js +28 -10
  145. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.d.ts.map +1 -1
  146. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.js +43 -17
  147. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.d.ts.map +1 -1
  148. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.js +23 -8
  149. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.d.ts.map +1 -1
  150. package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.js +22 -8
  151. package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.d.ts.map +1 -1
  152. package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.js +18 -5
  153. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.d.ts +1 -0
  154. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.d.ts.map +1 -1
  155. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.js +49 -24
  156. package/lib/exercises/pc/chemicalElements/weightPercent.d.ts.map +1 -1
  157. package/lib/exercises/pc/chemicalElements/weightPercent.js +42 -13
  158. package/lib/exercises/pc/chemicalReactions/calculateCombustionEnergy.d.ts.map +1 -1
  159. package/lib/exercises/pc/chemicalReactions/calculateCombustionEnergy.js +26 -9
  160. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.d.ts.map +1 -1
  161. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.js +48 -15
  162. package/lib/exercises/pc/chemicalReactions/identifyLimitingReagent.d.ts.map +1 -1
  163. package/lib/exercises/pc/chemicalReactions/identifyLimitingReagent.js +22 -9
  164. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.d.ts +1 -0
  165. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.d.ts.map +1 -1
  166. package/lib/exercises/pc/chemicalReactions/identifyStoichiometricMixture.js +30 -15
  167. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts +7 -2
  168. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.d.ts.map +1 -1
  169. package/lib/exercises/pc/chemicalReactions/stoichiometricReaction.js +49 -33
  170. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.d.ts +1 -2
  171. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.d.ts.map +1 -1
  172. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.js +104 -67
  173. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts +1 -1
  174. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
  175. package/lib/exercises/pc/dosage/beerLambertRandomValue.js +99 -82
  176. package/lib/exercises/pc/dosage/concentrationCalculation.d.ts.map +1 -1
  177. package/lib/exercises/pc/dosage/concentrationCalculation.js +69 -40
  178. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
  179. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +78 -40
  180. package/lib/exercises/pc/electricity/calculateIntensity.d.ts.map +1 -1
  181. package/lib/exercises/pc/electricity/calculateIntensity.js +23 -19
  182. package/lib/exercises/pc/electricity/calculateIntensityInSerieOrParallel.d.ts.map +1 -1
  183. package/lib/exercises/pc/electricity/calculateIntensityInSerieOrParallel.js +51 -43
  184. package/lib/exercises/pc/electricity/calculateVoltage.d.ts.map +1 -1
  185. package/lib/exercises/pc/electricity/calculateVoltage.js +0 -2
  186. package/lib/exercises/pc/electricity/electricChargeFromIntensity.d.ts.map +1 -1
  187. package/lib/exercises/pc/electricity/electricChargeFromIntensity.js +19 -6
  188. package/lib/exercises/pc/electricity/electricEnergyFromPower.d.ts.map +1 -1
  189. package/lib/exercises/pc/electricity/electricEnergyFromPower.js +16 -6
  190. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.d.ts +1 -0
  191. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.d.ts.map +1 -1
  192. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.js +54 -24
  193. package/lib/exercises/pc/electricity/kirchhoffVoltageLaw.d.ts.map +1 -1
  194. package/lib/exercises/pc/electricity/kirchhoffVoltageLaw.js +44 -44
  195. package/lib/exercises/pc/electricity/ohmLaw.d.ts.map +1 -1
  196. package/lib/exercises/pc/electricity/ohmLaw.js +67 -24
  197. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts +1 -1
  198. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts.map +1 -1
  199. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.js +36 -43
  200. package/lib/index.d.ts +25 -6
  201. package/lib/index.d.ts.map +1 -1
  202. package/lib/latexTester.js +2 -0
  203. package/package.json +1 -1
@@ -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"}
@@ -2,22 +2,35 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercis
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../math/utils/random/randint.js";
4
4
  import { random } from "../../../utils/alea/random.js";
5
+ const getAnswer = (identifiers) => {
6
+ const { l1, l2, isAsking, circuit } = identifiers;
7
+ const l = circuit === "Série" ? l1 : l1 + l2;
8
+ const values = [l, l1, l2];
9
+ const answer = circuit === "Série"
10
+ ? l1.frenchify()
11
+ : values[["L", "L1", "L2"].findIndex((value) => value === isAsking)].frenchify();
12
+ return answer;
13
+ };
5
14
  const getCalculateIntensityInSerieOrParallelQuestion = () => {
6
- const exo = generateExercise();
7
- const schemaIllu = exo.circuit === "Série"
8
- ? " https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/xpliveV2/activities/quizzes/generator/electricCircuit3.png"
9
- : "https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/xpliveV2/activities/quizzes/generator/electricCircuit2.png";
15
+ const l1 = randint(10, 60);
16
+ const isAsking = random(["L", "L1", "L2"]);
17
+ const circuit = random(["Série", "Parallèle", "Parallèle"]);
18
+ const l2 = circuit === "Série" ? l1 : randint(10, 60);
19
+ const identifiers = {
20
+ l1: l1,
21
+ l2: l2,
22
+ isAsking: isAsking,
23
+ circuit: circuit,
24
+ };
25
+ return getQuestionFromIdentifiers(identifiers);
26
+ };
27
+ const getQuestionFromIdentifiers = (identifiers) => {
10
28
  const question = {
11
- answer: exo.answer + "",
12
- instruction: exo.instruction + `![](${schemaIllu})`,
29
+ answer: getAnswer(identifiers),
30
+ instruction: getInstruction(identifiers),
13
31
  keys: [],
14
32
  answerFormat: "tex",
15
- identifiers: {
16
- l1: exo.l1,
17
- l2: exo.l2,
18
- isAsking: exo.isAsking,
19
- circuit: exo.circuit,
20
- },
33
+ identifiers,
21
34
  };
22
35
  return question;
23
36
  };
@@ -34,41 +47,37 @@ const getPropositions = (n, { answer, isAsking, circuit, l1, l2 }) => {
34
47
  const isAnswerValid = (ans, { answer }) => {
35
48
  return ans === answer;
36
49
  };
37
- const generateExercise = () => {
38
- const l1 = randint(10, 60);
39
- const isAsking = random(["L", "L1", "L2"]);
40
- const circuit = random(["Série", "Parallèle", "Parallèle"]);
41
- const l2 = circuit === "Série" ? l1 : randint(10, 60);
50
+ const getInstruction = (identifiers) => {
51
+ const { l1, l2, isAsking, circuit } = identifiers;
42
52
  const l = circuit === "Série" ? l1 : l1 + l2;
43
- const values = [l, l1, l2];
44
- const instruction = getInstruction(isAsking, circuit, l1, l2, l);
45
- const answer = circuit === "Série"
46
- ? l1
47
- : values[["L", "L1", "L2"].findIndex((value) => value === isAsking)];
48
- return {
49
- instruction,
50
- answer,
51
- l1,
52
- l2,
53
- l,
54
- isAsking,
55
- circuit,
56
- };
57
- };
58
- const getInstruction = (isAsking, circuit, l1, l2, l) => {
53
+ const schemaIllu = circuit === "Série"
54
+ ? "![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/xpliveV2/activities/quizzes/generator/electricCircuit3.png)"
55
+ : "![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/xpliveV2/activities/quizzes/generator/electricCircuit2.png)";
59
56
  if (circuit === "Série")
60
- return `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 \\
61
- Calculer l'intensité du courant qui traverse la pile en $mA$.`;
57
+ return `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}$.
58
+
59
+ Calculer l'intensité du courant qui traverse la pile en $mA$.
60
+
61
+ ${schemaIllu}`;
62
62
  switch (isAsking) {
63
63
  case "L":
64
- return `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 \\
65
- Calculer l'intensité du courant qui traverse la pile en $mA$.`;
64
+ return `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}$.
65
+
66
+ Calculer l'intensité du courant qui traverse la pile en $mA$.
67
+
68
+ ${schemaIllu}`;
66
69
  case "L1":
67
- return `Pour ce circuit schématisé, l'intensité du courant qui traverse la lampe $L_2$ est de $${l2}$ $mA$, celle traversant la pile est de $${l}$ $mA$. \n \\
68
- Calculer l'intensité du courant qui traverse la lampe $L_1$ en $mA$.`;
70
+ return `Pour ce circuit schématisé, l'intensité du courant qui traverse la lampe $L_2$ est de $${l2}\\ \\textrm{mA}$, celle traversant la pile est de $${l}\\ \\textrm{mA}$.
71
+
72
+ Calculer l'intensité du courant qui traverse la lampe $L_1$ en $mA$.
73
+
74
+ ${schemaIllu}`;
69
75
  case "L2":
70
- return `Pour ce circuit schématisé, l'intensité du courant qui traverse la lampe $L_1$ est de $${l1}$ $mA$, celle traversant la pile est de $${l}$ $mA$. \n \\
71
- Calculer l'intensité du courant qui traverse la lampe $L_2$ en $mA$.`;
76
+ return `Pour ce circuit schématisé, l'intensité du courant qui traverse la lampe $L_1$ est de $${l1}\\ \\textrm{mA}$, celle traversant la pile est de $${l}\\ \\textrm{mA}$.
77
+
78
+ Calculer l'intensité du courant qui traverse la lampe $L_2$ en $mA$.
79
+
80
+ ${schemaIllu}`;
72
81
  default:
73
82
  return "";
74
83
  }
@@ -90,13 +99,12 @@ const generatePropositions = (l1, l2, isAsking, circuit) => {
90
99
  export const calculateIntensityInSerieOrParallel = {
91
100
  id: "calculateIntensityInSerieOrParallel",
92
101
  label: "Calcul d'intnsité dans un circuit électrique en série/parallèle",
93
- levels: ["1reSpé"],
94
102
  isSingleStep: true,
95
- sections: ["Électricité"],
96
103
  generator: (nb) => getDistinctQuestions(getCalculateIntensityInSerieOrParallelQuestion, nb),
97
104
  qcmTimer: 60,
98
105
  freeTimer: 60,
99
106
  getPropositions,
100
107
  isAnswerValid,
101
108
  subject: "Physique",
109
+ getQuestionFromIdentifiers,
102
110
  };
@@ -1 +1 @@
1
- {"version":3,"file":"calculateVoltage.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/calculateVoltage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAiKF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"calculateVoltage.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/calculateVoltage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAiKF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAYlD,CAAC"}
@@ -128,9 +128,7 @@ $U=E-r \\cdot I\\ \\Rightarrow\\ U=${answer}\\ V$`;
128
128
  export const calculateVoltage = {
129
129
  id: "calculateVoltage",
130
130
  label: "Calcul de tension au borne d'une résistance",
131
- levels: ["2nde"],
132
131
  isSingleStep: true,
133
- sections: ["Électricité"],
134
132
  generator: (nb) => getDistinctQuestions(getCalculateVoltageQuestion, nb),
135
133
  qcmTimer: 60,
136
134
  freeTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"electricChargeFromIntensity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/electricChargeFromIntensity.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAqD1D,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAa7D,CAAC"}
1
+ {"version":3,"file":"electricChargeFromIntensity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/electricChargeFromIntensity.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAsE1D,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAY7D,CAAC"}
@@ -3,16 +3,30 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercis
3
3
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { randfloat } from "../../../math/utils/random/randfloat.js";
6
+ const getAnswer = (identifiers) => {
7
+ const { intensity, seconds } = identifiers;
8
+ const electricCharge = intensity * seconds;
9
+ return roundSignificant(electricCharge, 1);
10
+ };
11
+ const getInstruction = (identifiers) => {
12
+ const { intensity, seconds } = identifiers;
13
+ return `Un conducteur électrique est parcouru par un courant d'intensité $${roundSignificant(intensity, 1)}\\ \\textrm{A}$.
14
+
15
+ Calculer la charge électrique $\\text{Q}$ (en $\\textrm{C}$) ayant traversé la section de ce conducteur durant $${seconds}\\ \\textrm{s}$.`;
16
+ };
6
17
  const getElectricChargeFromIntensityQuestion = () => {
7
18
  const intensity = randfloat(0.1, 6, 1);
8
19
  const seconds = randint(1, 30);
9
- const electricCharge = intensity * seconds;
20
+ const identifiers = { intensity, seconds };
21
+ return getQuestionFromIdentifiers(identifiers);
22
+ };
23
+ const getQuestionFromIdentifiers = (identifiers) => {
10
24
  const question = {
11
- answer: roundSignificant(electricCharge, 1),
12
- instruction: `Un conducteur électrique est parcouru par un courant d'intensité $${roundSignificant(intensity, 1)}\\ \\text{A}$. Calculer la charge électrique $\\text{Q}$ (en $\\text{C}$) ayant traversé la section de ce conducteur durant $${seconds}\\ \\text{s}$.`,
25
+ answer: getAnswer(identifiers),
26
+ instruction: getInstruction(identifiers),
13
27
  keys: [],
14
28
  answerFormat: "tex",
15
- identifiers: { intensity, seconds },
29
+ identifiers,
16
30
  };
17
31
  return question;
18
32
  };
@@ -36,13 +50,12 @@ const isAnswerValid = (ans, { answer }) => {
36
50
  export const electricChargeFromIntensity = {
37
51
  id: "electricChargeFromIntensity",
38
52
  label: "Calculer une charge électrique",
39
- levels: ["1reSpé"],
40
53
  isSingleStep: true,
41
- sections: ["Électricité"],
42
54
  generator: (nb) => getDistinctQuestions(getElectricChargeFromIntensityQuestion, nb),
43
55
  qcmTimer: 60,
44
56
  freeTimer: 60,
45
57
  getPropositions,
46
58
  isAnswerValid,
47
59
  subject: "Physique",
60
+ getQuestionFromIdentifiers,
48
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"electricEnergyFromPower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/electricEnergyFromPower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AA8BrC,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAiDtD,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAazD,CAAC"}
1
+ {"version":3,"file":"electricEnergyFromPower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/electricEnergyFromPower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AA8BrC,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAgEtD,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAWzD,CAAC"}
@@ -24,16 +24,28 @@ import { random } from "../../../utils/alea/random.js";
24
24
  // ];
25
25
  // const durations = [{label: "année",gender: "feminine", valueInSeconds: }]
26
26
  const powers = [15, 18, 50, 25, 65, 66, 7.5, 10];
27
+ const getInstruction = (identifiers) => {
28
+ const { power, seconds } = identifiers;
29
+ return `Un chargeur a une puissance maximale de $${power}\\ \\text{W}$. Calculer l'énergie électrique qu'il fournit durant $${seconds}\\ \\text{s}$ de fonctionnement (en $\\text{J}$).`;
30
+ };
31
+ const getAnswer = (identifiers) => {
32
+ const { power, seconds } = identifiers;
33
+ const energy = power * seconds;
34
+ return `${energy.toScientific(0).toTex({ scientific: 0 })}`;
35
+ };
27
36
  const getElectricEnergyFromPowerQuestion = () => {
28
37
  const power = random(powers);
29
38
  const seconds = randint(10, 61);
30
- const energy = power * seconds;
39
+ const identifiers = { power, seconds };
40
+ return getQuestionFromIdentifiers(identifiers);
41
+ };
42
+ const getQuestionFromIdentifiers = (identifiers) => {
31
43
  const question = {
32
- answer: `${energy.toScientific(0).toTex({ scientific: 0 })}`,
33
- instruction: `Un chargeur a une puissance maximale de $${power}\\ \\text{W}$. Calculer l'énergie électrique qu'il fournit durant $${seconds}\\ \\text{s}$ de fonctionnement (en $\\text{J}$).`,
44
+ answer: getAnswer(identifiers),
45
+ instruction: getInstruction(identifiers),
34
46
  keys: ["timesTenPower"],
35
47
  answerFormat: "tex",
36
- identifiers: { power, seconds },
48
+ identifiers,
37
49
  };
38
50
  return question;
39
51
  };
@@ -54,9 +66,7 @@ const isAnswerValid = (ans, { answer }) => {
54
66
  export const electricEnergyFromPower = {
55
67
  id: "electricEnergyFromPower",
56
68
  label: "Calculer une énergie électrique",
57
- levels: ["1reSpé"],
58
69
  isSingleStep: true,
59
- sections: ["Électricité"],
60
70
  generator: (nb) => getDistinctQuestions(getElectricEnergyFromPowerQuestion, nb),
61
71
  qcmTimer: 60,
62
72
  freeTimer: 60,
@@ -3,6 +3,7 @@ type Identifiers = {
3
3
  power: number;
4
4
  seconds: number;
5
5
  energy: number;
6
+ isCalculatingEnergy: boolean;
6
7
  };
7
8
  export declare const electricPowerOrEnergyCalculation: Exercise<Identifiers>;
8
9
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"electricPowerOrEnergyCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/electricPowerOrEnergyCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAwFtE,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAclE,CAAC"}
1
+ {"version":3,"file":"electricPowerOrEnergyCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/electricPowerOrEnergyCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAsHF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
@@ -7,38 +7,69 @@ import { randfloat } from "../../../math/utils/random/randfloat.js";
7
7
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
8
8
  const powers = [15, 18, 50, 25, 65, 66, 7.5, 10]; // Puissances en watts
9
9
  const durations = [60, 3600, 86400, 604800]; // Durées en secondes (1 min, 1 h, 1 jour, 1 semaine)
10
- const getElectricPowerOrEnergyQuestion = () => {
11
- const power = random(powers);
12
- const seconds = random(durations);
13
- const energy = power * seconds;
14
- const isCalculatingEnergy = coinFlip();
10
+ const getInstruction = (identifiers) => {
11
+ const { power, seconds, energy, isCalculatingEnergy } = identifiers;
15
12
  const questionText = isCalculatingEnergy
16
- ? `Un appareil a une puissance de $P = ${frenchify(power)}\\ \\text{W}$ et fonctionne pendant $t = ${frenchify(seconds)}\\ \\text{s}$. Calculez l'énergie électrique $E$ en $\\text{J}$ fournie par cet appareil.`
17
- : `Un appareil consomme une énergie $E = ${frenchify(energy)}\\ \\text{J}$ en $t = ${frenchify(seconds)}\\ \\text{s}$. Calculez la puissance $P$ en $\\text{W}$ de cet appareil.`;
18
- const answer = isCalculatingEnergy ? energy : round(energy / seconds, 2);
13
+ ? `Un appareil a une puissance de $P = ${frenchify(power)}\\ \\textrm{W}$ et fonctionne pendant $t = ${frenchify(seconds)}\\ \\textrm{s}$.
14
+
15
+ Calculer l'énergie électrique $E$ en $\\textrm{J}$ fournie par cet appareil.`
16
+ : `Un appareil consomme une énergie $E = ${frenchify(energy)}\\ \\textrm{J}$ en $t = ${frenchify(seconds)}\\ \\textrm{s}$.
17
+
18
+ Calculez la puissance $P$ en $\\textrm{W}$ de cet appareil.`;
19
+ return questionText;
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { power, seconds, energy, isCalculatingEnergy } = identifiers;
23
+ const answer = isCalculatingEnergy
24
+ ? energy.frenchify()
25
+ : round(energy / seconds, 2).frenchify();
26
+ return answer;
27
+ };
28
+ const getHint = (identifiers) => {
19
29
  const hint = `La relation entre l'énergie électrique, la puissance et le temps est donnée par la formule :
20
- $$
21
- E = P \\times t
22
- $$
23
- Réarrangez cette formule pour isoler la variable à trouver.`;
30
+
31
+ $$
32
+ E = P \\times t
33
+ $$
34
+
35
+ Réarrangez cette formule pour isoler la variable à trouver.`;
36
+ return hint;
37
+ };
38
+ const getCorrection = (identifiers) => {
39
+ const { power, seconds, energy, isCalculatingEnergy } = identifiers;
40
+ const answer = getAnswer(identifiers);
24
41
  const correction = `La relation entre l'énergie électrique, la puissance et le temps est :
25
- $$
26
- E = P \\times t
27
- $$
42
+
43
+ $$
44
+ E = P \\times t
45
+ $$
28
46
 
29
47
  Pour résoudre ce problème, nous devons réorganiser la formule pour isoler la variable inconnue.
30
48
 
49
+ $$
31
50
  ${isCalculatingEnergy
32
- ? `$$E = P \\times t = ${frenchify(power)} \\times ${frenchify(seconds)} = ${frenchify(answer)}\\ \\text{J}$$`
33
- : `$$P = \\frac{E}{t} = \\frac{${frenchify(energy)}}{${frenchify(seconds)}} = ${frenchify(answer)}\\ \\text{W}$$`}`;
51
+ ? `E = P \\times t = ${frenchify(power)} \\times ${frenchify(seconds)} = ${answer}\\ \\textrm{J}`
52
+ : `P = \\frac{E}{t} = \\frac{${frenchify(energy)}}{${frenchify(seconds)}} = ${answer}\\ \\textrm{W}`}
53
+ $$`;
54
+ return correction;
55
+ };
56
+ const getElectricPowerOrEnergyQuestion = () => {
57
+ const power = random(powers);
58
+ const seconds = random(durations);
59
+ const energy = power * seconds;
60
+ const isCalculatingEnergy = coinFlip();
61
+ const identifiers = { power, seconds, energy, isCalculatingEnergy };
62
+ return getQuestionFromIdentifiers(identifiers);
63
+ };
64
+ const getQuestionFromIdentifiers = (identifiers) => {
34
65
  const question = {
35
- answer: answer.toTree().toTex(),
36
- instruction: questionText,
37
- hint,
38
- correction,
66
+ answer: getAnswer(identifiers),
67
+ instruction: getInstruction(identifiers),
68
+ hint: getHint(identifiers),
69
+ correction: getCorrection(identifiers),
39
70
  keys: ["P", "E", "t"],
40
71
  answerFormat: "tex",
41
- identifiers: { power, seconds, energy },
72
+ identifiers,
42
73
  };
43
74
  return question;
44
75
  };
@@ -65,9 +96,7 @@ const isAnswerValid = (ans, { answer }) => {
65
96
  export const electricPowerOrEnergyCalculation = {
66
97
  id: "electricPowerOrEnergyCalculation",
67
98
  label: "Calculer la puissance ou l'énergie électrique",
68
- levels: ["1reSpé"],
69
99
  isSingleStep: true,
70
- sections: ["Électricité"],
71
100
  generator: (nb) => getDistinctQuestions(getElectricPowerOrEnergyQuestion, nb),
72
101
  qcmTimer: 60,
73
102
  freeTimer: 60,
@@ -75,4 +104,5 @@ export const electricPowerOrEnergyCalculation = {
75
104
  isAnswerValid,
76
105
  subject: "Physique",
77
106
  hasHintAndCorrection: true,
107
+ getQuestionFromIdentifiers,
78
108
  };
@@ -1 +1 @@
1
- {"version":3,"file":"kirchhoffVoltageLaw.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/kirchhoffVoltageLaw.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAoHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAarD,CAAC"}
1
+ {"version":3,"file":"kirchhoffVoltageLaw.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/electricity/kirchhoffVoltageLaw.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAgHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAYrD,CAAC"}