math-exercises 2.2.86 → 2.2.87

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 (60) hide show
  1. package/lib/exercises/math/calcul/decimals/multiplyDecimalByTens.js +1 -1
  2. package/lib/exercises/math/calcul/rounding/rounding.js +2 -2
  3. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts +4 -0
  4. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +60 -28
  6. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType0.d.ts.map +1 -1
  7. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType0.js +2 -0
  8. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.js +2 -0
  10. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.js +1 -1
  11. package/lib/exercises/math/derivation/derivative/expDerivativeThree.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/derivative/expDerivativeThree.js +0 -2
  13. package/lib/exercises/math/derivation/derivative/quotientDerivative.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/derivative/quotientDerivative.js +0 -13
  15. package/lib/exercises/math/derivation/derivative/secondDegreeDerivative.js +1 -1
  16. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.js +1 -1
  17. package/lib/exercises/math/derivation/derivative/thirdDegreeDerivative.js +1 -1
  18. package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.js +3 -3
  19. package/lib/exercises/math/functions/affines/signFunction.d.ts.map +1 -1
  20. package/lib/exercises/math/functions/affines/signFunction.js +2 -0
  21. package/lib/exercises/math/functions/basics/imageFunction.d.ts +1 -0
  22. package/lib/exercises/math/functions/basics/imageFunction.d.ts.map +1 -1
  23. package/lib/exercises/math/functions/basics/imageFunction.js +69 -15
  24. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts.map +1 -1
  25. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.js +1 -0
  26. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -1
  27. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +1 -0
  28. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts.map +1 -1
  29. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.js +1 -0
  30. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.js +1 -1
  31. package/lib/exercises/math/percent/evolutionToCM.d.ts.map +1 -1
  32. package/lib/exercises/math/percent/evolutionToCM.js +39 -13
  33. package/lib/exercises/math/powers/powersDivision.js +1 -1
  34. package/lib/exercises/math/powers/powersOfTenToDecimal.js +1 -1
  35. package/lib/exercises/math/powers/powersPower.js +1 -1
  36. package/lib/exercises/math/powers/powersProduct.js +1 -1
  37. package/lib/exercises/math/python/conditionIf.js +1 -1
  38. package/lib/exercises/math/python/forLoop.js +1 -1
  39. package/lib/exercises/math/python/inOutCalcul.js +1 -1
  40. package/lib/exercises/math/python/pyForLoop1Exercise.js +1 -1
  41. package/lib/exercises/math/python/pyNestedForLoopExercise.js +1 -1
  42. package/lib/exercises/math/python/pyWhileLoop1Exercise.js +1 -1
  43. package/lib/exercises/math/python/whileLoop.js +1 -1
  44. package/lib/exercises/pc/pH.js +3 -3
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/latexTester.d.ts +2 -0
  48. package/lib/latexTester.d.ts.map +1 -0
  49. package/lib/latexTester.js +164 -0
  50. package/lib/playground.d.ts.map +1 -1
  51. package/lib/playground.js +11 -1
  52. package/lib/tree/nodes/inequations/inequationNode.js +1 -1
  53. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  54. package/lib/tree/nodes/operators/addNode.js +9 -0
  55. package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -0
  56. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  57. package/lib/tree/nodes/operators/multiplyNode.js +3 -0
  58. package/lib/utils/latex/alignTex.d.ts.map +1 -1
  59. package/lib/utils/latex/alignTex.js +2 -4
  60. package/package.json +1 -1
@@ -58,7 +58,7 @@ const isAnswerValid = (ans, { answer }) => {
58
58
  exports.multiplyDecimalByTens = {
59
59
  id: "multiplyDecimalByTens",
60
60
  connector: "=",
61
- label: "Multiplier/diviser un décimal par une puissance de 10",
61
+ label: "Multiplier/diviser un décimal par une puissance de $10$",
62
62
  levels: [],
63
63
  isSingleStep: true,
64
64
  sections: [],
@@ -42,10 +42,10 @@ const getRoundQuestions = (opts) => {
42
42
  correction: `Le chiffre des ${ranks[precisionAsked + 1]}s est $${figureToLookAt}$.
43
43
 
44
44
  ${figureToLookAt < 5
45
- ? `Puisque ${figureToLookAt} est inférieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} inférieur.
45
+ ? `Puisque $${figureToLookAt}$ est inférieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} inférieur.
46
46
 
47
47
  Ainsi, en arrondissant ${ranksWithAu[precisionAsked]}, on a $${decTex} \\approx ${answer}$`
48
- : `Puisque ${figureToLookAt} est supérieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} supérieur.
48
+ : `Puisque $${figureToLookAt}$ est supérieur à $5$, on arrondit ${ranksWithAu[precisionAsked]} supérieur.
49
49
 
50
50
  Ainsi, en arrondissant ${ranksWithAu[precisionAsked]}, on a
51
51
 
@@ -2,6 +2,10 @@
2
2
  * type (ax+b)(cx+d) ± (ax+b)(ex+f)
3
3
  */
4
4
  import { Exercise } from "../../../../exercises/exercise";
5
+ /**
6
+ * facto du type (ax+b)(cx+d) ± (ax+b)(ex+f)
7
+ * b, d, f non nuls
8
+ */
5
9
  type Identifiers = {
6
10
  affinesCoeffs: number[][];
7
11
  operation: string;
@@ -1 +1 @@
1
- {"version":3,"file":"factoType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType1Exercise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4HF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
1
+ {"version":3,"file":"factoType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType1Exercise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAclC;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAoJF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
@@ -7,44 +7,73 @@ exports.factoType1Exercise = void 0;
7
7
  const exercise_1 = require("../../../../exercises/exercise");
8
8
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
9
9
  const affine_1 = require("../../../../math/polynomials/affine");
10
+ const randint_1 = require("../../../../math/utils/random/randint");
10
11
  const addNode_1 = require("../../../../tree/nodes/operators/addNode");
11
12
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
12
13
  const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
14
+ const latexParser_1 = require("../../../../tree/parsers/latexParser");
13
15
  const random_1 = require("../../../../utils/alea/random");
14
16
  const shuffle_1 = require("../../../../utils/alea/shuffle");
15
17
  //TODO fix { "affinesCoeffs": [ [ -2, 8 ], [ -5, 4 ], [ 0, -8 ] ], "operation": "substract" } donne trop de moins
16
- const getFactoType1Question = () => {
17
- const affines = affine_1.AffineConstructor.differentRandoms(3);
18
+ const getStatementNode = (identifiers) => {
19
+ const { affinesCoeffs, operation } = identifiers;
20
+ const affines = affinesCoeffs.map((coeffs) => new affine_1.Affine(coeffs[1], coeffs[0]));
18
21
  const permut = [
19
22
  (0, shuffle_1.shuffle)([affines[0], affines[1]]),
20
23
  (0, shuffle_1.shuffle)([affines[0], affines[2]]),
21
24
  ];
22
- const operation = (0, random_1.random)(["add", "substract"]);
23
25
  const statementTree = operation === "add"
24
26
  ? new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(permut[0][0].toTree(), permut[0][1].toTree()), new multiplyNode_1.MultiplyNode(permut[1][0].toTree(), permut[1][1].toTree()))
25
27
  : new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(permut[0][0].toTree(), permut[0][1].toTree()), new multiplyNode_1.MultiplyNode(permut[1][0].toTree(), permut[1][1].toTree()));
26
- const affine1 = affines[0];
27
- const affine2 = affines[1].add(operation === "add" ? affines[2] : affines[2].opposite());
28
+ return statementTree;
29
+ };
30
+ const getInstruction = (identifiers) => {
31
+ const { affinesCoeffs, operation } = identifiers;
32
+ return `Factoriser et réduire :
33
+
34
+ $$
35
+ ${getStatementNode(identifiers).toTex()}
36
+ $$`;
37
+ };
38
+ const getAnswer = (identifiers) => {
39
+ const { affinesCoeffs, operation } = identifiers;
40
+ const affine1 = new affine_1.Affine(affinesCoeffs[0][1], affinesCoeffs[0][0]);
41
+ const affine2 = new affine_1.Affine(affinesCoeffs[1][1], affinesCoeffs[1][0]);
28
42
  const answerTree = affine2.coefficients[0] === 0
29
43
  ? affine1.coefficients[0] === 0
30
44
  ? affine1.multiply(affine2).toTree()
31
45
  : new multiplyNode_1.MultiplyNode(affine2.toTree(), affine1.toTree())
32
46
  : new multiplyNode_1.MultiplyNode(affine1.toTree(), affine2.toTree());
33
- const answer = answerTree.toTex();
47
+ const answer = answerTree.simplify().toTex();
48
+ return answer;
49
+ };
50
+ const getFactoType1Question = () => {
51
+ const a = (0, randint_1.randint)(-9, 10, [0]);
52
+ const b = (0, randint_1.randint)(-9, 10, [0]);
53
+ const operation = (0, random_1.random)(["add", "substract"]);
54
+ let c, d;
55
+ let e, f;
56
+ do {
57
+ c = (0, randint_1.randint)(-9, 10, [0]);
58
+ d = (0, randint_1.randint)(-9, 10, [0]);
59
+ e = (0, randint_1.randint)(-9, 10, [0]);
60
+ f = (0, randint_1.randint)(-9, 10, [0]);
61
+ } while (c / a === d / b || e / a === f / b);
62
+ const identifiers = {
63
+ affinesCoeffs: [
64
+ [a, b],
65
+ [c, d],
66
+ [e, f],
67
+ ],
68
+ operation,
69
+ };
34
70
  const question = {
35
- instruction: `Factoriser et réduire :
36
-
37
- $$
38
- ${statementTree.toTex()}
39
- $$`,
40
- startStatement: statementTree.toTex(),
41
- answer,
71
+ instruction: getInstruction(identifiers),
72
+ startStatement: getStatementNode(identifiers).toTex(),
73
+ answer: getAnswer(identifiers),
42
74
  keys: ["x"],
43
75
  answerFormat: "tex",
44
- identifiers: {
45
- affinesCoeffs: affines.map((affine) => affine.coefficients),
46
- operation,
47
- },
76
+ identifiers,
48
77
  };
49
78
  return question;
50
79
  };
@@ -67,17 +96,20 @@ const getPropositions = (n, { answer, affinesCoeffs, operation }) => {
67
96
  }
68
97
  return (0, shuffle_1.shuffle)(propositions);
69
98
  };
70
- const isAnswerValid = (ans, { affinesCoeffs, operation }) => {
71
- const affines = affinesCoeffs.map((coeffs) => new affine_1.Affine(coeffs[1], coeffs[0]));
72
- const affine1 = affines[0];
73
- const affine2 = affines[1].add(operation === "add" ? affines[2] : affines[2].opposite());
74
- const answerTree = affine2.coefficients[0] === 0
75
- ? affine1.coefficients[0] === 0
76
- ? affine1.multiply(affine2).toTree()
77
- : new multiplyNode_1.MultiplyNode(affine2.toTree(), affine1.toTree())
78
- : new multiplyNode_1.MultiplyNode(affine1.toTree(), affine2.toTree());
79
- const validLatexs = answerTree.toAllValidTexs();
80
- return validLatexs.includes(ans);
99
+ const isAnswerValid = (ans, { affinesCoeffs, operation, answer }) => {
100
+ try {
101
+ const parsed = (0, latexParser_1.parseAlgebraic)(ans);
102
+ if (!parsed)
103
+ return false;
104
+ if (!(0, multiplyNode_1.isMultiplyNode)(parsed))
105
+ return false;
106
+ const simp = parsed.simplify();
107
+ const reversed = parsed.toReversed().simplify();
108
+ return simp.toTex() === answer || reversed.toTex() === answer;
109
+ }
110
+ catch (err) {
111
+ return false;
112
+ }
81
113
  };
82
114
  exports.factoType1Exercise = {
83
115
  id: "facto1",
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAe3C,cAAc;AAEd,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA2JF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqBtE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAe3C,cAAc;AAEd,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA6JF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqBtE,CAAC"}
@@ -23,7 +23,9 @@ const getCorrection = (identifiers, opts) => {
23
23
  const answer = getAnswer(identifiers, opts);
24
24
  return `On isole $x$ à gauche en ${identifiers.b > 0 ? "soustrayant" : "additionnant"} les deux côtés de l'inéquation par $${Math.abs(identifiers.b)}$:
25
25
 
26
+ $$
26
27
  ${(0, inequationNode_1.firstDegreeInequationResolutionTex)(new affine_1.Affine(1, identifiers.b), identifiers.ineqType, identifiers.c.toTree())}
28
+ $$
27
29
 
28
30
  ${isInterval
29
31
  ? `On traduit ensuite cette inéquation en intervalle :
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA8KF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBtE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAgLF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBtE,CAAC"}
@@ -25,7 +25,9 @@ const getCorrection = (identifiers, opts) => {
25
25
  const answer = getAnswer(identifiers, opts);
26
26
  return `On isole $x$ à gauche en divisant les deux côtés de l'inéquation par $${identifiers.a}$:
27
27
 
28
+ $$
28
29
  ${(0, inequationNode_1.firstDegreeInequationResolutionTex)(new affine_1.Affine(a, 0), ineqType, b.toTree())}
30
+ $$
29
31
 
30
32
  ${identifiers.a < 0
31
33
  ? `On a changé le sens de l'inéquation, car $${a}$ est négatif.`
@@ -73,7 +73,7 @@ const isAnswerValid = (ans, { answer, askConvex, quadcoeffs }) => {
73
73
  };
74
74
  exports.convexityQuadrinomials = {
75
75
  id: "convexityQuadrinomials",
76
- label: "Convexité des fonctions polynomiales de degré 3",
76
+ label: "Convexité des fonctions polynomiales de degré $3$",
77
77
  levels: ["TermSpé"],
78
78
  isSingleStep: true,
79
79
  sections: ["Dérivation"],
@@ -1 +1 @@
1
- {"version":3,"file":"expDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwFF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
1
+ {"version":3,"file":"expDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
@@ -50,11 +50,9 @@ const getPropositions = (n, { answer, a, b }) => {
50
50
  };
51
51
  const isAnswerValid = (ans, { a, b, answer }) => {
52
52
  try {
53
- console.log(ans, answer);
54
53
  const parsed = (0, latexParser_1.parseAlgebraic)(ans);
55
54
  if (!parsed)
56
55
  return false;
57
- console.log(parsed.simplify().toTex());
58
56
  return parsed.simplify().toTex() === answer;
59
57
  }
60
58
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"quotientDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/quotientDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAoHF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAcpD,CAAC"}
1
+ {"version":3,"file":"quotientDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/quotientDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAuGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAcpD,CAAC"}
@@ -71,17 +71,6 @@ const getPropositions = (n, { answer, poly1Coeffs, poly2Coeffs }) => {
71
71
  return (0, exercise_1.shuffleProps)(propositions, n);
72
72
  };
73
73
  const isAnswerValid = (ans, { answer, poly1Coeffs, poly2Coeffs }) => {
74
- // const poly1 = new Polynomial(poly1Coeffs);
75
- // const poly2 = new Polynomial(poly2Coeffs);
76
- // const answerNum = poly1
77
- // .derivate()
78
- // .multiply(poly2)
79
- // .add(poly1.opposite().multiply(poly2.derivate()))
80
- // .toTree({ forbidPowerToProduct: true });
81
- // const answerDenum = new PowerNode(poly2.toTree(), new NumberNode(2));
82
- // const answer = new FractionNode(answerNum, answerDenum);
83
- // const texs = answer.toAllValidTexs();
84
- // return texs.includes(ans);
85
74
  try {
86
75
  const parsed = (0, latexParser_1.parseAlgebraic)(ans);
87
76
  const simp = parsed
@@ -91,8 +80,6 @@ const isAnswerValid = (ans, { answer, poly1Coeffs, poly2Coeffs }) => {
91
80
  const simpAnswer = parsedAnswer
92
81
  .simplify({ keepPowers: true, forbidFactorize: true })
93
82
  .toTex();
94
- console.log(answer);
95
- console.log(simp);
96
83
  return simp === simpAnswer;
97
84
  }
98
85
  catch (err) {
@@ -94,7 +94,7 @@ exports.isSecondDegreeDerivativeAnswerValid = isSecondDegreeDerivativeAnswerVali
94
94
  exports.secondDegreeDerivative = {
95
95
  id: "secondDegreeDerivative",
96
96
  connector: "=",
97
- label: "Dérivée d'un polynôme de degré 2",
97
+ label: "Dérivée d'un polynôme de degré $2$",
98
98
  levels: [
99
99
  "1reESM",
100
100
  "1reSpé",
@@ -47,7 +47,7 @@ const isAnswerValid = (ans, { a, b, c, d }) => {
47
47
  };
48
48
  exports.secondDerivativeOfThridDegreeFunction = {
49
49
  id: "secondDerivativeOfThirdDegreeFunction",
50
- label: "Dérivée seconde d'un polynôme de degré 3",
50
+ label: "Dérivée seconde d'un polynôme de degré $3$",
51
51
  levels: ["TermSpé"],
52
52
  isSingleStep: true,
53
53
  sections: ["Dérivation"],
@@ -111,7 +111,7 @@ exports.isThirdDegreeDerivativeAnswerValid = isThirdDegreeDerivativeAnswerValid;
111
111
  exports.thirdDegreeDerivative = {
112
112
  id: "thirdDegreeDerivative",
113
113
  connector: "=",
114
- label: "Dérivée d'un polynôme de degré 3",
114
+ label: "Dérivée d'un polynôme de degré $3$",
115
115
  levels: [
116
116
  "1reESM",
117
117
  "1reSpé",
@@ -78,9 +78,9 @@ $$
78
78
  ${firstIntersec
79
79
  ? `ce qui donne :
80
80
 
81
- $$
82
- x=${firstIntersec?.toTex()}
83
- $$`
81
+ $$
82
+ x=${firstIntersec?.toTex()}
83
+ $$`
84
84
  : "qui n'a pas de solution, "}
85
85
 
86
86
  et d'autre part :
@@ -1 +1 @@
1
- {"version":3,"file":"signFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/signFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAmBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AA8HF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAe9C,CAAC"}
1
+ {"version":3,"file":"signFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/signFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAmBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAgIF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAe9C,CAAC"}
@@ -31,7 +31,9 @@ const getCorrection = (identifiers) => {
31
31
  const order = askingPositive ? "\\ge" : "\\le";
32
32
  return `On résout l'inéquation :
33
33
 
34
+ $$
34
35
  ${(0, inequationNode_1.firstDegreeInequationResolutionTex)(affine, order, (0).toTree())}
36
+ $$
35
37
 
36
38
  On en conclut que $f$ est ${identifiers.askingPositive ? "positive" : "négative"} sur l'intervalle :
37
39
 
@@ -4,6 +4,7 @@ type Identifiers = {
4
4
  poly1: number[];
5
5
  poly2: number[];
6
6
  xValue: number;
7
+ flip: boolean;
7
8
  };
8
9
  export declare const imageFunction: Exercise<Identifiers>;
9
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"imageFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAOlC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAsDF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAa/C,CAAC"}
1
+ {"version":3,"file":"imageFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAqGF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAkB/C,CAAC"}
@@ -5,8 +5,51 @@ const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
6
  const polynomial_1 = require("../../../../math/polynomials/polynomial");
7
7
  const randint_1 = require("../../../../math/utils/random/randint");
8
+ const latexParser_1 = require("../../../../tree/parsers/latexParser");
8
9
  const coinFlip_1 = require("../../../../utils/alea/coinFlip");
9
10
  const shuffle_1 = require("../../../../utils/alea/shuffle");
11
+ const alignTex_1 = require("../../../../utils/latex/alignTex");
12
+ const getInstruction = (identifiers) => {
13
+ const { rand, poly1, poly2, xValue, flip } = identifiers;
14
+ const polynome1 = new polynomial_1.Polynomial(poly1);
15
+ const polynome2 = new polynomial_1.Polynomial(poly2);
16
+ const statement = `Soit $f(x) = ${(rand ? polynome1 : polynome2)
17
+ .toTree()
18
+ .toTex()}$.
19
+
20
+ Calculer ${flip ? `l'image de $${xValue}$ par $f$.` : `$f(${xValue})$.`}`;
21
+ return statement;
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ const { rand, poly1, poly2, xValue } = identifiers;
25
+ const polynome1 = new polynomial_1.Polynomial(poly1);
26
+ const polynome2 = new polynomial_1.Polynomial(poly2);
27
+ const answer = rand
28
+ ? polynome1.calculate(xValue) + ""
29
+ : polynome2.calculate(xValue) + "";
30
+ return answer;
31
+ };
32
+ const getHint = (identifiers) => {
33
+ return `Remplace $x$ par $${identifiers.xValue}$ dans l'expression de $f$.`;
34
+ };
35
+ const getCorrection = (identifiers) => {
36
+ const answer = getAnswer(identifiers);
37
+ const { rand, poly1, poly2, xValue, flip } = identifiers;
38
+ const polynome1 = new polynomial_1.Polynomial(poly1).toTree();
39
+ const polynome2 = new polynomial_1.Polynomial(poly2).toTree();
40
+ return `On remplace $x$ par $${identifiers.xValue}$ dans l'expression de $f$ :
41
+
42
+ ${(0, alignTex_1.alignTex)([
43
+ [
44
+ `f\\left(${identifiers.xValue}\\right)`,
45
+ "=",
46
+ rand
47
+ ? polynome1.toDetailedEvaluation({ x: xValue.toTree() }).toTex()
48
+ : polynome2.toDetailedEvaluation({ x: xValue.toTree() }).toTex(),
49
+ ],
50
+ ["", "=", answer],
51
+ ])}`;
52
+ };
10
53
  const getImageFunction = () => {
11
54
  const rand = (0, coinFlip_1.coinFlip)();
12
55
  const polynome1 = new polynomial_1.Polynomial([(0, randint_1.randint)(-9, 10), (0, randint_1.randint)(-5, 6, [0])]);
@@ -17,24 +60,22 @@ const getImageFunction = () => {
17
60
  ]);
18
61
  const xValue = (0, randint_1.randint)(-9, 10);
19
62
  const flip = (0, coinFlip_1.coinFlip)();
20
- const statement = `Soit $f(x) = ${(rand ? polynome1 : polynome2)
21
- .toTree()
22
- .toTex()}$. Calculer ${flip ? `l'image de $${xValue}$ par $f$.` : `$f(${xValue})$.`}`;
23
- const answer = rand
24
- ? polynome1.calculate(xValue) + ""
25
- : polynome2.calculate(xValue) + "";
63
+ const identifiers = {
64
+ poly1: polynome1.coefficients,
65
+ poly2: polynome2.coefficients,
66
+ rand,
67
+ xValue,
68
+ flip,
69
+ };
26
70
  const question = {
27
- instruction: statement,
71
+ instruction: getInstruction(identifiers),
28
72
  startStatement: `f(${xValue})`,
29
- answer: answer,
73
+ answer: getAnswer(identifiers),
30
74
  keys: [],
75
+ hint: getHint(identifiers),
76
+ correction: getCorrection(identifiers),
31
77
  answerFormat: "tex",
32
- identifiers: {
33
- poly1: polynome1.coefficients,
34
- poly2: polynome2.coefficients,
35
- rand,
36
- xValue,
37
- },
78
+ identifiers,
38
79
  };
39
80
  return question;
40
81
  };
@@ -48,7 +89,15 @@ const getPropositions = (n, { answer }) => {
48
89
  return (0, shuffle_1.shuffle)(propositions);
49
90
  };
50
91
  const isAnswerValid = (ans, { answer }) => {
51
- return answer === ans;
92
+ try {
93
+ const parsed = (0, latexParser_1.parseAlgebraic)(ans);
94
+ if (!parsed)
95
+ return false;
96
+ return parsed.simplify().toTex() === answer;
97
+ }
98
+ catch (err) {
99
+ return false;
100
+ }
52
101
  };
53
102
  exports.imageFunction = {
54
103
  id: "imageFunction",
@@ -63,4 +112,9 @@ exports.imageFunction = {
63
112
  getPropositions,
64
113
  isAnswerValid,
65
114
  subject: "Mathématiques",
115
+ getAnswer,
116
+ getCorrection,
117
+ getHint,
118
+ hasHintAndCorrection: true,
119
+ getInstruction,
66
120
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extractPointFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/extractPointFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAwHF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAiBhE,CAAC"}
1
+ {"version":3,"file":"extractPointFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/extractPointFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAwHF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAkBhE,CAAC"}
@@ -106,4 +106,5 @@ exports.extractPointFromParametricLine = {
106
106
  getCorrection,
107
107
  getAnswer,
108
108
  hasHintAndCorrection: true,
109
+ getInstruction,
109
110
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extractVectorFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/extractVectorFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA6GF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAgBjE,CAAC"}
1
+ {"version":3,"file":"extractVectorFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/extractVectorFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA6GF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAiBjE,CAAC"}
@@ -105,4 +105,5 @@ exports.extractVectorFromParametricLine = {
105
105
  // getHint,
106
106
  // getCorrection,
107
107
  getAnswer,
108
+ getInstruction,
108
109
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pointFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/pointFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAqFF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAkBzD,CAAC"}
1
+ {"version":3,"file":"pointFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/pointFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAqFF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAmBzD,CAAC"}
@@ -92,4 +92,5 @@ exports.pointFromParametricLine = {
92
92
  getAnswer,
93
93
  getKeys,
94
94
  answerType: "QCU",
95
+ getInstruction,
95
96
  };
@@ -16,7 +16,7 @@ const getAnswer = (identifiers) => {
16
16
  return correctAnswer.simplify().toTex();
17
17
  };
18
18
  const getHint = (identifiers) => {
19
- return `La norme d'un vecteur est la racine carrée de la somme des carrés de ses coordonnées. En d'autres termes, la norme du vecteur $$\\overrightarrow{u}\\begin{pmatrix}x\\\\y\\end{pmatrix}$$ est :
19
+ return `La norme d'un vecteur est la racine carrée de la somme des carrés de ses coordonnées. En d'autres termes, la norme du vecteur $$\\overrightarrow{u}\\begin{pmatrix}x \\\\ y \\end{pmatrix}$$ est :
20
20
 
21
21
  $$
22
22
  \\lVert \\overrightarrow u \\rVert = \\sqrt{x^2+y^2}
@@ -1 +1 @@
1
- {"version":3,"file":"evolutionToCM.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/evolutionToCM.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAuEF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAc/C,CAAC"}
1
+ {"version":3,"file":"evolutionToCM.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/evolutionToCM.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAkGF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAkB/C,CAAC"}
@@ -6,28 +6,50 @@ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQues
6
6
  const randint_1 = require("../../../math/utils/random/randint");
7
7
  const round_1 = require("../../../math/utils/round");
8
8
  const numberParser_1 = require("../../../tree/parsers/numberParser");
9
- const getEvolutionToCmQuestion = () => {
10
- const evolution = (0, randint_1.randint)(-99, 101, [0]);
9
+ const getInstruction = (identifiers) => {
10
+ const evolution = identifiers.evolution;
11
+ const isHausse = evolution > 0;
12
+ return `Quel est le coefficient multiplicateur associé à une ${isHausse ? "hausse" : "baisse"} de $${isHausse ? evolution : evolution.toString().slice(1)}\\%$ ?`;
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const evolution = identifiers.evolution;
11
16
  const isHausse = evolution > 0;
12
17
  const CM = ((0, round_1.round)(1 + evolution / 100, 2) + "").replaceAll(".", ",");
13
18
  const answer = CM;
14
- const question = {
15
- answer: answer,
16
- instruction: `Quel est le coefficient multiplicateur associé à une ${isHausse ? "hausse" : "baisse"} de $${isHausse ? evolution : evolution.toString().slice(1)}\\%$ ?`,
17
- keys: ["percent"],
18
- answerFormat: "tex",
19
- identifiers: { evolution },
20
- hint: `Le coefficient multiplicateur associé à une ${isHausse ? "hausse" : "baisse"} de $t\\%$ est donné par $${isHausse ? "1+\\frac{t}{100}" : "1-\\frac{t}{100}"}$.
21
- `,
22
- correction: `Le coefficient multiplicateur associé à une ${isHausse ? "hausse" : "baisse"} de $t\\%$ est donné par $${isHausse ? "1+\\frac{t}{100}" : "1-\\frac{t}{100}"}$.
19
+ return answer;
20
+ };
21
+ const getHint = (identifiers) => {
22
+ const evolution = identifiers.evolution;
23
+ const isHausse = evolution > 0;
24
+ return `Le coefficient multiplicateur associé à une ${isHausse ? "hausse" : "baisse"} de $t\\%$ est donné par $${isHausse ? "1+\\frac{t}{100}" : "1-\\frac{t}{100}"}$.
25
+ `;
26
+ };
27
+ const getCorrection = (identifiers) => {
28
+ const evolution = identifiers.evolution;
29
+ const isHausse = evolution > 0;
30
+ const CM = ((0, round_1.round)(1 + evolution / 100, 2) + "").replaceAll(".", ",");
31
+ return `Le coefficient multiplicateur associé à une ${isHausse ? "hausse" : "baisse"} de $t\\%$ est donné par $${isHausse ? "1+\\frac{t}{100}" : "1-\\frac{t}{100}"}$.
23
32
 
24
- Ici, on a $t = ${Math.abs(evolution)}$\\%, donc le coefficient multiplicateur vaut :
33
+ Ici, on a $t = ${Math.abs(evolution)}\\%$, donc le coefficient multiplicateur vaut :
25
34
 
26
35
  $$
27
36
  1${isHausse ? "+" : "-"}\\frac{${Math.abs(evolution)}}{100} = ${CM}
28
37
  $$
29
38
 
30
- `,
39
+ `;
40
+ };
41
+ const getEvolutionToCmQuestion = () => {
42
+ const evolution = (0, randint_1.randint)(-99, 101, [0]);
43
+ const isHausse = evolution > 0;
44
+ const identifiers = { evolution };
45
+ const question = {
46
+ answer: getAnswer(identifiers),
47
+ instruction: getInstruction(identifiers),
48
+ keys: ["percent"],
49
+ answerFormat: "tex",
50
+ identifiers,
51
+ hint: getHint(identifiers),
52
+ correction: getCorrection(identifiers),
31
53
  };
32
54
  return question;
33
55
  };
@@ -60,4 +82,8 @@ exports.evolutionToCM = {
60
82
  isAnswerValid,
61
83
  subject: "Mathématiques",
62
84
  hasHintAndCorrection: true,
85
+ getCorrection,
86
+ getInstruction,
87
+ getAnswer,
88
+ getHint,
63
89
  };
@@ -116,7 +116,7 @@ exports.powersDivision = {
116
116
  exports.powersOfTenDivision = {
117
117
  id: "powersOfTenDivision",
118
118
  connector: "=",
119
- label: "Division de puissances de 10",
119
+ label: "Division de puissances de $10$",
120
120
  levels: ["4ème", "3ème", "2nde"],
121
121
  sections: ["Puissances"],
122
122
  isSingleStep: true,
@@ -46,7 +46,7 @@ const isAnswerValid = (ans, { answer }) => {
46
46
  exports.powersOfTenToDecimal = {
47
47
  id: "powersOfTenToDecimal",
48
48
  connector: "=",
49
- label: "Ecriture décimale d'une puissance de 10",
49
+ label: "Ecriture décimale d'une puissance de $10$",
50
50
  levels: [
51
51
  "5ème",
52
52
  "4ème",
@@ -64,7 +64,7 @@ const isAnswerValid = (ans, { a, b, c }) => {
64
64
  exports.powersOfTenPower = {
65
65
  id: "powersOfTenPower",
66
66
  connector: "=",
67
- label: "Puissance d'une puissance de 10 ",
67
+ label: "Puissance d'une puissance de $10$ ",
68
68
  levels: [
69
69
  "4ème",
70
70
  "3ème",
@@ -108,7 +108,7 @@ const isAnswerValid = (ans, { a, b, c }) => {
108
108
  exports.powersOfTenProduct = {
109
109
  id: "powersOfTenProduct",
110
110
  connector: "=",
111
- label: "Multiplication de puissances de 10",
111
+ label: "Multiplication de puissances de $10$",
112
112
  levels: [
113
113
  "4ème",
114
114
  "3ème",
@@ -55,7 +55,7 @@ const isAnswerValid = (ans, { answer }) => {
55
55
  };
56
56
  exports.conditionIf = {
57
57
  id: "conditionIf",
58
- label: "Condition if 1",
58
+ label: "Condition if $1$",
59
59
  levels: ["2nde"],
60
60
  isSingleStep: true,
61
61
  sections: ["Python"],
@@ -77,7 +77,7 @@ const isAnswerValid = (ans, { answer }) => {
77
77
  };
78
78
  exports.forLoop = {
79
79
  id: "forLoop",
80
- label: "Boucle for 2",
80
+ label: "Boucle for $2$",
81
81
  levels: ["2nde"],
82
82
  isSingleStep: true,
83
83
  sections: ["Python"],
@@ -58,7 +58,7 @@ const isAnswerValid = (ans, { answer }) => {
58
58
  };
59
59
  exports.inOutCalcul = {
60
60
  id: "inOutCalcul",
61
- label: "Attribution de variables 1",
61
+ label: "Attribution de variables $1$",
62
62
  levels: ["2nde"],
63
63
  isSingleStep: true,
64
64
  sections: ["Python"],
@@ -131,7 +131,7 @@ const isAnswerValid = (ans, { exercise }) => {
131
131
  };
132
132
  exports.pythonForLoop1Exercise = {
133
133
  id: "pyForLoop1Exercise",
134
- label: "Boucles for 1",
134
+ label: "Boucles for $1$",
135
135
  levels: ["2nde"],
136
136
  isSingleStep: true,
137
137
  sections: ["Python"],
@@ -52,7 +52,7 @@ const generateExercise = () => {
52
52
  n,
53
53
  p,
54
54
  };
55
- const instruction = `Quaffichera le programme suivant ?
55
+ const instruction = `Qu'affichera le programme suivant ?
56
56
  \`\`\`
57
57
  s=0
58
58
  n=${n}
@@ -101,7 +101,7 @@ const generateType17Instruction = (a, b, op) => {
101
101
  };
102
102
  exports.pyWhileLoop1Exercise = {
103
103
  id: "pyWhileLoop1Exercise",
104
- label: "Boucles while 1",
104
+ label: "Boucles while $1$",
105
105
  levels: ["2nde"],
106
106
  isSingleStep: true,
107
107
  sections: ["Python"],
@@ -65,7 +65,7 @@ const isAnswerValid = (ans, { answer }) => {
65
65
  };
66
66
  exports.whileLoop = {
67
67
  id: "whileLoop",
68
- label: "Boucle while 2",
68
+ label: "Boucle while $2$",
69
69
  levels: ["2nde"],
70
70
  isSingleStep: true,
71
71
  sections: ["Python"],
@@ -15,9 +15,9 @@ const getpH = () => {
15
15
  const answer = (0, frenchify_1.frenchify)((0, round_1.round)(-Math.log10(concentrationHydrogene), 1));
16
16
  const hint = "Utilisez la formule du pH : $\\text{pH} = -\\log[H^+]$.";
17
17
  const correction = `Pour calculer le pH, on utilise la formule $\\text{pH} = -\\log[H^+]$ :
18
- \n1. La concentration en ions hydrogène est $${randomNumber} \\times 10^{-${randomTenPower}}$ mol/L.
19
- \n2. En appliquant la formule, on obtient $\\text{pH} = -\\log(${randomNumber} \\times 10^{-${randomTenPower}})$.
20
- \n3. Le résultat est $${answer}$.`;
18
+ \n$1$. La concentration en ions hydrogène est $${randomNumber} \\times 10^{-${randomTenPower}}$ mol/L.
19
+ \n$2$. En appliquant la formule, on obtient $\\text{pH} = -\\log(${randomNumber} \\times 10^{-${randomTenPower}})$.
20
+ \n$3$. Le résultat est $${answer}$.`;
21
21
  const question = {
22
22
  instruction,
23
23
  startStatement: `pH`,
package/lib/index.d.ts CHANGED
@@ -678,6 +678,7 @@ declare const mathExercises: (Exercise<{
678
678
  poly1: number[];
679
679
  poly2: number[];
680
680
  xValue: number;
681
+ flip: boolean;
681
682
  }, {}> | Exercise<{
682
683
  isSpline: boolean;
683
684
  splinePoints: number[][];
@@ -1 +1 @@
1
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+ {"version":3,"file":"latexTester.d.ts","sourceRoot":"","sources":["../src/latexTester.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,2CA+FxC,CAAC"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.latexTester = void 0;
4
+ const latexTester = (latex, isDefaultInMathMode = false) => {
5
+ let inDollarMode = isDefaultInMathMode ?? false;
6
+ let inDoubleDollarMode = isDefaultInMathMode ?? false;
7
+ let commandModeCount = 0;
8
+ let leftRightCount = 0;
9
+ let inArray = false;
10
+ for (let i = 0; i < latex.length; i++) {
11
+ const prevChar = latex[i - 1];
12
+ const char = latex[i];
13
+ const nextChar = latex[i + 1];
14
+ if (char === "$") {
15
+ if (isDefaultInMathMode)
16
+ throw new Error("Dollar in default math mode");
17
+ if (nextChar === "$") {
18
+ if (inDollarMode)
19
+ throw new Error("Double dollar instead of single");
20
+ inDoubleDollarMode = !inDoubleDollarMode;
21
+ i++;
22
+ }
23
+ else {
24
+ if (inDoubleDollarMode)
25
+ throw new Error("Single dollar instead of double");
26
+ inDollarMode = !inDollarMode;
27
+ }
28
+ }
29
+ else {
30
+ //check si nombre dans latex
31
+ if (!isNaN(Number(char)) &&
32
+ char !== " " &&
33
+ char !== "\n" &&
34
+ char !== "\t") {
35
+ if (!inDollarMode && !inDoubleDollarMode) {
36
+ throw new Error(`Number not in math mode, ${char}, ${latex}`);
37
+ }
38
+ }
39
+ //check si charactere spécial
40
+ if (mustEscapeCharacters.includes(char) && prevChar !== "\\") {
41
+ throw new Error("Must escape character");
42
+ }
43
+ //check si in math
44
+ if (mustBeInMath.includes(char) && !inDollarMode && !inDoubleDollarMode) {
45
+ throw new Error(`Must be in math mode, ${char}, ${latex}`);
46
+ }
47
+ //check si commande bien fermé
48
+ if (char === "{" && prevChar !== "\\") {
49
+ commandModeCount++;
50
+ }
51
+ if (char === "}" && prevChar !== "\\") {
52
+ commandModeCount--;
53
+ }
54
+ const substring = latex.substring(i);
55
+ if ((inDollarMode || inDoubleDollarMode) && char === "\n") {
56
+ let isEmptyLine = true;
57
+ for (let j = i + 1; j < latex.length; j++) {
58
+ if (latex[j] === "\n")
59
+ break;
60
+ if (latex[j] !== " " && latex[j] !== "\t") {
61
+ isEmptyLine = false;
62
+ break;
63
+ }
64
+ }
65
+ if (isEmptyLine)
66
+ throw new Error(`New emtpy line in math mode, ${latex}`);
67
+ }
68
+ //check si command existe
69
+ const cmdMatch = substring.match(/^\\[a-zA-Z]+/);
70
+ if (cmdMatch?.length) {
71
+ const cmd = cmdMatch[0];
72
+ if (!validCmds.includes(cmd))
73
+ throw new Error(`Command not valid, ${cmd}`);
74
+ if (cmd === "\\left") {
75
+ leftRightCount++;
76
+ }
77
+ if (cmd === "\\right") {
78
+ leftRightCount--;
79
+ }
80
+ }
81
+ //!Todo check si whitespace after double dollar
82
+ //!TODO Check si a^b^c ou a_b_c
83
+ //!Todo check si &, tabularnewline et hline sont bien dans tableaux
84
+ }
85
+ }
86
+ if (!isDefaultInMathMode && (inDollarMode || inDoubleDollarMode))
87
+ throw new Error(`Math mode not finished`);
88
+ if (leftRightCount !== 0)
89
+ throw new Error("Left right not balanced");
90
+ if (commandModeCount !== 0)
91
+ throw new Error(`Command not closed : ${latex}`);
92
+ return true;
93
+ };
94
+ exports.latexTester = latexTester;
95
+ const mustEscapeCharacters = ["%", "`"];
96
+ const mustBeInMath = ["%", "#", "_", "~", "^"];
97
+ const mustBeInArrays = ["&", "\\tabularnewline", "\\hline"];
98
+ const validCmds = [
99
+ "\\frac",
100
+ "\\exp",
101
+ "\\cos",
102
+ "\\arccos",
103
+ "\\sin",
104
+ "\\arcsin",
105
+ "\\tan",
106
+ "\\arctan",
107
+ "\\sqrt",
108
+ "\\log",
109
+ "\\ln",
110
+ "\\lim",
111
+ "\\in",
112
+ "\\belongs",
113
+ "\\text",
114
+ "\\int",
115
+ "\\circ",
116
+ "\\overrightarrow",
117
+ "\\le",
118
+ "\\ge",
119
+ "\\leq",
120
+ "\\geq",
121
+ "\\pi",
122
+ "\\infty",
123
+ "\\binom",
124
+ "\\left",
125
+ "\\right",
126
+ "\\alpha",
127
+ "\\beta",
128
+ "\\Delta",
129
+ "\\delta",
130
+ "\\theta",
131
+ "\\sigma",
132
+ "\\Theta",
133
+ "\\pm",
134
+ "\\times",
135
+ "\\div",
136
+ "\\cdot",
137
+ "\\ldots",
138
+ "\\begin",
139
+ "\\end",
140
+ "\\\\",
141
+ "\\arraystretch",
142
+ "\\def",
143
+ "\\tabularnewline",
144
+ "\\approx",
145
+ "\\lbrace",
146
+ "\\rbrace",
147
+ "\\varnothing",
148
+ "\\iff",
149
+ "\\neq",
150
+ "\\widehat",
151
+ "\\cup",
152
+ "\\cap",
153
+ "\\mathbb",
154
+ "\\to",
155
+ "\\newline",
156
+ "\\lVert",
157
+ "\\rVert",
158
+ "\\hline",
159
+ "\\mathrm",
160
+ "\\overline",
161
+ "\\quad",
162
+ "\\qquad",
163
+ "\\rightarrow",
164
+ ];
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,UAAU,YAAW,CAAC"}
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,UAAU,YAStB,CAAC"}
package/lib/playground.js CHANGED
@@ -2,7 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.playground = void 0;
4
4
  const nodeConstructor_1 = require("./tree/nodes/nodeConstructor");
5
- const playground = () => { };
5
+ const latexTester_1 = require("./latexTester");
6
+ const playground = () => {
7
+ const a = `
8
+ ijfezo
9
+ $$
10
+ \\frac{3^{2x+2}}{3}
11
+ $$
12
+ ad
13
+ `;
14
+ console.log((0, latexTester_1.latexTester)(a));
15
+ };
6
16
  exports.playground = playground;
7
17
  const logIdentifiers = () => {
8
18
  const ids = '{"xA":-3,"yA":-2,"yPrimeA":{"id":31,"child":{"id":3,"leftChild":{"id":7,"value":3},"rightChild":{"id":7,"value":2}}},"trinomCoeffs":[0.3888888888888889,0.833333333333333,-3]}';
@@ -148,6 +148,6 @@ const firstDegreeInequationResolutionTex = (affine, order, right) => {
148
148
  (0, fractionNode_1.frac)((0, substractNode_1.substract)(right, b), a).simplify().toTex(),
149
149
  ]);
150
150
  }
151
- return (0, alignTex_1.alignTex)(steps);
151
+ return (0, alignTex_1.alignTex)(steps, true);
152
152
  };
153
153
  exports.firstDegreeInequationResolutionTex = firstDegreeInequationResolutionTex;
@@ -1 +1 @@
1
- {"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWlE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAED,eAAO,MAAM,GAAG,MACX,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,YAOnC,CAAC;AAEF,qBAAa,OAAQ,YAAW,uBAAuB;IACrD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IASpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;I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AAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IASpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;IAItB,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAoCtD,SAAS,IAAI,MAAM,EAAE;IAIrB,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAK5C,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAerC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA4I/C,aAAa;;;;;;;;;IAOb,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAUpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAMxD"}
@@ -188,6 +188,15 @@ class AddNode {
188
188
  i--;
189
189
  j--;
190
190
  }
191
+ //!ca a l'air bien mais faut vérifier pour tous les exos...
192
+ // else if (isNumberNode(left) && isNumberNode(right)) {
193
+ // const pgcd = gcd(left.value, right.value);
194
+ // if (pgcd !== 1) {
195
+ // factors.push(pgcd.toTree());
196
+ // aSubExternals.splice(i, 1, new NumberNode(left.value / pgcd));
197
+ // bSubExternals.splice(j, 1, new NumberNode(right.value / pgcd));
198
+ // }
199
+ // }
191
200
  }
192
201
  }
193
202
  //si aucun facteur on return
@@ -13,6 +13,7 @@ export declare class MultiplyNode implements CommutativeOperatorNode {
13
13
  isNumeric: boolean;
14
14
  constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
15
15
  shuffle: () => void;
16
+ toReversed: () => MultiplyNode;
16
17
  toMathString(): string;
17
18
  toTex(options?: ToTexOptions): string;
18
19
  toAllTexs(): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAAM,kBAAkB,CAAC;AAU1B,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,QAAQ,MAChB,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AACF,eAAO,MAAM,iBAAiB,QAAS,aAAa,EAAE,SAYrD,CAAC;AACF,qBAAa,YAAa,YAAW,uBAAuB;IAC1D,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAgFrC,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAyFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,aAAa;;;;;;;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aAGL;IACF,UAAU,qBAER;IACF,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAgFrC,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAyFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,aAAa;;;;;;;;;IAYb,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAItC,IAAI;IAGJ,cAAc;IACd,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAqK/C,MAAM,CAAC,IAAI,EAAE,aAAa;IAU1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAQxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAMxD"}
@@ -49,6 +49,9 @@ class MultiplyNode {
49
49
  if ((0, coinFlip_1.coinFlip)())
50
50
  [this.leftChild, this.rightChild] = [this.rightChild, this.leftChild];
51
51
  };
52
+ this.toReversed = () => {
53
+ return new MultiplyNode(this.rightChild, this.leftChild, this.opts);
54
+ };
52
55
  this.id = operatorNode_1.OperatorIds.multiply;
53
56
  this.leftChild = leftChild;
54
57
  this.rightChild = rightChild;
@@ -1 +1 @@
1
- {"version":3,"file":"alignTex.d.ts","sourceRoot":"","sources":["../../../src/utils/latex/alignTex.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,YAAY,UAAQ,UAetE"}
1
+ {"version":3,"file":"alignTex.d.ts","sourceRoot":"","sources":["../../../src/utils/latex/alignTex.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,YAAY,UAAQ,UAatE"}
@@ -9,12 +9,10 @@ function alignTex(arr, noLatexSigns = false) {
9
9
  }
10
10
  }
11
11
  alignements += "l";
12
- const aligned = `${!noLatexSigns ? "$$" : ""}
13
- \\def\\arraystretch{1.8}
12
+ const aligned = `${!noLatexSigns ? "$$\n" : ""}\\def\\arraystretch{1.8}
14
13
  \\begin{array}{${alignements}}
15
14
  ${typeof arr === "string" ? arr : arr.map((el) => el.join("&")).join(` \\\\ `)}
16
- \\end{array}
17
- ${!noLatexSigns ? "$$" : ""}`;
15
+ \\end{array}${!noLatexSigns ? "\n$$\n" : ""}`;
18
16
  return aligned;
19
17
  }
20
18
  exports.alignTex = alignTex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.2.86",
3
+ "version": "2.2.87",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [