math-exercises 3.0.89 → 3.0.90

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 (57) hide show
  1. package/lib/exercises/math/calcul/arithmetics/isInequalityTrue.js +2 -2
  2. package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.d.ts.map +1 -1
  3. package/lib/exercises/math/conversion/lengthConversion.js +1 -1
  4. package/lib/exercises/math/functions/affines/affineFromExercise.d.ts +9 -0
  5. package/lib/exercises/math/functions/affines/affineFromExercise.d.ts.map +1 -0
  6. package/lib/exercises/math/functions/affines/affineFromExercise.js +111 -0
  7. package/lib/exercises/math/functions/affines/index.d.ts +1 -0
  8. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  9. package/lib/exercises/math/functions/affines/index.js +1 -0
  10. package/lib/exercises/math/functions/parity/finishParityFunctionGraph.d.ts +9 -0
  11. package/lib/exercises/math/functions/parity/finishParityFunctionGraph.d.ts.map +1 -0
  12. package/lib/exercises/math/functions/parity/finishParityFunctionGraph.js +154 -0
  13. package/lib/exercises/math/functions/parity/index.d.ts +1 -0
  14. package/lib/exercises/math/functions/parity/index.d.ts.map +1 -1
  15. package/lib/exercises/math/functions/parity/index.js +1 -0
  16. package/lib/exercises/math/functions/sign/affineProductSignTable.d.ts +9 -0
  17. package/lib/exercises/math/functions/sign/affineProductSignTable.d.ts.map +1 -0
  18. package/lib/exercises/math/functions/sign/affineProductSignTable.js +201 -0
  19. package/lib/exercises/math/functions/sign/affineSignTable.d.ts +8 -0
  20. package/lib/exercises/math/functions/sign/affineSignTable.d.ts.map +1 -0
  21. package/lib/exercises/math/functions/sign/affineSignTable.js +111 -0
  22. package/lib/exercises/math/functions/sign/index.d.ts +4 -0
  23. package/lib/exercises/math/functions/sign/index.d.ts.map +1 -1
  24. package/lib/exercises/math/functions/sign/index.js +4 -0
  25. package/lib/exercises/math/functions/sign/readSignTable.d.ts +10 -0
  26. package/lib/exercises/math/functions/sign/readSignTable.d.ts.map +1 -0
  27. package/lib/exercises/math/functions/sign/readSignTable.js +124 -0
  28. package/lib/exercises/math/functions/sign/signTableFromGraph.d.ts +11 -0
  29. package/lib/exercises/math/functions/sign/signTableFromGraph.d.ts.map +1 -0
  30. package/lib/exercises/math/functions/sign/signTableFromGraph.js +141 -0
  31. package/lib/exercises/math/functions/variations/compareImagesInVarTable.d.ts +11 -0
  32. package/lib/exercises/math/functions/variations/compareImagesInVarTable.d.ts.map +1 -0
  33. package/lib/exercises/math/functions/variations/compareImagesInVarTable.js +153 -0
  34. package/lib/exercises/math/functions/variations/index.d.ts +2 -0
  35. package/lib/exercises/math/functions/variations/index.d.ts.map +1 -1
  36. package/lib/exercises/math/functions/variations/index.js +2 -0
  37. package/lib/exercises/math/functions/variations/varTableFromGraph.d.ts +9 -0
  38. package/lib/exercises/math/functions/variations/varTableFromGraph.d.ts.map +1 -0
  39. package/lib/exercises/math/functions/variations/varTableFromGraph.js +184 -0
  40. package/lib/exercises/math/geometry/vectors/distributeAndReduceVectors.d.ts.map +1 -1
  41. package/lib/exercises/math/geometry/vectors/distributeAndReduceVectors.js +23 -4
  42. package/lib/exercises/math/geometry/vectors/index.d.ts +1 -0
  43. package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
  44. package/lib/exercises/math/geometry/vectors/index.js +1 -1
  45. package/lib/exercises/math/tests/index.d.ts +0 -2
  46. package/lib/exercises/math/tests/index.d.ts.map +1 -1
  47. package/lib/exercises/math/tests/index.js +0 -2
  48. package/lib/exercises/math/tests/testVarTable.js +2 -2
  49. package/lib/geogebra/parsers/ggbPointsToPoints.d.ts +3 -0
  50. package/lib/geogebra/parsers/ggbPointsToPoints.d.ts.map +1 -0
  51. package/lib/geogebra/parsers/ggbPointsToPoints.js +12 -0
  52. package/lib/index.d.ts +38 -7
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/playground.d.ts.map +1 -1
  55. package/lib/tree/nodes/operators/addNode.js +1 -1
  56. package/lib/tree/parsers/latexParser.js +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,111 @@
1
+ import { addValidProp, shuffleProps, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
4
+ import { firstDegreeInequationResolutionTex } from "../../../../tree/nodes/inequations/inequationNode.js";
5
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ const getPropositions = (n, { answer }) => {
9
+ const propositions = [];
10
+ addValidProp(propositions, answer);
11
+ while (propositions.length < n) {
12
+ throw Error("QCM not implemented");
13
+ }
14
+ return shuffleProps(propositions, n);
15
+ };
16
+ const getAnswerTable = (identifiers) => {
17
+ const affine = AffineConstructor.fromCoeffs(identifiers.affineCoeffs);
18
+ const root = affine.getRoot().toTree();
19
+ const signs = affine.a > 0 ? ["-", "+"] : ["+", "-"];
20
+ return [
21
+ ["$x$", "-\\infty", "\\ ", root.toTex(), "\\ ", "+\\infty"],
22
+ ["$f(x)$", "\\ ", signs[0], "0", signs[1], "\\ "],
23
+ ];
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const affine = AffineConstructor.fromCoeffs(identifiers.affineCoeffs);
27
+ const arr = [["a", "b", "c"], "d", "ef", "f"];
28
+ return `Dresser le tableau de signes de la fonction $f$ définie sur $\\mathbb{R}$ par :
29
+
30
+ $$
31
+ f(x) = ${affine.toTree().toTex()}
32
+ $$
33
+
34
+
35
+ <svg id="signTable">${JSON.stringify(arr)}</svg>`;
36
+ };
37
+ const getHint = (identifiers) => {
38
+ return `Résout l'inéquation $f(x)>0$.`;
39
+ };
40
+ const getCorrection = (identifiers) => {
41
+ const { affineCoeffs, initTable } = identifiers;
42
+ const affine = AffineConstructor.fromCoeffs(affineCoeffs);
43
+ const root = affine.getRoot().toTree();
44
+ const signs = affine.a > 0 ? ["-", "+"] : ["+", "-"];
45
+ return `On résout l'inéquation $f(x)>0$ :
46
+
47
+ $$
48
+ ${firstDegreeInequationResolutionTex(affine, ">", new NumberNode(0))}
49
+ $$
50
+
51
+ On en déduit que $f(x)$ est ${affine.a > 0 ? "négative" : "positive"} sur $]-\\infty; ${root.toTex()}]$ et ${affine.a > 0 ? "positive" : "négative"} sur $[${root.toTex()}; +\\infty[$.
52
+ `;
53
+ };
54
+ const getKeys = (identifiers) => {
55
+ return ["infty"];
56
+ };
57
+ const isAnswerTableValid = (ans, { answerTable }) => {
58
+ try {
59
+ return ans.every((row, i) => row.every((cell, j) => i === 0 && j === 3
60
+ ? parseAlgebraic(cell)
61
+ .simplify({ decimalToFractions: true })
62
+ .simplify()
63
+ .toTex() === answerTable[i][j]
64
+ : cell === answerTable[i][j]));
65
+ }
66
+ catch (err) {
67
+ return handleVEAError(err);
68
+ }
69
+ };
70
+ const getTestSignTableQuestion = (ops) => {
71
+ const aff = AffineConstructor.random();
72
+ const initTable = [
73
+ ["$x$", "", "\\ ", "", "\\ ", ""],
74
+ ["$f(x)$", "\\ ", "", "", "", "\\ "],
75
+ ];
76
+ const identifiers = {
77
+ affineCoeffs: aff.coefficients,
78
+ initTable,
79
+ };
80
+ return getQuestionFromIdentifiers(identifiers);
81
+ };
82
+ const getQuestionFromIdentifiers = (identifiers) => {
83
+ return {
84
+ answerTable: getAnswerTable(identifiers),
85
+ instruction: getInstruction(identifiers),
86
+ keys: getKeys(identifiers),
87
+ answerFormat: "tex",
88
+ identifiers,
89
+ hint: getHint(identifiers),
90
+ correction: getCorrection(identifiers),
91
+ initTable: identifiers.initTable,
92
+ };
93
+ };
94
+ export const affineSignTable = {
95
+ id: "affineSignTable",
96
+ label: "Dresser le tableau de signes d'une fonction affine",
97
+ isSingleStep: true,
98
+ generator: (nb, opts) => getDistinctQuestions(() => getTestSignTableQuestion(opts), nb),
99
+ qcmTimer: 60,
100
+ freeTimer: 60,
101
+ getPropositions,
102
+ isAnswerTableValid,
103
+ subject: "Mathématiques",
104
+ getInstruction,
105
+ getHint,
106
+ getCorrection,
107
+ getAnswerTable,
108
+ getQuestionFromIdentifiers,
109
+ hasHintAndCorrection: true,
110
+ answerType: "signTable",
111
+ };
@@ -1,2 +1,6 @@
1
1
  export * from "./affineProductSign.js";
2
+ export * from "./affineSignTable.js";
3
+ export * from "./affineProductSignTable.js";
4
+ export * from "./readSignTable.js";
5
+ export * from "./signTableFromGraph.js";
2
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
@@ -1 +1,5 @@
1
1
  export * from "./affineProductSign.js";
2
+ export * from "./affineSignTable.js";
3
+ export * from "./affineProductSignTable.js";
4
+ export * from "./readSignTable.js";
5
+ export * from "./signTableFromGraph.js";
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ signs: string[];
5
+ xs: NodeIdentifiers[];
6
+ x: NodeIdentifiers;
7
+ };
8
+ export declare const readSignTable: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=readSignTable.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,124 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
5
+ import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
6
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
7
+ const getPropositions = (n, { answer }) => {
8
+ const propositions = [];
9
+ addValidProp(propositions, answer, "raw");
10
+ tryToAddWrongProp(propositions, "Positif", "raw");
11
+ tryToAddWrongProp(propositions, "Négatif", "raw");
12
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
13
+ return shuffleProps(propositions, n);
14
+ };
15
+ const getAnswer = (identifiers) => {
16
+ const { xs, signs, x } = identifiers;
17
+ const xEv = reifyAlgebraic(x).evaluate();
18
+ const evals = xs.map((e) => reifyAlgebraic(e).evaluate());
19
+ for (let i = 0; i < evals.length - 1; i++) {
20
+ const a = evals[i];
21
+ const b = evals[i + 1];
22
+ if (a < xEv && b > xEv) {
23
+ const ans = signs[2 * i];
24
+ if (ans === "+")
25
+ return "Positif";
26
+ if (ans === "-")
27
+ return "Négatif";
28
+ }
29
+ }
30
+ return "";
31
+ };
32
+ const getInstruction = (identifiers) => {
33
+ const { xs, signs, x } = identifiers;
34
+ const firstRow = [];
35
+ for (let i = 0; i < xs.length; i++) {
36
+ firstRow.push(`${reifyAlgebraic(xs[i]).toTex()}`);
37
+ i < xs.length - 1 && firstRow.push(`\\ `);
38
+ }
39
+ const secondRow = ["\\ ", ...signs, "\\ "];
40
+ const table = [
41
+ [`x`, ...firstRow],
42
+ [`f(x)`, ...secondRow],
43
+ ];
44
+ return `On considère le tableau de signes suivant d'une fonction $f$ :
45
+
46
+ <svg id="signTable">${JSON.stringify(table)}</svg>
47
+
48
+ Quel est le signe de $f(${reifyAlgebraic(x).toTex()})$ ?`;
49
+ };
50
+ const getHint = (identifiers) => {
51
+ const { xs, signs, x } = identifiers;
52
+ const xEv = reifyAlgebraic(x);
53
+ return `Repère où se situe $${xEv.toTex()}$ dans la première ligne.
54
+
55
+ Puis, utilise la deuxième ligne pour déterminer le signe de $f(${xEv.toTex()})$.`;
56
+ };
57
+ const getCorrection = (identifiers) => {
58
+ const { xs, signs, x } = identifiers;
59
+ const xNode = reifyAlgebraic(x);
60
+ const xEv = xNode.evaluate();
61
+ const evals = xs.map((e) => reifyAlgebraic(e).evaluate());
62
+ let aNode;
63
+ let bNode;
64
+ let ans;
65
+ for (let i = 0; i < evals.length - 1; i++) {
66
+ const a = evals[i];
67
+ const b = evals[i + 1];
68
+ if (a < xEv && b > xEv) {
69
+ aNode = reifyAlgebraic(xs[i]);
70
+ bNode = reifyAlgebraic(xs[i + 1]);
71
+ const sign = signs[2 * i];
72
+ if (sign === "+")
73
+ ans = "positif";
74
+ if (sign === "-")
75
+ ans = "négatif";
76
+ break;
77
+ }
78
+ }
79
+ return `On remarque que $${xNode.toTex()}$ est compris entre $${aNode.toTex()}$ et $${bNode.toTex()}$.
80
+
81
+ D'après le tableau de signes, $f(${xNode.toTex()})$ est donc ${ans}.`;
82
+ };
83
+ const getReadSignTableQuestion = (ops) => {
84
+ const a = randint(-10, 0);
85
+ const b = randint(0, 10);
86
+ const xs = [MinusInfinityNode, a.toTree(), b.toTree(), PlusInfinityNode];
87
+ const signs = coinFlip()
88
+ ? ["+", "0", "-", "0", "+"]
89
+ : ["-", "0", "+", "0", "-"];
90
+ const x = randint(-20, 20, [a, b]).toTree();
91
+ const identifiers = {
92
+ x: x.toIdentifiers(),
93
+ xs: xs.map((e) => e.toIdentifiers()),
94
+ signs,
95
+ };
96
+ return getQuestionFromIdentifiers(identifiers);
97
+ };
98
+ const getQuestionFromIdentifiers = (identifiers) => {
99
+ return {
100
+ answer: getAnswer(identifiers),
101
+ instruction: getInstruction(identifiers),
102
+ answerFormat: "raw",
103
+ identifiers,
104
+ hint: getHint(identifiers),
105
+ correction: getCorrection(identifiers),
106
+ };
107
+ };
108
+ export const readSignTable = {
109
+ id: "readSignTable",
110
+ label: "Lire le tableau de signes d'une fonction",
111
+ isSingleStep: true,
112
+ generator: (nb, opts) => getDistinctQuestions(() => getReadSignTableQuestion(opts), nb),
113
+ qcmTimer: 60,
114
+ freeTimer: 60,
115
+ getPropositions,
116
+ subject: "Mathématiques",
117
+ getInstruction,
118
+ getHint,
119
+ getCorrection,
120
+ getAnswer,
121
+ getQuestionFromIdentifiers,
122
+ answerType: "QCU",
123
+ hasHintAndCorrection: true,
124
+ };
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ initTable: string[][];
4
+ a: number;
5
+ x1: number;
6
+ x2: number;
7
+ x3: number;
8
+ };
9
+ export declare const signTableFromGraph: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=signTableFromGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signTableFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/signTableFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA0IF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAoBpD,CAAC"}
@@ -0,0 +1,141 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
3
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ const getInstruction = (identifiers) => {
7
+ return `On donne la représentation graphique d'une fonction $f$ définie sur $\\mathbb{R}$.
8
+
9
+ Dresser le tableau de signes de $f$.`;
10
+ };
11
+ const getHint = (identifiers) => {
12
+ return `La fonction est définie sur $\\mathbb{R}$, donc les valeurs de $x$ vont de $-\\infty$ à $+\\infty$.
13
+
14
+ Repère ensuite les points de la courbe à l'intersection de l'axe des abscisses. Dans la première ligne du tableau, il faut mettre les abscisses de ces points, et dans la deuxième ligne, le signe de $f(x)$.`;
15
+ };
16
+ const getCorrection = (identifiers) => {
17
+ const { a, x1, x2, x3 } = identifiers;
18
+ const signs = a > 0
19
+ ? ["négatif", "positif", "négatif", "positif"]
20
+ : ["positif", "négatif", "positif", "négatif"];
21
+ return `On lit graphiquement que $f(x)$ s'annule pour les valeurs de $x$ suivantes : $${x1}$, $${x2}$ et $${x3}$.
22
+
23
+ De plus, $f(x)$ est ${signs[0]} pour $x \\in ]-\\infty;${x1}]$, puis ${signs[1]} pour $x \\in [${x1}, ${x2}]$, puis ${signs[2]} pour $x \\in [${x2}, ${x3}]$, et enfin ${signs[3]} pour $x \\in [${x3}, +\\infty[$.`;
24
+ };
25
+ const getGGBOptions = (identifiers) => {
26
+ const { a, x1, x2, x3 } = identifiers;
27
+ const ggb = new GeogebraConstructor({
28
+ commands: [`f(x) = ${a}*(x-${x1})*(x-${x2})*(x-${x3})`],
29
+ lockedAxesRatio: false,
30
+ gridDistance: false,
31
+ xAxis: {
32
+ steps: 1,
33
+ },
34
+ });
35
+ const func = (x) => a * (x - x1) * (x - x2) * (x - x3);
36
+ const xMin = Math.min(x1, x2, x3);
37
+ const xMax = Math.max(x1, x2, x3);
38
+ const root1 = (2 * (x1 + x2 + x3) -
39
+ Math.sqrt(4 * (x1 + x2 + x3) ** 2 - 12 * (x1 * x2 + x1 * x3 + x2 * x3))) /
40
+ 6;
41
+ const root2 = (2 * (x1 + x2 + x3) +
42
+ Math.sqrt(4 * (x1 + x2 + x3) ** 2 - 12 * (x1 * x2 + x1 * x3 + x2 * x3))) /
43
+ 6;
44
+ const [fx1, fx2] = [func(root1), func(root2)];
45
+ const yMin = Math.min(fx1, fx2);
46
+ const yMax = Math.max(fx1, fx2);
47
+ return ggb.getOptions({
48
+ coords: [xMin - 2, xMax + 2, yMin - 2, yMax + 2],
49
+ });
50
+ };
51
+ const getKeys = (identifiers) => {
52
+ return ["infty"];
53
+ };
54
+ const getAnswerTable = (identifiers) => {
55
+ const { a, x1, x2, x3 } = identifiers;
56
+ const signs = a > 0 ? ["-", "+", "-", "+"] : ["+", "-", "+", "-"];
57
+ return [
58
+ [
59
+ "$x$",
60
+ "-\\infty",
61
+ "\\ ",
62
+ x1.frenchify(),
63
+ "\\ ",
64
+ x2.frenchify(),
65
+ "\\ ",
66
+ x3.frenchify(),
67
+ "\\ ",
68
+ "+\\infty",
69
+ ],
70
+ [
71
+ "$f(x)$",
72
+ "\\ ",
73
+ signs[0],
74
+ "0",
75
+ signs[1],
76
+ "0",
77
+ signs[2],
78
+ "0",
79
+ signs[3],
80
+ "\\ ",
81
+ ],
82
+ ];
83
+ };
84
+ const isAnswerTableValid = (ans, { answerTable }) => {
85
+ try {
86
+ return ans.every((row, i) => row.every((cell, j) => cell === answerTable[i][j]));
87
+ }
88
+ catch (err) {
89
+ return handleVEAError(err);
90
+ }
91
+ };
92
+ const getSignTableFromGraphQuestion = (opts) => {
93
+ let x1 = randint(-9, 10);
94
+ let x2 = randint(-9, 10, [x1]);
95
+ let x3 = randint(-9, 10, [x1, x2]);
96
+ const sorted = [x1, x2, x3].sort((a, b) => a - b);
97
+ const a = randfloat(-1, 1, 4, [0]);
98
+ const identifiers = {
99
+ a,
100
+ x1: sorted[0],
101
+ x2: sorted[1],
102
+ x3: sorted[2],
103
+ initTable: [
104
+ ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", "", "\\ ", ""],
105
+ ["$f(x)$", "\\ ", "", "", "", "", "", "", "", "\\ "],
106
+ ],
107
+ };
108
+ return getQuestionFromIdentifiers(identifiers);
109
+ };
110
+ const getQuestionFromIdentifiers = (identifiers) => {
111
+ return {
112
+ answerTable: getAnswerTable(identifiers),
113
+ instruction: getInstruction(identifiers),
114
+ keys: getKeys(identifiers),
115
+ answerFormat: "tex",
116
+ identifiers,
117
+ hint: getHint(identifiers),
118
+ correction: getCorrection(identifiers),
119
+ ggbOptions: getGGBOptions(identifiers),
120
+ initTable: identifiers.initTable,
121
+ };
122
+ };
123
+ export const signTableFromGraph = {
124
+ id: "signTableFromGraph",
125
+ label: "Dresser le tableau de signes d'une fonction à partir de sa représentation graphique",
126
+ isSingleStep: true,
127
+ generator: (nb, opts) => getDistinctQuestions(() => getSignTableFromGraphQuestion(opts), nb),
128
+ qcmTimer: 60,
129
+ freeTimer: 60,
130
+ isAnswerTableValid,
131
+ subject: "Mathématiques",
132
+ getHint,
133
+ getCorrection,
134
+ getInstruction,
135
+ getAnswerTable,
136
+ getGGBOptions,
137
+ hasGeogebra: true,
138
+ getQuestionFromIdentifiers,
139
+ answerType: "signTable",
140
+ hasHintAndCorrection: true,
141
+ };
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ xs: number[];
4
+ ys: number[];
5
+ vars: string[];
6
+ a: number;
7
+ b: number;
8
+ };
9
+ export declare const compareImagesInVarTable: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=compareImagesInVarTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareImagesInVarTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/compareImagesInVarTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgJF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAiBzD,CAAC"}
@@ -0,0 +1,153 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
5
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
6
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
7
+ const getPropositions = (n, { answer }) => {
8
+ const propositions = [];
9
+ addValidProp(propositions, answer);
10
+ tryToAddWrongProp(propositions, "\\le");
11
+ tryToAddWrongProp(propositions, "\\ge");
12
+ return shuffleProps(propositions, n);
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const { a, b, vars, xs, ys } = identifiers;
16
+ const index = a < xs[0] ? 0 : a > xs[1] ? 2 : 1;
17
+ if (vars[index] === "\\nearrow") {
18
+ return "\\le";
19
+ }
20
+ else {
21
+ return "\\ge";
22
+ }
23
+ };
24
+ const getInstruction = (identifiers) => {
25
+ const { a, b, vars, xs, ys } = identifiers;
26
+ const firstIncr = vars[0] === "\\nearrow";
27
+ const table = [
28
+ ["x", "-\\infty", "\\ ", xs[0], "\\ ", xs[1], "\\ ", "+\\infty"],
29
+ [
30
+ "",
31
+ "\\ ",
32
+ "\\ ",
33
+ firstIncr ? ys[0] : "\\ ",
34
+ "\\ ",
35
+ firstIncr ? "\\ " : ys[1],
36
+ "\\ ",
37
+ "\\ ",
38
+ ],
39
+ ["f(x)", "\\ ", vars[0], "\\ ", vars[1], "\\ ", vars[2], "\\ "],
40
+ [
41
+ "",
42
+ "\\ ",
43
+ "\\ ",
44
+ firstIncr ? "\\ " : ys[0],
45
+ "\\ ",
46
+ firstIncr ? ys[1] : "\\ ",
47
+ "\\ ",
48
+ "\\ ",
49
+ ],
50
+ ];
51
+ return `On donne le tableau de variations d'une fonction $f$ définie sur $\\mathbb{R}$ :
52
+
53
+
54
+ <svg id='varTable'>${JSON.stringify(table)}</svg>
55
+
56
+ Compléter par le bon symbole :
57
+
58
+ $$
59
+ f(${a}) \\ \\ldots \\ f(${b})
60
+ $$`;
61
+ };
62
+ const getHint = (identifiers) => {
63
+ const { a, b, vars, xs, ys } = identifiers;
64
+ return `Si $a$ et $b$ sont deux nombres d'un intervalle $I$ sur lequel une fonction $f$ est croissante, alors $f(a)\\leq f(b)$.
65
+
66
+ Si sur cet intervalle, $f$ est décroissante, alors $f(a)\\geq f(b)$.`;
67
+ };
68
+ const getCorrection = (identifiers) => {
69
+ const { a, b, vars, xs, ys } = identifiers;
70
+ const index = a < xs[0] ? 0 : a > xs[1] ? 2 : 1;
71
+ const intervals = [
72
+ new IntervalNode(MinusInfinityNode, xs[0].toTree(), ClosureType.OF),
73
+ new IntervalNode(xs[0].toTree(), xs[1].toTree(), ClosureType.FF),
74
+ new IntervalNode(xs[1].toTree(), PlusInfinityNode, ClosureType.FO),
75
+ ];
76
+ return `Les nombres $${a}$ et $${b}$ appartiennent à l'intervalle $${intervals[index].toTex()}$.
77
+
78
+ Or, sur cet intervalle, la fonction $f$ est ${vars[index] === "\\nearrow" ? "croissante" : "décroissante"} d'après le tableau de variations.
79
+
80
+ On en déduit que :
81
+
82
+ $$
83
+ f(${a}) \\ ${vars[index] === "\\nearrow" ? "\\le" : "\\ge"} f(${b})
84
+ $$
85
+ `;
86
+ };
87
+ const getCompareImagesInVarTableQuestion = (ops) => {
88
+ const x1 = randint(-10, 0);
89
+ const x2 = randint(x1 + 6, 16);
90
+ const y1 = randint(-10, 10);
91
+ const y2 = randint(-10, 10, [y1]);
92
+ const flip = randint(0, 3);
93
+ let a;
94
+ let b;
95
+ if (flip === 0) {
96
+ //left side
97
+ a = randint(-20, x1 + 1);
98
+ b = randint(-20, x1 + 1, [a]);
99
+ if (a > b)
100
+ [a, b] = [b, a];
101
+ }
102
+ else if (flip === 1) {
103
+ //middle side
104
+ a = randint(x1, x2);
105
+ b = randint(x1, x2, [a]);
106
+ if (a > b)
107
+ [a, b] = [b, a];
108
+ }
109
+ else {
110
+ //right side
111
+ a = randint(x2, 20);
112
+ b = randint(x2, 20, [a]);
113
+ if (a > b)
114
+ [a, b] = [b, a];
115
+ }
116
+ const identifiers = {
117
+ a,
118
+ b,
119
+ vars: y2 < y1
120
+ ? ["\\nearrow", "\\searrow", "\\nearrow"]
121
+ : ["\\searrow", "\\nearrow", "\\searrow"],
122
+ xs: [x1, x2],
123
+ ys: [y1, y2],
124
+ };
125
+ return getQuestionFromIdentifiers(identifiers);
126
+ };
127
+ const getQuestionFromIdentifiers = (identifiers) => {
128
+ return {
129
+ answer: getAnswer(identifiers),
130
+ instruction: getInstruction(identifiers),
131
+ answerFormat: "tex",
132
+ identifiers,
133
+ hint: getHint(identifiers),
134
+ correction: getCorrection(identifiers),
135
+ };
136
+ };
137
+ export const compareImagesInVarTable = {
138
+ id: "compareImagesInVarTable",
139
+ label: "Comparer deux images dans le tableau de variations d'une fonction",
140
+ isSingleStep: true,
141
+ generator: (nb, opts) => getDistinctQuestions(() => getCompareImagesInVarTableQuestion(opts), nb),
142
+ qcmTimer: 60,
143
+ freeTimer: 60,
144
+ getPropositions,
145
+ subject: "Mathématiques",
146
+ getInstruction,
147
+ getHint,
148
+ getCorrection,
149
+ getAnswer,
150
+ getQuestionFromIdentifiers,
151
+ hasHintAndCorrection: true,
152
+ answerType: "QCU",
153
+ };
@@ -1,2 +1,4 @@
1
1
  export * from "./varTableExtremaReading.js";
2
+ export * from "./varTableFromGraph.js";
3
+ export * from "./compareImagesInVarTable.js";
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC"}
@@ -1 +1,3 @@
1
1
  export * from "./varTableExtremaReading.js";
2
+ export * from "./varTableFromGraph.js";
3
+ export * from "./compareImagesInVarTable.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ type: number;
4
+ coeffs: number[];
5
+ initTable: string[][];
6
+ };
7
+ export declare const varTableFromGraph: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=varTableFromGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varTableFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/varTableFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAgLF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAmBnD,CAAC"}