math-exercises 3.0.45 → 3.0.46

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 (39) hide show
  1. package/lib/exercises/math/calcul/arithmetics/pgcdCalcul.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/pgcdCalcul.js +15 -4
  3. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +1 -0
  4. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.js +1 -0
  6. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts.map +1 -1
  7. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.js +1 -0
  8. package/lib/exercises/math/conversion/lengthConversion.d.ts.map +1 -1
  9. package/lib/exercises/math/conversion/lengthConversion.js +3 -5
  10. package/lib/exercises/math/dataRepresentations/barChartReading.d.ts +88 -1
  11. package/lib/exercises/math/dataRepresentations/barChartReading.d.ts.map +1 -1
  12. package/lib/exercises/math/dataRepresentations/barChartReading.js +155 -83
  13. package/lib/exercises/math/dataRepresentations/index.d.ts +1 -0
  14. package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
  15. package/lib/exercises/math/dataRepresentations/index.js +1 -1
  16. package/lib/exercises/math/geometry/vectors/vectorLinearCombination.js +1 -1
  17. package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts +3 -2
  18. package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
  19. package/lib/exercises/math/limits/sequenceGeometricLimit.js +28 -16
  20. package/lib/exercises/math/percent/valuePercent.d.ts.map +1 -1
  21. package/lib/exercises/math/percent/valuePercent.js +30 -12
  22. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.d.ts +8 -1
  23. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.d.ts.map +1 -1
  24. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.js +60 -26
  25. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts +10 -1
  26. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts.map +1 -1
  27. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.js +34 -19
  28. package/lib/exercises/pc/mole/concentrationReading.js +1 -1
  29. package/lib/index.d.ts +23 -3
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/math/geometry/spaceVector.d.ts +1 -1
  32. package/lib/math/geometry/spaceVector.d.ts.map +1 -1
  33. package/lib/math/geometry/spaceVector.js +2 -2
  34. package/lib/math/sequences/geometricSequence.d.ts +7 -5
  35. package/lib/math/sequences/geometricSequence.d.ts.map +1 -1
  36. package/lib/math/sequences/geometricSequence.js +24 -20
  37. package/lib/playground.js +2 -2
  38. package/lib/tests/questionTest.js +1 -1
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"pgcdCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/pgcdCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqCF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAa5C,CAAC"}
1
+ {"version":3,"file":"pgcdCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/pgcdCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgDF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
@@ -4,16 +4,25 @@ import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
4
4
  import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
5
5
  import { randint } from "../../../../math/utils/random/randint.js";
6
6
  import { doWhile } from "../../../../utils/doWhile.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { a, b } = identifiers;
9
+ return `Quel est le PGCD de $${a}$ et $${b}$ ?`;
10
+ };
11
+ const getAnswer = (identifiers) => {
12
+ const { a, b } = identifiers;
13
+ const pgcd = gcd(a, b);
14
+ return pgcd + "";
15
+ };
7
16
  const getPgcdCalculQuestion = () => {
8
17
  const a = doWhile(() => randint(30, 150), (x) => isPrime(x));
9
18
  const b = doWhile(() => randint(30, 150), (x) => x === a || gcd(a, x) === 1);
10
- const pgcd = gcd(a, b);
19
+ const identifiers = { a, b };
11
20
  const question = {
12
- answer: pgcd + "",
13
- instruction: `Donner le PGCD de $${a}$ et $${b}$`,
21
+ answer: getAnswer(identifiers),
22
+ instruction: getInstruction(identifiers),
14
23
  keys: [],
15
24
  answerFormat: "tex",
16
- identifiers: { a, b },
25
+ identifiers,
17
26
  };
18
27
  return question;
19
28
  };
@@ -42,4 +51,6 @@ export const pgcdCalcul = {
42
51
  getPropositions,
43
52
  isAnswerValid,
44
53
  subject: "Mathématiques",
54
+ getAnswer,
55
+ getInstruction,
45
56
  };
@@ -8,6 +8,7 @@ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
8
8
  import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
9
9
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
10
10
  import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ //ax = b
11
12
  const getAnswer = (identifiers) => {
12
13
  const { a, b, x } = identifiers;
13
14
  const answer = new EqualNode(new VariableNode("x"), x.toTree()).toTex();
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeEquationIntType2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8HF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAkB7D,CAAC"}
1
+ {"version":3,"file":"firstDegreeEquationIntType2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+HF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAkB7D,CAAC"}
@@ -8,6 +8,7 @@ import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
8
8
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
9
9
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
10
10
  import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ //ax +b = c
11
12
  const getInstruction = (identifiers) => {
12
13
  const { a, b, c, x } = identifiers;
13
14
  const equation = new EqualNode(new AddNode(new MultiplyNode(a.toTree(), new VariableNode("x")), b.toTree()).simplify({ forbidFactorize: true }), c.toTree());
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeEquationIntType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkHF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAgB7D,CAAC"}
1
+ {"version":3,"file":"firstDegreeEquationIntType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoHF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAgB7D,CAAC"}
@@ -7,6 +7,7 @@ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
7
  import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
8
8
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
9
9
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
10
+ //ax+b = cx+d
10
11
  const getInstruction = (identifiers) => {
11
12
  const { a, b, c, d, x } = identifiers;
12
13
  const equation = new EqualNode(new AddNode(new MultiplyNode(a.toTree(), new VariableNode("x")), b.toTree()).simplify({ forbidFactorize: true }), new AddNode(new MultiplyNode(c.toTree(), new VariableNode("x")), d.toTree()).simplify({ forbidFactorize: true }));
@@ -1 +1 @@
1
- {"version":3,"file":"lengthConversion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/conversion/lengthConversion.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,QAAQ,EAaT,MAAM,mBAAmB,CAAC;AAI3B,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,0BAA0B,EAAE,MAAM,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAwHF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB3D,CAAC"}
1
+ {"version":3,"file":"lengthConversion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/conversion/lengthConversion.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,QAAQ,EAaT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,0BAA0B,EAAE,MAAM,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAuHF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB3D,CAAC"}
@@ -32,8 +32,8 @@ const getAnswer = (identifiers, options) => {
32
32
  return answer;
33
33
  };
34
34
  const getLengthConversion = (options) => {
35
- if (options && !validateOptions(options).valid)
36
- throw Error("options invalides, gen lengthConversion");
35
+ // if (options && !validateOptions(options).valid)
36
+ // throw Error("options invalides, gen lengthConversion");
37
37
  const availableUnitsIndexes = units
38
38
  .map((e, i) => i)
39
39
  .filter((i) => !options?.units?.length || options.units.includes(units[i]));
@@ -82,7 +82,7 @@ const options = [
82
82
  },
83
83
  ];
84
84
  const validateOptions = (opts) => {
85
- if (opts.units.length < 2)
85
+ if (!opts?.units?.length || opts?.units.length < 2)
86
86
  return {
87
87
  message: "Vous devez choisir au moins deux unités.",
88
88
  valid: false,
@@ -96,8 +96,6 @@ export const lengthConversion = {
96
96
  id: "lengthConversion",
97
97
  connector: "=",
98
98
  label: "Conversion de longueurs",
99
- levels: ["6ème", "5ème", "CAP", "2ndPro"],
100
- sections: ["Conversions"],
101
99
  isSingleStep: true,
102
100
  generator: (nb, opts) => getDistinctQuestions(() => getLengthConversion(opts), nb),
103
101
  qcmTimer: 60,
@@ -1,7 +1,94 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
- a: number;
3
+ labels: string[];
4
+ data: number[];
5
+ itemAsked: number;
4
6
  };
5
7
  export declare const barChartReading: Exercise<Identifiers>;
6
8
  export {};
9
+ /***Final version */
10
+ /**
11
+ *
12
+ * const newspapers = [
13
+ { name: "Le Figaro", sales: 320000 },
14
+ { name: "Les Échos", sales: 130000 },
15
+ { name: "La Croix", sales: 90000 },
16
+ { name: "L'Équipe", sales: 210000 },
17
+ { name: "Le Monde", sales: 330000 },
18
+ { name: "Le Parisien", sales: 270000 },
19
+ { name: "Libération", sales: 70000 },
20
+ { name: "L'Humanité", sales: 30000 },
21
+ ];
22
+
23
+ const width = 600,
24
+ height = 400,
25
+ margin = { top: 20, right: 30, bottom: 100, left: 60 };
26
+ const d3n = new D3Node();
27
+ const d3 = d3n.d3;
28
+
29
+ const svg = d3n.createSVG(width, height);
30
+
31
+ const xScale = d3
32
+ .scaleBand()
33
+ .domain(newspapers.map((d) => d.name))
34
+ .range([margin.left, width - margin.right])
35
+ .padding(0.1);
36
+
37
+ const yScale = d3
38
+ .scaleLinear()
39
+ .domain([0, d3.max(newspapers, (d: any) => d.sales)])
40
+ .nice()
41
+ .range([height - margin.bottom, margin.top]);
42
+
43
+ svg
44
+ .append("g")
45
+ .attr("transform", `translate(0,${height - margin.bottom})`)
46
+ .call(d3.axisBottom(xScale).tickSize(0))
47
+ .selectAll("text")
48
+ .style("text-anchor", "end")
49
+ .attr("transform", "rotate(-30)");
50
+
51
+ svg
52
+ .append("g")
53
+ .attr("transform", `translate(${margin.left},0)`)
54
+ .call(
55
+ d3
56
+ .axisLeft(yScale)
57
+ .ticks(5)
58
+ .tickFormat((d: any) =>
59
+ d.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "),
60
+ ),
61
+ );
62
+
63
+ svg
64
+ .append("text")
65
+ .attr("x", margin.left)
66
+ .attr("y", margin.top)
67
+ .attr("text-anchor", "start")
68
+ .style("font-size", "14px")
69
+ .style("font-weight", "bold")
70
+ .text("Nombre d’exemplaires vendus");
71
+
72
+ svg
73
+ .selectAll(".bar")
74
+ .data(newspapers)
75
+ .enter()
76
+ .append("rect")
77
+ .attr("class", "bar")
78
+ .attr("x", (d: any) => xScale(d.name))
79
+ .attr("y", (d: any) => yScale(d.sales))
80
+ .attr("width", xScale.bandwidth())
81
+ .attr("height", (d: any) => height - margin.bottom - yScale(d.sales))
82
+ .attr("fill", "steelblue");
83
+
84
+ const svgString = d3n.svgString();
85
+ return `BBteeeezfst :
86
+
87
+ ofzie
88
+ should read this
89
+ ${svgString}
90
+ should read this
91
+ zef
92
+ `;
93
+ */
7
94
  //# sourceMappingURL=barChartReading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"barChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/barChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC"}
1
+ {"version":3,"file":"barChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/barChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAqHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAgBjD,CAAC;;AAgFF,oBAAoB;AACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG"}
@@ -1,107 +1,92 @@
1
- import { addValidProp, shuffleProps, } from "../../../exercises/exercise.js";
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
4
- //@ts-ignore
5
- import { D3Node } from "d3-node";
6
- const getPropositions = (n, { answer }) => {
4
+ import { randint } from "../../../math/utils/random/randint.js";
5
+ import { GeogebraConstructor } from "../../../geogebra/geogebraConstructor.js";
6
+ import { valueParser } from "../../../tree/parsers/valueParser.js";
7
+ import { random } from "../../../utils/alea/random.js";
8
+ const getPropositions = (n, { answer, ...identifiers }) => {
7
9
  const propositions = [];
10
+ const { labels, data, itemAsked } = identifiers;
8
11
  addValidProp(propositions, answer);
9
12
  while (propositions.length < n) {
10
- throw Error("QCM not implemented");
13
+ tryToAddWrongProp(propositions, random(data).frenchify());
11
14
  }
12
15
  return shuffleProps(propositions, n);
13
16
  };
14
17
  const getAnswer = (identifiers) => {
15
- return "";
18
+ const { labels, data, itemAsked } = identifiers;
19
+ return data[itemAsked].frenchify();
16
20
  };
17
21
  const getInstruction = (identifiers) => {
18
- const newspapers = [
19
- { name: "Le Figaro", sales: 320000 },
20
- { name: "Les Échos", sales: 130000 },
21
- { name: "La Croix", sales: 90000 },
22
- { name: "L'Équipe", sales: 210000 },
23
- { name: "Le Monde", sales: 330000 },
24
- { name: "Le Parisien", sales: 270000 },
25
- { name: "Libération", sales: 70000 },
26
- { name: "L'Humanité", sales: 30000 },
27
- ];
28
- const width = 600, height = 400, margin = { top: 20, right: 30, bottom: 100, left: 60 };
29
- const d3n = new D3Node();
30
- const d3 = d3n.d3;
31
- const svg = d3n.createSVG(width, height);
32
- const xScale = d3
33
- .scaleBand()
34
- .domain(newspapers.map((d) => d.name))
35
- .range([margin.left, width - margin.right])
36
- .padding(0.1);
37
- const yScale = d3
38
- .scaleLinear()
39
- .domain([0, d3.max(newspapers, (d) => d.sales)])
40
- .nice()
41
- .range([height - margin.bottom, margin.top]);
42
- svg
43
- .append("g")
44
- .attr("transform", `translate(0,${height - margin.bottom})`)
45
- .call(d3.axisBottom(xScale).tickSize(0))
46
- .selectAll("text")
47
- .style("text-anchor", "end")
48
- .attr("transform", "rotate(-30)");
49
- svg
50
- .append("g")
51
- .attr("transform", `translate(${margin.left},0)`)
52
- .call(d3
53
- .axisLeft(yScale)
54
- .ticks(5)
55
- .tickFormat((d) => d.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ")));
56
- svg
57
- .append("text")
58
- .attr("x", margin.left)
59
- .attr("y", margin.top)
60
- .attr("text-anchor", "start")
61
- .style("font-size", "14px")
62
- .style("font-weight", "bold")
63
- .text("Nombre d’exemplaires vendus");
64
- svg
65
- .selectAll(".bar")
66
- .data(newspapers)
67
- .enter()
68
- .append("rect")
69
- .attr("class", "bar")
70
- .attr("x", (d) => xScale(d.name))
71
- .attr("y", (d) => yScale(d.sales))
72
- .attr("width", xScale.bandwidth())
73
- .attr("height", (d) => height - margin.bottom - yScale(d.sales))
74
- .attr("fill", "steelblue");
75
- const svgString = d3n.svgString();
76
- return `BBteeeezfst :
22
+ const { labels, data, itemAsked } = identifiers;
23
+ return `Un producteur trie sa récolte de pommes selon leur diamètre. Le diagramme en bâtons ci-dessous représente ses résultats.
77
24
 
78
- ofzie
79
- should read this
80
- ${svgString}
81
- should read this
82
- zef
25
+ Combien de pommes de $${labels[itemAsked]}$ cm de diamètre le producteur a-t-il récoltées ?
83
26
  `;
84
27
  };
85
- const getHint = (identifiers) => {
86
- return "";
87
- };
88
- const getCorrection = (identifiers) => {
89
- return "";
90
- };
28
+ // const getHint: GetHint<Identifiers> = (identifiers) => {
29
+ // return "";
30
+ // };
31
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
32
+ // return "";
33
+ // };
91
34
  const getKeys = (identifiers) => {
92
35
  return [];
93
36
  };
94
37
  const isAnswerValid = (ans, { answer }) => {
95
38
  try {
96
- throw Error("VEA not implemented");
39
+ const parsed = valueParser(ans);
40
+ if (parsed === false)
41
+ return false;
42
+ const ansNb = answer.unfrenchify();
43
+ return Math.abs(parsed - ansNb) < 20;
97
44
  }
98
45
  catch (err) {
99
46
  return handleVEAError(err);
100
47
  }
101
48
  };
49
+ const getGGBOptions = (identifiers) => {
50
+ const { labels, data } = identifiers;
51
+ const commands = [
52
+ `B = BarChart({1,2,3,4,5}, {${data.join(",")}}, 0.5)`,
53
+ ...labels.map((l, i) => `Text("\\footnotesize ${l}", (${i + 1}, 0), true, true, 0, -1)`),
54
+ `Text("\\footnotesize Diamètre\\ (en \\ cm)", (3, -100), true, true, 0, -1)`,
55
+ `ShowLabel(B,false)`,
56
+ `SetColor(B, "#FE0045AB")`,
57
+ ];
58
+ const ggb = new GeogebraConstructor({
59
+ commands,
60
+ gridDistance: [10000, 50],
61
+ fontSize: 16,
62
+ lockedAxesRatio: 1 / 250,
63
+ xAxis: {
64
+ // hideNumbers: true,
65
+ showPositive: true,
66
+ hidden: true,
67
+ },
68
+ yAxis: {
69
+ showPositive: true,
70
+ label: "$\\footnotesize Nombre\\ de\\ pommes$",
71
+ steps: 100,
72
+ },
73
+ });
74
+ return ggb.getOptions({
75
+ coords: [-1, 6, -100, 1000],
76
+ });
77
+ };
102
78
  const getBarChartReadingQuestion = (ops) => {
79
+ const data = [];
80
+ const labels = ["11", "12", "13", "15", "16"];
81
+ for (let i = 0; i < labels.length; i++) {
82
+ data.push(50 *
83
+ randint(1, 20, data.map((d) => d / 50)));
84
+ }
85
+ const itemAsked = randint(0, 5);
103
86
  const identifiers = {
104
- a: Math.random(),
87
+ labels,
88
+ data,
89
+ itemAsked,
105
90
  };
106
91
  const question = {
107
92
  answer: getAnswer(identifiers),
@@ -109,14 +94,15 @@ const getBarChartReadingQuestion = (ops) => {
109
94
  keys: getKeys(identifiers),
110
95
  answerFormat: "tex",
111
96
  identifiers,
112
- hint: getHint(identifiers),
113
- correction: getCorrection(identifiers),
97
+ // hint: getHint(identifiers),
98
+ // correction: getCorrection(identifiers),
99
+ ggbOptions: getGGBOptions(identifiers),
114
100
  };
115
101
  return question;
116
102
  };
117
103
  export const barChartReading = {
118
104
  id: "barChartReading",
119
- label: "",
105
+ label: "Lecture d'un diagramme en bâtons",
120
106
  isSingleStep: true,
121
107
  generator: (nb, opts) => getDistinctQuestions(() => getBarChartReadingQuestion(opts), nb),
122
108
  qcmTimer: 60,
@@ -125,9 +111,10 @@ export const barChartReading = {
125
111
  isAnswerValid,
126
112
  subject: "Mathématiques",
127
113
  getInstruction,
128
- getHint,
129
- getCorrection,
114
+ // getHint,
115
+ // getCorrection,
130
116
  getAnswer,
117
+ hasGeogebra: true,
131
118
  };
132
119
  // !signtable
133
120
  // const options = { svg: true };
@@ -196,3 +183,88 @@ export const barChartReading = {
196
183
  // text,
197
184
  // ),
198
185
  // );
186
+ /***Final version */
187
+ /**
188
+ *
189
+ * const newspapers = [
190
+ { name: "Le Figaro", sales: 320000 },
191
+ { name: "Les Échos", sales: 130000 },
192
+ { name: "La Croix", sales: 90000 },
193
+ { name: "L'Équipe", sales: 210000 },
194
+ { name: "Le Monde", sales: 330000 },
195
+ { name: "Le Parisien", sales: 270000 },
196
+ { name: "Libération", sales: 70000 },
197
+ { name: "L'Humanité", sales: 30000 },
198
+ ];
199
+
200
+ const width = 600,
201
+ height = 400,
202
+ margin = { top: 20, right: 30, bottom: 100, left: 60 };
203
+ const d3n = new D3Node();
204
+ const d3 = d3n.d3;
205
+
206
+ const svg = d3n.createSVG(width, height);
207
+
208
+ const xScale = d3
209
+ .scaleBand()
210
+ .domain(newspapers.map((d) => d.name))
211
+ .range([margin.left, width - margin.right])
212
+ .padding(0.1);
213
+
214
+ const yScale = d3
215
+ .scaleLinear()
216
+ .domain([0, d3.max(newspapers, (d: any) => d.sales)])
217
+ .nice()
218
+ .range([height - margin.bottom, margin.top]);
219
+
220
+ svg
221
+ .append("g")
222
+ .attr("transform", `translate(0,${height - margin.bottom})`)
223
+ .call(d3.axisBottom(xScale).tickSize(0))
224
+ .selectAll("text")
225
+ .style("text-anchor", "end")
226
+ .attr("transform", "rotate(-30)");
227
+
228
+ svg
229
+ .append("g")
230
+ .attr("transform", `translate(${margin.left},0)`)
231
+ .call(
232
+ d3
233
+ .axisLeft(yScale)
234
+ .ticks(5)
235
+ .tickFormat((d: any) =>
236
+ d.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "),
237
+ ),
238
+ );
239
+
240
+ svg
241
+ .append("text")
242
+ .attr("x", margin.left)
243
+ .attr("y", margin.top)
244
+ .attr("text-anchor", "start")
245
+ .style("font-size", "14px")
246
+ .style("font-weight", "bold")
247
+ .text("Nombre d’exemplaires vendus");
248
+
249
+ svg
250
+ .selectAll(".bar")
251
+ .data(newspapers)
252
+ .enter()
253
+ .append("rect")
254
+ .attr("class", "bar")
255
+ .attr("x", (d: any) => xScale(d.name))
256
+ .attr("y", (d: any) => yScale(d.sales))
257
+ .attr("width", xScale.bandwidth())
258
+ .attr("height", (d: any) => height - margin.bottom - yScale(d.sales))
259
+ .attr("fill", "steelblue");
260
+
261
+ const svgString = d3n.svgString();
262
+ return `BBteeeezfst :
263
+
264
+ ofzie
265
+ should read this
266
+ ${svgString}
267
+ should read this
268
+ zef
269
+ `;
270
+ */
@@ -1,4 +1,5 @@
1
1
  export * from "./tableReading.js";
2
+ export * from "./barChartReading.js";
2
3
  export * from "./functionGraphReading.js";
3
4
  export * from "./pieChartReading.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export * from "./tableReading.js";
2
- // export * from "./barChartReading.js";
2
+ export * from "./barChartReading.js";
3
3
  export * from "./functionGraphReading.js";
4
4
  export * from "./pieChartReading.js";
5
5
  // export * from "./testGen.js";
@@ -20,7 +20,7 @@ const getVectorLinearCombinationQuestion = () => {
20
20
  y: v.y.simplify().evaluate(),
21
21
  };
22
22
  const instruction = `Soient deux vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$.
23
- Calculer les coordonnées du vecteur $${getAddVectorTex(getMultiplyVectorTex(a, u), getMultiplyVectorTex(b, v))}$`;
23
+ Calculer les coordonnées du vecteur $${getAddVectorTex(getMultiplyVectorTex(a, u), getMultiplyVectorTex(b, v))}$.`;
24
24
  const aUPlusBv = calculateLinearCombination(a, b, u, v);
25
25
  const correctAnswer = new Vector("au+bv", aUPlusBv.x, aUPlusBv.y);
26
26
  const question = {
@@ -1,7 +1,8 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../tree/nodes/nodeConstructor.js";
2
3
  type Identifiers = {
3
- reason: string;
4
- firstTerm: string;
4
+ reason: NodeIdentifiers;
5
+ firstTerm: NodeIdentifiers;
5
6
  };
6
7
  export declare const sequenceGeometricLimit: Exercise<Identifiers>;
7
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceGeometricLimit.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/sequenceGeometricLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA6CF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
1
+ {"version":3,"file":"sequenceGeometricLimit.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/sequenceGeometricLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAE7C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,eAAe,CAAC;CAC5B,CAAC;AA6DF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
@@ -1,22 +1,34 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
- import { GeometricSequenceConstructor } from "../../../math/sequences/geometricSequence.js";
3
+ import { GeometricSequence, GeometricSequenceConstructor, } from "../../../math/sequences/geometricSequence.js";
4
+ import { reifyAlgebraic, } from "../../../tree/nodes/nodeConstructor.js";
5
+ const getInstruction = (identifiers) => {
6
+ const { reason, firstTerm } = identifiers;
7
+ const sequence = new GeometricSequence(reifyAlgebraic(firstTerm), reifyAlgebraic(reason));
8
+ return `Déterminer la limite de la suite $u$ définie par :
9
+
10
+ $$
11
+ u_n = ${sequence.toTree().toTex()}
12
+ $$`;
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const { reason, firstTerm } = identifiers;
16
+ const sequence = new GeometricSequence(reifyAlgebraic(firstTerm), reifyAlgebraic(reason));
17
+ const answer = sequence.getLimit();
18
+ return answer.toTex();
19
+ };
4
20
  const getSequenceGeometricLimitQuestion = () => {
5
21
  const sequence = GeometricSequenceConstructor.randomWithLimit();
6
- const answer = sequence.getLimit();
7
- if (!answer)
8
- throw Error("received geometric sequence with no limit");
22
+ const identifiers = {
23
+ reason: sequence.reason.toIdentifiers(),
24
+ firstTerm: sequence.firstTerm.toIdentifiers(),
25
+ };
9
26
  const question = {
10
- answer: answer,
11
- instruction: `Déterminer la limite de la suite $u$ définie par : $u_n = ${sequence
12
- .toTree()
13
- .toTex()}$.`,
27
+ answer: getAnswer(identifiers),
28
+ instruction: getInstruction(identifiers),
14
29
  keys: ["infty"],
15
30
  answerFormat: "tex",
16
- identifiers: {
17
- reason: sequence.reason.toTree().toTex(),
18
- firstTerm: sequence.firstTerm.toTree().toTex(),
19
- },
31
+ identifiers,
20
32
  };
21
33
  return question;
22
34
  };
@@ -26,8 +38,8 @@ const getPropositions = (n, { answer, reason, firstTerm }) => {
26
38
  tryToAddWrongProp(propositions, "+\\infty");
27
39
  tryToAddWrongProp(propositions, "-\\infty");
28
40
  tryToAddWrongProp(propositions, "0");
29
- tryToAddWrongProp(propositions, reason + "");
30
- tryToAddWrongProp(propositions, firstTerm + "");
41
+ tryToAddWrongProp(propositions, reifyAlgebraic(reason).toTex());
42
+ tryToAddWrongProp(propositions, reifyAlgebraic(firstTerm).toTex());
31
43
  return shuffleProps(propositions, n);
32
44
  };
33
45
  const isAnswerValid = (ans, { answer }) => {
@@ -37,13 +49,13 @@ export const sequenceGeometricLimit = {
37
49
  id: "sequenceGeometricLimit",
38
50
  connector: "=",
39
51
  label: "Limite d'une suite géométrique",
40
- levels: ["TermSpé", "MathComp"],
41
52
  isSingleStep: true,
42
- sections: ["Limites", "Suites"],
43
53
  generator: (nb) => getDistinctQuestions(getSequenceGeometricLimitQuestion, nb),
44
54
  qcmTimer: 60,
45
55
  freeTimer: 60,
46
56
  getPropositions,
47
57
  isAnswerValid,
48
58
  subject: "Mathématiques",
59
+ getAnswer,
60
+ getInstruction,
49
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"valuePercent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/valuePercent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAyCF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAc9C,CAAC"}
1
+ {"version":3,"file":"valuePercent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/valuePercent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4DF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAgB9C,CAAC"}
@@ -3,22 +3,38 @@ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuesti
3
3
  import { DecimalConstructor } from "../../../math/numbers/decimals/decimal.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { round } from "../../../math/utils/round.js";
6
+ const getInstruction = (identifiers) => {
7
+ const { percent, nb } = identifiers;
8
+ return `Calculer $${percent}\\%$ de $${nb}$.`;
9
+ };
10
+ const getAnswer = (identifiers) => {
11
+ const { percent, nb } = identifiers;
12
+ const ans = round((percent * nb) / 100, 2).frenchify();
13
+ return ans;
14
+ };
15
+ const getHint = (identifiers) => {
16
+ return `Pour calculer $x\\%$ d'un nombre, on le multiplie par $\\frac{x}{100}$.`;
17
+ };
18
+ const getCorrection = (identifiers) => {
19
+ const { percent, nb } = identifiers;
20
+ return `Pour calculer $${percent}\\%$ de $${nb}$, on multiplie $${nb}$ par $\\frac{${percent}}{100}$ :
21
+
22
+ $$
23
+ ${nb}\\times \\frac{${percent}}{100} = ${getAnswer(identifiers)}
24
+ $$`;
25
+ };
6
26
  const getValuePercentQuestion = () => {
7
27
  const percent = randint(1, 100);
8
28
  const nb = randint(1, 100);
9
- const ans = round((percent * nb) / 100, 2).frenchify();
29
+ const identifiers = { percent, nb };
10
30
  const question = {
11
- answer: ans + "",
12
- instruction: `Calculer $${percent}\\%$ de $${nb}$.`,
31
+ answer: getAnswer(identifiers),
32
+ instruction: getInstruction(identifiers),
13
33
  keys: [],
14
34
  answerFormat: "tex",
15
- identifiers: { percent, nb },
16
- hint: `Pour calculer $x\\%$ d'un nombre, on le multiplie par $\\frac{x}{100}$.`,
17
- correction: `Pour calculer $${percent}\\%$ de $${nb}$, on multiplie $${nb}$ par $\\frac{${percent}}{100}$ :
18
-
19
- $
20
- ${nb}\\times \\frac{${percent}}{100} = ${ans}
21
- $`,
35
+ identifiers,
36
+ hint: getHint(identifiers),
37
+ correction: getCorrection(identifiers),
22
38
  };
23
39
  return question;
24
40
  };
@@ -37,9 +53,7 @@ export const valuePercent = {
37
53
  id: "valuePercent",
38
54
  connector: "=",
39
55
  label: "Appliquer un pourcentage",
40
- levels: ["3ème", "2ndPro", "2nde", "1reESM", "1rePro"],
41
56
  isSingleStep: true,
42
- sections: ["Pourcentages"],
43
57
  generator: (nb) => getDistinctQuestions(getValuePercentQuestion, nb),
44
58
  qcmTimer: 60,
45
59
  freeTimer: 60,
@@ -47,4 +61,8 @@ export const valuePercent = {
47
61
  isAnswerValid,
48
62
  subject: "Mathématiques",
49
63
  hasHintAndCorrection: true,
64
+ getAnswer,
65
+ getInstruction,
66
+ getCorrection,
67
+ getHint,
50
68
  };
@@ -1,5 +1,12 @@
1
1
  import { Exercise } from "../../../../exercises/exercise.js";
2
- type Identifiers = {};
2
+ type Identifiers = {
3
+ ax: number;
4
+ ay: number;
5
+ az: number;
6
+ bx: number;
7
+ by: number;
8
+ bz: number;
9
+ };
3
10
  export declare const spaceVectorCoordinatesFromPoints: Exercise<Identifiers>;
4
11
  export {};
5
12
  //# sourceMappingURL=spaceVectorCoordinatesFromPoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spaceVectorCoordinatesFromPoints.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG,EAAE,CAAC;AAqEtB,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAgBlE,CAAC"}
1
+ {"version":3,"file":"spaceVectorCoordinatesFromPoints.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAuGF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAkBlE,CAAC"}
@@ -4,37 +4,69 @@ import { SpacePointConstructor } from "../../../../math/geometry/spacePoint.js";
4
4
  import { SpaceVectorConstructor, } from "../../../../math/geometry/spaceVector.js";
5
5
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
6
6
  import { alignTex } from "../../../../utils/latex/alignTex.js";
7
- const getSpaceVectorCoordinatesFromPointsQuestion = () => {
8
- const points = SpacePointConstructor.randomDifferent(["A", "B"]);
7
+ const getInstruction = (identifiers) => {
8
+ const { ax, ay, az, bx, by, bz } = identifiers;
9
+ const points = [
10
+ SpacePointConstructor.fromScalars([ax, ay, az], "A"),
11
+ SpacePointConstructor.fromScalars([bx, by, bz], "B"),
12
+ ];
13
+ const vector = SpaceVectorConstructor.fromPoints(points[0], points[1]);
14
+ return `Soit deux points de l'espace $${points[0].toTexWithCoords()}$ et $${points[1].toTexWithCoords()}$.
15
+
16
+ Quelles sont les coordonnées du vecteur $\\overrightarrow{AB}$ ?`;
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { ax, ay, az, bx, by, bz } = identifiers;
20
+ const points = [
21
+ SpacePointConstructor.fromScalars([ax, ay, az], "A"),
22
+ SpacePointConstructor.fromScalars([bx, by, bz], "B"),
23
+ ];
9
24
  const vector = SpaceVectorConstructor.fromPoints(points[0], points[1]);
10
25
  const answer = vector.toInlineCoordsTex();
11
- const question = {
12
- answer,
13
- instruction: `Soit deux points $${points[0].toTexWithCoords()}$ et $${points[1].toTexWithCoords()}$. Quelles sont les coordonnées du vecteur $\\overrightarrow{AB}$ ?`,
14
- keys: ["semicolon"],
15
- answerFormat: "tex",
16
- identifiers: {
17
- ax: points[0].x.evaluate({}),
18
- ay: points[0].y.evaluate({}),
19
- az: points[0].z.evaluate({}),
20
- bx: points[1].x.evaluate({}),
21
- by: points[1].y.evaluate({}),
22
- bz: points[1].z.evaluate({}),
23
- },
24
- hint: `Soient deux points $M(x_M;y_M;z_M)$ et $N(x_N;y_N;z_N)$, alors le vecteur $\\overrightarrow{MN}$ a pour coordonnées :
26
+ return answer;
27
+ };
28
+ const getHint = (identifiers) => {
29
+ return `Soient deux points $M(x_M;y_M;z_M)$ et $N(x_N;y_N;z_N)$, alors le vecteur $\\overrightarrow{MN}$ a pour coordonnées :
25
30
 
26
31
  $$
27
32
  \\overrightarrow{MN} \\begin{pmatrix} x_N - x_M \\\\ y_N - y_M \\\\ z_N - z_M \\end{pmatrix}
28
- $$`,
29
- correction: `Les coordonnées du vecteur $\\overrightarrow{AB}$ sont :
33
+ $$`;
34
+ };
35
+ const getCorrection = (identifiers) => {
36
+ const { ax, ay, az, bx, by, bz } = identifiers;
37
+ const points = [
38
+ SpacePointConstructor.fromScalars([ax, ay, az]),
39
+ SpacePointConstructor.fromScalars([bx, by, bz]),
40
+ ];
41
+ const vector = SpaceVectorConstructor.fromPoints(points[0], points[1]);
42
+ return `Les coordonnées du vecteur $\\overrightarrow{AB}$ sont :
30
43
 
31
44
  ${alignTex([
32
- [
33
- `\\begin{pmatrix} ${new SubstractNode(points[1].x, points[0].x).toTex()} \\\\ ${new SubstractNode(points[1].y, points[0].y).toTex()} \\\\ ${new SubstractNode(points[1].z, points[0].z).toTex()} \\end{pmatrix}`,
34
- "=",
35
- vector.toCoordsTex(),
36
- ],
37
- ])}`,
45
+ [
46
+ `\\begin{pmatrix} ${new SubstractNode(points[1].x, points[0].x).toTex()} \\\\ ${new SubstractNode(points[1].y, points[0].y).toTex()} \\\\ ${new SubstractNode(points[1].z, points[0].z).toTex()} \\end{pmatrix}`,
47
+ "=",
48
+ vector.toCoordsTex(),
49
+ ],
50
+ ])}`;
51
+ };
52
+ const getSpaceVectorCoordinatesFromPointsQuestion = () => {
53
+ const points = SpacePointConstructor.randomDifferent(["A", "B"]);
54
+ const identifiers = {
55
+ ax: points[0].x.evaluate({}),
56
+ ay: points[0].y.evaluate({}),
57
+ az: points[0].z.evaluate({}),
58
+ bx: points[1].x.evaluate({}),
59
+ by: points[1].y.evaluate({}),
60
+ bz: points[1].z.evaluate({}),
61
+ };
62
+ const question = {
63
+ answer: getAnswer(identifiers),
64
+ instruction: getInstruction(identifiers),
65
+ keys: ["semicolon"],
66
+ answerFormat: "tex",
67
+ identifiers,
68
+ hint: getHint(identifiers),
69
+ correction: getCorrection(identifiers),
38
70
  };
39
71
  return question;
40
72
  };
@@ -53,9 +85,7 @@ export const spaceVectorCoordinatesFromPoints = {
53
85
  id: "spaceVectorCoordinatesFromPoints",
54
86
  connector: "=",
55
87
  label: "Déterminer les coordonnées d'un vecteur à partir de deux points (dans l'espace)",
56
- levels: [],
57
88
  isSingleStep: true,
58
- sections: [],
59
89
  generator: (nb) => getDistinctQuestions(getSpaceVectorCoordinatesFromPointsQuestion, nb),
60
90
  qcmTimer: 60,
61
91
  freeTimer: 60,
@@ -63,4 +93,8 @@ export const spaceVectorCoordinatesFromPoints = {
63
93
  isAnswerValid,
64
94
  subject: "Mathématiques",
65
95
  hasHintAndCorrection: true,
96
+ getAnswer,
97
+ getInstruction,
98
+ getCorrection,
99
+ getHint,
66
100
  };
@@ -1,5 +1,14 @@
1
1
  import { Exercise } from "../../../../exercises/exercise.js";
2
- type Identifiers = {};
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ ux: number;
6
+ uy: number;
7
+ uz: number;
8
+ vx: number;
9
+ vy: number;
10
+ vz: number;
11
+ };
3
12
  export declare const spaceVectorLinearCombinationCoords: Exercise<Identifiers>;
4
13
  export {};
5
14
  //# sourceMappingURL=spaceVectorLinearCombinationCoords.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spaceVectorLinearCombinationCoords.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG,EAAE,CAAC;AA2DtB,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAepE,CAAC"}
1
+ {"version":3,"file":"spaceVectorLinearCombinationCoords.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4EF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAepE,CAAC"}
@@ -6,29 +6,44 @@ import { randint } from "../../../../math/utils/random/randint.js";
6
6
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
7
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  // coords de au + bv en 3D
9
- const getSpaceVectorLinearCombinationCoordsQuestion = () => {
10
- const a = randint(-10, 11, [0]);
11
- const b = randint(-10, 11, [0]);
12
- const [u, v] = SpaceVectorConstructor.randomDifferents(["u", "v"], false);
9
+ const getInstruction = (identifiers) => {
10
+ const { a, b, ux, uy, uz, vx, vy, vz } = identifiers;
11
+ const u = SpaceVectorConstructor.fromScalars([ux, uy, uz], "u");
12
+ const v = SpaceVectorConstructor.fromScalars([vx, vy, vz], "v");
13
+ return `Soit deux vecteurs de l'espace $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$.
14
+
15
+ Calculer les coordonnées du vecteur $${new AddNode(new MultiplyNode(a.toTree(), u.toTex().toTree()), new MultiplyNode(b.toTree(), v.toTex().toTree())).toTex()}$.`;
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { a, b, ux, uy, uz, vx, vy, vz } = identifiers;
19
+ const u = SpaceVectorConstructor.fromScalars([ux, uy, uz], "u");
20
+ const v = SpaceVectorConstructor.fromScalars([vx, vy, vz], "v");
13
21
  const answer = u
14
22
  .times(a.toTree())
15
23
  .add(v.times(b.toTree()))
16
24
  .toInlineCoordsTex();
25
+ return answer;
26
+ };
27
+ const getSpaceVectorLinearCombinationCoordsQuestion = () => {
28
+ const a = randint(-10, 11, [0]);
29
+ const b = randint(-10, 11, [0]);
30
+ const [u, v] = SpaceVectorConstructor.randomDifferents(["u", "v"], false);
31
+ const identifiers = {
32
+ a,
33
+ b,
34
+ ux: u.x.evaluate({}),
35
+ uy: u.y.evaluate({}),
36
+ uz: u.z.evaluate({}),
37
+ vx: v.x.evaluate({}),
38
+ vy: v.y.evaluate({}),
39
+ vz: v.z.evaluate({}),
40
+ };
17
41
  const question = {
18
- answer,
19
- instruction: `Soit deux vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$. Calculer les coordonnées du vecteur $${new AddNode(new MultiplyNode(a.toTree(), u.toTex().toTree()), new MultiplyNode(b.toTree(), v.toTex().toTree())).toTex()}$`,
42
+ answer: getAnswer(identifiers),
43
+ instruction: getInstruction(identifiers),
20
44
  keys: ["semicolon"],
21
45
  answerFormat: "tex",
22
- identifiers: {
23
- a,
24
- b,
25
- ux: u.x.evaluate({}),
26
- uy: u.y.evaluate({}),
27
- uz: u.z.evaluate({}),
28
- vx: v.x.evaluate({}),
29
- vy: v.y.evaluate({}),
30
- vz: v.z.evaluate({}),
31
- },
46
+ identifiers,
32
47
  };
33
48
  return question;
34
49
  };
@@ -46,14 +61,14 @@ const isAnswerValid = (ans, { answer }) => {
46
61
  export const spaceVectorLinearCombinationCoords = {
47
62
  id: "spaceVectorLinearCombinationCoords",
48
63
  connector: "=",
49
- label: "Calcul des coordonnées du vecteur $a\\overrightarrow{u} + b\\overrightarrow{v}$ (dans l'espace)",
50
- levels: [],
64
+ label: "Calculer les coordonnées du vecteur $a\\overrightarrow{u} + b\\overrightarrow{v}$ (dans l'espace)",
51
65
  isSingleStep: true,
52
- sections: [],
53
66
  generator: (nb) => getDistinctQuestions(getSpaceVectorLinearCombinationCoordsQuestion, nb),
54
67
  qcmTimer: 60,
55
68
  freeTimer: 60,
56
69
  getPropositions,
57
70
  isAnswerValid,
58
71
  subject: "Mathématiques",
72
+ getAnswer,
73
+ getInstruction,
59
74
  };
@@ -23,7 +23,7 @@ const getConcentrationReadingQuestion = () => {
23
23
  instruction: `On trace la courbe d'étalonnage ci-dessous. L'absorbance d'ue solution est $A = ${absorbtion}$. Quelle est la concentration en espèce colorée de cette solution ?`,
24
24
  keys: [],
25
25
  answerFormat: "tex",
26
- identifiers: {},
26
+ identifiers: { absorbtion, concentration },
27
27
  ggbOptions: ggb.getOptions({
28
28
  coords: [-1, concentration + 2, -1, absorbtion + 2],
29
29
  }),
package/lib/index.d.ts CHANGED
@@ -1339,8 +1339,8 @@ declare const mathExercises: (Exercise<{
1339
1339
  numCoeffs: number[];
1340
1340
  denumCoeffs: number[];
1341
1341
  }, {}> | Exercise<{
1342
- reason: string;
1343
- firstTerm: string;
1342
+ reason: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1343
+ firstTerm: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1344
1344
  }, {}> | Exercise<{
1345
1345
  coeffs: number[];
1346
1346
  }, {}> | Exercise<{
@@ -1756,7 +1756,23 @@ declare const mathExercises: (Exercise<{
1756
1756
  x: number;
1757
1757
  y: number;
1758
1758
  z: number;
1759
- }, {}> | Exercise<{}, {}> | Exercise<{}, {}> | Exercise<{
1759
+ }, {}> | Exercise<{
1760
+ ax: number;
1761
+ ay: number;
1762
+ az: number;
1763
+ bx: number;
1764
+ by: number;
1765
+ bz: number;
1766
+ }, {}> | Exercise<{
1767
+ a: number;
1768
+ b: number;
1769
+ ux: number;
1770
+ uy: number;
1771
+ uz: number;
1772
+ vx: number;
1773
+ vy: number;
1774
+ vz: number;
1775
+ }, {}> | Exercise<{
1760
1776
  l: number;
1761
1777
  L: number;
1762
1778
  h: number;
@@ -1914,6 +1930,10 @@ declare const mathExercises: (Exercise<{
1914
1930
  }, {}> | Exercise<{
1915
1931
  values: number[][];
1916
1932
  caseAsked: number;
1933
+ }, {}> | Exercise<{
1934
+ labels: string[];
1935
+ data: number[];
1936
+ itemAsked: number;
1917
1937
  }, {}> | Exercise<{
1918
1938
  isAskingX: boolean;
1919
1939
  xValue?: 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,OA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
@@ -5,7 +5,7 @@ export declare abstract class SpaceVectorConstructor {
5
5
  static fromPoints(origin: SpacePoint, end: SpacePoint): SpaceVector;
6
6
  static random(name: string, allowNull?: boolean): SpaceVector;
7
7
  static randomDifferents(names: string[], allowNull?: boolean): SpaceVector[];
8
- static fromScalars(arr: number[]): SpaceVector;
8
+ static fromScalars(arr: number[], name?: string): SpaceVector;
9
9
  }
10
10
  export declare class SpaceVector {
11
11
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"spaceVector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/spaceVector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAE,IAAI,EAAY,MAAM,0BAA0B,CAAC;AAY1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,8BAAsB,sBAAsB;IAC1C,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,WAAW;IAQnE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,WAAW;IAY3D,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,UAAQ,GAAG,WAAW,EAAE;IAW1E,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE;CAWjC;AAED,qBAAa,WAAW;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBAEf,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,aAAa,EA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AAG,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;CAWhD;AAED,qBAAa,WAAW;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBAEf,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa;IAQlB,SAAS;IAGT,kBAAkB;IAGlB,KAAK,IAAI,MAAM;IAIf,WAAW,IAAI,MAAM;IAGrB,iBAAiB,IAAI,MAAM;IAK3B,eAAe,IAAI,MAAM;IAMzB,eAAe,CAAC,CAAC,EAAE,WAAW,GAAG,WAAW;IAiB5C,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO;IAMnC,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO;IAGnC,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,aAAa;IAI1C,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAQrC,aAAa,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI;IAInC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,WAAW;IAShC,OAAO,IAAI,aAAa;IAYxB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM;IAQjD,MAAM,CAAC,CAAC,EAAE,WAAW;CAGtB"}
@@ -32,11 +32,11 @@ export class SpaceVectorConstructor {
32
32
  }
33
33
  return res;
34
34
  }
35
- static fromScalars(arr) {
35
+ static fromScalars(arr, name) {
36
36
  if (arr.length !== 3) {
37
37
  throw new Error("array must have 3 elements");
38
38
  }
39
- return new SpaceVector("P", new NumberNode(arr[0]), new NumberNode(arr[1]), new NumberNode(arr[2]));
39
+ return new SpaceVector(name ?? "P", new NumberNode(arr[0]), new NumberNode(arr[1]), new NumberNode(arr[2]));
40
40
  }
41
41
  }
42
42
  export class SpaceVector {
@@ -1,14 +1,16 @@
1
+ import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
2
+ import { NumberNode } from "../../tree/nodes/numbers/numberNode.js";
1
3
  import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode.js";
2
- import { Nombre, NumberType } from "../numbers/nombre.js";
4
+ import { NumberType } from "../numbers/nombre.js";
3
5
  export declare abstract class GeometricSequenceConstructor {
4
6
  static random(reasonType?: NumberType): GeometricSequence;
5
7
  static randomWithLimit(reasonType?: NumberType): GeometricSequence;
6
8
  }
7
9
  export declare class GeometricSequence {
8
- firstTerm: Nombre;
9
- reason: Nombre;
10
- constructor(firstTerm: Nombre, reason: Nombre);
11
- getLimit(): string | null;
10
+ firstTerm: AlgebraicNode;
11
+ reason: AlgebraicNode;
12
+ constructor(firstTerm: AlgebraicNode, reason: AlgebraicNode);
13
+ getLimit(): AlgebraicNode | import("../../tree/nodes/numbers/constantNode.js").ConstantNode | NumberNode;
12
14
  toTree(): MultiplyNode;
13
15
  }
14
16
  //# sourceMappingURL=geometricSequence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometricSequence.d.ts","sourceRoot":"","sources":["../../../src/math/sequences/geometricSequence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAO1E,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAI1D,8BAAsB,4BAA4B;IAChD,MAAM,CAAC,MAAM,CAAC,UAAU,GAAE,UAA+B;IAoBzD,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU;CA2B/C;AAED,qBAAa,iBAAiB;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;gBAEH,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK7C,QAAQ;IAOR,MAAM;CASP"}
1
+ {"version":3,"file":"geometricSequence.d.ts","sourceRoot":"","sources":["../../../src/math/sequences/geometricSequence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKlE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAK1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKlD,8BAAsB,4BAA4B;IAChD,MAAM,CAAC,MAAM,CAAC,UAAU,GAAE,UAA+B;IAoBzD,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU;CAuB/C;AAED,qBAAa,iBAAiB;IAC5B,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,aAAa,CAAC;gBAEV,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa;IAK3D,QAAQ;IAYR,MAAM;CASP"}
@@ -1,12 +1,12 @@
1
+ import { MinusInfinityNode, PlusInfinityNode, } from "../../tree/nodes/numbers/infiniteNode.js";
1
2
  import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode.js";
2
3
  import { PowerNode } from "../../tree/nodes/operators/powerNode.js";
3
4
  import { VariableNode } from "../../tree/nodes/variables/variableNode.js";
4
5
  import { coinFlip } from "../../utils/alea/coinFlip.js";
5
6
  import { random } from "../../utils/alea/random.js";
6
- import { DecimalConstructor } from "../numbers/decimals/decimal.js";
7
- import { Integer } from "../numbers/integer/integer.js";
8
7
  import { NumberType } from "../numbers/nombre.js";
9
8
  import { RationalConstructor } from "../numbers/rationals/rational.js";
9
+ import { randfloat } from "../utils/random/randfloat.js";
10
10
  import { randint } from "../utils/random/randint.js";
11
11
  export class GeometricSequenceConstructor {
12
12
  static random(reasonType = NumberType.Integer) {
@@ -15,18 +15,18 @@ export class GeometricSequenceConstructor {
15
15
  random([NumberType.Decimal, NumberType.Integer, NumberType.Rational]);
16
16
  switch (type) {
17
17
  case NumberType.Decimal:
18
- reason = DecimalConstructor.random(-9, 10);
18
+ reason = randfloat(-9, 10, 2).toTree();
19
19
  break;
20
20
  case NumberType.Integer:
21
- reason = new Integer(randint(-9, 10, [0, 1]));
21
+ reason = randint(-9, 10, [0, 1]).toTree();
22
22
  break;
23
23
  case NumberType.Rational:
24
- reason = RationalConstructor.randomIrreductible();
24
+ reason = RationalConstructor.randomIrreductible().toTree();
25
25
  break;
26
26
  case NumberType.Real:
27
27
  throw Error("real geometric reason not supported yet");
28
28
  }
29
- return new GeometricSequence(new Integer(randint(-9, 10, [0, 1])), reason);
29
+ return new GeometricSequence(randint(-9, 10, [0, 1]).toTree(), reason);
30
30
  }
31
31
  static randomWithLimit(reasonType) {
32
32
  let reason;
@@ -34,21 +34,20 @@ export class GeometricSequenceConstructor {
34
34
  random([NumberType.Decimal, NumberType.Integer, NumberType.Rational]);
35
35
  switch (type) {
36
36
  case NumberType.Decimal:
37
- const precision = randint(1, 4);
38
37
  reason = coinFlip()
39
- ? DecimalConstructor.fromParts(coinFlip() ? "0" : "-0", DecimalConstructor.randomFracPart(precision))
40
- : DecimalConstructor.random(1, 10);
38
+ ? randfloat(-0.9999, 1, 2).toTree()
39
+ : randfloat(1.01, 10, 2).toTree();
41
40
  break;
42
41
  case NumberType.Integer:
43
- reason = new Integer(randint(2, 10, [0, 1]));
42
+ reason = randint(2, 10, [0, 1]).toTree();
44
43
  break;
45
44
  case NumberType.Rational:
46
- reason = RationalConstructor.randomIrreductible();
45
+ reason = RationalConstructor.randomIrreductible().toTree();
47
46
  break;
48
47
  case NumberType.Real:
49
48
  throw Error("real geometric reason not supported yet");
50
49
  }
51
- return new GeometricSequence(new Integer(randint(-9, 10, [0, 1])), reason);
50
+ return new GeometricSequence(randint(-9, 10, [0, 1]).toTree(), reason);
52
51
  }
53
52
  }
54
53
  export class GeometricSequence {
@@ -59,16 +58,21 @@ export class GeometricSequence {
59
58
  this.reason = reason;
60
59
  }
61
60
  getLimit() {
62
- if (this.reason.value <= -1)
63
- return null;
64
- if (this.reason.value === 1)
65
- return this.firstTerm + "";
66
- if (this.reason.value > 1)
67
- return this.firstTerm.value > 0 ? "+\\infty" : "-\\infty";
68
- return "0";
61
+ if (!this.reason.isNumeric)
62
+ throw new Error("unimplemented geometric limit");
63
+ const reason = this.reason.evaluate();
64
+ if (reason <= -1)
65
+ throw new Error("no limit");
66
+ if (reason === 1)
67
+ return this.firstTerm;
68
+ if (reason > 1) {
69
+ const ev = this.firstTerm.evaluate();
70
+ return ev > 0 ? PlusInfinityNode : MinusInfinityNode;
71
+ }
72
+ return (0).toTree();
69
73
  }
70
74
  toTree() {
71
- return new MultiplyNode(this.firstTerm.toTree(), new PowerNode(this.reason.toTree(), new VariableNode("n")), {
75
+ return new MultiplyNode(this.firstTerm, new PowerNode(this.reason, new VariableNode("n")), {
72
76
  forceTimesSign: true,
73
77
  });
74
78
  }
package/lib/playground.js CHANGED
@@ -4,6 +4,6 @@ export const playground = () => {
4
4
  // const tex = "3\\%";
5
5
  // console.log(parseAlgebraic(tex).simplify({}).toTex());
6
6
  const x = multiply(3, substract("x", 9));
7
- console.log(x.simplify().toTex());
8
- console.log(x.equals(x.simplify()));
7
+ // console.log(x.simplify().toTex());
8
+ // console.log(x.equals(x.simplify()));
9
9
  };
@@ -29,7 +29,7 @@ export const questionTest = (exo, question) => {
29
29
  throw new Error(`exo ${exo.id} has hint or correction but not hasHintAndCorr`);
30
30
  }
31
31
  }
32
- if (!question.identifiers)
32
+ if (!question.identifiers || !Object.keys(question.identifiers).length)
33
33
  throw new Error(`exo ${exo.id} has no identifiers`);
34
34
  const dotDecimalPattern = /\d+\.\d+/;
35
35
  if (question.studentGgbOptions?.coords?.length) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.45",
4
+ "version": "3.0.46",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [