math-exercises 3.0.199 → 3.0.200

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 (123) hide show
  1. package/lib/exercises/exercise.d.ts +14 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/_debug/debugReorder1.d.ts +8 -0
  4. package/lib/exercises/math/_debug/debugReorder1.d.ts.map +1 -0
  5. package/lib/exercises/math/_debug/debugReorder1.js +81 -0
  6. package/lib/exercises/math/_debug/debugReorder2.d.ts +10 -0
  7. package/lib/exercises/math/_debug/debugReorder2.d.ts.map +1 -0
  8. package/lib/exercises/math/_debug/debugReorder2.js +88 -0
  9. package/lib/exercises/math/_debug/debugReorder3.d.ts +10 -0
  10. package/lib/exercises/math/_debug/debugReorder3.d.ts.map +1 -0
  11. package/lib/exercises/math/_debug/debugReorder3.js +81 -0
  12. package/lib/exercises/math/_debug/index.d.ts +3 -1
  13. package/lib/exercises/math/_debug/index.d.ts.map +1 -1
  14. package/lib/exercises/math/_debug/index.js +3 -1
  15. package/lib/exercises/math/calcul/factorial/index.d.ts +2 -0
  16. package/lib/exercises/math/calcul/factorial/index.d.ts.map +1 -0
  17. package/lib/exercises/math/calcul/factorial/index.js +1 -0
  18. package/lib/exercises/math/calcul/factorial/simplifyQuotientOfFactorialToProduct.d.ts +8 -0
  19. package/lib/exercises/math/calcul/factorial/simplifyQuotientOfFactorialToProduct.d.ts.map +1 -0
  20. package/lib/exercises/math/calcul/factorial/simplifyQuotientOfFactorialToProduct.js +199 -0
  21. package/lib/exercises/math/combinatory/combination/index.d.ts +3 -0
  22. package/lib/exercises/math/combinatory/combination/index.d.ts.map +1 -0
  23. package/lib/exercises/math/combinatory/combination/index.js +2 -0
  24. package/lib/exercises/math/combinatory/combination/mentalCalculateCombination.d.ts +11 -0
  25. package/lib/exercises/math/combinatory/combination/mentalCalculateCombination.d.ts.map +1 -0
  26. package/lib/exercises/math/combinatory/combination/mentalCalculateCombination.js +225 -0
  27. package/lib/exercises/math/combinatory/combination/writeCombinationFormulaUsingFactorial.d.ts +13 -0
  28. package/lib/exercises/math/combinatory/combination/writeCombinationFormulaUsingFactorial.d.ts.map +1 -0
  29. package/lib/exercises/math/combinatory/combination/writeCombinationFormulaUsingFactorial.js +285 -0
  30. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts.map +1 -1
  31. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.js +1 -1
  32. package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.d.ts +9 -0
  33. package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.d.ts.map +1 -0
  34. package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.js +209 -0
  35. package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.d.ts +9 -0
  36. package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.d.ts.map +1 -0
  37. package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.js +359 -0
  38. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts +11 -0
  39. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts.map +1 -0
  40. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +445 -0
  41. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts.map +1 -1
  42. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.js +2 -3
  43. package/lib/exercises/math/index.d.ts +1 -0
  44. package/lib/exercises/math/index.d.ts.map +1 -1
  45. package/lib/exercises/math/index.js +1 -1
  46. package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
  47. package/lib/exercises/math/limits/sequenceGeometricLimit.js +9 -0
  48. package/lib/exercises/math/primitive/constantPrimitive.d.ts +8 -5
  49. package/lib/exercises/math/primitive/constantPrimitive.d.ts.map +1 -1
  50. package/lib/exercises/math/primitive/constantPrimitive.js +40 -21
  51. package/lib/exercises/math/probaStat/stats2var/averagePoint.d.ts.map +1 -1
  52. package/lib/exercises/math/probaStat/stats2var/averagePoint.js +34 -2
  53. package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdFromGraph.d.ts +15 -0
  54. package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdFromGraph.d.ts.map +1 -0
  55. package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdFromGraph.js +255 -0
  56. package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdUsingCalculator.d.ts +15 -0
  57. package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdUsingCalculator.d.ts.map +1 -0
  58. package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdUsingCalculator.js +242 -0
  59. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.js +4 -4
  60. package/lib/exercises/math/sequences/geometric/graph/geometricSignOfReasonFromGraph.d.ts +12 -0
  61. package/lib/exercises/math/sequences/geometric/graph/geometricSignOfReasonFromGraph.d.ts.map +1 -0
  62. package/lib/exercises/math/sequences/geometric/graph/geometricSignOfReasonFromGraph.js +161 -0
  63. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.d.ts +10 -0
  64. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.d.ts.map +1 -0
  65. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.js +224 -0
  66. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.d.ts +18 -0
  67. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.d.ts.map +1 -0
  68. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.js +198 -0
  69. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfPowEK.d.ts +10 -0
  70. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfPowEK.d.ts.map +1 -0
  71. package/lib/exercises/math/sets/cartesianProduct/findCardinalOfPowEK.js +231 -0
  72. package/lib/exercises/math/sets/cartesianProduct/findNumberOfPasswordsWithLettersAndNumbers.d.ts +19 -0
  73. package/lib/exercises/math/sets/cartesianProduct/findNumberOfPasswordsWithLettersAndNumbers.d.ts.map +1 -0
  74. package/lib/exercises/math/sets/cartesianProduct/findNumberOfPasswordsWithLettersAndNumbers.js +187 -0
  75. package/lib/exercises/math/sets/cartesianProduct/index.d.ts +7 -0
  76. package/lib/exercises/math/sets/cartesianProduct/index.d.ts.map +1 -0
  77. package/lib/exercises/math/sets/cartesianProduct/index.js +6 -0
  78. package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.d.ts +15 -0
  79. package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.d.ts.map +1 -0
  80. package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.js +291 -0
  81. package/lib/exercises/math/sets/cartesianProduct/proposeElementInPowEK.d.ts +15 -0
  82. package/lib/exercises/math/sets/cartesianProduct/proposeElementInPowEK.d.ts.map +1 -0
  83. package/lib/exercises/math/sets/cartesianProduct/proposeElementInPowEK.js +274 -0
  84. package/lib/exercises/math/sets/combinations/findNumberOfCombinationsFromSituation.d.ts +17 -0
  85. package/lib/exercises/math/sets/combinations/findNumberOfCombinationsFromSituation.d.ts.map +1 -0
  86. package/lib/exercises/math/sets/combinations/findNumberOfCombinationsFromSituation.js +228 -0
  87. package/lib/exercises/math/sets/combinations/findNumberOfProductsOfCombinationsFromSituation.d.ts +17 -0
  88. package/lib/exercises/math/sets/combinations/findNumberOfProductsOfCombinationsFromSituation.d.ts.map +1 -0
  89. package/lib/exercises/math/sets/combinations/findNumberOfProductsOfCombinationsFromSituation.js +388 -0
  90. package/lib/exercises/math/sets/combinations/index.d.ts +4 -0
  91. package/lib/exercises/math/sets/combinations/index.d.ts.map +1 -0
  92. package/lib/exercises/math/sets/combinations/index.js +3 -0
  93. package/lib/exercises/math/sets/combinations/proposeCombination.d.ts +15 -0
  94. package/lib/exercises/math/sets/combinations/proposeCombination.d.ts.map +1 -0
  95. package/lib/exercises/math/sets/combinations/proposeCombination.js +347 -0
  96. package/lib/exercises/math/sets/partialPermutations/findNumberOfPartialPermutationsFromSituation.d.ts +16 -0
  97. package/lib/exercises/math/sets/partialPermutations/findNumberOfPartialPermutationsFromSituation.d.ts.map +1 -0
  98. package/lib/exercises/math/sets/partialPermutations/findNumberOfPartialPermutationsFromSituation.js +186 -0
  99. package/lib/exercises/math/sets/partialPermutations/findNumberOfPermutationsFromSituation.d.ts +17 -0
  100. package/lib/exercises/math/sets/partialPermutations/findNumberOfPermutationsFromSituation.d.ts.map +1 -0
  101. package/lib/exercises/math/sets/partialPermutations/findNumberOfPermutationsFromSituation.js +232 -0
  102. package/lib/exercises/math/sets/partialPermutations/index.d.ts +4 -0
  103. package/lib/exercises/math/sets/partialPermutations/index.d.ts.map +1 -0
  104. package/lib/exercises/math/sets/partialPermutations/index.js +3 -0
  105. package/lib/exercises/math/sets/partialPermutations/proposePartialPermutation.d.ts +15 -0
  106. package/lib/exercises/math/sets/partialPermutations/proposePartialPermutation.d.ts.map +1 -0
  107. package/lib/exercises/math/sets/partialPermutations/proposePartialPermutation.js +343 -0
  108. package/lib/exercises/math/trigonometry/functions/parityOfCosAXTimesSinBX.d.ts +8 -0
  109. package/lib/exercises/math/trigonometry/functions/parityOfCosAXTimesSinBX.d.ts.map +1 -0
  110. package/lib/exercises/math/trigonometry/functions/parityOfCosAXTimesSinBX.js +193 -0
  111. package/lib/index.d.ts +15 -1
  112. package/lib/index.d.ts.map +1 -1
  113. package/lib/math/sets/setOperations.d.ts +9 -0
  114. package/lib/math/sets/setOperations.d.ts.map +1 -0
  115. package/lib/math/sets/setOperations.js +84 -0
  116. package/lib/math/sets/tuple.d.ts +12 -0
  117. package/lib/math/sets/tuple.d.ts.map +1 -0
  118. package/lib/math/sets/tuple.js +17 -0
  119. package/lib/server.js +25 -0
  120. package/lib/tree/utilities/nodePrinter.d.ts +7 -0
  121. package/lib/tree/utilities/nodePrinter.d.ts.map +1 -0
  122. package/lib/tree/utilities/nodePrinter.js +36 -0
  123. package/package.json +1 -1
@@ -0,0 +1,445 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { nodeByReplacingNodeAtPath } from "../../../../../math/utils/functions/functionComposition.js";
4
+ import { randint } from "../../../../../math/utils/random/randint.js";
5
+ import { cos, CosNode } from "../../../../../tree/nodes/functions/cosNode.js";
6
+ import { isFunctionNode } from "../../../../../tree/nodes/functions/functionNode.js";
7
+ import { sin, SinNode } from "../../../../../tree/nodes/functions/sinNode.js";
8
+ import { NodeIds } from "../../../../../tree/nodes/node.js";
9
+ import { NodeConstructor, } from "../../../../../tree/nodes/nodeConstructor.js";
10
+ import { isNumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
11
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
12
+ import { multiply, } from "../../../../../tree/nodes/operators/multiplyNode.js";
13
+ import { isOperatorNode, } from "../../../../../tree/nodes/operators/operatorNode.js";
14
+ import { isPowerNode, isSquareNode, power, square, } from "../../../../../tree/nodes/operators/powerNode.js";
15
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
16
+ import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
17
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
18
+ import { NodeComparator } from "../../../../../tree/utilities/nodeComparator.js";
19
+ import { NodePrinter } from "../../../../../tree/utilities/nodePrinter.js";
20
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
21
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
22
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
23
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
24
+ function myRewrite(node, createFuncRewrite) {
25
+ const funcRewrite = createFuncRewrite(node);
26
+ if (funcRewrite !== undefined) {
27
+ const nodeRewritten = funcRewrite(node);
28
+ return nodeRewritten;
29
+ }
30
+ else {
31
+ if (isOperatorNode(node)) {
32
+ return nodeByReplacingNodeAtPath(nodeByReplacingNodeAtPath(node, { keys: ["leftChild"] }, myRewrite(node.leftChild, createFuncRewrite)), { keys: ["rightChild"] }, myRewrite(node.rightChild, createFuncRewrite));
33
+ }
34
+ else if (isFunctionNode(node)) {
35
+ return nodeByReplacingNodeAtPath(node, { keys: ["child"] }, myRewrite(node.child, createFuncRewrite));
36
+ }
37
+ else {
38
+ return node;
39
+ }
40
+ }
41
+ }
42
+ const mySimplify = (node) => {
43
+ const rewriteCosToCAndSinToS = (node) => myRewrite(node, (node) => {
44
+ if (node.toTex() === "\\cos\\left(x\\right)") {
45
+ return () => new VariableNode("c");
46
+ }
47
+ else if (node.toTex() === "\\sin\\left(x\\right)") {
48
+ return () => new VariableNode("s");
49
+ }
50
+ else {
51
+ return undefined;
52
+ }
53
+ });
54
+ const rewriteCToCosAndSToSin = (node) => myRewrite(node, (node) => {
55
+ if (node.toTex() === "c") {
56
+ return () => new CosNode(new VariableNode("x"));
57
+ }
58
+ else if (node.toTex() === "s") {
59
+ return () => new SinNode(new VariableNode("x"));
60
+ }
61
+ else {
62
+ return undefined;
63
+ }
64
+ });
65
+ const nodeCSRaw = rewriteCosToCAndSinToS(node);
66
+ const nodeCSSimplified = nodeCSRaw.simplify({
67
+ towardsDistribute: true,
68
+ forbidFactorize: true,
69
+ });
70
+ const nodeMySimplified = rewriteCToCosAndSToSin(nodeCSSimplified);
71
+ return nodeMySimplified;
72
+ };
73
+ const getPrettyNodeDerivative = (node) => {
74
+ if (isPowerNode(node)) {
75
+ const nodeDerivativeUgly = node.derivative();
76
+ const nodeDerivativeLeft = nodeDerivativeUgly.leftChild;
77
+ const nodeDerivativeRight = nodeDerivativeUgly.rightChild;
78
+ const nodeDerivativePretty = multiply(nodeDerivativeLeft.leftChild, multiply(nodeDerivativeLeft.rightChild.simplify({
79
+ towardsDistribute: true,
80
+ forbidFactorize: true,
81
+ }), nodeDerivativeRight));
82
+ return nodeDerivativePretty;
83
+ }
84
+ else {
85
+ return node.derivative();
86
+ }
87
+ };
88
+ const getInstruction = (identifiers) => {
89
+ const { nodeIdsLambda, nodeIdsU, nodeIdsV, nodeIdsRewriteUsing } = identifiers;
90
+ const [nodeLambda, nodeU, nodeV, nodeRewriteUsing] = [
91
+ nodeIdsLambda,
92
+ nodeIdsU,
93
+ nodeIdsV,
94
+ nodeIdsRewriteUsing,
95
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
96
+ const nodeF = multiply(nodeLambda, multiply(nodeU, nodeV)).simplify();
97
+ return `Soit la fonction $f$ définie sur $\\mathbb{R}$ par :
98
+
99
+ $$
100
+ f(x) = ${nodeF.toTex()}
101
+ $$
102
+
103
+ Calculer $f'(x)$, et l'exprimer uniquement en fonction de $${nodeRewriteUsing.toTex()}$.`;
104
+ };
105
+ const getNodeFDerivativeStuff = (identifiers) => {
106
+ const { nodeIdsLambda, nodeIdsU, nodeIdsV } = identifiers;
107
+ const [nodeLambda, nodeU, nodeV] = [nodeIdsLambda, nodeIdsU, nodeIdsV].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
108
+ // const nodeF = multiply(nodeLambda, multiply(nodeU, nodeV)).simplify();
109
+ const [nodeUPrime, nodeVPrime] = [nodeU, nodeV].map(getPrettyNodeDerivative);
110
+ //f' = lambda (u'v+uv')
111
+ return {
112
+ nodeFDerivative0: multiply(nodeLambda, add(multiply(nodeUPrime, nodeV), multiply(nodeU, nodeVPrime))),
113
+ nodeFDerivative1: multiply(nodeLambda, add(mySimplify(multiply(nodeUPrime, nodeV).simplify()), mySimplify(multiply(nodeU, nodeVPrime).simplify()))),
114
+ };
115
+ };
116
+ const getAnswerNode = (identifiers) => {
117
+ const { nodeIdsRewriteUsing } = identifiers;
118
+ const { nodeFDerivative1: nodeDerivative1 } = getNodeFDerivativeStuff(identifiers);
119
+ const createFuncRewrite = (node) => {
120
+ const isPowerNode2 = (node) => isPowerNode(node) &&
121
+ isNumberNode(node.rightChild) &&
122
+ node.rightChild.value === 2;
123
+ if (isSquareNode(node) || isPowerNode2(node)) {
124
+ const nodeIdsLeftChild = node.leftChild.toIdentifiers();
125
+ switch (nodeIdsRewriteUsing.id) {
126
+ case NodeIds.cos:
127
+ if (nodeIdsLeftChild.id === NodeIds.sin) {
128
+ return (node) => {
129
+ const nodeSin = node.leftChild;
130
+ return substract(1, power(cos(nodeSin.child), 2));
131
+ };
132
+ }
133
+ else {
134
+ return undefined;
135
+ }
136
+ case NodeIds.sin:
137
+ if (nodeIdsLeftChild.id === NodeIds.cos) {
138
+ return (node) => {
139
+ const nodeCos = node.leftChild;
140
+ return substract(1, power(sin(nodeCos.child), 2));
141
+ };
142
+ }
143
+ else {
144
+ return undefined;
145
+ }
146
+ }
147
+ }
148
+ else {
149
+ return undefined;
150
+ }
151
+ };
152
+ const nodeDerivative2 = myRewrite(nodeDerivative1, createFuncRewrite);
153
+ return nodeDerivative2;
154
+ };
155
+ const getAnswer = (identifiers) => {
156
+ return mySimplify(getAnswerNode(identifiers)).toTex();
157
+ };
158
+ const getHint = (_identifiers) => {
159
+ return `Si $u$ et $v$ sont deux fonctions dérivables alors,
160
+ pour $x$ dans l'ensemble de dérivation de $u \\circ v = x \\mapsto u(v(x))$, on a :
161
+
162
+ $$
163
+ (u \\circ v)'(x) = v'(x)u'(v(x))
164
+ $$
165
+
166
+ Une fois que tu as obtenu la dérivée, réécris-la en utilisant la formule,
167
+ pour tout $x$ réel :
168
+
169
+ $$
170
+ \\sin^{2}{(x)} + \\cos^{2}{(x)} = 1
171
+ $$
172
+
173
+ `;
174
+ };
175
+ const getCorrection = (identifiers) => {
176
+ const { nodeIdsLambda, nodeIdsU, nodeIdsV } = identifiers;
177
+ const [nodeLambda, nodeU, nodeV] = [nodeIdsLambda, nodeIdsU, nodeIdsV].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
178
+ const [nodeUPrime, nodeVPrime] = [nodeU, nodeV].map(getPrettyNodeDerivative);
179
+ const { nodeFDerivative0, nodeFDerivative1 } = getNodeFDerivativeStuff(identifiers);
180
+ const nodeAnswer = getAnswerNode(identifiers);
181
+ return `On doit calculer la dérivée d'un produit.
182
+
183
+ ${(() => {
184
+ if (nodeLambda.evaluate() === 1) {
185
+ return `Ici, $f(x) = u(x) v(x)$ avec :`;
186
+ }
187
+ else {
188
+ return `Ici, $f(x) = \\lambda u(x) v(x)$ avec :
189
+
190
+ $$
191
+ \\lambda = ${nodeLambda.toTex({})}
192
+ $$
193
+
194
+ `;
195
+ }
196
+ })()}
197
+
198
+
199
+ $$
200
+ u(x) = ${nodeU.toTex({})}
201
+ $$
202
+
203
+ $$
204
+ v(x) = ${nodeV.toTex()}
205
+ $$
206
+
207
+ On calcule (dérivées de fonctions composées):
208
+
209
+ $$
210
+ u'(x) = ${nodeUPrime.toTex()}
211
+ $$
212
+
213
+ $$
214
+ v'(x) = ${nodeVPrime.toTex()}
215
+ $$
216
+
217
+ Donc :
218
+
219
+ ${alignTex([
220
+ [
221
+ `f'(x)`,
222
+ `=`,
223
+ nodeLambda.evaluate() === 1
224
+ ? `u'(x)v(x)+u(x)v'(x)`
225
+ : `\\lambda(u'(x)v(x)+u(x)v'(x))`,
226
+ ],
227
+ [``, `=`, NodePrinter.toTexWithMaxWidth(nodeFDerivative0, 70)],
228
+ [``, `=`, nodeFDerivative1.toTex()],
229
+ ])}
230
+
231
+ Pour tout $x$ réel, on a :
232
+
233
+ $$
234
+ \\sin^{2}{(x)} + \\cos^{2}{(x)} = 1
235
+ $$
236
+
237
+ On peut donc réécrire :
238
+
239
+ ${alignTex([
240
+ [`f'(x)`, `=`, nodeAnswer.toTex()],
241
+ [``, `=`, mySimplify(nodeAnswer).toTex()],
242
+ ])}
243
+
244
+ `;
245
+ };
246
+ const getPropositions = (n, { answer: _answer, ...identifiers }) => {
247
+ const { nodeIdsU, nodeIdsV, nodeIdsRewriteUsing } = identifiers;
248
+ const [nodeU, nodeV] = [nodeIdsU, nodeIdsV].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
249
+ const [_nodeUPrime, _nodeVPrime] = [nodeU, nodeV].map((node) => node.derivative().simplify());
250
+ const maxWidthForTex = 70;
251
+ const propositions = [];
252
+ const nodeAnswer = mySimplify(getAnswerNode(identifiers));
253
+ addValidProp(propositions, NodePrinter.toTexWithMaxWidth(nodeAnswer, maxWidthForTex));
254
+ //student: cos^2(x) - sin^2(x) = 1
255
+ {
256
+ const { nodeFDerivative1: nodeDerivative1 } = getNodeFDerivativeStuff(identifiers);
257
+ const createFuncRewrite = (node) => {
258
+ const isPowerNode2 = (node) => isPowerNode(node) &&
259
+ isNumberNode(node.rightChild) &&
260
+ node.rightChild.value === 2;
261
+ if (isSquareNode(node) || isPowerNode2(node)) {
262
+ const nodeIdsLeftChild = node.leftChild.toIdentifiers();
263
+ switch (nodeIdsRewriteUsing.id) {
264
+ case NodeIds.cos:
265
+ if (nodeIdsLeftChild.id === NodeIds.sin) {
266
+ return (node) => {
267
+ const nodeSin = node.leftChild;
268
+ return substract(power(cos(nodeSin.child), 2), 1);
269
+ };
270
+ }
271
+ else {
272
+ return undefined;
273
+ }
274
+ case NodeIds.sin:
275
+ if (nodeIdsLeftChild.id === NodeIds.cos) {
276
+ return (node) => {
277
+ const nodeCos = node.leftChild;
278
+ return add(1, power(sin(nodeCos.child), 2));
279
+ };
280
+ }
281
+ else {
282
+ return undefined;
283
+ }
284
+ }
285
+ }
286
+ else {
287
+ return undefined;
288
+ }
289
+ };
290
+ const nodeDerivative2 = myRewrite(nodeDerivative1, createFuncRewrite);
291
+ try {
292
+ const nodeWrong = mySimplify(nodeDerivative2);
293
+ tryToAddWrongProp(propositions, NodePrinter.toTexWithMaxWidth(nodeWrong, maxWidthForTex));
294
+ }
295
+ catch (e) {
296
+ console.log(e);
297
+ }
298
+ }
299
+ //student: cos^2(x) + sin^2(x) = -1
300
+ {
301
+ const { nodeFDerivative1: nodeDerivative1 } = getNodeFDerivativeStuff(identifiers);
302
+ const createFuncRewrite = (node) => {
303
+ const isPowerNode2 = (node) => isPowerNode(node) &&
304
+ isNumberNode(node.rightChild) &&
305
+ node.rightChild.value === 2;
306
+ if (isSquareNode(node) || isPowerNode2(node)) {
307
+ const nodeIdsLeftChild = node.leftChild.toIdentifiers();
308
+ switch (nodeIdsRewriteUsing.id) {
309
+ case NodeIds.cos:
310
+ if (nodeIdsLeftChild.id === NodeIds.sin) {
311
+ return (node) => {
312
+ const nodeSin = node.leftChild;
313
+ return substract(-1, power(cos(nodeSin.child), 2));
314
+ };
315
+ }
316
+ else {
317
+ return undefined;
318
+ }
319
+ case NodeIds.sin:
320
+ if (nodeIdsLeftChild.id === NodeIds.cos) {
321
+ return (node) => {
322
+ const nodeCos = node.leftChild;
323
+ return substract(-1, power(sin(nodeCos.child), 2));
324
+ };
325
+ }
326
+ else {
327
+ return undefined;
328
+ }
329
+ }
330
+ }
331
+ else {
332
+ return undefined;
333
+ }
334
+ };
335
+ const nodeDerivative2 = myRewrite(nodeDerivative1, createFuncRewrite);
336
+ try {
337
+ const nodeWrong = mySimplify(nodeDerivative2);
338
+ tryToAddWrongProp(propositions, NodePrinter.toTexWithMaxWidth(nodeWrong, maxWidthForTex));
339
+ }
340
+ catch (e) {
341
+ console.log(e);
342
+ }
343
+ }
344
+ //student: cos(x) = sin(x)
345
+ {
346
+ const { nodeFDerivative1: nodeDerivative1 } = getNodeFDerivativeStuff(identifiers);
347
+ const createFuncRewrite = (node) => {
348
+ const isPowerNode2 = (node) => isPowerNode(node) &&
349
+ isNumberNode(node.rightChild) &&
350
+ node.rightChild.value === 2;
351
+ if (isSquareNode(node) || isPowerNode2(node)) {
352
+ const nodeIdsLeftChild = node.leftChild.toIdentifiers();
353
+ switch (nodeIdsRewriteUsing.id) {
354
+ case NodeIds.cos:
355
+ if (nodeIdsLeftChild.id === NodeIds.sin) {
356
+ return (node) => {
357
+ const nodeSin = node.leftChild;
358
+ return power(cos(nodeSin.child), 2);
359
+ };
360
+ }
361
+ else {
362
+ return undefined;
363
+ }
364
+ case NodeIds.sin:
365
+ if (nodeIdsLeftChild.id === NodeIds.cos) {
366
+ return (node) => {
367
+ const nodeCos = node.leftChild;
368
+ return power(sin(nodeCos.child), 2);
369
+ };
370
+ }
371
+ else {
372
+ return undefined;
373
+ }
374
+ }
375
+ }
376
+ else {
377
+ return undefined;
378
+ }
379
+ };
380
+ const nodeDerivative2 = myRewrite(nodeDerivative1, createFuncRewrite);
381
+ try {
382
+ const nodeWrong = mySimplify(nodeDerivative2);
383
+ tryToAddWrongProp(propositions, NodePrinter.toTexWithMaxWidth(nodeWrong, maxWidthForTex));
384
+ }
385
+ catch (e) {
386
+ console.log(e);
387
+ }
388
+ }
389
+ return shuffleProps(propositions, n);
390
+ };
391
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
392
+ try {
393
+ const nodeAns = parseAlgebraic(ans);
394
+ const nodeAnswer = getAnswerNode(identifiers);
395
+ return NodeComparator.isEqualViaRandomEvaluations(nodeAns, nodeAnswer, 3);
396
+ }
397
+ catch (e) {
398
+ handleVEAError(e);
399
+ return false;
400
+ }
401
+ };
402
+ const getSinCosDerivativeRewriteUsingCos2PlusSin2Equals1Question = () => {
403
+ const nodeVarX = new VariableNode("x");
404
+ const createRandomFactorNode = () => ((coinFlip() ? +1 : -1) * randint(1, 7)).toTree();
405
+ const [func1, func2] = shuffle([sin, cos]);
406
+ const nodeLambda = createRandomFactorNode();
407
+ const node1 = square(func1(nodeVarX));
408
+ const node2 = func2(nodeVarX);
409
+ const [nodeU, nodeV] = shuffle([node1, node2]);
410
+ const identifiers = {
411
+ nodeIdsLambda: nodeLambda.toIdentifiers(),
412
+ nodeIdsU: nodeU.toIdentifiers(),
413
+ nodeIdsV: nodeV.toIdentifiers(),
414
+ nodeIdsRewriteUsing: func1(nodeVarX).toIdentifiers(),
415
+ };
416
+ return getQuestionFromIdentifiers(identifiers);
417
+ };
418
+ const getQuestionFromIdentifiers = (identifiers) => {
419
+ const question = {
420
+ answer: getAnswer(identifiers),
421
+ instruction: getInstruction(identifiers),
422
+ keys: ["x", "sin", "cos", "tan"],
423
+ answerFormat: "tex",
424
+ identifiers,
425
+ hint: getHint(identifiers),
426
+ correction: getCorrection(identifiers),
427
+ };
428
+ return question;
429
+ };
430
+ export const sinCosDerivativeRewriteUsingCos2PlusSin2Equals1 = {
431
+ id: "sinCosDerivativeRewriteUsingCos2PlusSin2Equals1",
432
+ connector: "=",
433
+ label: "Dérivée de $\\sin{(x)}\\cos^{2}{(x)}$ ou $\\sin^{2}{(x)}\\cos{(x)}$ à exprimer en fonction de $\\cos{(x)}$ ou $\\sin{(x)}$ uniquement",
434
+ isSingleStep: true,
435
+ generator: (nb) => getDistinctQuestions(getSinCosDerivativeRewriteUsingCos2PlusSin2Equals1Question, nb),
436
+ qcmTimer: 60,
437
+ freeTimer: 60,
438
+ getPropositions,
439
+ isAnswerValid,
440
+ subject: "Mathématiques",
441
+ getInstruction,
442
+ getAnswer,
443
+ getQuestionFromIdentifiers,
444
+ hasHintAndCorrection: true,
445
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"affineVarTableOnBoundedInterval.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineVarTableOnBoundedInterval.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AA8KF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAqBjE,CAAC"}
1
+ {"version":3,"file":"affineVarTableOnBoundedInterval.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineVarTableOnBoundedInterval.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AA6KF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAqBjE,CAAC"}
@@ -10,14 +10,13 @@ const getInstruction = (identifiers) => {
10
10
  const [nodeX1, nodeX2] = nodeIdsBounds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
11
11
  const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
12
12
  const strInterval = `[${nodeX1.toTex()};${nodeX2.toTex()}]`;
13
- return `Dresser le tableau de variations de la fonction $f$ sur l'intervalle $${strInterval}$.
14
-
15
- On donne, pour tout $x$ dans $${strInterval}$ :
13
+ return `Soit $f$ la fonction définie sur $${strInterval}$ par :
16
14
 
17
15
  $$
18
16
  f(x) = ${nodeF.toTex()}
19
17
  $$
20
18
 
19
+ Dresser le tableau de variations de la fonction $f$ sur l'intervalle $${strInterval}$.
21
20
  `;
22
21
  };
23
22
  const getAnswerTable = (identifiers) => {
@@ -25,4 +25,5 @@ export * from "./dataRepresentations/index.js";
25
25
  export * from "./tests/index.js";
26
26
  export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
+ export * from "./_debug/index.js";
28
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
@@ -25,4 +25,4 @@ export * from "./dataRepresentations/index.js";
25
25
  export * from "./tests/index.js";
26
26
  export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
- // export * from "./_debug/index.js";
28
+ export * from "./_debug/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceGeometricLimit.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/sequenceGeometricLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAE7C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,eAAe,CAAC;CAC5B,CAAC;AAmEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAexD,CAAC"}
1
+ {"version":3,"file":"sequenceGeometricLimit.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/sequenceGeometricLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAE7C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,eAAe,CAAC;CAC5B,CAAC;AA4EF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAgBxD,CAAC"}
@@ -17,6 +17,12 @@ const getAnswer = (identifiers) => {
17
17
  const answer = sequence.getLimit();
18
18
  return answer.toTex();
19
19
  };
20
+ // const getHint: GetHint<Identifiers> = (identifiers)=>{
21
+ // return ``
22
+ // }
23
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers)=>{
24
+ // return ``
25
+ // }
20
26
  const getSequenceGeometricLimitQuestion = () => {
21
27
  const sequence = GeometricSequenceConstructor.randomWithLimit();
22
28
  const identifiers = {
@@ -32,6 +38,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
32
38
  keys: ["infty"],
33
39
  answerFormat: "tex",
34
40
  identifiers,
41
+ // hint: getHint(identifiers),
42
+ // correction: getCorrection(identifiers),
35
43
  };
36
44
  return question;
37
45
  };
@@ -62,4 +70,5 @@ export const sequenceGeometricLimit = {
62
70
  getAnswer,
63
71
  getInstruction,
64
72
  getQuestionFromIdentifiers,
73
+ // hasHintAndCorrection: true,
65
74
  };
@@ -2,10 +2,13 @@ import { Exercise, GetQuestionFromIdentifiers, QCMGenerator, QuestionGenerator,
2
2
  type Identifiers = {
3
3
  c: number;
4
4
  };
5
- export declare const getConstantPrimitive: QuestionGenerator<Identifiers>;
6
- export declare const getConstantPrimitiveQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers>;
7
- export declare const getConstantPrimitivePropositions: QCMGenerator<Identifiers>;
8
- export declare const isConstantPrimitiveAnswerValid: VEA<Identifiers>;
9
- export declare const constantPrimitive: Exercise<Identifiers>;
5
+ type Options = {
6
+ askParticularPrimitive?: boolean;
7
+ };
8
+ export declare const getConstantPrimitive: QuestionGenerator<Identifiers, Options>;
9
+ export declare const getConstantPrimitiveQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers, Options>;
10
+ export declare const getConstantPrimitivePropositions: QCMGenerator<Identifiers, Options>;
11
+ export declare const isConstantPrimitiveAnswerValid: VEA<Identifiers, Options>;
12
+ export declare const constantPrimitive: Exercise<Identifiers, Options>;
10
13
  export {};
11
14
  //# sourceMappingURL=constantPrimitive.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constantPrimitive.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/primitive/constantPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,0BAA0B,EAE1B,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAIJ,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoBF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAI/D,CAAC;AAEF,eAAO,MAAM,2CAA2C,EAAE,0BAA0B,CAClF,WAAW,CAYZ,CAAC;AACF,eAAO,MAAM,gCAAgC,EAAE,YAAY,CAAC,WAAW,CActE,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,GAAG,CAAC,WAAW,CAO3D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAYnD,CAAC"}
1
+ {"version":3,"file":"constantPrimitive.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/primitive/constantPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,0BAA0B,EAE1B,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAOJ,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAgCF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAMxE,CAAC;AAEF,eAAO,MAAM,2CAA2C,EAAE,0BAA0B,CAClF,WAAW,EACX,OAAO,CAaR,CAAC;AACF,eAAO,MAAM,gCAAgC,EAAE,YAAY,CAAC,WAAW,EAAE,OAAO,CAmB/E,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAQpE,CAAC;AAYF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAc5D,CAAC"}
@@ -1,66 +1,85 @@
1
- import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
1
+ import { addValidProp, propWhile, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Monom } from "../../../math/polynomials/monom.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { AddNode } from "../../../tree/nodes/operators/addNode.js";
6
6
  import { VariableNode } from "../../../tree/nodes/variables/variableNode.js";
7
7
  import { shuffle } from "../../../utils/alea/shuffle.js";
8
- const getInstruction = (identifiers) => {
8
+ const getAnswerNode = (identifiers, opts) => {
9
9
  const { c } = identifiers;
10
- return `Déterminer la forme générale des primitives de la fonction constante $f$ définie par :
10
+ const monom = new Monom(1, c);
11
+ if (opts?.askParticularPrimitive)
12
+ return monom.toTree();
13
+ return new AddNode(monom.toTree(), new VariableNode("C"));
14
+ };
15
+ const getInstruction = (identifiers, opts) => {
16
+ const { c } = identifiers;
17
+ const isAskingParticularPrimitive = opts?.askParticularPrimitive;
18
+ return `${isAskingParticularPrimitive
19
+ ? "Déterminer une primitive en particulier de la fonction constante $f$ définie par"
20
+ : "Déterminer la forme générale des primitives de la fonction constante $f$ définie par"} :
11
21
 
12
22
  $$
13
23
  f(x) = ${c}
14
24
  $$`;
15
25
  };
16
- const getAnswer = (identifiers) => {
17
- const { c } = identifiers;
18
- const monom = new Monom(1, c);
19
- const answer = new AddNode(monom.toTree(), new VariableNode("C")).toTex();
20
- return answer;
26
+ const getAnswer = (identifiers, opts) => {
27
+ return getAnswerNode(identifiers, opts).toTex();
21
28
  };
22
- export const getConstantPrimitive = () => {
29
+ export const getConstantPrimitive = (opts) => {
23
30
  const c = randint(-19, 20, [0]);
24
31
  const identifiers = { c };
25
- return getConstantPrimitiveQuestionFromIdentifiers(identifiers);
32
+ return getConstantPrimitiveQuestionFromIdentifiers(identifiers, opts);
26
33
  };
27
- export const getConstantPrimitiveQuestionFromIdentifiers = (identifiers) => {
34
+ export const getConstantPrimitiveQuestionFromIdentifiers = (identifiers, opts) => {
28
35
  const question = {
29
- instruction: getInstruction(identifiers),
36
+ instruction: getInstruction(identifiers, opts),
30
37
  startStatement: `F(x)`,
31
- answer: getAnswer(identifiers),
32
- keys: ["x", "C"],
38
+ answer: getAnswer(identifiers, opts),
39
+ keys: opts?.askParticularPrimitive ? ["x"] : ["x", "C"],
33
40
  answerFormat: "tex",
34
41
  identifiers,
42
+ options: opts,
35
43
  };
36
44
  return question;
37
45
  };
38
- export const getConstantPrimitivePropositions = (n, { answer }) => {
46
+ export const getConstantPrimitivePropositions = (n, { answer, c }, opts) => {
39
47
  const propositions = [];
40
48
  addValidProp(propositions, answer);
41
- const cNode = new VariableNode("C");
42
49
  propWhile(propositions, n, () => {
43
- const monom = new Monom(1, randint(-9, 10, [-1, 0, 1]));
44
- const wrongAnswer = new AddNode(monom.toTree(), cNode);
50
+ const monom = new Monom(1, randint(-9, 10, opts?.askParticularPrimitive ? [-1, 0, 1, c] : [-1, 0, 1]));
51
+ const wrongAnswer = opts?.askParticularPrimitive
52
+ ? monom.toTree()
53
+ : new AddNode(monom.toTree(), new VariableNode("C"));
45
54
  tryToAddWrongProp(propositions, wrongAnswer.toTex());
46
55
  });
47
56
  return shuffle(propositions);
48
57
  };
49
- export const isConstantPrimitiveAnswerValid = (ans, { c }) => {
50
- const answer = new AddNode(new Monom(1, c).toTree(), new VariableNode("C"));
58
+ export const isConstantPrimitiveAnswerValid = (ans, { c }, opts) => {
59
+ const answer = getAnswerNode({ c }, opts);
51
60
  const texs = answer.toAllValidTexs();
52
61
  return texs.includes(ans);
53
62
  };
63
+ const options = [
64
+ {
65
+ id: "askParticularPrimitive",
66
+ label: "Demander une primitive en particulier",
67
+ target: GeneratorOptionTarget.answer,
68
+ type: GeneratorOptionType.checkbox,
69
+ defaultValue: false,
70
+ },
71
+ ];
54
72
  export const constantPrimitive = {
55
73
  id: "constantPrimitive",
56
74
  connector: "=",
57
75
  label: "Primitive d'une constante",
58
76
  isSingleStep: false,
59
- generator: (nb) => getDistinctQuestions(getConstantPrimitive, nb),
77
+ generator: (nb, opts) => getDistinctQuestions(() => getConstantPrimitive(opts), nb),
60
78
  qcmTimer: 60,
61
79
  freeTimer: 60,
62
80
  getPropositions: getConstantPrimitivePropositions,
63
81
  isAnswerValid: isConstantPrimitiveAnswerValid,
64
82
  subject: "Mathématiques",
65
83
  getQuestionFromIdentifiers: getConstantPrimitiveQuestionFromIdentifiers,
84
+ options,
66
85
  };
@@ -1 +1 @@
1
- {"version":3,"file":"averagePoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats2var/averagePoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAyEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
1
+ {"version":3,"file":"averagePoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats2var/averagePoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAkHF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAc9C,CAAC"}