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
@@ -37,10 +37,10 @@ $$
37
37
  ${leftNode.toTex()} ${inequalitySign ? "<" : ">"} ${rightNode.toTex()}
38
38
  $$
39
39
 
40
- Cette inéquation est-elle vraie pour $x = ${x}$ ?`;
40
+ Cette inéquation est-elle vraie pour pour $x = ${x}$ ?`;
41
41
  };
42
42
  const getHint = (identifiers) => {
43
- return `Remplace $x$ par $${identifiers.x}$ dans les deux membres. Ensuite, vérifie si l'inégalité est vraie ou non.`;
43
+ return `Remplacer $x$ par $${identifiers.x}$ dans les deux membres. Ensuite, vérifie si l'inégalité est vraie ou non.`;
44
44
  };
45
45
  const reverseSign = (sign) => {
46
46
  let x = "";
@@ -1 +1 @@
1
- {"version":3,"file":"simpleDistriXCoeff.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAoBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmHF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
1
+ {"version":3,"file":"simpleDistriXCoeff.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmHF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
@@ -83,7 +83,7 @@ const getLengthConversion = (opts) => {
83
83
  const randomUnitInstructionIndex = random(availableUnitsIndexes, [
84
84
  randomUnitIndex,
85
85
  ]);
86
- const randomLength = doWhile(() => DecimalConstructor.random(0, 1000, randint(0, 4)), (x) => x.value === 0);
86
+ const randomLength = doWhile(() => DecimalConstructor.random(1, 1000, randint(0, 4)), (x) => x.value === 0);
87
87
  const identifiers = {
88
88
  randomLength: randomLength.value,
89
89
  randomUnitIndex,
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ phrase: number;
4
+ initial: number;
5
+ growth: number;
6
+ };
7
+ export declare const affineFromExercise: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=affineFromExercise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineFromExercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineFromExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAuHF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAiBpD,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
8
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
+ const getPropositions = (n, { answer, ...identifiers }) => {
10
+ const propositions = [];
11
+ const { phrase, initial, growth } = identifiers;
12
+ addValidProp(propositions, answer);
13
+ tryToAddWrongProp(propositions, add(multiply(initial, new VariableNode("x")), growth).toTex());
14
+ tryToAddWrongProp(propositions, add(multiply(growth, new VariableNode("n")), initial).toTex());
15
+ tryToAddWrongProp(propositions, add(multiply(initial, growth), new VariableNode("x")).toTex());
16
+ tryToAddWrongProp(propositions, multiply(add(initial, growth).simplify(), new VariableNode("x")).toTex());
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ return add(multiply(identifiers.growth, new VariableNode("x")), identifiers.initial).toTex();
21
+ };
22
+ const getInstruction = (identifiers) => {
23
+ const { phrase, initial, growth } = identifiers;
24
+ switch (phrase) {
25
+ case 0:
26
+ return `On suppose qu'une plante, d'une hauteur initiale de
27
+ $${initial}\\ \\textrm{cm}$, croît chaque jour de $${growth.frenchify()}\\ \\textrm{cm}$.
28
+ Quelle est sa hauteur (en $\\textrm{cm}$) après $x$ jours ?`;
29
+ case 1:
30
+ default:
31
+ return `Une compagnie de taxis propose un tarif qui inclut un
32
+ montant fixe de $${initial}\\ €$ et un montant variable de $${growth.frenchify()}\\ €$
33
+ par kilomètre parcouru.
34
+ Quel est le prix payé (en $€$) pour $x \\ \\textrm{km}$ parcourus ?`;
35
+ }
36
+ };
37
+ const getHint = (identifiers) => {
38
+ const { growth, initial, phrase } = identifiers;
39
+ if (phrase === 0) {
40
+ return `Quel calcul permet de trouver la hauteur de la plante au bout de $10$ jours ?
41
+
42
+ Inspire toi de ce calcul pour déterminer la hauteur de la plante au bout de $x$ jours.`;
43
+ }
44
+ return `Quel calcul permet de trouver le prix payé pour $10$ kilomètres parcourus ?
45
+
46
+ Inspire toi de ce calcul pour déterminer le prix payé pour $x$ kilomètres parcourus.
47
+ `;
48
+ };
49
+ const getCorrection = (identifiers) => {
50
+ const { growth, initial, phrase } = identifiers;
51
+ if (phrase === 0) {
52
+ return `Chaque jour, la plante gagne $${growth.frenchify()}\\ \\textrm{cm}$. Au bout de $x$ jours, la plante a donc gagné $x\\times ${growth.frenchify()}\\ \\textrm{cm}$.
53
+
54
+ La hauteur initiale de la plante est de $${initial}\\ \\textrm{cm}$.
55
+
56
+ Au bout de $x$ jours, la plante a donc une hauteur de :
57
+
58
+ $$
59
+ ${getAnswer(identifiers)}\\ \\textrm{cm}
60
+ $$`;
61
+ }
62
+ return `Pour chaque kilomètre parcouru, le prix augmente de $${growth.frenchify()}\\ €$. Au bout de $x$ kilomètres, le prix augmente donc de $x\\times ${growth.frenchify()}\\ \\ €$.
63
+
64
+ Le montant fixe initial du trajet est de $${initial}\\ €$.
65
+
66
+ Pour $x$ kilomètres parcourus, le prix du trajet est donc de :
67
+
68
+ $$
69
+ ${getAnswer(identifiers)}\\ €
70
+ $$`;
71
+ };
72
+ const isAnswerValid = (ans, { answer }) => {
73
+ return parseAlgebraic(ans)
74
+ .simplify()
75
+ .equals(parseAlgebraic(answer).simplify());
76
+ };
77
+ const getAffineFromExerciseQuestion = (ops) => {
78
+ const phrase = randint(0, 2);
79
+ const initial = randint(2, 20);
80
+ const growth = randfloat(0, 4, 2, [0]);
81
+ const identifiers = { phrase, initial, growth };
82
+ return getQuestionFromIdentifiers(identifiers);
83
+ };
84
+ const getQuestionFromIdentifiers = (identifiers) => {
85
+ return {
86
+ answer: getAnswer(identifiers),
87
+ instruction: getInstruction(identifiers),
88
+ keys: ["x"],
89
+ answerFormat: "tex",
90
+ identifiers,
91
+ hint: getHint(identifiers),
92
+ correction: getCorrection(identifiers),
93
+ };
94
+ };
95
+ export const affineFromExercise = {
96
+ id: "affineFromExercise",
97
+ label: "Écrire la fonction affine correspondant à une situation donnée",
98
+ isSingleStep: true,
99
+ generator: (nb, opts) => getDistinctQuestions(() => getAffineFromExerciseQuestion(opts), nb),
100
+ qcmTimer: 60,
101
+ freeTimer: 60,
102
+ getPropositions,
103
+ isAnswerValid,
104
+ subject: "Mathématiques",
105
+ getInstruction,
106
+ getHint,
107
+ getCorrection,
108
+ getAnswer,
109
+ getQuestionFromIdentifiers,
110
+ hasHintAndCorrection: true,
111
+ };
@@ -11,4 +11,5 @@ export * from "./affineAdjustmentRsquared.js";
11
11
  export * from "./affineAdjustmentComplete.js";
12
12
  export * from "./affineMeanValue.js";
13
13
  export * from "./affineExpressionFromTwoImages.js";
14
+ export * from "./affineFromExercise.js";
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,yBAAyB,CAAC"}
@@ -11,3 +11,4 @@ export * from "./affineAdjustmentRsquared.js";
11
11
  export * from "./affineAdjustmentComplete.js";
12
12
  export * from "./affineMeanValue.js";
13
13
  export * from "./affineExpressionFromTwoImages.js";
14
+ export * from "./affineFromExercise.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ isEven: boolean;
4
+ isLeftSideGiven: boolean;
5
+ givenPointsCoords: number[][];
6
+ };
7
+ export declare const finishParityFunctionGraph: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=finishParityFunctionGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"finishParityFunctionGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/parity/finishParityFunctionGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,MAAM,EAAE,EAAE,CAAC;CAC/B,CAAC;AAoLF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAkB3D,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { toolBarConstructor } from "../../../../exercises/utils/geogebra/toolBarConstructor.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
+ import { ggbPointToCoords } from "../../../../geogebra/parsers/ggbPointToCoords.js";
5
+ import { parseGGBPoints } from "../../../../geogebra/parsers/parseGGBPoints.js";
6
+ import { randint } from "../../../../math/utils/random/randint.js";
7
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
8
+ import { doWhile } from "../../../../utils/doWhile.js";
9
+ const getInstruction = (identifiers) => {
10
+ const { isEven, givenPointsCoords, isLeftSideGiven } = identifiers;
11
+ let xMin = (isLeftSideGiven ? Math.min : Math.max)(...givenPointsCoords.map((n) => n[0]));
12
+ let xMax = -xMin;
13
+ if (xMin > xMax)
14
+ [xMin, xMax] = [xMax, xMin];
15
+ return `On considère la fonction $f$ définie sur $[${xMin}; ${xMax}]$ et dont la courbe représentative est donnée ci-dessous.
16
+
17
+ La fonction $f$ est ${isEven ? "paire" : "impaire"}.
18
+
19
+ Compléter la courbe représentative de $f$.`;
20
+ };
21
+ const getHint = (identifiers) => {
22
+ return `Une fonction est paire si sa courbe représentative est symétrique par rapport à l'axe des ordonnées.
23
+
24
+ Une fonction est impaire si sa courbe représentative est symétrique par rapport à l'origine du repère.`;
25
+ };
26
+ const getCorrection = (identifiers) => {
27
+ const { isEven, givenPointsCoords, isLeftSideGiven } = identifiers;
28
+ if (isEven) {
29
+ return `Puisque $f$ est paire, alors sa courbe représentative est symétrique par rapport à l'axe des ordonnées.
30
+
31
+ On trace donc les symétriques de chacun des segments composant la courbe de $f$ par rapport à l'axe des ordonnées.`;
32
+ }
33
+ return `Puisque $f$ est impaire, alors sa courbe représentative est symétrique par rapport à l'origine du repère.
34
+
35
+ On trace donc les symétriques de chacun des segments composant la courbe de $f$ par rapport à l'origine du repère.`;
36
+ };
37
+ const getGGBAnswer = (identifiers) => {
38
+ const { isEven, givenPointsCoords, isLeftSideGiven } = identifiers;
39
+ const symPointsCoords = [];
40
+ if (isEven) {
41
+ for (const coords of [...givenPointsCoords].reverse()) {
42
+ symPointsCoords.push([-coords[0], coords[1]]);
43
+ }
44
+ }
45
+ else {
46
+ for (const coords of [...givenPointsCoords].reverse()) {
47
+ symPointsCoords.push([-coords[0], -coords[1]]);
48
+ }
49
+ }
50
+ const commands = [];
51
+ for (let i = 1; i < symPointsCoords.length; i++) {
52
+ commands.push(`Segment((${symPointsCoords[i - 1][0]}, ${symPointsCoords[i - 1][1]}), (${symPointsCoords[i][0]}, ${symPointsCoords[i][1]}))`);
53
+ }
54
+ return commands;
55
+ };
56
+ const getStudentGGBOptions = (identifiers) => {
57
+ const { isEven, givenPointsCoords, isLeftSideGiven } = identifiers;
58
+ const commands = [];
59
+ for (let i = 1; i < givenPointsCoords.length; i++) {
60
+ commands.push(`Segment((${givenPointsCoords[i - 1][0]}, ${givenPointsCoords[i - 1][1]}), (${givenPointsCoords[i][0]}, ${givenPointsCoords[i][1]}))`);
61
+ }
62
+ const ggb = new GeogebraConstructor({
63
+ commands,
64
+ customToolBar: toolBarConstructor({
65
+ segment: true,
66
+ }),
67
+ });
68
+ let xMax = Math.abs((isLeftSideGiven ? Math.min : Math.max)(...givenPointsCoords.map((n) => n[0])));
69
+ const yMin = Math.min(...givenPointsCoords.map((n) => n[1]));
70
+ const yMax = Math.max(...givenPointsCoords.map((n) => n[1]));
71
+ const coords = isEven
72
+ ? [-xMax - 2, xMax + 2, yMin - 2, yMax + 2]
73
+ : [
74
+ -xMax - 2,
75
+ xMax + 2,
76
+ Math.min(...givenPointsCoords.map((n) => -n[1])) - 2,
77
+ Math.max(...givenPointsCoords.map((n) => -n[1])) + 2,
78
+ ];
79
+ return ggb.getOptions({
80
+ coords,
81
+ });
82
+ };
83
+ const isGGBAnswerValid = (ans, { ggbAnswer, givenPointsCoords, isEven }) => {
84
+ const points = parseGGBPoints(ans).map((p) => ggbPointToCoords(p));
85
+ if (isEven) {
86
+ return (points.length === givenPointsCoords.length &&
87
+ points.every((p) => givenPointsCoords.some((c) => Math.abs(p.x + c[0]) < 0.5 && Math.abs(p.y - c[1]) < 0.5)));
88
+ }
89
+ else {
90
+ return (points.length === givenPointsCoords.length &&
91
+ points.every((p) => givenPointsCoords.some((c) => Math.abs(p.x + c[0]) < 0.5 && Math.abs(p.y + c[1]) < 0.5)));
92
+ }
93
+ };
94
+ const getFinishParityFunctionGraphQuestion = () => {
95
+ const isEven = coinFlip();
96
+ const isLeftSideGiven = coinFlip();
97
+ const givenPointsCoords = [];
98
+ if (isLeftSideGiven) {
99
+ const point0 = [randint(-7, -4), randint(-5, 5, [0])];
100
+ givenPointsCoords.push(point0);
101
+ const pointOrigin = isEven ? [0, randint(-3, 3)] : [0, 0];
102
+ givenPointsCoords.push([
103
+ randint(point0[0] + 1, 0),
104
+ doWhile(() => randint(-5, 5), (x) => (x <= point0[1] && x >= pointOrigin[1]) ||
105
+ (x >= point0[1] && x <= pointOrigin[1])),
106
+ ]);
107
+ givenPointsCoords.push(pointOrigin);
108
+ }
109
+ else {
110
+ const pointOrigin = isEven ? [0, randint(-3, 3)] : [0, 0];
111
+ givenPointsCoords.push(pointOrigin);
112
+ const point3 = [randint(4, 7), randint(-5, 5)];
113
+ const point2 = [
114
+ randint(1, 4),
115
+ doWhile(() => randint(-5, 5), (x) => (x <= point3[1] && x >= pointOrigin[1]) ||
116
+ (x >= point3[1] && x <= pointOrigin[1])),
117
+ ];
118
+ givenPointsCoords.push(point2);
119
+ givenPointsCoords.push(point3);
120
+ }
121
+ const identifiers = {
122
+ isEven,
123
+ isLeftSideGiven,
124
+ givenPointsCoords,
125
+ };
126
+ return getQuestionFromIdentifiers(identifiers);
127
+ };
128
+ const getQuestionFromIdentifiers = (identifiers) => {
129
+ return {
130
+ ggbAnswer: getGGBAnswer(identifiers),
131
+ instruction: getInstruction(identifiers),
132
+ studentGgbOptions: getStudentGGBOptions(identifiers),
133
+ identifiers,
134
+ hint: getHint(identifiers),
135
+ correction: getCorrection(identifiers),
136
+ };
137
+ };
138
+ export const finishParityFunctionGraph = {
139
+ id: "finishParityFunctionGraph",
140
+ label: "Compléter la représentation graphique d'une fonction paire ou impaire",
141
+ isSingleStep: true,
142
+ generator: (nb, opts) => getDistinctQuestions(() => getFinishParityFunctionGraphQuestion(opts), nb),
143
+ ggbTimer: 60,
144
+ isGGBAnswerValid,
145
+ subject: "Mathématiques",
146
+ getHint,
147
+ getInstruction,
148
+ getCorrection,
149
+ getGGBAnswer,
150
+ getStudentGGBOptions,
151
+ answerType: "GGB",
152
+ getQuestionFromIdentifiers,
153
+ hasHintAndCorrection: true,
154
+ };
@@ -1,3 +1,4 @@
1
1
  export * from "./parityFromAlgebra.js";
2
2
  export * from "./parityFromGraph.js";
3
+ export * from "./finishParityFunctionGraph.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/parity/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/parity/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from "./parityFromAlgebra.js";
2
2
  export * from "./parityFromGraph.js";
3
+ export * from "./finishParityFunctionGraph.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ affine1Coeffs: number[];
4
+ affine2Coeffs: number[];
5
+ initTable: string[][];
6
+ };
7
+ export declare const affineProductSignTable: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=affineProductSignTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineProductSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/affineProductSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAmNF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
@@ -0,0 +1,201 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { firstDegreeInequationResolutionTex } from "../../../../tree/nodes/inequations/inequationNode.js";
5
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
8
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
9
+ const getAnswerTable = (identifiers) => {
10
+ const affine1 = AffineConstructor.fromCoeffs(identifiers.affine1Coeffs);
11
+ const affine2 = AffineConstructor.fromCoeffs(identifiers.affine2Coeffs);
12
+ let root1 = affine1.getRoot().toTree();
13
+ let root2 = affine2.getRoot().toTree();
14
+ const isRoot1OfAffine1 = root1.evaluate() < root2.evaluate();
15
+ if (!isRoot1OfAffine1) {
16
+ [root1, root2] = [root2, root1];
17
+ }
18
+ const signs1 = affine1.a > 0 ? ["-", "+"] : ["+", "-"];
19
+ const signs2 = affine2.a > 0 ? ["-", "+"] : ["+", "-"];
20
+ const signs3 = affine1.a * affine2.a > 0 ? ["+", "-", "+"] : ["-", "+", "-"];
21
+ return [
22
+ [
23
+ "$x$",
24
+ "-\\infty",
25
+ "\\ ",
26
+ root1.toTex(),
27
+ "\\ ",
28
+ root2.toTex(),
29
+ "\\ ",
30
+ "+\\infty",
31
+ ],
32
+ [
33
+ `$${affine1.toTree().toTex()}$`,
34
+ "\\ ",
35
+ signs1[0],
36
+ isRoot1OfAffine1 ? "0" : signs1[0],
37
+ isRoot1OfAffine1 ? signs1[1] : signs1[0],
38
+ isRoot1OfAffine1 ? signs1[1] : "0",
39
+ signs1[1],
40
+ "\\ ",
41
+ ],
42
+ [
43
+ `$${affine2.toTree().toTex()}$`,
44
+ "\\ ",
45
+ signs2[0],
46
+ !isRoot1OfAffine1 ? "0" : signs2[0],
47
+ !isRoot1OfAffine1 ? signs2[1] : signs2[0],
48
+ !isRoot1OfAffine1 ? signs2[1] : "0",
49
+ signs2[1],
50
+ "\\ ",
51
+ ],
52
+ [`$f(x)$`, "\\ ", signs3[0], "0", signs3[1], "0", signs3[2], "\\ "],
53
+ ];
54
+ };
55
+ const getInstruction = (identifiers) => {
56
+ const affine1 = AffineConstructor.fromCoeffs(identifiers.affine1Coeffs);
57
+ const affine2 = AffineConstructor.fromCoeffs(identifiers.affine2Coeffs);
58
+ const product = multiply(affine1.toTree(), affine2.toTree());
59
+ return `Compléter le tableau de signes suivant afin de déterminer le signe de la fonction $f$ définie par :
60
+
61
+ $$
62
+ f(x) = ${product.toTex()}
63
+ $$`;
64
+ };
65
+ const getHint = (identifiers) => {
66
+ const affine1 = AffineConstructor.fromCoeffs(identifiers.affine1Coeffs);
67
+ const affine2 = AffineConstructor.fromCoeffs(identifiers.affine2Coeffs);
68
+ return `Résout les inéquations $${affine1.toTree().toTex()}>0$ et $${affine2
69
+ .toTree()
70
+ .toTex()}>0$.
71
+
72
+ Puis, utilise la règle des signes pour déterminer le signe de $f(x)$.`;
73
+ };
74
+ const getCorrection = (identifiers) => {
75
+ const affine1 = AffineConstructor.fromCoeffs(identifiers.affine1Coeffs);
76
+ const affine2 = AffineConstructor.fromCoeffs(identifiers.affine2Coeffs);
77
+ let root1 = affine1.getRoot().toTree();
78
+ let root2 = affine2.getRoot().toTree();
79
+ const isRoot1OfAffine1 = root1.evaluate() < root2.evaluate();
80
+ if (!isRoot1OfAffine1) {
81
+ [root1, root2] = [root2, root1];
82
+ }
83
+ const signs3 = affine1.a * affine2.a > 0
84
+ ? ["positif", "négatif", "positif"]
85
+ : ["négatif", "positif", "négatif"];
86
+ return `On résout l'inéquation $${affine1.toTree().toTex()} > 0$ :
87
+
88
+ $$
89
+ ${firstDegreeInequationResolutionTex(affine1, ">", new NumberNode(0))}
90
+ $$
91
+
92
+ On en déduit que $${affine1.toTree().toTex()}$ est ${affine1.a > 0 ? "négatif" : "positif"} sur $]-\\infty; ${(isRoot1OfAffine1 ? root1 : root2).toTex()}]$ et ${affine1.a > 0 ? "positif" : "négatif"} sur $[${(isRoot1OfAffine1 ? root1 : root2).toTex()}; +\\infty[$.
93
+
94
+ On résout ensuite l'inéquation $${affine2.toTree().toTex()} > 0$ :
95
+
96
+ $$
97
+ ${firstDegreeInequationResolutionTex(affine2, ">", new NumberNode(0))}
98
+ $$
99
+
100
+ On en déduit que $${affine2.toTree().toTex()}$ est ${affine2.a > 0 ? "négatif" : "positif"} sur $]-\\infty; ${(isRoot1OfAffine1 ? root2 : root1).toTex()}]$ et ${affine2.a > 0 ? "positif" : "négatif"} sur $[${(isRoot1OfAffine1 ? root2 : root1).toTex()}; +\\infty[$.
101
+
102
+ En utilisant la règle des signes, on en déduit alors que $f$ est ${signs3[0]} sur $]\\infty; ${root1.toTex()}]$, puis ${signs3[1]} sur $[${root1.toTex()}; ${root2.toTex()}[$, puis ${signs3[2]} sur $[${root2.toTex()}; +\\infty[$.
103
+ `;
104
+ };
105
+ const getKeys = (identifiers) => {
106
+ return ["infty"];
107
+ };
108
+ const isAnswerTableValid = (ans, { answerTable, affine1Coeffs, affine2Coeffs }) => {
109
+ try {
110
+ const firstRowVea = ans[0].every((cell, j) => j === 3 || j === 5
111
+ ? parseAlgebraic(cell)
112
+ .simplify({ decimalToFractions: true })
113
+ .toTex() === answerTable[0][j]
114
+ : cell === answerTable[0][j]);
115
+ if (!firstRowVea)
116
+ return false;
117
+ const lastRowVEA = ans[3].every((cell, j) => cell === answerTable[3][j]);
118
+ if (!lastRowVEA)
119
+ return false;
120
+ const secondVEA = rowTableVEA(ans[1], answerTable[1], affine1Coeffs);
121
+ if (!secondVEA)
122
+ return false;
123
+ const thirdVEA = rowTableVEA(ans[2], answerTable[2], affine2Coeffs);
124
+ if (!thirdVEA)
125
+ return false;
126
+ return true;
127
+ }
128
+ catch (err) {
129
+ return handleVEAError(err);
130
+ }
131
+ };
132
+ const rowTableVEA = (row, answerRow, affineCoeffs) => {
133
+ const signs = affineCoeffs[1] > 0 ? ["-", "+"] : ["+", "-"];
134
+ const zero = row.indexOf("0");
135
+ if (!zero || answerRow[zero] !== "0")
136
+ return false;
137
+ const left = row.slice(1, zero);
138
+ const right = row.slice(zero + 1);
139
+ const leftGood = left.some((e) => e === signs[0]) &&
140
+ left.every((e) => e === signs[0] || e == "\\ " || e === "");
141
+ const rightGood = right.some((e) => e === signs[1]) &&
142
+ right.every((e) => e === signs[1] || e == "\\ " || e === "");
143
+ if (!leftGood || !rightGood)
144
+ return false;
145
+ return true;
146
+ };
147
+ const getTestSignTableQuestion = (ops) => {
148
+ let a = 0;
149
+ let b = 0;
150
+ let c = 0;
151
+ let d = 0;
152
+ do {
153
+ a = randint(-10, 10, [0]);
154
+ b = randint(-10, 10);
155
+ c = randint(-10, 10, [0]);
156
+ d = randint(-10, 10);
157
+ } while (c * b === a * d);
158
+ const affine1 = new Affine(a, b);
159
+ const affine2 = new Affine(c, d);
160
+ const initTable = [
161
+ ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", ""],
162
+ [`$${affine1.toTree().toTex()}$`, "\\ ", "", "", "", "", "", "\\ "],
163
+ [`$${affine2.toTree().toTex()}$`, "\\ ", "", "", "", "", "", "\\ "],
164
+ [`$f(x)$`, "\\ ", "", "", "", "", "", "\\ "],
165
+ ];
166
+ const identifiers = {
167
+ affine1Coeffs: [b, a],
168
+ affine2Coeffs: [d, c],
169
+ initTable,
170
+ };
171
+ return getQuestionFromIdentifiers(identifiers);
172
+ };
173
+ const getQuestionFromIdentifiers = (identifiers) => {
174
+ return {
175
+ answerTable: getAnswerTable(identifiers),
176
+ instruction: getInstruction(identifiers),
177
+ keys: getKeys(identifiers),
178
+ answerFormat: "tex",
179
+ identifiers,
180
+ hint: getHint(identifiers),
181
+ correction: getCorrection(identifiers),
182
+ initTable: identifiers.initTable,
183
+ };
184
+ };
185
+ export const affineProductSignTable = {
186
+ id: "affineProductSignTable",
187
+ label: "Dresser le tableau de signes d'un produit de fonctions affines",
188
+ isSingleStep: true,
189
+ generator: (nb, opts) => getDistinctQuestions(() => getTestSignTableQuestion(opts), nb),
190
+ qcmTimer: 60,
191
+ freeTimer: 60,
192
+ isAnswerTableValid,
193
+ subject: "Mathématiques",
194
+ getInstruction,
195
+ getHint,
196
+ getCorrection,
197
+ getAnswerTable,
198
+ getQuestionFromIdentifiers,
199
+ hasHintAndCorrection: true,
200
+ answerType: "signTable",
201
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ affineCoeffs: number[];
4
+ initTable: string[][];
5
+ };
6
+ export declare const affineSignTable: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=affineSignTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/affineSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAwGF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAkBjD,CAAC"}