math-exercises 3.0.125 → 3.0.126

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 (291) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +61 -1
  3. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +1 -0
  4. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/mentalCaluls/index.js +1 -0
  6. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts +15 -0
  7. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -0
  8. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +217 -0
  9. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts +16 -0
  10. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts.map +1 -0
  11. package/lib/exercises/math/calcul/ordering/compareA10N.js +327 -0
  12. package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.d.ts +8 -0
  13. package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.d.ts.map +1 -0
  14. package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.js +221 -0
  15. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts +9 -0
  16. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts.map +1 -0
  17. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.js +135 -0
  18. package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts +29 -0
  19. package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts.map +1 -0
  20. package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +367 -0
  21. package/lib/exercises/math/calcul/ordering/comparePowersOfFracs.d.ts +12 -0
  22. package/lib/exercises/math/calcul/ordering/comparePowersOfFracs.d.ts.map +1 -0
  23. package/lib/exercises/math/calcul/ordering/comparePowersOfFracs.js +164 -0
  24. package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.d.ts +9 -0
  25. package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.d.ts.map +1 -0
  26. package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.js +140 -0
  27. package/lib/exercises/math/calcul/ordering/index.d.ts +6 -0
  28. package/lib/exercises/math/calcul/ordering/index.d.ts.map +1 -1
  29. package/lib/exercises/math/calcul/ordering/index.js +6 -0
  30. package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.d.ts +9 -0
  31. package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.d.ts.map +1 -0
  32. package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.js +84 -0
  33. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts +8 -0
  34. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts.map +1 -0
  35. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.js +90 -0
  36. package/lib/exercises/math/calcul/rounding/index.d.ts +2 -0
  37. package/lib/exercises/math/calcul/rounding/index.d.ts.map +1 -1
  38. package/lib/exercises/math/calcul/rounding/index.js +2 -0
  39. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts +13 -0
  40. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -0
  41. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +414 -0
  42. package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
  43. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  44. package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
  45. package/lib/exercises/math/calculLitteral/factorisation/factorizeAX2PlusBX.d.ts +10 -0
  46. package/lib/exercises/math/calculLitteral/factorisation/factorizeAX2PlusBX.d.ts.map +1 -0
  47. package/lib/exercises/math/calculLitteral/factorisation/factorizeAX2PlusBX.js +70 -0
  48. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +1 -0
  49. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
  50. package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -0
  51. package/lib/exercises/math/calculLitteral/index.d.ts +2 -0
  52. package/lib/exercises/math/calculLitteral/index.d.ts.map +1 -1
  53. package/lib/exercises/math/calculLitteral/index.js +2 -0
  54. package/lib/exercises/math/calculLitteral/isolate/index.d.ts +2 -1
  55. package/lib/exercises/math/calculLitteral/isolate/index.d.ts.map +1 -1
  56. package/lib/exercises/math/calculLitteral/isolate/index.js +2 -1
  57. package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.d.ts +8 -0
  58. package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.d.ts.map +1 -0
  59. package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.js +107 -0
  60. package/lib/exercises/math/calculLitteral/isolate/isolateXInInvXPlusInvYEqualsInvU.d.ts +7 -0
  61. package/lib/exercises/math/calculLitteral/isolate/isolateXInInvXPlusInvYEqualsInvU.d.ts.map +1 -0
  62. package/lib/exercises/math/calculLitteral/isolate/isolateXInInvXPlusInvYEqualsInvU.js +80 -0
  63. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.d.ts +10 -0
  64. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.d.ts.map +1 -0
  65. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.js +182 -0
  66. package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.d.ts +9 -0
  67. package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.d.ts.map +1 -0
  68. package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.js +144 -0
  69. package/lib/exercises/math/calculLitteral/ordering/index.d.ts +3 -0
  70. package/lib/exercises/math/calculLitteral/ordering/index.d.ts.map +1 -0
  71. package/lib/exercises/math/calculLitteral/ordering/index.js +2 -0
  72. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts +11 -0
  73. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts.map +1 -0
  74. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.js +120 -0
  75. package/lib/exercises/math/calculLitteral/simplifying/compareFracXA.d.ts +8 -0
  76. package/lib/exercises/math/calculLitteral/simplifying/compareFracXA.d.ts.map +1 -0
  77. package/lib/exercises/math/calculLitteral/simplifying/compareFracXA.js +67 -0
  78. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.d.ts +11 -0
  79. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.d.ts.map +1 -0
  80. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +114 -0
  81. package/lib/exercises/math/calculLitteral/simplifying/index.d.ts +5 -0
  82. package/lib/exercises/math/calculLitteral/simplifying/index.d.ts.map +1 -1
  83. package/lib/exercises/math/calculLitteral/simplifying/index.js +5 -0
  84. package/lib/exercises/math/calculLitteral/simplifying/pickSameAsAPercentOfB.d.ts +13 -0
  85. package/lib/exercises/math/calculLitteral/simplifying/pickSameAsAPercentOfB.d.ts.map +1 -0
  86. package/lib/exercises/math/calculLitteral/simplifying/pickSameAsAPercentOfB.js +125 -0
  87. package/lib/exercises/math/calculLitteral/simplifying/pickSameAsInverseOfFracAB.d.ts +14 -0
  88. package/lib/exercises/math/calculLitteral/simplifying/pickSameAsInverseOfFracAB.d.ts.map +1 -0
  89. package/lib/exercises/math/calculLitteral/simplifying/pickSameAsInverseOfFracAB.js +148 -0
  90. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts +5 -27
  91. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts.map +1 -1
  92. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.js +178 -241
  93. package/lib/exercises/math/conversion/index.d.ts +4 -0
  94. package/lib/exercises/math/conversion/index.d.ts.map +1 -1
  95. package/lib/exercises/math/conversion/index.js +4 -0
  96. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.d.ts +8 -0
  97. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.d.ts.map +1 -0
  98. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.js +98 -0
  99. package/lib/exercises/math/conversion/minutesToHours.d.ts +10 -0
  100. package/lib/exercises/math/conversion/minutesToHours.d.ts.map +1 -0
  101. package/lib/exercises/math/conversion/minutesToHours.js +150 -0
  102. package/lib/exercises/math/conversion/prefixToNumber.d.ts +15 -0
  103. package/lib/exercises/math/conversion/prefixToNumber.d.ts.map +1 -0
  104. package/lib/exercises/math/conversion/prefixToNumber.js +233 -0
  105. package/lib/exercises/math/conversion/secondsToHours.d.ts +10 -0
  106. package/lib/exercises/math/conversion/secondsToHours.d.ts.map +1 -0
  107. package/lib/exercises/math/conversion/secondsToHours.js +150 -0
  108. package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts +50 -0
  109. package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -0
  110. package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +517 -0
  111. package/lib/exercises/math/dataRepresentations/boxPlotInterpreting.d.ts +7 -0
  112. package/lib/exercises/math/dataRepresentations/boxPlotInterpreting.d.ts.map +1 -0
  113. package/lib/exercises/math/dataRepresentations/boxPlotInterpreting.js +223 -0
  114. package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.d.ts +10 -0
  115. package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.d.ts.map +1 -0
  116. package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.js +139 -0
  117. package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.d.ts +8 -0
  118. package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.d.ts.map +1 -0
  119. package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.js +133 -0
  120. package/lib/exercises/math/dataRepresentations/graphReading.d.ts +8 -0
  121. package/lib/exercises/math/dataRepresentations/graphReading.d.ts.map +1 -0
  122. package/lib/exercises/math/dataRepresentations/graphReading.js +136 -0
  123. package/lib/exercises/math/dataRepresentations/halfPieChartCommenting.d.ts +18 -0
  124. package/lib/exercises/math/dataRepresentations/halfPieChartCommenting.d.ts.map +1 -0
  125. package/lib/exercises/math/dataRepresentations/halfPieChartCommenting.js +228 -0
  126. package/lib/exercises/math/dataRepresentations/halfPieChartReading.d.ts +8 -0
  127. package/lib/exercises/math/dataRepresentations/halfPieChartReading.d.ts.map +1 -0
  128. package/lib/exercises/math/dataRepresentations/halfPieChartReading.js +213 -0
  129. package/lib/exercises/math/dataRepresentations/histogramReading.d.ts +9 -0
  130. package/lib/exercises/math/dataRepresentations/histogramReading.d.ts.map +1 -0
  131. package/lib/exercises/math/dataRepresentations/histogramReading.js +163 -0
  132. package/lib/exercises/math/dataRepresentations/index.d.ts +10 -0
  133. package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
  134. package/lib/exercises/math/dataRepresentations/index.js +10 -0
  135. package/lib/exercises/math/dataRepresentations/plausibleGraph.d.ts +9 -0
  136. package/lib/exercises/math/dataRepresentations/plausibleGraph.d.ts.map +1 -0
  137. package/lib/exercises/math/dataRepresentations/plausibleGraph.js +145 -0
  138. package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.d.ts +9 -0
  139. package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.d.ts.map +1 -0
  140. package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.js +308 -0
  141. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.d.ts.map +1 -1
  142. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.js +5 -6
  143. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts +8 -0
  144. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts.map +1 -0
  145. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.js +103 -0
  146. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.d.ts +8 -0
  147. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.d.ts.map +1 -0
  148. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.js +100 -0
  149. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.d.ts +16 -0
  150. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.d.ts.map +1 -0
  151. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.js +215 -0
  152. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts +13 -0
  153. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts.map +1 -0
  154. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.js +206 -0
  155. package/lib/exercises/math/functions/affines/index.d.ts +7 -0
  156. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  157. package/lib/exercises/math/functions/affines/index.js +7 -0
  158. package/lib/exercises/math/functions/affines/recognizeExprAffine.d.ts +20 -0
  159. package/lib/exercises/math/functions/affines/recognizeExprAffine.d.ts.map +1 -0
  160. package/lib/exercises/math/functions/affines/recognizeExprAffine.js +284 -0
  161. package/lib/exercises/math/functions/affines/representationOfAffine.d.ts +13 -0
  162. package/lib/exercises/math/functions/affines/representationOfAffine.d.ts.map +1 -0
  163. package/lib/exercises/math/functions/affines/representationOfAffine.js +184 -0
  164. package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.d.ts +14 -0
  165. package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.d.ts.map +1 -0
  166. package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.js +216 -0
  167. package/lib/exercises/math/functions/basics/index.d.ts +1 -0
  168. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  169. package/lib/exercises/math/functions/basics/index.js +1 -0
  170. package/lib/exercises/math/functions/composition/functionComposition.d.ts +8 -0
  171. package/lib/exercises/math/functions/composition/functionComposition.d.ts.map +1 -0
  172. package/lib/exercises/math/functions/composition/functionComposition.js +238 -0
  173. package/lib/exercises/math/functions/composition/index.d.ts +2 -0
  174. package/lib/exercises/math/functions/composition/index.d.ts.map +1 -0
  175. package/lib/exercises/math/functions/composition/index.js +1 -0
  176. package/lib/exercises/math/functions/index.d.ts +1 -0
  177. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  178. package/lib/exercises/math/functions/index.js +1 -0
  179. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts +23 -0
  180. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -0
  181. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +448 -0
  182. package/lib/exercises/math/geometry/angles/index.js +2 -0
  183. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts +23 -0
  184. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts.map +1 -0
  185. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.js +402 -0
  186. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts +9 -6
  187. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
  188. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +140 -60
  189. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.js +1 -1
  190. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts.map +1 -1
  191. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.js +121 -104
  192. package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts.map +1 -1
  193. package/lib/exercises/math/geometry/vectors/vectorRepresentative.js +3 -2
  194. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +1 -0
  195. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
  196. package/lib/exercises/math/probaStat/basicProbas/index.js +1 -0
  197. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.d.ts +0 -1
  198. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.d.ts.map +1 -1
  199. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +42 -80
  200. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.d.ts +9 -0
  201. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.d.ts.map +1 -0
  202. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.js +217 -0
  203. package/lib/exercises/math/probaStat/index.d.ts +2 -0
  204. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  205. package/lib/exercises/math/probaStat/index.js +2 -0
  206. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts +30 -0
  207. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts.map +1 -0
  208. package/lib/exercises/math/probaStat/probaAsSumOfProbas.js +548 -0
  209. package/lib/exercises/math/probaStat/stats1var/index.d.ts +2 -0
  210. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  211. package/lib/exercises/math/probaStat/stats1var/index.js +2 -0
  212. package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.d.ts +9 -0
  213. package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.d.ts.map +1 -0
  214. package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.js +90 -0
  215. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts +10 -0
  216. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts.map +1 -0
  217. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +151 -0
  218. package/lib/exercises/pc/electricity/calculateUEqualsRI.d.ts +7 -0
  219. package/lib/exercises/pc/electricity/calculateUEqualsRI.d.ts.map +1 -0
  220. package/lib/exercises/pc/electricity/calculateUEqualsRI.js +73 -0
  221. package/lib/exercises/pc/electricity/index.d.ts +1 -0
  222. package/lib/exercises/pc/electricity/index.d.ts.map +1 -1
  223. package/lib/exercises/pc/electricity/index.js +1 -0
  224. package/lib/exercises/pc/index.d.ts +1 -0
  225. package/lib/exercises/pc/index.d.ts.map +1 -1
  226. package/lib/exercises/pc/index.js +1 -0
  227. package/lib/exercises/pc/moleculeFormula.d.ts.map +1 -1
  228. package/lib/exercises/pc/moleculeFormula.js +4 -3
  229. package/lib/exercises/pc/optics/index.d.ts +2 -0
  230. package/lib/exercises/pc/optics/index.d.ts.map +1 -0
  231. package/lib/exercises/pc/optics/index.js +1 -0
  232. package/lib/exercises/pc/optics/lensFormula.d.ts +21 -0
  233. package/lib/exercises/pc/optics/lensFormula.d.ts.map +1 -0
  234. package/lib/exercises/pc/optics/lensFormula.js +415 -0
  235. package/lib/exercises/pc/weight/calculateWeight.d.ts +8 -1
  236. package/lib/exercises/pc/weight/calculateWeight.d.ts.map +1 -1
  237. package/lib/exercises/pc/weight/calculateWeight.js +113 -38
  238. package/lib/geogebra/parsers/geogebraParser.d.ts +4 -0
  239. package/lib/geogebra/parsers/geogebraParser.d.ts.map +1 -1
  240. package/lib/geogebra/parsers/geogebraParser.js +17 -0
  241. package/lib/index.d.ts +346 -12
  242. package/lib/index.d.ts.map +1 -1
  243. package/lib/latexTester.d.ts.map +1 -1
  244. package/lib/latexTester.js +1 -0
  245. package/lib/math/geometry/CloudPoints.d.ts +10 -0
  246. package/lib/math/geometry/CloudPoints.d.ts.map +1 -1
  247. package/lib/math/geometry/CloudPoints.js +119 -0
  248. package/lib/math/geometry/line.d.ts +1 -0
  249. package/lib/math/geometry/line.d.ts.map +1 -1
  250. package/lib/math/geometry/line.js +10 -2
  251. package/lib/math/geometry/vector.d.ts +1 -0
  252. package/lib/math/geometry/vector.d.ts.map +1 -1
  253. package/lib/math/geometry/vector.js +12 -0
  254. package/lib/math/progCalc/progCalc.d.ts +46 -0
  255. package/lib/math/progCalc/progCalc.d.ts.map +1 -0
  256. package/lib/math/progCalc/progCalc.js +239 -0
  257. package/lib/math/utils/latex/realize.d.ts +12 -0
  258. package/lib/math/utils/latex/realize.d.ts.map +1 -0
  259. package/lib/math/utils/latex/realize.js +43 -0
  260. package/lib/pc/constants/molecularChemistry/molecule.d.ts +2 -0
  261. package/lib/pc/constants/molecularChemistry/molecule.d.ts.map +1 -1
  262. package/lib/pc/constants/molecularChemistry/molecule.js +52 -0
  263. package/lib/tests/questionTest.d.ts.map +1 -1
  264. package/lib/tests/questionTest.js +1 -1
  265. package/lib/tests/singleExo.test.js +3 -3
  266. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  267. package/lib/tree/nodes/operators/addNode.d.ts +4 -2
  268. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  269. package/lib/tree/nodes/operators/addNode.js +8 -17
  270. package/lib/tree/nodes/operators/fractionNode.d.ts +1 -1
  271. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  272. package/lib/tree/nodes/operators/fractionNode.js +5 -1
  273. package/lib/tree/nodes/operators/multiplyNode.d.ts +4 -2
  274. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  275. package/lib/tree/nodes/operators/multiplyNode.js +8 -17
  276. package/lib/tree/nodes/operators/operatorNode.d.ts +3 -3
  277. package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
  278. package/lib/tree/nodes/variables/variableNode.d.ts +1 -1
  279. package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
  280. package/lib/tree/utilities/nodeShuffler.d.ts +12 -0
  281. package/lib/tree/utilities/nodeShuffler.d.ts.map +1 -0
  282. package/lib/tree/utilities/nodeShuffler.js +123 -0
  283. package/lib/utils/arrays/getAllPicks.d.ts +2 -0
  284. package/lib/utils/arrays/getAllPicks.d.ts.map +1 -0
  285. package/lib/utils/arrays/getAllPicks.js +17 -0
  286. package/lib/utils/errors/handleVEAError.d.ts +1 -1
  287. package/lib/utils/errors/handleVEAError.d.ts.map +1 -1
  288. package/lib/utils/strings/decapitalize.d.ts +2 -0
  289. package/lib/utils/strings/decapitalize.d.ts.map +1 -0
  290. package/lib/utils/strings/decapitalize.js +3 -0
  291. package/package.json +1 -1
@@ -0,0 +1,415 @@
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../math/utils/random/randint.js";
4
+ import { round } from "../../../math/utils/round.js";
5
+ import { EqualNode } from "../../../tree/nodes/equations/equalNode.js";
6
+ import { NodeConstructor, } from "../../../tree/nodes/nodeConstructor.js";
7
+ import { InfinityNode, MinusInfinityNode, } from "../../../tree/nodes/numbers/infiniteNode.js";
8
+ import { add } from "../../../tree/nodes/operators/addNode.js";
9
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
10
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
11
+ import { substract } from "../../../tree/nodes/operators/substractNode.js";
12
+ import { random } from "../../../utils/alea/random.js";
13
+ import { alignTex } from "../../../utils/latex/alignTex.js";
14
+ const optsDefault = {
15
+ typeDistance: [
16
+ "distance focale",
17
+ "distance objet",
18
+ "distance image",
19
+ ],
20
+ typeImage: [
21
+ "réelle finie",
22
+ "réelle infinie",
23
+ "imaginaire finie",
24
+ "imaginaire infinie",
25
+ ],
26
+ unit: ["cm", "m"],
27
+ roundTo: [0, 1, 2],
28
+ };
29
+ const options = [
30
+ {
31
+ id: "typeDistance",
32
+ label: "Distance à calculer",
33
+ target: GeneratorOptionTarget.generation,
34
+ type: GeneratorOptionType.multiselect,
35
+ defaultValue: optsDefault.typeDistance,
36
+ values: ["distance focale", "distance objet", "distance image"],
37
+ },
38
+ {
39
+ id: "typeImage",
40
+ label: "Type d'image",
41
+ target: GeneratorOptionTarget.generation,
42
+ type: GeneratorOptionType.multiselect,
43
+ defaultValue: optsDefault.typeImage,
44
+ values: [
45
+ "réelle finie",
46
+ "réelle infinie",
47
+ "imaginaire finie",
48
+ "imaginaire infinie",
49
+ ],
50
+ },
51
+ {
52
+ id: "unit",
53
+ label: "unité de mesure",
54
+ target: GeneratorOptionTarget.generation,
55
+ type: GeneratorOptionType.multiselect,
56
+ defaultValue: optsDefault.unit,
57
+ values: ["cm", "m"],
58
+ },
59
+ {
60
+ id: "roundTo",
61
+ label: "Arrondir à (nombre de décimales)",
62
+ target: GeneratorOptionTarget.generation,
63
+ type: GeneratorOptionType.multiselect,
64
+ defaultValue: optsDefault.roundTo,
65
+ values: [0, 1, 2],
66
+ },
67
+ ];
68
+ const getLensFormulaEqualNode = () => {
69
+ const equation = new EqualNode(frac(1, "\\overline {OA'}"), add(frac(1, "\\overline {OF'}"), frac(1, "\\overline {OA}")));
70
+ return equation;
71
+ };
72
+ const getInstruction = (identifiers) => {
73
+ const { OFPrime, OA, OAPrime, opts } = identifiers;
74
+ const nodeOFPrime = NodeConstructor.fromIdentifiers(OFPrime);
75
+ const nodeOA = NodeConstructor.fromIdentifiers(OA);
76
+ const nodeOAPrime = NodeConstructor.fromIdentifiers(OAPrime);
77
+ const strRounTo = (() => {
78
+ switch (opts.roundTo) {
79
+ case 0:
80
+ return "à l'unité";
81
+ case 1:
82
+ return "au dixième";
83
+ case 2:
84
+ return "au centième";
85
+ }
86
+ })();
87
+ let strOAPrime = `$${nodeOAPrime.simplify().toTex()}${opts.unit}$`;
88
+ let strOA = `$${nodeOA.simplify().toTex()}${opts.unit}$`;
89
+ const strOFPrime = `$${nodeOFPrime.simplify().toTex()}${opts.unit}$`;
90
+ if (strOAPrime.includes("\\infty")) {
91
+ strOAPrime = "à l'infini";
92
+ }
93
+ if (strOA.includes("\\infty")) {
94
+ strOA = "à l'infini";
95
+ }
96
+ const strLensType = nodeOFPrime.evaluate() >= 0 ? "convergente" : "divergente";
97
+ switch (opts.typeDistance) {
98
+ case "distance focale": {
99
+ return `Calculer la distance focale algébrique de la lentille, en $${opts.unit}$, arrondie ${strRounTo},
100
+ sachant que la position algébrique de l'objet de l'objet $AB$ est ${strOA},
101
+ et que la position algébrique de l'image $A'$ est ${strOAPrime}.`;
102
+ }
103
+ case "distance image": {
104
+ return `Calculer la position algébrique de l'image $A'$ de l'objet $AB$, en $${opts.unit}$, arrondie ${strRounTo},
105
+ situé algébriquement à ${strOA}
106
+ d'une lentille ${strLensType} ayant une distance focale de ${strOFPrime}.`;
107
+ }
108
+ case "distance objet": {
109
+ return `Calculer la position algébrique $A$ de l'objet $AB$, en $${opts.unit}$, arrondie ${strRounTo},
110
+ sachant que la position algébrique de l'image $A'$ est ${strOAPrime},
111
+ et que la distance focale algébrique est ${strOFPrime}.`;
112
+ }
113
+ }
114
+ };
115
+ const getHint = () => {
116
+ return `Relation de conjugaison de Descartes :
117
+
118
+ $$
119
+ ${getLensFormulaEqualNode().toTex()}
120
+ $$
121
+
122
+ `;
123
+ };
124
+ const getCorrection = (identifiers) => {
125
+ const { OFPrime, OA, OAPrime, opts } = identifiers;
126
+ const nodeOFPrime = NodeConstructor.fromIdentifiers(OFPrime);
127
+ const nodeOA = NodeConstructor.fromIdentifiers(OA);
128
+ const nodeOAPrime = NodeConstructor.fromIdentifiers(OAPrime);
129
+ const answer = getAnswer(identifiers);
130
+ return `La relation de conjugaison de Descartes s'écrit :
131
+
132
+ $$
133
+ ${getLensFormulaEqualNode().toTex()}
134
+ $$
135
+
136
+ Dans notre cas :
137
+
138
+ ${(() => {
139
+ switch (opts.typeDistance) {
140
+ case "distance focale":
141
+ return alignTex([
142
+ [
143
+ `\\frac{1}{\\overline {OF'}}`,
144
+ `=`,
145
+ `\\frac{1}{\\overline {OA'}} - \\frac{1}{\\overline {OA}}`,
146
+ ],
147
+ [
148
+ `\\overline {OF'}`,
149
+ `=`,
150
+ `\\frac{1} {\\frac{1}{\\overline {OA'}} - \\frac{1}{\\overline {OA}}}`,
151
+ ],
152
+ [
153
+ `\\overline {OF'}`,
154
+ `=`,
155
+ `\\frac{1} {\\frac{1}{${nodeOAPrime.toTex()}} - \\frac{1}{${nodeOA.toTex()}}}`,
156
+ ],
157
+ [`\\overline {OF'}`, `=`, answer.replaceAll("$", "")],
158
+ ]);
159
+ case "distance image":
160
+ return alignTex([
161
+ [
162
+ `\\overline {OA'}`,
163
+ `=`,
164
+ `\\frac{1} {\\frac{1}{\\overline {OF'}} + \\frac{1}{\\overline {OA}}}`,
165
+ ],
166
+ [
167
+ `\\overline {OA'}`,
168
+ `=`,
169
+ `\\frac{1} {\\frac{1}{${nodeOFPrime.toTex()}} + \\frac{1}{${nodeOA.toTex()}}}`,
170
+ ],
171
+ [`\\overline {OA'}`, `=`, answer.replaceAll("$", "")],
172
+ ]);
173
+ case "distance objet":
174
+ return alignTex([
175
+ [
176
+ `\\frac{1}{\\overline {OA}}`,
177
+ `=`,
178
+ `\\frac{1}{\\overline {OA'}} - \\frac{1}{\\overline {OF'}}`,
179
+ ],
180
+ [
181
+ `\\overline {OA}`,
182
+ `=`,
183
+ `\\frac{1} {\\frac{1}{\\overline {OA'}} - \\frac{1}{\\overline {OF'}}}`,
184
+ ],
185
+ [
186
+ `\\overline {OA}`,
187
+ `=`,
188
+ `\\frac{1} {\\frac{1}{${nodeOAPrime.toTex()}} - \\frac{1}{${nodeOFPrime.toTex()}}}`,
189
+ ],
190
+ [`\\overline {OA}`, `=`, answer.replaceAll("$", "")],
191
+ ]);
192
+ }
193
+ })()}`;
194
+ };
195
+ const getAnswer = (identifiers) => {
196
+ const { OFPrime, OA, OAPrime, opts } = identifiers;
197
+ const nodeOFPrime = NodeConstructor.fromIdentifiers(OFPrime);
198
+ const nodeOA = NodeConstructor.fromIdentifiers(OA);
199
+ const nodeOAPrime = NodeConstructor.fromIdentifiers(OAPrime);
200
+ return `${round((() => {
201
+ switch (opts.typeDistance) {
202
+ case "distance focale":
203
+ return nodeOFPrime;
204
+ case "distance image":
205
+ return nodeOAPrime;
206
+ case "distance objet":
207
+ return nodeOA;
208
+ }
209
+ })().evaluate(), opts.roundTo).frenchify()}${opts.unit}`;
210
+ };
211
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
212
+ const { opts } = identifiers;
213
+ if (!ans.endsWith(opts.unit))
214
+ return false;
215
+ const ansNumber = parseFloat(ans.replace(opts.unit, ""));
216
+ const answerNumber = parseFloat(answer.replace(opts.unit, ""));
217
+ return ansNumber === answerNumber;
218
+ };
219
+ const getPropositions = (nbProps, { answer, ...identifiers }) => {
220
+ const { OFPrime, OA, OAPrime, opts } = identifiers;
221
+ const nodeOFPrime = NodeConstructor.fromIdentifiers(OFPrime);
222
+ const nodeOA = NodeConstructor.fromIdentifiers(OA);
223
+ const nodeOAPrime = NodeConstructor.fromIdentifiers(OAPrime);
224
+ let propositions = [];
225
+ function toUnitedTex(tex) {
226
+ return `${tex}${opts.unit}`;
227
+ }
228
+ addValidProp(propositions, answer, "tex");
229
+ switch (opts.typeDistance) {
230
+ case "distance focale":
231
+ {
232
+ function tryToAddWrongProps(roundTo) {
233
+ //x = A + B
234
+ tryToAddWrongProp(propositions, toUnitedTex(round(add(nodeOAPrime, nodeOA).evaluate(), roundTo).frenchify()));
235
+ //erreur d'inverse
236
+ tryToAddWrongProp(propositions, toUnitedTex(round(nodeOFPrime.rightChild.evaluate(), roundTo).frenchify()));
237
+ //erreur de signe
238
+ tryToAddWrongProp(propositions, toUnitedTex(round(frac(1, add(frac(1, nodeOAPrime.evaluate()), frac(1, nodeOA.evaluate()))).evaluate(), roundTo).frenchify()));
239
+ }
240
+ //erreurs d'arrondis
241
+ [0, 1, 2].forEach((roundTo) => {
242
+ tryToAddWrongProps(roundTo);
243
+ });
244
+ }
245
+ break;
246
+ case "distance image":
247
+ {
248
+ function tryToAddWrongProps(roundTo) {
249
+ //x = A + B
250
+ tryToAddWrongProp(propositions, toUnitedTex(round(add(nodeOFPrime, nodeOA).evaluate(), roundTo).frenchify()));
251
+ //erreur d'inverse
252
+ tryToAddWrongProp(propositions, toUnitedTex(round(frac(1, nodeOAPrime).evaluate(), roundTo).frenchify()));
253
+ //erreur de signe
254
+ tryToAddWrongProp(propositions, toUnitedTex(round(substract(frac(1, nodeOFPrime.evaluate()), frac(1, nodeOA.evaluate())).evaluate(), roundTo).frenchify()));
255
+ }
256
+ //erreurs d'arrondis
257
+ [0, 1, 2].forEach((roundTo) => {
258
+ tryToAddWrongProps(roundTo);
259
+ });
260
+ }
261
+ break;
262
+ case "distance objet":
263
+ {
264
+ function tryToAddWrongProps(roundTo) {
265
+ //x = A + B
266
+ tryToAddWrongProp(propositions, toUnitedTex(round(add(nodeOAPrime, nodeOFPrime).evaluate(), roundTo).frenchify()));
267
+ //erreur d'inverse
268
+ tryToAddWrongProp(propositions, toUnitedTex(round(nodeOA.rightChild.evaluate(), roundTo).frenchify()));
269
+ //erreur de signe
270
+ tryToAddWrongProp(propositions, toUnitedTex(round(frac(1, add(frac(1, nodeOAPrime.evaluate()), frac(1, nodeOFPrime.evaluate()))).evaluate(), roundTo).frenchify()));
271
+ }
272
+ //erreurs d'arrondis
273
+ [0, 1, 2].forEach((roundTo) => {
274
+ tryToAddWrongProps(roundTo);
275
+ });
276
+ }
277
+ break;
278
+ }
279
+ propositions = propositions.filter((proposition) => !proposition.statement.includes("NaN"));
280
+ return shuffleProps(propositions, nbProps);
281
+ };
282
+ const getLensFormulaQuestion = (optsIn) => {
283
+ const optsInRetyped = optsIn
284
+ ? {
285
+ typeDistance: optsIn?.typeDistance,
286
+ typeImage: optsIn?.typeImage,
287
+ unit: optsIn?.unit,
288
+ roundTo: (optsIn?.roundTo)
289
+ .filter((a) => typeof a === "string")
290
+ .map((str) => +str),
291
+ }
292
+ : undefined;
293
+ console.log("optsIn", optsIn);
294
+ console.log("optsInRetyped", optsInRetyped);
295
+ let nodeOFPrime = NaN.toTree();
296
+ let nodeOA = NaN.toTree();
297
+ let nodeOAPrime = NaN.toTree();
298
+ let opts;
299
+ function getRandomNodes() {
300
+ opts = optsInRetyped
301
+ ? {
302
+ typeDistance: random(optsInRetyped.typeDistance),
303
+ typeImage: random(optsInRetyped.typeImage),
304
+ unit: random(optsInRetyped.unit),
305
+ roundTo: random(optsInRetyped.roundTo),
306
+ }
307
+ : {
308
+ typeDistance: random(optsDefault.typeDistance),
309
+ typeImage: random(optsDefault.typeImage),
310
+ unit: random(optsDefault.unit),
311
+ roundTo: random(optsDefault.roundTo),
312
+ };
313
+ console.log("opts", opts);
314
+ //objet réel: \\overline {OA} < 0
315
+ //image réelle : \\overline {OA'} > 0
316
+ function factorNodeForTypeImage(typeImage) {
317
+ let factorNode;
318
+ switch (typeImage) {
319
+ case "réelle finie":
320
+ factorNode = (+1).toTree();
321
+ break;
322
+ case "réelle infinie":
323
+ factorNode = (-1).toTree();
324
+ break;
325
+ case "imaginaire finie":
326
+ factorNode = InfinityNode;
327
+ break;
328
+ case "imaginaire infinie":
329
+ factorNode = MinusInfinityNode;
330
+ break;
331
+ }
332
+ return factorNode;
333
+ }
334
+ switch (opts.typeDistance) {
335
+ case "distance focale":
336
+ {
337
+ nodeOA = (-randint(1, 10)).toTree();
338
+ nodeOAPrime = multiply(factorNodeForTypeImage(opts.typeImage), randint(1, 10, [-nodeOA.evaluate()]).toTree()).simplify();
339
+ const equalNode = getLensFormulaEqualNode();
340
+ nodeOFPrime = frac(1, substract(equalNode.leftChild.evaluate({
341
+ "\\overline {OA'}": nodeOA.evaluate(),
342
+ }), equalNode.rightChild.rightChild.evaluate({
343
+ "\\overline {OA}": nodeOAPrime.evaluate(),
344
+ })));
345
+ }
346
+ break;
347
+ case "distance image":
348
+ {
349
+ nodeOA = (-randint(1, 10)).toTree();
350
+ nodeOFPrime = multiply(factorNodeForTypeImage(opts.typeImage), randint(1, 10, [-nodeOA.evaluate()]).toTree()).simplify();
351
+ const equalNode = getLensFormulaEqualNode();
352
+ nodeOAPrime = frac(1, equalNode.rightChild.evaluate({
353
+ "\\overline {OA}": nodeOA.evaluate(),
354
+ "\\overline {OF'}": nodeOFPrime.evaluate(),
355
+ }));
356
+ }
357
+ break;
358
+ case "distance objet":
359
+ {
360
+ nodeOAPrime = multiply(factorNodeForTypeImage(opts.typeImage), randint(1, 10).toTree()).simplify();
361
+ nodeOFPrime = randint(1, 10, [-nodeOAPrime.evaluate()]).toTree();
362
+ const equalNode = getLensFormulaEqualNode();
363
+ nodeOA = frac(1, substract(equalNode.leftChild.evaluate({
364
+ "\\overline {OA'}": nodeOAPrime.evaluate(),
365
+ }), equalNode.rightChild.leftChild.evaluate({
366
+ "\\overline {OF'}": nodeOFPrime.evaluate(),
367
+ })));
368
+ }
369
+ break;
370
+ }
371
+ }
372
+ function checkValidNodes() {
373
+ const isContainingNaN = [nodeOA, nodeOAPrime, nodeOFPrime].some((node) => isNaN(node.evaluate()));
374
+ const valueOFPrime = nodeOFPrime.evaluate();
375
+ const isFocalInfinite = valueOFPrime === -Infinity || valueOFPrime == Infinity;
376
+ return !isContainingNaN && !isFocalInfinite;
377
+ }
378
+ do {
379
+ getRandomNodes();
380
+ } while (!checkValidNodes());
381
+ return getQuestionFromIdentifiers({
382
+ OFPrime: nodeOFPrime.toIdentifiers(),
383
+ OA: nodeOA.toIdentifiers(),
384
+ OAPrime: nodeOAPrime.toIdentifiers(),
385
+ opts: opts,
386
+ }, opts);
387
+ };
388
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
389
+ const question = {
390
+ instruction: getInstruction(identifiers, opts),
391
+ keys: [],
392
+ answerFormat: "tex",
393
+ identifiers,
394
+ hint: getHint(identifiers, opts),
395
+ correction: getCorrection(identifiers, opts),
396
+ answer: getAnswer(identifiers),
397
+ };
398
+ return question;
399
+ };
400
+ export const lensFormula = {
401
+ id: "lensFormula",
402
+ label: "Exploiter la relation de conjugaison de Descartes",
403
+ isSingleStep: true,
404
+ generator: (nb, opts) => getDistinctQuestions(() => getLensFormulaQuestion(opts), nb, 30, () => false),
405
+ options,
406
+ qcmTimer: 60,
407
+ freeTimer: 60,
408
+ getPropositions,
409
+ isAnswerValid,
410
+ subject: "Physique",
411
+ maxAllowedQuestions: 30,
412
+ getQuestionFromIdentifiers,
413
+ answerType: "QCU",
414
+ hasHintAndCorrection: true,
415
+ };
@@ -1,7 +1,14 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  mass: number;
4
+ optsIdent: Options;
4
5
  };
5
- export declare const calculateWeight: Exercise<Identifiers>;
6
+ type InputType = "decimal" | "sci";
7
+ type NbDigitsType = 0 | 1 | 2;
8
+ type Options = {
9
+ inputType: InputType;
10
+ nbDigits: NbDigitsType;
11
+ };
12
+ export declare const calculateWeight: Exercise<Identifiers, Options>;
6
13
  export {};
7
14
  //# sourceMappingURL=calculateWeight.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"calculateWeight.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/weight/calculateWeight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA+FF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
1
+ {"version":3,"file":"calculateWeight.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/weight/calculateWeight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC;AACnC,KAAK,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE9B,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAuMF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAc1D,CAAC"}
@@ -1,21 +1,62 @@
1
- import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randfloat } from "../../../math/utils/random/randfloat.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
+ import { round } from "../../../math/utils/round.js";
5
6
  import { earthGravity } from "../../../pc/constants/gravity.js";
7
+ import { random } from "../../../utils/alea/random.js";
6
8
  const g = +earthGravity.measure.significantPart.toFixed(2);
9
+ const optsDefault = {
10
+ inputType: "sci",
11
+ nbDigits: 2,
12
+ };
13
+ const options = [
14
+ {
15
+ id: "inputType",
16
+ label: "Format de la réponse",
17
+ type: GeneratorOptionType.multiselect,
18
+ target: GeneratorOptionTarget.generation,
19
+ values: ["decimal", "sci"],
20
+ defaultValue: [optsDefault.inputType],
21
+ },
22
+ {
23
+ id: "nbDigits",
24
+ label: "Nombre de décimales",
25
+ type: GeneratorOptionType.multiselect,
26
+ target: GeneratorOptionTarget.generation,
27
+ values: [0, 1, 2],
28
+ defaultValue: [optsDefault.nbDigits],
29
+ },
30
+ ];
7
31
  const getInstruction = (identifiers) => {
8
- const { mass } = identifiers;
32
+ const { mass, optsIdent } = identifiers;
9
33
  const instruction = `Soit un objet avec une masse de $${mass}\\ \\textrm{kg}$.
34
+
35
+ L'accélération due à la gravité vaut $${g.frenchify()}$ $\\textrm{m} \\cdot \\textrm{s}^{${-2}}$.
10
36
 
11
- Calculer le poids de cet objet.`;
37
+ Calculer le poids de cet objet en Newtons.
38
+ Donner le résultat
39
+ ${(() => {
40
+ switch (optsIdent.inputType) {
41
+ case "decimal":
42
+ return `en écriture décimale`;
43
+ case "sci":
44
+ return `en écriture scientifique`;
45
+ }
46
+ })()}
47
+ ${(() => {
48
+ switch (optsIdent.nbDigits) {
49
+ case 0:
50
+ return `arrondie à l'unité`;
51
+ case 1:
52
+ return `arrondie à une décimale`;
53
+ case 2:
54
+ return `arrondie à deux décimales`;
55
+ }
56
+ })()}.
57
+ `;
12
58
  return instruction;
13
59
  };
14
- const getAnswer = (identifiers) => {
15
- const { mass } = identifiers;
16
- const answer = (mass * g).toScientific(2);
17
- return answer.toTex();
18
- };
19
60
  const getHint = () => {
20
61
  const hint = `Le poids $P$ se calcule en utilisant la formule :
21
62
 
@@ -27,7 +68,7 @@ où
27
68
 
28
69
  - m est la masse de l'objet (en $\\textrm{kg}$).
29
70
 
30
- - g est l'accélération due à la gravité (en $\\textrm{m} \\cdot \\textrm{s}^${-1}$).`;
71
+ - g est l'accélération due à la gravité (en $\\textrm{m} \\cdot \\textrm{s}^{${-2}}$).`;
31
72
  return hint;
32
73
  };
33
74
  const getCorrection = (identifiers) => {
@@ -42,52 +83,85 @@ $$
42
83
  On a :
43
84
 
44
85
  $$
45
- P = ${mass.frenchify()} \\times ${g.frenchify()} \\Rightarrow P=${answer}\\ \\textrm{N}
86
+ P = ${mass.frenchify()} \\times ${g.frenchify()} \\Rightarrow P=${answer}
46
87
  $$`;
47
88
  return correction;
48
89
  };
49
- const getQuestionFromIdentifiers = (identifiers) => {
90
+ const getAnswer = (identifiers) => {
91
+ const { mass, optsIdent } = identifiers;
92
+ switch (optsIdent.inputType) {
93
+ case "decimal": {
94
+ const answer = round(mass * g, optsIdent.nbDigits);
95
+ return `${answer.frenchify()}N`;
96
+ }
97
+ case "sci": {
98
+ const answer = (mass * g).toScientific(optsIdent.nbDigits);
99
+ return `${answer.toTex()}N`;
100
+ }
101
+ }
102
+ };
103
+ const isAnswerValid = (ans, { answer }) => {
104
+ return ans === answer;
105
+ };
106
+ const getPropositions = (n, { answer, mass, optsIdent }) => {
107
+ const propositions = [];
108
+ const weight = mass * g;
109
+ addValidProp(propositions, answer);
110
+ switch (optsIdent.inputType) {
111
+ case "decimal":
112
+ {
113
+ tryToAddWrongProp(propositions, `${round(weight * 10, optsIdent.nbDigits).frenchify()}N`);
114
+ tryToAddWrongProp(propositions, `${round(randfloat(weight - 100, weight + 100, 2, [weight]) / 10, optsIdent.nbDigits).frenchify()}N`);
115
+ propWhile(propositions, n, () => {
116
+ const random = randfloat(weight - 50, weight + 50, 2, [weight]);
117
+ tryToAddWrongProp(propositions, `${round(random, optsIdent.nbDigits).frenchify()}N`);
118
+ });
119
+ }
120
+ break;
121
+ case "sci":
122
+ {
123
+ tryToAddWrongProp(propositions, `${(weight * 10).toScientific(optsIdent.nbDigits).toTex()}N`);
124
+ tryToAddWrongProp(propositions, `${(randfloat(weight - 100, weight + 100, 2, [weight]) / 10)
125
+ .toScientific(optsIdent.nbDigits)
126
+ .toTex()}N`);
127
+ propWhile(propositions, n, () => {
128
+ const random = randfloat(weight - 50, weight + 50, 2, [weight]);
129
+ tryToAddWrongProp(propositions, `${random.toScientific(optsIdent.nbDigits).toTex()}N`);
130
+ });
131
+ }
132
+ break;
133
+ }
134
+ return shuffleProps(propositions, n);
135
+ };
136
+ const getCalculateWeightQuestion = (optsIn) => {
137
+ const opts = optsIn
138
+ ? Object.assign(optsDefault, {
139
+ inputType: random(optsIn.inputType),
140
+ nbDigits: +random(optsIn.nbDigits),
141
+ })
142
+ : optsDefault;
143
+ const mass = randint(30, 151);
144
+ const identifiers = { mass: mass, optsIdent: opts };
145
+ return getQuestionFromIdentifiers(identifiers, opts);
146
+ };
147
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
50
148
  const question = {
51
149
  answer: getAnswer(identifiers),
52
150
  instruction: getInstruction(identifiers),
53
- keys: [],
151
+ keys: ["N"],
54
152
  hint: getHint(identifiers),
55
153
  correction: getCorrection(identifiers),
56
154
  answerFormat: "tex",
57
155
  identifiers,
156
+ options: opts,
58
157
  };
59
158
  return question;
60
159
  };
61
- const getCalculateWeightQuestion = () => {
62
- const mass = randint(30, 151);
63
- const identifiers = { mass: mass };
64
- return getQuestionFromIdentifiers(identifiers);
65
- };
66
- const getPropositions = (n, { answer, mass }) => {
67
- const propositions = [];
68
- const weight = mass * g;
69
- addValidProp(propositions, answer);
70
- generatePropositions(mass).forEach((value) => tryToAddWrongProp(propositions, value));
71
- propWhile(propositions, n, () => {
72
- const random = randfloat(weight - 50, weight + 50, 2, [weight]);
73
- tryToAddWrongProp(propositions, random.toScientific(2).toTex());
74
- });
75
- return shuffleProps(propositions, n);
76
- };
77
- const isAnswerValid = (ans, { answer }) => {
78
- return ans === answer;
79
- };
80
- const generatePropositions = (mass) => {
81
- const weight = mass * g;
82
- const first = (weight * 10).toScientific(2);
83
- const second = (randfloat(weight - 100, weight + 100, 2, [weight]) / 10).toScientific(2);
84
- return [first.toTex(), second.toTex()];
85
- };
86
160
  export const calculateWeight = {
87
161
  id: "calculateWeight",
88
162
  label: "Calculer le poids d'un objet",
89
163
  isSingleStep: true,
90
- generator: (nb) => getDistinctQuestions(getCalculateWeightQuestion, nb),
164
+ generator: (nb, opts) => getDistinctQuestions(() => getCalculateWeightQuestion(opts), nb),
91
165
  qcmTimer: 60,
92
166
  freeTimer: 60,
93
167
  getPropositions,
@@ -95,4 +169,5 @@ export const calculateWeight = {
95
169
  subject: "Physique",
96
170
  hasHintAndCorrection: true,
97
171
  getQuestionFromIdentifiers,
172
+ options,
98
173
  };
@@ -3,5 +3,9 @@ export declare class GeogebraParser {
3
3
  constructor(studentCommands: string[]);
4
4
  pointCoords(name: string): number[] | undefined;
5
5
  vectors(): number[][];
6
+ objectDict(): {
7
+ [k: string]: string;
8
+ };
9
+ static pointNamesForLineObj(lineObj: string): string[];
6
10
  }
7
11
  //# sourceMappingURL=geogebraParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geogebraParser.d.ts","sourceRoot":"","sources":["../../../src/geogebra/parsers/geogebraParser.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,eAAe,EAAE,MAAM,EAAE;IAIrC,WAAW,CAAC,IAAI,EAAE,MAAM;IAWxB,OAAO;CAwCR"}
1
+ {"version":3,"file":"geogebraParser.d.ts","sourceRoot":"","sources":["../../../src/geogebra/parsers/geogebraParser.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,eAAe,EAAE,MAAM,EAAE;IAIrC,WAAW,CAAC,IAAI,EAAE,MAAM;IAWxB,OAAO;IAyCP,UAAU;;;IAWV,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM;CAS5C"}
@@ -56,4 +56,21 @@ export class GeogebraParser {
56
56
  }
57
57
  return res;
58
58
  }
59
+ objectDict() {
60
+ return Object.fromEntries(this.commands
61
+ .filter((command) => command.includes("="))
62
+ .map((definitionCommand) => {
63
+ const [name, obj] = definitionCommand.split("=");
64
+ return [name, obj];
65
+ }));
66
+ }
67
+ static pointNamesForLineObj(lineObj) {
68
+ const reLine = /^Line\[\s*([^,\]]+)\s*,\s*([^,\]]+)\s*\]$/;
69
+ const match = lineObj.match(reLine);
70
+ if (!match) {
71
+ return [];
72
+ }
73
+ const [, nameA, nameB] = match;
74
+ return [nameA, nameB];
75
+ }
59
76
  }