math-exercises 3.0.98 → 3.0.99

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 (35) hide show
  1. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +10 -0
  3. package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.js +1 -1
  4. package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +1 -1
  5. package/lib/exercises/math/functions/sign/readSignTable.d.ts.map +1 -1
  6. package/lib/exercises/math/functions/variations/compareImagesInVarTable.js +1 -1
  7. package/lib/exercises/math/functions/variations/varTableExtremaReading.js +1 -1
  8. package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts +1 -0
  9. package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts.map +1 -1
  10. package/lib/exercises/math/functions/variations/varTableFromSentences.js +15 -0
  11. package/lib/exercises/math/geometry/vectors/chasles.d.ts.map +1 -1
  12. package/lib/exercises/math/geometry/vectors/chasles.js +83 -4
  13. package/lib/exercises/math/geometry/vectors/determinant.d.ts.map +1 -1
  14. package/lib/exercises/math/geometry/vectors/determinant.js +44 -9
  15. package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts.map +1 -1
  16. package/lib/index.d.ts +1 -0
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/tests/pdfExo.test.d.ts.map +1 -1
  19. package/lib/tests/pdfExo.test.js +2 -2
  20. package/lib/tests/pdfs/buildPDFForExercise.d.ts.map +1 -1
  21. package/lib/tests/pdfs/buildPDFForExercise.js +59 -6
  22. package/lib/tests/pdfs/quizPdfPreambule.d.ts.map +1 -1
  23. package/lib/tests/pdfs/quizPdfPreambule.js +2 -1
  24. package/lib/tests/pdfs/signTableToLatex.d.ts +2 -0
  25. package/lib/tests/pdfs/signTableToLatex.d.ts.map +1 -0
  26. package/lib/tests/pdfs/signTableToLatex.js +32 -0
  27. package/lib/tests/pdfs/valueTableToLatex.d.ts +2 -0
  28. package/lib/tests/pdfs/valueTableToLatex.d.ts.map +1 -0
  29. package/lib/tests/pdfs/valueTableToLatex.js +18 -0
  30. package/lib/tests/pdfs/varTableToLatex.d.ts +2 -0
  31. package/lib/tests/pdfs/varTableToLatex.d.ts.map +1 -0
  32. package/lib/tests/pdfs/varTableToLatex.js +58 -0
  33. package/lib/tests/questionTest.d.ts.map +1 -1
  34. package/lib/tests/questionTest.js +8 -0
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"mentalAddAndSub.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAoFF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
1
+ {"version":3,"file":"mentalAddAndSub.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA+FF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
@@ -24,6 +24,16 @@ const getStartStatement = (identifiers) => {
24
24
  const getAnswer = (identifiers) => {
25
25
  return getStatementNode(identifiers).simplify().toTex();
26
26
  };
27
+ // const getHint: GetHint<Identifiers> = (identifiers)=>{
28
+ // return `Ajoute les nombres dans l'ordre.`
29
+ // }
30
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers)=>{
31
+ // const {numbers} = identifiers
32
+ // return `On ajoute les nombres dans l'ordre :
33
+ // ${alignTex([
34
+ // [getStartStatement(identifiers), "=", add(numbers[])],
35
+ // ])}`
36
+ // }
27
37
  const getQuestionFromIdentifiers = (identifiers) => {
28
38
  const question = {
29
39
  instruction: getInstruction(identifiers),
@@ -50,7 +50,7 @@ $$`;
50
50
  };
51
51
  const getHint = (identifiers) => {
52
52
  const { type, a, b, c, d, e, f } = identifiers;
53
- return `Commence par développer ${type === 0 ? "le produit" : "les produits"} en utilisant la distributivité. Ensuite, résout l'équation en regroupant les termes en $x$ d'un côté de l'équation.`;
53
+ return `Commence par développer ${type === 0 ? "le produit" : "les produits"} en utilisant la distributivité. Ensuite, résous l'équation en regroupant les termes en $x$ d'un côté de l'équation.`;
54
54
  };
55
55
  const getCorrection = (identifiers) => {
56
56
  const { type, a, b, c, d, e, f } = identifiers;
@@ -115,7 +115,7 @@ const isAnswerValid = (ans, { answer, xA, xB, yA, yB }) => {
115
115
  export const affineExpressionFromTwoImages = {
116
116
  id: "affineExpressionFromTwoImages",
117
117
  connector: "=",
118
- label: "Expression algébrique d'une fonction affine via deux images",
118
+ label: "Déterminer l'expression algébrique d'une fonction affine via deux images",
119
119
  isSingleStep: true,
120
120
  generator: (nb) => getDistinctQuestions(getAffineExpressionFromTwoImagesQuestion, nb),
121
121
  qcmTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"readSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/readSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AA4GF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
1
+ {"version":3,"file":"readSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/readSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AA4GF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
@@ -51,7 +51,7 @@ const getInstruction = (identifiers) => {
51
51
  return `On donne le tableau de variations d'une fonction $f$ définie sur $\\mathbb{R}$ :
52
52
 
53
53
 
54
- <svg id='varTable'>${JSON.stringify(table)}</svg>
54
+ <svg id="varTable">${JSON.stringify(table)}</svg>
55
55
 
56
56
  Compléter par le bon symbole :
57
57
 
@@ -64,7 +64,7 @@ const getInstruction = (identifiers) => {
64
64
  const table = getTable(identifiers);
65
65
  let instruction = `On considère la fonction $f$ dont le tableau de variations est donné ci-dessous :
66
66
 
67
- <svg id='varTable'>${JSON.stringify(table)}</svg>
67
+ <svg id="varTable">${JSON.stringify(table)}</svg>
68
68
 
69
69
  ${identifiers.isAskingX
70
70
  ? `Sur l'intervalle $${interval.toTex()}$, en quelle valeur le ${type} de la fonction $f$ est-il atteint ?`
@@ -3,6 +3,7 @@ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
3
  type Identifiers = {
4
4
  vars: string[];
5
5
  xs: NodeIdentifiers[];
6
+ initTable: string[][];
6
7
  };
7
8
  export declare const varTableFromSentences: Exercise<Identifiers>;
8
9
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"varTableFromSentences.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/varTableFromSentences.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,EAAE,EAAE,eAAe,EAAE,CAAC;CACvB,CAAC;AAyKF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
1
+ {"version":3,"file":"varTableFromSentences.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/varTableFromSentences.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAwLF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
@@ -134,9 +134,21 @@ const getVarTableFromSentencesQuestion = (ops) => {
134
134
  const identifiers = {
135
135
  xs: xs.map((e) => e.toTree().toIdentifiers()),
136
136
  vars,
137
+ initTable: getInitTable(),
137
138
  };
138
139
  return getQuestionFromIdentifiers(identifiers);
139
140
  };
141
+ const getInitTable = () => {
142
+ const stringed = ["", "\\ ", "", "\\ ", "", "\\ ", ""];
143
+ const emptyLine = ["\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ "];
144
+ const inputLine = ["", "", "", "", "", "", ""];
145
+ return [
146
+ ["$x$", ...stringed],
147
+ ["$\\ $", ...emptyLine],
148
+ ["$f(x)$", ...inputLine],
149
+ ["$\\ $", ...emptyLine],
150
+ ];
151
+ };
140
152
  const getQuestionFromIdentifiers = (identifiers) => {
141
153
  return {
142
154
  answerTable: getAnswerTable(identifiers),
@@ -146,6 +158,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
146
158
  identifiers,
147
159
  hint: getHint(identifiers),
148
160
  correction: getCorrection(identifiers),
161
+ initTable: identifiers.initTable,
149
162
  };
150
163
  };
151
164
  export const varTableFromSentences = {
@@ -165,3 +178,5 @@ export const varTableFromSentences = {
165
178
  hasHintAndCorrection: true,
166
179
  answerType: "varTable",
167
180
  };
181
+ // caca
182
+ // /pas d'init table ?
@@ -1 +1 @@
1
- {"version":3,"file":"chasles.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/chasles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAqFF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAYzC,CAAC"}
1
+ {"version":3,"file":"chasles.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/chasles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAyKF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAazC,CAAC"}
@@ -3,15 +3,19 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { random } from "../../../../utils/alea/random.js";
5
5
  import { shuffle } from "../../../../utils/alea/shuffle.js";
6
- const getInstruction = (identifiers) => {
6
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
7
+ const getStatement = (identifiers) => {
7
8
  const { randLetters, vectors } = identifiers;
8
9
  let statement = vectors.join("");
9
10
  if (statement[0] === "+")
10
11
  statement = statement.slice(1, statement.length);
12
+ return statement;
13
+ };
14
+ const getInstruction = (identifiers) => {
11
15
  return `Simplifier :
12
16
 
13
17
  $$
14
- ${statement}
18
+ ${getStatement(identifiers)}
15
19
  $$`;
16
20
  };
17
21
  const getAnswer = (identifiers) => {
@@ -21,11 +25,83 @@ const getAnswer = (identifiers) => {
21
25
  };
22
26
  const getKeys = (identifiers) => {
23
27
  const { randLetters, vectors } = identifiers;
28
+ const copy = [...randLetters];
24
29
  return [
25
30
  "overrightarrow",
26
- ...randLetters.sort((a, b) => a.localeCompare(b)),
31
+ ...copy.sort((a, b) => a.localeCompare(b)),
27
32
  ];
28
33
  };
34
+ const getHint = (identifiers) => {
35
+ return `Tu peux utiliser les deux propriétés suivantes : d'une part, pour tous points $A$ et $B$,
36
+
37
+ $$
38
+ -\\overrightarrow{AB} = \\overrightarrow{BA}
39
+ $$
40
+
41
+ et d'autre part, pour tous points $A$, $B$ et $C$, la relation de Chasles :
42
+
43
+ $$
44
+ \\overrightarrow{AB} + \\overrightarrow{BC} = \\overrightarrow{AC}
45
+ $$`;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { randLetters, vectors } = identifiers;
49
+ const answerVec = `${randLetters[0]}${randLetters[vectors.length]}`;
50
+ const vecs = identifiers.vectors.map((v) => v.replace("\\overrightarrow{", "").replace("}", ""));
51
+ const positives = vecs.map((e) => (e[0] === "-" ? `+${e[2]}${e[1]}` : e));
52
+ const positiveStatement = positives
53
+ .map((e) => `${e[0]}\\overrightarrow{${e.slice(1)}}`)
54
+ .join("")
55
+ .slice(1);
56
+ const ordered = [];
57
+ ordered.push(positives.find((v) => v[1] === answerVec[0]));
58
+ for (let i = 1; i < positives.length; i++) {
59
+ ordered.push(positives.find((v) => v[1] === ordered[i - 1][2]));
60
+ }
61
+ const orderedStatement = ordered
62
+ .map((e) => `${e[0]}\\overrightarrow{${e.slice(1)}}`)
63
+ .join("")
64
+ .slice(1);
65
+ // for (let i = 0; i < positives.length; i++) {
66
+ // const vec = positives[i];
67
+ // const next = positives[i + 1];
68
+ // if (vec[0] === next[2]) {
69
+ // ordered.push(next, vec);
70
+ // i++;
71
+ // }
72
+ // }
73
+ let corr = "";
74
+ if (identifiers.vectors.some((vec) => vec[0] === "-")) {
75
+ corr += `On commence par supprimer les signes $-$, en utilisant la propriété :
76
+
77
+ $$
78
+ -\\overrightarrow{AB} = \\overrightarrow{BA}
79
+ $$
80
+
81
+ On a donc :
82
+
83
+ ${alignTex([
84
+ ["", getStatement(identifiers)],
85
+ ["=", positiveStatement],
86
+ ])}
87
+ `;
88
+ }
89
+ if (ordered.some((v, i) => positives[i] !== v)) {
90
+ corr += `On déplace les vecteurs de sorte à pouvoir utiliser la relation de Chasles :
91
+
92
+ ${alignTex([
93
+ ["", positiveStatement],
94
+ ["=", orderedStatement],
95
+ ])}`;
96
+ }
97
+ return (corr +
98
+ `\n \n On applique la relation de Chasles :
99
+
100
+ ${alignTex([
101
+ ["", orderedStatement],
102
+ ["=", getAnswer(identifiers)],
103
+ ])}`);
104
+ };
29
105
  const getQuestionFromIdentifiers = (identifiers) => {
30
106
  const question = {
31
107
  answer: getAnswer(identifiers),
@@ -33,6 +109,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
33
109
  keys: getKeys(identifiers),
34
110
  answerFormat: "tex",
35
111
  identifiers,
112
+ hint: getHint(identifiers),
113
+ correction: getCorrection(identifiers),
36
114
  };
37
115
  return question;
38
116
  };
@@ -71,7 +149,7 @@ const isAnswerValid = (ans, { answer }) => {
71
149
  export const chasles = {
72
150
  id: "chasles",
73
151
  connector: "=",
74
- label: "Relation de Chasles pour les vecteurs",
152
+ label: "Simplifier une somme de vecteurs par la relation de Chasles",
75
153
  isSingleStep: true,
76
154
  generator: (nb) => getDistinctQuestions(getChaslesQuestion, nb),
77
155
  qcmTimer: 60,
@@ -80,4 +158,5 @@ export const chasles = {
80
158
  isAnswerValid,
81
159
  subject: "Mathématiques",
82
160
  getQuestionFromIdentifiers,
161
+ hasHintAndCorrection: true,
83
162
  };
@@ -1 +1 @@
1
- {"version":3,"file":"determinant.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/determinant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAwFF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAY7C,CAAC"}
1
+ {"version":3,"file":"determinant.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/determinant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA6GF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAa7C,CAAC"}
@@ -2,21 +2,54 @@ import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Vector, VectorConstructor } from "../../../../math/geometry/vector.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
- import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
5
  import { shuffle } from "../../../../utils/alea/shuffle.js";
7
- const getInstruction = (identifiers) => {
6
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
7
+ const getVectors = (identifiers) => {
8
8
  const u = new Vector("u", Number(identifiers.uCoords[0]).toTree(), Number(identifiers.uCoords[1]).toTree());
9
- const v = new Vector("v", Number(identifiers.uCoords[0]).toTree(), Number(identifiers.uCoords[1]).toTree());
9
+ const v = new Vector("v", Number(identifiers.vCoords[0]).toTree(), Number(identifiers.vCoords[1]).toTree());
10
+ return { u, v };
11
+ };
12
+ const getInstruction = (identifiers) => {
13
+ const { u, v } = getVectors(identifiers);
10
14
  return `Soient les vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$.
11
15
 
12
- Calculer le déterminant $\\det(\\overrightarrow u;\\overrightarrow v)$.`;
16
+ Calculer le déterminant $\\det(\\overrightarrow{u};\\overrightarrow{v})$.`;
13
17
  };
14
18
  const getAnswer = (identifiers) => {
15
- const u = new Vector("u", Number(identifiers.uCoords[0]).toTree(), Number(identifiers.uCoords[1]).toTree());
16
- const v = new Vector("v", Number(identifiers.uCoords[0]).toTree(), Number(identifiers.uCoords[1]).toTree());
19
+ const { u, v } = getVectors(identifiers);
17
20
  const answer = u.determinant(v).simplify();
18
21
  return answer.toTex();
19
22
  };
23
+ const getHint = (identifiers) => {
24
+ const u = new Vector("u", "x".toTree(), "y".toTree());
25
+ const v = new Vector("v", "x'".toTree(), "y'".toTree());
26
+ return `Le déterminant de deux vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$ s'obtient par la formule :
27
+
28
+ $$
29
+ \\det(\\overrightarrow{u}, \\overrightarrow{v})= xy' - x'y
30
+ $$`;
31
+ };
32
+ const getCorrection = (identifiers) => {
33
+ const uGlobal = new Vector("u", "x".toTree(), "y".toTree());
34
+ const vGlobal = new Vector("v", "x'".toTree(), "y'".toTree());
35
+ const { u, v } = getVectors(identifiers);
36
+ return `Le déterminant de deux vecteurs $${uGlobal.toTexWithCoords()}$ et $${vGlobal.toTexWithCoords()}$ s'obtient par la formule :
37
+
38
+ $$
39
+ \\det(\\overrightarrow{u}, \\overrightarrow{v})= xy' - x'y
40
+ $$
41
+
42
+ Ici, on a donc :
43
+
44
+ ${alignTex([
45
+ [
46
+ `\\det(\\overrightarrow{u}, \\overrightarrow{v})`,
47
+ "=",
48
+ `${u.determinant(v).toTex()}`,
49
+ ],
50
+ ["", "=", `${u.determinant(v).simplify().toTex()}`],
51
+ ])}`;
52
+ };
20
53
  const getQuestionFromIdentifiers = (identifiers) => {
21
54
  const question = {
22
55
  answer: getAnswer(identifiers),
@@ -24,6 +57,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
24
57
  keys: [],
25
58
  answerFormat: "tex",
26
59
  identifiers,
60
+ hint: getHint(identifiers),
61
+ correction: getCorrection(identifiers),
27
62
  };
28
63
  return question;
29
64
  };
@@ -36,11 +71,10 @@ const getDeterminantQuestion = () => {
36
71
  };
37
72
  return getQuestionFromIdentifiers(identifiers);
38
73
  };
39
- const getPropositions = (n, { answer, uCoords, vCoords }) => {
74
+ const getPropositions = (n, { answer, ...identifiers }) => {
40
75
  const propositions = [];
41
76
  addValidProp(propositions, answer);
42
- const u = new Vector("u", new NumberNode(Number(uCoords[0])), new NumberNode(Number(uCoords[1])));
43
- const v = new Vector("v", new NumberNode(Number(vCoords[0])), new NumberNode(Number(vCoords[1])));
77
+ const { u, v } = getVectors(identifiers);
44
78
  tryToAddWrongProp(propositions, u.scalarProduct(v).toTex());
45
79
  while (propositions.length < n) {
46
80
  const wrongAnswer = randint(-20, 20) + "";
@@ -63,4 +97,5 @@ export const determinant = {
63
97
  isAnswerValid,
64
98
  subject: "Mathématiques",
65
99
  getQuestionFromIdentifiers,
100
+ hasHintAndCorrection: true,
66
101
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pyWhileLoop1Exercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pyWhileLoop1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;CAKZ,CAAC;AAwIF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
1
+ {"version":3,"file":"pyWhileLoop1Exercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pyWhileLoop1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;CAKZ,CAAC;AAwIF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1215,6 +1215,7 @@ declare const mathExercises: (Exercise<{
1215
1215
  }, {}> | Exercise<{
1216
1216
  vars: string[];
1217
1217
  xs: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
1218
+ initTable: string[][];
1218
1219
  }, {}> | Exercise<{
1219
1220
  type: number;
1220
1221
  coeffs: number[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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","sources":["../../src/tests/pdfExo.test.ts"],"names":[],"mappings":"AA2BA,OAAO,6BAA6B,CAAC"}
@@ -1,8 +1,8 @@
1
- import { subsetsOfKnownSets, } from "../exercises/math/index.js";
1
+ import { valueTableCompletion, } from "../exercises/math/index.js";
2
2
  import { buildPdfForExercise } from "./pdfs/buildPDFForExercise.js";
3
3
  import "../prototypesEnhancement.js";
4
4
  try {
5
- buildPdfForExercise(subsetsOfKnownSets);
5
+ buildPdfForExercise(valueTableCompletion);
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,EAAyB,MAAM,6BAA6B,CAAC;AAI9E,eAAO,MAAM,mBAAmB,QAAS,QAAQ,SAkHhD,CAAC"}
1
+ {"version":3,"file":"buildPDFForExercise.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/buildPDFForExercise.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAyB,MAAM,6BAA6B,CAAC;AAQ9E,eAAO,MAAM,mBAAmB,QAAS,QAAQ,SA0KhD,CAAC"}
@@ -7,6 +7,9 @@ import fs from "fs";
7
7
  import latex from "node-latex";
8
8
  import { fileURLToPath } from "url";
9
9
  import path from "path";
10
+ import { signTableToLatex } from "./signTableToLatex.js";
11
+ import { varTableToLatex } from "./varTableToLatex.js";
12
+ import { valueTableToLatex } from "./valueTableToLatex.js";
10
13
  export const buildPdfForExercise = (exo) => {
11
14
  const __filename = fileURLToPath(import.meta.url);
12
15
  const __dirname = path.dirname(__filename);
@@ -26,11 +29,37 @@ export const buildPdfForExercise = (exo) => {
26
29
  for (const match of matches) {
27
30
  question.instruction = question.instruction.replace(match[0], ``);
28
31
  }
32
+ const signTableRegex = /<svg id=["']signTable["']>([\s\S]*?)<\/svg>/g;
33
+ const signTableMatches = question.instruction.matchAll(signTableRegex);
34
+ for (const match of signTableMatches) {
35
+ question.instruction = question.instruction.replace(match[0], signTableToLatex(JSON.parse(match[1])));
36
+ }
37
+ const varTableRegex = /<svg id=["']varTable["']>([\s\S]*?)<\/svg>/g;
38
+ const varTableMatches = question.instruction.matchAll(varTableRegex);
39
+ for (const match of varTableMatches) {
40
+ question.instruction = question.instruction.replace(match[0], varTableToLatex(JSON.parse(match[1])));
41
+ }
29
42
  const formatted = formatMarkdownToLatex(question.instruction);
30
43
  content += `
31
44
  ${formatted} \n
32
45
  `;
33
- if (exo.answerType !== "GGB") {
46
+ if (question.initTable) {
47
+ if (exo.answerType === "signTable") {
48
+ content += signTableToLatex(question.initTable, true);
49
+ }
50
+ if (exo.answerType === "varTable") {
51
+ content += varTableToLatex(question.initTable, true);
52
+ }
53
+ if (exo.answerType === "valueTable") {
54
+ //!TODO
55
+ // content += mdTableToLatexTabular(question.initTable)
56
+ content += valueTableToLatex(question.initTable);
57
+ }
58
+ }
59
+ if (exo.answerType !== "GGB" &&
60
+ exo.answerType !== "valueTable" &&
61
+ exo.answerType !== "signTable" &&
62
+ exo.answerType !== "varTable") {
34
63
  propositions = exo.getPropositions(4, {
35
64
  answer: question.answer,
36
65
  ...question.identifiers,
@@ -66,17 +95,41 @@ export const buildPdfForExercise = (exo) => {
66
95
  content += "\\textbf{Correction : } ";
67
96
  if (question.correction) {
68
97
  content += formatMarkdownToLatex(question.correction);
98
+ if (question.answerTable) {
99
+ if (exo.answerType === "signTable") {
100
+ content += signTableToLatex(question.answerTable);
101
+ }
102
+ else if (exo.answerType === "varTable") {
103
+ content += varTableToLatex(question.answerTable);
104
+ }
105
+ else if (exo.answerType === "valueTable") {
106
+ // à mettre dans la correction direct
107
+ }
108
+ }
69
109
  }
70
110
  else {
71
111
  if (exo.answerType === "GGB") {
72
112
  content += "Correction GGB";
73
113
  }
74
114
  else {
75
- const answers = propositions.filter((prop) => prop.isRightAnswer);
76
- answers?.forEach((ans) => {
77
- content +=
78
- ans.format === "raw" ? ans.statement : `$${ans.statement}$`;
79
- });
115
+ if (question.answerTable) {
116
+ if (exo.answerType === "signTable") {
117
+ content += signTableToLatex(question.answerTable);
118
+ }
119
+ else if (exo.answerType === "varTable") {
120
+ content += varTableToLatex(question.answerTable);
121
+ }
122
+ else if (exo.answerType === "valueTable") {
123
+ // à mettre dans la correction direct
124
+ }
125
+ }
126
+ else {
127
+ const answers = propositions.filter((prop) => prop.isRightAnswer);
128
+ answers?.forEach((ans) => {
129
+ content +=
130
+ ans.format === "raw" ? ans.statement : `$${ans.statement}$`;
131
+ });
132
+ }
80
133
  }
81
134
  }
82
135
  content += "\\end{correctionColored}";
@@ -1 +1 @@
1
- {"version":3,"file":"quizPdfPreambule.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/quizPdfPreambule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,cA4E5B,CAAC"}
1
+ {"version":3,"file":"quizPdfPreambule.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/quizPdfPreambule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,cA6E5B,CAAC"}
@@ -1,5 +1,7 @@
1
1
  export const quizPdfPreambule = () => {
2
2
  return `\\documentclass[a4paper, 8pt]{article}
3
+ \\usepackage{tikz}
4
+ \\usepackage{tkz-tab}
3
5
  \\usepackage[dvipsnames]{xcolor}
4
6
  \\usepackage[utf8]{inputenc}
5
7
  \\usepackage[T1]{fontenc}
@@ -19,7 +21,6 @@ export const quizPdfPreambule = () => {
19
21
  \\usepackage{qrcode}
20
22
  \\usepackage{listings}
21
23
  \\usepackage{hyperref}
22
- \\usepackage{tikz}
23
24
  \\usepackage{amssymb}
24
25
  \\usepackage{fancyhdr}
25
26
  \\usepackage{cancel}
@@ -0,0 +1,2 @@
1
+ export declare const signTableToLatex: (arr: string[][], isInput?: boolean) => string;
2
+ //# sourceMappingURL=signTableToLatex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signTableToLatex.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/signTableToLatex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,QAAS,MAAM,EAAE,EAAE,8BA2B/C,CAAC"}
@@ -0,0 +1,32 @@
1
+ export const signTableToLatex = (arr, isInput = false) => {
2
+ const width = arr[0].length;
3
+ // const formated = arr.map((row) =>
4
+ // row.map((e) => (e === "\\ " ? " " : e)),
5
+ // );
6
+ const size = isInput ? `[lgt = 1.5, espcl=2]` : `[lgt = 1.5, espcl=1.5]`;
7
+ return `\n \n
8
+ \\begin{tikzpicture}
9
+ \\tkzTabInit${size}{${arr
10
+ .map((row) => `${dollarize(row[0])} /1`)
11
+ .join(",")}}{${arr[0]
12
+ .slice(1)
13
+ .filter((e) => e !== "\\ ")
14
+ .map((e) => dollarize(e))
15
+ .join(",")}}
16
+ ${arr
17
+ .slice(1)
18
+ .map((row) => `\\tkzTabLine{${row
19
+ .slice(1)
20
+ .map((e) => (e === "0" ? "z" : e === "\\ " || e === "" ? " " : e))
21
+ .join(",")}}`)
22
+ .join("\n")}
23
+ \\end{tikzpicture} \n \n
24
+ `;
25
+ };
26
+ const dollarize = (s) => {
27
+ if (s === " " || s === "")
28
+ return s;
29
+ if (s[0] === "$" && s[s.length - 1] === "$")
30
+ return s;
31
+ return "$" + s + "$";
32
+ };
@@ -0,0 +1,2 @@
1
+ export declare const valueTableToLatex: (arr: string[][]) => string;
2
+ //# sourceMappingURL=valueTableToLatex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueTableToLatex.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/valueTableToLatex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAS,MAAM,EAAE,EAAE,WAQhD,CAAC"}
@@ -0,0 +1,18 @@
1
+ export const valueTableToLatex = (arr) => {
2
+ const width = arr[0].length;
3
+ const alignement = "|c".repeat(width) + "|";
4
+ let res = `\n \n \\begin{center}\\begin{tabular}{${alignement}} \n ` +
5
+ arr.map((row, i) => formatRow(row, i)).join(" \\tabularnewline ") +
6
+ "\\tabularnewline \\hline \\end{tabular}\\end{center} \n \n";
7
+ return res;
8
+ };
9
+ const dollarize = (s) => {
10
+ if (s === " " || s === "")
11
+ return s;
12
+ if (s[0] === "$" && s[s.length - 1] === "$")
13
+ return s;
14
+ return "$" + s + "$";
15
+ };
16
+ const formatRow = (row, i) => {
17
+ return "\\hline " + row.map((el) => dollarize(el)).join(" & ");
18
+ };
@@ -0,0 +1,2 @@
1
+ export declare const varTableToLatex: (arr: string[][], isInput?: boolean) => string;
2
+ //# sourceMappingURL=varTableToLatex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varTableToLatex.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/varTableToLatex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QAAS,MAAM,EAAE,EAAE,8BA2C9C,CAAC"}
@@ -0,0 +1,58 @@
1
+ export const varTableToLatex = (arr, isInput = false) => {
2
+ if (isInput)
3
+ return getInputVarTable(arr);
4
+ const formated = arr.map((row) => row.map((e) => (e === "" || e === "\\ " ? " " : e)));
5
+ const final = [formated[0], [formated[2][0]]];
6
+ for (let i = 1; i < arr[0].length; i++) {
7
+ const data = formated[1][i] !== " "
8
+ ? formated[1][i]
9
+ : formated[2][i] !== " "
10
+ ? formated[2][i]
11
+ : formated[3][i];
12
+ final[1][i] = data;
13
+ }
14
+ const varLine = [];
15
+ for (let i = 1; i < final[1].length; i++) {
16
+ const current = final[1][i];
17
+ if (current === "\\nearrow" || current === "\\searrow")
18
+ continue;
19
+ if (i === final[1].length - 1) {
20
+ const prev = final[1][i - 1];
21
+ varLine.push(`${prev === "\\nearrow" ? "+" : "-"}/ ${dollarize(current)}`);
22
+ }
23
+ else {
24
+ const next = final[1][i + 1];
25
+ varLine.push(`${next === "\\nearrow" ? "-" : "+"}/ ${dollarize(current)}`);
26
+ }
27
+ }
28
+ return `\n \n
29
+ \\begin{tikzpicture}
30
+ \\tkzTabInit[lgt=1.5,espcl=1.5]{${final
31
+ .map((row, i) => `${dollarize(row[0])} /${i === 0 ? "1" : "1.5"}`)
32
+ .join(",")}}{${final[0]
33
+ .slice(1)
34
+ .filter((e) => e !== " ")
35
+ .map((e) => dollarize(e))
36
+ .join(",")}}
37
+ \\tkzTabVar{${varLine.join(",")}}
38
+ \\end{tikzpicture} \n \n
39
+ `;
40
+ };
41
+ const dollarize = (s) => {
42
+ if (s === " " || s === "")
43
+ return s;
44
+ if (s[0] === "$" && s[s.length - 1] === "$")
45
+ return s;
46
+ return "$" + s + "$";
47
+ };
48
+ const getInputVarTable = (arr) => {
49
+ const width = arr[0].length;
50
+ const alignement = "|c|" + "c".repeat(width - 1) + "|";
51
+ let res = ` \\begin{center}\\begin{tabular}{${alignement}} \n \\hline ` +
52
+ arr.map((row, i) => formatRow(row, i)).join(" \\tabularnewline ") +
53
+ "\\tabularnewline \\hline \\end{tabular}\\end{center} ";
54
+ return res;
55
+ };
56
+ const formatRow = (row, i) => {
57
+ return ((i === 1 ? "\\hline " : "") + row.map((el) => dollarize(el)).join(" & "));
58
+ };
@@ -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;AAIjE,eAAO,MAAM,YAAY,QAAS,QAAQ,YAAY,QAAQ;;;CAkN7D,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;AAIjE,eAAO,MAAM,YAAY,QAAS,QAAQ,YAAY,QAAQ;;;CA4N7D,CAAC"}
@@ -37,6 +37,12 @@ export const questionTest = (exo, question) => {
37
37
  throw new Error(`exo ${exo.id} has studentGgbOptions but answerType is not GGB`);
38
38
  }
39
39
  }
40
+ if (question.initTable?.length &&
41
+ exo.answerType !== "valueTable" &&
42
+ exo.answerType !== "varTable" &&
43
+ exo.answerType !== "signTable") {
44
+ throw new Error(`exo ${exo.id} has init table but is not tableExo`);
45
+ }
40
46
  if (exo.answerType === "GGB") {
41
47
  if (!question.ggbAnswer?.length)
42
48
  throw new Error(`exo ${exo.id} has no ggbAnswer`);
@@ -48,6 +54,8 @@ export const questionTest = (exo, question) => {
48
54
  exo.answerType === "signTable") {
49
55
  if (!question.answerTable?.length)
50
56
  throw new Error(`exo ${exo.id} has no answerTable`);
57
+ if (!question.initTable?.length)
58
+ throw new Error(`exo ${exo.id} has no initTable`);
51
59
  }
52
60
  else if (exo.answerType !== "QCU" && exo.answerType !== "QCM") {
53
61
  if (!question.answer)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.98",
4
+ "version": "3.0.99",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [