math-exercises 3.0.151 → 3.0.153

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 (199) hide show
  1. package/lib/exercises/exercise.d.ts +7 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts +5 -1
  4. package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.js +92 -38
  6. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +5 -1
  8. package/lib/exercises/math/calcul/proportionality/isTableProportional.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/proportionality/isTableProportional.js +7 -1
  10. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +5 -1
  12. package/lib/exercises/math/calcul/proportionality/proportionalityTable.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/proportionality/proportionalityTable.js +5 -1
  14. package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.js +8 -2
  16. package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -1
  17. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/equation/index.js +1 -1
  19. package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.d.ts +10 -0
  20. package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.d.ts.map +1 -0
  21. package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.js +183 -0
  22. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.d.ts +10 -0
  23. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.d.ts.map +1 -0
  24. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.js +173 -0
  25. package/lib/exercises/math/calculLitteral/equation/square/index.d.ts +3 -0
  26. package/lib/exercises/math/calculLitteral/equation/square/index.d.ts.map +1 -0
  27. package/lib/exercises/math/calculLitteral/equation/square/index.js +2 -0
  28. package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.d.ts.map +1 -1
  29. package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.js +7 -0
  30. package/lib/exercises/math/dataRepresentations/tableReading.d.ts.map +1 -1
  31. package/lib/exercises/math/dataRepresentations/tableReading.js +7 -0
  32. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
  33. package/lib/exercises/math/functions/affines/affineAdjustment.js +7 -1
  34. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
  35. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +7 -1
  36. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +7 -1
  38. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
  39. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +7 -1
  40. package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/basics/placePointsFromValueTable.js +7 -0
  42. package/lib/exercises/math/functions/sqrt/squareRootCalculation.d.ts.map +1 -1
  43. package/lib/exercises/math/functions/sqrt/squareRootCalculation.js +4 -2
  44. package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.d.ts +15 -0
  45. package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.d.ts.map +1 -0
  46. package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.js +301 -0
  47. package/lib/exercises/math/geometry/euclidian/index.d.ts +7 -0
  48. package/lib/exercises/math/geometry/euclidian/index.d.ts.map +1 -1
  49. package/lib/exercises/math/geometry/euclidian/index.js +7 -0
  50. package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.d.ts +21 -0
  51. package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.d.ts.map +1 -0
  52. package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.js +406 -0
  53. package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.d.ts +18 -0
  54. package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.d.ts.map +1 -0
  55. package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.js +315 -0
  56. package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.d.ts +20 -0
  57. package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.d.ts.map +1 -0
  58. package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.js +314 -0
  59. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.d.ts +18 -0
  60. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.d.ts.map +1 -0
  61. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.js +387 -0
  62. package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.d.ts +18 -0
  63. package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.d.ts.map +1 -0
  64. package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.js +309 -0
  65. package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.d.ts +17 -0
  66. package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.d.ts.map +1 -0
  67. package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.js +301 -0
  68. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.d.ts.map +1 -1
  69. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.js +22 -8
  70. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.d.ts +11 -0
  71. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.d.ts.map +1 -0
  72. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.js +169 -0
  73. package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
  74. package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -1
  75. package/lib/exercises/math/geometry/euclidianConstructions/index.js +2 -0
  76. package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.d.ts +16 -0
  77. package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.d.ts.map +1 -0
  78. package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.js +309 -0
  79. package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.d.ts.map +1 -1
  80. package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.js +7 -0
  81. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts.map +1 -1
  82. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.js +7 -0
  83. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts +9 -0
  84. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts.map +1 -0
  85. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.js +120 -0
  86. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +2 -0
  87. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
  88. package/lib/exercises/math/probaStat/basicProbas/index.js +2 -0
  89. package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts +12 -0
  90. package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts.map +1 -0
  91. package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.js +374 -0
  92. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
  93. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +7 -0
  94. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  95. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +7 -0
  96. package/lib/exercises/math/probaStat/stats1var/averageWithClasses.d.ts +9 -0
  97. package/lib/exercises/math/probaStat/stats1var/averageWithClasses.d.ts.map +1 -0
  98. package/lib/exercises/math/probaStat/stats1var/averageWithClasses.js +140 -0
  99. package/lib/exercises/math/probaStat/stats1var/averageWithTable.d.ts.map +1 -1
  100. package/lib/exercises/math/probaStat/stats1var/averageWithTable.js +7 -1
  101. package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.d.ts +8 -0
  102. package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.d.ts.map +1 -0
  103. package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.js +113 -0
  104. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -1
  105. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +7 -0
  106. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts.map +1 -1
  107. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +7 -0
  108. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts.map +1 -1
  109. package/lib/exercises/math/probaStat/stats1var/etendueTable.js +7 -1
  110. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.d.ts.map +1 -1
  111. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.js +7 -0
  112. package/lib/exercises/math/probaStat/stats1var/index.d.ts +2 -0
  113. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  114. package/lib/exercises/math/probaStat/stats1var/index.js +2 -0
  115. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -1
  116. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +5 -1
  117. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
  118. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +7 -0
  119. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts +2 -0
  120. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
  121. package/lib/exercises/math/probaStat/stats1var/medianWithList.js +67 -14
  122. package/lib/exercises/math/probaStat/stats1var/medianWithTable.d.ts.map +1 -1
  123. package/lib/exercises/math/probaStat/stats1var/medianWithTable.js +7 -1
  124. package/lib/exercises/math/probaStat/stats1var/quartiles.d.ts.map +1 -1
  125. package/lib/exercises/math/probaStat/stats1var/quartiles.js +7 -1
  126. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts.map +1 -1
  127. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +5 -1
  128. package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts.map +1 -1
  129. package/lib/exercises/math/probaStat/stats1var/varianceTable.js +5 -1
  130. package/lib/exercises/math/probaStat/stats2var/averagePoint.d.ts.map +1 -1
  131. package/lib/exercises/math/probaStat/stats2var/averagePoint.js +7 -1
  132. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts +7 -0
  133. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts.map +1 -0
  134. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.js +171 -0
  135. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts +7 -0
  136. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts.map +1 -0
  137. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.js +155 -0
  138. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts +3 -0
  139. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts.map +1 -1
  140. package/lib/exercises/math/probaStat/twoStepExperiments/index.js +3 -0
  141. package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts +7 -0
  142. package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts.map +1 -0
  143. package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.js +189 -0
  144. package/lib/exercises/math/scratch/index.d.ts +3 -0
  145. package/lib/exercises/math/scratch/index.d.ts.map +1 -1
  146. package/lib/exercises/math/scratch/index.js +3 -0
  147. package/lib/exercises/math/scratch/scratchListElemAtIndex.d.ts +13 -0
  148. package/lib/exercises/math/scratch/scratchListElemAtIndex.d.ts.map +1 -0
  149. package/lib/exercises/math/scratch/scratchListElemAtIndex.js +189 -0
  150. package/lib/exercises/math/scratch/scratchListElemAtIndex2.d.ts +23 -0
  151. package/lib/exercises/math/scratch/scratchListElemAtIndex2.d.ts.map +1 -0
  152. package/lib/exercises/math/scratch/scratchListElemAtIndex2.js +207 -0
  153. package/lib/exercises/math/scratch/scratchListFilter.d.ts +13 -0
  154. package/lib/exercises/math/scratch/scratchListFilter.d.ts.map +1 -0
  155. package/lib/exercises/math/scratch/scratchListFilter.js +397 -0
  156. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.d.ts +14 -0
  157. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.d.ts.map +1 -0
  158. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.js +347 -0
  159. package/lib/exercises/math/spaceGeometry/basis/index.d.ts +1 -0
  160. package/lib/exercises/math/spaceGeometry/basis/index.d.ts.map +1 -1
  161. package/lib/exercises/math/spaceGeometry/basis/index.js +1 -0
  162. package/lib/exercises/math/spaceGeometry/index.d.ts +2 -0
  163. package/lib/exercises/math/spaceGeometry/index.d.ts.map +1 -1
  164. package/lib/exercises/math/spaceGeometry/index.js +2 -0
  165. package/lib/exercises/math/spaceGeometry/sections/areaOfConeSection.js +3 -3
  166. package/lib/exercises/math/spaceGeometry/solids/index.d.ts +3 -0
  167. package/lib/exercises/math/spaceGeometry/solids/index.d.ts.map +1 -0
  168. package/lib/exercises/math/spaceGeometry/solids/index.js +2 -0
  169. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.d.ts +15 -0
  170. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.d.ts.map +1 -0
  171. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.js +440 -0
  172. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.d.ts +11 -0
  173. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.d.ts.map +1 -0
  174. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.js +1089 -0
  175. package/lib/exercises/math/spaceGeometry/sphere/index.d.ts +3 -0
  176. package/lib/exercises/math/spaceGeometry/sphere/index.d.ts.map +1 -0
  177. package/lib/exercises/math/spaceGeometry/sphere/index.js +2 -0
  178. package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.d.ts +9 -0
  179. package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.d.ts.map +1 -0
  180. package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.js +127 -0
  181. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.d.ts +14 -0
  182. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.d.ts.map +1 -0
  183. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.js +390 -0
  184. package/lib/geogebra/geogebraConstructor.d.ts +2 -0
  185. package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
  186. package/lib/geogebra/geogebraConstructor.js +6 -0
  187. package/lib/index.d.ts +198 -6
  188. package/lib/index.d.ts.map +1 -1
  189. package/lib/math/geometry/point.d.ts +6 -0
  190. package/lib/math/geometry/point.d.ts.map +1 -1
  191. package/lib/math/geometry/point.js +28 -0
  192. package/lib/tree/nodes/equations/equalNode.d.ts +1 -1
  193. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  194. package/lib/tree/nodes/equations/equalNode.js +0 -1
  195. package/lib/tree/utilities/nodeSimplifier.d.ts +1 -1
  196. package/lib/utils/arrays/arrayZip.d.ts +2 -0
  197. package/lib/utils/arrays/arrayZip.d.ts.map +1 -0
  198. package/lib/utils/arrays/arrayZip.js +12 -0
  199. package/package.json +1 -1
@@ -0,0 +1,140 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
+ import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
+ import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
11
+ import { averageWithEffectifs } from "../../../../utils/average.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
14
+ import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
15
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
16
+ const getPropositions = (n, { answer }) => {
17
+ const propositions = [];
18
+ addValidProp(propositions, answer);
19
+ const nbAnwer = answer.unfrenchify();
20
+ propWhile(propositions, n, () => {
21
+ tryToAddWrongProp(propositions, round(nbAnwer + randfloat(-5, 5, 1), 4).frenchify());
22
+ });
23
+ return shuffleProps(propositions, n);
24
+ };
25
+ const getAnswer = (identifiers) => {
26
+ const { bounds, effectifs } = identifiers;
27
+ const centers = bounds
28
+ .slice(0, bounds.length - 1)
29
+ .map((b, i) => round((b + bounds[i + 1]) / 2, 4));
30
+ return round(averageWithEffectifs(centers, effectifs), 1).frenchify();
31
+ };
32
+ const getInstruction = (identifiers) => {
33
+ const { bounds, effectifs } = identifiers;
34
+ const n = effectifs.reduce((acc, curr) => acc + curr, 0);
35
+ return `Un agriculteur a classé les $${n}$ oeufs pondus par ses poules selon leur calibre :
36
+
37
+ ${mdTable([
38
+ [
39
+ "Masse $m$ (en $\\textrm{g})$",
40
+ ...bounds
41
+ .slice(0, bounds.length - 1)
42
+ .map((b, i) => `$${b}\\leq m < ${bounds[i + 1]}$`),
43
+ ],
44
+ ["Effectif", ...effectifs.map((e) => `$${e}$`)],
45
+ ])}
46
+
47
+ Quel est le poids moyen des oeufs ?
48
+
49
+ Arrondir au dixième.`;
50
+ };
51
+ const getHint = () => {
52
+ return `Calcule le centre de chaque classe en faisant la moyenne des valeurs extrêmes de la classe. Puis, calcule la moyenne de la série en prenant comme valeurs les centres des classes.`;
53
+ };
54
+ const getCorrection = (identifiers) => {
55
+ const { bounds, effectifs } = identifiers;
56
+ const centers = bounds
57
+ .slice(0, bounds.length - 1)
58
+ .map((b, i) => round((b + bounds[i + 1]) / 2, 4));
59
+ const n = effectifs.reduce((acc, curr) => acc + curr, 0);
60
+ const avg = averageWithEffectifs(centers, effectifs);
61
+ const sum = centers.reduce((acc, curr, i) => acc + curr * effectifs[i], 0);
62
+ return `On calcule d'abord le centre de chaque classe :
63
+
64
+ ${bounds
65
+ .slice(0, bounds.length - 1)
66
+ .map((b, i) => `$$
67
+ ${frac(add(b, bounds[i + 1]), 2).toTex()} = ${round((b + bounds[i + 1]) / 2, 4).frenchify()}
68
+ $$`)
69
+ .join("\n \n")}
70
+
71
+ On calcule alors la moyenne en multipliant le centre de chaque classe par l'effectif correspondant :
72
+
73
+ ${alignTex([
74
+ [
75
+ "",
76
+ frac(operatorComposition(AddNode, centers.map((c, i) => multiply(c, effectifs[i]))), n).toTex(),
77
+ ],
78
+ ["=", frac(sum, n).toTex()],
79
+ approxOrEqual(avg, 1),
80
+ ])}
81
+
82
+ Le poids moyen des oeufs est donc de $${round(avg, 1).frenchify()} \\textrm{g}$.
83
+
84
+ `;
85
+ };
86
+ const getKeys = () => {
87
+ return [];
88
+ };
89
+ const isAnswerValid = (ans, { answer }) => {
90
+ try {
91
+ return numberVEA(ans, answer);
92
+ }
93
+ catch (err) {
94
+ return handleVEAError(err);
95
+ }
96
+ };
97
+ const getAverageWithClassesQuestion = () => {
98
+ const effectifs = [randint(5, 20)];
99
+ const bounds = [randint(30, 50)];
100
+ for (let i = 0; i < 3; i++) {
101
+ effectifs.push(randint(5, 20));
102
+ bounds.push(bounds[i] + randint(2, 7));
103
+ }
104
+ bounds.push(bounds[bounds.length - 1] + randint(2, 7));
105
+ const identifiers = {
106
+ situation: 0,
107
+ effectifs: effectifs,
108
+ bounds,
109
+ };
110
+ return getQuestionFromIdentifiers(identifiers);
111
+ };
112
+ const getQuestionFromIdentifiers = (identifiers) => {
113
+ return {
114
+ answer: getAnswer(identifiers),
115
+ instruction: getInstruction(identifiers),
116
+ keys: getKeys(identifiers),
117
+ answerFormat: "tex",
118
+ identifiers,
119
+ hint: getHint(identifiers),
120
+ correction: getCorrection(identifiers),
121
+ };
122
+ };
123
+ export const averageWithClasses = {
124
+ id: "averageWithClasses",
125
+ connector: "=",
126
+ label: "Calculer la moyenne d'une série regroupée en classes",
127
+ isSingleStep: true,
128
+ generator: (nb, opts) => getDistinctQuestions(() => getAverageWithClassesQuestion(opts), nb),
129
+ qcmTimer: 60,
130
+ freeTimer: 60,
131
+ getPropositions,
132
+ isAnswerValid,
133
+ subject: "Mathématiques",
134
+ getInstruction,
135
+ getHint,
136
+ getCorrection,
137
+ getAnswer,
138
+ getQuestionFromIdentifiers,
139
+ hasHintAndCorrection: true,
140
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"averageWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageWithTable.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAQ9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAsHF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
1
+ {"version":3,"file":"averageWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageWithTable.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAQ9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AA4HF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
@@ -70,7 +70,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
70
70
  keys: [],
71
71
  answerFormat: "tex",
72
72
  identifiers,
73
- style: { tableHasNoHeader: true },
73
+ style: {
74
+ tableOptions: {
75
+ firstColumnIsHeader: true,
76
+ firstCellIsDivided: false,
77
+ firstRowIsHeader: false,
78
+ },
79
+ },
74
80
  hint: getHint(identifiers),
75
81
  correction: getCorrection(identifiers),
76
82
  };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercise.js";
2
+ type Identifiers = {
3
+ randomValues: number[];
4
+ randomEffectives: number[];
5
+ };
6
+ export declare const averageWithTableWithContext: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=averageWithTableWithContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"averageWithTableWithContext.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageWithTableWithContext.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAQ9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AA4HF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAe7D,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { randint } from "../../../../math/utils/random/randint.js";
2
+ import { round } from "../../../../math/utils/round.js";
3
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
4
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
5
+ import { dollarize } from "../../../../utils/latex/dollarize.js";
6
+ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercise.js";
7
+ import { getDistinctQuestions } from "../../../utils/getDistinctQuestions.js";
8
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
9
+ import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
10
+ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
11
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
12
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
13
+ const getHint = () => {
14
+ return `Multiplie chaque note par son coefficient, puis additionne les résultats obtenus, et divise le tout par la somme des coefficients.`;
15
+ };
16
+ const getCorrection = (identifiers) => {
17
+ const { randomEffectives, randomValues } = identifiers;
18
+ const sumEff = operatorComposition(AddNode, randomEffectives.map((e) => e.toTree()));
19
+ const sumProd = operatorComposition(AddNode, randomValues.map((e, i) => multiply(randomEffectives[i].toTree(), e.toTree())));
20
+ const fraction = frac(sumProd, sumEff);
21
+ return `La moyenne est égale à :
22
+
23
+ $$
24
+ ${fraction.toSimplificationTex()}
25
+ $$
26
+ `;
27
+ };
28
+ const getInstruction = ({ randomEffectives, randomValues, }) => {
29
+ return `Voici les notes en mathématiques d'un élève au premier trimestre :
30
+
31
+ ${mdTable([
32
+ ["Note sur $20$", ...randomValues.map((e) => dollarize(e))],
33
+ ["Coefficient", ...randomEffectives.map((e) => dollarize(e))],
34
+ ])}
35
+
36
+ Calculer la moyenne (arrondir au centième).`;
37
+ };
38
+ const getAnswer = (identifiers) => {
39
+ const { randomEffectives, randomValues } = identifiers;
40
+ let average = 0;
41
+ for (let i = 0; i < randomValues.length; i++)
42
+ average += randomValues[i] * randomEffectives[i];
43
+ const sumEffectives = randomEffectives.reduce((sum, value) => sum + value, 0);
44
+ average /= sumEffectives;
45
+ average = round(average, 2);
46
+ const answer = (average + "").replace(".", ",");
47
+ return answer;
48
+ };
49
+ const getAverageWithTableQuestion = () => {
50
+ const getRandomUniqueValues = (count, min, max) => {
51
+ let counter = 0;
52
+ const uniqueValues = new Set();
53
+ while (uniqueValues.size < count) {
54
+ counter++;
55
+ if (counter > 1000)
56
+ throw new Error("Too many iterations in averageWithTable");
57
+ uniqueValues.add(randint(min, max));
58
+ }
59
+ return Array.from(uniqueValues).sort((a, b) => a - b);
60
+ };
61
+ const randomValues = getRandomUniqueValues(4, 1, 20);
62
+ const randomEffectives = [1, 2, 3, 4].map(() => randint(1, 6));
63
+ const identifiers = { randomEffectives, randomValues };
64
+ return getQuestionFromIdentifiers(identifiers);
65
+ };
66
+ const getQuestionFromIdentifiers = (identifiers) => {
67
+ const question = {
68
+ instruction: getInstruction(identifiers),
69
+ answer: getAnswer(identifiers),
70
+ keys: [],
71
+ answerFormat: "tex",
72
+ identifiers,
73
+ style: {
74
+ tableOptions: {
75
+ firstColumnIsHeader: true,
76
+ firstCellIsDivided: false,
77
+ firstRowIsHeader: false,
78
+ },
79
+ },
80
+ hint: getHint(identifiers),
81
+ correction: getCorrection(identifiers),
82
+ };
83
+ return question;
84
+ };
85
+ const getPropositions = (n, { answer }) => {
86
+ const propositions = [];
87
+ addValidProp(propositions, answer);
88
+ const average = Number(answer.replace(",", "."));
89
+ propWhile(propositions, n, () => {
90
+ tryToAddWrongProp(propositions, round(average + randint(-average, 20 - average, [0]) + randint(1, 100) / 100, 2)
91
+ .toString()
92
+ .replace(".", ","));
93
+ });
94
+ return shuffle(propositions);
95
+ };
96
+ const isAnswerValid = (ans, { answer }) => {
97
+ return numberVEA(ans, answer);
98
+ };
99
+ export const averageWithTableWithContext = {
100
+ id: "averageWithTableWithContext",
101
+ connector: "=",
102
+ label: "Calcul de la moyenne de notes coefficientées",
103
+ isSingleStep: false,
104
+ generator: (nb) => getDistinctQuestions(getAverageWithTableQuestion, nb),
105
+ qcmTimer: 60,
106
+ freeTimer: 60,
107
+ getPropositions,
108
+ isAnswerValid,
109
+ subject: "Mathématiques",
110
+ getQuestionFromIdentifiers,
111
+ hasHintAndCorrection: true,
112
+ shouldHaveCalculator: true,
113
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"calculateMeanFromFrequencies.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAwGF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAqB9D,CAAC"}
1
+ {"version":3,"file":"calculateMeanFromFrequencies.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA+GF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAqB9D,CAAC"}
@@ -87,6 +87,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
87
87
  identifiers,
88
88
  hint: getHint(identifiers),
89
89
  correction: getCorrection(identifiers),
90
+ style: {
91
+ tableOptions: {
92
+ firstColumnIsHeader: true,
93
+ firstCellIsDivided: false,
94
+ firstRowIsHeader: false,
95
+ },
96
+ },
90
97
  };
91
98
  };
92
99
  export const calculateMeanFromFrequencies = {
@@ -1 +1 @@
1
- {"version":3,"file":"cumulativeSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/cumulativeSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4GF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
1
+ {"version":3,"file":"cumulativeSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/cumulativeSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmHF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
@@ -84,6 +84,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
84
84
  identifiers,
85
85
  hint: getHint(identifiers),
86
86
  correction: getCorrection(identifiers),
87
+ style: {
88
+ tableOptions: {
89
+ firstColumnIsHeader: true,
90
+ firstCellIsDivided: false,
91
+ firstRowIsHeader: false,
92
+ },
93
+ },
87
94
  };
88
95
  };
89
96
  export const cumulativeSum = {
@@ -1 +1 @@
1
- {"version":3,"file":"etendueTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/etendueTable.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAuGF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
1
+ {"version":3,"file":"etendueTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/etendueTable.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AA6GF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
@@ -56,7 +56,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
56
56
  keys: [],
57
57
  answerFormat: "tex",
58
58
  identifiers,
59
- style: { tableHasNoHeader: true },
59
+ style: {
60
+ tableOptions: {
61
+ firstColumnIsHeader: true,
62
+ firstCellIsDivided: false,
63
+ firstRowIsHeader: false,
64
+ },
65
+ },
60
66
  hint: getHint(identifiers),
61
67
  correction: getCorrection(identifiers),
62
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getQuartileProportionQuestion.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAgOF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}
1
+ {"version":3,"file":"getQuartileProportionQuestion.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAuOF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}
@@ -173,6 +173,13 @@ const getQuestionFromIdentifiers = (identifiers) => ({
173
173
  identifiers,
174
174
  hint: getHint(identifiers),
175
175
  correction: getCorrection(identifiers),
176
+ style: {
177
+ tableOptions: {
178
+ firstColumnIsHeader: true,
179
+ firstCellIsDivided: false,
180
+ firstRowIsHeader: true,
181
+ },
182
+ },
176
183
  });
177
184
  export const getQuartileProportionQuestion = {
178
185
  id: "getQuartileProportionQuestion",
@@ -21,4 +21,6 @@ export * from "./getQuartileProportionQuestion.js";
21
21
  export * from "./interpretIndicatorsForLists.js";
22
22
  export * from "./plausibilityOfAverage.js";
23
23
  export * from "./etendueTable.js";
24
+ export * from "./averageWithClasses.js";
25
+ export * from "./averageWithTableWithContext.js";
24
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,oBAAoB,CAAC;AACnC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,oBAAoB,CAAC;AACnC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC"}
@@ -21,3 +21,5 @@ export * from "./getQuartileProportionQuestion.js";
21
21
  export * from "./interpretIndicatorsForLists.js";
22
22
  export * from "./plausibilityOfAverage.js";
23
23
  export * from "./etendueTable.js";
24
+ export * from "./averageWithClasses.js";
25
+ export * from "./averageWithTableWithContext.js";
@@ -1 +1 @@
1
- {"version":3,"file":"interquartilesTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/interquartilesTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAmHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAerD,CAAC"}
1
+ {"version":3,"file":"interquartilesTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/interquartilesTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAuHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAerD,CAAC"}
@@ -92,7 +92,11 @@ const getQuestionFromIdentifiers = (identifiers) => {
92
92
  hint: getHint(identifiers),
93
93
  correction: getCorrection(identifiers),
94
94
  style: {
95
- tableHasNoHeader: true,
95
+ tableOptions: {
96
+ firstColumnIsHeader: true,
97
+ firstCellIsDivided: false,
98
+ firstRowIsHeader: false,
99
+ },
96
100
  },
97
101
  };
98
102
  return question;
@@ -1 +1 @@
1
- {"version":3,"file":"marginalAndConditionalFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EAYT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA4LF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"marginalAndConditionalFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EAYT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmMF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAajE,CAAC"}
@@ -140,6 +140,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
140
140
  keys: ["f", "cap", "underscore"],
141
141
  answerFormat: "tex",
142
142
  identifiers,
143
+ style: {
144
+ tableOptions: {
145
+ firstColumnIsHeader: true,
146
+ firstCellIsDivided: false,
147
+ firstRowIsHeader: true,
148
+ },
149
+ },
143
150
  };
144
151
  return question;
145
152
  };
@@ -4,7 +4,9 @@ type Identifiers = {
4
4
  };
5
5
  type Options = {
6
6
  nbValues: string;
7
+ isOrdered: boolean;
7
8
  };
8
9
  export declare const medianWithList: Exercise<Identifiers, Options>;
10
+ export declare const medianWithListUnorderedVariant: Exercise<Identifiers, Options>;
9
11
  export {};
10
12
  //# sourceMappingURL=medianWithList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"medianWithList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/medianWithList.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EAkBT,MAAM,sBAAsB,CAAC;AAE9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA2FF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAsBF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAezD,CAAC"}
1
+ {"version":3,"file":"medianWithList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/medianWithList.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EAkBT,MAAM,sBAAsB,CAAC;AAE9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAyIF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAsBF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBzD,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBzE,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { randint } from "../../../../math/utils/random/randint.js";
2
2
  import { median } from "../../../../math/utils/stats/median.js";
3
3
  import { random } from "../../../../utils/alea/random.js";
4
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
4
5
  import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercise.js";
5
6
  import { getDistinctQuestions } from "../../../utils/getDistinctQuestions.js";
6
7
  const getInstruction = (identifiers) => {
@@ -15,16 +16,37 @@ Déterminer la médiane de cette liste de valeurs.`;
15
16
  };
16
17
  const getAnswer = (identifiers) => {
17
18
  const { sortedValues } = identifiers;
18
- return median(sortedValues).frenchify();
19
+ return median([...sortedValues].sort((a, b) => a - b)).frenchify();
19
20
  };
20
- const getHint = () => {
21
- return `La médiane est la valeur centrale de la série : il y a autant de valeur inférieures à la médiane que de valeurs supérieures à la médiane.`;
21
+ const getHint = (_, opts) => {
22
+ return `La médiane est la valeur centrale de la série : il y a autant de valeur inférieures à la médiane que de valeurs supérieures à la médiane.
23
+
24
+ ${opts?.isOrdered
25
+ ? "Les valeurs sont déjà rangées par ordre croissant."
26
+ : "Commence par ranger les valeurs dans l'ordre croissant."}`;
22
27
  };
23
- const getCorrection = (identifiers) => {
28
+ const getCorrection = (identifiers, opts) => {
24
29
  const { sortedValues } = identifiers;
25
30
  const total = sortedValues.length;
26
31
  const rank = total / 2;
27
- return `Il y a $${total}$ valeurs dans la liste.
32
+ return `${(() => {
33
+ if (!opts?.isOrdered) {
34
+ const sorted = sortedValues.sort((a, b) => a - b);
35
+ return `On range les valeurs de la liste par ordre croissant :
36
+
37
+ $$
38
+ ${sorted.join(";\\ ")}
39
+ $$
40
+
41
+ `;
42
+ }
43
+ else {
44
+ return `Les valeurs de la liste sont rangées dans l'ordre croissant.
45
+ `;
46
+ }
47
+ })()}
48
+
49
+ Il y a $${total}$ valeurs dans la liste.
28
50
 
29
51
  Puisque $\\frac{${total}}{2} = ${rank.frenchify()}$, la médiane est ${rank % 1 === 0
30
52
  ? `entre la $${rank}$ème et la $${rank + 1}$ème valeur.`
@@ -45,16 +67,33 @@ const isAnswerValid = (ans, { answer }) => {
45
67
  return ans === answer;
46
68
  };
47
69
  const getMedianList = (optsIn) => {
48
- const arrayedOptions = optsIn ?? optsDefault;
70
+ const arrayedOptions = optsIn;
49
71
  const opts = {
50
- nbValues: random(arrayedOptions.nbValues),
72
+ nbValues: random(arrayedOptions.nbValues ?? optsDefault.nbValues),
73
+ isOrdered: optsIn?.isOrdered ?? true,
51
74
  };
52
- const randomValues = [];
53
75
  const length = Number(opts.nbValues);
54
- for (let i = 0; i < length; i++)
55
- randomValues.push(randint(1, 20));
76
+ const randomValues = [...Array(length).keys()].map(() => randint(1, 20));
56
77
  const sortedValues = randomValues.sort((a, b) => a - b);
57
- const identifiers = { sortedValues };
78
+ let values;
79
+ if (opts.isOrdered) {
80
+ values = sortedValues;
81
+ }
82
+ else {
83
+ //ensure unordered
84
+ let counter = -1;
85
+ let isValid = false;
86
+ while (!isValid && counter < 100) {
87
+ counter++;
88
+ values = shuffle(randomValues);
89
+ isValid = !randomValues.every((v, i) => v === sortedValues[i]);
90
+ }
91
+ if (!isValid) {
92
+ const randomValuesDesperateCall = [...Array(length).keys()].map(() => randint(1, 20));
93
+ values = randomValuesDesperateCall;
94
+ }
95
+ }
96
+ const identifiers = { sortedValues: values };
58
97
  return getQuestionFromIdentifiers(identifiers);
59
98
  };
60
99
  const getQuestionFromIdentifiers = (identifiers, opts) => {
@@ -64,8 +103,8 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
64
103
  keys: [],
65
104
  answerFormat: "tex",
66
105
  identifiers,
67
- hint: getHint(identifiers),
68
- correction: getCorrection(identifiers),
106
+ hint: getHint(identifiers, opts),
107
+ correction: getCorrection(identifiers, opts),
69
108
  options: opts,
70
109
  };
71
110
  return question;
@@ -88,7 +127,7 @@ export const medianWithList = {
88
127
  connector: "=",
89
128
  label: "Calcul de la médiane d'une liste de valeurs",
90
129
  isSingleStep: false,
91
- generator: (nb, opts) => getDistinctQuestions(() => getMedianList(opts), nb),
130
+ generator: (nb, opts) => getDistinctQuestions(() => getMedianList(Object.assign({}, opts, { isOrdered: true })), nb),
92
131
  options,
93
132
  qcmTimer: 60,
94
133
  freeTimer: 60,
@@ -98,3 +137,17 @@ export const medianWithList = {
98
137
  getQuestionFromIdentifiers,
99
138
  hasHintAndCorrection: true,
100
139
  };
140
+ export const medianWithListUnorderedVariant = {
141
+ id: "medianWithListUnorderedVariant",
142
+ connector: "=",
143
+ label: "Calcul de la médiane d'une liste de valeurs non ordonnée",
144
+ isSingleStep: false,
145
+ generator: (nb, opts) => getDistinctQuestions(() => getMedianList(Object.assign({}, opts, { isOrdered: false })), nb),
146
+ qcmTimer: 60,
147
+ freeTimer: 60,
148
+ getPropositions,
149
+ isAnswerValid,
150
+ subject: "Mathématiques",
151
+ getQuestionFromIdentifiers,
152
+ hasHintAndCorrection: true,
153
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"medianWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/medianWithTable.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AA2HF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
1
+ {"version":3,"file":"medianWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/medianWithTable.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAiIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
@@ -79,7 +79,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
79
79
  keys: [],
80
80
  answerFormat: "tex",
81
81
  identifiers,
82
- style: { tableHasNoHeader: true },
82
+ style: {
83
+ tableOptions: {
84
+ firstColumnIsHeader: true,
85
+ firstCellIsDivided: false,
86
+ firstRowIsHeader: false,
87
+ },
88
+ },
83
89
  hint: getHint(identifiers),
84
90
  correction: getCorrection(identifiers),
85
91
  };
@@ -1 +1 @@
1
- {"version":3,"file":"quartiles.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartiles.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAgIF,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,WAAW,CAc3C,CAAC"}
1
+ {"version":3,"file":"quartiles.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartiles.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAsIF,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,WAAW,CAc3C,CAAC"}
@@ -86,7 +86,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
86
86
  keys: [],
87
87
  answerFormat: "tex",
88
88
  identifiers,
89
- style: { tableHasNoHeader: true },
89
+ style: {
90
+ tableOptions: {
91
+ firstColumnIsHeader: true,
92
+ firstCellIsDivided: false,
93
+ firstRowIsHeader: false,
94
+ },
95
+ },
90
96
  hint: getHint(identifiers),
91
97
  correction: getCorrection(identifiers),
92
98
  };
@@ -1 +1 @@
1
- {"version":3,"file":"standardDeviationTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/standardDeviationTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAkJF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAexD,CAAC"}
1
+ {"version":3,"file":"standardDeviationTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/standardDeviationTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAsJF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAexD,CAAC"}
@@ -123,7 +123,11 @@ const getQuestionFromIdentifiers = (identifiers) => {
123
123
  hint: getHint(identifiers),
124
124
  correction: getCorrection(identifiers),
125
125
  style: {
126
- tableHasNoHeader: true,
126
+ tableOptions: {
127
+ firstColumnIsHeader: true,
128
+ firstCellIsDivided: false,
129
+ firstRowIsHeader: false,
130
+ },
127
131
  },
128
132
  };
129
133
  return question;