math-exercises 3.0.93 → 3.0.95

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 (84) hide show
  1. package/lib/exercises/math/calcul/arithmetics/index.d.ts +0 -9
  2. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/index.js +0 -9
  4. package/lib/exercises/math/calcul/decimals/decimalBoundingOnLine.d.ts +9 -0
  5. package/lib/exercises/math/calcul/decimals/decimalBoundingOnLine.d.ts.map +1 -0
  6. package/lib/exercises/math/calcul/decimals/decimalBoundingOnLine.js +171 -0
  7. package/lib/exercises/math/calcul/decimals/index.d.ts +1 -0
  8. package/lib/exercises/math/calcul/decimals/index.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/decimals/index.js +1 -0
  10. package/lib/exercises/math/calcul/fractions/index.d.ts +0 -1
  11. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/fractions/index.js +0 -1
  13. package/lib/exercises/math/functions/basics/countFunctionZeroes.d.ts +11 -0
  14. package/lib/exercises/math/functions/basics/countFunctionZeroes.d.ts.map +1 -0
  15. package/lib/exercises/math/functions/basics/countFunctionZeroes.js +197 -0
  16. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts +11 -0
  17. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -0
  18. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +213 -0
  19. package/lib/exercises/math/functions/basics/index.d.ts +3 -0
  20. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/basics/index.js +3 -1
  22. package/lib/exercises/math/functions/basics/isPointOnFunction.d.ts +10 -0
  23. package/lib/exercises/math/functions/basics/isPointOnFunction.d.ts.map +1 -0
  24. package/lib/exercises/math/functions/basics/isPointOnFunction.js +133 -0
  25. package/lib/exercises/math/functions/cube/index.d.ts +1 -0
  26. package/lib/exercises/math/functions/cube/index.d.ts.map +1 -1
  27. package/lib/exercises/math/functions/cube/index.js +1 -0
  28. package/lib/exercises/math/functions/cube/isPointOnCubicFunction.d.ts +9 -0
  29. package/lib/exercises/math/functions/cube/isPointOnCubicFunction.d.ts.map +1 -0
  30. package/lib/exercises/math/functions/cube/isPointOnCubicFunction.js +111 -0
  31. package/lib/exercises/math/functions/inverse/compareInverseValues.d.ts +10 -0
  32. package/lib/exercises/math/functions/inverse/compareInverseValues.d.ts.map +1 -0
  33. package/lib/exercises/math/functions/inverse/compareInverseValues.js +136 -0
  34. package/lib/exercises/math/functions/inverse/index.d.ts +3 -0
  35. package/lib/exercises/math/functions/inverse/index.d.ts.map +1 -0
  36. package/lib/exercises/math/functions/inverse/index.js +2 -0
  37. package/lib/exercises/math/functions/inverse/isPointOnReciprocalFunction.d.ts +9 -0
  38. package/lib/exercises/math/functions/inverse/isPointOnReciprocalFunction.d.ts.map +1 -0
  39. package/lib/exercises/math/functions/inverse/isPointOnReciprocalFunction.js +117 -0
  40. package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts +4 -1
  41. package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts.map +1 -1
  42. package/lib/exercises/math/functions/sign/equationFromSignTable.js +25 -10
  43. package/lib/exercises/math/functions/sqrt/getImageOfSquareRootFunction.d.ts +8 -0
  44. package/lib/exercises/math/functions/sqrt/getImageOfSquareRootFunction.d.ts.map +1 -0
  45. package/lib/exercises/math/functions/sqrt/getImageOfSquareRootFunction.js +128 -0
  46. package/lib/exercises/math/functions/sqrt/index.d.ts +1 -0
  47. package/lib/exercises/math/functions/sqrt/index.d.ts.map +1 -1
  48. package/lib/exercises/math/functions/sqrt/index.js +1 -0
  49. package/lib/exercises/math/functions/square/compareSquaredValues.d.ts +9 -0
  50. package/lib/exercises/math/functions/square/compareSquaredValues.d.ts.map +1 -0
  51. package/lib/exercises/math/functions/square/compareSquaredValues.js +143 -0
  52. package/lib/exercises/math/functions/square/imageOfSquareFunction.d.ts +8 -0
  53. package/lib/exercises/math/functions/square/imageOfSquareFunction.d.ts.map +1 -0
  54. package/lib/exercises/math/functions/square/imageOfSquareFunction.js +152 -0
  55. package/lib/exercises/math/functions/square/index.d.ts +2 -1
  56. package/lib/exercises/math/functions/square/index.d.ts.map +1 -1
  57. package/lib/exercises/math/functions/square/index.js +3 -1
  58. package/lib/exercises/math/functions/square/squareImageIntervalWithGraph.d.ts +11 -0
  59. package/lib/exercises/math/functions/square/squareImageIntervalWithGraph.d.ts.map +1 -0
  60. package/lib/exercises/math/functions/square/squareImageIntervalWithGraph.js +174 -0
  61. package/lib/exercises/math/functions/variations/index.d.ts +1 -0
  62. package/lib/exercises/math/functions/variations/index.d.ts.map +1 -1
  63. package/lib/exercises/math/functions/variations/index.js +1 -0
  64. package/lib/exercises/math/functions/variations/partialVarTableFromGraph.d.ts +10 -0
  65. package/lib/exercises/math/functions/variations/partialVarTableFromGraph.d.ts.map +1 -0
  66. package/lib/exercises/math/functions/variations/partialVarTableFromGraph.js +198 -0
  67. package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts +2 -0
  68. package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts.map +1 -0
  69. package/lib/exercises/math/functions/variations/varTableFromSentences.js +137 -0
  70. package/lib/exercises/math/powers/index.d.ts +1 -0
  71. package/lib/exercises/math/powers/index.d.ts.map +1 -1
  72. package/lib/exercises/math/powers/index.js +1 -0
  73. package/lib/exercises/math/powers/powerNotation.d.ts +9 -0
  74. package/lib/exercises/math/powers/powerNotation.d.ts.map +1 -0
  75. package/lib/exercises/math/powers/powerNotation.js +126 -0
  76. package/lib/exercises/math/sets/index.d.ts +1 -0
  77. package/lib/exercises/math/sets/index.d.ts.map +1 -1
  78. package/lib/exercises/math/sets/index.js +1 -0
  79. package/lib/exercises/math/sets/isNumberDecimal.d.ts +11 -0
  80. package/lib/exercises/math/sets/isNumberDecimal.d.ts.map +1 -0
  81. package/lib/exercises/math/sets/isNumberDecimal.js +144 -0
  82. package/lib/index.d.ts +48 -42
  83. package/lib/index.d.ts.map +1 -1
  84. package/package.json +1 -1
@@ -0,0 +1,136 @@
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 { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
6
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
8
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const propositions = [];
11
+ const symbols = ["<", "=", ">"];
12
+ addValidProp(propositions, answer);
13
+ const remaining = symbols.filter((s) => s !== answer);
14
+ for (const sym of remaining) {
15
+ tryToAddWrongProp(propositions, sym);
16
+ }
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = ({ a, b }) => {
20
+ const aNode = reifyAlgebraic(a);
21
+ const bNode = reifyAlgebraic(b);
22
+ const aVal = aNode.simplify().evaluate();
23
+ const bVal = bNode.simplify().evaluate();
24
+ return aVal === bVal ? "=" : aVal < bVal ? ">" : "<";
25
+ };
26
+ const getInstruction = ({ a, b, isMinusInside, }) => {
27
+ const aNode = reifyAlgebraic(a);
28
+ const bNode = reifyAlgebraic(b);
29
+ return `Compléter par le bon symbole :
30
+
31
+ $$
32
+ ${frac(1, aNode).toTex({
33
+ allowMinusAnywhereInFraction: isMinusInside,
34
+ })}\\ \\ldots \\ ${frac(1, bNode).toTex({
35
+ allowMinusAnywhereInFraction: isMinusInside,
36
+ })}
37
+ $$`;
38
+ };
39
+ const getHint = ({ a, b }) => {
40
+ return `Si $a$ et $b$ sont deux nombres non nuls et de même signe, alors la fonction inverse ne conserve pas l'ordre :
41
+
42
+ - $\\frac{1}{a} < \\frac{1}{b}$ si et seulement si $a>b$ ;
43
+ - $\\frac{1}{a} > \\frac{1}{b}$ si et seulement si $a<b$ ;
44
+ - $\\frac{1}{a} = \\frac{1}{b}$ si et seulement si $a=b$ ; `;
45
+ };
46
+ const getCorrection = (identifiers) => {
47
+ const { a, b, isMinusInside } = identifiers;
48
+ const aNode = reifyAlgebraic(a);
49
+ const bNode = reifyAlgebraic(b);
50
+ const aVal = aNode.simplify().evaluate();
51
+ const bVal = bNode.simplify().evaluate();
52
+ const signe = aVal < bVal ? "<" : aVal > bVal ? ">" : "=";
53
+ const answer = getAnswer(identifiers);
54
+ // return aVal === bVal ? "=" : aVal < bVal ? ">" : "<";
55
+ return `Puisque $${aNode.toTex()} ${signe} ${bNode.toTex()}$, et puisque ce sont deux nombres de même signe, leurs inverses sont dans l'ordre contraire :
56
+
57
+ $$
58
+ ${frac(1, aNode).toTex({
59
+ allowMinusAnywhereInFraction: isMinusInside,
60
+ })} ${answer} ${frac(1, bNode).toTex({
61
+ allowMinusAnywhereInFraction: isMinusInside,
62
+ })}
63
+ $$
64
+ `;
65
+ };
66
+ const getKeys = () => [];
67
+ const isAnswerValid = (ans, { answer }) => {
68
+ try {
69
+ return ans === answer;
70
+ }
71
+ catch (err) {
72
+ return handleVEAError(err);
73
+ }
74
+ };
75
+ function randBetween(isInteger, min, max, roundTo, excludes) {
76
+ if (isInteger) {
77
+ return randint(min, max, excludes);
78
+ }
79
+ else {
80
+ return randfloat(min, max, roundTo, excludes);
81
+ }
82
+ }
83
+ const getCompareInverseValuesQuestion = () => {
84
+ const min = 2;
85
+ const max = 50;
86
+ const roundTo = 2;
87
+ const isInteger = coinFlip();
88
+ let x;
89
+ let y;
90
+ if (coinFlip()) {
91
+ // tous deux positifs
92
+ x = randBetween(isInteger, min, max, roundTo);
93
+ y = randBetween(isInteger, min, max, roundTo, [x]);
94
+ }
95
+ else {
96
+ // tous deux négatifs
97
+ x = -randBetween(isInteger, min, max, roundTo);
98
+ y = -randBetween(isInteger, min, max, roundTo, [Math.abs(x)]);
99
+ }
100
+ const isMinusOutside = coinFlip();
101
+ const identifiers = {
102
+ a: x.toTree().toIdentifiers(),
103
+ b: y.toTree().toIdentifiers(),
104
+ isMinusInside: coinFlip(),
105
+ };
106
+ return getQuestionFromIdentifiers(identifiers);
107
+ };
108
+ const getQuestionFromIdentifiers = (identifiers) => {
109
+ return {
110
+ answer: getAnswer(identifiers),
111
+ instruction: getInstruction(identifiers),
112
+ keys: getKeys(identifiers),
113
+ answerFormat: "tex",
114
+ identifiers,
115
+ hint: getHint(identifiers),
116
+ correction: getCorrection(identifiers),
117
+ };
118
+ };
119
+ export const compareInverseValues = {
120
+ id: "compareInverseValues",
121
+ label: "Comparer des inverses",
122
+ isSingleStep: true,
123
+ generator: (nb, opts) => getDistinctQuestions(() => getCompareInverseValuesQuestion(opts), nb),
124
+ qcmTimer: 60,
125
+ freeTimer: 60,
126
+ getPropositions,
127
+ isAnswerValid,
128
+ subject: "Mathématiques",
129
+ getInstruction,
130
+ getHint,
131
+ getCorrection,
132
+ getAnswer,
133
+ getQuestionFromIdentifiers,
134
+ hasHintAndCorrection: true,
135
+ answerType: "QCU",
136
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./isPointOnReciprocalFunction.js";
2
+ export * from "./compareInverseValues.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/inverse/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./isPointOnReciprocalFunction.js";
2
+ export * from "./compareInverseValues.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ x: NodeIdentifiers;
5
+ y: NodeIdentifiers;
6
+ };
7
+ export declare const isPointOnReciprocalFunction: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=isPointOnReciprocalFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPointOnReciprocalFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/inverse/isPointOnReciprocalFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAqGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAqB7D,CAAC"}
@@ -0,0 +1,117 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Point } from "../../../../math/geometry/point.js";
4
+ import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
+ import { random } from "../../../../utils/alea/random.js";
11
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ const getPropositions = (n, { answer }) => {
13
+ const propositions = [];
14
+ addValidProp(propositions, answer, "raw");
15
+ tryToAddWrongProp(propositions, "Non", "raw");
16
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
17
+ tryToAddWrongProp(propositions, "Oui", "raw");
18
+ return shuffleProps(propositions, n);
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { x, y } = identifiers;
22
+ const reciprocalNode = frac(1, "x");
23
+ const xNode = reifyAlgebraic(x);
24
+ const yNode = reifyAlgebraic(y);
25
+ const reciprocalValue = reciprocalNode
26
+ .toDetailedEvaluation({ x: xNode })
27
+ .simplify();
28
+ const answer = reciprocalValue.equals(yNode) ? "Oui" : "Non";
29
+ return answer;
30
+ };
31
+ const getInstruction = (identifiers) => {
32
+ const reciprocalNode = frac(1, "x");
33
+ const { x, y } = identifiers;
34
+ const xNode = reifyAlgebraic(x);
35
+ const yNode = reifyAlgebraic(y);
36
+ const point = new Point("A", xNode, yNode);
37
+ return `Le point $${point.toTexWithCoords()}$ appartient-il à la courbe de la fonction inverse ?`;
38
+ };
39
+ const getHint = (identifiers) => {
40
+ const reciprocalNode = frac(1, "x");
41
+ return `Un point $A(x;y)$ appartient à la courbe de la fonction inverse si et seulement si $y = ${reciprocalNode.toTex()}$.`;
42
+ };
43
+ const getCorrection = (identifiers) => {
44
+ const { x, y } = identifiers;
45
+ const fracNode = frac(1, "x");
46
+ const xNode = reifyAlgebraic(x);
47
+ const yNode = reifyAlgebraic(y);
48
+ const reciprocalValue = fracNode
49
+ .toDetailedEvaluation({ x: xNode })
50
+ .simplify();
51
+ if (getAnswer(identifiers) == "Oui") {
52
+ return `L'inverse de $${xNode.toTex()}$ est bien $${yNode.toTex()}$, donc le point appartient à la courbe de la fonction inverse.`;
53
+ }
54
+ else {
55
+ return `L'inverse de $${xNode.toTex()}$ est $${reciprocalValue.toTex()} \\neq ${yNode.toTex()}$.
56
+
57
+ Le point n'appartient donc pas à la courbe de la fonction inverse.`;
58
+ }
59
+ };
60
+ const getKeys = (identifiers) => {
61
+ return [];
62
+ };
63
+ const isAnswerValid = (ans, { answer }) => {
64
+ try {
65
+ return ans == answer;
66
+ }
67
+ catch (err) {
68
+ return handleVEAError(err);
69
+ }
70
+ };
71
+ const getIsPointOnReciprocalFunctionQuestion = (ops) => {
72
+ const xNumber = randint(-9, 10, [0]);
73
+ const xFrac = RationalConstructor.randomIrreductible().toTree();
74
+ const xDecimal = random([
75
+ round(randint(-9, 10, [0]) * 0.1, 3),
76
+ round(randint(-3, 4, [0]) * 0.25, 3),
77
+ ]);
78
+ const xChoices = [xNumber.toTree(), xFrac, xDecimal.toTree()];
79
+ const chosenX = random(xChoices);
80
+ const yNumber = coinFlip()
81
+ ? frac(1, chosenX).simplify()
82
+ : randint(1, 10).toTree();
83
+ const identifiers = {
84
+ x: chosenX.toIdentifiers(),
85
+ y: yNumber.toIdentifiers(),
86
+ };
87
+ return getQuestionFromIdentifiers(identifiers);
88
+ };
89
+ const getQuestionFromIdentifiers = (identifiers) => {
90
+ return {
91
+ answer: getAnswer(identifiers),
92
+ instruction: getInstruction(identifiers),
93
+ keys: getKeys(identifiers),
94
+ answerFormat: "tex",
95
+ identifiers,
96
+ hint: getHint(identifiers),
97
+ correction: getCorrection(identifiers),
98
+ };
99
+ };
100
+ export const isPointOnReciprocalFunction = {
101
+ id: "isPointOnReciprocalFunction",
102
+ label: "Déterminer si un point appartient à la courbe de la fonction inverse",
103
+ isSingleStep: true,
104
+ generator: (nb, opts) => getDistinctQuestions(() => getIsPointOnReciprocalFunctionQuestion(opts), nb),
105
+ qcmTimer: 60,
106
+ freeTimer: 60,
107
+ getPropositions,
108
+ isAnswerValid,
109
+ subject: "Mathématiques",
110
+ getInstruction,
111
+ getHint,
112
+ getCorrection,
113
+ getAnswer,
114
+ getQuestionFromIdentifiers,
115
+ hasHintAndCorrection: true,
116
+ answerType: "QCU",
117
+ };
@@ -6,6 +6,9 @@ type Identifiers = {
6
6
  type: number;
7
7
  ineqSymbol?: string;
8
8
  };
9
- export declare const equationFromSignTable: Exercise<Identifiers>;
9
+ type Options = {
10
+ questionType: string;
11
+ };
12
+ export declare const equationFromSignTable: Exercise<Identifiers, Options>;
10
13
  export {};
11
14
  //# sourceMappingURL=equationFromSignTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"equationFromSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/equationFromSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAc7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAkPF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
1
+ {"version":3,"file":"equationFromSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/equationFromSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAc7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAuQF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmBhE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionType, GeneratorOptionTarget, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { InequationSymbol, InequationSymbolConstructor, } from "../../../../math/inequations/inequation.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
@@ -150,14 +150,18 @@ $$
150
150
  ${getAnswer(identifiers)}
151
151
  $$`;
152
152
  };
153
- const getReadSignTableQuestion = (ops) => {
153
+ const getReadSignTableQuestion = (opts) => {
154
154
  const a = randint(-10, 0);
155
155
  const b = randint(0, 10);
156
156
  const xs = [MinusInfinityNode, a.toTree(), b.toTree(), PlusInfinityNode];
157
157
  const signs = coinFlip()
158
158
  ? ["+", "0", "-", "0", "+"]
159
159
  : ["-", "0", "+", "0", "-"];
160
- const type = randint(0, 2);
160
+ const type = !opts?.questionType || opts.questionType === "Les deux"
161
+ ? randint(0, 2)
162
+ : opts.questionType === "Inéquations"
163
+ ? 1
164
+ : 0;
161
165
  const ineqSymbol = InequationSymbolConstructor.randomSymbol();
162
166
  const identifiers = {
163
167
  type,
@@ -165,7 +169,7 @@ const getReadSignTableQuestion = (ops) => {
165
169
  xs: xs.map((e) => e.toIdentifiers()),
166
170
  signs,
167
171
  };
168
- return getQuestionFromIdentifiers(identifiers);
172
+ return getQuestionFromIdentifiers(identifiers, opts);
169
173
  };
170
174
  const isAnswerValid = (ans, { answer, ...identifiers }) => {
171
175
  try {
@@ -192,15 +196,25 @@ const getKeys = (identifiers) => {
192
196
  else
193
197
  return ["S", "equal", "lbracket", "semicolon", "rbracket", "cup", "infty"];
194
198
  };
195
- const getQuestionFromIdentifiers = (identifiers) => {
199
+ const options = [
200
+ {
201
+ id: "questionType",
202
+ type: GeneratorOptionType.select,
203
+ label: "Types de questions",
204
+ target: GeneratorOptionTarget.generation,
205
+ defaultValue: "Les deux",
206
+ values: ["Équation $f(x) = 0$", "Inéquations", "Les deux"],
207
+ },
208
+ ];
209
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
196
210
  return {
197
- answer: getAnswer(identifiers),
198
- instruction: getInstruction(identifiers),
211
+ answer: getAnswer(identifiers, opts),
212
+ instruction: getInstruction(identifiers, opts),
199
213
  answerFormat: "raw",
200
214
  identifiers,
201
- hint: getHint(identifiers),
202
- correction: getCorrection(identifiers),
203
- keys: getKeys(identifiers),
215
+ hint: getHint(identifiers, opts),
216
+ correction: getCorrection(identifiers, opts),
217
+ keys: getKeys(identifiers, opts),
204
218
  };
205
219
  };
206
220
  export const equationFromSignTable = {
@@ -219,4 +233,5 @@ export const equationFromSignTable = {
219
233
  getQuestionFromIdentifiers,
220
234
  isAnswerValid,
221
235
  hasHintAndCorrection: true,
236
+ options,
222
237
  };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ a: NodeIdentifiers;
5
+ };
6
+ export declare const getImageOfSquareRootFunction: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=getImageOfSquareRootFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getImageOfSquareRootFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sqrt/getImageOfSquareRootFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAmIF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAoB9D,CAAC"}
@@ -0,0 +1,128 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
4
+ import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { sqrt } from "../../../../tree/nodes/functions/sqrtNode.js";
7
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
+ import { isNumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
9
+ import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
10
+ import { isPowerNode, square } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
12
+ import { random } from "../../../../utils/alea/random.js";
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ const getPropositions = (n, { answer }) => {
15
+ const propositions = [];
16
+ addValidProp(propositions, answer);
17
+ while (propositions.length < n) {
18
+ const randomNumber = randint(0, 100);
19
+ const randomNumberNode = randomNumber.toTree();
20
+ const randomNumberSquare = square(randomNumberNode);
21
+ const randomFraction = RationalConstructor.randomIrreductible().toTree();
22
+ const choices = [randomNumberNode, randomNumberSquare, randomFraction];
23
+ const randomChoice = random(choices);
24
+ tryToAddWrongProp(propositions, randomChoice.toTex());
25
+ }
26
+ return shuffleProps(propositions, n);
27
+ };
28
+ const getAnswer = (identifiers) => {
29
+ const { a } = identifiers;
30
+ const sqrtNode = sqrt(reifyAlgebraic(a));
31
+ const x = sqrtNode.simplify().toTex();
32
+ return x;
33
+ };
34
+ const getInstruction = (identifiers) => {
35
+ const { a } = identifiers;
36
+ return `Déterminer l'image de $${reifyAlgebraic(a).toTex()}$ par la fonction racine carrée.`;
37
+ };
38
+ const getHint = (identifiers) => {
39
+ const { a } = identifiers;
40
+ return `Quel est le nombre qui, multiplié par lui-même, donne $${reifyAlgebraic(a).toTex()}$ ?`;
41
+ };
42
+ const getCorrection = (identifiers) => {
43
+ const { a } = identifiers;
44
+ const aNode = reifyAlgebraic(a);
45
+ const tex = aNode.toTex();
46
+ const answer = getAnswer(identifiers);
47
+ switch (true) {
48
+ case isNumberNode(aNode):
49
+ return `On remarque que $${tex} = ${answer}^2$.
50
+
51
+ Ici on a donc $\\sqrt{${tex}} = ${answer}$.`;
52
+ case isPowerNode(aNode):
53
+ return `On sait que $\\sqrt{x^2} = |x|$.
54
+
55
+ Ici on a donc $\\sqrt{${tex}} = ${answer}$.`;
56
+ case isFractionNode(aNode):
57
+ return `On sait que $\\sqrt{\\frac{a}{b}} = \\frac{\\sqrt{a}}{\\sqrt{b}}$.
58
+
59
+ Ici on a donc $\\sqrt{${tex}} = ${answer}$.`;
60
+ default:
61
+ throw new Error(`getCorrection: nœud inattendu rencontré (${aNode.constructor.name})`);
62
+ }
63
+ };
64
+ const getKeys = (identifiers) => {
65
+ return [];
66
+ };
67
+ const isAnswerValid = (ans, { answer }) => {
68
+ try {
69
+ const ansNode = parseAlgebraic(ans);
70
+ const answerNode = parseAlgebraic(answer);
71
+ if (!isNumberNode(ansNode) && !isFractionNode(ansNode))
72
+ return false;
73
+ return ansNode.simplify().equals(answerNode.simplify());
74
+ }
75
+ catch (err) {
76
+ return handleVEAError(err);
77
+ }
78
+ };
79
+ const getGetImageOfSquareRootFunctionQuestion = (ops) => {
80
+ const xTreeValue = randint(1, 11) ** 2;
81
+ const xTree = xTreeValue.toTree();
82
+ const randomIntTree = randint(1, 100).toTree();
83
+ let denom = randint(2, 10);
84
+ let numer = randint(1, 10);
85
+ while (gcd(numer, denom) !== 1) {
86
+ denom = randint(2, 10);
87
+ numer = randint(1, 10);
88
+ }
89
+ const fractionTree = frac(numer ** 2, denom ** 2);
90
+ const candidates = [randomIntTree, fractionTree];
91
+ const chosenInputTree = candidates[randint(0, candidates.length)];
92
+ const squaredTree = square(chosenInputTree);
93
+ const choices = [
94
+ xTree.toIdentifiers(),
95
+ squaredTree.toIdentifiers(),
96
+ fractionTree.toIdentifiers(),
97
+ ];
98
+ const a = random(choices);
99
+ return getQuestionFromIdentifiers({ a });
100
+ };
101
+ const getQuestionFromIdentifiers = (identifiers) => {
102
+ return {
103
+ answer: getAnswer(identifiers),
104
+ instruction: getInstruction(identifiers),
105
+ keys: getKeys(identifiers),
106
+ answerFormat: "tex",
107
+ identifiers,
108
+ hint: getHint(identifiers),
109
+ correction: getCorrection(identifiers),
110
+ };
111
+ };
112
+ export const getImageOfSquareRootFunction = {
113
+ id: "getImageOfSquareRootFunction",
114
+ label: "Calculer une image par la fonction racine carrée",
115
+ isSingleStep: true,
116
+ generator: (nb, opts) => getDistinctQuestions(() => getGetImageOfSquareRootFunctionQuestion(opts), nb),
117
+ qcmTimer: 60,
118
+ freeTimer: 60,
119
+ getPropositions,
120
+ isAnswerValid,
121
+ subject: "Mathématiques",
122
+ getInstruction,
123
+ getHint,
124
+ getCorrection,
125
+ getAnswer,
126
+ getQuestionFromIdentifiers,
127
+ hasHintAndCorrection: true,
128
+ };
@@ -1,4 +1,5 @@
1
1
  export * from "./compareSqrtValues.js";
2
2
  export * from "./sqrtInequality.js";
3
3
  export * from "./squareRootCalculation.js";
4
+ export * from "./getImageOfSquareRootFunction.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sqrt/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sqrt/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./compareSqrtValues.js";
2
2
  export * from "./sqrtInequality.js";
3
3
  export * from "./squareRootCalculation.js";
4
+ export * from "./getImageOfSquareRootFunction.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ a: NodeIdentifiers;
5
+ b: NodeIdentifiers;
6
+ };
7
+ export declare const compareSquaredValues: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=compareSquaredValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareSquaredValues.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/square/compareSquaredValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAkJF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC"}