math-exercises 3.0.132 → 3.0.133

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 (48) hide show
  1. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts +1 -1
  2. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +5 -5
  4. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/ordering/compareA10N.js +12 -7
  6. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.js +8 -6
  8. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +8 -9
  10. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts.map +1 -1
  11. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.js +4 -4
  12. package/lib/exercises/math/conversion/prefixToNumber.d.ts +0 -2
  13. package/lib/exercises/math/conversion/prefixToNumber.d.ts.map +1 -1
  14. package/lib/exercises/math/conversion/prefixToNumber.js +27 -22
  15. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.js +1 -2
  17. package/lib/exercises/math/geometry/cartesian/index.d.ts +1 -0
  18. package/lib/exercises/math/geometry/cartesian/index.d.ts.map +1 -1
  19. package/lib/exercises/math/geometry/cartesian/index.js +1 -0
  20. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts +6 -9
  21. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
  22. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +60 -137
  23. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts +16 -0
  24. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -0
  25. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +213 -0
  26. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +2 -2
  27. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.js +6 -6
  28. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts +0 -1
  29. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts.map +1 -1
  30. package/lib/exercises/math/probaStat/probaAsSumOfProbas.js +52 -59
  31. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts.map +1 -1
  32. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +70 -23
  33. package/lib/exercises/pc/index.d.ts +0 -1
  34. package/lib/exercises/pc/index.d.ts.map +1 -1
  35. package/lib/exercises/pc/index.js +0 -1
  36. package/lib/exercises/pc/motion/averageSpeed.d.ts +0 -2
  37. package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
  38. package/lib/exercises/pc/motion/averageSpeed.js +28 -36
  39. package/lib/exercises/pc/weight/calculateWeight.d.ts +0 -1
  40. package/lib/exercises/pc/weight/calculateWeight.d.ts.map +1 -1
  41. package/lib/exercises/pc/weight/calculateWeight.js +26 -19
  42. package/lib/index.d.ts +9 -38
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/playgroundUtils.d.ts +3 -0
  45. package/lib/playgroundUtils.d.ts.map +1 -0
  46. package/lib/playgroundUtils.js +13 -0
  47. package/lib/server.js +121 -0
  48. package/package.json +1 -1
@@ -1,56 +1,32 @@
1
- import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
1
  import { toolBarConstructor } from "../../../../exercises/utils/geogebra/toolBarConstructor.js";
3
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
4
3
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
- import { GeogebraParser } from "../../../../geogebra/parsers/geogebraParser.js";
6
4
  import { ggbPointToCoords } from "../../../../geogebra/parsers/ggbPointToCoords.js";
7
5
  import { parseGGBPoints } from "../../../../geogebra/parsers/parseGGBPoints.js";
8
6
  import { Point } from "../../../../math/geometry/point.js";
9
7
  import { NumberType } from "../../../../math/numbers/nombre.js";
10
- import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
8
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
11
9
  import { randint } from "../../../../math/utils/random/randint.js";
12
10
  import { round } from "../../../../math/utils/round.js";
13
- import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
14
- import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
15
- import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
12
+ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
16
13
  import { random } from "../../../../utils/alea/random.js";
17
- const getInstruction = ({ abscissType, absciss2, }) => {
18
- const absciss2Node = NodeConstructor.fromIdentifiers(absciss2);
19
- return `Placer le point d'abscisse $${abscissType === NumberType.Decimal
20
- ? round(absciss2Node.evaluate(), 1).frenchify()
21
- : absciss2Node.toTex()}$ sur la demi-droite graduée ci-dessous :`;
14
+ const getInstruction = ({ abscissTex }) => {
15
+ return `Placer le point d'abscisse $${abscissTex}$ sur la demi-droite graduée ci-dessous :`;
22
16
  };
23
17
  // const getHint: GetHint<Identifiers> = (identifiers) => {};
24
18
  // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
25
- const getGGBAnswer = ({ absciss2 }) => {
26
- const nodeAbciss2 = NodeConstructor.fromIdentifiers(absciss2);
27
- return [`(${nodeAbciss2.evaluate()},0)`];
19
+ const getGGBAnswer = ({ coeff }) => {
20
+ return [`(${coeff},0)`];
28
21
  };
29
- const getStudentGGBOptions = ({ abscissType, absciss1, axisUnit, absciss2, }) => {
30
- const [axisUnitNode, absciss1Node, absciss2Node] = [
31
- axisUnit,
32
- absciss1,
33
- absciss2,
34
- ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
35
- const [valueAxisUnit, valueAbsciss1, valueAbsciss2] = [
36
- axisUnitNode,
37
- absciss1Node,
38
- absciss2Node,
39
- ].map((node) => node.evaluate());
40
- const xMin = Math.min(Math.min(0, valueAbsciss1), valueAbsciss2);
41
- const xMax = Math.max(Math.max(0, valueAbsciss1), valueAbsciss2);
42
- const yxRatio = 0.5;
43
- const yMax = yxRatio * (xMax - xMin);
44
- const yMin = -yMax;
22
+ const getStudentGGBOptions = ({ oneUnitTex, abscissType, }) => {
45
23
  const O = new Point("O", (0).toTree(), (0).toTree());
46
- const I = new Point("I", absciss1Node, (0).toTree());
24
+ const I = new Point("I", (1).toTree(), (0).toTree());
47
25
  const commands = [
48
26
  ...O.toGGBCommand(),
49
- `Text("\\footnotesize 0", (0, ${yMin / 4}), false, true, 0, 0)`,
27
+ `Text("\\footnotesize 0", (0, -0.5), false, true, 0, 0)`,
50
28
  ...I.toGGBCommand(),
51
- `Text("\\footnotesize ${abscissType === NumberType.Decimal
52
- ? round(absciss1Node.evaluate(), 1).frenchify()
53
- : absciss1Node.toTex()}", (${valueAbsciss1}, ${abscissType === NumberType.Rational ? yMin / 2 : yMin / 4}), false, true, 0, 0)`,
29
+ `Text("\\footnotesize ${oneUnitTex}", (1, ${abscissType === NumberType.Rational ? -1 : -0.5}), false, true, 0, 0)`,
54
30
  ];
55
31
  const ggb = new GeogebraConstructor({
56
32
  commands,
@@ -60,7 +36,7 @@ const getStudentGGBOptions = ({ abscissType, absciss1, axisUnit, absciss2, }) =>
60
36
  hideGrid: true,
61
37
  xAxis: {
62
38
  hideNumbers: true,
63
- steps: valueAxisUnit,
39
+ steps: 1,
64
40
  showPositive: true,
65
41
  },
66
42
  yAxis: {
@@ -70,102 +46,73 @@ const getStudentGGBOptions = ({ abscissType, absciss1, axisUnit, absciss2, }) =>
70
46
  forbidShiftDragZoom: true,
71
47
  });
72
48
  return ggb.getOptions({
73
- coords: ggb.getAdaptedCoords({
74
- xMin,
75
- xMax,
76
- yMin,
77
- yMax,
78
- }),
79
- // coords: [xMin, xMax, yMin, yMax],
49
+ coords: [-1, 10, -2, 2],
80
50
  });
81
51
  };
82
- const isGGBAnswerValid = (ans, { absciss2, axisUnit }) => {
83
- const [absciss2Node, axisUnitNode] = [absciss2, axisUnit].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
84
- const commands = ans;
85
- const dictObj = new GeogebraParser(commands).objectDict();
86
- console.log("dictObj:", dictObj);
87
- const strPointA = dictObj["A"];
88
- if (!strPointA) {
89
- return false;
90
- }
91
- const coordsA = ggbPointToCoords(strPointA);
52
+ const isGGBAnswerValid = (ans, { coeff }) => {
92
53
  const points = parseGGBPoints(ans).map((p) => ggbPointToCoords(p));
93
- return (points.length === 3 && //O,I,A
94
- Math.abs(coordsA.y) < 0.5 * axisUnitNode.evaluate() &&
95
- Math.abs(coordsA.x - absciss2Node.evaluate()) <
96
- 0.1 * axisUnitNode.evaluate());
54
+ return (points.length === 1 &&
55
+ Math.abs(points[0].y) < 0.5 &&
56
+ Math.abs(points[0].x - coeff) < 0.1);
97
57
  };
98
- const getPlaceAbscissOnSemiLineQuestion = (optsIn) => {
99
- const arrayedOptions = optsIn ?? optsDefault;
100
- const opts = {
101
- questionType: random(arrayedOptions.questionType),
102
- numberType: random(arrayedOptions.numberType),
103
- };
104
- const abscissType = (() => {
105
- switch (opts.numberType) {
106
- case "Entiers":
107
- return NumberType.Integer;
108
- case "Rationnels":
109
- return NumberType.Rational;
110
- case "Décimaux":
111
- return NumberType.Decimal;
112
- }
113
- })();
114
- //[ [1/2, 2/2, 3/2], [1/3,2/3,3/3,4/3,5/3], ...]
115
- function fracFamilyList() {
116
- const maxDen = 5;
117
- return [...Array(maxDen - 2).keys()]
118
- .map((index) => index + 2)
119
- .map((den) => [...Array(den === 2 ? 3 * den - 1 : 2 * den - 1).keys()]
120
- .map((index) => index + 1)
121
- .filter((num) => opts.questionType === "éviter le comptage"
122
- ? num !== 1 && num !== den
123
- : true)
124
- .map((num) => frac(num, den)));
125
- }
126
- const fracList = random(fracFamilyList());
127
- const den = fracList[0].rightChild;
128
- const factor1 = random(fracList);
129
- const factor2 = random(fracList, [factor1]);
130
- let referenceNum;
131
- let absciss1Node;
132
- let absciss2Node;
58
+ const getPlaceAbscissOnSemiLineQuestion = () => {
59
+ const abscissType = random([
60
+ NumberType.Integer,
61
+ NumberType.Rational,
62
+ NumberType.Decimal,
63
+ ]);
64
+ let absciss, axisUnit, oneUnitTex, abscissTex, coeff;
133
65
  switch (abscissType) {
134
66
  case NumberType.Integer:
135
- {
136
- referenceNum = multiply(randint(1, 13), den);
137
- absciss1Node = multiply(referenceNum, factor1).simplify();
138
- absciss2Node = multiply(referenceNum, factor2).simplify();
139
- }
67
+ axisUnit = randint(1, 10);
68
+ coeff = randint(2, 10);
69
+ absciss = axisUnit * coeff;
70
+ oneUnitTex = axisUnit.frenchify();
71
+ abscissTex = absciss.frenchify();
140
72
  break;
141
73
  case NumberType.Rational:
142
74
  {
143
- referenceNum = random([...Array(19).keys()]
144
- .map((index) => index + 1)
145
- .filter((num) => !dividersOf(num).includes(den.evaluate()))).toTree();
146
- absciss1Node = frac(multiply(referenceNum, factor1.leftChild).simplify(), factor1.rightChild);
147
- absciss2Node = frac(multiply(referenceNum, factor2.leftChild).simplify(), factor2.rightChild);
75
+ const randomFrac = random([
76
+ [1, 2],
77
+ [1, 3],
78
+ [2, 3],
79
+ [1, 4],
80
+ [3, 4],
81
+ [1, 5],
82
+ [2, 5],
83
+ [3, 5],
84
+ [4, 5],
85
+ ]);
86
+ axisUnit = randomFrac[0] / randomFrac[1];
87
+ const oneUnit = new FractionNode(randomFrac[0].toTree(), randomFrac[1].toTree());
88
+ oneUnitTex = oneUnit.toTex();
89
+ coeff = randint(2, 10);
90
+ absciss = axisUnit * coeff;
91
+ abscissTex = new MultiplyNode(oneUnit, coeff.toTree())
92
+ .simplify()
93
+ .toTex();
148
94
  }
149
95
  break;
150
96
  case NumberType.Decimal:
151
97
  default:
152
- {
153
- referenceNum = frac(multiply(randint(1, 13 * 10), den), 10);
154
- absciss1Node = multiply(referenceNum, factor1).simplify();
155
- absciss2Node = multiply(referenceNum, factor2).simplify();
156
- }
98
+ axisUnit = randfloat(0, 5, 1);
99
+ coeff = randint(2, 10);
100
+ absciss = round(axisUnit * coeff, 2);
101
+ oneUnitTex = axisUnit.frenchify();
102
+ abscissTex = absciss.frenchify();
157
103
  break;
158
104
  }
159
- const axisUnitNode = frac(referenceNum, den).simplify();
160
105
  const identifiers = {
106
+ absciss,
107
+ abscissTex,
161
108
  abscissType,
162
- axisUnit: axisUnitNode.toIdentifiers(),
163
- absciss1: absciss1Node.toIdentifiers(),
164
- absciss2: absciss2Node.toIdentifiers(),
109
+ axisUnit,
110
+ coeff,
111
+ oneUnitTex,
165
112
  };
166
113
  return getQuestionFromIdentifiers(identifiers);
167
114
  };
168
- const getQuestionFromIdentifiers = (identifiers, opts) => {
115
+ const getQuestionFromIdentifiers = (identifiers) => {
169
116
  const question = {
170
117
  ggbAnswer: getGGBAnswer(identifiers),
171
118
  instruction: getInstruction(identifiers),
@@ -173,38 +120,14 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
173
120
  identifiers,
174
121
  // hint: getHint(identifiers),
175
122
  // correction: getCorrection(identifiers),
176
- options: opts,
177
123
  };
178
124
  return question;
179
125
  };
180
- const optsDefault = {
181
- questionType: ["standard", "éviter le comptage"],
182
- numberType: ["Entiers", "Rationnels", "Décimaux"],
183
- };
184
- const options = [
185
- {
186
- id: "questionType",
187
- label: "Type de question",
188
- target: GeneratorOptionTarget.generation,
189
- type: GeneratorOptionType.multiselect,
190
- values: ["standard", "éviter le comptage"],
191
- defaultValue: optsDefault.questionType,
192
- },
193
- {
194
- id: "numberType",
195
- label: "Type de nombres",
196
- target: GeneratorOptionTarget.generation,
197
- type: GeneratorOptionType.multiselect,
198
- values: ["Entiers", "Rationnels", "Décimaux"],
199
- defaultValue: optsDefault.numberType,
200
- },
201
- ];
202
126
  export const placeAbscissOnSemiLine = {
203
127
  id: "placeAbscissOnSemiLine",
204
128
  label: "Placer un point d'abscisse donnée sur une demi-droite graduée",
205
129
  isSingleStep: true,
206
- generator: (nb, opts) => getDistinctQuestions(() => getPlaceAbscissOnSemiLineQuestion(opts), nb),
207
- options,
130
+ generator: (nb) => getDistinctQuestions(getPlaceAbscissOnSemiLineQuestion, nb),
208
131
  ggbTimer: 60,
209
132
  isGGBAnswerValid,
210
133
  subject: "Mathématiques",
@@ -0,0 +1,16 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NumberType } from "../../../../math/numbers/nombre.js";
3
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
4
+ type Identifiers = {
5
+ abscissType: NumberType;
6
+ axisUnit: NodeIdentifiers;
7
+ absciss1: NodeIdentifiers;
8
+ absciss2: NodeIdentifiers;
9
+ };
10
+ type Options = {
11
+ questionType: "standard" | "éviter le comptage";
12
+ numberType: "Entiers" | "Rationnels" | "Décimaux";
13
+ };
14
+ export declare const placeAbscissOnSemiLineV2: Exercise<Identifiers, Options>;
15
+ export {};
16
+ //# sourceMappingURL=placeAbscissOnSemiLineV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placeAbscissOnSemiLineV2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAK1D,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAkOF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,UAAU,GAAG,oBAAoB,CAAC;IAChD,UAAU,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,CAAC;CACnD,CAAC;AA6BF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAYnE,CAAC"}
@@ -0,0 +1,213 @@
1
+ import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
+ import { toolBarConstructor } from "../../../../exercises/utils/geogebra/toolBarConstructor.js";
3
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
4
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
+ import { GeogebraParser } from "../../../../geogebra/parsers/geogebraParser.js";
6
+ import { ggbPointToCoords } from "../../../../geogebra/parsers/ggbPointToCoords.js";
7
+ import { parseGGBPoints } from "../../../../geogebra/parsers/parseGGBPoints.js";
8
+ import { Point } from "../../../../math/geometry/point.js";
9
+ import { NumberType } from "../../../../math/numbers/nombre.js";
10
+ import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
11
+ import { randint } from "../../../../math/utils/random/randint.js";
12
+ import { round } from "../../../../math/utils/round.js";
13
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
14
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
15
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
16
+ import { random } from "../../../../utils/alea/random.js";
17
+ const getInstruction = ({ abscissType, absciss2, }) => {
18
+ const absciss2Node = NodeConstructor.fromIdentifiers(absciss2);
19
+ return `Placer le point d'abscisse $${abscissType === NumberType.Decimal
20
+ ? round(absciss2Node.evaluate(), 1).frenchify()
21
+ : absciss2Node.toTex()}$ sur la demi-droite graduée ci-dessous :`;
22
+ };
23
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
24
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
25
+ const getGGBAnswer = ({ absciss2 }) => {
26
+ const nodeAbciss2 = NodeConstructor.fromIdentifiers(absciss2);
27
+ return [`(${nodeAbciss2.evaluate()},0)`];
28
+ };
29
+ const getStudentGGBOptions = ({ abscissType, absciss1, axisUnit, absciss2, }) => {
30
+ const [axisUnitNode, absciss1Node, absciss2Node] = [
31
+ axisUnit,
32
+ absciss1,
33
+ absciss2,
34
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
35
+ const [valueAxisUnit, valueAbsciss1, valueAbsciss2] = [
36
+ axisUnitNode,
37
+ absciss1Node,
38
+ absciss2Node,
39
+ ].map((node) => node.evaluate());
40
+ const xMin = Math.min(Math.min(0, valueAbsciss1), valueAbsciss2);
41
+ const xMax = Math.max(Math.max(0, valueAbsciss1), valueAbsciss2);
42
+ const yxRatio = 0.5;
43
+ const yMax = yxRatio * (xMax - xMin);
44
+ const yMin = -yMax;
45
+ const O = new Point("O", (0).toTree(), (0).toTree());
46
+ const I = new Point("I", absciss1Node, (0).toTree());
47
+ const commands = [
48
+ ...O.toGGBCommand(),
49
+ `Text("\\footnotesize 0", (0, ${yMin / 4}), false, true, 0, 0)`,
50
+ ...I.toGGBCommand(),
51
+ `Text("\\footnotesize ${abscissType === NumberType.Decimal
52
+ ? round(absciss1Node.evaluate(), 1).frenchify()
53
+ : absciss1Node.toTex()}", (${valueAbsciss1}, ${abscissType === NumberType.Rational ? yMin / 2 : yMin / 4}), false, true, 0, 0)`,
54
+ ];
55
+ const ggb = new GeogebraConstructor({
56
+ commands,
57
+ customToolBar: toolBarConstructor({
58
+ point: true,
59
+ }),
60
+ hideGrid: true,
61
+ xAxis: {
62
+ hideNumbers: true,
63
+ steps: valueAxisUnit,
64
+ showPositive: true,
65
+ },
66
+ yAxis: {
67
+ hidden: true,
68
+ },
69
+ maxHeight: 220,
70
+ forbidShiftDragZoom: true,
71
+ });
72
+ return ggb.getOptions({
73
+ coords: ggb.getAdaptedCoords({
74
+ xMin,
75
+ xMax,
76
+ yMin,
77
+ yMax,
78
+ }),
79
+ // coords: [xMin, xMax, yMin, yMax],
80
+ });
81
+ };
82
+ const isGGBAnswerValid = (ans, { absciss2, axisUnit }) => {
83
+ const [absciss2Node, axisUnitNode] = [absciss2, axisUnit].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
84
+ const commands = ans;
85
+ const dictObj = new GeogebraParser(commands).objectDict();
86
+ console.log("dictObj:", dictObj);
87
+ const strPointA = dictObj["A"];
88
+ if (!strPointA) {
89
+ return false;
90
+ }
91
+ const coordsA = ggbPointToCoords(strPointA);
92
+ const points = parseGGBPoints(ans).map((p) => ggbPointToCoords(p));
93
+ return (points.length === 3 && //O,I,A
94
+ Math.abs(coordsA.y) < 0.5 * axisUnitNode.evaluate() &&
95
+ Math.abs(coordsA.x - absciss2Node.evaluate()) <
96
+ 0.1 * axisUnitNode.evaluate());
97
+ };
98
+ const getPlaceAbscissOnSemiLineV2Question = (optsIn) => {
99
+ const arrayedOptions = optsIn ?? optsDefault;
100
+ const opts = {
101
+ questionType: random(arrayedOptions.questionType),
102
+ numberType: random(arrayedOptions.numberType),
103
+ };
104
+ const abscissType = (() => {
105
+ switch (opts.numberType) {
106
+ case "Entiers":
107
+ return NumberType.Integer;
108
+ case "Rationnels":
109
+ return NumberType.Rational;
110
+ case "Décimaux":
111
+ return NumberType.Decimal;
112
+ }
113
+ })();
114
+ //[ [1/2, 2/2, 3/2], [1/3,2/3,3/3,4/3,5/3], ...]
115
+ function fracFamilyList() {
116
+ const maxDen = 5;
117
+ return [...Array(maxDen - 2).keys()]
118
+ .map((index) => index + 2)
119
+ .map((den) => [...Array(den === 2 ? 3 * den - 1 : 2 * den - 1).keys()]
120
+ .map((index) => index + 1)
121
+ .filter((num) => opts.questionType === "éviter le comptage"
122
+ ? num !== 1 && num !== den
123
+ : true)
124
+ .map((num) => frac(num, den)));
125
+ }
126
+ const fracList = random(fracFamilyList());
127
+ const den = fracList[0].rightChild;
128
+ const factor1 = random(fracList);
129
+ const factor2 = random(fracList, [factor1]);
130
+ let referenceNum;
131
+ let absciss1Node;
132
+ let absciss2Node;
133
+ switch (abscissType) {
134
+ case NumberType.Integer:
135
+ {
136
+ referenceNum = multiply(randint(1, 13), den);
137
+ absciss1Node = multiply(referenceNum, factor1).simplify();
138
+ absciss2Node = multiply(referenceNum, factor2).simplify();
139
+ }
140
+ break;
141
+ case NumberType.Rational:
142
+ {
143
+ referenceNum = random([...Array(19).keys()]
144
+ .map((index) => index + 1)
145
+ .filter((num) => !dividersOf(num).includes(den.evaluate()))).toTree();
146
+ absciss1Node = frac(multiply(referenceNum, factor1.leftChild).simplify(), factor1.rightChild);
147
+ absciss2Node = frac(multiply(referenceNum, factor2.leftChild).simplify(), factor2.rightChild);
148
+ }
149
+ break;
150
+ case NumberType.Decimal:
151
+ default:
152
+ {
153
+ referenceNum = frac(multiply(randint(1, 13 * 10), den), 10);
154
+ absciss1Node = multiply(referenceNum, factor1).simplify();
155
+ absciss2Node = multiply(referenceNum, factor2).simplify();
156
+ }
157
+ break;
158
+ }
159
+ const axisUnitNode = frac(referenceNum, den).simplify();
160
+ const identifiers = {
161
+ abscissType,
162
+ axisUnit: axisUnitNode.toIdentifiers(),
163
+ absciss1: absciss1Node.toIdentifiers(),
164
+ absciss2: absciss2Node.toIdentifiers(),
165
+ };
166
+ return getQuestionFromIdentifiers(identifiers);
167
+ };
168
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
169
+ const question = {
170
+ ggbAnswer: getGGBAnswer(identifiers),
171
+ instruction: getInstruction(identifiers),
172
+ studentGgbOptions: getStudentGGBOptions(identifiers),
173
+ identifiers,
174
+ // hint: getHint(identifiers),
175
+ // correction: getCorrection(identifiers),
176
+ options: opts,
177
+ };
178
+ return question;
179
+ };
180
+ const optsDefault = {
181
+ questionType: ["standard", "éviter le comptage"],
182
+ numberType: ["Entiers", "Rationnels", "Décimaux"],
183
+ };
184
+ const options = [
185
+ {
186
+ id: "questionType",
187
+ label: "Type de question",
188
+ target: GeneratorOptionTarget.generation,
189
+ type: GeneratorOptionType.multiselect,
190
+ values: ["standard", "éviter le comptage"],
191
+ defaultValue: optsDefault.questionType,
192
+ },
193
+ {
194
+ id: "numberType",
195
+ label: "Type de nombres",
196
+ target: GeneratorOptionTarget.generation,
197
+ type: GeneratorOptionType.multiselect,
198
+ values: ["Entiers", "Rationnels", "Décimaux"],
199
+ defaultValue: optsDefault.numberType,
200
+ },
201
+ ];
202
+ export const placeAbscissOnSemiLineV2 = {
203
+ id: "placeAbscissOnSemiLineV2",
204
+ label: "Placer un point d'abscisse donnée sur une demi-droite graduée",
205
+ isSingleStep: true,
206
+ generator: (nb, opts) => getDistinctQuestions(() => getPlaceAbscissOnSemiLineV2Question(opts), nb),
207
+ options,
208
+ ggbTimer: 60,
209
+ isGGBAnswerValid,
210
+ subject: "Mathématiques",
211
+ getQuestionFromIdentifiers,
212
+ answerType: "GGB",
213
+ };
@@ -103,7 +103,7 @@ const createRandomNode = (numberType, isPossibleProba) => {
103
103
  case "Fraction": {
104
104
  if (probaFlip(0.7)) {
105
105
  const num = randint(0, 10_000);
106
- const den = randint(num, 20_000);
106
+ const den = randint(num, 20_000, [0]);
107
107
  return frac(num, den);
108
108
  }
109
109
  else {
@@ -145,7 +145,7 @@ const createRandomNode = (numberType, isPossibleProba) => {
145
145
  const num = coinFlip()
146
146
  ? randint(10_000, 20_000)
147
147
  : randint(-20_000, -10_000);
148
- const den = randint(0, abs(num).evaluate());
148
+ const den = randint(1, abs(num).evaluate());
149
149
  return frac(num, den);
150
150
  }
151
151
  else {
@@ -57,12 +57,12 @@ const situations = [
57
57
  {
58
58
  context: "Dans une émission TV, le présentateur demande son prénom à quelqu'un dans le public.",
59
59
  strA: "Le prénom est Jean-Michel.",
60
- strB: 'Le prénom commence par la lettre "A".',
60
+ strB: "La personne est un adulte.",
61
61
  "(A)": "que le prénom soit Jean-Michel",
62
- "(B)": 'que le prénom commence par la lettre "J"',
63
- "(A \\cap B)": 'que le prénom soit Jean-Michel et qu\'il commence par un "A"',
64
- "_A(B)": 'que le prénom commence par un "A", sachant que c\'est Jean-Michel',
65
- "_B(A)": 'que le prénom soit Jean-Michel, sachant qu\'il commence par un "A"',
62
+ "(B)": "que la personne soit un adulte",
63
+ "(A \\cap B)": "que le prénom soit Jean-Michel et que la personne soit un adulte",
64
+ "_A(B)": "que la personne soit un adulte, sachant que son prénom est Jean-Michel",
65
+ "_B(A)": "que le prénom soit Jean-Michel, sachant que la personne est un adulte",
66
66
  },
67
67
  {
68
68
  context: "Il est $14$h$37$. Yohann et Sarah sont assis en classe. C'est un cours sur les probabilités.",
@@ -119,7 +119,7 @@ Soit $B$ l'évenement :
119
119
 
120
120
  Écris en langage mathématique :
121
121
 
122
- La probabilité ${situation[pType]}.`;
122
+ > La probabilité ${situation[pType]}.`;
123
123
  return instruction;
124
124
  };
125
125
  const getAnswer = (identifiers) => {
@@ -22,7 +22,6 @@ type EventIdentifiers = {
22
22
  type Options = {
23
23
  nbElem: string[];
24
24
  unionLength: string[];
25
- isProbasAreNumbers: boolean;
26
25
  };
27
26
  export declare const probaAsSumOfProbas: Exercise<Identifiers, Options>;
28
27
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"probaAsSumOfProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaAsSumOfProbas.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAkBT,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAa7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF,KAAK,gBAAgB,GACjB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,eAAe,CAAC;CACpB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,eAAe,CAAC;IACnB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AA4eN,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAqRF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAe7D,CAAC"}
1
+ {"version":3,"file":"probaAsSumOfProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaAsSumOfProbas.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAkBT,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAa7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF,KAAK,gBAAgB,GACjB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,eAAe,CAAC;CACpB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,eAAe,CAAC;IACnB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AA0eN,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAsQF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAe7D,CAAC"}