math-exercises 3.0.31 → 3.0.32

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 (56) hide show
  1. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
  2. package/lib/exercises/math/functions/sign/affineProductSign.d.ts.map +1 -1
  3. package/lib/exercises/math/functions/sign/affineProductSign.js +3 -0
  4. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts.map +1 -1
  5. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.js +64 -72
  6. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.d.ts.map +1 -1
  7. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.js +1 -1
  8. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.d.ts.map +1 -1
  9. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.js +31 -14
  10. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
  11. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +1 -2
  12. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts.map +1 -1
  13. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.js +3 -0
  14. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.d.ts.map +1 -1
  15. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.js +3 -0
  16. package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
  17. package/lib/exercises/math/geometry/cartesian/midpoint.js +19 -6
  18. package/lib/exercises/math/geometry/cartesian/pointCoordinates.d.ts.map +1 -1
  19. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoAxisNumbers.d.ts.map +1 -1
  20. package/lib/exercises/math/geometry/cartesian/pointCoordinatesNoOrthonorm.d.ts.map +1 -1
  21. package/lib/exercises/math/probaStat/ballsBasicProbas.d.ts.map +1 -1
  22. package/lib/exercises/math/probaStat/ballsBasicProbas.js +29 -16
  23. package/lib/exercises/math/probaStat/cardBasicProbas.d.ts.map +1 -1
  24. package/lib/exercises/math/probaStat/cardBasicProbas.js +44 -32
  25. package/lib/exercises/math/probaStat/stats1var/median.js +2 -2
  26. package/lib/exercises/math/probaStat/stats1var/medianList.d.ts.map +1 -1
  27. package/lib/exercises/math/probaStat/stats1var/medianList.js +28 -12
  28. package/lib/math/geometry/vector.d.ts.map +1 -1
  29. package/lib/math/geometry/vector.js +0 -11
  30. package/lib/math/polynomials/trinom.d.ts +1 -1
  31. package/lib/math/polynomials/trinom.d.ts.map +1 -1
  32. package/lib/math/polynomials/trinom.js +7 -17
  33. package/lib/tree/nodes/complex/complexNode.d.ts +9 -3
  34. package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
  35. package/lib/tree/nodes/complex/complexNode.js +18 -1
  36. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  37. package/lib/tree/nodes/node.d.ts +2 -1
  38. package/lib/tree/nodes/node.d.ts.map +1 -1
  39. package/lib/tree/nodes/node.js +1 -0
  40. package/lib/tree/nodes/sets/belongsNode.d.ts +0 -1
  41. package/lib/tree/nodes/sets/belongsNode.d.ts.map +1 -1
  42. package/lib/tree/nodes/sets/belongsNode.js +0 -3
  43. package/lib/tree/nodes/sets/discreteSetNode.d.ts +8 -2
  44. package/lib/tree/nodes/sets/discreteSetNode.d.ts.map +1 -1
  45. package/lib/tree/nodes/sets/discreteSetNode.js +20 -2
  46. package/lib/tree/nodes/sets/intervalNode.d.ts +6 -2
  47. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  48. package/lib/tree/nodes/sets/intervalNode.js +15 -1
  49. package/lib/tree/nodes/sets/setNode.d.ts +3 -1
  50. package/lib/tree/nodes/sets/setNode.d.ts.map +1 -1
  51. package/lib/tree/nodes/sets/unionIntervalNode.d.ts +8 -2
  52. package/lib/tree/nodes/sets/unionIntervalNode.d.ts.map +1 -1
  53. package/lib/tree/nodes/sets/unionIntervalNode.js +16 -0
  54. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
  55. package/lib/tree/parsers/discreteSetParser.js +0 -2
  56. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IAEjB,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB,CAAC;AAmNF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAoB9D,CAAC"}
1
+ {"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IAEjB,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB,CAAC;AAmNF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAoB9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"affineProductSign.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/affineProductSign.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,wBAAwB,EACzB,MAAM,yCAAyC,CAAC;AAejD,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,wBAAwB,CAAC;IACrC,UAAU,EAAE,wBAAwB,CAAC;IACrC,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AA8IF,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAaF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
1
+ {"version":3,"file":"affineProductSign.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/affineProductSign.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,wBAAwB,EACzB,MAAM,yCAAyC,CAAC;AAejD,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,wBAAwB,CAAC;IACrC,UAAU,EAAE,wBAAwB,CAAC;IACrC,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AA8IF,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAaF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoB5D,CAAC"}
@@ -142,4 +142,7 @@ export const affineProductSign = {
142
142
  // getCorrection,
143
143
  getAnswer,
144
144
  options,
145
+ pdfOptions: {
146
+ shouldSpreadPropositions: true,
147
+ },
145
148
  };
@@ -1 +1 @@
1
- {"version":3,"file":"solveSecondDegreeEquationByFactorisation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAgIF,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAAC,WAAW,CAiB1E,CAAC"}
1
+ {"version":3,"file":"solveSecondDegreeEquationByFactorisation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAiHF,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAAC,WAAW,CAiB1E,CAAC"}
@@ -1,12 +1,15 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { equationKeys } from "../../../../../exercises/utils/keys/equationKeys.js";
4
- import { Rational } from "../../../../../math/numbers/rationals/rational.js";
5
4
  import { Trinom } from "../../../../../math/polynomials/trinom.js";
6
5
  import { randint } from "../../../../../math/utils/random/randint.js";
6
+ import { equal } from "../../../../../tree/nodes/equations/equalNode.js";
7
7
  import { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
8
- import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
8
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
9
+ import { DiscreteSetNode, set } from "../../../../../tree/nodes/sets/discreteSetNode.js";
10
+ import { discreteSetParser } from "../../../../../tree/parsers/discreteSetParser.js";
9
11
  import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
12
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
10
13
  /**
11
14
  * Equation donnée sous forme ax^2 + bx ou bien forme développée d'une identité remarquable
12
15
  * type 1 ax^2 + bx
@@ -14,61 +17,69 @@ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
14
17
  * type 3 (ax-b)^2
15
18
  * type 4 (ax+b)(ax-b)
16
19
  */
17
- const getSolveSecondDegreeEquationByFactorisationQuestion = () => {
18
- const type = randint(1, 4);
19
- let statement = "";
20
- let roots = [];
21
- let answer = "";
22
- let a;
23
- let b;
20
+ const getStatementNode = (identifiers) => {
21
+ const { a, b, type } = identifiers;
22
+ let statement;
23
+ switch (type) {
24
+ case 1:
25
+ //ax^2 + bx
26
+ const trinom = new Trinom(a, b, 0);
27
+ return trinom.toTex();
28
+ case 2:
29
+ //(ax+b)^2
30
+ return new Trinom(a ** 2, 2 * a * b, b ** 2).toTex();
31
+ case 3:
32
+ //(ax-b)^2
33
+ return new Trinom(a ** 2, -2 * a * b, b ** 2).toTex();
34
+ case 4:
35
+ default:
36
+ //(ax+b)(ax-b)
37
+ return new Trinom(a ** 2, 0, -(b ** 2)).toTex();
38
+ }
39
+ };
40
+ const getInstruction = (identifiers) => {
41
+ const instruction = `Soit $f$ la fonction définie par :
42
+
43
+ $$
44
+ f(x) = ${getStatementNode(identifiers)}
45
+ $$
46
+
47
+ Factoriser $f(x)$, puis résoudre l'équation $f(x) = 0$.`;
48
+ return instruction;
49
+ };
50
+ const getAnswer = (identifiers) => {
51
+ const { a, b, type } = identifiers;
52
+ let roots;
24
53
  switch (type) {
25
54
  case 1:
26
- {
27
- //ax^2 + bx
28
- const trinom = new Trinom(randint(-9, 10, [0]), randint(-9, 10), 0);
29
- a = trinom.a;
30
- b = trinom.b;
31
- statement = trinom.toTex();
32
- roots = trinom.getRootsNode();
33
- }
55
+ roots = set([(0).toTree(), frac(-b, a)]).simplify();
34
56
  break;
35
57
  case 2:
36
- {
37
- //(ax+b)^2
38
- a = randint(-9, 10, [0]);
39
- b = randint(1, 10);
40
- statement = new Trinom(a ** 2, 2 * a * b, b ** 2).toTex();
41
- roots = [new Rational(-b, a).simplify().toTree()];
42
- }
58
+ roots = set([frac(-b, a).simplify()]);
43
59
  break;
44
60
  case 3:
45
- {
46
- //(ax-b)^2
47
- a = randint(-9, 10, [0]);
48
- b = randint(-9, 0, [0]);
49
- statement = new Trinom(a ** 2, -2 * a * b, b ** 2).toTex();
50
- roots = [new Rational(b, a).simplify().toTree()];
51
- }
61
+ roots = set([frac(b, a)]).simplify();
52
62
  break;
53
63
  case 4:
54
64
  default:
55
- {
56
- //(ax+b)(ax-b)
57
- a = randint(-9, 10, [0]);
58
- b = randint(1, 10);
59
- statement = new Trinom(a ** 2, 0, -(b ** 2)).toTex();
60
- roots = [b, -b].sort((a, b) => a - b).map((x) => x.toTree());
61
- }
65
+ roots = set([frac(-b, a), frac(b, a)]).simplify();
62
66
  break;
63
67
  }
64
- const instruction = `Soit $f(x) = ${statement}$. Factoriser $f(x)$, puis résoudre l'équation $f(x) = 0$.`;
65
- answer = new EquationSolutionNode(new DiscreteSetNode(roots)).toTex();
68
+ return equal("S", roots).toTex();
69
+ };
70
+ const getSolveSecondDegreeEquationByFactorisationQuestion = () => {
71
+ const type = randint(1, 4);
72
+ let a;
73
+ let b;
74
+ a = randint(-9, 10, [0]);
75
+ b = randint([2, 4].includes(type) ? 1 : -9, 10, [0]);
76
+ const identifiers = { a, b, type };
66
77
  const question = {
67
- answer,
68
- instruction,
78
+ answer: getAnswer(identifiers),
79
+ instruction: getInstruction(identifiers),
69
80
  keys: [...equationKeys],
70
81
  answerFormat: "tex",
71
- identifiers: { a, b, type },
82
+ identifiers,
72
83
  };
73
84
  return question;
74
85
  };
@@ -86,46 +97,27 @@ const getPropositions = (n, { answer }) => {
86
97
  return shuffleProps(propositions, n);
87
98
  };
88
99
  const isAnswerValid = (ans, { answer, type, a, b }) => {
89
- let roots = [];
90
- switch (type) {
91
- case 1:
92
- {
93
- const trinom = new Trinom(a, b, 0);
94
- roots = trinom.getRootsNode();
95
- }
96
- break;
97
- case 2:
98
- {
99
- roots = [new Rational(-b, a).simplify().toTree()];
100
- }
101
- break;
102
- case 3:
103
- {
104
- roots = [new Rational(b, a).simplify().toTree()];
105
- }
106
- break;
107
- case 4:
108
- {
109
- roots = [b, -b].sort((a, b) => a - b).map((x) => x.toTree());
110
- }
111
- break;
100
+ try {
101
+ const parsed = discreteSetParser(ans);
102
+ if (!parsed)
103
+ return false;
104
+ return ("S=" + parsed.simplify({ decimalToFractions: true }).toTex() === answer);
105
+ }
106
+ catch (err) {
107
+ return handleVEAError(err);
112
108
  }
113
- const answerTree = new EquationSolutionNode(new DiscreteSetNode(roots), {
114
- opts: { allowFractionToDecimal: true, allowRawRightChildAsSolution: true },
115
- });
116
- return answerTree.toAllValidTexs().includes(ans);
117
109
  };
118
110
  export const solveSecondDegreeEquationByFactorisation = {
119
111
  id: "solveSecondDegreeEquationByFactorisation",
120
112
  connector: "\\iff",
121
113
  label: "Résoudre une équation du second degré par factorisation",
122
- levels: [],
123
114
  isSingleStep: true,
124
- sections: [],
125
115
  generator: (nb) => getDistinctQuestions(getSolveSecondDegreeEquationByFactorisationQuestion, nb),
126
116
  qcmTimer: 60,
127
117
  freeTimer: 60,
128
118
  getPropositions,
129
119
  isAnswerValid,
130
120
  subject: "Mathématiques",
121
+ getAnswer,
122
+ getInstruction,
131
123
  };
@@ -1 +1 @@
1
- {"version":3,"file":"paraboleExpressionReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CAIpB,CAAC;AAoSF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAmB3D,CAAC"}
1
+ {"version":3,"file":"paraboleExpressionReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CAIpB,CAAC;AAuSF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAmB3D,CAAC"}
@@ -29,7 +29,7 @@ const getPropositions = (n, { answer, ...identifiers }) => {
29
29
  let x2 = randint(-8, 9, [0]);
30
30
  if (x1 > x2)
31
31
  [x1, x2] = [x2, x1];
32
- tryToAddWrongProp(propositions, multiply(randint(-5, 6, [0]), multiply(substract("x", x1), substract("x", x2))).toTex());
32
+ tryToAddWrongProp(propositions, multiply(randint(-5, 6, [0]), multiply(substract("x", x1).simplify(), substract("x", x2).simplify())).toTex());
33
33
  break;
34
34
  }
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rootsFromFactorizedForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+EF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
1
+ {"version":3,"file":"rootsFromFactorizedForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6FF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAgBzD,CAAC"}
@@ -2,22 +2,33 @@ import { addValidProp, tryToAddWrongProp, } from "../../../../../exercises/exerc
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
4
  import { randint } from "../../../../../math/utils/random/randint.js";
5
- import { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
6
5
  import { OppositeNode } from "../../../../../tree/nodes/functions/oppositeNode.js";
7
6
  import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
8
- import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
7
+ import { discreteSetParser } from "../../../../../tree/parsers/discreteSetParser.js";
9
8
  import { shuffle } from "../../../../../utils/alea/shuffle.js";
9
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
10
+ const getInstruction = (identifiers) => {
11
+ const { a, b, c } = identifiers;
12
+ const trinom = new Trinom(a, b, c);
13
+ return `Soit $f(x) = ${trinom
14
+ .toFactorized()
15
+ .toTex()}$. Résoudre l'équation $f(x) = 0$.`;
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { a, b, c } = identifiers;
19
+ const trinom = new Trinom(a, b, c);
20
+ const answer = trinom.getRootsEquationSolutionTex();
21
+ return answer;
22
+ };
10
23
  const getRootsFromFactorizedFormQuestion = () => {
11
24
  const trinom = TrinomConstructor.randomFactorized();
12
- const answer = trinom.getRootsEquationSolutionTex();
25
+ const identifiers = { a: trinom.a, b: trinom.b, c: trinom.c };
13
26
  const question = {
14
- answer: answer,
15
- instruction: `Soit $f(x) = ${trinom
16
- .getFactorizedForm()
17
- .toTex()}$. Résoudre l'équation $f(x) = 0$.`,
27
+ answer: getAnswer(identifiers),
28
+ instruction: getInstruction(identifiers),
18
29
  keys: ["S", "equal", "lbrace", "semicolon", "rbrace", "varnothing"],
19
30
  answerFormat: "tex",
20
- identifiers: { a: trinom.a, b: trinom.b, c: trinom.c },
31
+ identifiers,
21
32
  };
22
33
  return question;
23
34
  };
@@ -44,12 +55,16 @@ const getPropositions = (n, { answer, a, b, c }) => {
44
55
  }
45
56
  return shuffle(propositions);
46
57
  };
47
- const isAnswerValid = (ans, { a, b, c }) => {
48
- const trinom = new Trinom(a, b, c);
49
- const roots = trinom.getRootsNode();
50
- const answer = new EquationSolutionNode(new DiscreteSetNode(roots));
51
- const texs = answer.toAllValidTexs();
52
- return texs.includes(ans);
58
+ const isAnswerValid = (ans, { answer, a, b, c }) => {
59
+ try {
60
+ const parsed = discreteSetParser(ans);
61
+ if (!parsed)
62
+ return false;
63
+ return ("S=" + parsed.simplify({ decimalToFractions: true }).toTex() === answer);
64
+ }
65
+ catch (err) {
66
+ return handleVEAError(err);
67
+ }
53
68
  };
54
69
  export const rootsFromFactorizedForm = {
55
70
  id: "rootsFromFactorizedForm",
@@ -64,4 +79,6 @@ export const rootsFromFactorizedForm = {
64
79
  getPropositions,
65
80
  isAnswerValid,
66
81
  subject: "Mathématiques",
82
+ getInstruction,
83
+ getAnswer,
67
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAgB9C,CAAC"}
1
+ {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAc9C,CAAC"}
@@ -54,6 +54,7 @@ const getPropositions = (n, { answer }) => {
54
54
  const isAnswerValid = (ans, { answer, a, b, c }) => {
55
55
  const roots = new Trinom(a, b, c).getRoots();
56
56
  const studentNumbers = ans
57
+ .replaceAll("\\text{ }", "")
57
58
  .split("\\text{ et }")
58
59
  .map((n) => Number(n.replace(",", ".")))
59
60
  .filter((n) => !isNaN(n))
@@ -64,9 +65,7 @@ const isAnswerValid = (ans, { answer, a, b, c }) => {
64
65
  export const rootsReading = {
65
66
  id: "rootsReading",
66
67
  label: "Lire graphiquement les racines d'un trinôme",
67
- levels: ["1reSpé", "1rePro"],
68
68
  isSingleStep: true,
69
- sections: ["Second degré"],
70
69
  generator: (nb) => getDistinctQuestions(getRootsReadingQuestion, nb),
71
70
  qcmTimer: 60,
72
71
  freeTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"trinomSignFromFacto.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignFromFacto.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAwHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAiBrD,CAAC"}
1
+ {"version":3,"file":"trinomSignFromFacto.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignFromFacto.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAwHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAoBrD,CAAC"}
@@ -117,4 +117,7 @@ export const trinomSignFromFacto = {
117
117
  getAnswer,
118
118
  hasHintAndCorrection: true,
119
119
  getInstruction,
120
+ pdfOptions: {
121
+ shouldSpreadPropositions: true,
122
+ },
120
123
  };
@@ -1 +1 @@
1
- {"version":3,"file":"trinomSignFromRoots.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignFromRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAuHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAiBrD,CAAC"}
1
+ {"version":3,"file":"trinomSignFromRoots.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignFromRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAuHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAoBrD,CAAC"}
@@ -116,4 +116,7 @@ export const trinomSignFromRoots = {
116
116
  getAnswer,
117
117
  hasHintAndCorrection: true,
118
118
  getInstruction,
119
+ pdfOptions: {
120
+ shouldSpreadPropositions: true,
121
+ },
119
122
  };
@@ -1 +1 @@
1
- {"version":3,"file":"midpoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/midpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAuEF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAa1C,CAAC"}
1
+ {"version":3,"file":"midpoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/midpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAmFF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAa1C,CAAC"}
@@ -5,18 +5,31 @@ import { distinctRandTupleInt } from "../../../../math/utils/random/randTupleInt
5
5
  import { PointNode } from "../../../../tree/nodes/geometry/pointNode.js";
6
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
7
7
  import { shuffle } from "../../../../utils/alea/shuffle.js";
8
+ const getPoints = (identifiers) => {
9
+ const { coordsA, coordsB } = identifiers;
10
+ const A = new Point("A", new NumberNode(coordsA[0]), new NumberNode(coordsA[1]));
11
+ const B = new Point("B", new NumberNode(coordsB[0]), new NumberNode(coordsB[1]));
12
+ return [A, B];
13
+ };
14
+ const getInstruction = (identifiers) => {
15
+ const [A, B] = getPoints(identifiers);
16
+ return `Soit $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$. Quelles sont les coordonnées du milieu $I$ de $[AB]$ ?`;
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const [A, B] = getPoints(identifiers);
20
+ const answer = A.midpoint(B).toTexWithCoords();
21
+ return answer;
22
+ };
8
23
  const getMidpointQuestion = () => {
9
24
  const [coords1, coords2] = distinctRandTupleInt(2, 2, { from: -9, to: 10 });
10
- const A = new Point("A", new NumberNode(coords1[0]), new NumberNode(coords1[1]));
11
- const B = new Point("B", new NumberNode(coords2[0]), new NumberNode(coords2[1]));
12
- const answer = A.midpoint(B).toTexWithCoords();
25
+ const identifiers = { coordsA: coords1, coordsB: coords2 };
13
26
  const question = {
14
- instruction: `Soit $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$. Quelles sont les coordonnées du milieu $I$ de $[AB]$ ?`,
27
+ instruction: getInstruction(identifiers),
15
28
  startStatement: "I",
16
- answer,
29
+ answer: getAnswer(identifiers),
17
30
  keys: ["I", "semicolon"],
18
31
  answerFormat: "tex",
19
- identifiers: { coordsA: coords1, coordsB: coords2 },
32
+ identifiers,
20
33
  };
21
34
  return question;
22
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pointCoordinates.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"pointCoordinates.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pointCoordinatesNoAxisNumbers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinatesNoAxisNumbers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6HF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAc/D,CAAC"}
1
+ {"version":3,"file":"pointCoordinatesNoAxisNumbers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinatesNoAxisNumbers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6HF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAc/D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pointCoordinatesNoOrthonorm.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinatesNoOrthonorm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2GF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAc7D,CAAC"}
1
+ {"version":3,"file":"pointCoordinatesNoOrthonorm.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinatesNoOrthonorm.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;AA2GF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAc7D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ballsBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/ballsBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAiEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"ballsBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/ballsBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAyEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAgBlD,CAAC"}
@@ -2,21 +2,32 @@ import { shuffleProps, tryToAddWrongProp, addValidProp, } from "../../../exercis
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Rational } from "../../../math/numbers/rationals/rational.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
- const getBallsBasicProbasQuestion = () => {
5
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
6
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { repartitions, colorAskedIndex } = identifiers;
6
9
  const colors = ["rouge", "jaune", "verte"];
7
- const repartitions = [randint(1, 4), randint(1, 4), randint(1, 4)];
8
- const total = repartitions.reduce((acc, curr) => (acc += curr), 0);
9
- const colorAskedIndex = randint(0, 3);
10
10
  const colorAsked = colors[colorAskedIndex];
11
+ return `Dans un sac, il y a $${repartitions[0]}$ boules ${colors[0]}${repartitions[0] > 1 ? "s" : ""},
12
+ $${repartitions[1]}$ boules ${colors[1]}${repartitions[1] > 1 ? "s" : ""} et $${repartitions[2]}$ boules ${colors[2]}${repartitions[2] > 1 ? "s" : ""}. Quelle est la probabilité de tirer une boule ${colorAsked} ?`;
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const { repartitions, colorAskedIndex } = identifiers;
11
16
  const nbColorAsked = repartitions[colorAskedIndex];
17
+ const total = repartitions.reduce((acc, curr) => (acc += curr), 0);
12
18
  const answer = new Rational(nbColorAsked, total).simplify().tex;
19
+ return answer;
20
+ };
21
+ const getBallsBasicProbasQuestion = () => {
22
+ const repartitions = [randint(1, 4), randint(1, 4), randint(1, 4)];
23
+ const colorAskedIndex = randint(0, 3);
24
+ const identifiers = { colorAskedIndex, repartitions };
13
25
  const question = {
14
- answer,
15
- instruction: `Dans un sac, il y a $${repartitions[0]}$ boules ${colors[0]}${repartitions[0] > 1 ? "s" : ""},
16
- $${repartitions[1]}$ boules ${colors[1]}${repartitions[1] > 1 ? "s" : ""} et $${repartitions[2]}$ boules ${colors[2]}${repartitions[2] > 1 ? "s" : ""}. Quelle est la probabilité de tirer une boule ${colorAsked} ?`,
26
+ answer: getAnswer(identifiers),
27
+ instruction: getInstruction(identifiers),
17
28
  keys: [],
18
29
  answerFormat: "tex",
19
- identifiers: { colorAskedIndex, repartitions },
30
+ identifiers,
20
31
  };
21
32
  return question;
22
33
  };
@@ -36,14 +47,14 @@ const getPropositions = (n, { answer, colorAskedIndex, repartitions }) => {
36
47
  }
37
48
  return shuffleProps(propositions, n);
38
49
  };
39
- const isAnswerValid = (ans, { colorAskedIndex, repartitions }) => {
40
- const total = repartitions.reduce((acc, curr) => (acc += curr), 0);
41
- const nbColorAsked = repartitions[colorAskedIndex];
42
- const answer = new Rational(nbColorAsked, total)
43
- .simplify()
44
- .toTree({ allowFractionToDecimal: true });
45
- const texs = answer.toAllValidTexs();
46
- return texs.includes(ans);
50
+ const isAnswerValid = (ans, { colorAskedIndex, repartitions, answer }) => {
51
+ try {
52
+ const parsed = parseAlgebraic(ans);
53
+ return parsed.simplify({ decimalToFractions: true }).toTex() === answer;
54
+ }
55
+ catch (err) {
56
+ return handleVEAError(err);
57
+ }
47
58
  };
48
59
  export const ballsBasicProbas = {
49
60
  id: "ballsBasicProbas",
@@ -58,4 +69,6 @@ export const ballsBasicProbas = {
58
69
  getPropositions,
59
70
  isAnswerValid,
60
71
  subject: "Mathématiques",
72
+ getInstruction,
73
+ getAnswer,
61
74
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cardBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/cardBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAAE,UAAU,EAAe,MAAM,oCAAoC,CAAC;AAE7E,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AA6FF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
1
+ {"version":3,"file":"cardBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/cardBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAAE,UAAU,EAAe,MAAM,oCAAoC,CAAC;AAI7E,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAsGF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAgBjD,CAAC"}
@@ -4,44 +4,66 @@ import { Rational } from "../../../math/numbers/rationals/rational.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { probaLawFlip } from "../../../utils/alea/probaLawFlip.js";
6
6
  import { randomEnumValue } from "../../../utils/alea/randomEnumValue.js";
7
- import { FractionNode } from "../../../tree/nodes/operators/fractionNode.js";
8
- import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
9
7
  import { CardsColor, CardsValues } from "../../../exercises/utils/cardsData.js";
8
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
9
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
10
+ const getInstruction = (identifiers) => {
11
+ const { questionType, value, color } = identifiers;
12
+ let target;
13
+ switch (questionType) {
14
+ case "oneCard":
15
+ target = `${value === "dame" ? "une" : "un"} ${value} de ${color}`;
16
+ break;
17
+ case "valueCard":
18
+ target = `${value === "dame" ? "une" : "un"} ${value}`;
19
+ break;
20
+ case "colorCard":
21
+ default:
22
+ target = `un ${color}`;
23
+ break;
24
+ }
25
+ return `On tire une carte dans un jeu de $52$ cartes. Quelle est la probabilité d'obtenir ${target} ?`;
26
+ };
27
+ const getAnswer = (identifiers) => {
28
+ const { questionType, value, color } = identifiers;
29
+ switch (questionType) {
30
+ case "oneCard":
31
+ return `\\frac{1}{52}`;
32
+ case "valueCard":
33
+ return "\\frac{1}{13}";
34
+ case "colorCard":
35
+ default:
36
+ return `\\frac{1}{4}`;
37
+ }
38
+ };
10
39
  const getCardBasicProbasQuestion = () => {
11
40
  const questionType = probaLawFlip([
12
41
  ["oneCard", 0.33],
13
42
  ["valueCard", 0.33],
14
43
  ["colorCard", 0.33],
15
44
  ]);
16
- let answer = "";
17
- let target = "";
18
45
  let value = "";
19
46
  let color;
20
47
  switch (questionType) {
21
48
  case "oneCard":
22
49
  value = randomEnumValue(CardsValues);
23
50
  color = randomEnumValue(CardsColor);
24
- target = `${value === "dame" ? "une" : "un"} ${value} de ${color}`;
25
- answer = `\\frac{1}{52}`;
26
51
  break;
27
52
  case "valueCard":
28
53
  value = randomEnumValue(CardsValues);
29
- target = `${value === "dame" ? "une" : "un"} ${value}`;
30
- answer = "\\frac{1}{13}";
31
54
  break;
32
55
  case "colorCard":
33
56
  default:
34
57
  color = randomEnumValue(CardsColor);
35
- target = `un ${color}`;
36
- answer = `\\frac{1}{4}`;
37
58
  break;
38
59
  }
60
+ const identifiers = { questionType, value, color: color };
39
61
  const question = {
40
- answer,
41
- instruction: `On tire une carte dans un jeu de $52$ cartes. Quelle est la probabilité d'obtenir ${target} ?`,
62
+ answer: getAnswer(identifiers),
63
+ instruction: getInstruction(identifiers),
42
64
  keys: [],
43
65
  answerFormat: "tex",
44
- identifiers: { questionType, value, color: color },
66
+ identifiers,
45
67
  };
46
68
  return question;
47
69
  };
@@ -65,26 +87,14 @@ const getPropositions = (n, { answer, questionType }) => {
65
87
  }
66
88
  return shuffleProps(propositions, n);
67
89
  };
68
- const isAnswerValid = (ans, { questionType }) => {
69
- let denum;
70
- switch (questionType) {
71
- case "oneCard":
72
- denum = 52;
73
- break;
74
- case "valueCard":
75
- denum = 13;
76
- break;
77
- case "colorCard":
78
- denum = 4;
79
- break;
80
- default:
81
- throw Error("wrong questionType in card Basic Probas");
90
+ const isAnswerValid = (ans, { answer, questionType }) => {
91
+ try {
92
+ const parsed = parseAlgebraic(ans);
93
+ return parsed.simplify({ decimalToFractions: true }).toTex() === answer;
94
+ }
95
+ catch (err) {
96
+ return handleVEAError(err);
82
97
  }
83
- const answer = new FractionNode(new NumberNode(1), new NumberNode(denum), {
84
- allowFractionToDecimal: true,
85
- });
86
- const texs = answer.toAllValidTexs();
87
- return texs.includes(ans);
88
98
  };
89
99
  export const cardBasicProbas = {
90
100
  id: "cardBasicProbas",
@@ -99,4 +109,6 @@ export const cardBasicProbas = {
99
109
  getPropositions,
100
110
  isAnswerValid,
101
111
  subject: "Mathématiques",
112
+ getInstruction,
113
+ getAnswer,
102
114
  };