math-exercises 3.0.45 → 3.0.47

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 (52) 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 +156 -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/quadrilaterals/index.d.ts +1 -0
  17. package/lib/exercises/math/geometry/quadrilaterals/index.d.ts.map +1 -1
  18. package/lib/exercises/math/geometry/quadrilaterals/index.js +1 -0
  19. package/lib/exercises/math/geometry/quadrilaterals/parallelogramAngles.d.ts +10 -0
  20. package/lib/exercises/math/geometry/quadrilaterals/parallelogramAngles.d.ts.map +1 -0
  21. package/lib/exercises/math/geometry/quadrilaterals/parallelogramAngles.js +128 -0
  22. package/lib/exercises/math/geometry/vectors/vectorLinearCombination.js +1 -1
  23. package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts +3 -2
  24. package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
  25. package/lib/exercises/math/limits/sequenceGeometricLimit.js +28 -16
  26. package/lib/exercises/math/percent/valuePercent.d.ts.map +1 -1
  27. package/lib/exercises/math/percent/valuePercent.js +30 -12
  28. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.d.ts +8 -1
  29. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.d.ts.map +1 -1
  30. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.js +60 -26
  31. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts +10 -1
  32. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts.map +1 -1
  33. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.js +34 -19
  34. package/lib/exercises/pc/mole/concentrationReading.js +1 -1
  35. package/lib/index.d.ts +27 -3
  36. package/lib/index.d.ts.map +1 -1
  37. package/lib/math/geometry/angle.d.ts.map +1 -1
  38. package/lib/math/geometry/angle.js +2 -1
  39. package/lib/math/geometry/quadrilaterals/parallelogram.d.ts.map +1 -1
  40. package/lib/math/geometry/quadrilaterals/parallelogram.js +3 -1
  41. package/lib/math/geometry/quadrilaterals/quadrilateral.d.ts +6 -0
  42. package/lib/math/geometry/quadrilaterals/quadrilateral.d.ts.map +1 -1
  43. package/lib/math/geometry/quadrilaterals/quadrilateral.js +11 -0
  44. package/lib/math/geometry/spaceVector.d.ts +1 -1
  45. package/lib/math/geometry/spaceVector.d.ts.map +1 -1
  46. package/lib/math/geometry/spaceVector.js +2 -2
  47. package/lib/math/sequences/geometricSequence.d.ts +7 -5
  48. package/lib/math/sequences/geometricSequence.d.ts.map +1 -1
  49. package/lib/math/sequences/geometricSequence.js +24 -20
  50. package/lib/playground.js +2 -2
  51. package/lib/tests/questionTest.js +1 -1
  52. 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;AAsHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAgBjD,CAAC;;AAgFF,oBAAoB;AACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG"}
@@ -1,107 +1,93 @@
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}, 50), 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 / 400,
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: [-0.2, 5.2, -300, 1100],
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, i < 3 ? 18 : 20, //pour ne pas que les 2 premieres barres touchent le label de l'axe
84
+ data.map((d) => d / 50)));
85
+ }
86
+ const itemAsked = randint(0, 5);
103
87
  const identifiers = {
104
- a: Math.random(),
88
+ labels,
89
+ data,
90
+ itemAsked,
105
91
  };
106
92
  const question = {
107
93
  answer: getAnswer(identifiers),
@@ -109,14 +95,15 @@ const getBarChartReadingQuestion = (ops) => {
109
95
  keys: getKeys(identifiers),
110
96
  answerFormat: "tex",
111
97
  identifiers,
112
- hint: getHint(identifiers),
113
- correction: getCorrection(identifiers),
98
+ // hint: getHint(identifiers),
99
+ // correction: getCorrection(identifiers),
100
+ ggbOptions: getGGBOptions(identifiers),
114
101
  };
115
102
  return question;
116
103
  };
117
104
  export const barChartReading = {
118
105
  id: "barChartReading",
119
- label: "",
106
+ label: "Lecture d'un diagramme en bâtons",
120
107
  isSingleStep: true,
121
108
  generator: (nb, opts) => getDistinctQuestions(() => getBarChartReadingQuestion(opts), nb),
122
109
  qcmTimer: 60,
@@ -125,9 +112,10 @@ export const barChartReading = {
125
112
  isAnswerValid,
126
113
  subject: "Mathématiques",
127
114
  getInstruction,
128
- getHint,
129
- getCorrection,
115
+ // getHint,
116
+ // getCorrection,
130
117
  getAnswer,
118
+ hasGeogebra: true,
131
119
  };
132
120
  // !signtable
133
121
  // const options = { svg: true };
@@ -196,3 +184,88 @@ export const barChartReading = {
196
184
  // text,
197
185
  // ),
198
186
  // );
187
+ /***Final version */
188
+ /**
189
+ *
190
+ * const newspapers = [
191
+ { name: "Le Figaro", sales: 320000 },
192
+ { name: "Les Échos", sales: 130000 },
193
+ { name: "La Croix", sales: 90000 },
194
+ { name: "L'Équipe", sales: 210000 },
195
+ { name: "Le Monde", sales: 330000 },
196
+ { name: "Le Parisien", sales: 270000 },
197
+ { name: "Libération", sales: 70000 },
198
+ { name: "L'Humanité", sales: 30000 },
199
+ ];
200
+
201
+ const width = 600,
202
+ height = 400,
203
+ margin = { top: 20, right: 30, bottom: 100, left: 60 };
204
+ const d3n = new D3Node();
205
+ const d3 = d3n.d3;
206
+
207
+ const svg = d3n.createSVG(width, height);
208
+
209
+ const xScale = d3
210
+ .scaleBand()
211
+ .domain(newspapers.map((d) => d.name))
212
+ .range([margin.left, width - margin.right])
213
+ .padding(0.1);
214
+
215
+ const yScale = d3
216
+ .scaleLinear()
217
+ .domain([0, d3.max(newspapers, (d: any) => d.sales)])
218
+ .nice()
219
+ .range([height - margin.bottom, margin.top]);
220
+
221
+ svg
222
+ .append("g")
223
+ .attr("transform", `translate(0,${height - margin.bottom})`)
224
+ .call(d3.axisBottom(xScale).tickSize(0))
225
+ .selectAll("text")
226
+ .style("text-anchor", "end")
227
+ .attr("transform", "rotate(-30)");
228
+
229
+ svg
230
+ .append("g")
231
+ .attr("transform", `translate(${margin.left},0)`)
232
+ .call(
233
+ d3
234
+ .axisLeft(yScale)
235
+ .ticks(5)
236
+ .tickFormat((d: any) =>
237
+ d.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "),
238
+ ),
239
+ );
240
+
241
+ svg
242
+ .append("text")
243
+ .attr("x", margin.left)
244
+ .attr("y", margin.top)
245
+ .attr("text-anchor", "start")
246
+ .style("font-size", "14px")
247
+ .style("font-weight", "bold")
248
+ .text("Nombre d’exemplaires vendus");
249
+
250
+ svg
251
+ .selectAll(".bar")
252
+ .data(newspapers)
253
+ .enter()
254
+ .append("rect")
255
+ .attr("class", "bar")
256
+ .attr("x", (d: any) => xScale(d.name))
257
+ .attr("y", (d: any) => yScale(d.sales))
258
+ .attr("width", xScale.bandwidth())
259
+ .attr("height", (d: any) => height - margin.bottom - yScale(d.sales))
260
+ .attr("fill", "steelblue");
261
+
262
+ const svgString = d3n.svgString();
263
+ return `BBteeeezfst :
264
+
265
+ ofzie
266
+ should read this
267
+ ${svgString}
268
+ should read this
269
+ zef
270
+ `;
271
+ */
@@ -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";
@@ -1,2 +1,3 @@
1
1
  export * from "./quadrilateralRecognition.js";
2
+ export * from "./parallelogramAngles.js";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/quadrilaterals/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/quadrilaterals/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from "./quadrilateralRecognition.js";
2
+ export * from "./parallelogramAngles.js";
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { ParallelogramIdentifiers } from "../../../../math/geometry/quadrilaterals/parallelogram.js";
3
+ type Identifiers = {
4
+ paraIdentifiers: ParallelogramIdentifiers;
5
+ givenAngleIndex: number;
6
+ askedAngleIndex: number;
7
+ };
8
+ export declare const parallelogramAngles: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=parallelogramAngles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parallelogramAngles.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/quadrilaterals/parallelogramAngles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAEL,wBAAwB,EACzB,MAAM,qDAAqD,CAAC;AAO7D,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,wBAAwB,CAAC;IAC1C,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAuIF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAmBrD,CAAC"}