math-exercises 3.0.189 → 3.0.191

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 (138) hide show
  1. package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.js +5 -4
  3. package/lib/exercises/math/calculLitteral/equation/factorizeEquation.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/equation/factorizeEquation.js +9 -8
  5. package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.d.ts.map +1 -1
  6. package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +7 -6
  7. package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -1
  8. package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +5 -4
  9. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts +6 -0
  10. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts.map +1 -0
  11. package/lib/exercises/math/dataRepresentations/scatterPlot/index.js +5 -0
  12. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts +12 -0
  13. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts.map +1 -0
  14. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.js +206 -0
  15. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts +9 -0
  16. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts.map +1 -0
  17. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.js +210 -0
  18. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts +10 -0
  19. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts.map +1 -0
  20. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.js +252 -0
  21. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts +12 -0
  22. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map +1 -0
  23. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.js +352 -0
  24. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts +11 -0
  25. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts.map +1 -0
  26. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.js +403 -0
  27. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts.map +1 -1
  28. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.js +3 -2
  29. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts.map +1 -1
  30. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.js +3 -2
  31. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -1
  32. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +3 -2
  33. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
  34. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +3 -2
  35. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -1
  36. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +3 -2
  37. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -1
  38. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +4 -3
  39. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -1
  40. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +4 -3
  41. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
  42. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +4 -3
  43. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map +1 -1
  44. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.js +3 -2
  45. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts.map +1 -1
  46. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.js +3 -2
  47. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -1
  48. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +8 -4
  49. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts +13 -0
  50. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts.map +1 -0
  51. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.js +205 -0
  52. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts +9 -0
  53. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts.map +1 -0
  54. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.js +157 -0
  55. package/lib/exercises/math/functions/affines/affineVariations.d.ts +12 -0
  56. package/lib/exercises/math/functions/affines/affineVariations.d.ts.map +1 -0
  57. package/lib/exercises/math/functions/affines/affineVariations.js +176 -0
  58. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts +8 -0
  59. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts.map +1 -0
  60. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.js +203 -0
  61. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts +12 -0
  62. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts.map +1 -0
  63. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.js +259 -0
  64. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts.map +1 -1
  65. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.js +8 -6
  66. package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.d.ts +2 -0
  67. package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.d.ts.map +1 -0
  68. package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.js +155 -0
  69. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts +9 -0
  70. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts.map +1 -0
  71. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.js +99 -0
  72. package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.d.ts +8 -0
  73. package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.d.ts.map +1 -0
  74. package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.js +99 -0
  75. package/lib/exercises/math/functions/exponentials/index.d.ts +8 -0
  76. package/lib/exercises/math/functions/exponentials/index.d.ts.map +1 -1
  77. package/lib/exercises/math/functions/exponentials/index.js +9 -0
  78. package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.d.ts +12 -0
  79. package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.d.ts.map +1 -0
  80. package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.js +138 -0
  81. package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.d.ts +8 -0
  82. package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.d.ts.map +1 -0
  83. package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.js +142 -0
  84. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts +10 -0
  85. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts.map +1 -0
  86. package/lib/exercises/math/functions/exponentials/realPowersFraction.js +125 -0
  87. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts +12 -0
  88. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts.map +1 -0
  89. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.js +148 -0
  90. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts +10 -0
  91. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts.map +1 -0
  92. package/lib/exercises/math/functions/exponentials/realPowersPower.js +128 -0
  93. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts +10 -0
  94. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts.map +1 -0
  95. package/lib/exercises/math/functions/exponentials/realPowersProduct.js +128 -0
  96. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -1
  97. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +7 -6
  98. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts.map +1 -1
  99. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.js +3 -2
  100. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.d.ts.map +1 -1
  101. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.js +7 -6
  102. package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
  103. package/lib/exercises/math/percent/percentToDecimal.js +5 -4
  104. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.d.ts.map +1 -1
  105. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.js +5 -4
  106. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  107. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +7 -8
  108. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
  109. package/lib/exercises/math/probaStat/stats1var/medianWithList.js +5 -4
  110. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -1
  111. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +9 -9
  112. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts +12 -0
  113. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts.map +1 -0
  114. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.js +217 -0
  115. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts +10 -0
  116. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts.map +1 -0
  117. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.js +186 -0
  118. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts +14 -0
  119. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts.map +1 -0
  120. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.js +189 -0
  121. package/lib/exercises/math/sequences/geometric/graph/index.d.ts +2 -0
  122. package/lib/exercises/math/sequences/geometric/graph/index.d.ts.map +1 -0
  123. package/lib/exercises/math/sequences/geometric/graph/index.js +1 -0
  124. package/lib/exercises/utils/options/arrayedOptions.d.ts +2 -0
  125. package/lib/exercises/utils/options/arrayedOptions.d.ts.map +1 -0
  126. package/lib/exercises/utils/options/arrayedOptions.js +16 -0
  127. package/lib/index.d.ts +33 -0
  128. package/lib/index.d.ts.map +1 -1
  129. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  130. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +20 -20
  131. package/lib/tree/nodes/algebraicNode.d.ts +3 -0
  132. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  133. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  134. package/lib/tree/nodes/operators/fractionNode.js +5 -3
  135. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  136. package/lib/tree/nodes/operators/multiplyNode.js +5 -3
  137. package/lib/tree/nodes/operators/powerNode.js +1 -1
  138. package/package.json +1 -1
@@ -0,0 +1,210 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
+ import { CloudPoints, CloudPointsConstructor, } from "../../../../math/geometry/CloudPoints.js";
5
+ import { Point, PointConstructor } from "../../../../math/geometry/point.js";
6
+ import { randint } from "../../../../math/utils/random/randint.js";
7
+ import { random, randomMany } from "../../../../utils/alea/random.js";
8
+ const countries = [
9
+ "Lusitalie",
10
+ "Franemagne",
11
+ "Esprèce",
12
+ "Belgarie",
13
+ "Slovégal",
14
+ "Finlange",
15
+ "Suénemark",
16
+ "Cromanie",
17
+ "Polgique",
18
+ "Maltonie",
19
+ ];
20
+ const getInstruction = () => {
21
+ return `Observe ce nuage de points.
22
+
23
+ Parmi les propositions suivantes, lesquelles sont vraies ?`;
24
+ };
25
+ const getHint = () => {
26
+ return `Regarde si les points semblent respecter une règle ou bien pas du tout.`;
27
+ };
28
+ const getCorrection = (identifiers) => {
29
+ const { evolutionType, cloudPointsIdentifiers } = identifiers;
30
+ const allValidProps = propsForEvolutionType[evolutionType];
31
+ const cloudPoints = CloudPointsConstructor.fromIdentifiers(cloudPointsIdentifiers);
32
+ return `Voici tout ce que l'on peut dire sur ce nuage de points :
33
+
34
+ ${allValidProps.join(`
35
+
36
+ `)}
37
+
38
+ ${(() => {
39
+ switch (evolutionType) {
40
+ case "increasing": {
41
+ const [pointLowX, pointHighX] = cloudPoints.points.toSorted((p1, p2) => p1.x.evaluate() - p2.x.evaluate());
42
+ return `En particulier :
43
+
44
+ Le pays ${pointLowX.name} a un faible taux de chômage et une faible croissance du PIB.
45
+
46
+ Le pays ${pointHighX.name} a un fort taux de chômage et une forte croissance du PIB.`;
47
+ }
48
+ case "decreasing": {
49
+ const [pointLowX, pointHighX] = cloudPoints.points.toSorted((p1, p2) => p1.x.evaluate() - p2.x.evaluate());
50
+ return `En particulier :
51
+
52
+ Le pays ${pointLowX.name} a un faible taux de chômage et une forte croissance du PIB.
53
+
54
+ Le pays ${pointHighX.name} a un fort taux de chômage et une faible croissance du PIB.`;
55
+ }
56
+ case "unpredictible": {
57
+ return `En effet,
58
+ il y a des pays avec un taux de chômage faible et une croissance faible,
59
+ il y a des pays avec un taux de chômage faible et une croissance forte,
60
+ il y a des pays avec un taux de chômage fort et une croissance faible,
61
+ il y a des pays avec un taux de chômage fort et une croissance forte.
62
+ `;
63
+ }
64
+ default:
65
+ return ``;
66
+ }
67
+ })()}`;
68
+ };
69
+ const propsForEvolutionType = {
70
+ increasing: [
71
+ `Plus le taux de chômage est élevé et plus la croissance du PIB est élevée.`,
72
+ ],
73
+ decreasing: [
74
+ `Plus le taux de chômage est élevé et plus la croissance du PIB est faible.`,
75
+ ],
76
+ unpredictible: [
77
+ `Il n'y a aucun lien entre le taux de chômage et la croissance du PIB.`,
78
+ ],
79
+ increasingThenDecreasing: [],
80
+ decreasingThenIncreasing: [],
81
+ };
82
+ const getPropositions = (n, { evolutionType }) => {
83
+ const propositions = [];
84
+ const allValidProps = propsForEvolutionType[evolutionType];
85
+ const validPropsPicked = randomMany(propsForEvolutionType[evolutionType], randint(1, propsForEvolutionType[evolutionType].length + 1));
86
+ validPropsPicked.forEach((str) => {
87
+ addValidProp(propositions, str, "raw");
88
+ });
89
+ const invalidProps = [
90
+ ...Object.values(propsForEvolutionType).flatMap((props) => props),
91
+ ].filter((prop) => !allValidProps.includes(prop));
92
+ invalidProps.forEach((str) => {
93
+ tryToAddWrongProp(propositions, str, "raw");
94
+ });
95
+ return shuffleProps(propositions, n);
96
+ };
97
+ const getGGBOptions = (identifiers) => {
98
+ const { cloudPointsIdentifiers } = identifiers;
99
+ const cloudPoints = new CloudPoints(cloudPointsIdentifiers.pointsIdentifiers.map((i) => PointConstructor.fromIdentifiers(i)));
100
+ const commands = cloudPoints.points.flatMap((point, i) => {
101
+ return [
102
+ `${point.name}=Point({${point.getXnumber()},${point.getYnumber()}})`,
103
+ `SetFixed(${point.name},true, false)`,
104
+ `Lbl_{${i}} = Text("\\tiny ${point.name}", (${point.x.toMathString()},${point.y.evaluate() + 0.7}), true, true, 0, 0)`,
105
+ `SetFixed(Lbl_{${i}},true, false)`,
106
+ ];
107
+ });
108
+ const ggb = new GeogebraConstructor({
109
+ commands,
110
+ hideAxes: false,
111
+ hideGrid: false,
112
+ xAxis: {
113
+ steps: 1,
114
+ label: "Chômage (%)",
115
+ },
116
+ yAxis: {
117
+ steps: 0.5,
118
+ label: "Croissance du PIB (%)",
119
+ },
120
+ fontSize: 15,
121
+ });
122
+ const xValues = cloudPoints.points.map((element) => {
123
+ return element.getXnumber();
124
+ });
125
+ const yValues = cloudPoints.points.map((element) => {
126
+ return element.getYnumber();
127
+ });
128
+ const xMin = Math.min(...xValues);
129
+ const xMax = Math.max(...xValues);
130
+ const yMin = Math.min(...yValues);
131
+ const yMax = Math.max(...yValues);
132
+ return ggb.getOptions({
133
+ coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
134
+ });
135
+ };
136
+ const getScatterPlotCommentingQuestion = () => {
137
+ const nbCountries = 6;
138
+ const countriesPicked = randomMany(countries, nbCountries);
139
+ const boxFull = { xMin: 3, xMax: 13, yMin: 0, yMax: 4 };
140
+ const evolutionType = random(["increasing", "decreasing", "unpredictible"]);
141
+ let cloudPointsWithEvoBoxed;
142
+ switch (evolutionType) {
143
+ case "increasing":
144
+ case "decreasing":
145
+ {
146
+ cloudPointsWithEvoBoxed =
147
+ CloudPointsConstructor.cloudPointsByReboxingCloudPoints(CloudPointsConstructor.randomWithEvolutionType(nbCountries, evolutionType), boxFull);
148
+ }
149
+ break;
150
+ case "unpredictible":
151
+ default:
152
+ {
153
+ const nbCountriesTop = Math.floor(nbCountries / 2);
154
+ const nbCountriesBottom = nbCountries - nbCountriesTop;
155
+ const cloudPointsTop = CloudPointsConstructor.cloudPointsByReboxingCloudPoints(CloudPointsConstructor.randomWithEvolutionType(nbCountriesTop, "scatter"), {
156
+ xMin: 0,
157
+ xMax: 1,
158
+ yMin: 0.7,
159
+ yMax: 1,
160
+ });
161
+ const cloudPointsBottom = CloudPointsConstructor.cloudPointsByReboxingCloudPoints(CloudPointsConstructor.randomWithEvolutionType(nbCountriesBottom, "scatter"), {
162
+ xMin: 0,
163
+ xMax: 1,
164
+ yMin: 0,
165
+ yMax: 0.3,
166
+ });
167
+ cloudPointsWithEvoBoxed =
168
+ CloudPointsConstructor.cloudPointsByReboxingCloudPoints(new CloudPoints([
169
+ ...cloudPointsTop.points,
170
+ ...cloudPointsBottom.points,
171
+ ]), boxFull);
172
+ }
173
+ break;
174
+ }
175
+ const namedPoints = cloudPointsWithEvoBoxed.points.map((point, i) => new Point(countriesPicked[i], point.x, point.y));
176
+ const cloudPointsNamed = new CloudPoints(namedPoints);
177
+ const identifiers = {
178
+ cloudPointsIdentifiers: cloudPointsNamed.toIdentifiers(),
179
+ evolutionType,
180
+ };
181
+ return getQuestionFromIdentifiers(identifiers);
182
+ };
183
+ const getQuestionFromIdentifiers = (identifiers) => {
184
+ const question = {
185
+ instruction: getInstruction(identifiers),
186
+ hint: getHint(identifiers),
187
+ correction: getCorrection(identifiers),
188
+ ggbOptions: getGGBOptions(identifiers),
189
+ keys: [],
190
+ answerFormat: "raw",
191
+ identifiers,
192
+ };
193
+ return question;
194
+ };
195
+ export const scatterPlotCommenting = {
196
+ id: "scatterPlotCommenting",
197
+ label: "Commenter un nuage de points",
198
+ isSingleStep: true,
199
+ hasGeogebra: true,
200
+ generator: (nb) => getDistinctQuestions(getScatterPlotCommentingQuestion, nb),
201
+ qcmTimer: 60,
202
+ freeTimer: 60,
203
+ getPropositions,
204
+ getHint,
205
+ getCorrection,
206
+ subject: "Mathématiques",
207
+ getQuestionFromIdentifiers,
208
+ hasHintAndCorrection: true,
209
+ answerType: "QCU",
210
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { PointIdentifiers } from "../../../../math/geometry/point.js";
3
+ type Identifiers = {
4
+ pointIds: PointIdentifiers[];
5
+ strGroupBy: string;
6
+ isTransposed: boolean;
7
+ };
8
+ export declare const scatterPlotFillDataTableFromScatterPlotData: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=scatterPlotFillDataTableFromScatterPlotData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scatterPlotFillDataTableFromScatterPlotData.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AA+CtC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AA4PF,eAAO,MAAM,2CAA2C,EAAE,QAAQ,CAAC,WAAW,CAuB3E,CAAC"}
@@ -0,0 +1,252 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { greenMain } from "../../../../geogebra/colors.js";
3
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
+ import { Point, PointConstructor, } from "../../../../math/geometry/point.js";
5
+ import { frenchify } from "../../../../math/utils/latex/frenchify.js";
6
+ import { numberParser } from "../../../../tree/parsers/numberParser.js";
7
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
8
+ import { random } from "../../../../utils/alea/random.js";
9
+ import { getCartesiansProducts } from "../../../../utils/arrays/cartesianProducts.js";
10
+ import { transpose } from "../../../../utils/arrays/transpose.js";
11
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ const _getStrStatClassForIndexCateg = (indexCateg, data, bounds) => {
13
+ const labels = bounds.map(frenchify);
14
+ const isLastCateg = indexCateg == data.length;
15
+ return `[${labels[indexCateg]};${labels[indexCateg + 1]}${isLastCateg ? "]" : "["}`;
16
+ };
17
+ const getComponentOfPointForStrGroupBy = (point, strGroupBy) => {
18
+ switch (strGroupBy) {
19
+ case "x":
20
+ return point.x.evaluate();
21
+ case "y":
22
+ return point.y.evaluate();
23
+ default:
24
+ throw new Error("Unsupported strGroupBy: " + strGroupBy);
25
+ }
26
+ };
27
+ const getArrValueForScatterPlotData = (arrPoint, strGroupBy) => {
28
+ return [
29
+ ...new Set(arrPoint.map((point) => getComponentOfPointForStrGroupBy(point, strGroupBy))),
30
+ ].toSorted((v1, v2) => v1 - v2);
31
+ };
32
+ const getInstruction = () => {
33
+ return `Remplir le tableau avec les données issues du nuage de points ci-dessous.`;
34
+ };
35
+ const getInitTable = (identifiers) => {
36
+ const { pointIds, strGroupBy, isTransposed } = identifiers;
37
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
38
+ const arrValue = getArrValueForScatterPlotData(arrPoint, strGroupBy);
39
+ const tableRaw = [
40
+ [`$${strGroupBy}$`, ...arrValue.map(() => "\\ ")],
41
+ ["\\text{valeur}", ...arrValue.map(() => "")],
42
+ ["\\text{effectif}", ...arrValue.map(() => "")],
43
+ ];
44
+ return isTransposed ? transpose(tableRaw) : tableRaw;
45
+ };
46
+ const getAnswerTable = (identifiers) => {
47
+ const { pointIds, strGroupBy, isTransposed } = identifiers;
48
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
49
+ const arrValue = getArrValueForScatterPlotData(arrPoint, strGroupBy);
50
+ const arrDict = arrValue.map((value) => {
51
+ const count = arrPoint.filter((point) => getComponentOfPointForStrGroupBy(point, strGroupBy) === value).length;
52
+ return {
53
+ value,
54
+ count,
55
+ };
56
+ });
57
+ const tableRaw = [
58
+ [`$${strGroupBy}$`, ...arrValue.map(() => "\\ ")],
59
+ ["\\text{valeur}", ...arrDict.map(({ value }) => value.frenchify())],
60
+ ["\\text{effectif}", ...arrDict.map(({ count }) => count.frenchify())],
61
+ ];
62
+ return isTransposed ? transpose(tableRaw) : tableRaw;
63
+ };
64
+ const getHint = (identifiers) => {
65
+ const { strGroupBy } = identifiers;
66
+ return `Pour chaque valeur $v$ de ${strGroupBy}, compte le nombre de points qui ont $${strGroupBy}=v$.`;
67
+ };
68
+ const getCorrection = (identifiers) => {
69
+ const { pointIds, strGroupBy } = identifiers;
70
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
71
+ const arrValue = getArrValueForScatterPlotData(arrPoint, strGroupBy);
72
+ const arrDict = arrValue.map((value) => {
73
+ const count = arrPoint.filter((point) => getComponentOfPointForStrGroupBy(point, strGroupBy) === value).length;
74
+ return {
75
+ value,
76
+ count,
77
+ };
78
+ });
79
+ return `Pour chaque valeur $v$ de $${strGroupBy}$, on compte le nombre de points qui ont $${strGroupBy}=v$.
80
+
81
+
82
+ ${arrDict.map(({ value, count }) => `Il y a $${count}$ point${count === 1 ? "" : "s"} qui ${count === 1 ? "a" : "ont"} $${strGroupBy}=${value}$.`).join(`
83
+
84
+ `)}`;
85
+ };
86
+ const getCorrectionGGBOptions = (identifiers) => {
87
+ const { pointIds, strGroupBy } = identifiers;
88
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
89
+ const arrValue = getArrValueForScatterPlotData(arrPoint, strGroupBy);
90
+ const commands = [
91
+ ...arrPoint.flatMap((point) => point.toGGBCommand({
92
+ isFixed: true,
93
+ isSelectionnable: true,
94
+ showLabel: false,
95
+ size: 6,
96
+ style: 3,
97
+ })),
98
+ ...(() => {
99
+ switch (strGroupBy) {
100
+ case "x":
101
+ return arrValue.flatMap((value, i) => [
102
+ `l${i} = Line((${value}, 0),(${value}, 1))`,
103
+ `SetColor(l${i}, "${greenMain}")`,
104
+ ]);
105
+ case "y":
106
+ return arrValue.flatMap((value, i) => [
107
+ `l${i} = Line((0, ${value}),(1, ${value}))`,
108
+ `SetColor(l${i}, "${greenMain}")`,
109
+ ]);
110
+ default:
111
+ throw new Error("Unsupported strGroupBy: " + strGroupBy);
112
+ }
113
+ })(),
114
+ ];
115
+ const ggb = new GeogebraConstructor({
116
+ commands,
117
+ hideGrid: true,
118
+ fontSize: 16,
119
+ xAxis: {
120
+ showPositive: true,
121
+ label: "x",
122
+ steps: 1,
123
+ },
124
+ yAxis: {
125
+ showPositive: true,
126
+ label: "y",
127
+ steps: 1,
128
+ },
129
+ });
130
+ return ggb.getOptions({
131
+ coords: ggb.getAdaptedCoords({
132
+ xMin: -1,
133
+ xMax: 6,
134
+ yMin: -1,
135
+ yMax: 6,
136
+ }),
137
+ });
138
+ };
139
+ const getGGBOptions = (identifiers) => {
140
+ const { pointIds } = identifiers;
141
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
142
+ const commands = [
143
+ ...arrPoint.flatMap((point) => point.toGGBCommand({
144
+ isFixed: true,
145
+ isSelectionnable: true,
146
+ showLabel: false,
147
+ size: 5,
148
+ style: 3,
149
+ })),
150
+ ];
151
+ const ggb = new GeogebraConstructor({
152
+ commands,
153
+ hideGrid: true,
154
+ fontSize: 16,
155
+ xAxis: {
156
+ showPositive: true,
157
+ label: "x",
158
+ steps: 1,
159
+ },
160
+ yAxis: {
161
+ showPositive: true,
162
+ label: "y",
163
+ steps: 1,
164
+ },
165
+ });
166
+ return ggb.getOptions({
167
+ coords: ggb.getAdaptedCoords({
168
+ xMin: -1,
169
+ xMax: 6,
170
+ yMin: -1,
171
+ yMax: 6,
172
+ }),
173
+ });
174
+ };
175
+ const getKeys = () => {
176
+ return [];
177
+ };
178
+ const isAnswerTableValid = (ans, { answerTable }) => {
179
+ try {
180
+ return answerTable.every((rowAnswer, j) => rowAnswer.every((answer, i) => {
181
+ const ansParsed = numberParser(ans[i][j]);
182
+ const answerParsed = numberParser(answer);
183
+ return ansParsed === answerParsed;
184
+ }));
185
+ }
186
+ catch (err) {
187
+ return handleVEAError(err);
188
+ }
189
+ };
190
+ const getScatterPlotFillDataTableFromScatterPlotDataQuestion = () => {
191
+ const length = 5;
192
+ const height = 5;
193
+ const arrArrDict = getCartesiansProducts([
194
+ [...Array(length).keys()].map((i) => i + 1),
195
+ [...Array(height).keys()].map((i) => i + 1),
196
+ ]).map(([x, y]) => {
197
+ return {
198
+ x,
199
+ y,
200
+ isActivated: coinFlip(),
201
+ };
202
+ });
203
+ //at least one point should be activated
204
+ {
205
+ const dictRandom = random(arrArrDict);
206
+ dictRandom.isActivated = true;
207
+ }
208
+ const arrPoint = arrArrDict
209
+ .filter(({ isActivated }) => isActivated)
210
+ .map(({ x, y }) => new Point(`P${x}${y}`, x, y));
211
+ const strGroupBy = coinFlip() ? "x" : "y";
212
+ const isTransposed = coinFlip();
213
+ const identifiers = {
214
+ pointIds: arrPoint.map((point) => point.toIdentifiers()),
215
+ strGroupBy,
216
+ isTransposed,
217
+ };
218
+ return getQuestionFromIdentifiers(identifiers);
219
+ };
220
+ const getQuestionFromIdentifiers = (identifiers) => {
221
+ return {
222
+ instruction: getInstruction(identifiers),
223
+ initTable: getInitTable(identifiers),
224
+ answerTable: getAnswerTable(identifiers),
225
+ answerFormat: "tex",
226
+ keys: getKeys(identifiers),
227
+ identifiers,
228
+ hint: getHint(identifiers),
229
+ correction: getCorrection(identifiers),
230
+ correctionGgbOptions: getCorrectionGGBOptions(identifiers),
231
+ ggbOptions: getGGBOptions(identifiers),
232
+ };
233
+ };
234
+ export const scatterPlotFillDataTableFromScatterPlotData = {
235
+ id: "scatterPlotFillDataTableFromScatterPlotData",
236
+ label: "Remplir un tableau avec les données issues d'un nuage de points",
237
+ isSingleStep: true,
238
+ generator: (nb, opts) => getDistinctQuestions(() => getScatterPlotFillDataTableFromScatterPlotDataQuestion(opts), nb),
239
+ qcmTimer: 60,
240
+ freeTimer: 60,
241
+ subject: "Mathématiques",
242
+ isAnswerTableValid,
243
+ getAnswerTable,
244
+ getInstruction,
245
+ getGGBOptions,
246
+ hasGeogebra: true,
247
+ getQuestionFromIdentifiers,
248
+ getHint,
249
+ getCorrection,
250
+ hasHintAndCorrection: true,
251
+ answerType: "valueTable",
252
+ };
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { PointIdentifiers } from "../../../../math/geometry/point.js";
3
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
4
+ type Identifiers = {
5
+ pointIds: PointIdentifiers[];
6
+ strGroupBy: string;
7
+ isTransposed: boolean;
8
+ nodeIdsDataClasses: NodeIdentifiers[];
9
+ };
10
+ export declare const scatterPlotFillDataTableWithDataClassesFromScatterPlotData: Exercise<Identifiers>;
11
+ export {};
12
+ //# sourceMappingURL=scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AA0B7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,kBAAkB,EAAE,eAAe,EAAE,CAAC;CACvC,CAAC;AAwXF,eAAO,MAAM,0DAA0D,EAAE,QAAQ,CAAC,WAAW,CA2B1F,CAAC"}