math-exercises 3.0.47 → 3.0.49

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 (65) hide show
  1. package/lib/exercises/math/calcul/addAndSub.d.ts +7 -1
  2. package/lib/exercises/math/calcul/addAndSub.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/addAndSub.js +26 -14
  4. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
  6. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
  7. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
  8. package/lib/exercises/math/functions/affines/affineExpressionReading.js +0 -1
  9. package/lib/exercises/math/functions/affines/index.d.ts +0 -1
  10. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  11. package/lib/exercises/math/functions/affines/index.js +0 -1
  12. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.d.ts +10 -0
  13. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.d.ts.map +1 -0
  14. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.js +171 -0
  15. package/lib/exercises/math/geometry/lines/findPointOnLineWithCartesianEquation.d.ts +9 -0
  16. package/lib/exercises/math/geometry/lines/findPointOnLineWithCartesianEquation.d.ts.map +1 -0
  17. package/lib/exercises/math/geometry/lines/findPointOnLineWithCartesianEquation.js +146 -0
  18. package/lib/exercises/math/geometry/lines/findPointOnLineWithReductEquation.d.ts +8 -0
  19. package/lib/exercises/math/geometry/lines/findPointOnLineWithReductEquation.d.ts.map +1 -0
  20. package/lib/exercises/math/geometry/lines/findPointOnLineWithReductEquation.js +99 -0
  21. package/lib/exercises/math/geometry/lines/index.d.ts +5 -0
  22. package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -1
  23. package/lib/exercises/math/geometry/lines/index.js +5 -0
  24. package/lib/exercises/math/geometry/lines/isPointOnCartesianLine.d.ts +13 -0
  25. package/lib/exercises/math/geometry/lines/isPointOnCartesianLine.d.ts.map +1 -0
  26. package/lib/exercises/math/geometry/lines/isPointOnCartesianLine.js +118 -0
  27. package/lib/exercises/math/geometry/lines/isPointOnLine.d.ts +11 -0
  28. package/lib/exercises/math/geometry/lines/isPointOnLine.d.ts.map +1 -0
  29. package/lib/exercises/math/geometry/lines/isPointOnLine.js +94 -0
  30. package/lib/exercises/math/geometry/triangles/triangleThirdAngleValue.d.ts.map +1 -1
  31. package/lib/exercises/math/geometry/triangles/triangleThirdAngleValue.js +16 -4
  32. package/lib/exercises/math/probaStat/probabilityTree.d.ts.map +1 -1
  33. package/lib/exercises/math/probaStat/stats1var/etendueList.d.ts.map +1 -1
  34. package/lib/exercises/math/probaStat/stats1var/etendueList.js +46 -14
  35. package/lib/exercises/math/trigonometry/trigonometry.d.ts.map +1 -1
  36. package/lib/exercises/math/trigonometry/trigonometry.js +49 -22
  37. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts.map +1 -1
  38. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +44 -22
  39. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts.map +1 -1
  40. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.js +6 -3
  41. package/lib/index.d.ts +28 -7
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/math/geometry/triangles/triangle.js +2 -2
  44. package/lib/math/sequences/geometricSequence.js +2 -2
  45. package/lib/playground.d.ts.map +1 -1
  46. package/lib/playground.js +0 -6
  47. package/lib/tree/nodes/algebraicNode.d.ts +0 -1
  48. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  49. package/lib/tree/nodes/node.d.ts +1 -0
  50. package/lib/tree/nodes/node.d.ts.map +1 -1
  51. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  52. package/lib/tree/nodes/numbers/numberNode.js +4 -1
  53. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  54. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  55. package/lib/tree/nodes/operators/fractionNode.js +14 -25
  56. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  57. package/lib/tree/nodes/operators/multiplyNode.js +7 -1
  58. package/lib/tree/nodes/operators/scalarProductNode.d.ts.map +1 -1
  59. package/lib/tree/nodes/polynomials/monomNode.js +1 -2
  60. package/lib/tree/parsers/pointParser.d.ts +3 -0
  61. package/lib/tree/parsers/pointParser.d.ts.map +1 -0
  62. package/lib/tree/parsers/pointParser.js +13 -0
  63. package/lib/tree/parsers/spacePointParser.d.ts.map +1 -1
  64. package/lib/tree/parsers/spacePointParser.js +2 -0
  65. package/package.json +1 -1
@@ -0,0 +1,118 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Point } from "../../../../math/geometry/point.js";
4
+ import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
12
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
13
+ import { randomLetter } from "../../../../utils/strings/randomLetter.js";
14
+ const getCartesianEquation = (identifiers) => {
15
+ const { a, b, c } = identifiers;
16
+ return add(add(multiply(a, "x"), multiply(b, "y")), c).simplify({
17
+ forbidFactorize: true,
18
+ });
19
+ };
20
+ const getPropositions = (n, { answer }) => {
21
+ const propositions = [];
22
+ addValidProp(propositions, answer, "raw");
23
+ tryToAddWrongProp(propositions, "Oui", "raw");
24
+ tryToAddWrongProp(propositions, "Non", "raw");
25
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
26
+ return shuffleProps(propositions, n);
27
+ };
28
+ const getAnswer = (identifiers) => {
29
+ return identifiers.isOnLine ? "Oui" : "Non";
30
+ };
31
+ const getInstruction = (identifiers) => {
32
+ const { x, y } = identifiers;
33
+ const point = new Point(randomLetter(true), reifyAlgebraic(x), reifyAlgebraic(y));
34
+ return `On considère la droite $d$ d'équation cartésienne :
35
+
36
+ $$
37
+ ${getCartesianEquation(identifiers).toTex()}=0
38
+ $$
39
+
40
+ Le point $${point.toTexWithCoords()}$ appartient-il à $d$ ?`;
41
+ };
42
+ const getHint = (identifiers) => {
43
+ return `Remplace $x$ et $y$ dans l'équation de la droite par les coordonnées du point. Le point appartient à la droite si et seulement si le résultat est égal à $0$.`;
44
+ };
45
+ const getCorrection = (identifiers) => {
46
+ const { x, y } = identifiers;
47
+ const xNode = reifyAlgebraic(x);
48
+ const yNode = reifyAlgebraic(y);
49
+ const equation = getCartesianEquation(identifiers);
50
+ const detailed = equation.toDetailedEvaluation({ x: xNode, y: yNode });
51
+ const simp = detailed.simplify();
52
+ return `On remplace $x$ et $y$ dans l'équation de la droite par les coordonnées du point :
53
+
54
+ ${alignTex([
55
+ ["", detailed.toTex()],
56
+ ["=", simp.toTex()],
57
+ ])}
58
+
59
+ ${identifiers.isOnLine
60
+ ? `On obtient bien $0$. Le point appartient donc bien à la droite.`
61
+ : `On n'obtient pas $0$. Le point n'appartient donc pas à la droite.`}
62
+ `;
63
+ };
64
+ const getKeys = (identifiers) => {
65
+ return [];
66
+ };
67
+ const isAnswerValid = (ans, { answer }) => {
68
+ throw Error("VEA not implemented");
69
+ };
70
+ const getIsPointOnLineQuestion = () => {
71
+ let a;
72
+ let b;
73
+ let c;
74
+ do {
75
+ a = randint(-9, 10);
76
+ b = randint(-9, 10, a === 0 ? [0] : undefined);
77
+ c = randint(-9, 10, (a === 1 && b === 0) || (a === 0 && b === 1) ? [0] : undefined);
78
+ } while (gcd(a, b, c) !== 1 || (a <= 0 && b <= 0 && c <= 0));
79
+ const isOnLine = coinFlip();
80
+ const x = b === 0 && isOnLine ? frac(-c, a).simplify() : randint(-10, 10).toTree();
81
+ const yOnLine = b === 0 ? (0).toTree() : frac(substract(-c, multiply(a, x)), b).simplify();
82
+ const y = isOnLine ? yOnLine : add(yOnLine, randint(-10, 10, [0])).simplify();
83
+ const identifiers = {
84
+ x: x.toIdentifiers(),
85
+ y: y.toIdentifiers(),
86
+ isOnLine,
87
+ a,
88
+ b,
89
+ c,
90
+ };
91
+ const question = {
92
+ answer: getAnswer(identifiers),
93
+ instruction: getInstruction(identifiers),
94
+ keys: getKeys(identifiers),
95
+ answerFormat: "raw",
96
+ identifiers,
97
+ hint: getHint(identifiers),
98
+ correction: getCorrection(identifiers),
99
+ };
100
+ return question;
101
+ };
102
+ export const isPointOnCartesianLine = {
103
+ id: "isPointOnCartesianLine",
104
+ connector: "=",
105
+ label: "Vérifier si un point appartient à une droite d'équation cartésienne donnée",
106
+ isSingleStep: true,
107
+ generator: (nb) => getDistinctQuestions(getIsPointOnLineQuestion, nb),
108
+ qcmTimer: 60,
109
+ freeTimer: 60,
110
+ getPropositions,
111
+ isAnswerValid,
112
+ subject: "Mathématiques",
113
+ getHint,
114
+ getCorrection,
115
+ getAnswer,
116
+ answerType: "QCU",
117
+ hasHintAndCorrection: true,
118
+ };
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ affineA: number;
4
+ affineB: number;
5
+ x: number;
6
+ y: number;
7
+ isOnLine: boolean;
8
+ };
9
+ export declare const isPointOnLine: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=isPointOnLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPointOnLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/lines/isPointOnLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAoFF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAgB/C,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Point } from "../../../../math/geometry/point.js";
4
+ import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
7
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
8
+ import { randomLetter } from "../../../../utils/strings/randomLetter.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer, "raw");
12
+ tryToAddWrongProp(propositions, "Oui", "raw");
13
+ tryToAddWrongProp(propositions, "Non", "raw");
14
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
15
+ return shuffleProps(propositions, n);
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ return identifiers.isOnLine ? "Oui" : "Non";
19
+ };
20
+ const getInstruction = (identifiers) => {
21
+ const point = new Point(randomLetter(true), identifiers.x.toTree(), identifiers.y.toTree());
22
+ const affine = new Affine(identifiers.affineA, identifiers.affineB);
23
+ return `Le point $${point.toTexWithCoords()}$ appartient-il à la droite d'équation $${affine.toReducedEquation()}$ ?`;
24
+ };
25
+ const getHint = (identifiers) => {
26
+ return `Remplace $x$ dans l'équation de la droite par l'abscisse du point. Le point appartient à la droite si et seulement si le résultat est égal à l'ordonnée du point.`;
27
+ };
28
+ const getCorrection = (identifiers) => {
29
+ const affine = new Affine(identifiers.affineA, identifiers.affineB);
30
+ const affineTree = affine.toTree();
31
+ const res = affine.calculate(identifiers.x).toTree().toTex();
32
+ return `On remplace $x$ dans l'équation de la droite par l'abscisse du point :
33
+
34
+ ${alignTex([
35
+ [
36
+ "y",
37
+ "=",
38
+ affineTree.toDetailedEvaluation({ x: identifiers.x.toTree() }).toTex(),
39
+ ],
40
+ ["", "=", res],
41
+ ])}
42
+
43
+ ${identifiers.isOnLine
44
+ ? `On obtient bien l'ordonnée du point. Ainsi, le point appartient bien à la droite.`
45
+ : `On n'obtient pas l'ordonnée du point. Ainsi, le point n'appartient pas à la droite.`}
46
+ `;
47
+ };
48
+ const getKeys = (identifiers) => {
49
+ return [];
50
+ };
51
+ const isAnswerValid = (ans, { answer }) => {
52
+ throw Error("VEA not implemented");
53
+ };
54
+ const getIsPointOnLineQuestion = () => {
55
+ const affine = AffineConstructor.random();
56
+ const x = randint(-10, 10);
57
+ const isOnLine = coinFlip();
58
+ const yOnLine = affine.calculate(x);
59
+ const y = isOnLine ? yOnLine : yOnLine + randint(-10, 10, [0]);
60
+ const identifiers = {
61
+ x,
62
+ y,
63
+ isOnLine,
64
+ affineA: affine.a,
65
+ affineB: affine.b,
66
+ };
67
+ const question = {
68
+ answer: getAnswer(identifiers),
69
+ instruction: getInstruction(identifiers),
70
+ keys: getKeys(identifiers),
71
+ answerFormat: "raw",
72
+ identifiers,
73
+ hint: getHint(identifiers),
74
+ correction: getCorrection(identifiers),
75
+ };
76
+ return question;
77
+ };
78
+ export const isPointOnLine = {
79
+ id: "isPointOnLine",
80
+ connector: "=",
81
+ label: "Vérifier si un point appartient à une droite d'équation $y=ax+b$",
82
+ isSingleStep: true,
83
+ generator: (nb) => getDistinctQuestions(getIsPointOnLineQuestion, nb),
84
+ qcmTimer: 60,
85
+ freeTimer: 60,
86
+ getPropositions,
87
+ isAnswerValid,
88
+ subject: "Mathématiques",
89
+ getHint,
90
+ getCorrection,
91
+ getAnswer,
92
+ answerType: "QCU",
93
+ hasHintAndCorrection: true,
94
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"triangleThirdAngleValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/triangles/triangleThirdAngleValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAGL,mBAAmB,EAEpB,MAAM,2CAA2C,CAAC;AAQnD,KAAK,WAAW,GAAG;IACjB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAkIF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAmBzD,CAAC"}
1
+ {"version":3,"file":"triangleThirdAngleValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/triangles/triangleThirdAngleValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAGL,mBAAmB,EAEpB,MAAM,2CAA2C,CAAC;AASnD,KAAK,WAAW,GAAG;IACjB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA8IF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAoBzD,CAAC"}
@@ -6,6 +6,7 @@ import { randint } from "../../../../math/utils/random/randint.js";
6
6
  import { round } from "../../../../math/utils/round.js";
7
7
  import { DegreeNode } from "../../../../tree/nodes/geometry/degree.js";
8
8
  import { add } from "../../../../tree/nodes/operators/addNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
9
10
  import { degreeParser } from "../../../../tree/parsers/degreeParser.js";
10
11
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
12
  const getPropositions = (n, { answer }) => {
@@ -20,7 +21,13 @@ const getPropositions = (n, { answer }) => {
20
21
  const getAnswer = (identifiers) => {
21
22
  const { triangleIdentifiers, angleAsked } = identifiers;
22
23
  const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
23
- return triangle.angles[angleAsked].getValueNode(true).toTex() + "^{\\circ}";
24
+ const angles = [
25
+ triangle.angles[(angleAsked + 1) % 3].getValueNode(true),
26
+ triangle.angles[(angleAsked + 2) % 3].getValueNode(true),
27
+ ];
28
+ const addAngles = add(angles[0], angles[1]);
29
+ const simp = addAngles.simplify();
30
+ return substract(180, simp).simplify().toTex() + "^{\\circ}";
24
31
  };
25
32
  const getInstruction = (identifiers) => {
26
33
  const { triangleIdentifiers, angleAsked } = identifiers;
@@ -66,7 +73,9 @@ $$`;
66
73
  const getGGBOptions = (identifiers) => {
67
74
  const { triangleIdentifiers, angleAsked } = identifiers;
68
75
  const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
69
- triangle.drawAngles([angleAsked], { fitCaption: true, color: "red" });
76
+ // triangle.drawAngles([angleAsked], { fitCaption: true, color: "black" });
77
+ triangle.drawAngles([angleAsked]);
78
+ triangle.highlightAngle(angleAsked, { color: "red" });
70
79
  const ggb = new GeogebraConstructor({
71
80
  commands: [...triangle.commands],
72
81
  hideAxes: true,
@@ -101,7 +110,10 @@ const getTriangleThirdAngleValueQuestion = (opts) => {
101
110
  triangleIdentifiers: triangle.toIdentifiers(),
102
111
  angleAsked: randint(0, 3),
103
112
  };
104
- const question = {
113
+ return getQuestionFromIdentifiers(identifiers);
114
+ };
115
+ const getQuestionFromIdentifiers = (identifiers) => {
116
+ return {
105
117
  answer: getAnswer(identifiers),
106
118
  instruction: getInstruction(identifiers),
107
119
  keys: getKeys(identifiers),
@@ -111,7 +123,6 @@ const getTriangleThirdAngleValueQuestion = (opts) => {
111
123
  correction: getCorrection(identifiers),
112
124
  ggbOptions: getGGBOptions(identifiers),
113
125
  };
114
- return question;
115
126
  };
116
127
  export const triangleThirdAngleValue = {
117
128
  id: "triangleThirdAngleValue",
@@ -131,4 +142,5 @@ export const triangleThirdAngleValue = {
131
142
  getGGBOptions,
132
143
  hasGeogebra: true,
133
144
  hasHintAndCorrection: true,
145
+ getQuestionFromIdentifiers,
134
146
  };
@@ -1 +1 @@
1
- {"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAa7C,OAAO,EACL,QAAQ,EAeT,MAAM,mBAAmB,CAAC;AAmC3B,KAAK,WAAW,GAAG;IAIjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4MF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA+CF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB1D,CAAC"}
1
+ {"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAa7C,OAAO,EACL,QAAQ,EAeT,MAAM,mBAAmB,CAAC;AAmC3B,KAAK,WAAW,GAAG;IAIjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4MF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA+CF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB1D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"etendueList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/etendueList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAmDF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAc7C,CAAC"}
1
+ {"version":3,"file":"etendueList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/etendueList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAgFF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAkB7C,CAAC"}
@@ -1,28 +1,50 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
5
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ const getInstruction = (identifiers) => {
7
+ const { sortedValues } = identifiers;
8
+ return `On considère la liste de valeurs suivante :
9
+
10
+ $$
11
+ ${sortedValues.join("\\ ;\\ ")}
12
+ $$
13
+
14
+ Calculer l'étendue de cette liste de valeurs.`;
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const { sortedValues } = identifiers;
18
+ const answer = (sortedValues[sortedValues.length - 1] - sortedValues[0]).frenchify();
19
+ return answer;
20
+ };
21
+ const getHint = (identifiers) => {
22
+ return "L'étendue d'une liste de valeurs est la différence entre la valeur maximale et la valeur minimale.";
23
+ };
24
+ const getCorrection = (identifiers) => {
25
+ const { sortedValues } = identifiers;
26
+ return `L'étendue est la différence entre la valeur maximale et la valeur minimale :
27
+
28
+ $$
29
+ ${sortedValues[sortedValues.length - 1]} - ${sortedValues[0]} = ${getAnswer(identifiers)}
30
+ $$
31
+ `;
32
+ };
4
33
  const getEtendueListQuestion = () => {
5
34
  let randomValues = [];
6
35
  const length = randint(6, 10);
7
36
  for (let i = 0; i < length; i++)
8
37
  randomValues.push(randint(1, 20));
9
38
  const sortedValues = randomValues.sort((a, b) => a - b);
10
- const answer = (sortedValues[sortedValues.length - 1] - sortedValues[0]).frenchify();
39
+ const identifiers = { sortedValues };
11
40
  const question = {
12
- answer,
13
- instruction: `On considère la liste suivante : $${randomValues.join(";\\ ")}.$
14
- $\\\\$Calculer l'étendue de cette liste de valeurs.`,
41
+ answer: getAnswer(identifiers),
42
+ instruction: getInstruction(identifiers),
15
43
  keys: [],
16
44
  answerFormat: "tex",
17
- identifiers: { sortedValues },
18
- hint: "L'étendue d'une liste de valeurs est la différence entre la valeur maximale et la valeur minimale.",
19
- correction: `
20
- On calcule la différence entre la valeur maximale et la valeur minimale :
21
-
22
- $$
23
- ${sortedValues[sortedValues.length - 1]} - ${sortedValues[0]} = ${answer}
24
- $$
25
- `,
45
+ identifiers,
46
+ hint: getHint(identifiers),
47
+ correction: getCorrection(identifiers),
26
48
  };
27
49
  return question;
28
50
  };
@@ -36,7 +58,13 @@ const getPropositions = (n, { answer, sortedValues }) => {
36
58
  return shuffleProps(propositions, n);
37
59
  };
38
60
  const isAnswerValid = (ans, { answer }) => {
39
- return ans === answer;
61
+ try {
62
+ const parsed = parseAlgebraic(ans);
63
+ return parsed.simplify().toTex() === answer;
64
+ }
65
+ catch (err) {
66
+ return handleVEAError(err);
67
+ }
40
68
  };
41
69
  export const etendueList = {
42
70
  id: "etendueList",
@@ -52,4 +80,8 @@ export const etendueList = {
52
80
  isAnswerValid,
53
81
  subject: "Mathématiques",
54
82
  hasHintAndCorrection: true,
83
+ getInstruction,
84
+ getAnswer,
85
+ getHint,
86
+ getCorrection,
55
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"trigonometry.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/trigonometry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AASnD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAsHF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAe9C,CAAC"}
1
+ {"version":3,"file":"trigonometry.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/trigonometry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AASnD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAyJF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAmB9C,CAAC"}
@@ -7,17 +7,18 @@ import { LengthNode } from "../../../tree/nodes/geometry/lengthNode.js";
7
7
  import { FractionNode } from "../../../tree/nodes/operators/fractionNode.js";
8
8
  import { random } from "../../../utils/alea/random.js";
9
9
  import { shuffle } from "../../../utils/alea/shuffle.js";
10
- const getTrigonometry = () => {
11
- const triangle = RightTriangleConstructor.randomNiceSides({
12
- randomName: true,
13
- });
10
+ const getInstruction = (identifiers) => {
11
+ const { randAngle, triangleIdentifiers, randTrigo } = identifiers;
12
+ const triangle = RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
14
13
  const trigo = ["le cosinus", "le sinus", "la tangente"];
15
- const randTrigo = randint(0, 3);
16
- const randAngle = random([1, 2]);
17
- triangle.highlightAngle(randAngle, { color: "red" });
18
- const [sideA, sideB, sideC] = triangle.sides.map((s) => s.toInsideName());
19
14
  const angleSummit = triangle.points[randAngle].name;
15
+ return `À quel quotient est égal ${trigo[randTrigo]} de l'angle $${triangle.angles[randAngle].toTex()}$ ?`;
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { randAngle, triangleIdentifiers, randTrigo } = identifiers;
19
+ const triangle = RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
20
20
  let quotient;
21
+ const [sideA, sideB, sideC] = triangle.sides.map((s) => s.toInsideName());
21
22
  switch (randAngle) {
22
23
  case 1: //angle B
23
24
  quotient = [
@@ -35,27 +36,49 @@ const getTrigonometry = () => {
35
36
  ];
36
37
  break;
37
38
  }
39
+ const answer = quotient[randTrigo];
40
+ return answer;
41
+ };
42
+ const getKeys = (identifiers) => {
43
+ const { randAngle, triangleIdentifiers, randTrigo } = identifiers;
44
+ const triangle = RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
45
+ return [...triangle.points.map((p) => p.name), "equal"];
46
+ };
47
+ const getGGBOptions = (identifiers) => {
48
+ const { randAngle, triangleIdentifiers, randTrigo } = identifiers;
49
+ const triangle = RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
50
+ triangle.highlightAngle(randAngle, { color: "red" });
38
51
  const ggb = new GeogebraConstructor({
39
52
  commands: triangle.commands,
40
53
  hideAxes: true,
41
54
  hideGrid: true,
42
55
  });
43
- const answer = quotient[randTrigo];
44
- const question = {
45
- instruction: `À quel quotient est égal ${trigo[randTrigo]} de l'angle $\\widehat{${angleSummit}}$ ?`,
46
- answer,
47
- keys: [...triangle.points.map((p) => p.name), "equal"],
48
- ggbOptions: ggb.getOptions({
49
- coords: triangle.generateCoords(),
50
- }),
56
+ return ggb.getOptions({
57
+ coords: triangle.generateCoords(),
58
+ });
59
+ };
60
+ const getTrigonometry = () => {
61
+ const triangle = RightTriangleConstructor.randomNiceSides({
62
+ randomName: true,
63
+ });
64
+ const randTrigo = randint(0, 3);
65
+ const randAngle = random([1, 2]);
66
+ const identifiers = {
67
+ triangleIdentifiers: triangle.toIdentifiers(),
68
+ randAngle,
69
+ randTrigo,
70
+ };
71
+ return getQuestionFromIdentifiers(identifiers);
72
+ };
73
+ const getQuestionFromIdentifiers = (identifiers) => {
74
+ return {
75
+ instruction: getInstruction(identifiers),
76
+ answer: getAnswer(identifiers),
77
+ keys: getKeys(identifiers),
78
+ ggbOptions: getGGBOptions(identifiers),
51
79
  answerFormat: "tex",
52
- identifiers: {
53
- triangleIdentifiers: triangle.toIdentifiers(),
54
- randAngle,
55
- randTrigo,
56
- },
80
+ identifiers,
57
81
  };
58
- return question;
59
82
  };
60
83
  const getPropositions = (n, { answer, triangleIdentifiers }) => {
61
84
  const propositions = [];
@@ -116,4 +139,8 @@ export const trigonometry = {
116
139
  isAnswerValid,
117
140
  hasGeogebra: true,
118
141
  subject: "Mathématiques",
142
+ getAnswer,
143
+ getInstruction,
144
+ getGGBOptions,
145
+ getQuestionFromIdentifiers,
119
146
  };
@@ -1 +1 @@
1
- {"version":3,"file":"trigonometryAngleCalcul.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/trigonometryAngleCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AAOnD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAyDF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAezD,CAAC"}
1
+ {"version":3,"file":"trigonometryAngleCalcul.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/trigonometryAngleCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AAOnD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AA+EF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAmBzD,CAAC"}
@@ -5,39 +5,57 @@ import { RightTriangleConstructor } from "../../../math/geometry/triangles/right
5
5
  import { randint } from "../../../math/utils/random/randint.js";
6
6
  import { round } from "../../../math/utils/round.js";
7
7
  import { shuffle } from "../../../utils/alea/shuffle.js";
8
- const getTrigonometryAngleCalcul = () => {
9
- const triangle = RightTriangleConstructor.randomNiceSides({
10
- randomName: true,
11
- });
12
- const randAngle = randint(1, 3);
13
- const hiddenSide = randint(0, 3);
8
+ const getInstruction = (identifiers) => {
9
+ const { randAngle, hiddenSide, triangleIdentifiers } = identifiers;
10
+ const triangle = RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
14
11
  const givenSides = triangle.sides.filter((s, i) => i !== hiddenSide);
12
+ return `Le triangle $${triangle.name}$ rectangle en $${triangle.points[0].name}$ est tel que $${givenSides[0].toLengthTex()}$ cm et $${givenSides[1].toLengthTex()}$ cm.
13
+
14
+ Calculer $\\widehat{${triangle.points[randAngle].name}}$ à $1^\\circ$ près.`;
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const { randAngle, hiddenSide, triangleIdentifiers } = identifiers;
18
+ const triangle = RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
19
+ const answer = round(triangle.angles[randAngle].evaluate(), 0);
20
+ return answer + "^{\\circ}";
21
+ };
22
+ const getGGBOptions = (identifiers) => {
23
+ const { randAngle, hiddenSide, triangleIdentifiers } = identifiers;
24
+ const triangle = RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
15
25
  triangle.showSidesLength([hiddenSide]);
16
26
  triangle.highlightAngle(randAngle, { color: "red" });
17
- const answer = round(triangle.angles[randAngle].evaluate(), 0);
18
- const answerTex = answer + "^{\\circ}";
19
27
  const ggb = new GeogebraConstructor({
20
28
  commands: triangle.commands,
21
29
  hideAxes: true,
22
30
  hideGrid: true,
23
31
  });
24
- const question = {
25
- instruction: `Le triangle $${triangle.name}$ rectangle en $${triangle.points[0].name}$ est tel que $${givenSides[0].toLengthTex()}$ cm et $${givenSides[1].toLengthTex()}$ cm.
26
-
27
- Calculer $\\widehat{${triangle.points[randAngle].name}}$ à $1^\\circ$ près.`,
28
- answer: answerTex,
32
+ return ggb.getOptions({
33
+ coords: triangle.generateCoords(),
34
+ });
35
+ };
36
+ const getTrigonometryAngleCalcul = () => {
37
+ const triangle = RightTriangleConstructor.randomNiceSides({
38
+ randomName: true,
39
+ });
40
+ const randAngle = randint(1, 3);
41
+ const hiddenSide = randint(0, 3);
42
+ const identifiers = {
43
+ randAngle,
44
+ hiddenSide,
45
+ triangleIdentifiers: triangle.toIdentifiers(),
46
+ };
47
+ const question = getQuestionFromIdentifiers(identifiers);
48
+ return question;
49
+ };
50
+ const getQuestionFromIdentifiers = (identifiers) => {
51
+ return {
52
+ instruction: getInstruction(identifiers),
53
+ answer: getAnswer(identifiers),
29
54
  keys: ["degree"],
30
- ggbOptions: ggb.getOptions({
31
- coords: triangle.generateCoords(),
32
- }),
55
+ ggbOptions: getGGBOptions(identifiers),
33
56
  answerFormat: "tex",
34
- identifiers: {
35
- randAngle,
36
- hiddenSide,
37
- triangleIdentifiers: triangle.toIdentifiers(),
38
- },
57
+ identifiers,
39
58
  };
40
- return question;
41
59
  };
42
60
  const getPropositions = (n, { answer }) => {
43
61
  const propositions = [];
@@ -64,4 +82,8 @@ export const trigonometryAngleCalcul = {
64
82
  isAnswerValid,
65
83
  hasGeogebra: true,
66
84
  subject: "Mathématiques",
85
+ getAnswer,
86
+ getInstruction,
87
+ getGGBOptions,
88
+ getQuestionFromIdentifiers,
67
89
  };
@@ -1 +1 @@
1
- {"version":3,"file":"trigonometrySideCalcul.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/trigonometrySideCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AAMnD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AA8OF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAmBxD,CAAC"}
1
+ {"version":3,"file":"trigonometrySideCalcul.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/trigonometrySideCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AAMnD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAiPF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAoBxD,CAAC"}
@@ -12,7 +12,7 @@ const getInstruction = (identifiers) => {
12
12
  const { givenAngle, givenSide, sideAsked, triangleIdentifiers } = identifiers;
13
13
  const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
14
14
  const angleValue = triangle.angles[givenAngle].evaluate().frenchify();
15
- return `Le triangle $${triangle.name}$ rectangle en $${triangle.points[0].name}$ est tel que $${triangle.sides[givenSide].toLengthTex()}$ cm et $\\widehat{${triangle.points[givenAngle].name}} = ${angleValue}^\\circ$.
15
+ return `Le triangle $${triangle.name}$ rectangle en $${triangle.points[0].name}$ est tel que $${triangle.sides[givenSide].toLengthTex()}$ cm et $${triangle.angles[givenAngle].toTex()} = ${angleValue}^\\circ$.
16
16
 
17
17
  Calculer $${triangle.sides[sideAsked].toInsideName()}$ à $0,1$ cm près.`;
18
18
  };
@@ -51,7 +51,10 @@ const getTrigonometrySideCalcul = () => {
51
51
  sideAsked,
52
52
  triangleIdentifiers: triangle.toIdentifiers(),
53
53
  };
54
- const question = {
54
+ return getQuestionFromIdentifiers(identifiers);
55
+ };
56
+ const getQuestionFromIdentifiers = (identifiers) => {
57
+ return {
55
58
  instruction: getInstruction(identifiers),
56
59
  answer: getAnswer(identifiers),
57
60
  hint: getHint(identifiers),
@@ -61,7 +64,6 @@ const getTrigonometrySideCalcul = () => {
61
64
  answerFormat: "tex",
62
65
  identifiers,
63
66
  };
64
- return question;
65
67
  };
66
68
  const getPropositions = (n, { answer }) => {
67
69
  const propositions = [];
@@ -223,4 +225,5 @@ export const trigonometrySideCalcul = {
223
225
  getGGBOptions,
224
226
  getCorrection,
225
227
  hasHintAndCorrection: true,
228
+ getQuestionFromIdentifiers,
226
229
  };