math-exercises 3.0.198 → 3.0.199

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 (31) hide show
  1. package/lib/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.d.ts.map +1 -1
  2. package/lib/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.js +3 -0
  3. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.js +58 -30
  5. package/lib/exercises/math/complex/addComplex.d.ts.map +1 -1
  6. package/lib/exercises/math/complex/addComplex.js +53 -7
  7. package/lib/exercises/math/complex/conjugateComplex.d.ts.map +1 -1
  8. package/lib/exercises/math/complex/conjugateComplex.js +48 -7
  9. package/lib/exercises/math/complex/mutiplyComplex.d.ts.map +1 -1
  10. package/lib/exercises/math/complex/mutiplyComplex.js +51 -18
  11. package/lib/exercises/math/complex/reAndIm.d.ts.map +1 -1
  12. package/lib/exercises/math/complex/reAndIm.js +35 -4
  13. package/lib/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.js +47 -3
  15. package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.js +3 -0
  17. package/lib/exercises/math/functions/sign/affineProductSign.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/sign/affineProductSign.js +0 -4
  19. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts.map +1 -1
  20. package/lib/server.js +3 -2
  21. package/lib/tests/pdfExo.test.js +2 -2
  22. package/lib/tests/pdfs/buildPDFForExercise.d.ts.map +1 -1
  23. package/lib/tests/pdfs/buildPDFForExercise.js +6 -0
  24. package/lib/tests/pdfs/quizPdfPreambule.d.ts.map +1 -1
  25. package/lib/tests/pdfs/quizPdfPreambule.js +1 -0
  26. package/lib/tests/pdfs/treeDiagramToLatex.d.ts +15 -0
  27. package/lib/tests/pdfs/treeDiagramToLatex.d.ts.map +1 -0
  28. package/lib/tests/pdfs/treeDiagramToLatex.js +49 -0
  29. package/lib/tests/questionTest.d.ts.map +1 -1
  30. package/lib/tests/questionTest.js +19 -0
  31. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"expOfTrinomEquals1Equation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAoBT,MAAM,6BAA6B,CAAC;AAmCrC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0YF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAgBF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBrE,CAAC"}
1
+ {"version":3,"file":"expOfTrinomEquals1Equation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAoBT,MAAM,6BAA6B,CAAC;AAmCrC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0YF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAgBF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAuBrE,CAAC"}
@@ -368,4 +368,7 @@ export const expOfTrinomEquals1Equation = {
368
368
  getStartStatement,
369
369
  getQuestionFromIdentifiers,
370
370
  options,
371
+ pdfOptions: {
372
+ shouldSpreadPropositions: true,
373
+ },
371
374
  };
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAY9C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4LF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CActE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAe9C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkOF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAetE,CAAC"}
@@ -7,6 +7,9 @@ import { Affine } from "../../../../math/polynomials/affine.js";
7
7
  import { randint } from "../../../../math/utils/random/randint.js";
8
8
  import { InequationNode } from "../../../../tree/nodes/inequations/inequationNode.js";
9
9
  import { InequationSolutionNode } from "../../../../tree/nodes/inequations/inequationSolutionNode.js";
10
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
11
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
12
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
13
  import { inequationParser } from "../../../../tree/parsers/inequationParser.js";
11
14
  import { intervalParser } from "../../../../tree/parsers/intervalParser.js";
12
15
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
@@ -41,37 +44,59 @@ const getAnswerNode = (identifiers, opts) => {
41
44
  const getAnswer = (identifiers, opts) => {
42
45
  return getAnswerNode(identifiers, opts).toTex();
43
46
  };
44
- // const getHint: GetHint<Identifiers, Options> = (identifiers, opts) => {
45
- // return `Isole le terme $x$ dans le membre de gauche de l'inéquation. Attention : lorsqu'on multiplie (ou divise) les deux membres d'une inéquation par un nombre négatif, le sens de l'inéquation est inversé.`;
46
- // };
47
- // const getCorrection: GetHint<Identifiers, Options> = (identifiers, opts) => {
48
- // const { a, b, c, d,ineqType } = identifiers;
49
- // const isInterval =
50
- // opts?.inequationSolutionFormat === "Intervalle (S = [a;b])";
51
- // const answer = getAnswer(identifiers, opts);
52
- // return `On isole $x$ dans le membre de gauche de l'inéquation :
53
- // $$
54
- // ${firstDegreeInequationResolutionTex(new Affine(a, b), ineqType, new Affine(c,d))}
55
- // $$
56
- // ${
57
- // identifiers.a < 0
58
- // ? `On a changé le sens de l'inéquation, car $${a}$ est négatif.`
59
- // : ""
60
- // }
61
- // ${
62
- // isInterval
63
- // ? `On traduit ensuite cette inéquation en intervalle :
64
- // $$
65
- // ${answer}
66
- // $$
67
- // `
68
- // : ""
69
- // }
70
- // `;
71
- // };
47
+ const getHint = () => {
48
+ return `Commence par regrouper les termes en $x$ d'un même côté de l'inéquation. Puis isole $x$ en effectuant les bonnes opérations.
49
+
50
+ Attention, lorsqu'on divise ou multiplie les deux membres d'une inéquation par un nombre négatif, l'inéquation change de sens. `;
51
+ };
52
+ const getCorrection = (identifiers, opts) => {
53
+ const { a, b, c, d, ineqType } = identifiers;
54
+ const affine1 = new Affine(a, b);
55
+ const affine2 = new Affine(c, d);
56
+ const isInterval = opts?.inequationSolutionFormat === "Intervalle (S = [a;b])";
57
+ return `On doit résoudre l'inéquation :
58
+
59
+ $$
60
+ ${affine1.toTex()} ${ineqType} ${affine2.toTex()}
61
+ $$
62
+
63
+ On ${c < 0 ? "ajoute" : "enlève"} $${multiply(Math.abs(c), "x").toTex()}$ des deux côtés :
64
+
65
+ $$
66
+ ${add(multiply(substract(a, c).simplify(), "x"), b).toTex()} ${ineqType} ${d.frenchify()}
67
+ $$
68
+
69
+ On ${b < 0 ? "ajoute" : "enlève"} $${Math.abs(b).frenchify()}$ des deux côtés :
70
+
71
+ $$
72
+ ${multiply(substract(a, c).simplify(), "x").toTex()} ${ineqType} ${substract(d, b)
73
+ .simplify()
74
+ .toTex()}
75
+ $$
76
+
77
+ On divise ensuite par $${substract(a, c)
78
+ .simplify()
79
+ .toTex()}$. Puisque $${substract(a, c).simplify().toTex()}$ est ${a > c ? "positif" : "négatif"}, l'inéquation ${a > c ? "ne change pas" : "change"} de sens :
80
+
81
+ $$
82
+ ${getAnswer(identifiers, {
83
+ inequationSolutionFormat: "Inégalité (x>a)",
84
+ })}
85
+ $$
86
+
87
+ ${isInterval
88
+ ? `On traduit cette inégalité par un intervalle :
89
+
90
+ $$
91
+ ${getAnswer(identifiers, opts)}
92
+ $$`
93
+ : ""}
94
+ `;
95
+ };
72
96
  const getFirstDegreeInequationsQuestion = (opts) => {
73
- const affine1 = new Affine(randint(-10, 10, [0]), randint(-10, 10));
74
- const affine2 = new Affine(randint(-10, 10, [0, affine1.a]), randint(-10, 10));
97
+ // ax+b < cx+d
98
+ const affine1 = new Affine(randint(-10, 10, [0, 1]), randint(-10, 10, [0]));
99
+ const affine2 = new Affine(randint(-10, 10, [0, affine1.a, 1, affine1.a - 1]), randint(-10, 10, [0]));
75
100
  const coeff = affine1.a - affine2.a;
76
101
  const ineqType = InequationSymbolConstructor.random();
77
102
  const identifiers = {
@@ -91,6 +116,8 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
91
116
  keys: getKeys(identifiers, opts),
92
117
  answerFormat: "tex",
93
118
  identifiers,
119
+ hint: getHint(identifiers, opts),
120
+ correction: getCorrection(identifiers, opts),
94
121
  };
95
122
  return question;
96
123
  };
@@ -157,6 +184,7 @@ export const firstDegreeInequationsType3 = {
157
184
  subject: "Mathématiques",
158
185
  options,
159
186
  getQuestionFromIdentifiers,
187
+ hasHintAndCorrection: true,
160
188
  };
161
189
  // export const reuseFirstDegreeInequationsType3 = {
162
190
  // getAnswerNode,
@@ -1 +1 @@
1
- {"version":3,"file":"addComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/addComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA4EF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAY5C,CAAC"}
1
+ {"version":3,"file":"addComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/addComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAwHF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAa5C,CAAC"}
@@ -1,7 +1,11 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
+ import { add } from "../../../tree/nodes/operators/addNode.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
4
7
  import { shuffle } from "../../../utils/alea/shuffle.js";
8
+ import { alignTex } from "../../../utils/latex/alignTex.js";
5
9
  const getInstruction = (identifiers) => {
6
10
  const z1 = new Complex(identifiers.z1Re, identifiers.z1Im);
7
11
  const z2 = new Complex(identifiers.z2Re, identifiers.z2Im);
@@ -15,14 +19,47 @@ const getAnswer = (identifiers) => {
15
19
  const answer = z1.add(z2).toTree().toTex();
16
20
  return answer;
17
21
  };
22
+ const getHint = () => {
23
+ return `Soient deux nombres complexes $z = a+ib$ et $z' = a'+ib'$. Alors :
24
+
25
+ $$
26
+ z+z' = (a+a') + i(b+b')
27
+ $$`;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const { z1Re, z1Im, z2Re, z2Im } = identifiers;
31
+ const z1 = add(z1Re, multiply(z1Im, "i")).simplify({
32
+ forbidFactorize: true,
33
+ noAddOrder: true,
34
+ });
35
+ const z2 = add(z2Re, multiply(z2Im, "i")).simplify({
36
+ forbidFactorize: true,
37
+ noAddOrder: true,
38
+ });
39
+ return `Soient deux nombres complexes $z = a+ib$ et $z' = a'+ib'$. Alors :
40
+
41
+ $$
42
+ z+z' = (a+a') + i(b+b')
43
+ $$
44
+
45
+ Ici, on a donc :
46
+
47
+ ${alignTex([
48
+ ["z+ z'", "=", add(z1, z2).toTex()],
49
+ ["", "=", add(add(z1Re, z2Re), multiply("i", add(z1Im, z2Im))).toTex()],
50
+ ["", "=", getAnswer(identifiers)],
51
+ ])}`;
52
+ };
18
53
  const getQuestionFromIdentifiers = (identifiers) => {
19
54
  const question = {
20
55
  answer: getAnswer(identifiers),
21
56
  instruction: getInstruction(identifiers),
22
- keys: ["i", "z", "quote"],
57
+ keys: ["i"],
23
58
  answerFormat: "tex",
24
59
  startStatement: "z+z'",
25
60
  identifiers,
61
+ hint: getHint(identifiers),
62
+ correction: getCorrection(identifiers),
26
63
  };
27
64
  return question;
28
65
  };
@@ -57,12 +94,20 @@ const getPropositions = (n, { answer, z1Re, z1Im, z2Re, z2Im }) => {
57
94
  });
58
95
  return shuffle(propositions);
59
96
  };
60
- const isAnswerValid = (ans, { z1Im, z1Re, z2Im, z2Re }) => {
61
- const z1 = new Complex(z1Re, z1Im);
62
- const z2 = new Complex(z2Re, z2Im);
63
- const answer = z1.add(z2).toTree();
64
- const texs = answer.toAllValidTexs();
65
- return texs.includes(ans);
97
+ const isAnswerValid = (ans, { answer }) => {
98
+ const parsed = parseAlgebraic(ans);
99
+ if (!parsed)
100
+ return false;
101
+ return (parsed
102
+ .simplify({
103
+ forbidFactorize: true,
104
+ })
105
+ .toTex() ===
106
+ parseAlgebraic(answer)
107
+ .simplify({
108
+ forbidFactorize: true,
109
+ })
110
+ .toTex());
66
111
  };
67
112
  export const addComplex = {
68
113
  id: "addComplex",
@@ -76,4 +121,5 @@ export const addComplex = {
76
121
  isAnswerValid,
77
122
  subject: "Mathématiques",
78
123
  getQuestionFromIdentifiers,
124
+ hasHintAndCorrection: true,
79
125
  };
@@ -1 +1 @@
1
- {"version":3,"file":"conjugateComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4DF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
1
+ {"version":3,"file":"conjugateComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAqGF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
@@ -1,11 +1,16 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
4
5
  import { shuffle } from "../../../utils/alea/shuffle.js";
5
6
  const getInstruction = (identifiers) => {
6
7
  const { re, im } = identifiers;
7
8
  const complex = new Complex(re, im);
8
- return `Déterminer le conjugué de $z=${complex.toTree().toTex()}$.`;
9
+ return `Déterminer le conjugué $\\overline{z}$ de :
10
+
11
+ $$
12
+ z=${complex.toTree().toTex()}
13
+ $$`;
9
14
  };
10
15
  const getAnswer = (identifiers) => {
11
16
  const { re, im } = identifiers;
@@ -13,14 +18,40 @@ const getAnswer = (identifiers) => {
13
18
  const answer = complex.conjugate().toTree().toTex();
14
19
  return answer;
15
20
  };
21
+ const getHint = () => {
22
+ return `Soit $z = a+ib$ un nombre complexe.
23
+
24
+ Le conjugué $\\overline{z}$ de $z$ est le nombre :
25
+
26
+ $$
27
+ \\overline{z} = a-ib
28
+ $$`;
29
+ };
30
+ const getCorrection = (identifiers) => {
31
+ return `Soit $z = a+ib$ un nombre complexe.
32
+
33
+ Le conjugué $\\overline{z}$ de $z$ est le nombre :
34
+
35
+ $$
36
+ \\overline{z} = a-ib
37
+ $$
38
+
39
+ Ici, on a donc :
40
+
41
+ $$
42
+ \\overline{z} = ${getAnswer(identifiers)}
43
+ $$`;
44
+ };
16
45
  const getQuestionFromIdentifiers = (identifiers) => {
17
46
  const question = {
18
47
  answer: getAnswer(identifiers),
19
48
  instruction: getInstruction(identifiers),
20
- keys: ["i", "overline"],
49
+ keys: ["i"],
21
50
  answerFormat: "tex",
22
51
  startStatement: "\\overline z",
23
52
  identifiers,
53
+ hint: getHint(identifiers),
54
+ correction: getCorrection(identifiers),
24
55
  };
25
56
  return question;
26
57
  };
@@ -43,11 +74,20 @@ const getPropositions = (n, { answer, re, im }) => {
43
74
  });
44
75
  return shuffle(propositions);
45
76
  };
46
- const isAnswerValid = (ans, { im, re }) => {
47
- const complex = new Complex(re, im);
48
- const answer = complex.conjugate().toTree();
49
- const texs = answer.toAllValidTexs();
50
- return texs.includes(ans);
77
+ const isAnswerValid = (ans, { answer }) => {
78
+ const parsed = parseAlgebraic(ans);
79
+ if (!parsed)
80
+ return false;
81
+ return (parsed
82
+ .simplify({
83
+ forbidFactorize: true,
84
+ })
85
+ .toTex() ===
86
+ parseAlgebraic(answer)
87
+ .simplify({
88
+ forbidFactorize: true,
89
+ })
90
+ .toTex());
51
91
  };
52
92
  export const conjugateComplex = {
53
93
  id: "conjugateComplex",
@@ -61,4 +101,5 @@ export const conjugateComplex = {
61
101
  isAnswerValid,
62
102
  subject: "Mathématiques",
63
103
  getQuestionFromIdentifiers,
104
+ hasHintAndCorrection: true,
64
105
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mutiplyComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/mutiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AAmEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAahD,CAAC"}
1
+ {"version":3,"file":"mutiplyComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/mutiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AA2GF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAchD,CAAC"}
@@ -1,7 +1,12 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
+ import { randTupleInt } from "../../../math/utils/random/randTupleInt.js";
5
+ import { add } from "../../../tree/nodes/operators/addNode.js";
6
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
7
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
4
8
  import { shuffle } from "../../../utils/alea/shuffle.js";
9
+ import { alignTex } from "../../../utils/latex/alignTex.js";
5
10
  const getInstruction = (identifiers) => {
6
11
  const z1 = new Complex(identifiers.z1[0], identifiers.z1[1]);
7
12
  const z2 = new Complex(identifiers.z2[0], identifiers.z2[1]);
@@ -15,29 +20,48 @@ const getAnswer = (identifiers) => {
15
20
  const answer = z1.multiply(z2).toTree().toTex();
16
21
  return answer;
17
22
  };
23
+ const getHint = () => {
24
+ return `Pour multiplier deux nombres complexes, on utilise la distributivité double, ainsi que le fait que $i^2 = -1$.`;
25
+ };
26
+ const getCorrection = (identifiers) => {
27
+ const { z1, z2 } = identifiers;
28
+ const [a, b] = z1;
29
+ const [c, d] = z2;
30
+ const zA = add(a, multiply(b, "i"));
31
+ const zB = add(c, multiply(d, "i"));
32
+ return `On distribue comme pour des nombres réels, puis on utilise le fait que $i^2=-1$ :
33
+
34
+ ${alignTex([
35
+ ["z\\times z'", "=", multiply(zA, zB).toTex()],
36
+ [
37
+ "",
38
+ "=",
39
+ add(add(multiply(a, c), multiply(a, multiply(d, "i"))), add(multiply(multiply(b, "i"), c), multiply(multiply(b, "i"), multiply(d, "i")))).toTex(),
40
+ ],
41
+ [
42
+ "",
43
+ "=",
44
+ add(add(multiply(a, c).simplify(), multiply(a * d + b * c, "i")), multiply(multiply(b, d).simplify(), -1)).toTex(),
45
+ ],
46
+ ["", "=", getAnswer(identifiers)],
47
+ ])}`;
48
+ };
18
49
  const getQuestionFromIdentifiers = (identifiers) => {
19
50
  const question = {
20
51
  answer: getAnswer(identifiers),
21
52
  instruction: getInstruction(identifiers),
22
- keys: ["i", "z", "quote"],
53
+ keys: ["i"],
23
54
  answerFormat: "tex",
24
55
  startStatement: "z\\times z'",
25
56
  identifiers,
57
+ hint: getHint(identifiers),
58
+ correction: getCorrection(identifiers),
26
59
  };
27
60
  return question;
28
61
  };
29
62
  const getMutiplyComplexQuestion = () => {
30
- const z1 = ComplexConstructor.random();
31
- let z2;
32
- let counter = 0;
33
- do {
34
- counter++;
35
- if (counter > 1000) {
36
- throw new Error("multiply complex too many iterations");
37
- }
38
- z2 = ComplexConstructor.random();
39
- } while (z1.im === 0 && z2.im === 0);
40
- const identifiers = { z1: [z1.re, z1.im], z2: [z2.re, z2.im] };
63
+ const [a, b, c, d] = randTupleInt(4, { from: -9, to: 10, elExcludes: [0] });
64
+ const identifiers = { z1: [a, b], z2: [c, d] };
41
65
  return getQuestionFromIdentifiers(identifiers);
42
66
  };
43
67
  const getPropositions = (n, { answer, z1, z2 }) => {
@@ -51,12 +75,20 @@ const getPropositions = (n, { answer, z1, z2 }) => {
51
75
  });
52
76
  return shuffle(propositions);
53
77
  };
54
- const isAnswerValid = (ans, { z1, z2 }) => {
55
- const complex1 = new Complex(z1[0], z1[1]);
56
- const complex2 = new Complex(z2[0], z2[1]);
57
- const answer = complex1.multiply(complex2).toTree();
58
- const texs = answer.toAllValidTexs();
59
- return texs.includes(ans);
78
+ const isAnswerValid = (ans, { answer }) => {
79
+ const parsed = parseAlgebraic(ans);
80
+ if (!parsed)
81
+ return false;
82
+ return (parsed
83
+ .simplify({
84
+ forbidFactorize: true,
85
+ })
86
+ .toTex() ===
87
+ parseAlgebraic(answer)
88
+ .simplify({
89
+ forbidFactorize: true,
90
+ })
91
+ .toTex());
60
92
  };
61
93
  export const mutiplyComplex = {
62
94
  id: "mutiplyComplex",
@@ -70,4 +102,5 @@ export const mutiplyComplex = {
70
102
  isAnswerValid,
71
103
  subject: "Mathématiques",
72
104
  getQuestionFromIdentifiers,
105
+ hasHintAndCorrection: true,
73
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"reAndIm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/reAndIm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA6DF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAYzC,CAAC"}
1
+ {"version":3,"file":"reAndIm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/reAndIm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA2FF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAazC,CAAC"}
@@ -1,13 +1,17 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../exercises/vea/numberVEA.js";
3
4
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
5
  import { randint } from "../../../math/utils/random/randint.js";
5
6
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
6
7
  import { shuffle } from "../../../utils/alea/shuffle.js";
8
+ import { doWhile } from "../../../utils/doWhile.js";
7
9
  const getInstruction = (identifiers) => {
8
10
  const { re, im, isRe } = identifiers;
9
11
  const z1 = new Complex(re, im);
10
- return `Soit $z=${z1.toTree().toTex()}$. Quelle est la partie ${isRe ? "réelle" : "imaginaire"} de $z$ ?`;
12
+ return `Soit $z=${z1.toTree().toTex()}$.
13
+
14
+ Quelle est la partie ${isRe ? "réelle" : "imaginaire"} de $z$ ?`;
11
15
  };
12
16
  const getAnswer = (identifiers) => {
13
17
  const { re, im, isRe } = identifiers;
@@ -15,6 +19,30 @@ const getAnswer = (identifiers) => {
15
19
  const answer = (isRe ? z1.re : z1.im) + "";
16
20
  return answer;
17
21
  };
22
+ const getHint = () => {
23
+ return `Si $z$ est un nombre complexe tel que :
24
+
25
+ $$
26
+ z = a+ib
27
+ $$
28
+
29
+ alors $a$ est la partie réelle de $z$, et $b$ et sa partie imaginaire.`;
30
+ };
31
+ const getCorrection = (identifiers) => {
32
+ const { re, im } = identifiers;
33
+ const z1 = new Complex(re, im);
34
+ return `Si $z$ est un nombre complexe tel que :
35
+
36
+ $$
37
+ z = a+ib
38
+ $$
39
+
40
+ alors $a$ est la partie réelle de $z$, et $b$ et sa partie imaginaire.
41
+
42
+ Ici, on a $z = ${z1
43
+ .toTree()
44
+ .toTex()}$, donc la partie réelle de $z$ est $${re}$ et sa partie imaginaire est $${im}$. `;
45
+ };
18
46
  const getQuestionFromIdentifiers = (identifiers) => {
19
47
  const question = {
20
48
  answer: getAnswer(identifiers),
@@ -22,11 +50,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
22
50
  keys: ["i", "z"],
23
51
  answerFormat: "tex",
24
52
  identifiers,
53
+ hint: getHint(identifiers),
54
+ correction: getCorrection(identifiers),
25
55
  };
26
56
  return question;
27
57
  };
28
58
  const getReAndImQuestion = () => {
29
- const z1 = ComplexConstructor.random();
59
+ const z1 = doWhile(() => ComplexConstructor.random(), (z) => z.re === z.im);
30
60
  const isRe = coinFlip();
31
61
  const identifiers = { re: z1.re, im: z1.im, isRe };
32
62
  return getQuestionFromIdentifiers(identifiers);
@@ -44,13 +74,13 @@ const getPropositions = (n, { answer, re, im, isRe }) => {
44
74
  return shuffle(propositions);
45
75
  };
46
76
  const isAnswerValid = (ans, { answer }) => {
47
- return ans === answer;
77
+ return numberVEA(ans, answer);
48
78
  };
49
79
  export const reAndIm = {
50
80
  id: "getReAndImQuestion",
51
81
  connector: "=",
52
82
  getPropositions,
53
- label: "Identifier partie réelle et partie imaginaire",
83
+ label: "Identifier partie réelle et partie imaginaire d'un nombre complexe",
54
84
  isSingleStep: true,
55
85
  generator: (nb) => getDistinctQuestions(getReAndImQuestion, nb),
56
86
  qcmTimer: 60,
@@ -58,4 +88,5 @@ export const reAndIm = {
58
88
  isAnswerValid,
59
89
  subject: "Mathématiques",
60
90
  getQuestionFromIdentifiers,
91
+ hasHintAndCorrection: true,
61
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cosSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAqIF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"cosSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAmLF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { AffineConstructor } from "../../../../../math/polynomials/affine.js";
4
- import { CosNode } from "../../../../../tree/nodes/functions/cosNode.js";
5
- import { SinNode } from "../../../../../tree/nodes/functions/sinNode.js";
4
+ import { cos, CosNode } from "../../../../../tree/nodes/functions/cosNode.js";
5
+ import { sin, SinNode } from "../../../../../tree/nodes/functions/sinNode.js";
6
6
  import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
7
7
  import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
8
- import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { multiply, MultiplyNode, } from "../../../../../tree/nodes/operators/multiplyNode.js";
9
9
  import { PowerNode } from "../../../../../tree/nodes/operators/powerNode.js";
10
10
  import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
11
11
  import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
@@ -28,6 +28,47 @@ const getAnswer = (identifiers) => {
28
28
  .toTex();
29
29
  return ans;
30
30
  };
31
+ const getHint = () => {
32
+ return `Pour toute fonction dérivable $u$, on a :
33
+
34
+ $$
35
+ \\left(\\cos(u)\\right)' = -u'\\times \\sin(u)
36
+ $$
37
+
38
+ et
39
+
40
+ $$
41
+ \\left(\\sin(u)\\right)' = u'\\times \\cos(u)
42
+ $$`;
43
+ };
44
+ const getCorrection = (identifiers) => {
45
+ const { affinecoeffs } = identifiers;
46
+ const affTree = AffineConstructor.fromCoeffs(affinecoeffs).toTree();
47
+ const a = affinecoeffs[1];
48
+ return `On utilise la propriété suivante : pour toute fonction dérivable $u$,
49
+
50
+ $$
51
+ \\left(\\cos(u)\\right)' = -u'\\times \\sin(u)
52
+ $$
53
+
54
+ et
55
+
56
+ $$
57
+ \\left(\\sin(u)\\right)' = u'\\times \\cos(u)
58
+ $$
59
+
60
+ Ici, on dérive la fonction $f$ deux fois. On a, pour tout $x\\in \\mathbb{R}$ :
61
+
62
+ $$
63
+ f'(x) = ${multiply(-a, sin(affTree)).toTex()}
64
+ $$
65
+
66
+ Donc
67
+
68
+ $$
69
+ f''(x)= ${multiply(multiply(-a, a).simplify(), cos(affTree)).toTex()}
70
+ $$`;
71
+ };
31
72
  const getCosSecondDegreeDerivativeQuestion = () => {
32
73
  const affine = AffineConstructor.random();
33
74
  const affinecoeffs = affine.coefficients;
@@ -41,6 +82,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
41
82
  keys: ["x", "sin", "cos", "tan"],
42
83
  answerFormat: "tex",
43
84
  identifiers,
85
+ hint: getHint(identifiers),
86
+ correction: getCorrection(identifiers),
44
87
  };
45
88
  return question;
46
89
  };
@@ -104,4 +147,5 @@ export const cosSecondDegreeDerivative = {
104
147
  getAnswer,
105
148
  getInstruction,
106
149
  getQuestionFromIdentifiers,
150
+ hasHintAndCorrection: true,
107
151
  };
@@ -1 +1 @@
1
- {"version":3,"file":"expFunctionBasicSign.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/sign/expFunctionBasicSign.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IAGjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAwFF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC"}
1
+ {"version":3,"file":"expFunctionBasicSign.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/sign/expFunctionBasicSign.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IAGjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAwFF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAqBtD,CAAC"}
@@ -98,4 +98,7 @@ export const expFunctionBasicSign = {
98
98
  getAnswer,
99
99
  getQuestionFromIdentifiers,
100
100
  hasHintAndCorrection: true,
101
+ pdfOptions: {
102
+ shouldSpreadPropositions: true,
103
+ },
101
104
  };
@@ -1 +1 @@
1
- {"version":3,"file":"affineProductSign.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/affineProductSign.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,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;AAkJF,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,EAgBT,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;AA6IF,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAaF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
@@ -75,8 +75,6 @@ $$
75
75
 
76
76
  Sur quel(s) intervalle(s) $f$ est-elle ${isAskingPositive ? "positive" : "négative"} ?`;
77
77
  };
78
- // const getHint: GetHint<Identifiers, Options> = (identifiers, opts) => {};
79
- // const getCorrection: GetCorrection<Identifiers, Options> = (identifiers) => {};
80
78
  const getKeys = () => {
81
79
  return ["lbracket", "semicolon", "rbracket", "cup", "infty"];
82
80
  };
@@ -114,8 +112,6 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
114
112
  keys: getKeys(identifiers, opts),
115
113
  answerFormat: "tex",
116
114
  identifiers,
117
- // hint: getHint(identifiers, opts),
118
- // correction: getCorrection(identifiers, opts),
119
115
  };
120
116
  return question;
121
117
  };
@@ -1 +1 @@
1
- {"version":3,"file":"spaceVectorLinearCombinationCoords.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAiFF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAcpE,CAAC"}
1
+ {"version":3,"file":"spaceVectorLinearCombinationCoords.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAkFF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAcpE,CAAC"}
package/lib/server.js CHANGED
@@ -27,8 +27,9 @@ const runServer = () => {
27
27
  dotenv.config();
28
28
  const app = express();
29
29
  app.use(cors());
30
- console.log("math exos", mathExercises.length);
31
- console.log("math hints", mathExercises.filter((exo) => exo.hasHintAndCorrection).length);
30
+ console.log("math exos", mathExercises.filter((exo) => !exo.subject || exo.subject === "Mathématiques").length);
31
+ console.log("math hints", mathExercises.filter((exo) => exo.hasHintAndCorrection &&
32
+ (!exo.subject || exo.subject === "Mathématiques")).length);
32
33
  console.log("pc exos", `${pcExercises.length}`);
33
34
  console.log("pc hints", pcExercises.filter((exo) => exo.hasHintAndCorrection).length);
34
35
  playground();
@@ -1,8 +1,8 @@
1
1
  import { buildPdfForExercise } from "./pdfs/buildPDFForExercise.js";
2
2
  import "../prototypesEnhancement.js";
3
- import { equationFromSignTable } from "../exercises/math/index.js";
3
+ import { independancyFromProbaTree, } from "../exercises/math/index.js";
4
4
  try {
5
- buildPdfForExercise(equationFromSignTable);
5
+ buildPdfForExercise(independancyFromProbaTree);
6
6
  }
7
7
  catch (err) {
8
8
  console.log(err);
@@ -1 +1 @@
1
- {"version":3,"file":"buildPDFForExercise.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/buildPDFForExercise.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAe,MAAM,6BAA6B,CAAC;AAQpE,eAAO,MAAM,mBAAmB,GAAI,KAAK,QAAQ,CAAC,MAAM,CAAC,SA8LxD,CAAC"}
1
+ {"version":3,"file":"buildPDFForExercise.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/buildPDFForExercise.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAe,MAAM,6BAA6B,CAAC;AASpE,eAAO,MAAM,mBAAmB,GAAI,KAAK,QAAQ,CAAC,MAAM,CAAC,SAwMxD,CAAC"}
@@ -11,6 +11,7 @@ import { signTableToLatex } from "./signTableToLatex.js";
11
11
  import { varTableToLatex } from "./varTableToLatex.js";
12
12
  import { valueTableToLatex } from "./valueTableToLatex.js";
13
13
  import { signVarTableToLatex } from "./signVarTableToLatex.js";
14
+ import { treeDiagramToLatex } from "./treeDiagramToLatex.js";
14
15
  export const buildPdfForExercise = (exo) => {
15
16
  const __filename = fileURLToPath(import.meta.url);
16
17
  const __dirname = path.dirname(__filename);
@@ -45,6 +46,11 @@ export const buildPdfForExercise = (exo) => {
45
46
  for (const match of signVarTableMatches) {
46
47
  question.instruction = question.instruction.replace(match[0], signVarTableToLatex(JSON.parse(match[1])));
47
48
  }
49
+ const treeDiagramRegex = /<svg id=["']treeDiagram["']>([\s\S]*?)<\/svg>/g;
50
+ const treeDiagramMatches = question.instruction.matchAll(treeDiagramRegex);
51
+ for (const match of treeDiagramMatches) {
52
+ question.instruction = question.instruction.replace(match[0], treeDiagramToLatex(match[1]));
53
+ }
48
54
  const formatted = formatMarkdownToLatex(question.instruction);
49
55
  content += `
50
56
  ${formatted} \n
@@ -1 +1 @@
1
- {"version":3,"file":"quizPdfPreambule.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/quizPdfPreambule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,cA6E5B,CAAC"}
1
+ {"version":3,"file":"quizPdfPreambule.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/quizPdfPreambule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,cA8E5B,CAAC"}
@@ -2,6 +2,7 @@ export const quizPdfPreambule = () => {
2
2
  return `\\documentclass[a4paper, 8pt]{article}
3
3
  \\usepackage[dvipsnames,table]{xcolor}
4
4
  \\usepackage{tikz}
5
+ \\usetikzlibrary{trees}
5
6
  \\usepackage{tkz-tab}
6
7
  \\usepackage[utf8]{inputenc}
7
8
  \\usepackage[T1]{fontenc}
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param tree string[][][][] stringified, avec des £ au lieu des dollars
4
+ * @returns
5
+ *
6
+ * [//arbre
7
+ * [//etage
8
+ * [//block
9
+ * [proba, event]
10
+ * ]
11
+ * ]
12
+ * ]
13
+ */
14
+ export declare const treeDiagramToLatex: (tree: string) => string;
15
+ //# sourceMappingURL=treeDiagramToLatex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeDiagramToLatex.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/treeDiagramToLatex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,WAmC9C,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { dollarizeString } from "./dollarizeString.js";
2
+ /**
3
+ *
4
+ * @param tree string[][][][] stringified, avec des £ au lieu des dollars
5
+ * @returns
6
+ *
7
+ * [//arbre
8
+ * [//etage
9
+ * [//block
10
+ * [proba, event]
11
+ * ]
12
+ * ]
13
+ * ]
14
+ */
15
+ export const treeDiagramToLatex = (tree) => {
16
+ const parsedTree = JSON.parse(tree.replaceAll("£", "$"));
17
+ const mainEvent = dollarizeString(parsedTree[0][0][0][1]);
18
+ const mainProba = dollarizeString(parsedTree[0][0][0][0]);
19
+ const oppMainEvent = dollarizeString(parsedTree[0][0][1][1]);
20
+ const oppMainProba = dollarizeString(parsedTree[0][0][1][0]);
21
+ const firstSubEvent = dollarizeString(parsedTree[1][0][0][1]);
22
+ const firstSubProba = dollarizeString(parsedTree[1][0][0][0]);
23
+ const firstOppSubEvent = dollarizeString(parsedTree[1][0][1][1]);
24
+ const firstOppSubProba = dollarizeString(parsedTree[1][0][1][0]);
25
+ const secondSubEvent = dollarizeString(parsedTree[1][1][0][1]);
26
+ const secondSubProba = dollarizeString(parsedTree[1][1][0][0]);
27
+ const secondOppSubEvent = dollarizeString(parsedTree[1][1][1][1]);
28
+ const secondOppSubProba = dollarizeString(parsedTree[1][1][1][0]);
29
+ return `
30
+
31
+ \\begin{tikzpicture}[
32
+ level 1/.style={sibling distance=4cm},
33
+ level 2/.style={sibling distance=2cm},
34
+ edge from parent/.style={draw, -latex}
35
+ ]
36
+ \\node {}
37
+ child { node {${mainEvent}} }
38
+ child { node {${firstSubEvent}} edge from parent node[left] {${firstSubProba}} }
39
+ child { node {${firstOppSubEvent}} edge from parent node[right] {${firstOppSubProba}} }
40
+ edge from parent node[left] {${mainProba}}
41
+ }
42
+ child { node {${oppMainEvent}}
43
+ child { node {${secondSubEvent}} edge from parent node[left] {${secondSubProba}} }
44
+ child { node {${secondOppSubEvent}} edge from parent node[right] {${secondOppSubProba}} }
45
+ edge from parent node[right] {${oppMainProba}}
46
+ };
47
+ \\end{tikzpicture}
48
+ `;
49
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"questionTest.d.ts","sourceRoot":"","sources":["../../src/tests/questionTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKjE,eAAO,MAAM,YAAY,GACvB,KAAK,QAAQ,CAAC,MAAM,CAAC,EACrB,UAAU,QAAQ,CAAC,MAAM,CAAC;;;CAqU3B,CAAC"}
1
+ {"version":3,"file":"questionTest.d.ts","sourceRoot":"","sources":["../../src/tests/questionTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA0BjE,eAAO,MAAM,YAAY,GACvB,KAAK,QAAQ,CAAC,MAAM,CAAC,EACrB,UAAU,QAAQ,CAAC,MAAM,CAAC;;;CAsU3B,CAAC"}
@@ -1,6 +1,25 @@
1
1
  import { latexTester } from "../latexTester.js";
2
2
  import { assertJsonStringifiable } from "./assertJsonStringifiable.js";
3
3
  import { formatMarkdownToLatex } from "./pdfs/formatMdToLatex.js";
4
+ /* //TODO
5
+ - tester les touches du clavier (si touche manquante erreur)
6
+ - tests sur les tableaux (ya-t-il bien au moins un input, la structure est-elle bonne, ...)
7
+ - tests sur les arbres (ya-t-il bien au moins un input, la structure est-elle bonne, ...)
8
+ -
9
+
10
+ */
11
+ /*
12
+ touches du clavier basiques :
13
+ 0-9
14
+ ,
15
+ +-* et /
16
+ sqrt et square
17
+ power
18
+ ( et )
19
+
20
+ un test basique serait si l'exo n'a pas de touche mais la réponse contient n'importe quel symbole hors des précédents
21
+ c'est basique car il faudrait aussi pouvoir tester les cas où y'a des touches mais certaines manquent
22
+ */
4
23
  export const questionTest = (exo, question) => {
5
24
  let qcmTime = -1;
6
25
  let veaTime = -1;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.198",
4
+ "version": "3.0.199",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [