math-exercises 3.0.8 → 3.0.10

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.
@@ -132,7 +132,7 @@ const isAnswerValid = (ans, { a, b }) => {
132
132
  const options = [
133
133
  {
134
134
  id: "aNumberType",
135
- label: "Autoriser des fractions pour $a$",
135
+ label: "Type du coefficient $a$",
136
136
  target: GeneratorOptionTarget.generation,
137
137
  type: GeneratorOptionType.multiselect,
138
138
  defaultValue: ["Entier"],
@@ -5,9 +5,10 @@ type Identifiers = {
5
5
  /** new */
6
6
  functionType: string;
7
7
  x: number;
8
- y: number;
9
- wrongY: number;
8
+ y?: number;
9
+ wrongY?: number;
10
10
  otherPoints: number[][];
11
+ functionCommand?: string;
11
12
  };
12
13
  type Options = {
13
14
  curveTypes: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"imageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAsBrC,KAAK,WAAW,GAAG;IACjB,cAAc;IAMd,UAAU;IAMV,UAAU;IACV,YAAY,EAAE,MAAM,CAAC;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;CACzB,CAAC;AAoOF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmBhE,CAAC"}
1
+ {"version":3,"file":"imageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAyBrC,KAAK,WAAW,GAAG;IACjB,cAAc;IAMd,UAAU;IAMV,UAAU;IACV,YAAY,EAAE,MAAM,CAAC;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AA0SF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqBhE,CAAC"}
@@ -13,8 +13,11 @@ import { randfloat } from "../../../../math/utils/random/randfloat.js";
13
13
  import { randint } from "../../../../math/utils/random/randint.js";
14
14
  import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
15
15
  import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
16
+ import { valueParser } from "../../../../tree/parsers/valueParser.js";
17
+ import { probaFlip } from "../../../../utils/alea/probaFlip.js";
16
18
  import { random } from "../../../../utils/alea/random.js";
17
19
  import { shuffle } from "../../../../utils/alea/shuffle.js";
20
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
18
21
  const rebuildIdentifiers = (oldIds) => {
19
22
  if (oldIds.splinePoints?.length) {
20
23
  const x = oldIds.x;
@@ -49,22 +52,44 @@ const rebuildIdentifiers = (oldIds) => {
49
52
  else
50
53
  return oldIds;
51
54
  };
52
- const getInstruction = (identifiers) => {
55
+ const getInstruction = (identifiers, opts) => {
53
56
  const { x } = identifiers;
54
- return `Quelle est l'image de $${x}$ par la fonction $f$ représentée ci dessous ?`;
57
+ let instruction = `Quelle est l'image de $${x}$ par la fonction $f$ représentée ci dessous ?
58
+
59
+ On écrira "aucun" si l'image n'existe pas.`;
60
+ // if (opts?.curveTypes?.includes("Avec valeur interdite (pas d'image)")) {
61
+ // instruction += `
62
+ // On écrira "aucun" si l'image n'existe pas.`;
63
+ // }
64
+ return instruction;
55
65
  };
56
66
  const getAnswer = (identifiers) => {
57
67
  const { y } = identifiers;
68
+ if (y === undefined)
69
+ return "\\text{Aucun}";
58
70
  return y.frenchify();
59
71
  };
60
72
  const getGGBOptions = (identifiers) => {
61
- const { functionType, otherPoints, wrongY, x, y } = identifiers;
62
- const allPoints = [...otherPoints, [x, y], [wrongY, x]].sort((a, b) => a[0] - b[0]);
73
+ const { functionType, otherPoints, wrongY, x, y, functionCommand } = identifiers;
74
+ const allPoints = [...otherPoints];
75
+ if (y !== undefined)
76
+ allPoints.push([x, y]);
77
+ if (wrongY !== undefined)
78
+ allPoints.push([wrongY, x]);
79
+ allPoints.sort((a, b) => a[0] - b[0]);
63
80
  let commands = [];
64
81
  switch (functionType) {
82
+ case "Avec valeur interdite (pas d'image)":
83
+ commands = [
84
+ `f(x) = ${functionCommand}`,
85
+ `SetColor(f, "${randomColor()}")`,
86
+ `SetCaption(f, "$f$")`,
87
+ `ShowLabel(f, true)`,
88
+ ];
89
+ break;
65
90
  case "Droites":
66
91
  const line = new Line(new Point("A", allPoints[0][0], allPoints[0][1]), new Point("B", allPoints[1][0], allPoints[1][1]));
67
- commands = line.toGGBCommands(false);
92
+ commands = line.toGGBCommands(false, { showLabel: true, label: "$f$" });
68
93
  break;
69
94
  case "Tracés":
70
95
  //! on devrait plutôt build a spline et renvoyer toGgbCommand
@@ -74,6 +99,8 @@ const getGGBOptions = (identifiers) => {
74
99
  .join(",")})`,
75
100
  "SetFixed(S, true)",
76
101
  `SetColor(S, "${randomColor()}")`,
102
+ `SetCaption(S, "$f$")`,
103
+ `ShowLabel(S, true)`,
77
104
  ];
78
105
  break;
79
106
  case "Paraboles":
@@ -82,7 +109,10 @@ const getGGBOptions = (identifiers) => {
82
109
  new Point("B", allPoints[1][0], allPoints[1][1]),
83
110
  new Point("C", allPoints[2][0], allPoints[2][1]),
84
111
  ]);
85
- commands = parabola.toGGBCommands(false);
112
+ commands = parabola.toGGBCommands(false, {
113
+ showLabel: true,
114
+ label: "$f$",
115
+ });
86
116
  break;
87
117
  case "Polynômes":
88
118
  default:
@@ -93,6 +123,8 @@ const getGGBOptions = (identifiers) => {
93
123
  .join(",")})`,
94
124
  "SetFixed(P, true)",
95
125
  `SetColor(P, "${randomColor()}")`,
126
+ `SetCaption(P, "$f$")`,
127
+ `ShowLabel(P, true)`,
96
128
  ];
97
129
  break;
98
130
  }
@@ -104,10 +136,19 @@ const getGGBOptions = (identifiers) => {
104
136
  // commands: spline.getCommands()
105
137
  commands,
106
138
  });
107
- const xMin = allPoints[0][0];
108
- const xMax = allPoints[allPoints.length - 1][0];
109
- const yMin = Math.min(...allPoints.map((p) => p[1])) - 1;
110
- const yMax = Math.max(...allPoints.map((p) => p[1])) + 1;
139
+ let xMin, xMax, yMin, yMax;
140
+ if (functionType === "Avec valeur interdite (pas d'image)") {
141
+ xMin = x - 3;
142
+ xMax = x + 3;
143
+ yMin = -7;
144
+ yMax = 7;
145
+ }
146
+ else {
147
+ xMin = allPoints[0][0];
148
+ xMax = allPoints[allPoints.length - 1][0];
149
+ yMin = Math.min(...allPoints.map((p) => p[1])) - 1;
150
+ yMax = Math.max(...allPoints.map((p) => p[1])) + 1;
151
+ }
111
152
  return ggb.getOptions({
112
153
  coords: ggb.getAdaptedCoords({
113
154
  forceShowAxes: true,
@@ -122,12 +163,20 @@ const getStartStatement = (identifiers) => {
122
163
  const { x } = identifiers;
123
164
  return `f(${x})`;
124
165
  };
166
+ const getKeys = (identifiers, options) => {
167
+ // if (options?.curveTypes?.includes("Avec valeur interdite (pas d'image)")) {
168
+ // return ["aucun"];
169
+ // } else {
170
+ // return [];
171
+ // }
172
+ return ["aucun"];
173
+ };
125
174
  const getQuestionFromIdentifiers = (identifiers, opts) => {
126
175
  const question = {
127
176
  instruction: getInstruction(identifiers, opts),
128
177
  startStatement: getStartStatement(identifiers, opts),
129
178
  answer: getAnswer(identifiers, opts),
130
- keys: [],
179
+ keys: getKeys(identifiers, opts),
131
180
  ggbOptions: getGGBOptions(identifiers, opts),
132
181
  answerFormat: "tex",
133
182
  identifiers,
@@ -135,13 +184,24 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
135
184
  return question;
136
185
  };
137
186
  const getImageFunctionGeogebra = (opts) => {
138
- const x = randint(-8, 9);
139
- const y = randint(-8, 9);
140
- const wrongY = y + randint(-3, 4, [0, x - y, 10 - y, -10 - y]);
187
+ let x = randint(-8, 9);
188
+ let y = randint(-8, 9);
189
+ let wrongY = y + randint(-3, 4, [0, x - y, 10 - y, -10 - y]);
190
+ let functionCommand = undefined;
141
191
  const functionType = random(opts?.curveTypes ?? ["Tracés", "Polynômes", "Droites", "Paraboles"]);
142
192
  let otherPoints = [];
143
193
  switch (functionType) {
194
+ case "Avec valeur interdite (pas d'image)":
195
+ y = undefined;
196
+ const k = randint(2, 6);
197
+ functionCommand = `${k}/(x-${x}) -x`;
198
+ break;
144
199
  case "Droites":
200
+ const isConstante = probaFlip(0.2);
201
+ if (isConstante) {
202
+ wrongY = undefined;
203
+ otherPoints.push([x + 1, y]);
204
+ }
145
205
  //nothing to add
146
206
  break;
147
207
  case "Tracés":
@@ -172,21 +232,34 @@ const getImageFunctionGeogebra = (opts) => {
172
232
  functionType,
173
233
  wrongY,
174
234
  otherPoints,
235
+ functionCommand,
175
236
  };
176
237
  return getQuestionFromIdentifiers(identifiers, opts);
177
238
  };
178
- const getPropositions = (n, { answer, x, y, wrongY }, opts) => {
239
+ const getPropositions = (n, { answer, wrongY }, opts) => {
179
240
  const propositions = [];
180
241
  addValidProp(propositions, answer);
181
- //old questions have spline POint undefined
182
- tryToAddWrongProp(propositions, wrongY + "");
242
+ if (wrongY !== undefined)
243
+ tryToAddWrongProp(propositions, wrongY + "");
244
+ tryToAddWrongProp(propositions, "\\text{Aucun}");
183
245
  while (propositions.length < n) {
184
- const wrongAnswer = Number(answer) + randint(-10, 11, [0]);
246
+ const wrongAnswer = randint(-10, 11, [0]);
185
247
  tryToAddWrongProp(propositions, wrongAnswer + "");
186
248
  }
187
249
  return shuffle(propositions);
188
250
  };
189
251
  const isAnswerValid = (ans, { answer }, opts) => {
252
+ if (answer === "\\text{Aucun}")
253
+ return ans === answer;
254
+ try {
255
+ const parsed = valueParser(ans);
256
+ if (parsed === false)
257
+ return false;
258
+ return Math.abs(parsed - answer.unfrenchify()) < 0.3;
259
+ }
260
+ catch (err) {
261
+ return handleVEAError(err);
262
+ }
190
263
  return numberVEA(ans, answer);
191
264
  };
192
265
  const options = [
@@ -196,7 +269,13 @@ const options = [
196
269
  target: GeneratorOptionTarget.generation,
197
270
  type: GeneratorOptionType.multiselect,
198
271
  defaultValue: ["Tracés", "Polynômes", "Droites", "Paraboles"],
199
- values: ["Tracés", "Polynômes", "Droites", "Paraboles"],
272
+ values: [
273
+ "Tracés",
274
+ "Polynômes",
275
+ "Droites",
276
+ "Paraboles",
277
+ "Avec valeur interdite (pas d'image)",
278
+ ],
200
279
  },
201
280
  ];
202
281
  export const imageFunctionGeogebra = {
@@ -217,4 +296,6 @@ export const imageFunctionGeogebra = {
217
296
  getGGBOptions,
218
297
  rebuildIdentifiers,
219
298
  getQuestionFromIdentifiers,
299
+ getKeys,
300
+ getStartStatement,
220
301
  };
@@ -1,10 +1,7 @@
1
1
  import { Exercise } from "../../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
- xValue: number;
4
3
  yValue: number;
5
- affineCoeffs?: number[];
6
- trinomCoeffs?: number[];
7
- isAffine: boolean;
4
+ points: number[][];
8
5
  };
9
6
  export declare const inverseImageFunctionGeogebra: Exercise<Identifiers>;
10
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AA0IF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAe9D,CAAC"}
1
+ {"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IAEjB,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB,CAAC;AAmNF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAoB9D,CAAC"}
@@ -1,94 +1,175 @@
1
1
  import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
- import { randomColor } from "../../../../geogebra/colors.js";
4
3
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
- import { Affine } from "../../../../math/polynomials/affine.js";
6
- import { Polynomial } from "../../../../math/polynomials/polynomial.js";
7
- import { Trinom } from "../../../../math/polynomials/trinom.js";
4
+ import { Line } from "../../../../math/geometry/line.js";
5
+ import { Parabola } from "../../../../math/geometry/parabola.js";
6
+ import { Point } from "../../../../math/geometry/point.js";
7
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
8
+ import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
9
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
8
10
  import { randint } from "../../../../math/utils/random/randint.js";
9
11
  import { round } from "../../../../math/utils/round.js";
12
+ import { valueParser } from "../../../../tree/parsers/valueParser.js";
10
13
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
14
+ import { probaFlip } from "../../../../utils/alea/probaFlip.js";
11
15
  import { shuffle } from "../../../../utils/alea/shuffle.js";
16
+ const rebuildIdentifiers = (oldIds) => {
17
+ if (oldIds.points?.length)
18
+ return oldIds;
19
+ const [x, y] = [oldIds.xValue, oldIds.yValue];
20
+ let points = [[x, y]];
21
+ if (oldIds.isAffine) {
22
+ const affine = AffineConstructor.fromCoeffs(oldIds.affineCoeffs);
23
+ const x2 = x + 1;
24
+ const y2 = affine.calculate(x2);
25
+ points.push([x2, y2]);
26
+ }
27
+ else {
28
+ const trinom = TrinomConstructor.fromCoeffs(oldIds.trinomCoeffs);
29
+ const x2 = x - 1;
30
+ const x3 = x + 1;
31
+ const y2 = trinom.calculate(x2);
32
+ const y3 = trinom.calculate(x3);
33
+ points.push([x2, y2], [x3, y3]);
34
+ }
35
+ return {
36
+ points,
37
+ yValue: oldIds.yValue,
38
+ };
39
+ };
40
+ const getInstruction = (identifiers) => {
41
+ const { yValue } = identifiers;
42
+ return `Avec la précision permise par le graphique, déterminer le ou les antécédents de $${yValue}$ par la fonction $f$ représentée ci dessous.
43
+
44
+ S'il n'y en a pas, on écrira "aucun".`;
45
+ };
46
+ const getAnswer = (identifiers) => {
47
+ const { points, yValue } = identifiers;
48
+ const validPoints = points.filter((p) => p[1] === yValue);
49
+ if (!validPoints.length) {
50
+ return "\\text{Aucun}";
51
+ }
52
+ return validPoints
53
+ .map((p) => round(p[0], 2).frenchify())
54
+ .join("\\text{ et }");
55
+ };
56
+ const getGGBOptions = (identifiers) => {
57
+ const { points } = identifiers;
58
+ let commands = [];
59
+ if (points.length === 2) {
60
+ const line = new Line(new Point("A", points[0][0], points[0][1]), new Point("B", points[1][0], points[1][1]));
61
+ commands = line.toGGBCommands(false);
62
+ }
63
+ else {
64
+ const parabola = new Parabola(points.map((p, i) => new Point(`A_${i}`, p[0], p[1])));
65
+ commands = parabola.toGGBCommands(false);
66
+ }
67
+ const Xs = points.map((p) => p[0]);
68
+ const Ys = points.map((p) => p[1]);
69
+ const xMin = Math.min(...Xs);
70
+ const xMax = Math.max(...Xs);
71
+ const yMin = Math.min(...Ys);
72
+ const yMax = Math.max(...Ys);
73
+ const ggb = new GeogebraConstructor({ commands });
74
+ return ggb.getOptions({
75
+ coords: ggb.getAdaptedCoords({
76
+ xMin,
77
+ xMax,
78
+ yMin,
79
+ yMax,
80
+ forceShowAxes: true,
81
+ }),
82
+ });
83
+ };
12
84
  const getInverseImageFunctionGeogebra = () => {
13
- const isAffine = coinFlip();
14
- const xValue = randint(-5, 6);
15
- // const yValue = randint(-5, 6);
85
+ const isLine = coinFlip();
86
+ const hasAntecedent = probaFlip(0.8);
87
+ // const isLine = false;
88
+ // const hasAntecedent = true;
16
89
  let yValue;
17
- let affine;
18
- let trinom;
19
- let answer = "";
20
- let xMin = -1;
21
- let xMax = 1;
22
- let yMin = -1;
23
- let yMax = 1;
24
- let commands;
25
- if (isAffine) {
26
- do {
27
- affine = new Affine(randint(-5, 6, [0]), randint(-9, 10));
28
- yValue = affine.calculate(xValue);
29
- } while (Math.abs(yValue) > 10);
30
- answer = xValue.toString().replace(".", ",");
31
- yMin = yValue;
32
- yMax = yValue;
33
- xMin = xValue;
34
- xMax = xValue;
35
- commands = [affine.toString()];
90
+ const points = [];
91
+ if (isLine) {
92
+ if (hasAntecedent) {
93
+ yValue = randint(-6, 7);
94
+ const xIsDecimal = probaFlip(0.3);
95
+ const xValue = xIsDecimal
96
+ ? randfloat(-6, 7, 2, [yValue])
97
+ : randint(-6, 7, [yValue]);
98
+ const wrongY = randint(-6, 7);
99
+ points.push([xValue, yValue], [yValue, wrongY]);
100
+ }
101
+ else {
102
+ yValue = randint(-6, 7, [0]);
103
+ const constante = randint(-6, 7, [yValue]);
104
+ points.push([0, constante], [1, constante]);
105
+ }
36
106
  }
37
107
  else {
38
- let roots;
39
- yValue = randint(-5, 6);
40
- do {
41
- trinom = new Trinom(randint(-4, 5, [0]), randint(-9, 10), randint(-9, 10) - yValue);
42
- roots = trinom.getRoots();
43
- } while (roots.some((root) => Math.abs(root) > 10));
44
- answer = !roots.length
45
- ? "\\text{Aucun}"
46
- : roots
47
- .map((r) => round(r, 1).toString().replace(".", ","))
48
- .join("\\text{ et }");
49
- const beta = trinom.getBeta() + yValue;
50
- yMin = trinom.a > 0 ? beta : roots.length ? yValue : beta - 5;
51
- yMax = trinom.a < 0 ? beta : roots.length ? yValue : beta + 5;
52
- xMax = roots.length ? Math.max(...roots) : -10;
53
- xMin = roots.length ? Math.min(...roots) : 10;
54
- commands = [
55
- `f(x) = ${yValue !== 0
56
- ? trinom.add(new Polynomial([yValue])).toString()
57
- : trinom.toString()}`,
58
- `SetColor(f, "${randomColor()}")`,
59
- ];
108
+ if (hasAntecedent) {
109
+ yValue = randint(-6, 7);
110
+ const xIsDecimal = coinFlip();
111
+ const xValue = xIsDecimal
112
+ ? randfloat(-6, 7, 2, [yValue])
113
+ : randint(-6, 7, [yValue]);
114
+ const hasTwoAntecedents = probaFlip(0.8);
115
+ if (hasTwoAntecedents) {
116
+ const wrongY = randint(-6, 7, [yValue]);
117
+ const secondAntecedentPoint = [
118
+ randint(-6, 7, [xValue, yValue]),
119
+ yValue,
120
+ ];
121
+ points.push([xValue, yValue], [yValue, wrongY], secondAntecedentPoint);
122
+ }
123
+ else {
124
+ //(x,y) is summit
125
+ const wrongY = randint(-6, 7, [yValue]);
126
+ points.push([xValue, yValue], [yValue, wrongY], [2 * xValue - yValue, wrongY]);
127
+ }
128
+ }
129
+ else {
130
+ yValue = randint(-8, 9);
131
+ const wrongY = randint(-3, 4, [yValue, yValue - 1, yValue + 1]);
132
+ const below = wrongY < yValue;
133
+ const summit = [
134
+ randint(-6, 7, [yValue]),
135
+ below
136
+ ? randint(wrongY + 1, yValue, [wrongY])
137
+ : randint(yValue + 1, wrongY, [wrongY]),
138
+ ];
139
+ const thirdPoint = [2 * summit[0] - yValue, wrongY];
140
+ //construire deux autrs points au pif avec y sous/audssu yValus
141
+ points.push([yValue, wrongY], summit, thirdPoint);
142
+ }
60
143
  }
61
- const statement = `Lire graphiquement le ou les antécédents de $${yValue}$ par la fonction $f$ représentée ci dessous.`;
62
- const ggb = new GeogebraConstructor({ commands });
144
+ points.sort((p1, p2) => p1[0] - p2[0]);
145
+ const identifiers = {
146
+ // xValue,
147
+ // affineCoeffs: isAffine ? affine!.coefficients : undefined,
148
+ // trinomCoeffs: isAffine ? undefined : trinom!.coefficients,
149
+ yValue,
150
+ points,
151
+ // isAffine,
152
+ };
153
+ return getQuestionFromIdentifiers(identifiers);
154
+ };
155
+ const getQuestionFromIdentifiers = (identifiers) => {
63
156
  const question = {
64
- instruction: statement,
65
- answer,
157
+ instruction: getInstruction(identifiers),
158
+ answer: getAnswer(identifiers),
66
159
  keys: ["et", "aucun"],
67
- ggbOptions: ggb.getOptions({
68
- coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
69
- }),
160
+ ggbOptions: getGGBOptions(identifiers),
70
161
  answerFormat: "tex",
71
- identifiers: {
72
- xValue,
73
- affineCoeffs: isAffine ? affine.coefficients : undefined,
74
- trinomCoeffs: isAffine ? undefined : trinom.coefficients,
75
- yValue,
76
- isAffine,
77
- },
162
+ identifiers,
78
163
  };
79
164
  return question;
80
165
  };
81
- const getPropositions = (n, { answer, xValue, affineCoeffs, trinomCoeffs, yValue, isAffine }) => {
166
+ const getPropositions = (n, { answer, points, yValue }) => {
82
167
  const propositions = [];
83
168
  addValidProp(propositions, answer);
84
169
  tryToAddWrongProp(propositions, "\\text{Aucun}");
85
- if (isAffine) {
86
- const affine = new Polynomial(affineCoeffs);
87
- tryToAddWrongProp(propositions, affine.calculate(yValue).toString().replace(".", ","));
88
- }
89
- else {
90
- const trinom = new Polynomial(trinomCoeffs);
91
- tryToAddWrongProp(propositions, trinom.calculate(yValue).toString().replace(".", ","));
170
+ const wrongY = points.find((p) => p[0] === yValue)?.[1];
171
+ if (wrongY !== undefined) {
172
+ tryToAddWrongProp(propositions, wrongY.frenchify());
92
173
  }
93
174
  while (propositions.length < n) {
94
175
  const wrongAnswer = coinFlip()
@@ -98,26 +179,27 @@ const getPropositions = (n, { answer, xValue, affineCoeffs, trinomCoeffs, yValue
98
179
  }
99
180
  return shuffle(propositions);
100
181
  };
101
- const isAnswerValid = (ans, { answer, xValue, affineCoeffs, trinomCoeffs, yValue, isAffine }) => {
102
- const antecedents = [];
103
- if (isAffine) {
104
- antecedents.push(xValue);
182
+ const isAnswerValid = (ans, { answer, points, yValue }) => {
183
+ if (ans === "\\text{Aucun}" || answer === "\\text{Aucun}")
184
+ return ans === answer;
185
+ const validPoints = points.filter((p) => p[1] === yValue);
186
+ const ansElements = ans.split("\\text{ et }");
187
+ if (validPoints.length !== ansElements.length)
188
+ return false;
189
+ let sorted = [];
190
+ for (const el of ansElements) {
191
+ const parsed = valueParser(el);
192
+ if (parsed === false)
193
+ return false;
194
+ sorted.push(parsed);
105
195
  }
106
- else {
107
- const trinom = new Polynomial(trinomCoeffs);
108
- const roots = trinom.getRoots();
109
- antecedents.push(...roots);
196
+ sorted.sort((a, b) => a - b);
197
+ for (let i = 0; i < sorted.length; i++) {
198
+ const validPointX = validPoints[i][0];
199
+ if (Math.abs(sorted[i] - validPointX) > 0.3)
200
+ return false;
110
201
  }
111
- if (!antecedents.length)
112
- return ans === `\\text{Aucun}`;
113
- const studentNumbers = ans
114
- .split("\\text{ et }")
115
- .map((n) => Number(n.replace(",", ".")))
116
- .filter((n) => !isNaN(n))
117
- .sort((a, b) => a - b);
118
- antecedents.sort((a, b) => a - b);
119
- return (!!studentNumbers.length &&
120
- studentNumbers.every((nb, index) => Math.abs(nb - antecedents[index]) < 0.2));
202
+ return true;
121
203
  };
122
204
  export const inverseImageFunctionGeogebra = {
123
205
  id: "inverseImageFunctionGeogebra",
@@ -133,4 +215,9 @@ export const inverseImageFunctionGeogebra = {
133
215
  isAnswerValid,
134
216
  hasGeogebra: true,
135
217
  subject: "Mathématiques",
218
+ getAnswer,
219
+ getInstruction,
220
+ getGGBOptions,
221
+ getQuestionFromIdentifiers,
222
+ rebuildIdentifiers,
136
223
  };
@@ -7,5 +7,6 @@ export type ToGGBCommandsProps = {
7
7
  size?: number;
8
8
  color?: string;
9
9
  showLength?: boolean;
10
+ label?: string;
10
11
  };
11
12
  //# sourceMappingURL=toGGBCommandsProps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toGGBCommandsProps.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toGGBCommandsProps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC"}
1
+ {"version":3,"file":"toGGBCommandsProps.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toGGBCommandsProps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -684,20 +684,18 @@ declare const mathExercises: (Exercise<{
684
684
  }> | Exercise<{
685
685
  functionType: string;
686
686
  x: number;
687
- y: number;
688
- wrongY: number;
687
+ y?: number;
688
+ wrongY?: number;
689
689
  otherPoints: number[][];
690
+ functionCommand?: string;
690
691
  }, {
691
692
  curveTypes: string[];
692
693
  }> | Exercise<{
693
694
  poly1: number[];
694
695
  xValue: number;
695
696
  }, {}> | Exercise<{
696
- xValue: number;
697
697
  yValue: number;
698
- affineCoeffs?: number[];
699
- trinomCoeffs?: number[];
700
- isAffine: boolean;
698
+ points: number[][];
701
699
  }, {}> | Exercise<{
702
700
  yValue: number;
703
701
  splinePoints: [number, number][];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
@@ -49,7 +49,7 @@ export declare class Line {
49
49
  };
50
50
  toTex(): string;
51
51
  toTexNoLeftRight(): string;
52
- toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showUnderlyingPoints, }?: ToGGBCommandsProps): string[];
52
+ toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showUnderlyingPoints, color, label, }?: ToGGBCommandsProps): string[];
53
53
  intersect(line: Line, intersectName?: string): Point;
54
54
  }
55
55
  //# sourceMappingURL=line.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,OAAO,EAAO,MAAM,uCAAuC,CAAC;AAMrE,OAAO,EACL,aAAa,EAEd,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,M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AI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAsBvD,aAAa;;;;;IAOb,WAAW,CAAC,IAAI,EAAE,IAAI;IAYtB,iBAAiB;IAIjB,YAAY,CAAC,KAAK,EAAE,KAAK;IAYzB,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAW7B,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,GAAE,OAAe;IAgBnD,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAK7C,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAW7C,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;IAuBjC,WAAW;IAMX,iBAAiB;;;;;IAcjB,KAAK;IAGL,gBAAgB;IAIhB,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,oBAA2B,EAC3B,KAAiB,EACjB,KAAiB,GAClB,GAAE,kBAAuB;IA2C5B,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,MAAM;CAW7C"}
@@ -1,4 +1,5 @@
1
1
  import { randomSegmentName } from "../../exercises/utils/geometry/randomSegmentName.js";
2
+ import { randomColor } from "../../geogebra/colors.js";
2
3
  import { EqualNode } from "../../tree/nodes/equations/equalNode.js";
3
4
  import { opposite } from "../../tree/nodes/functions/oppositeNode.js";
4
5
  import { NumberNode } from "../../tree/nodes/numbers/numberNode.js";
@@ -176,7 +177,7 @@ export class Line {
176
177
  toTexNoLeftRight() {
177
178
  return this.name.replace("\\left", "").replace("\\right", "");
178
179
  }
179
- toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showUnderlyingPoints = true, } = {}) {
180
+ toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showUnderlyingPoints = true, color = undefined, label = undefined, } = {}) {
180
181
  const commands = [];
181
182
  if (shouldBuildPoints) {
182
183
  const ACommands = this.pointA.toGGBCommand({
@@ -196,6 +197,15 @@ export class Line {
196
197
  `SetFixed(${this.ggbName},${isFixed ? "true" : "false"})`,
197
198
  `ShowLabel(${this.ggbName},${showLabel ? "true" : "false"})`,
198
199
  ]);
200
+ if (label) {
201
+ commands.push(`SetCaption(${this.ggbName}, "${label}")`);
202
+ }
203
+ if (color) {
204
+ commands.push(`SetColor(${this.ggbName},"${color}")`);
205
+ }
206
+ else {
207
+ commands.push(`SetColor(${this.ggbName},"${randomColor()}")`);
208
+ }
199
209
  return commands;
200
210
  }
201
211
  intersect(line, intersectName) {
@@ -6,6 +6,6 @@ export declare class Parabola {
6
6
  unformatedName: string;
7
7
  ggbName: string;
8
8
  constructor(points: Point[], name?: string);
9
- toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showUnderlyingPoints, }?: ToGGBCommandsProps): string[];
9
+ toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showUnderlyingPoints, label, }?: ToGGBCommandsProps): string[];
10
10
  }
11
11
  //# sourceMappingURL=parabola.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parabola.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/parabola.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,qBAAa,QAAQ;IACnB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;IAS1C,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,oBAA2B,GAC5B,GAAE,kBAAuB;CA+B7B"}
1
+ {"version":3,"file":"parabola.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/parabola.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,qBAAa,QAAQ;IACnB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;IAS1C,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,oBAA2B,EAC3B,KAAiB,GAClB,GAAE,kBAAuB;CAkC7B"}
@@ -11,7 +11,7 @@ export class Parabola {
11
11
  this.name = name ?? `\\mathcal{P}_${points.map((p) => p.name)}`;
12
12
  this.ggbName = name ?? `parabola_{${points.map((p) => p.name)}}`;
13
13
  }
14
- toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showUnderlyingPoints = true, } = {}) {
14
+ toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showUnderlyingPoints = true, label = undefined, } = {}) {
15
15
  const commands = [];
16
16
  if (shouldBuildPoints) {
17
17
  const pointsCommands = this.points.map((p) => p.toGGBCommand({
@@ -23,6 +23,9 @@ export class Parabola {
23
23
  else {
24
24
  commands.push(`${this.ggbName}=Polynomial(${this.points[0].toMathString()},${this.points[1].toMathString()},${this.points[2].toMathString()})`);
25
25
  }
26
+ if (label) {
27
+ commands.push(`SetCaption(${this.ggbName}, "${label}")`);
28
+ }
26
29
  commands.push(...[
27
30
  `SetFixed(${this.ggbName},${isFixed ? "true" : "false"})`,
28
31
  `ShowLabel(${this.ggbName},${showLabel ? "true" : "false"})`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.8",
4
+ "version": "3.0.10",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [