math-exercises 3.0.190 → 3.0.192

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 (125) hide show
  1. package/lib/exercises/math/dataRepresentations/barChart/barChartInterpreting.d.ts +53 -0
  2. package/lib/exercises/math/dataRepresentations/barChart/barChartInterpreting.d.ts.map +1 -0
  3. package/lib/exercises/math/dataRepresentations/barChart/barChartInterpreting.js +543 -0
  4. package/lib/exercises/math/dataRepresentations/barChart/barChartReading.d.ts +94 -0
  5. package/lib/exercises/math/dataRepresentations/barChart/barChartReading.d.ts.map +1 -0
  6. package/lib/exercises/math/dataRepresentations/barChart/barChartReading.js +280 -0
  7. package/lib/exercises/math/dataRepresentations/barChart/index.d.ts +3 -0
  8. package/lib/exercises/math/dataRepresentations/barChart/index.d.ts.map +1 -0
  9. package/lib/exercises/math/dataRepresentations/barChart/index.js +2 -0
  10. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotInterpreting.d.ts +7 -0
  11. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotInterpreting.d.ts.map +1 -0
  12. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotInterpreting.js +223 -0
  13. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReading.d.ts +9 -0
  14. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReading.d.ts.map +1 -0
  15. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReading.js +133 -0
  16. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReadingPercentages.d.ts +11 -0
  17. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReadingPercentages.d.ts.map +1 -0
  18. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReadingPercentages.js +198 -0
  19. package/lib/exercises/math/dataRepresentations/boxPlot/compareBoxPlot.d.ts +13 -0
  20. package/lib/exercises/math/dataRepresentations/boxPlot/compareBoxPlot.d.ts.map +1 -0
  21. package/lib/exercises/math/dataRepresentations/boxPlot/compareBoxPlot.js +192 -0
  22. package/lib/exercises/math/dataRepresentations/boxPlot/index.d.ts +5 -0
  23. package/lib/exercises/math/dataRepresentations/boxPlot/index.d.ts.map +1 -0
  24. package/lib/exercises/math/dataRepresentations/boxPlot/index.js +4 -0
  25. package/lib/exercises/math/dataRepresentations/index.d.ts +4 -7
  26. package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
  27. package/lib/exercises/math/dataRepresentations/index.js +4 -11
  28. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts +6 -0
  29. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts.map +1 -0
  30. package/lib/exercises/math/dataRepresentations/scatterPlot/index.js +5 -0
  31. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts +12 -0
  32. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts.map +1 -0
  33. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.js +206 -0
  34. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts +9 -0
  35. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts.map +1 -0
  36. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.js +210 -0
  37. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts +10 -0
  38. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts.map +1 -0
  39. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.js +252 -0
  40. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts +12 -0
  41. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map +1 -0
  42. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.js +352 -0
  43. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts +11 -0
  44. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts.map +1 -0
  45. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.js +403 -0
  46. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.d.ts +7 -0
  47. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.d.ts.map +1 -0
  48. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.js +222 -0
  49. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.d.ts +7 -0
  50. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.d.ts.map +1 -0
  51. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.js +187 -0
  52. package/lib/exercises/math/dataRepresentations/tables/index.d.ts +4 -0
  53. package/lib/exercises/math/dataRepresentations/tables/index.d.ts.map +1 -0
  54. package/lib/exercises/math/dataRepresentations/tables/index.js +3 -0
  55. package/lib/exercises/math/dataRepresentations/tables/tableReading.d.ts +8 -0
  56. package/lib/exercises/math/dataRepresentations/tables/tableReading.d.ts.map +1 -0
  57. package/lib/exercises/math/dataRepresentations/tables/tableReading.js +109 -0
  58. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.d.ts +8 -0
  59. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.d.ts.map +1 -0
  60. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.js +145 -0
  61. package/lib/exercises/math/derivation/applications/index.d.ts +1 -0
  62. package/lib/exercises/math/derivation/applications/index.d.ts.map +1 -1
  63. package/lib/exercises/math/derivation/applications/index.js +1 -0
  64. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +1 -1
  65. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -1
  66. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +4 -1
  67. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts +13 -0
  68. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts.map +1 -0
  69. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.js +205 -0
  70. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts +9 -0
  71. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts.map +1 -0
  72. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.js +157 -0
  73. package/lib/exercises/math/functions/affines/affineVariations.d.ts +12 -0
  74. package/lib/exercises/math/functions/affines/affineVariations.d.ts.map +1 -0
  75. package/lib/exercises/math/functions/affines/affineVariations.js +176 -0
  76. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts +8 -0
  77. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts.map +1 -0
  78. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.js +203 -0
  79. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts +12 -0
  80. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts.map +1 -0
  81. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.js +259 -0
  82. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts +9 -0
  83. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts.map +1 -0
  84. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.js +99 -0
  85. package/lib/exercises/math/functions/exponentials/index.d.ts +5 -0
  86. package/lib/exercises/math/functions/exponentials/index.d.ts.map +1 -1
  87. package/lib/exercises/math/functions/exponentials/index.js +5 -0
  88. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts +10 -0
  89. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts.map +1 -0
  90. package/lib/exercises/math/functions/exponentials/realPowersFraction.js +125 -0
  91. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts +12 -0
  92. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts.map +1 -0
  93. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.js +148 -0
  94. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts +10 -0
  95. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts.map +1 -0
  96. package/lib/exercises/math/functions/exponentials/realPowersPower.js +128 -0
  97. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts +10 -0
  98. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts.map +1 -0
  99. package/lib/exercises/math/functions/exponentials/realPowersProduct.js +128 -0
  100. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -1
  101. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +7 -2
  102. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
  103. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +131 -61
  104. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts +12 -0
  105. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts.map +1 -0
  106. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.js +217 -0
  107. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts +10 -0
  108. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts.map +1 -0
  109. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.js +186 -0
  110. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts +14 -0
  111. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts.map +1 -0
  112. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.js +189 -0
  113. package/lib/exercises/math/sequences/geometric/graph/index.d.ts +2 -0
  114. package/lib/exercises/math/sequences/geometric/graph/index.d.ts.map +1 -0
  115. package/lib/exercises/math/sequences/geometric/graph/index.js +1 -0
  116. package/lib/index.d.ts +53 -25
  117. package/lib/index.d.ts.map +1 -1
  118. package/lib/tree/nodes/algebraicNode.d.ts +3 -0
  119. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  120. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  121. package/lib/tree/nodes/operators/fractionNode.js +5 -3
  122. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  123. package/lib/tree/nodes/operators/multiplyNode.js +5 -3
  124. package/lib/tree/nodes/operators/powerNode.js +1 -1
  125. package/package.json +1 -1
@@ -0,0 +1,403 @@
1
+ import { tryToAddWrongProp, addValidProp, propWhile, shuffleProps, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { greenMain, orange, red } from "../../../../geogebra/colors.js";
5
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
6
+ import { Point, PointConstructor, } from "../../../../math/geometry/point.js";
7
+ import { randint } from "../../../../math/utils/random/randint.js";
8
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
9
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
10
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
11
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
12
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
13
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
14
+ import { probaFlip } from "../../../../utils/alea/probaFlip.js";
15
+ import { probaLawFlip } from "../../../../utils/alea/probaLawFlip.js";
16
+ import { random } from "../../../../utils/alea/random.js";
17
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
18
+ import { getCartesiansProducts } from "../../../../utils/arrays/cartesianProducts.js";
19
+ const getComponentOfPointForStrGroupBy = (point, strGroupBy) => {
20
+ switch (strGroupBy) {
21
+ case "x":
22
+ return point.x;
23
+ case "y":
24
+ return point.y;
25
+ default:
26
+ throw new Error("Unsupported strGroupBy: " + strGroupBy);
27
+ }
28
+ };
29
+ const getTexCondition = (strGroupBy, nodeDataClass) => {
30
+ if (NodeComparator.isEqualViaSub(nodeDataClass.a, nodeDataClass.b)) {
31
+ return `${strGroupBy} = ${nodeDataClass.a.toTex()}`;
32
+ }
33
+ else {
34
+ switch (nodeDataClass.closure) {
35
+ case ClosureType.FF:
36
+ return `${nodeDataClass.a.toTex()} \\leq ${strGroupBy} \\leq ${nodeDataClass.b.toTex()}`;
37
+ case ClosureType.FO:
38
+ return `${nodeDataClass.a.toTex()} \\leq ${strGroupBy} < ${nodeDataClass.b.toTex()}`;
39
+ case ClosureType.OF:
40
+ return `${nodeDataClass.a.toTex()} < ${strGroupBy} \\leq ${nodeDataClass.b.toTex()}`;
41
+ case ClosureType.OO:
42
+ return `${nodeDataClass.a.toTex()} < ${strGroupBy} < ${nodeDataClass.b.toTex()}`;
43
+ }
44
+ }
45
+ };
46
+ const getInstruction = (identifiers) => {
47
+ const { strGroupBy, nodeIdsDataClass } = identifiers;
48
+ const nodeDataClass = NodeConstructor.fromIdentifiers(nodeIdsDataClass);
49
+ return `Si l'on considère le nuage de points ci-dessous,
50
+ combien y a-t-il d'éléments avec $${getTexCondition(strGroupBy, nodeDataClass)}$ ?`;
51
+ };
52
+ const getAnswerNode = (identifiers) => {
53
+ const { pointIds, strGroupBy, nodeIdsDataClass } = identifiers;
54
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
55
+ const nodeDataClass = NodeConstructor.fromIdentifiers(nodeIdsDataClass);
56
+ const count = arrPoint.filter((point) => {
57
+ const nodeComponent = getComponentOfPointForStrGroupBy(point, strGroupBy);
58
+ return nodeDataClass.includes(nodeComponent);
59
+ }).length;
60
+ return count.toTree();
61
+ };
62
+ const getAnswer = (identifiers) => {
63
+ return getAnswerNode(identifiers).toTex();
64
+ };
65
+ const getHint = (identifiers) => {
66
+ const { strGroupBy, nodeIdsDataClass } = identifiers;
67
+ const nodeDataClass = NodeConstructor.fromIdentifiers(nodeIdsDataClass);
68
+ return `Compte le nombre de points qui ont $${getTexCondition(strGroupBy, nodeDataClass)}$.`;
69
+ };
70
+ const getCorrection = (identifiers) => {
71
+ const { strGroupBy, nodeIdsDataClass } = identifiers;
72
+ const nodeDataClass = NodeConstructor.fromIdentifiers(nodeIdsDataClass);
73
+ return `On compte le nombre de points qui ont $${getTexCondition(strGroupBy, nodeDataClass)}$.
74
+
75
+ Il y en a $${getAnswer(identifiers)}$.
76
+ `;
77
+ };
78
+ const getCorrectionGGBOptions = (identifiers) => {
79
+ const { pointIds, strGroupBy, nodeIdsDataClass } = identifiers;
80
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
81
+ const nodeDataClass = NodeConstructor.fromIdentifiers(nodeIdsDataClass);
82
+ const [arrPointFiltered, arrPointDropped] = arrPoint.reduce((acc, point) => {
83
+ const nodeComponent = getComponentOfPointForStrGroupBy(point, strGroupBy);
84
+ if (nodeDataClass.includes(nodeComponent)) {
85
+ acc[0].push(point);
86
+ }
87
+ else {
88
+ acc[1].push(point);
89
+ }
90
+ return acc;
91
+ }, [[], []]);
92
+ const commands = [
93
+ ...[arrPointFiltered, arrPointDropped].flatMap((arrPoint, i) => arrPoint.flatMap((point) => point.toGGBCommand({
94
+ isFixed: true,
95
+ isSelectionnable: true,
96
+ showLabel: false,
97
+ size: 6,
98
+ style: 3,
99
+ color: i % 2 === 0 ? greenMain : "#000000",
100
+ }))),
101
+ ...(() => {
102
+ switch (strGroupBy) {
103
+ case "x":
104
+ return [nodeDataClass].flatMap((nodeInterval, i) => {
105
+ return [
106
+ ...(() => {
107
+ const value = nodeInterval.a.evaluate();
108
+ return [
109
+ `l${i}l = Line((${value}, 0),(${value}, 1))`,
110
+ `SetColor(l${i}l, "${(() => {
111
+ switch (nodeInterval.closure) {
112
+ case ClosureType.FF:
113
+ case ClosureType.FO:
114
+ return orange;
115
+ case ClosureType.OF:
116
+ case ClosureType.OO:
117
+ return red;
118
+ }
119
+ })()}")`,
120
+ ];
121
+ })(),
122
+ ...(() => {
123
+ const value = nodeInterval.b.evaluate();
124
+ return [
125
+ `l${i}h = Line((${value}, 0),(${value}, 1))`,
126
+ `SetColor(l${i}h, "${(() => {
127
+ switch (nodeInterval.closure) {
128
+ case ClosureType.FF:
129
+ case ClosureType.OF:
130
+ return orange;
131
+ case ClosureType.FO:
132
+ case ClosureType.OO:
133
+ return red;
134
+ }
135
+ })()}")`,
136
+ ];
137
+ })(),
138
+ ];
139
+ });
140
+ case "y":
141
+ return [nodeDataClass].flatMap((nodeInterval, i) => {
142
+ return [
143
+ ...(() => {
144
+ const value = nodeInterval.a.evaluate();
145
+ return [
146
+ `l${i}l = Line((0, ${value}),(1,${value}))`,
147
+ `SetColor(l${i}l, "${(() => {
148
+ switch (nodeInterval.closure) {
149
+ case ClosureType.FF:
150
+ case ClosureType.FO:
151
+ return orange;
152
+ case ClosureType.OF:
153
+ case ClosureType.OO:
154
+ return red;
155
+ }
156
+ })()}")`,
157
+ ];
158
+ })(),
159
+ ...(() => {
160
+ const value = nodeInterval.b.evaluate();
161
+ return [
162
+ `l${i}h = Line((0, ${value}),(1,${value}))`,
163
+ `SetColor(l${i}h, "${(() => {
164
+ switch (nodeInterval.closure) {
165
+ case ClosureType.FF:
166
+ case ClosureType.OF:
167
+ return orange;
168
+ case ClosureType.FO:
169
+ case ClosureType.OO:
170
+ return red;
171
+ }
172
+ })()}")`,
173
+ ];
174
+ })(),
175
+ ];
176
+ });
177
+ default:
178
+ throw new Error("Unsupported strGroupBy: " + strGroupBy);
179
+ }
180
+ })(),
181
+ ];
182
+ const ggb = new GeogebraConstructor({
183
+ commands,
184
+ hideGrid: true,
185
+ fontSize: 16,
186
+ xAxis: {
187
+ showPositive: true,
188
+ label: "x",
189
+ steps: 1,
190
+ },
191
+ yAxis: {
192
+ showPositive: true,
193
+ label: "y",
194
+ steps: 1,
195
+ },
196
+ });
197
+ return ggb.getOptions({
198
+ coords: ggb.getAdaptedCoords({
199
+ xMin: -1,
200
+ xMax: 6,
201
+ yMin: -1,
202
+ yMax: 6,
203
+ }),
204
+ });
205
+ };
206
+ const getGGBOptions = (identifiers) => {
207
+ const { pointIds } = identifiers;
208
+ const arrPoint = pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
209
+ const commands = [
210
+ ...arrPoint.flatMap((point) => point.toGGBCommand({
211
+ isFixed: true,
212
+ isSelectionnable: true,
213
+ showLabel: false,
214
+ size: 5,
215
+ style: 3,
216
+ })),
217
+ ];
218
+ const ggb = new GeogebraConstructor({
219
+ commands,
220
+ hideGrid: false,
221
+ fontSize: 16,
222
+ xAxis: {
223
+ showPositive: true,
224
+ label: "x",
225
+ steps: 1,
226
+ },
227
+ yAxis: {
228
+ showPositive: true,
229
+ label: "y",
230
+ steps: 1,
231
+ },
232
+ });
233
+ return ggb.getOptions({
234
+ coords: ggb.getAdaptedCoords({
235
+ xMin: -1,
236
+ xMax: 6,
237
+ yMin: -1,
238
+ yMax: 6,
239
+ }),
240
+ });
241
+ };
242
+ const getPropositions = (n, { answer, ...identifiers }) => {
243
+ const { strGroupBy, nodeIdsDataClass } = identifiers;
244
+ const nodeDataClass = NodeConstructor.fromIdentifiers(nodeIdsDataClass);
245
+ const propositions = [];
246
+ addValidProp(propositions, answer);
247
+ const arrTerror = [answer];
248
+ //student: wrong groupBy
249
+ {
250
+ const identifiersWrong = {
251
+ ...identifiers,
252
+ strGroupBy: strGroupBy === "x" ? "y" : "x",
253
+ };
254
+ const texWrong = getAnswer(identifiersWrong);
255
+ tryToAddWrongProp(propositions, texWrong);
256
+ arrTerror.push(texWrong);
257
+ }
258
+ //student: wrong closure
259
+ {
260
+ [ClosureType.FF, ClosureType.FO, ClosureType.OF].forEach((closure) => {
261
+ const nodeDataClassWrong = new IntervalNode(nodeDataClass.a, nodeDataClass.b, closure);
262
+ const identifiersWrong = {
263
+ ...identifiers,
264
+ nodeIdsDataClass: nodeDataClassWrong.toIdentifiers(),
265
+ };
266
+ const texWrong = getAnswer(identifiersWrong);
267
+ tryToAddWrongProp(propositions, texWrong);
268
+ arrTerror.push(texWrong);
269
+ });
270
+ }
271
+ //filler
272
+ {
273
+ propWhile(propositions, n, () => {
274
+ const vTerrorTarget = parseInt(random(arrTerror));
275
+ const vTerrorAround = vTerrorTarget + randint(-5, 5);
276
+ if (vTerrorAround >= 0) {
277
+ tryToAddWrongProp(propositions, vTerrorAround.frenchify());
278
+ }
279
+ });
280
+ }
281
+ return shuffleProps(propositions, n);
282
+ };
283
+ const getKeys = () => {
284
+ return [];
285
+ };
286
+ const isAnswerValid = (ans, { answer }) => {
287
+ return numberVEA(ans, answer);
288
+ };
289
+ const getScatterPlotInterpretingQuestion = () => {
290
+ const length = 6;
291
+ const height = 6;
292
+ const arrArrDict1 = getCartesiansProducts([
293
+ [...Array(length).keys()].map((i) => i + 1),
294
+ [...Array(height).keys()].map((i) => i + 1),
295
+ ]).map(([x, y]) => {
296
+ return {
297
+ x,
298
+ y,
299
+ isActivated: probaFlip(0.14),
300
+ };
301
+ });
302
+ const arrArrDict2 = getCartesiansProducts([
303
+ [...Array(length - 1).keys()].map((i) => i + 1),
304
+ [...Array(height - 1).keys()].map((i) => i + 1),
305
+ ]).map(([x, y]) => {
306
+ return {
307
+ x: x + 0.333,
308
+ y: y + 0.333,
309
+ isActivated: probaFlip(0.14),
310
+ };
311
+ });
312
+ const arrArrDict3 = getCartesiansProducts([
313
+ [...Array(length - 1).keys()].map((i) => i + 1),
314
+ [...Array(height - 1).keys()].map((i) => i + 1),
315
+ ]).map(([x, y]) => {
316
+ return {
317
+ x: x + 0.666,
318
+ y: y + 0.666,
319
+ isActivated: probaFlip(0.14),
320
+ };
321
+ });
322
+ //at least one point should be activated
323
+ {
324
+ const dictRandom = random(arrArrDict1);
325
+ dictRandom.isActivated = true;
326
+ }
327
+ const arrPoint = [...arrArrDict1, ...arrArrDict2, ...arrArrDict3]
328
+ .filter(({ isActivated }) => isActivated)
329
+ .map(({ x, y }, i) => new Point(`P${i}`, x, y));
330
+ const strGroupBy = coinFlip() ? "x" : "y";
331
+ const nodeDataClass = (() => {
332
+ if (coinFlip()) {
333
+ const nodeV = randint(1, 1 + length).toTree();
334
+ return new IntervalNode(nodeV, nodeV, ClosureType.FF);
335
+ }
336
+ else {
337
+ const templateArrLengthDataClass = probaLawFlip([
338
+ [[1, 1, 1, 2], 0.2],
339
+ [[1, 2, 2], 0.4],
340
+ [[1, 1, 3], 0.3],
341
+ [[2, 3], 0.1],
342
+ ]);
343
+ const arrLengthDataClass = shuffle(templateArrLengthDataClass);
344
+ const arrDataClass = arrLengthDataClass.reduce((acc, lengthDataClass) => {
345
+ const nodeBoundLow = acc.nodeBoundLowWork;
346
+ const nodeBoundHigh = add(nodeBoundLow, lengthDataClass).simplify({
347
+ towardsDistribute: true,
348
+ });
349
+ const closure = random([
350
+ ClosureType.FF,
351
+ ClosureType.FO,
352
+ ClosureType.OF,
353
+ ]);
354
+ const nodeDataClass = new IntervalNode(nodeBoundLow, nodeBoundHigh, closure);
355
+ acc.dataClasses.push(nodeDataClass);
356
+ acc.nodeBoundLowWork = nodeBoundHigh;
357
+ return acc;
358
+ }, {
359
+ nodeBoundLowWork: (1).toTree(),
360
+ dataClasses: [],
361
+ }).dataClasses;
362
+ return random(arrDataClass);
363
+ }
364
+ })();
365
+ const identifiers = {
366
+ pointIds: arrPoint.map((point) => point.toIdentifiers()),
367
+ strGroupBy,
368
+ nodeIdsDataClass: nodeDataClass.toIdentifiers(),
369
+ };
370
+ return getQuestionFromIdentifiers(identifiers);
371
+ };
372
+ const getQuestionFromIdentifiers = (identifiers) => {
373
+ return {
374
+ instruction: getInstruction(identifiers),
375
+ answer: getAnswer(identifiers),
376
+ answerFormat: "tex",
377
+ keys: getKeys(identifiers),
378
+ identifiers,
379
+ hint: getHint(identifiers),
380
+ correction: getCorrection(identifiers),
381
+ correctionGgbOptions: getCorrectionGGBOptions(identifiers),
382
+ ggbOptions: getGGBOptions(identifiers),
383
+ };
384
+ };
385
+ export const scatterPlotInterpreting = {
386
+ id: "scatterPlotInterpreting",
387
+ label: "Interpréter un nuage de points",
388
+ isSingleStep: true,
389
+ generator: (nb, opts) => getDistinctQuestions(() => getScatterPlotInterpretingQuestion(opts), nb),
390
+ qcmTimer: 60,
391
+ freeTimer: 60,
392
+ subject: "Mathématiques",
393
+ getAnswer,
394
+ isAnswerValid,
395
+ getPropositions,
396
+ getInstruction,
397
+ getGGBOptions,
398
+ hasGeogebra: true,
399
+ getQuestionFromIdentifiers,
400
+ getHint,
401
+ getCorrection,
402
+ hasHintAndCorrection: true,
403
+ };
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeffs: (number | undefined)[][];
4
+ };
5
+ export declare const buildDoubleTableFromContext: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=buildDoubleTableFromContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildDoubleTableFromContext.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAAE,CAAC;CAClC,CAAC;AA0NF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAoB7D,CAAC"}
@@ -0,0 +1,222 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { valueTableVEA } from "../../../../exercises/vea/valueTableVEA.js";
3
+ import { randTupleInt } from "../../../../math/utils/random/randTupleInt.js";
4
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
5
+ import { dollarize } from "../../../../utils/latex/dollarize.js";
6
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
7
+ const getAnswerTable = (identifiers) => {
8
+ const { coeffs } = identifiers;
9
+ let done = false;
10
+ let counter = 1;
11
+ const rightCoeffs = coeffs.map((e) => [...e]);
12
+ while (!done && counter < 1000) {
13
+ counter++;
14
+ if (counter > 1000)
15
+ throw new Error("Too many iterations in fillDoubleTable");
16
+ // console.log(rightCoeffs);
17
+ for (let i = 0; i < 9; i++) {
18
+ const cellLine = Math.floor(i / 3);
19
+ const cellColumn = i % 3;
20
+ const cell = rightCoeffs[cellLine][cellColumn];
21
+ if (cell)
22
+ continue;
23
+ const isLineCalculable = rightCoeffs[cellLine].filter((e) => !!e).length === 2;
24
+ if (isLineCalculable) {
25
+ //si total ligne
26
+ if ((cellColumn + 1) % 3 === 0)
27
+ rightCoeffs[cellLine][cellColumn] = rightCoeffs[cellLine]
28
+ .filter((e) => !!e)
29
+ .reduce((acc, e) => acc + e, 0);
30
+ else
31
+ rightCoeffs[cellLine][cellColumn] =
32
+ rightCoeffs[cellLine][2] -
33
+ (rightCoeffs[cellLine][0] ?? rightCoeffs[cellLine][1]);
34
+ }
35
+ const isColCalculable = rightCoeffs[(cellLine + 1) % 3][cellColumn] &&
36
+ rightCoeffs[(cellLine + 2) % 3][cellColumn];
37
+ if (isColCalculable) {
38
+ const prev = rightCoeffs[(cellLine + 1) % 3][cellColumn];
39
+ const next = rightCoeffs[(cellLine + 2) % 3][cellColumn];
40
+ //si total colomne
41
+ if (cellLine === 2)
42
+ rightCoeffs[cellLine][cellColumn] = prev + next;
43
+ else
44
+ rightCoeffs[cellLine][cellColumn] =
45
+ rightCoeffs[2][cellColumn] -
46
+ rightCoeffs[1 - cellLine][cellColumn];
47
+ }
48
+ }
49
+ done = rightCoeffs.every((line) => line.every((a) => a !== undefined));
50
+ }
51
+ return [
52
+ [" ", "Hommes", "Femmes", "Total"],
53
+ ["Plus de $40$ ans", ...rightCoeffs[0].map((e) => e.frenchify())],
54
+ ["Moins de $40$ ans", ...rightCoeffs[1].map((e) => e.frenchify())],
55
+ ["Total", ...rightCoeffs[2].map((e) => e.frenchify())],
56
+ ];
57
+ };
58
+ const getInstruction = (identifiers) => {
59
+ const { coeffs } = identifiers;
60
+ const strings = [
61
+ [
62
+ "hommes de plus de $40$ ans",
63
+ "femmes de plus de $40$ ans",
64
+ "employés de plus de $40$ ans",
65
+ ],
66
+ [
67
+ "hommes de moins de $40$ ans",
68
+ "femmes de moins de $40$ ans",
69
+ "employés de moins de $40$ ans",
70
+ ],
71
+ ["hommes", "femmes", "employés"],
72
+ ];
73
+ const givenStrings = [];
74
+ for (let i = 0; i < coeffs.length; i++) {
75
+ for (let j = 0; j < coeffs[i].length; j++) {
76
+ if (coeffs[i][j] !== undefined)
77
+ givenStrings.push(`$${coeffs[i][j]}$ ${strings[i][j]}`);
78
+ }
79
+ }
80
+ return `Dans une entreprise, il y a :
81
+
82
+ - ${givenStrings[0]};
83
+
84
+ - ${givenStrings[1]};
85
+
86
+ - ${givenStrings[2]};
87
+
88
+ - ${givenStrings[3]}.
89
+
90
+ Compléter le tableau croisé d'effectifs ci-dessous pour décrire la répartition des employés de l'entreprise.`;
91
+ };
92
+ const getHint = () => {
93
+ return `Commence par remplir les cases que l'on peut déterminer grâce aux données de l'énoncé.
94
+
95
+ Puis, détermine les cases manquantes en faisant des additions ou des soustractions.`;
96
+ };
97
+ const getCorrection = (identifiers) => {
98
+ const { coeffs } = identifiers;
99
+ const ansTable = getAnswerTable(identifiers);
100
+ const dollarized = ansTable.map((e, i) => i === 0 ? e : [e[0], ...e.slice(1).map((e) => dollarize(e))]);
101
+ return `On commence par remplir les cases que l'on peut déterminer grâce aux données de l'énoncé :
102
+
103
+ ${mdTable([
104
+ [" ", "Hommes", "Femmes", "Total"],
105
+ [
106
+ "Plus de $40$ ans",
107
+ ...coeffs[0].map((e) => (e ? dollarize(e.frenchify()) : "")),
108
+ ],
109
+ [
110
+ "Moins de $40$ ans",
111
+ ...coeffs[1].map((e) => (e ? dollarize(e.frenchify()) : "")),
112
+ ],
113
+ ["Total", ...coeffs[2].map((e) => (e ? dollarize(e.frenchify()) : ""))],
114
+ ])}
115
+
116
+ Puis, on complète les cases manquantes :
117
+
118
+ ${mdTable(dollarized)}`;
119
+ };
120
+ const getKeys = () => {
121
+ return [];
122
+ };
123
+ const isAnswerTableValid = (ans, { answerTable }) => {
124
+ try {
125
+ return valueTableVEA(ans, answerTable);
126
+ }
127
+ catch (err) {
128
+ return handleVEAError(err);
129
+ }
130
+ };
131
+ function rank(vectors) {
132
+ const basis = [];
133
+ for (let v of vectors) {
134
+ for (const b of basis) {
135
+ v = Math.min(v, v ^ b); // réduction
136
+ }
137
+ if (v !== 0)
138
+ basis.push(v);
139
+ }
140
+ return basis.length;
141
+ }
142
+ const getBuildDoubleTableFromContextQuestion = () => {
143
+ const [a, b, c, d] = randTupleInt(4, {
144
+ from: 1,
145
+ to: 100,
146
+ });
147
+ //on calcule le rang de 4 vecteurs ci-dessous pris au hasard, si linéairement indépendants alors le tableau est remplissable
148
+ const vecs = [
149
+ [1, 0, 0, 0], //A1
150
+ [0, 1, 0, 0], //A2
151
+ [1, 1, 0, 0], //TA
152
+ [0, 0, 1, 0], //B1
153
+ [0, 0, 0, 1], //B2
154
+ [0, 0, 1, 1], //TB
155
+ [1, 0, 1, 0], //T1
156
+ [0, 1, 0, 1], //T2
157
+ [1, 1, 1, 1], //T
158
+ ];
159
+ const coeffs = [
160
+ [a, b, a + b],
161
+ [c, d, c + d],
162
+ [a + c, b + d, a + b + c + d],
163
+ ];
164
+ let choices = [];
165
+ do {
166
+ choices = randTupleInt(4, {
167
+ from: 0,
168
+ to: vecs.length,
169
+ allDifferent: true,
170
+ });
171
+ } while (rank(choices.map((i) => parseInt(vecs[i].join(""), 2))) !== 4);
172
+ for (let i = 0; i < 9; i++) {
173
+ if (choices.includes(i))
174
+ continue;
175
+ coeffs[Math.floor(i / 3)][i % 3] = undefined;
176
+ }
177
+ const identifiers = {
178
+ coeffs,
179
+ };
180
+ return getQuestionFromIdentifiers(identifiers);
181
+ };
182
+ const getQuestionFromIdentifiers = (identifiers) => {
183
+ return {
184
+ answerTable: getAnswerTable(identifiers),
185
+ instruction: getInstruction(identifiers),
186
+ keys: getKeys(identifiers),
187
+ answerFormat: "tex",
188
+ identifiers,
189
+ hint: getHint(identifiers),
190
+ correction: getCorrection(identifiers),
191
+ initTable: [
192
+ [" ", "Hommes", "Femmes", "Total"],
193
+ ["Plus de $40$ ans", "", "", ""],
194
+ ["Moins de $40$ ans", "", "", ""],
195
+ ["Total", "", "", ""],
196
+ ],
197
+ style: {
198
+ tableOptions: {
199
+ firstColumnIsHeader: true,
200
+ firstCellIsDivided: false,
201
+ firstRowIsHeader: true,
202
+ },
203
+ },
204
+ };
205
+ };
206
+ export const buildDoubleTableFromContext = {
207
+ id: "buildDoubleTableFromContext",
208
+ label: "Construire un tableau croisé d'effectifs à partir d'un contexte",
209
+ isSingleStep: true,
210
+ generator: (nb, opts) => getDistinctQuestions(() => getBuildDoubleTableFromContextQuestion(opts), nb),
211
+ qcmTimer: 60,
212
+ freeTimer: 60,
213
+ isAnswerTableValid,
214
+ subject: "Mathématiques",
215
+ getInstruction,
216
+ getHint,
217
+ getCorrection,
218
+ getAnswerTable,
219
+ getQuestionFromIdentifiers,
220
+ hasHintAndCorrection: true,
221
+ answerType: "valueTable",
222
+ };
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeffs: (number | undefined)[][];
4
+ };
5
+ export declare const fillDoubleTable: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=fillDoubleTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fillDoubleTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/tables/fillDoubleTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAAE,CAAC;CAClC,CAAC;AAqLF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAiBjD,CAAC"}