math-exercises 3.0.94 → 3.0.96

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 (88) 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/varTableFromSentences.d.ts +2 -0
  62. package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts.map +1 -0
  63. package/lib/exercises/math/functions/variations/varTableFromSentences.js +137 -0
  64. package/lib/exercises/math/powers/index.d.ts +1 -0
  65. package/lib/exercises/math/powers/index.d.ts.map +1 -1
  66. package/lib/exercises/math/powers/index.js +1 -0
  67. package/lib/exercises/math/powers/powerNotation.d.ts +9 -0
  68. package/lib/exercises/math/powers/powerNotation.d.ts.map +1 -0
  69. package/lib/exercises/math/powers/powerNotation.js +126 -0
  70. package/lib/exercises/math/probaStat/stats1var/averageList.d.ts.map +1 -1
  71. package/lib/exercises/math/probaStat/stats1var/averageList.js +1 -0
  72. package/lib/exercises/math/probaStat/stats1var/averageWithTable.d.ts.map +1 -1
  73. package/lib/exercises/math/probaStat/stats1var/averageWithTable.js +1 -0
  74. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -1
  75. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +1 -0
  76. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.d.ts.map +1 -1
  77. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +1 -0
  78. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts.map +1 -1
  79. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +1 -0
  80. package/lib/exercises/math/sets/index.d.ts +1 -0
  81. package/lib/exercises/math/sets/index.d.ts.map +1 -1
  82. package/lib/exercises/math/sets/index.js +1 -0
  83. package/lib/exercises/math/sets/isNumberDecimal.d.ts +11 -0
  84. package/lib/exercises/math/sets/isNumberDecimal.d.ts.map +1 -0
  85. package/lib/exercises/math/sets/isNumberDecimal.js +144 -0
  86. package/lib/index.d.ts +43 -42
  87. package/lib/index.d.ts.map +1 -1
  88. package/package.json +1 -1
@@ -0,0 +1,143 @@
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 { square } from "../../../../tree/nodes/operators/powerNode.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
+ let remaining = symbols.filter((s) => s !== answer);
14
+ while (remaining.length > 0) {
15
+ tryToAddWrongProp(propositions, remaining[remaining.length - 1]);
16
+ remaining.pop();
17
+ }
18
+ return shuffleProps(propositions, n);
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { a, b } = identifiers;
22
+ const aNode = square(reifyAlgebraic(a));
23
+ const bNode = square(reifyAlgebraic(b));
24
+ const aValue = aNode.simplify({ calculatePowers: true }).evaluate();
25
+ const bValue = bNode.simplify({ calculatePowers: true }).evaluate();
26
+ const res = aValue === bValue ? "=" : aValue < bValue ? "<" : ">";
27
+ return res;
28
+ };
29
+ const getInstruction = (identifiers) => {
30
+ const { a, b } = identifiers;
31
+ const aNode = square(reifyAlgebraic(a));
32
+ const bNode = square(reifyAlgebraic(b));
33
+ return `Compléter par le bon symbole :
34
+
35
+ $$
36
+ ${aNode.toTex()} \\ \\ldots \\ ${bNode.toTex()}
37
+ $$`;
38
+ };
39
+ const getHint = (identifiers) => {
40
+ const { a, b } = identifiers;
41
+ const aNode = reifyAlgebraic(a);
42
+ const bNode = reifyAlgebraic(b);
43
+ return `Pour tous nombres $a$ et $b$ tels que $a<b$ :
44
+
45
+ - Si $a$ et $b$ sont positifs, alors $a^2 <b^2$ ;
46
+ - Si $a$ et $b$ sont négatifs, alors $a^2 > b^2$.`;
47
+ };
48
+ const getCorrection = (identifiers) => {
49
+ const { a, b } = identifiers;
50
+ const aNode = reifyAlgebraic(a);
51
+ const bNode = reifyAlgebraic(b);
52
+ const simplifiedA = aNode.simplify({
53
+ calculatePowers: true,
54
+ });
55
+ const simplifiedB = bNode.simplify({ calculatePowers: true });
56
+ const valueA = simplifiedA.evaluate();
57
+ const valueB = simplifiedB.evaluate();
58
+ const sign = valueA < 0 ? "négatif" : "positif";
59
+ const symbol = valueA < valueB ? "<" : valueA > valueB ? ">" : "=";
60
+ const answer = getAnswer(identifiers);
61
+ return `Puisque $${aNode.toTex()}$ et $${bNode.toTex()}$ sont ${sign}s, et puisque $${aNode.toTex()} ${symbol} ${bNode.toTex()}$, on a :
62
+
63
+ $$
64
+ ${square(aNode).toTex()} ${answer} ${square(bNode).toTex()}
65
+ $$
66
+
67
+ `;
68
+ };
69
+ const getKeys = (identifiers) => {
70
+ return [];
71
+ };
72
+ const isAnswerValid = (ans, { answer }) => {
73
+ try {
74
+ throw Error("VEA not implemented");
75
+ }
76
+ catch (err) {
77
+ return handleVEAError(err);
78
+ }
79
+ };
80
+ const randCase = () => Math.floor(Math.random() * 2);
81
+ function randBetween(isInteger, min, max, roundTo, excludes) {
82
+ if (isInteger) {
83
+ return randint(min, max, excludes);
84
+ }
85
+ else {
86
+ return randfloat(min, max, roundTo, excludes);
87
+ }
88
+ }
89
+ const getCompareSquaredValuesQuestion = (ops) => {
90
+ const min = 0;
91
+ const max = 50;
92
+ const roundTo = 2;
93
+ const caseType = randCase();
94
+ const isInteger = coinFlip();
95
+ let a;
96
+ let b;
97
+ switch (caseType) {
98
+ case 0:
99
+ // tous deux positifs
100
+ a = randBetween(isInteger, min, max, roundTo);
101
+ b = randBetween(isInteger, min, max, roundTo, [a]);
102
+ break;
103
+ case 1:
104
+ // tous deux négatifs
105
+ a = -randBetween(isInteger, min, max, roundTo);
106
+ b = -randBetween(isInteger, min, max, roundTo, [-a]);
107
+ break;
108
+ }
109
+ const identifiers = {
110
+ a: a.toTree().toIdentifiers(),
111
+ b: b.toTree().toIdentifiers(),
112
+ };
113
+ return getQuestionFromIdentifiers(identifiers);
114
+ };
115
+ const getQuestionFromIdentifiers = (identifiers) => {
116
+ return {
117
+ answer: getAnswer(identifiers),
118
+ instruction: getInstruction(identifiers),
119
+ keys: getKeys(identifiers),
120
+ answerFormat: "tex",
121
+ identifiers,
122
+ hint: getHint(identifiers),
123
+ correction: getCorrection(identifiers),
124
+ };
125
+ };
126
+ export const compareSquaredValues = {
127
+ id: "compareSquaredValues",
128
+ label: "Comparer des nombres élevés au carré",
129
+ isSingleStep: true,
130
+ generator: (nb, opts) => getDistinctQuestions(() => getCompareSquaredValuesQuestion(opts), nb),
131
+ qcmTimer: 60,
132
+ freeTimer: 60,
133
+ getPropositions,
134
+ isAnswerValid,
135
+ subject: "Mathématiques",
136
+ getInstruction,
137
+ getHint,
138
+ getCorrection,
139
+ getAnswer,
140
+ getQuestionFromIdentifiers,
141
+ hasHintAndCorrection: true,
142
+ answerType: "QCU",
143
+ };
@@ -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 imageOfSquareFunction: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=imageOfSquareFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageOfSquareFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/square/imageOfSquareFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAwJF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAiBvD,CAAC"}
@@ -0,0 +1,152 @@
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 { randint } from "../../../../math/utils/random/randint.js";
5
+ import { sqrt, SqrtNode } from "../../../../tree/nodes/functions/sqrtNode.js";
6
+ import { NodeIds } from "../../../../tree/nodes/node.js";
7
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
9
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
10
+ import { divide } from "../../../../tree/nodes/operators/divideNode.js";
11
+ import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
12
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
13
+ import { square } from "../../../../tree/nodes/operators/powerNode.js";
14
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
15
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
16
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
17
+ const getPropositions = (n, { answer, ...identifiers }) => {
18
+ const propositions = [];
19
+ addValidProp(propositions, answer);
20
+ const { a } = identifiers;
21
+ if (a.id === NodeIds.fraction) {
22
+ const frac = reifyAlgebraic(a);
23
+ // Erreurs potentielles pour les fractions:
24
+ // - l'élève ne fait le carré que sur le nominateur et dénominateur
25
+ // - l'élève multiplie par 2 à la place de faire un carré
26
+ tryToAddWrongProp(propositions, new FractionNode(frac.leftChild, square(frac.rightChild))
27
+ .simplify()
28
+ .toTex());
29
+ tryToAddWrongProp(propositions, new FractionNode(square(frac.leftChild), frac.rightChild)
30
+ .simplify()
31
+ .toTex());
32
+ tryToAddWrongProp(propositions, new FractionNode(frac.leftChild, multiply(frac.rightChild, 2))
33
+ .simplify()
34
+ .toTex());
35
+ tryToAddWrongProp(propositions, new FractionNode(multiply(frac.leftChild, 2), frac.rightChild)
36
+ .simplify()
37
+ .toTex());
38
+ tryToAddWrongProp(propositions, multiply(frac, 2).simplify().toTex());
39
+ }
40
+ else if (a.id === NodeIds.number) {
41
+ const N = reifyAlgebraic(a);
42
+ // Erreurs potentielles pour les nombres:
43
+ // - Division par 2
44
+ // - Multiplication par 2 (sauf pour le cas N = 2)
45
+ // - Carre de N+1
46
+ // - Carre de N-1
47
+ if (N.value != 2)
48
+ tryToAddWrongProp(propositions, multiply(N, 2).simplify().toTex());
49
+ tryToAddWrongProp(propositions, divide(N, 2).simplify().toTex());
50
+ tryToAddWrongProp(propositions, square(substract(N, 1)).simplify().toTex());
51
+ tryToAddWrongProp(propositions, square(add(N, 1)).simplify().toTex());
52
+ }
53
+ else {
54
+ // Cas racine carre
55
+ // Multiplication de 2 dans la racine
56
+ // Multiplication de 2 en dehors de la racine
57
+ // N^2 pour sqrt(N) (carre effectue deux fois)
58
+ const N = reifyAlgebraic(a);
59
+ tryToAddWrongProp(propositions, sqrt(multiply(N.child, 2)).simplify().toTex());
60
+ tryToAddWrongProp(propositions, multiply(N, 2).simplify().toTex());
61
+ tryToAddWrongProp(propositions, square(N.child).simplify().toTex());
62
+ }
63
+ return shuffleProps(propositions, n);
64
+ };
65
+ const getAnswer = (identifiers) => {
66
+ const { a } = identifiers;
67
+ const correctAnswer = square(reifyAlgebraic(a));
68
+ return correctAnswer.simplify().toTex();
69
+ };
70
+ const getInstruction = (identifiers) => {
71
+ const { a } = identifiers;
72
+ const nNode = reifyAlgebraic(a);
73
+ return `Calculer l'image de $${nNode.toTex()}$ par la fonction carré.`;
74
+ };
75
+ const getHint = (identifiers) => {
76
+ return `La fonction carré est la fonction définie par:
77
+
78
+ $$
79
+ f(x) = x^2
80
+ $$`;
81
+ };
82
+ const getCorrection = (identifiers) => {
83
+ const { a } = identifiers;
84
+ const aNode = reifyAlgebraic(a);
85
+ return `L'image de $${aNode.toTex()}$ par $f(x) = x^2$ est :
86
+
87
+ $$
88
+ f\\left(${aNode.toTex()}\\right) = ${square(aNode).toTex()} = ${getAnswer(identifiers)}
89
+ $$`;
90
+ };
91
+ const getKeys = (identifiers) => {
92
+ return [];
93
+ };
94
+ const isAnswerValid = (ans, { answer }) => {
95
+ try {
96
+ const studentAnswer = parseAlgebraic(ans);
97
+ const correctAnswer = parseAlgebraic(answer);
98
+ return studentAnswer
99
+ .simplify({ decimalToFractions: true })
100
+ .equals(correctAnswer.simplify());
101
+ }
102
+ catch (err) {
103
+ return handleVEAError(err);
104
+ }
105
+ };
106
+ const getImageOfSquareFunctionQuestion = (ops) => {
107
+ let a = null;
108
+ // Soit un nombre, soit une fraction, soit une racine carre
109
+ const choice = randint(1, 4);
110
+ switch (choice) {
111
+ case 1:
112
+ a = new NumberNode(randint(-10, 10));
113
+ break;
114
+ case 2:
115
+ a = RationalConstructor.randomIrreductible().toTree();
116
+ break;
117
+ case 3:
118
+ default:
119
+ a = new SqrtNode(new NumberNode(randint(2, 100)));
120
+ break;
121
+ }
122
+ const identifiers = { a: a.toIdentifiers() };
123
+ return getQuestionFromIdentifiers(identifiers);
124
+ };
125
+ const getQuestionFromIdentifiers = (identifiers) => {
126
+ return {
127
+ answer: getAnswer(identifiers),
128
+ instruction: getInstruction(identifiers),
129
+ keys: getKeys(identifiers),
130
+ answerFormat: "tex",
131
+ identifiers,
132
+ hint: getHint(identifiers),
133
+ correction: getCorrection(identifiers),
134
+ };
135
+ };
136
+ export const imageOfSquareFunction = {
137
+ id: "imageOfSquareFunction",
138
+ label: "Calcul d'image par la fonction carré",
139
+ isSingleStep: true,
140
+ generator: (nb, opts) => getDistinctQuestions(() => getImageOfSquareFunctionQuestion(opts), nb),
141
+ qcmTimer: 60,
142
+ freeTimer: 60,
143
+ getPropositions,
144
+ isAnswerValid,
145
+ subject: "Mathématiques",
146
+ getInstruction,
147
+ getHint,
148
+ getCorrection,
149
+ getAnswer,
150
+ getQuestionFromIdentifiers,
151
+ hasHintAndCorrection: true,
152
+ };
@@ -1,3 +1,4 @@
1
1
  export * from "./squareImageInterval.js";
2
- export * from "./getImageOfSquareRootFunction.js";
2
+ export * from "./imageOfSquareFunction.js";
3
+ export * from "./compareSquaredValues.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/square/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/square/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export * from "./squareImageInterval.js";
2
- export * from "./getImageOfSquareRootFunction.js";
2
+ export * from "./imageOfSquareFunction.js";
3
+ export * from "./compareSquaredValues.js";
4
+ // export * from "./sqaureImageIntervalWithGraph.js";
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
3
+ type Identifiers = {
4
+ a: number;
5
+ b: number;
6
+ closure: ClosureType;
7
+ type: number;
8
+ };
9
+ export declare const squareImageIntervalWithGraph: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=squareImageIntervalWithGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"squareImageIntervalWithGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/square/squareImageIntervalWithGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAW,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAMxE,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA8LF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAc9D,CAAC"}
@@ -0,0 +1,174 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randomColor } from "../../../../geogebra/colors.js";
4
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { Closure, ClosureType } from "../../../../tree/nodes/sets/closure.js";
7
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
8
+ import { intervalParser } from "../../../../tree/parsers/intervalParser.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ // a < x < b avec a > 0 ==> a^2 < x^2 < b^2
11
+ // a < x < b avec b < 0 ==> b^2 < x^2 < a^2
12
+ // a < x < b avec a<0 et b>0 ==> 0 < x^2 < max(|a|,|b|)^2
13
+ const getAnswerNode = (identifiers) => {
14
+ const { a, b, closure, type } = identifiers;
15
+ switch (type) {
16
+ case 1:
17
+ return new IntervalNode((a ** 2).toTree(), (b ** 2).toTree(), closure);
18
+ case 2:
19
+ return new IntervalNode((b ** 2).toTree(), (a ** 2).toTree(), Closure.switch(closure));
20
+ case 3:
21
+ default:
22
+ const max = Math.max(Math.abs(a), Math.abs(b));
23
+ const maxClosure = Math.abs(a) === Math.abs(b)
24
+ ? closure !== ClosureType.OO
25
+ ? "F"
26
+ : "O"
27
+ : max === Math.abs(a)
28
+ ? closure === ClosureType.FF || closure === ClosureType.FO
29
+ ? "F"
30
+ : "O"
31
+ : closure === ClosureType.FF || closure === ClosureType.OF
32
+ ? "F"
33
+ : "O";
34
+ const ansClosure = maxClosure === "F" ? ClosureType.FF : ClosureType.FO;
35
+ return new IntervalNode((0).toTree(), (Math.max(Math.abs(a), Math.abs(b)) ** 2).toTree(), ansClosure);
36
+ }
37
+ };
38
+ const getAnswer = (identifiers) => {
39
+ return getAnswerNode(identifiers).toTex();
40
+ };
41
+ const getInstruction = (identifiers) => {
42
+ const { type, a, b, closure } = identifiers;
43
+ let instruction = "";
44
+ switch (type) {
45
+ case 1:
46
+ instruction = new IntervalNode(a.toTree(), b.toTree(), closure)
47
+ .toInequality()
48
+ .toTex();
49
+ break;
50
+ case 2:
51
+ instruction = new IntervalNode(a.toTree(), b.toTree(), closure)
52
+ .toInequality()
53
+ .toTex();
54
+ break;
55
+ case 3:
56
+ default:
57
+ instruction = new IntervalNode(a.toTree(), b.toTree(), closure)
58
+ .toInequality()
59
+ .toTex();
60
+ break;
61
+ }
62
+ return `Soit $x$ un nombre réel tel que :
63
+
64
+ $$
65
+ ${instruction}
66
+ $$
67
+
68
+ On rappelle ci-dessous la courbe représentative de la fonction carré $f(x) = x^2$.
69
+
70
+ À l'aide de la courbe, déterminer à quel intervalle appartient $x^2$.`;
71
+ };
72
+ const getSquareImageIntervalQuestion = () => {
73
+ let a;
74
+ let b;
75
+ let instruction = "";
76
+ let closure;
77
+ const type = randint(1, 4);
78
+ switch (type) {
79
+ case 1:
80
+ a = randint(0, 5);
81
+ b = randint(a + 1, a + 5);
82
+ closure = Closure.random();
83
+ break;
84
+ case 2:
85
+ b = randint(-5, 0);
86
+ a = randint(b - 5, b);
87
+ closure = Closure.random();
88
+ break;
89
+ case 3:
90
+ default:
91
+ a = randint(-9, 0);
92
+ b = randint(1, 10);
93
+ closure = Closure.random();
94
+ break;
95
+ }
96
+ const identifiers = { a, b, closure, type };
97
+ return getQuestionFromIdentifiers(identifiers);
98
+ };
99
+ const getHint = (identifiers) => {
100
+ return ``;
101
+ };
102
+ const getCorrection = (identifiers) => {
103
+ const { a, b, closure, type } = identifiers;
104
+ const interval = new IntervalNode(a.toTree(), b.toTree(), closure);
105
+ return ``;
106
+ };
107
+ const getGGBOptions = (identifiers) => {
108
+ const ggb = new GeogebraConstructor({
109
+ commands: ["f(x) = x^2", `SetColor(f, "${randomColor()}")`],
110
+ lockedAxesRatio: false,
111
+ });
112
+ const { a, b } = identifiers;
113
+ return ggb.getOptions({
114
+ // coords: [
115
+ // Math.min(a - 1, -1),
116
+ // Math.max(b + 1, 1),
117
+ // -1,
118
+ // Math.max(a ** 2, b ** 2) + 1,
119
+ // ],
120
+ coords: [-11, 11, -5, 110],
121
+ });
122
+ };
123
+ const getQuestionFromIdentifiers = (identifiers) => {
124
+ const question = {
125
+ answer: getAnswer(identifiers),
126
+ instruction: getInstruction(identifiers),
127
+ keys: ["lbracket", "semicolon", "rbracket"],
128
+ answerFormat: "tex",
129
+ identifiers,
130
+ hint: getHint(identifiers),
131
+ correction: getCorrection(identifiers),
132
+ ggbOptions: getGGBOptions(identifiers),
133
+ };
134
+ return question;
135
+ };
136
+ const getPropositions = (n, { answer, a, b, type, closure }) => {
137
+ const propositions = [];
138
+ addValidProp(propositions, answer);
139
+ tryToAddWrongProp(propositions, new IntervalNode(a.toTree(), b.toTree(), closure).toTex());
140
+ if (type === 3) {
141
+ const min = Math.min(Math.abs(a), Math.abs(b)) ** 2;
142
+ const max = Math.max(Math.abs(a), Math.abs(b)) ** 2;
143
+ tryToAddWrongProp(propositions, new IntervalNode(min.toTree(), max.toTree(), closure).toTex());
144
+ }
145
+ while (propositions.length < n) {
146
+ tryToAddWrongProp(propositions, getAnswer({ a, b, type, closure: Closure.random() }));
147
+ }
148
+ return shuffleProps(propositions, n);
149
+ };
150
+ const isAnswerValid = (ans, { answer, a, b, closure, type }) => {
151
+ try {
152
+ const parsed = intervalParser(ans);
153
+ if (!parsed)
154
+ return false;
155
+ return parsed.simplify().toTex() === answer;
156
+ }
157
+ catch (err) {
158
+ return handleVEAError(err);
159
+ }
160
+ };
161
+ export const squareImageIntervalWithGraph = {
162
+ id: "squareImageIntervalWithGraph",
163
+ label: "Passer une inégalité au carré (avec graphique)",
164
+ isSingleStep: true,
165
+ generator: (nb) => getDistinctQuestions(getSquareImageIntervalQuestion, nb),
166
+ qcmTimer: 60,
167
+ freeTimer: 60,
168
+ getPropositions,
169
+ isAnswerValid,
170
+ subject: "Mathématiques",
171
+ getQuestionFromIdentifiers,
172
+ hasHintAndCorrection: true,
173
+ hasGeogebra: true,
174
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=varTableFromSentences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varTableFromSentences.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/varTableFromSentences.ts"],"names":[],"mappings":""}
@@ -0,0 +1,137 @@
1
+ // import {
2
+ // Exercise,
3
+ // Proposition,
4
+ // QCMGenerator,
5
+ // Question,
6
+ // QuestionGenerator,
7
+ // VEA,
8
+ // addValidProp,
9
+ // shuffleProps,
10
+ // GetAnswer,
11
+ // GetHint,
12
+ // GetCorrection,
13
+ // GetInstruction,
14
+ // GetKeys,
15
+ // GetQuestionFromIdentifiers,
16
+ // GetAnswerTable,
17
+ // TableVEA,
18
+ // } from "../../../../exercises/exercise.js";
19
+ // import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
20
+ // import { randTupleInt } from "../../../../math/utils/random/randTupleInt.js";
21
+ // import {
22
+ // NodeIdentifiers,
23
+ // reifyAlgebraic,
24
+ // } from "../../../../tree/nodes/nodeConstructor.js";
25
+ // import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
26
+ // import { coinFlip } from "../../../../utils/alea/coinFlip.js";
27
+ // import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
28
+ export {};
29
+ // type Identifiers = {
30
+ // vars: string[];
31
+ // xs: NodeIdentifiers[];
32
+ // };
33
+ // /**
34
+ // *
35
+ // * xs
36
+ // * [-10, -4, 3, 10]
37
+ // * [f(-10), "\\nearrow", f(-4), "\\searrow", "f(3)", "\\nearrow", f(10)]
38
+ // */
39
+ // const getAnswerTable: GetAnswerTable<Identifiers> = (identifiers) => {
40
+ // const { vars, xs } = identifiers;
41
+ // const xsNodes = xs.map((x) => reifyAlgebraic(x));
42
+ // const secondLine: string[][] = [[], [], []];
43
+ // for (let i = 0; i < vars.length; i++) {
44
+ // if (i % 2 === 0) {
45
+ // let row = 0;
46
+ // if (i === 0) {
47
+ // row = vars[1] === "\\nearrow" ? 2 : 0;
48
+ // } else {
49
+ // row = vars[i - 1] === "\\nearrow" ? 0 : 2;
50
+ // }
51
+ // secondLine[row].push(vars[i]);
52
+ // secondLine[2 - row].push("\\ ");
53
+ // secondLine[1].push("\\ ");
54
+ // } else {
55
+ // secondLine[1].push(vars[i]);
56
+ // secondLine[0].push("\\ ");
57
+ // secondLine[2].push("\\ ");
58
+ // }
59
+ // }
60
+ // return [
61
+ // ["$x$", ...xsNodes.join("\\ ")],
62
+ // ["$\\ $", ...secondLine[0]],
63
+ // ["$f(x)$", ...secondLine[1]],
64
+ // ["$\\ $", ...secondLine[2]],
65
+ // ];
66
+ // };
67
+ // const getInstruction: GetInstruction<Identifiers> = (identifiers) => {
68
+ // const { vars, xs } = identifiers;
69
+ // const xsNodes = xs.map((x) => reifyAlgebraic(x));
70
+ // return `La fonction $f$ est définie sur ...
71
+ // Elle est croissante sur ...
72
+ // Elle est décroissante sur ...
73
+ // De plus, on a $f()=...$`;
74
+ // };
75
+ // const getHint: GetHint<Identifiers> = (identifiers) => {
76
+ // return `La première ligne d'un tableau de variations contient les valeurs de $x$. La deuxième ligne donne les variations de la fonction en fonction des valeurs de $x$ de la premiere ligne.`;
77
+ // };
78
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
79
+ // return ``;
80
+ // };
81
+ // const getKeys: GetKeys<Identifiers> = (identifiers) => {
82
+ // return [];
83
+ // };
84
+ // const isAnswerTableValid: TableVEA<Identifiers> = (ans, { answerTable }) => {
85
+ // try {
86
+ // return ans.every((row, i) =>
87
+ // row.every((cell, j) => cell === answerTable[i][j]),
88
+ // );
89
+ // } catch (err) {
90
+ // return handleVEAError(err);
91
+ // }
92
+ // };
93
+ // const getVarTableFromSentencesQuestion: QuestionGenerator<Identifiers> = (
94
+ // ops,
95
+ // ) => {
96
+ // const x = randTupleInt(4, {allDifferent: true, from: -10, to: 11})
97
+ // const xs = x.sort((a,b)=>a-b);
98
+ // const sens = coinFlip()
99
+ // const vars = [];
100
+ // const identifiers: Identifiers = {
101
+ // xs: xs.map((e)=>e.toTree().toIdentifiers()),
102
+ // vars,
103
+ // };
104
+ // return getQuestionFromIdentifiers(identifiers);
105
+ // };
106
+ // const getQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers> = (
107
+ // identifiers,
108
+ // ) => {
109
+ // return {
110
+ // answerTable: getAnswerTable(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 varTableFromSentences: Exercise<Identifiers> = {
120
+ // id: "varTableFromSentences",
121
+ // label:
122
+ // "Dresser le tableau de variations d'une fonction à partir de phrases descriptives",
123
+ // isSingleStep: true,
124
+ // generator: (nb, opts) =>
125
+ // getDistinctQuestions(() => getVarTableFromSentencesQuestion(opts), nb),
126
+ // qcmTimer: 60,
127
+ // freeTimer: 60,
128
+ // isAnswerTableValid,
129
+ // subject: "Mathématiques",
130
+ // getInstruction,
131
+ // getHint,
132
+ // getCorrection,
133
+ // getAnswerTable,
134
+ // getQuestionFromIdentifiers,
135
+ // hasHintAndCorrection: true,
136
+ // answerType: "varTable",
137
+ // };
@@ -9,4 +9,5 @@ export * from "./powersProduct.js";
9
9
  export * from "./scientificToDecimal.js";
10
10
  export * from "./powersMixOperations.js";
11
11
  export * from "./powersOfTenMixOperations.js";
12
+ export * from "./powerNotation.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC"}