math-exercises 2.2.90 → 2.2.92

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 (75) hide show
  1. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +13 -6
  2. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  3. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +68 -68
  4. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +59 -22
  6. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
  7. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +67 -25
  8. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +54 -22
  10. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
  11. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +35 -15
  12. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.d.ts.map +1 -1
  13. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.js +51 -29
  14. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.d.ts.map +1 -1
  15. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +48 -21
  16. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts.map +1 -1
  17. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.js +48 -22
  18. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts.map +1 -1
  19. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.js +22 -8
  20. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +29 -16
  22. package/lib/exercises/math/combinatory/ballsCounting.d.ts.map +1 -1
  23. package/lib/exercises/math/combinatory/ballsCounting.js +44 -18
  24. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts +0 -4
  25. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
  26. package/lib/exercises/math/functions/affines/affineAdjustment.js +27 -27
  27. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts +0 -5
  28. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
  29. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +45 -62
  30. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts +0 -1
  31. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
  32. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +32 -48
  33. package/lib/exercises/math/matrices/productCell.js +1 -1
  34. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  35. package/lib/exercises/math/probaStat/stats1var/interquartilesList.js +1 -1
  36. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +1 -1
  37. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +2 -2
  38. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +2 -2
  39. package/lib/exercises/math/probaStat/stats1var/varianceList.js +1 -1
  40. package/lib/exercises/math/probaStat/stats1var/varianceTable.js +1 -1
  41. package/lib/index.d.ts +0 -10
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/math/geometry/CloudPoints.js +2 -2
  44. package/lib/math/probability/binomial.js +1 -1
  45. package/lib/math/utils/round.d.ts.map +1 -1
  46. package/lib/math/utils/round.js +19 -5
  47. package/lib/math/utils/stats/covariance.d.ts +4 -0
  48. package/lib/math/utils/stats/covariance.d.ts.map +1 -0
  49. package/lib/math/utils/stats/covariance.js +26 -0
  50. package/lib/math/utils/stats/generateAffineCloud.d.ts +5 -0
  51. package/lib/math/utils/stats/generateAffineCloud.d.ts.map +1 -0
  52. package/lib/math/utils/stats/generateAffineCloud.js +23 -0
  53. package/lib/math/utils/stats/leastSquares.d.ts +5 -0
  54. package/lib/math/utils/stats/leastSquares.d.ts.map +1 -0
  55. package/lib/math/utils/stats/leastSquares.js +19 -0
  56. package/lib/math/utils/stats/quartiles.d.ts +3 -0
  57. package/lib/math/utils/stats/quartiles.d.ts.map +1 -0
  58. package/lib/math/utils/stats/quartiles.js +47 -0
  59. package/lib/math/utils/stats/rSquared.d.ts +2 -0
  60. package/lib/math/utils/stats/rSquared.d.ts.map +1 -0
  61. package/lib/math/utils/stats/rSquared.js +17 -0
  62. package/lib/math/utils/stats/standardDeviation.d.ts +3 -0
  63. package/lib/math/utils/stats/standardDeviation.d.ts.map +1 -0
  64. package/lib/math/utils/stats/standardDeviation.js +13 -0
  65. package/lib/math/utils/stats/sum.d.ts +8 -0
  66. package/lib/math/utils/stats/sum.d.ts.map +1 -0
  67. package/lib/math/utils/stats/sum.js +17 -0
  68. package/lib/math/utils/stats/variance.d.ts +5 -0
  69. package/lib/math/utils/stats/variance.d.ts.map +1 -0
  70. package/lib/math/utils/stats/variance.js +35 -0
  71. package/lib/playground.d.ts.map +1 -1
  72. package/lib/tree/nodes/operators/limitNode.d.ts +1 -1
  73. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
  74. package/lib/tree/parsers/discreteSetParser.js +3 -0
  75. package/package.json +1 -1
@@ -28,6 +28,7 @@
28
28
  // } from "../../../../tree/nodes/nodeConstructor";
29
29
  // type Identifiers = {
30
30
  // equaIdentifiers: EqualNodeIdentifiers;
31
+ // type: number
31
32
  // };
32
33
  // const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
33
34
  // const propositions: Proposition[] = [];
@@ -71,22 +72,28 @@
71
72
  // switch (type) {
72
73
  // case 1:
73
74
  // //ax = b tous entiers
74
- // a = randint(-10);
75
- // break;
76
- // case 2:
75
+ // a = randint(2, 10);
76
+ // b = randint(2, 10)
77
77
  // break;
78
+ // case 2 :
79
+ // // ax + b = c tous entiers
80
+ // break;
78
81
  // case 3:
82
+ // //ax-b = c tous entiers
79
83
  // break;
80
84
  // case 4:
81
- // break;
85
+ // //x/a = b tous entiers
86
+ // break;
82
87
  // case 5:
83
- // break;
88
+ // //x+a = b
89
+ // break;
84
90
  // case 6:
91
+ // //x-a = b
85
92
  // break;
86
93
  // case 7:
87
94
  // break;
88
95
  // }
89
- // const identifiers: Identifiers = {};
96
+ // const identifiers: Identifiers = {type, };
90
97
  // const question: Question<Identifiers> = {
91
98
  // answer: getAnswer(identifiers),
92
99
  // instruction: getInstruction(identifiers),
@@ -1 +1 @@
1
- {"version":3,"file":"equationSimpleSquare.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationSimpleSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AA0BlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAuKF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
1
+ {"version":3,"file":"equationSimpleSquare.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationSimpleSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AA2BlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA+JF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC"}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.equationSimpleSquare = void 0;
4
4
  const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
- const equationKeys_1 = require("../../../../exercises/utils/keys/equationKeys");
7
6
  const rational_1 = require("../../../../math/numbers/rationals/rational");
8
7
  const real_1 = require("../../../../math/numbers/reals/real");
9
8
  const randint_1 = require("../../../../math/utils/random/randint");
@@ -15,6 +14,7 @@ const coinFlip_1 = require("../../../../utils/alea/coinFlip");
15
14
  const diceFlip_1 = require("../../../../utils/alea/diceFlip");
16
15
  const isInt_1 = require("../../../../utils/isInt");
17
16
  const random_1 = require("../../../../utils/alea/random");
17
+ const discreteSetParser_1 = require("../../../../tree/parsers/discreteSetParser");
18
18
  const squares = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((el) => el ** 2);
19
19
  const higherFactor = (n) => {
20
20
  for (let i = Math.floor(Math.sqrt(n)); i > 0; i--)
@@ -22,65 +22,77 @@ const higherFactor = (n) => {
22
22
  return i;
23
23
  return 1;
24
24
  };
25
- const getEquationSimpleSquare = () => {
26
- let randNbr = (0, randint_1.randint)(-10, 101);
27
- const rand = (0, diceFlip_1.diceFlip)(3);
28
- if (rand === 0)
29
- randNbr = (0, randint_1.randint)(-20, 0);
30
- else if (rand === 1)
31
- randNbr = (0, random_1.random)(squares);
32
- else
33
- randNbr = (0, randint_1.randint)(2, 100);
34
- const instruction = `Résoudre l'équation : $x^2 = ${randNbr}$`;
35
- const sqrt = Math.sqrt(randNbr);
25
+ const getInstruction = (identifiers) => {
26
+ const { randNbr } = identifiers;
27
+ return `Résoudre l'équation :
28
+
29
+ $$
30
+ x^2 = ${randNbr}
31
+ $$`;
32
+ };
33
+ const getHint = (identifiers) => {
34
+ return `L'équation $x^2 = k$ :
35
+
36
+ - n'admet pas de solution si $k<0$,
37
+ - admet une solution si $k=0$, qui est $0$
38
+ - admet deux solutions si $k>0$, qui sont $-\\sqrt{k}$ et $\\sqrt{k}$
39
+ `;
40
+ };
41
+ const getAnswer = (identifiers) => {
42
+ const { randNbr } = identifiers;
36
43
  let solutionsSet;
37
- let simplifiedRoot;
38
44
  if (randNbr < 0) {
39
45
  solutionsSet = new discreteSetNode_1.DiscreteSetNode([]);
40
46
  }
41
- else if (sqrt === Math.floor(sqrt)) {
42
- if (sqrt === 0)
43
- solutionsSet = new discreteSetNode_1.DiscreteSetNode([new numberNode_1.NumberNode(0)]);
44
- else
45
- solutionsSet = new discreteSetNode_1.DiscreteSetNode([
46
- new numberNode_1.NumberNode(-sqrt),
47
- new numberNode_1.NumberNode(+sqrt),
48
- ]);
47
+ else if (randNbr === 0) {
48
+ solutionsSet = new discreteSetNode_1.DiscreteSetNode([new numberNode_1.NumberNode(0)]);
49
49
  }
50
50
  else {
51
51
  const tree = new real_1.SquareRoot(randNbr).simplify().toTree();
52
52
  solutionsSet = new discreteSetNode_1.DiscreteSetNode([new oppositeNode_1.OppositeNode(tree), tree]);
53
53
  }
54
54
  const answer = new equationSolutionNode_1.EquationSolutionNode(solutionsSet).toTex();
55
- const question = {
56
- instruction,
57
- answer,
58
- keys: equationKeys_1.equationKeys,
59
- answerFormat: "tex",
60
- identifiers: { randNbr },
61
- hint: `L'équation $x^2 = k$ :
62
-
63
- - n'admet pas de solution si $k<0$,
64
- - admet une solution si $k=0$, qui est $0$
65
- - admet deux solutions si $k>0$, qui sont $-\\sqrt{k}$ et $\\sqrt{k}$
66
- `,
67
- correction: `
55
+ return answer;
56
+ };
57
+ const getCorrection = (identifiers) => {
58
+ const { randNbr } = identifiers;
59
+ const answer = getAnswer(identifiers);
60
+ return `
68
61
  ${randNbr < 0
69
- ? `L'équation $x^2 = ${randNbr}$ n'admet pas de solution, car $${randNbr}$ est négatif. Ainsi, $${answer}$.`
70
- : randNbr === 0
71
- ? `L'équation $x^2 = 0$ admet une unique solution : $0$. En effet, $0$ est le seul nombre qui au carré est égal à $0$. Ainsi, $${answer}$.`
72
- : `Puisque $${randNbr}>0$, l'équation $x^2 = ${randNbr}$ admet deux solutions : $-\\sqrt{${randNbr}}$ et $\\sqrt{${randNbr}}$.
62
+ ? `L'équation $x^2 = ${randNbr}$ n'admet pas de solution, car $${randNbr}$ est négatif. Ainsi, $${answer}$.`
63
+ : randNbr === 0
64
+ ? `L'équation $x^2 = 0$ admet une unique solution : $0$. En effet, $0$ est le seul nombre qui au carré est égal à $0$. Ainsi, $${answer}$.`
65
+ : `Puisque $${randNbr}>0$, l'équation $x^2 = ${randNbr}$ admet deux solutions : $-\\sqrt{${randNbr}}$ et $\\sqrt{${randNbr}}$.
73
66
 
74
67
  ${new real_1.SquareRoot(randNbr).isSimplifiable()
75
- ? `Or, $\\sqrt{${randNbr}}=${new real_1.SquareRoot(randNbr)
76
- .simplify()
77
- .toTree()
78
- .toTex()}$.`
79
- : ""}
68
+ ? `Or, $\\sqrt{${randNbr}}=${new real_1.SquareRoot(randNbr)
69
+ .simplify()
70
+ .toTree()
71
+ .toTex()}$.`
72
+ : ""}
80
73
 
81
74
  Ainsi, $${answer}$.
82
75
  `}
83
- `,
76
+ `;
77
+ };
78
+ const getEquationSimpleSquare = () => {
79
+ let randNbr;
80
+ const rand = (0, diceFlip_1.diceFlip)(10);
81
+ if (rand === 1)
82
+ randNbr = (0, randint_1.randint)(-20, 0);
83
+ else if (rand < 6)
84
+ randNbr = (0, random_1.random)(squares);
85
+ else
86
+ randNbr = (0, randint_1.randint)(2, 100);
87
+ const identifiers = { randNbr };
88
+ const question = {
89
+ instruction: getInstruction(identifiers),
90
+ answer: getAnswer(identifiers),
91
+ keys: ["S", "equal", "lbrace", "semicolon", "rbrace", "varnothing"],
92
+ answerFormat: "tex",
93
+ identifiers,
94
+ hint: getHint(identifiers),
95
+ correction: getCorrection(identifiers),
84
96
  };
85
97
  return question;
86
98
  };
@@ -121,32 +133,16 @@ const getPropositions = (n, { answer, randNbr }) => {
121
133
  }
122
134
  return (0, exercise_1.shuffleProps)(propositions, n);
123
135
  };
124
- const isAnswerValid = (ans, { randNbr }) => {
125
- let answerTrees = [];
126
- if (randNbr < 0) {
127
- answerTrees = [new equationSolutionNode_1.EquationSolutionNode(discreteSetNode_1.EmptySet)];
136
+ const isAnswerValid = (ans, { answer, randNbr }) => {
137
+ try {
138
+ const parsed = (0, discreteSetParser_1.discreteSetParser)(ans);
139
+ if (!parsed)
140
+ return false;
141
+ return "S=" + parsed.simplify().toTex() === answer;
128
142
  }
129
- else if (randNbr === 0) {
130
- answerTrees = [
131
- new equationSolutionNode_1.EquationSolutionNode(new discreteSetNode_1.DiscreteSetNode([new numberNode_1.NumberNode(0)])),
132
- ];
133
- }
134
- // else if (randNbr === 1) {
135
- // answerTrees = [
136
- // new EquationSolutionNode(new DiscreteSetNode([new NumberNode(1)])),
137
- // ];
138
- // }
139
- else {
140
- const sqrt = new real_1.SquareRoot(randNbr);
141
- const sqrtTree = sqrt.toTree();
142
- answerTrees.push(new equationSolutionNode_1.EquationSolutionNode(new discreteSetNode_1.DiscreteSetNode([new oppositeNode_1.OppositeNode(sqrtTree), sqrtTree])));
143
- if (sqrt.isSimplifiable()) {
144
- const simplified = sqrt.simplify().toTree();
145
- answerTrees.push(new equationSolutionNode_1.EquationSolutionNode(new discreteSetNode_1.DiscreteSetNode([new oppositeNode_1.OppositeNode(simplified), simplified])));
146
- }
143
+ catch (err) {
144
+ return false;
147
145
  }
148
- const texs = answerTrees.flatMap((tree) => tree.toAllValidTexs());
149
- return texs.includes(ans);
150
146
  };
151
147
  exports.equationSimpleSquare = {
152
148
  id: "equationSimpleSquare",
@@ -162,4 +158,8 @@ exports.equationSimpleSquare = {
162
158
  isAnswerValid,
163
159
  subject: "Mathématiques",
164
160
  hasHintAndCorrection: true,
161
+ getAnswer,
162
+ getCorrection,
163
+ getInstruction,
164
+ getHint,
165
165
  };
@@ -1 +1 @@
1
- {"version":3,"file":"equationType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAclC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4DF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAevD,CAAC"}
1
+ {"version":3,"file":"equationType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAclC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAoBvD,CAAC"}
@@ -12,33 +12,65 @@ const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
12
12
  const alignTex_1 = require("../../../../utils/latex/alignTex");
13
13
  const addNode_1 = require("../../../../tree/nodes/operators/addNode");
14
14
  const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
15
- const getEquationType1ExerciseQuestion = () => {
16
- const b = (0, randint_1.randint)(-10, 11);
17
- const a = (0, randint_1.randint)(-10, 11, [0]);
18
- const solution = b - a;
15
+ const getInstruction = (identifiers) => {
16
+ const { a, b } = identifiers;
19
17
  const affine = new affine_1.Affine(1, a).toTree();
20
18
  const tree = new equalNode_1.EqualNode(affine, new numberNode_1.NumberNode(b));
19
+ const statementTree = tree.toTex();
20
+ return `Résoudre :
21
+
22
+ $$
23
+ ${statementTree}
24
+ $$`;
25
+ };
26
+ const getAnswer = (identifiers) => {
27
+ const { a, b } = identifiers;
28
+ const solution = b - a;
21
29
  const answer = `x=${solution}`;
30
+ return answer;
31
+ };
32
+ const getHint = (identifiers) => {
33
+ const { a, b } = identifiers;
34
+ return `Il faut isoler $x$ à gauche. Pour cela, effectue l'opération des deux côtés de l'équation qui permet de supprimer le terme $${a < 0 ? "" : "+"}${a}$.`;
35
+ };
36
+ const getCorrection = (identifiers) => {
37
+ const { a, b } = identifiers;
38
+ const affine = new affine_1.Affine(1, a).toTree();
39
+ const tree = new equalNode_1.EqualNode(affine, new numberNode_1.NumberNode(b));
22
40
  const statementTree = tree.toTex();
41
+ const answer = getAnswer(identifiers);
42
+ return `Pour isoler $x$ à gauche, on effectue l'opération $${a > 0 ? `$-${a}$` : `+${Math.abs(a)}`}$ des deux côtés de l'équation :
43
+
44
+ ${(0, alignTex_1.alignTex)([
45
+ [
46
+ `${statementTree}`,
47
+ "\\iff",
48
+ new equalNode_1.EqualNode(new addNode_1.AddNode(affine, new numberNode_1.NumberNode(-a)), new addNode_1.AddNode(b.toTree(), new numberNode_1.NumberNode(-a))).toTex(),
49
+ ],
50
+ ["", "\\iff", answer],
51
+ ])}
52
+ `;
53
+ };
54
+ const getStartStatement = (identifiers) => {
55
+ const { a, b } = identifiers;
56
+ const affine = new affine_1.Affine(1, a).toTree();
57
+ const tree = new equalNode_1.EqualNode(affine, new numberNode_1.NumberNode(b));
58
+ const statementTree = tree.toTex();
59
+ return statementTree;
60
+ };
61
+ const getEquationType1ExerciseQuestion = () => {
62
+ const b = (0, randint_1.randint)(-10, 11);
63
+ const a = (0, randint_1.randint)(-10, 11, [0]);
64
+ const identifiers = { a, b };
23
65
  const question = {
24
- instruction: `Résoudre : $${statementTree}$`,
25
- startStatement: statementTree,
26
- answer,
66
+ instruction: getInstruction(identifiers),
67
+ startStatement: getStartStatement(identifiers),
68
+ answer: getAnswer(identifiers),
27
69
  keys: equationKeys_1.equationKeys,
28
70
  answerFormat: "tex",
29
- identifiers: { a, b },
30
- hint: `Il faut isoler $x$ à gauche. Pour cela, effectue l'opération des deux côtés de l'équation qui permet de supprimer le terme $${a < 0 ? "" : "+"}${a}$.`,
31
- correction: `Pour isoler $x$ à gauche, on effectue l'opération $${a > 0 ? `$-${a}$` : `+${Math.abs(a)}`}$ des deux côtés de l'équation :
32
-
33
- ${(0, alignTex_1.alignTex)([
34
- [
35
- `${statementTree}`,
36
- "\\iff",
37
- new equalNode_1.EqualNode(new addNode_1.AddNode(affine, new numberNode_1.NumberNode(-a)), new addNode_1.AddNode(b.toTree(), new numberNode_1.NumberNode(-a))).toTex(),
38
- ],
39
- ["", "\\iff", answer],
40
- ])}
41
- `,
71
+ identifiers,
72
+ hint: getHint(identifiers),
73
+ correction: getCorrection(identifiers),
42
74
  };
43
75
  return question;
44
76
  };
@@ -46,10 +78,10 @@ const getPropositions = (n, { answer, a, b }) => {
46
78
  const propositions = [];
47
79
  (0, exercise_1.addValidProp)(propositions, answer);
48
80
  const solution = b - a;
49
- (0, exercise_1.tryToAddWrongProp)(propositions, `x = ${b + a}`);
81
+ (0, exercise_1.tryToAddWrongProp)(propositions, `x=${b + a}`);
50
82
  while (propositions.length < n) {
51
83
  const wrongAnswer = solution + (0, randint_1.randint)(-3, 4, [0]);
52
- (0, exercise_1.tryToAddWrongProp)(propositions, `x = ${wrongAnswer}`);
84
+ (0, exercise_1.tryToAddWrongProp)(propositions, `x=${wrongAnswer}`);
53
85
  }
54
86
  return (0, shuffle_1.shuffle)(propositions);
55
87
  };
@@ -71,4 +103,9 @@ exports.equationType1Exercise = {
71
103
  isAnswerValid,
72
104
  subject: "Mathématiques",
73
105
  hasHintAndCorrection: true,
106
+ getCorrection,
107
+ getHint,
108
+ getInstruction,
109
+ getAnswer,
110
+ getStartStatement,
74
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"equationType2Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType2Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAsBlC,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAM1C;;GAEG;AAGH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA2GF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAaF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBhE,CAAC"}
1
+ {"version":3,"file":"equationType2Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType2Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,0BAA0B,CAAC;AAsBlC,OAAO,EAEL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAM1C;;GAEG;AAGH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAmJF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAaF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBhE,CAAC"}
@@ -19,7 +19,7 @@ const substractNode_1 = require("../../../../tree/nodes/operators/substractNode"
19
19
  const addNode_1 = require("../../../../tree/nodes/operators/addNode");
20
20
  const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
21
21
  const rebuildIdentifiers = (oldIdentifiers) => {
22
- if (!!oldIdentifiers.numberType)
22
+ if (!!oldIdentifiers.aNumberType)
23
23
  return oldIdentifiers;
24
24
  return {
25
25
  a: oldIdentifiers.a.toTree().toIdentifiers(),
@@ -28,6 +28,61 @@ const rebuildIdentifiers = (oldIdentifiers) => {
28
28
  aNumberType: "Entier",
29
29
  };
30
30
  };
31
+ const getInstruction = (identifiers) => {
32
+ return `Résoudre :
33
+
34
+ $$
35
+ ${getStatementNode(identifiers).toTex()}
36
+ $$`;
37
+ };
38
+ const getAnswer = (identifiers) => {
39
+ const { a, b, isXRight, aNumberType } = identifiers;
40
+ const aTree = (0, nodeConstructor_1.reifyAlgebraic)(a);
41
+ const bTree = (0, nodeConstructor_1.reifyAlgebraic)(b);
42
+ const solution = (0, fractionNode_1.frac)(bTree, aTree).simplify();
43
+ const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), solution).toTex();
44
+ return answer;
45
+ };
46
+ const getHint = (identifiers) => {
47
+ const { a, b, isXRight, aNumberType } = identifiers;
48
+ const aTree = (0, nodeConstructor_1.reifyAlgebraic)(a);
49
+ const bTree = (0, nodeConstructor_1.reifyAlgebraic)(b);
50
+ return `Il faut isoler $x$ à ${isXRight ? "droite" : "gauche"}. Pour cela, effectue l'opération des deux côtés de l'équation qui permet de supprimer la multiplication par $${aTree.toTex()}$.`;
51
+ };
52
+ const getCorrection = (identifiers) => {
53
+ const { a, b, isXRight, aNumberType } = identifiers;
54
+ const aTree = (0, nodeConstructor_1.reifyAlgebraic)(a);
55
+ const bTree = (0, nodeConstructor_1.reifyAlgebraic)(b);
56
+ const affine = new generalAffine_1.GeneralAffine(aTree, 0).toTree();
57
+ const equalTree = new equalNode_1.EqualNode(affine, bTree);
58
+ const tree = isXRight ? equalTree.reverse() : equalTree;
59
+ const answer = getAnswer(identifiers);
60
+ return `Pour isoler $x$ à ${isXRight ? "droite" : "gauche"}, on divise les deux côtés de l'équation par $${aTree.toTex()}$ :
61
+
62
+ ${(0, alignTex_1.alignTex)([
63
+ [
64
+ `${tree.toTex()}`,
65
+ "\\iff",
66
+ isXRight
67
+ ? (0, equalNode_1.equal)((0, fractionNode_1.frac)(bTree, aTree), (0, fractionNode_1.frac)(affine, aTree)).toTex()
68
+ : (0, equalNode_1.equal)((0, fractionNode_1.frac)(affine, aTree), (0, fractionNode_1.frac)(bTree, aTree)).toTex(),
69
+ ],
70
+ ["", "\\iff", answer],
71
+ ])}
72
+ `;
73
+ };
74
+ const getStatementNode = (identifiers) => {
75
+ const { a, b, isXRight, aNumberType } = identifiers;
76
+ const aTree = (0, nodeConstructor_1.reifyAlgebraic)(a);
77
+ const bTree = (0, nodeConstructor_1.reifyAlgebraic)(b);
78
+ const affine = new generalAffine_1.GeneralAffine(aTree, 0).toTree();
79
+ const equalTree = new equalNode_1.EqualNode(affine, bTree);
80
+ const tree = isXRight ? equalTree.reverse() : equalTree;
81
+ return tree;
82
+ };
83
+ const getStartStatement = (identifiers) => {
84
+ return getStatementNode(identifiers).toTex();
85
+ };
31
86
  const getEquationType2ExerciseQuestion = (opts) => {
32
87
  const types = opts?.aNumberType ?? ["Entier"];
33
88
  const b = (0, randint_1.randint)(-10, 11).toTree();
@@ -35,13 +90,7 @@ const getEquationType2ExerciseQuestion = (opts) => {
35
90
  const a = type === "Entier"
36
91
  ? (0, randint_1.randint)(-9, 10, [0, 1]).toTree()
37
92
  : rational_1.RationalConstructor.randomIrreductibleWithSign().toTree();
38
- const solution = (0, fractionNode_1.frac)(b, a).simplify();
39
- const affine = new generalAffine_1.GeneralAffine(a, 0).toTree();
40
93
  const isXRight = (0, coinFlip_1.coinFlip)();
41
- const equalTree = new equalNode_1.EqualNode(affine, b);
42
- const tree = isXRight ? equalTree.reverse() : equalTree;
43
- const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), solution).toTex();
44
- const statementTex = tree.toTex();
45
94
  const identifiers = {
46
95
  a: a.toIdentifiers(),
47
96
  b: b.toIdentifiers(),
@@ -49,26 +98,14 @@ const getEquationType2ExerciseQuestion = (opts) => {
49
98
  aNumberType: type,
50
99
  };
51
100
  const question = {
52
- instruction: `Résoudre : $${statementTex}$`,
53
- startStatement: statementTex,
54
- answer,
101
+ instruction: getInstruction(identifiers),
102
+ startStatement: getStartStatement(identifiers),
103
+ answer: getAnswer(identifiers),
55
104
  keys: equationKeys_1.equationKeys,
56
105
  answerFormat: "tex",
57
- identifiers: identifiers,
58
- hint: `Il faut isoler $x$ à ${isXRight ? "droite" : "gauche"}. Pour cela, effectue l'opération des deux côtés de l'équation qui permet de supprimer la multiplication par $${a.toTex()}$.`,
59
- correction: `Pour isoler $x$ à ${isXRight ? "droite" : "gauche"}, on divise les deux côtés de l'équation par $${a.toTex()}$ :
60
-
61
- ${(0, alignTex_1.alignTex)([
62
- [
63
- `${statementTex}`,
64
- "\\iff",
65
- isXRight
66
- ? (0, equalNode_1.equal)((0, fractionNode_1.frac)(b, a), (0, fractionNode_1.frac)(affine, a)).toTex()
67
- : (0, equalNode_1.equal)((0, fractionNode_1.frac)(affine, a), (0, fractionNode_1.frac)(b, a)).toTex(),
68
- ],
69
- ["", "\\iff", answer],
70
- ])}
71
- `,
106
+ identifiers,
107
+ hint: getHint(identifiers),
108
+ correction: getCorrection(identifiers),
72
109
  };
73
110
  return question;
74
111
  };
@@ -117,5 +154,10 @@ exports.equationType2Exercise = {
117
154
  subject: "Mathématiques",
118
155
  hasHintAndCorrection: true,
119
156
  options,
157
+ getCorrection,
158
+ getHint,
159
+ getInstruction,
160
+ getAnswer,
161
+ getStartStatement,
120
162
  rebuildIdentifiers,
121
163
  };
@@ -1 +1 @@
1
- {"version":3,"file":"equationType3Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType3Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAelC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiEF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAgBvD,CAAC"}
1
+ {"version":3,"file":"equationType3Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType3Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAqBvD,CAAC"}
@@ -15,36 +15,63 @@ const alignTex_1 = require("../../../../utils/latex/alignTex");
15
15
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
16
16
  const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
17
17
  const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
18
- const getEquationType3ExerciseQuestion = () => {
19
- const b = (0, randint_1.randint)(-10, 11, [0]);
20
- const a = (0, randint_1.randint)(-10, 11, [0, 1]);
21
- const c = (0, randint_1.randint)(-10, 11);
18
+ const getStatementNode = (identifiers) => {
19
+ const { a, b, c } = identifiers;
22
20
  const affine = new affine_1.Affine(a, b).toTree();
23
- const solution = new rational_1.Rational(c - b, a).simplify();
24
21
  const statementTree = new equalNode_1.EqualNode(affine, new numberNode_1.NumberNode(c));
25
- const answerTree = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), solution.toTree());
26
- const answer = answerTree.toTex();
27
- const statementTex = statementTree.toTex();
28
- const question = {
29
- instruction: `Résoudre : $${statementTex}$`,
30
- hint: "Isolez le terme $x$ dans la partie gauche de l'équation.",
31
- correction: `Commencer par soustraire $${b}$ des deux côtés de l'équation pour
22
+ return statementTree;
23
+ };
24
+ const getInstruction = (identifiers) => {
25
+ return `Résoudre :
26
+
27
+ $$
28
+ ${getStatementNode(identifiers).toTex()}
29
+ $$`;
30
+ };
31
+ const getHint = (identifiers) => {
32
+ return "Isolez le terme $x$ dans la partie gauche de l'équation.";
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const { a, b, c } = identifiers;
36
+ const statementTex = getStatementNode(identifiers).toTex();
37
+ const answer = getAnswer(identifiers);
38
+ return `Commencer par soustraire $${b}$ des deux côtés de l'équation pour
32
39
  l'éliminer du côté gauche. Ensuite, diviser les deux côtés de l'équation par
33
40
  $${a}$ pour isoler $x$, ce qui donne :
34
41
 
35
42
  ${(0, alignTex_1.alignTex)([
36
- [
37
- statementTex,
38
- "\\iff",
39
- new equalNode_1.EqualNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), (c - b).toTree()).toTex(),
40
- ],
41
- ["", "\\iff", answer],
42
- ])}`,
43
- startStatement: statementTree.toTex(),
44
- answer,
43
+ [
44
+ statementTex,
45
+ "\\iff",
46
+ new equalNode_1.EqualNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), (c - b).toTree()).toTex(),
47
+ ],
48
+ ["", "\\iff", answer],
49
+ ])}`;
50
+ };
51
+ const getStartStatement = (identifiers) => {
52
+ return getStatementNode(identifiers).toTex();
53
+ };
54
+ const getAnswer = (identifiers) => {
55
+ const { a, b, c } = identifiers;
56
+ const solution = new rational_1.Rational(c - b, a).simplify();
57
+ const answerTree = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), solution.toTree());
58
+ const answer = answerTree.toTex();
59
+ return answer;
60
+ };
61
+ const getEquationType3ExerciseQuestion = () => {
62
+ const b = (0, randint_1.randint)(-10, 11, [0]);
63
+ const a = (0, randint_1.randint)(-10, 11, [0, 1]);
64
+ const c = (0, randint_1.randint)(-10, 11);
65
+ const identifiers = { a, b, c };
66
+ const question = {
67
+ instruction: getInstruction(identifiers),
68
+ hint: getHint(identifiers),
69
+ correction: getCorrection(identifiers),
70
+ startStatement: getStartStatement(identifiers),
71
+ answer: getAnswer(identifiers),
45
72
  keys: equationKeys_1.equationKeys,
46
73
  answerFormat: "tex",
47
- identifiers: { a, b, c },
74
+ identifiers,
48
75
  };
49
76
  return question;
50
77
  };
@@ -77,4 +104,9 @@ exports.equationType3Exercise = {
77
104
  isAnswerValid,
78
105
  subject: "Mathématiques",
79
106
  hasHintAndCorrection: true,
107
+ getAnswer,
108
+ getInstruction,
109
+ getCorrection,
110
+ getHint,
111
+ getStartStatement,
80
112
  };
@@ -1 +1 @@
1
- {"version":3,"file":"equationType4Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType4Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAelC;;GAEG;AAEH,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;AA0EF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAcvD,CAAC"}
1
+ {"version":3,"file":"equationType4Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType4Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAelC;;GAEG;AAEH,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+FF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAgBvD,CAAC"}
@@ -12,29 +12,47 @@ const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
12
12
  const shuffle_1 = require("../../../../utils/alea/shuffle");
13
13
  const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
14
14
  const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
15
+ const getStatementNode = (identifiers) => {
16
+ const { a, b, c, d } = identifiers;
17
+ const affines = [new affine_1.Affine(a, b), new affine_1.Affine(c, d)];
18
+ const statementTree = new equalNode_1.EqualNode(affines[0].toTree(), affines[1].toTree());
19
+ return statementTree;
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ return `Résoudre :
23
+
24
+ $$
25
+ ${getStatementNode(identifiers).toTex()}
26
+ $$`;
27
+ };
28
+ const getStartStatement = (identifiers) => {
29
+ return getStatementNode(identifiers).toTex();
30
+ };
31
+ const getAnswer = (identifiers) => {
32
+ const { a, b, c, d } = identifiers;
33
+ const solution = new rational_1.Rational(d - b, a - c).simplify();
34
+ const answerTree = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), solution.toTree());
35
+ const answer = answerTree.toTex();
36
+ return answer;
37
+ };
15
38
  const getEquationType4ExerciseQuestion = () => {
16
39
  const a = (0, randint_1.randint)(-10, 11, [0, 1]);
17
40
  const b = (0, randint_1.randint)(-10, 11, [0]);
18
41
  const c = (0, randint_1.randint)(-10, 11, [0, a]);
19
42
  const d = (0, randint_1.randint)(-10, 11, [0]);
20
- const affines = [new affine_1.Affine(a, b), new affine_1.Affine(c, d)];
21
- const solution = new rational_1.Rational(d - b, a - c).simplify();
22
- const statementTree = new equalNode_1.EqualNode(affines[0].toTree(), affines[1].toTree());
23
- const answerTree = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), solution.toTree());
24
- const answer = answerTree.toTex();
25
- const statementTex = statementTree.toTex();
43
+ const identifiers = {
44
+ a,
45
+ b,
46
+ c,
47
+ d,
48
+ };
26
49
  const question = {
27
- instruction: `Résoudre : $${statementTex}$`,
28
- startStatement: statementTex,
29
- answer,
50
+ instruction: getInstruction(identifiers),
51
+ startStatement: getStartStatement(identifiers),
52
+ answer: getAnswer(identifiers),
30
53
  keys: equationKeys_1.equationKeys,
31
54
  answerFormat: "tex",
32
- identifiers: {
33
- a: a,
34
- b: b,
35
- c: c,
36
- d: d,
37
- },
55
+ identifiers,
38
56
  // hint: `Commence par regrouper les termes en $x$ d'un même côté de l'équation. Puis, isole $x$ en effectuant les bonnes opérations.`,
39
57
  // correction: `On isole $x$ à gauche en soustrayant par $${b}$ puis en divisant par $${a}$ :
40
58
  // ${alignTex([
@@ -80,4 +98,6 @@ exports.equationType4Exercise = {
80
98
  getPropositions,
81
99
  isAnswerValid,
82
100
  subject: "Mathématiques",
101
+ getInstruction,
102
+ getAnswer,
83
103
  };