math-exercises 2.1.8 → 2.1.10

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 (205) hide show
  1. package/lib/exercises/exercise.d.ts +1 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/commonDivisorsList.js +1 -1
  4. package/lib/exercises/math/calcul/arithmetics/divisorsList.js +1 -1
  5. package/lib/exercises/math/calcul/arithmetics/euclideanDivision.js +1 -1
  6. package/lib/exercises/math/calcul/arithmetics/pgcdCalcul.js +1 -1
  7. package/lib/exercises/math/calcul/rounding/rounding.js +1 -1
  8. package/lib/exercises/math/calculLitteral/equation/binomialsTrinomialsProposedSolutions.d.ts +5 -0
  9. package/lib/exercises/math/calculLitteral/equation/binomialsTrinomialsProposedSolutions.d.ts.map +1 -0
  10. package/lib/exercises/math/calculLitteral/equation/binomialsTrinomialsProposedSolutions.js +78 -0
  11. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.d.ts +14 -0
  12. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.d.ts.map +1 -0
  13. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.js +160 -0
  14. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.d.ts +9 -0
  15. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.d.ts.map +1 -0
  16. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +65 -0
  17. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts +10 -0
  18. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts.map +1 -0
  19. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.js +72 -0
  20. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts +11 -0
  21. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts.map +1 -0
  22. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.js +78 -0
  23. package/lib/exercises/math/calculLitteral/equation/index.d.ts +5 -1
  24. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  25. package/lib/exercises/math/calculLitteral/equation/index.js +5 -1
  26. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.d.ts +8 -0
  27. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.d.ts.map +1 -0
  28. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.js +96 -0
  29. package/lib/exercises/math/derivation/derivative/convexityTrinomials.d.ts +7 -0
  30. package/lib/exercises/math/derivation/derivative/convexityTrinomials.d.ts.map +1 -0
  31. package/lib/exercises/math/derivation/derivative/convexityTrinomials.js +44 -0
  32. package/lib/exercises/math/derivation/derivative/cosSecondDegreeDerivative.d.ts +7 -0
  33. package/lib/exercises/math/derivation/derivative/cosSecondDegreeDerivative.d.ts.map +1 -0
  34. package/lib/exercises/math/derivation/derivative/cosSecondDegreeDerivative.js +79 -0
  35. package/lib/exercises/math/derivation/derivative/index.d.ts +8 -0
  36. package/lib/exercises/math/derivation/derivative/index.d.ts.map +1 -1
  37. package/lib/exercises/math/derivation/derivative/index.js +8 -0
  38. package/lib/exercises/math/derivation/derivative/inflexionPointQuadrinomials.d.ts +7 -0
  39. package/lib/exercises/math/derivation/derivative/inflexionPointQuadrinomials.d.ts.map +1 -0
  40. package/lib/exercises/math/derivation/derivative/inflexionPointQuadrinomials.js +83 -0
  41. package/lib/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.d.ts +7 -0
  42. package/lib/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.d.ts.map +1 -0
  43. package/lib/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.js +59 -0
  44. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.d.ts +10 -0
  45. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.d.ts.map +1 -0
  46. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.js +60 -0
  47. package/lib/exercises/math/derivation/derivative/secondDerivativeOfTrinom.d.ts +9 -0
  48. package/lib/exercises/math/derivation/derivative/secondDerivativeOfTrinom.d.ts.map +1 -0
  49. package/lib/exercises/math/derivation/derivative/secondDerivativeOfTrinom.js +56 -0
  50. package/lib/exercises/math/derivation/derivative/sinSecondDegreeDerivative.d.ts +7 -0
  51. package/lib/exercises/math/derivation/derivative/sinSecondDegreeDerivative.d.ts.map +1 -0
  52. package/lib/exercises/math/derivation/derivative/sinSecondDegreeDerivative.js +79 -0
  53. package/lib/exercises/math/derivation/index.d.ts +1 -0
  54. package/lib/exercises/math/derivation/index.d.ts.map +1 -1
  55. package/lib/exercises/math/derivation/index.js +1 -0
  56. package/lib/exercises/math/derivation/tangent/index.d.ts +2 -0
  57. package/lib/exercises/math/derivation/tangent/index.d.ts.map +1 -0
  58. package/lib/exercises/math/derivation/tangent/index.js +17 -0
  59. package/lib/exercises/math/derivation/tangent/tangentEquations.d.ts +8 -0
  60. package/lib/exercises/math/derivation/tangent/tangentEquations.d.ts.map +1 -0
  61. package/lib/exercises/math/derivation/tangent/tangentEquations.js +70 -0
  62. package/lib/exercises/math/equaDiff/equaDiffAyPlusB.d.ts +8 -0
  63. package/lib/exercises/math/equaDiff/equaDiffAyPlusB.d.ts.map +1 -0
  64. package/lib/exercises/math/equaDiff/equaDiffAyPlusB.js +85 -0
  65. package/lib/exercises/math/equaDiff/index.d.ts +1 -0
  66. package/lib/exercises/math/equaDiff/index.d.ts.map +1 -1
  67. package/lib/exercises/math/equaDiff/index.js +1 -0
  68. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts +10 -0
  69. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -0
  70. package/lib/exercises/math/functions/affines/affineAdjustment.js +106 -0
  71. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts +11 -0
  72. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -0
  73. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +125 -0
  74. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts +7 -0
  75. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -0
  76. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +100 -0
  77. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.d.ts +8 -0
  78. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.d.ts.map +1 -0
  79. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.js +55 -0
  80. package/lib/exercises/math/functions/affines/index.d.ts +5 -0
  81. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  82. package/lib/exercises/math/functions/affines/index.js +5 -0
  83. package/lib/exercises/math/functions/affines/leadingCoeffAndOriginOrdinate.d.ts +9 -0
  84. package/lib/exercises/math/functions/affines/leadingCoeffAndOriginOrdinate.d.ts.map +1 -0
  85. package/lib/exercises/math/functions/affines/leadingCoeffAndOriginOrdinate.js +61 -0
  86. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts +10 -0
  87. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts.map +1 -0
  88. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.js +172 -0
  89. package/lib/exercises/math/geometry/cartesian/directionVector.d.ts +8 -0
  90. package/lib/exercises/math/geometry/cartesian/directionVector.d.ts.map +1 -0
  91. package/lib/exercises/math/geometry/cartesian/directionVector.js +106 -0
  92. package/lib/exercises/math/geometry/cartesian/directionVectorEquation.d.ts +8 -0
  93. package/lib/exercises/math/geometry/cartesian/directionVectorEquation.d.ts.map +1 -0
  94. package/lib/exercises/math/geometry/cartesian/directionVectorEquation.js +100 -0
  95. package/lib/exercises/math/geometry/cartesian/index.d.ts +4 -0
  96. package/lib/exercises/math/geometry/cartesian/index.d.ts.map +1 -1
  97. package/lib/exercises/math/geometry/cartesian/index.js +4 -0
  98. package/lib/exercises/math/geometry/cartesian/pointCoordinates.d.ts +8 -0
  99. package/lib/exercises/math/geometry/cartesian/pointCoordinates.d.ts.map +1 -0
  100. package/lib/exercises/math/geometry/cartesian/pointCoordinates.js +76 -0
  101. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.d.ts +8 -0
  102. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.d.ts.map +1 -0
  103. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.js +135 -0
  104. package/lib/exercises/math/geometry/convexity/convexityTrinomialsGeo.d.ts +7 -0
  105. package/lib/exercises/math/geometry/convexity/convexityTrinomialsGeo.d.ts.map +1 -0
  106. package/lib/exercises/math/geometry/convexity/convexityTrinomialsGeo.js +61 -0
  107. package/lib/exercises/math/geometry/convexity/index.d.ts +3 -0
  108. package/lib/exercises/math/geometry/convexity/index.d.ts.map +1 -0
  109. package/lib/exercises/math/geometry/convexity/index.js +18 -0
  110. package/lib/exercises/math/geometry/index.d.ts +1 -0
  111. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  112. package/lib/exercises/math/geometry/index.js +1 -0
  113. package/lib/exercises/math/geometry/vectors/index.d.ts +3 -0
  114. package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
  115. package/lib/exercises/math/geometry/vectors/index.js +3 -0
  116. package/lib/exercises/math/geometry/vectors/lineFromDirectorVector.d.ts +10 -0
  117. package/lib/exercises/math/geometry/vectors/lineFromDirectorVector.d.ts.map +1 -0
  118. package/lib/exercises/math/geometry/vectors/lineFromDirectorVector.js +112 -0
  119. package/lib/exercises/math/geometry/vectors/vectorLinearCombination.d.ts +14 -0
  120. package/lib/exercises/math/geometry/vectors/vectorLinearCombination.d.ts.map +1 -0
  121. package/lib/exercises/math/geometry/vectors/vectorLinearCombination.js +99 -0
  122. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.d.ts +8 -0
  123. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.d.ts.map +1 -0
  124. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.js +61 -0
  125. package/lib/exercises/math/index.d.ts +1 -0
  126. package/lib/exercises/math/index.d.ts.map +1 -1
  127. package/lib/exercises/math/index.js +1 -0
  128. package/lib/exercises/math/percent/findProportion.js +1 -1
  129. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +3 -3
  130. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts +7 -0
  131. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts.map +1 -0
  132. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.js +97 -0
  133. package/lib/exercises/math/probaStat/stats2var/index.d.ts +1 -0
  134. package/lib/exercises/math/probaStat/stats2var/index.d.ts.map +1 -1
  135. package/lib/exercises/math/probaStat/stats2var/index.js +1 -0
  136. package/lib/exercises/math/python/conditionIf.d.ts +9 -0
  137. package/lib/exercises/math/python/conditionIf.d.ts.map +1 -0
  138. package/lib/exercises/math/python/conditionIf.js +66 -0
  139. package/lib/exercises/math/python/forLoop.d.ts +10 -0
  140. package/lib/exercises/math/python/forLoop.d.ts.map +1 -0
  141. package/lib/exercises/math/python/forLoop.js +90 -0
  142. package/lib/exercises/math/python/inOutCalcul.d.ts +10 -0
  143. package/lib/exercises/math/python/inOutCalcul.d.ts.map +1 -0
  144. package/lib/exercises/math/python/inOutCalcul.js +71 -0
  145. package/lib/exercises/math/python/index.d.ts +8 -0
  146. package/lib/exercises/math/python/index.d.ts.map +1 -1
  147. package/lib/exercises/math/python/index.js +23 -0
  148. package/lib/exercises/math/python/pyForLoop1Exercise.d.ts +13 -0
  149. package/lib/exercises/math/python/pyForLoop1Exercise.d.ts.map +1 -0
  150. package/lib/exercises/math/python/pyForLoop1Exercise.js +144 -0
  151. package/lib/exercises/math/python/pyNestedForLoopExercise.d.ts +12 -0
  152. package/lib/exercises/math/python/pyNestedForLoopExercise.d.ts.map +1 -0
  153. package/lib/exercises/math/python/pyNestedForLoopExercise.js +84 -0
  154. package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts +12 -0
  155. package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts.map +1 -0
  156. package/lib/exercises/math/python/pyWhileLoop1Exercise.js +114 -0
  157. package/lib/exercises/math/python/pythonFunctionTrinom.d.ts +9 -0
  158. package/lib/exercises/math/python/pythonFunctionTrinom.d.ts.map +1 -0
  159. package/lib/exercises/math/python/pythonFunctionTrinom.js +63 -0
  160. package/lib/exercises/math/python/whileLoop.d.ts +12 -0
  161. package/lib/exercises/math/python/whileLoop.d.ts.map +1 -0
  162. package/lib/exercises/math/python/whileLoop.js +78 -0
  163. package/lib/exercises/pc/electricity/electricChargeFromIntensity.js +1 -1
  164. package/lib/exercises/pc/mole/molFromMass.js +1 -1
  165. package/lib/exercises/pc/mole/molFromMolarMass.js +1 -1
  166. package/lib/exercises/pc/potentialEnergy.d.ts.map +1 -1
  167. package/lib/exercises/pc/potentialEnergy.js +4 -5
  168. package/lib/exercises/pc/waves/periodicWaveCelerity.js +1 -1
  169. package/lib/index.d.ts +152 -0
  170. package/lib/index.d.ts.map +1 -1
  171. package/lib/math/geometry/CloudPoints.d.ts +14 -0
  172. package/lib/math/geometry/CloudPoints.d.ts.map +1 -0
  173. package/lib/math/geometry/CloudPoints.js +94 -0
  174. package/lib/math/geometry/line.d.ts +4 -0
  175. package/lib/math/geometry/line.d.ts.map +1 -1
  176. package/lib/math/geometry/line.js +25 -0
  177. package/lib/math/geometry/vector.d.ts +5 -0
  178. package/lib/math/geometry/vector.d.ts.map +1 -1
  179. package/lib/math/geometry/vector.js +31 -0
  180. package/lib/math/polynomials/polynomial.d.ts +1 -0
  181. package/lib/math/polynomials/polynomial.d.ts.map +1 -1
  182. package/lib/math/polynomials/polynomial.js +10 -2
  183. package/lib/math/polynomials/trinom.d.ts +1 -0
  184. package/lib/math/polynomials/trinom.d.ts.map +1 -1
  185. package/lib/math/polynomials/trinom.js +28 -0
  186. package/lib/math/utils/arithmetic/factorial.d.ts +2 -0
  187. package/lib/math/utils/arithmetic/factorial.d.ts.map +1 -0
  188. package/lib/math/utils/arithmetic/factorial.js +10 -0
  189. package/lib/math/utils/covariance.d.ts +4 -0
  190. package/lib/math/utils/covariance.d.ts.map +1 -0
  191. package/lib/math/utils/covariance.js +26 -0
  192. package/lib/math/utils/functions/expUDerivate.d.ts +5 -0
  193. package/lib/math/utils/functions/expUDerivate.d.ts.map +1 -0
  194. package/lib/math/utils/functions/expUDerivate.js +9 -0
  195. package/lib/math/utils/functions/expUSecondDerivate.d.ts +5 -0
  196. package/lib/math/utils/functions/expUSecondDerivate.d.ts.map +1 -0
  197. package/lib/math/utils/functions/expUSecondDerivate.js +12 -0
  198. package/lib/math/utils/variance.d.ts +4 -0
  199. package/lib/math/utils/variance.d.ts.map +1 -0
  200. package/lib/math/utils/variance.js +27 -0
  201. package/lib/server.d.ts.map +1 -1
  202. package/lib/tree/nodes/sets/intervalNode.d.ts +1 -1
  203. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  204. package/lib/tree/nodes/sets/intervalNode.js +2 -2
  205. package/package.json +3 -3
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.affineAdjustmentRsquaredExercise = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const randint_1 = require("../../../../math/utils/random/randint");
7
+ const round_1 = require("../../../../math/utils/round");
8
+ const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
9
+ const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
10
+ const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
11
+ const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
12
+ function generateLinearData(n) {
13
+ const slope = (0, randint_1.randint)(-500, 500, [0]) / 100;
14
+ const intercept = (0, randint_1.randint)(100, 5000) / 100;
15
+ let data = [];
16
+ let generatedXs = new Set();
17
+ while (data.length < n) {
18
+ let x = (0, randint_1.randint)(1, 100);
19
+ while (generatedXs.has(x)) {
20
+ x = (0, randint_1.randint)(1, 100);
21
+ }
22
+ generatedXs.add(x);
23
+ let noise = Math.random() * 100;
24
+ let y = (0, round_1.round)(slope * x + intercept + noise, 2);
25
+ data.push({ x, y });
26
+ }
27
+ return data;
28
+ }
29
+ function calculateRSquared(xValues, yValues) {
30
+ const n = xValues.length;
31
+ const sumX = xValues.reduce((acc, x) => acc + x, 0);
32
+ const sumY = yValues.reduce((acc, y) => acc + y, 0);
33
+ const sumXY = xValues.reduce((acc, x, i) => acc + x * yValues[i], 0);
34
+ const sumX2 = xValues.reduce((acc, x) => acc + x * x, 0);
35
+ const sumY2 = yValues.reduce((acc, y) => acc + y * y, 0);
36
+ const numerator = n * sumXY - sumX * sumY;
37
+ const denominator = Math.sqrt((n * sumX2 - sumX * sumX) * (n * sumY2 - sumY * sumY));
38
+ const r = numerator / denominator;
39
+ const rSquared = r * r;
40
+ return rSquared;
41
+ }
42
+ const getAffineAdjustmentRsquaredQuestion = () => {
43
+ const data = generateLinearData(10);
44
+ data.sort((a, b) => a.x - b.x);
45
+ const xValues = data.map((point) => (0, round_1.round)(point.x, 2));
46
+ const yValues = data.map((point) => (0, round_1.round)(point.y, 2));
47
+ const rSquared = calculateRSquared(xValues, yValues);
48
+ const answer = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (0, round_1.round)(rSquared, 2).toTree()).toTex();
49
+ let dataTable = `
50
+ | | | | | | | | | | | |
51
+ |-|-|-|-|-|-|-|-|-|-|-|
52
+ | x | ${xValues.join(" | ")} |
53
+ | y | ${yValues.join(" | ")} |
54
+ `;
55
+ const question = {
56
+ answer: answer,
57
+ instruction: `À partir des données fournies ci-dessous, déterminez la valeur du coefficient de détermination : ${dataTable}
58
+ `,
59
+ keys: ["R", "equal"],
60
+ answerFormat: "tex",
61
+ identifiers: { rSquared },
62
+ };
63
+ return question;
64
+ };
65
+ const getPropositions = (n, { answer, rSquared }) => {
66
+ const propositions = [];
67
+ (0, exercise_1.addValidProp)(propositions, answer, "tex");
68
+ const wrongAnswer1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"), (0, round_1.round)(rSquared, 2).toTree()).toTex();
69
+ const wrongAnswer2 = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (-(0, round_1.round)(rSquared, 2)).toTree()).toTex();
70
+ const wrongAnswer3 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("R"), (-(0, round_1.round)(rSquared, 2)).toTree()).toTex();
71
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer1);
72
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer2);
73
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer3);
74
+ while (propositions.length < n) {
75
+ const wrongAnswer = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (0, round_1.round)(Math.random(), 2).toTree()).toTex();
76
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer);
77
+ }
78
+ return (0, exercise_1.shuffleProps)(propositions, n);
79
+ };
80
+ const isAnswerValid = (ans, { rSquared }) => {
81
+ const valid = new equalNode_1.EqualNode(new powerNode_1.PowerNode(new variableNode_1.VariableNode("R"), new numberNode_1.NumberNode(2)), (0, round_1.round)(rSquared, 2).toTree());
82
+ const latexs = valid.toAllValidTexs({
83
+ allowRawRightChildAsSolution: true,
84
+ allowFractionToDecimal: true,
85
+ });
86
+ return latexs.includes(ans);
87
+ };
88
+ exports.affineAdjustmentRsquaredExercise = {
89
+ id: "affineAdjustmentRsquared",
90
+ label: "Déterminer le coefficient de détermination à partir d'un tableau de données",
91
+ levels: ["1rePro"],
92
+ isSingleStep: true,
93
+ sections: ["Statistiques"],
94
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getAffineAdjustmentRsquaredQuestion, nb),
95
+ qcmTimer: 60,
96
+ freeTimer: 60,
97
+ getPropositions,
98
+ isAnswerValid,
99
+ subject: "Mathématiques",
100
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const algebricExpressionOfAffine: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=algebricExpressionOfAffine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algebricExpressionOfAffine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/algebricExpressionOfAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAOlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgDF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAc5D,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.algebricExpressionOfAffine = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const affine_1 = require("../../../../math/polynomials/affine");
7
+ const getAlgebricExpressionOfAffineQuestion = () => {
8
+ const f = affine_1.AffineConstructor.random();
9
+ const a = f.a;
10
+ const b = f.b;
11
+ const question = {
12
+ answer: f.toTex(),
13
+ instruction: `Soit une fonction affine $f$ dont le coefficient directeur vaut $${a}$ et l'ordonnée à l'origine vaut $${b}$. Écrire l'expression algébrique de $f(x)$.`,
14
+ keys: ["x", "equal"],
15
+ answerFormat: "tex",
16
+ identifiers: { a, b },
17
+ };
18
+ return question;
19
+ };
20
+ const getPropositions = (n, { answer, a, b }) => {
21
+ const propositions = [];
22
+ (0, exercise_1.addValidProp)(propositions, answer);
23
+ generatePropositions(a, b).forEach((value) => (0, exercise_1.tryToAddWrongProp)(propositions, value));
24
+ let random;
25
+ while (propositions.length < n) {
26
+ random = affine_1.AffineConstructor.random();
27
+ (0, exercise_1.tryToAddWrongProp)(propositions, random.toTree().toTex());
28
+ }
29
+ return (0, exercise_1.shuffleProps)(propositions, n);
30
+ };
31
+ const isAnswerValid = (ans, { a, b }) => {
32
+ const f = new affine_1.Affine(a, b, "x");
33
+ return f.toTree().toAllValidTexs().includes(ans);
34
+ };
35
+ const generatePropositions = (a, b) => {
36
+ const firstProposition = new affine_1.Affine(b, a, "x");
37
+ const secondProposition = new affine_1.Affine(a, -b, "x");
38
+ return [
39
+ firstProposition.toTree().toTex(),
40
+ secondProposition.toTree().toTex(),
41
+ ];
42
+ };
43
+ exports.algebricExpressionOfAffine = {
44
+ id: "algebricExpressionOfAffine",
45
+ label: "Écrire l'expression algébrique d'une fonction affine connaissant les valeurs de son coefficient directeur et de son ordonnée à l'origine",
46
+ levels: ["2nde"],
47
+ isSingleStep: true,
48
+ sections: ["Fonctions affines"],
49
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getAlgebricExpressionOfAffineQuestion, nb),
50
+ qcmTimer: 60,
51
+ freeTimer: 60,
52
+ getPropositions,
53
+ isAnswerValid,
54
+ subject: "Mathématiques",
55
+ };
@@ -4,4 +4,9 @@ export * from "./leadingCoefficientCalculV2";
4
4
  export * from "./signFunction";
5
5
  export * from "./affineExpressionReading";
6
6
  export * from "./interceptReading";
7
+ export * from "./algebricExpressionOfAffine";
8
+ export * from "./leadingCoeffAndOriginOrdinate";
9
+ export * from "./affineAdjustment";
10
+ export * from "./affineAdjustmentRsquared";
11
+ export * from "./affineAdjustmentComplete";
7
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC"}
@@ -20,3 +20,8 @@ __exportStar(require("./leadingCoefficientCalculV2"), exports);
20
20
  __exportStar(require("./signFunction"), exports);
21
21
  __exportStar(require("./affineExpressionReading"), exports);
22
22
  __exportStar(require("./interceptReading"), exports);
23
+ __exportStar(require("./algebricExpressionOfAffine"), exports);
24
+ __exportStar(require("./leadingCoeffAndOriginOrdinate"), exports);
25
+ __exportStar(require("./affineAdjustment"), exports);
26
+ __exportStar(require("./affineAdjustmentRsquared"), exports);
27
+ __exportStar(require("./affineAdjustmentComplete"), exports);
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ isAskingA: boolean;
6
+ };
7
+ export declare const leadingCoeffAndOriginOrdinate: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=leadingCoeffAndOriginOrdinate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leadingCoeffAndOriginOrdinate.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/leadingCoeffAndOriginOrdinate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAMlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AA4DF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAc/D,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.leadingCoeffAndOriginOrdinate = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const affine_1 = require("../../../../math/polynomials/affine");
7
+ const randint_1 = require("../../../../math/utils/random/randint");
8
+ const coinFlip_1 = require("../../../../utils/coinFlip");
9
+ const getLeadingCoeffAndOriginOrdinateQuestion = () => {
10
+ const exercise = generateExercise();
11
+ const isAskingA = +exercise.correctAnwer === exercise.f.a ? true : false;
12
+ const question = {
13
+ answer: exercise.correctAnwer,
14
+ instruction: exercise.instruction,
15
+ keys: [],
16
+ answerFormat: "tex",
17
+ identifiers: { a: exercise.f.a, b: exercise.f.b, isAskingA },
18
+ };
19
+ return question;
20
+ };
21
+ const getPropositions = (n, { answer, a, b, isAskingA }) => {
22
+ const propositions = [];
23
+ (0, exercise_1.addValidProp)(propositions, answer);
24
+ (0, exercise_1.tryToAddWrongProp)(propositions, isAskingA ? b + "" : a + "");
25
+ let random;
26
+ let flip;
27
+ while (propositions.length < n) {
28
+ flip = (0, coinFlip_1.coinFlip)();
29
+ random = flip ? (0, randint_1.randint)(a - 5, a + 6, [a]) : (0, randint_1.randint)(b - 5, b + 6, [b]);
30
+ (0, exercise_1.tryToAddWrongProp)(propositions, random + "");
31
+ }
32
+ return (0, exercise_1.shuffleProps)(propositions, n);
33
+ };
34
+ const isAnswerValid = (ans, { answer }) => {
35
+ return ans === answer;
36
+ };
37
+ const generateExercise = () => {
38
+ const flip = (0, coinFlip_1.coinFlip)();
39
+ const f = affine_1.AffineConstructor.random();
40
+ const instruction = `Soit la fonction affine $f(x)=${f.toTex()}$. ${flip
41
+ ? `Déterminer la valeur du coefficient directeur`
42
+ : `Déterminer la valeur de l'ordonnée à l'origine.`}`;
43
+ return {
44
+ instruction,
45
+ correctAnwer: flip ? f.a + "" : f.b + "",
46
+ f,
47
+ };
48
+ };
49
+ exports.leadingCoeffAndOriginOrdinate = {
50
+ id: "leadingCoeffAndOriginOrdinate",
51
+ label: "A partir de l'expression algébrique d'une fonction affine, déterminer la valeur du coefficient directeur ou de l'ordonnée à l'origine.",
52
+ levels: ["2nde"],
53
+ isSingleStep: true,
54
+ sections: ["Fonctions affines"],
55
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getLeadingCoeffAndOriginOrdinateQuestion, nb),
56
+ qcmTimer: 60,
57
+ freeTimer: 60,
58
+ getPropositions,
59
+ isAnswerValid,
60
+ subject: "Mathématiques",
61
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ aX: number;
4
+ aY: number;
5
+ bX: number;
6
+ bY: number;
7
+ };
8
+ export declare const cartesianEquationOfLine: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=cartesianEquationOfLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesianEquationOfLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/cartesianEquationOfLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAclC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA8NF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cartesianEquationOfLine = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
7
+ const line_1 = require("../../../../math/geometry/line");
8
+ const point_1 = require("../../../../math/geometry/point");
9
+ const vector_1 = require("../../../../math/geometry/vector");
10
+ const randint_1 = require("../../../../math/utils/random/randint");
11
+ const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
12
+ const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
13
+ const addNode_1 = require("../../../../tree/nodes/operators/addNode");
14
+ const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
15
+ const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
16
+ const zero = new numberNode_1.NumberNode(0);
17
+ const getCartesianEquationOfLineQuestion = () => {
18
+ const a = new point_1.Point("A", new numberNode_1.NumberNode((0, randint_1.randint)(-5, 6)), new numberNode_1.NumberNode((0, randint_1.randint)(-5, 6)));
19
+ const b = new point_1.Point("B", new numberNode_1.NumberNode((0, randint_1.randint)(-5, 6, [a.getXnumber()])), new numberNode_1.NumberNode((0, randint_1.randint)(-5, 6, [a.getXnumber()])));
20
+ const line = new line_1.Line(a, b);
21
+ const commands = [
22
+ `d = Line((${a.getXnumber()},${a.getYnumber()}),(${b.getXnumber()},${b.getYnumber()}))`,
23
+ `SetCaption(d, "$d$")`,
24
+ `ShowLabel(d,true)`,
25
+ `SetFixed(d,true)`,
26
+ ];
27
+ const ggb = new geogebraConstructor_1.GeogebraConstructor(commands, { isGridSimple: true });
28
+ const correctAnswer = line.getCartesianEquation();
29
+ const instruction = `Déterminer l'equation cartesienne de la droite $d$`;
30
+ const aX = a.getXnumber();
31
+ const aY = a.getYnumber();
32
+ const bX = b.getXnumber();
33
+ const bY = b.getYnumber();
34
+ const question = {
35
+ answer: correctAnswer.toTex(),
36
+ commands: ggb.commands,
37
+ options: ggb.getOptions(),
38
+ coords: ggb.getAdaptedCoords({
39
+ xMin: Math.min(aX, bX) - 5,
40
+ xMax: Math.max(bX, aX) + 5,
41
+ yMin: Math.min(aY, bY) - 5,
42
+ yMax: Math.max(bY, aY) + 5,
43
+ }),
44
+ instruction: instruction,
45
+ keys: ["x", "y", "equal"],
46
+ answerFormat: "tex",
47
+ identifiers: { aX, aY, bX, bY },
48
+ };
49
+ return question;
50
+ };
51
+ const getPropositions = (n, { answer, aX, aY, bX, bY }) => {
52
+ const propositions = [];
53
+ (0, exercise_1.addValidProp)(propositions, answer);
54
+ generateProposition(aX, aY, bX, bY).forEach((value) => (0, exercise_1.tryToAddWrongProp)(propositions, value.toTex()));
55
+ let aXrand;
56
+ let aYrand;
57
+ while (propositions.length < n) {
58
+ aXrand = (0, randint_1.randint)(-10, 11, [aX]);
59
+ aYrand = (0, randint_1.randint)(-10, 11, [aY]);
60
+ (0, exercise_1.tryToAddWrongProp)(propositions, getCorrectAnswer(aXrand, aYrand, bX, bY).toTex());
61
+ }
62
+ return (0, exercise_1.shuffleProps)(propositions, n);
63
+ };
64
+ const getCorrectAnswer = (aX, aY, bX, bY) => {
65
+ const a = new point_1.Point("A", new numberNode_1.NumberNode(aX), new numberNode_1.NumberNode(aY));
66
+ const b = new point_1.Point("B", new numberNode_1.NumberNode(bX), new numberNode_1.NumberNode(bY));
67
+ const line = new line_1.Line(a, b);
68
+ return line.getCartesianEquation();
69
+ };
70
+ const generateProposition = (aX, aY, bX, bY) => {
71
+ const x = new variableNode_1.VariableNode("x");
72
+ const y = new variableNode_1.VariableNode("y");
73
+ const firstProposition = getFirstProposition(x, y, aX, aY, bX, bY);
74
+ const secondProposition = getSecondPropoition(x, y, aX, aY, bX, bY);
75
+ return [firstProposition, secondProposition];
76
+ };
77
+ const getFirstProposition = (x, y, aX, aY, bX, bY) => {
78
+ const u = new vector_1.Vector("u", new numberNode_1.NumberNode(bX - aX), new numberNode_1.NumberNode(bY - aY));
79
+ const b = u.getXAsNumber();
80
+ const a = -u.getYAsNumber();
81
+ const c = -a * aX - b * aY;
82
+ return new equalNode_1.EqualNode(new addNode_1.AddNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), x).simplify(), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(b), y).simplify()), new numberNode_1.NumberNode(c)), zero);
83
+ };
84
+ const getSecondPropoition = (x, y, aX, aY, bX, bY) => {
85
+ const u = new vector_1.Vector("u", new numberNode_1.NumberNode(aX - bX), new numberNode_1.NumberNode(aY - bY));
86
+ const b = -u.getXAsNumber();
87
+ const a = u.getYAsNumber();
88
+ const c = a * aX + b * aY;
89
+ return new equalNode_1.EqualNode(new addNode_1.AddNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(b), x).simplify(), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), y).simplify()), new numberNode_1.NumberNode(c)), zero);
90
+ };
91
+ const isAnswerValid = (ans, { aX, aY, bX, bY }) => {
92
+ let userAns = getEquationNodeFromString(ans);
93
+ if (userAns === undefined)
94
+ return false;
95
+ userAns = userAns;
96
+ if (userAns.evaluate({ x: aX, y: aY }) !== 0)
97
+ return false;
98
+ if (userAns.evaluate({ x: bX, y: bY }) !== 0)
99
+ return false;
100
+ return true;
101
+ };
102
+ const getEquationNodeFromString = (ans) => {
103
+ if (!isValidFormat(ans))
104
+ return undefined;
105
+ const leftSide = ans.split("=")[0];
106
+ let op = leftSide.charAt(0) === "-" ? leftSide.replace("-", "minus") : leftSide;
107
+ op = op.includes("+") ? op : op.replaceAll("-", "+minus");
108
+ return getNodeFromString(op.split("+"));
109
+ };
110
+ const isValidFormat = (ans) => {
111
+ if (!ans.includes("="))
112
+ return false;
113
+ const splitted = ans.split("=");
114
+ if (splitted.length !== 2 || splitted[1] !== "0")
115
+ return false;
116
+ return true;
117
+ };
118
+ const getNodeFromString = (tab) => {
119
+ if (tab.length === 1) {
120
+ let varStr = tab[0];
121
+ const operator = findOpInSimpleOpString(varStr);
122
+ if (operator !== undefined) {
123
+ const modified = operator === "-" ? varStr.replaceAll("-", "+minus") : varStr;
124
+ const separated = modified.split("+");
125
+ return getNodeFromString(separated).simplify();
126
+ }
127
+ varStr = varStr.replace("minus", "-");
128
+ if (varStr.includes("x")) {
129
+ return getNodeFromVariableString(varStr, "x");
130
+ }
131
+ if (varStr.includes("y")) {
132
+ return getNodeFromVariableString(varStr, "y");
133
+ }
134
+ return isNaN(+varStr) ? new numberNode_1.NumberNode(0) : new numberNode_1.NumberNode(+varStr);
135
+ }
136
+ else {
137
+ const middle = Math.floor(tab.length / 2);
138
+ const leftSide = tab.slice(0, middle);
139
+ const rightSide = tab.slice(middle);
140
+ return new addNode_1.AddNode(getNodeFromString(leftSide).simplify(), getNodeFromString(rightSide).simplify()).simplify();
141
+ }
142
+ };
143
+ const findOpInSimpleOpString = (str) => {
144
+ if (str.includes("+"))
145
+ return "+";
146
+ if (str.includes("-"))
147
+ return "-";
148
+ return undefined;
149
+ };
150
+ const getNodeFromVariableString = (str, splitter) => {
151
+ if (str === splitter)
152
+ return new variableNode_1.VariableNode(splitter);
153
+ const splitted = str.split(splitter);
154
+ if (splitted[0] === "-") {
155
+ return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(-1), new variableNode_1.VariableNode(splitter)).simplify();
156
+ }
157
+ return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(+splitted[0]), new variableNode_1.VariableNode(splitter)).simplify();
158
+ };
159
+ exports.cartesianEquationOfLine = {
160
+ id: "cartesianEquationOfLine",
161
+ label: "Déterminer une equation cartesienne de droite",
162
+ levels: ["2nde"],
163
+ isSingleStep: true,
164
+ sections: ["Droites"],
165
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getCartesianEquationOfLineQuestion, nb),
166
+ qcmTimer: 60,
167
+ freeTimer: 60,
168
+ getPropositions,
169
+ isAnswerValid,
170
+ hasGeogebra: true,
171
+ subject: "Mathématiques",
172
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ xValue: number;
4
+ yValue: number;
5
+ };
6
+ export declare const directionVector: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=directionVector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directionVector.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/directionVector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAyHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.directionVector = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
7
+ const vector_1 = require("../../../../math/geometry/vector");
8
+ const randint_1 = require("../../../../math/utils/random/randint");
9
+ function parseVector(input) {
10
+ const tex = input.replace("\\left", "");
11
+ const latex = tex.replace("\\right", "");
12
+ const regex = /\((-?\d+)\s*[;,]\s*(-?\d+)\)/;
13
+ const match = latex.match(regex);
14
+ if (match && match.length === 3) {
15
+ return {
16
+ x: parseInt(match[1], 10),
17
+ y: parseInt(match[2], 10),
18
+ };
19
+ }
20
+ return null;
21
+ }
22
+ const getDirectionVectorQuestion = () => {
23
+ let x1 = (0, randint_1.randint)(-8, 8);
24
+ let x2 = (0, randint_1.randint)(-8, 8);
25
+ while (x2 === x1) {
26
+ x2 = (0, randint_1.randint)(-8, 8);
27
+ }
28
+ let y1 = (0, randint_1.randint)(-8, 8);
29
+ let y2 = (0, randint_1.randint)(-8, 8);
30
+ while (y2 === y1) {
31
+ y2 = (0, randint_1.randint)(-8, 8);
32
+ }
33
+ const xValue = x2 - x1;
34
+ const yValue = y2 - y1;
35
+ const vector = new vector_1.Vector("v", xValue.toTree(), yValue.toTree());
36
+ const instruction = `Soit la droite tracée ci-dessous dans le plan cartésien. Déterminez les coordonnées d'un vecteur directeur $\\overrightarrow{v}$ de cette droite.`;
37
+ const commands = [`line = Line((${x1}, ${y1}), (${x2}, ${y2}))`];
38
+ const xMin = Math.min(x1, x2);
39
+ const yMin = Math.min(y1, y2);
40
+ const xMax = Math.max(x1, x2);
41
+ const yMax = Math.max(y1, y2);
42
+ const ggb = new geogebraConstructor_1.GeogebraConstructor(commands, {
43
+ isGridSimple: true,
44
+ });
45
+ const question = {
46
+ answer: vector.toInlineCoordsTex(),
47
+ instruction,
48
+ commands: ggb.commands,
49
+ coords: [xMin - 10, xMax + 10, yMin - 10, yMax + 10],
50
+ options: ggb.getOptions(),
51
+ keys: ["semicolon", "x", "y"],
52
+ answerFormat: "tex",
53
+ identifiers: { xValue, yValue },
54
+ };
55
+ return question;
56
+ };
57
+ const getPropositions = (n, { answer, xValue, yValue }) => {
58
+ const propositions = [];
59
+ (0, exercise_1.addValidProp)(propositions, answer);
60
+ const vector = new vector_1.Vector("v", xValue.toTree(), yValue.toTree());
61
+ const wrongAnswer1 = new vector_1.Vector("v", (xValue - 1).toTree(), (yValue - 1).toTree());
62
+ const wrongAnswer2 = new vector_1.Vector("v", (xValue + 1).toTree(), (yValue + 1).toTree());
63
+ const wrongAnswer3 = new vector_1.Vector("v", yValue.toTree(), xValue.toTree());
64
+ if (wrongAnswer1.isColinear(vector) === false) {
65
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer1.toInlineCoordsTex());
66
+ }
67
+ if (wrongAnswer2.isColinear(vector) === false) {
68
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer2.toInlineCoordsTex());
69
+ }
70
+ if (wrongAnswer3.isColinear(vector) === false) {
71
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer3.toInlineCoordsTex());
72
+ }
73
+ while (propositions.length < n) {
74
+ const wrongAnswer = new vector_1.Vector("v", (0, randint_1.randint)(-5, 5).toTree(), (0, randint_1.randint)(-5, 5).toTree());
75
+ if (wrongAnswer.isColinear(vector) === false) {
76
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer.toInlineCoordsTex());
77
+ }
78
+ }
79
+ return (0, exercise_1.shuffleProps)(propositions, n);
80
+ };
81
+ const isAnswerValid = (ans, { answer, xValue, yValue }) => {
82
+ const parsed = parseVector(ans);
83
+ if (!parsed) {
84
+ return false;
85
+ }
86
+ const { x, y } = parsed;
87
+ const correctVector = new vector_1.Vector("v", xValue.toTree(), yValue.toTree());
88
+ const studentVector = new vector_1.Vector("v", x.toTree(), y.toTree());
89
+ if (!studentVector.isColinear(correctVector)) {
90
+ return false;
91
+ }
92
+ return true;
93
+ };
94
+ exports.directionVector = {
95
+ id: "directionVector",
96
+ label: "Lire les coordonnées d'un vecteur directeur d'une droite",
97
+ levels: ["2nde"],
98
+ isSingleStep: true,
99
+ sections: ["Géométrie cartésienne"],
100
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getDirectionVectorQuestion, nb),
101
+ qcmTimer: 60,
102
+ freeTimer: 60,
103
+ getPropositions,
104
+ isAnswerValid,
105
+ subject: "Mathématiques",
106
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ xValue: number;
4
+ yValue: number;
5
+ };
6
+ export declare const directionVectorEquation: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=directionVectorEquation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directionVectorEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/directionVectorEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAwHF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}