math-exercises 3.0.85 → 3.0.87

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 (151) hide show
  1. package/lib/exercises/exercise.d.ts +7 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/decimalBoundingOnLine.js +1 -1
  4. package/lib/exercises/math/calcul/arithmetics/divisorsList.js +1 -1
  5. package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.js +1 -1
  6. package/lib/exercises/math/calcul/arithmetics/index.d.ts +0 -10
  7. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/arithmetics/index.js +0 -10
  9. package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +1 -1
  10. package/lib/exercises/math/calcul/fractions/evalFractionExpression.d.ts +9 -0
  11. package/lib/exercises/math/calcul/fractions/evalFractionExpression.d.ts.map +1 -0
  12. package/lib/exercises/math/calcul/fractions/evalFractionExpression.js +113 -0
  13. package/lib/exercises/math/calcul/fractions/fractionSquare.d.ts.map +1 -1
  14. package/lib/exercises/math/calcul/fractions/fractionSquare.js +1 -0
  15. package/lib/exercises/math/calcul/fractions/index.d.ts +2 -0
  16. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  17. package/lib/exercises/math/calcul/fractions/index.js +2 -0
  18. package/lib/exercises/math/calcul/fractions/powerNotation.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/fractions/powerNotation.js +1 -0
  20. package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
  21. package/lib/exercises/math/calcul/fractions/simplifyFraction.js +1 -0
  22. package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.d.ts.map +1 -1
  23. package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.js +1 -0
  24. package/lib/exercises/math/calcul/fractions/simplifyToFraction.d.ts +9 -0
  25. package/lib/exercises/math/calcul/fractions/simplifyToFraction.d.ts.map +1 -0
  26. package/lib/exercises/math/calcul/fractions/simplifyToFraction.js +168 -0
  27. package/lib/exercises/math/calcul/ordering/framing.js +3 -3
  28. package/lib/exercises/math/calcul/sign/absoluteNumber.d.ts.map +1 -1
  29. package/lib/exercises/math/calcul/sign/absoluteNumber.js +1 -0
  30. package/lib/exercises/math/calculLitteral/inequations/index.d.ts +2 -0
  31. package/lib/exercises/math/calculLitteral/inequations/index.d.ts.map +1 -1
  32. package/lib/exercises/math/calculLitteral/inequations/index.js +2 -0
  33. package/lib/exercises/math/calculLitteral/inequations/isInequalityTrue.d.ts +15 -0
  34. package/lib/exercises/math/calculLitteral/inequations/isInequalityTrue.d.ts.map +1 -0
  35. package/lib/exercises/math/calculLitteral/inequations/isInequalityTrue.js +143 -0
  36. package/lib/exercises/math/calculLitteral/inequations/minNumberInequality.d.ts +13 -0
  37. package/lib/exercises/math/calculLitteral/inequations/minNumberInequality.d.ts.map +1 -0
  38. package/lib/exercises/math/calculLitteral/inequations/minNumberInequality.js +192 -0
  39. package/lib/exercises/math/calculLitteral/systems/verifySystemSolution.js +1 -1
  40. package/lib/exercises/math/functions/absolute/calculateDistanceBetweenNumbers.d.ts +8 -0
  41. package/lib/exercises/math/functions/absolute/calculateDistanceBetweenNumbers.d.ts.map +1 -0
  42. package/lib/exercises/math/functions/absolute/calculateDistanceBetweenNumbers.js +102 -0
  43. package/lib/exercises/math/functions/absolute/calculateDistanceWithAbsoluteValue.d.ts +10 -0
  44. package/lib/exercises/math/functions/absolute/calculateDistanceWithAbsoluteValue.d.ts.map +1 -0
  45. package/lib/exercises/math/functions/absolute/calculateDistanceWithAbsoluteValue.js +112 -0
  46. package/lib/exercises/math/functions/absolute/calculateWithAbsoluteValue.d.ts +8 -0
  47. package/lib/exercises/math/functions/absolute/calculateWithAbsoluteValue.d.ts.map +1 -0
  48. package/lib/exercises/math/functions/absolute/calculateWithAbsoluteValue.js +124 -0
  49. package/lib/exercises/math/functions/absolute/index.d.ts +3 -0
  50. package/lib/exercises/math/functions/absolute/index.d.ts.map +1 -1
  51. package/lib/exercises/math/functions/absolute/index.js +3 -0
  52. package/lib/exercises/math/functions/basics/index.d.ts +1 -0
  53. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  54. package/lib/exercises/math/functions/basics/index.js +1 -1
  55. package/lib/exercises/math/functions/basics/valueTableCompletion.d.ts +2 -1
  56. package/lib/exercises/math/functions/basics/valueTableCompletion.d.ts.map +1 -1
  57. package/lib/exercises/math/functions/basics/valueTableCompletion.js +103 -31
  58. package/lib/exercises/math/functions/sqrt/index.d.ts +2 -0
  59. package/lib/exercises/math/functions/sqrt/index.d.ts.map +1 -1
  60. package/lib/exercises/math/functions/sqrt/index.js +2 -0
  61. package/lib/exercises/math/functions/sqrt/sqrtInequality.d.ts +10 -0
  62. package/lib/exercises/math/functions/sqrt/sqrtInequality.d.ts.map +1 -0
  63. package/lib/exercises/math/functions/sqrt/sqrtInequality.js +160 -0
  64. package/lib/exercises/math/functions/sqrt/squareRootCalculation.d.ts +8 -0
  65. package/lib/exercises/math/functions/sqrt/squareRootCalculation.d.ts.map +1 -0
  66. package/lib/exercises/math/functions/sqrt/squareRootCalculation.js +108 -0
  67. package/lib/exercises/math/geometry/angles/recognizeAngleType.d.ts.map +1 -1
  68. package/lib/exercises/math/geometry/angles/recognizeAngleType.js +0 -1
  69. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts.map +1 -1
  70. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.js +1 -1
  71. package/lib/exercises/math/geometry/cartesian/cartesianFromTwoPoints.js +1 -1
  72. package/lib/exercises/math/geometry/cartesian/cartesianFromVectorAndPoint.js +1 -1
  73. package/lib/exercises/math/geometry/index.d.ts +0 -1
  74. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  75. package/lib/exercises/math/geometry/index.js +0 -1
  76. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.js +1 -1
  77. package/lib/exercises/math/geometry/lines/cartesianEquationsIntersection.js +1 -1
  78. package/lib/exercises/math/geometry/lines/findParallelLineFromCartesianEquation.d.ts.map +1 -1
  79. package/lib/exercises/math/geometry/lines/findParallelLineFromCartesianEquation.js +1 -1
  80. package/lib/exercises/math/geometry/lines/findParallelLineFromReductEquation.d.ts.map +1 -1
  81. package/lib/exercises/math/geometry/lines/findParallelLineFromReductEquation.js +1 -1
  82. package/lib/exercises/math/geometry/vectors/lineFromDirectorVector.js +1 -1
  83. package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
  84. package/lib/exercises/math/powers/calculateNegativePower.js +1 -0
  85. package/lib/exercises/math/powers/powersDivision.d.ts.map +1 -1
  86. package/lib/exercises/math/powers/powersDivision.js +2 -0
  87. package/lib/exercises/math/powers/powersMixOperations.d.ts.map +1 -1
  88. package/lib/exercises/math/powers/powersMixOperations.js +1 -0
  89. package/lib/exercises/math/powers/powersPower.d.ts.map +1 -1
  90. package/lib/exercises/math/powers/powersPower.js +2 -0
  91. package/lib/exercises/math/powers/powersProduct.d.ts.map +1 -1
  92. package/lib/exercises/math/powers/powersProduct.js +2 -0
  93. package/lib/exercises/math/probaStat/basicStats/index.d.ts +0 -1
  94. package/lib/exercises/math/probaStat/basicStats/index.d.ts.map +1 -1
  95. package/lib/exercises/math/probaStat/basicStats/index.js +0 -1
  96. package/lib/exercises/math/probaStat/index.d.ts +0 -2
  97. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  98. package/lib/exercises/math/probaStat/index.js +0 -2
  99. package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.js +2 -2
  100. package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.js +2 -2
  101. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.d.ts +12 -0
  102. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.d.ts.map +1 -0
  103. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.js +178 -0
  104. package/lib/exercises/math/probaStat/stats1var/index.d.ts +1 -0
  105. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  106. package/lib/exercises/math/probaStat/stats1var/index.js +1 -0
  107. package/lib/exercises/math/sampling/getSampleCountAndSize.d.ts +12 -0
  108. package/lib/exercises/math/sampling/getSampleCountAndSize.d.ts.map +1 -0
  109. package/lib/exercises/math/sampling/getSampleCountAndSize.js +95 -0
  110. package/lib/exercises/math/sampling/index.d.ts +2 -0
  111. package/lib/exercises/math/sampling/index.d.ts.map +1 -1
  112. package/lib/exercises/math/sampling/index.js +2 -0
  113. package/lib/exercises/math/sampling/samplingFrequency.d.ts +7 -0
  114. package/lib/exercises/math/sampling/samplingFrequency.d.ts.map +1 -0
  115. package/lib/exercises/math/sampling/samplingFrequency.js +106 -0
  116. package/lib/exercises/math/sets/intervals/index.d.ts +2 -0
  117. package/lib/exercises/math/sets/intervals/index.d.ts.map +1 -1
  118. package/lib/exercises/math/sets/intervals/index.js +2 -0
  119. package/lib/exercises/math/sets/intervals/intervalOnGraph.d.ts +8 -0
  120. package/lib/exercises/math/sets/intervals/intervalOnGraph.d.ts.map +1 -0
  121. package/lib/exercises/math/sets/intervals/intervalOnGraph.js +156 -0
  122. package/lib/exercises/math/sets/intervals/isNumberInInterval.d.ts +9 -0
  123. package/lib/exercises/math/sets/intervals/isNumberInInterval.d.ts.map +1 -0
  124. package/lib/exercises/math/sets/intervals/isNumberInInterval.js +174 -0
  125. package/lib/exercises/math/squareRoots/simpifySquareRoot.d.ts.map +1 -1
  126. package/lib/exercises/math/squareRoots/simpifySquareRoot.js +1 -0
  127. package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
  128. package/lib/exercises/math/squareRoots/squareRootIdentities.js +1 -0
  129. package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
  130. package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +1 -0
  131. package/lib/exercises/math/squareRoots/squareRootsFractions.d.ts.map +1 -1
  132. package/lib/exercises/math/squareRoots/squareRootsFractions.js +1 -0
  133. package/lib/exercises/math/squareRoots/squareRootsProducts.d.ts.map +1 -1
  134. package/lib/exercises/math/squareRoots/squareRootsProducts.js +1 -0
  135. package/lib/exercises/math/squareRoots/squareRootsSum.d.ts.map +1 -1
  136. package/lib/exercises/math/squareRoots/squareRootsSum.js +1 -0
  137. package/lib/index.d.ts +60 -55
  138. package/lib/index.d.ts.map +1 -1
  139. package/lib/math/geometry/line.d.ts.map +1 -1
  140. package/lib/math/geometry/line.js +0 -11
  141. package/lib/server.js +21 -0
  142. package/lib/tests/exoTest.d.ts.map +1 -1
  143. package/lib/tests/exoTest.js +9 -2
  144. package/lib/tests/questionTest.d.ts.map +1 -1
  145. package/lib/tests/questionTest.js +21 -2
  146. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  147. package/lib/tree/nodes/equations/equalNode.js +0 -1
  148. package/lib/utils/markdown/mdTable.d.ts +1 -1
  149. package/lib/utils/markdown/mdTable.d.ts.map +1 -1
  150. package/lib/utils/markdown/mdTable.js +10 -5
  151. 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 { randint } from "../../../../math/utils/random/randint.js";
4
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
5
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer, "raw");
12
+ tryToAddWrongProp(propositions, "Non", "raw");
13
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
14
+ tryToAddWrongProp(propositions, "Oui", "raw");
15
+ return shuffleProps(propositions, n);
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { x, inequalitySign, left, right } = identifiers;
19
+ const leftValue = reifyAlgebraic(left)
20
+ .toDetailedEvaluation({ x: x.toTree() })
21
+ .evaluate();
22
+ const rightValue = reifyAlgebraic(right)
23
+ .toDetailedEvaluation({ x: x.toTree() })
24
+ .evaluate();
25
+ const isTrue = inequalitySign
26
+ ? leftValue < rightValue
27
+ : leftValue > rightValue;
28
+ return isTrue ? "Oui" : "Non";
29
+ };
30
+ const getInstruction = (identifiers) => {
31
+ const { x, inequalitySign, left, right } = identifiers;
32
+ const leftNode = reifyAlgebraic(left);
33
+ const rightNode = reifyAlgebraic(right);
34
+ return `On considère l'inéquation suivante :
35
+
36
+ $$
37
+ ${leftNode.toTex()} ${inequalitySign ? "<" : ">"} ${rightNode.toTex()}
38
+ $$
39
+
40
+ Cette inéquation est-elle vraie pour $x = ${x}$ ?`;
41
+ };
42
+ const getHint = (identifiers) => {
43
+ return `Remplace $x$ par $${identifiers.x}$ dans les deux membres. Ensuite, vérifie si l'inégalité est vraie ou non.`;
44
+ };
45
+ const reverseSign = (sign) => {
46
+ let x = "";
47
+ if (sign === "<") {
48
+ x = ">";
49
+ }
50
+ else if (sign === ">") {
51
+ x = "<";
52
+ }
53
+ return x;
54
+ };
55
+ const getCorrection = (identifiers) => {
56
+ const { x, inequalitySign, left, right } = identifiers;
57
+ const leftNode = reifyAlgebraic(left);
58
+ const rightNode = reifyAlgebraic(right);
59
+ const detailedLeft = leftNode.toDetailedEvaluation({ x: x.toTree() });
60
+ const simplifiedLeft = detailedLeft.simplify();
61
+ const detailedRight = rightNode.toDetailedEvaluation({ x: x.toTree() });
62
+ const simplifiedRight = detailedRight.simplify();
63
+ const leftDetTex = detailedLeft.toTex();
64
+ const leftSimTex = simplifiedLeft.toTex();
65
+ const rightDetTex = detailedRight.toTex();
66
+ const rightSimTex = simplifiedRight.toTex();
67
+ const isTrue = getAnswer(identifiers) === "Oui";
68
+ const sign = inequalitySign ? "<" : ">";
69
+ return `Pour $x = ${x}$, le membre de gauche vaut :
70
+
71
+ $$
72
+ ${leftDetTex} = ${leftSimTex}
73
+ $$
74
+
75
+ Le membre de droite vaut :
76
+
77
+ $$
78
+ ${rightDetTex} = ${rightSimTex}
79
+ $$
80
+
81
+ Puisque $${leftSimTex} ${isTrue ? sign : reverseSign(sign)} ${rightSimTex}$, l'inéquation ${isTrue ? "est bien verifiée" : "n'est pas vérifiée"} pour $x = ${x}$.`;
82
+ };
83
+ const getKeys = (identifiers) => {
84
+ return [];
85
+ };
86
+ const isAnswerValid = (ans, { answer }) => {
87
+ try {
88
+ return ans === answer;
89
+ }
90
+ catch (err) {
91
+ return handleVEAError(err);
92
+ }
93
+ };
94
+ const getIsInequalityTrueQuestion = (ops) => {
95
+ const a = randint(-10, 10, [0]);
96
+ const b = randint(-10, 10, [0]);
97
+ const c = randint(-10, 10, [0]);
98
+ const d = randint(-10, 10, [0]);
99
+ const x = randint(-10, 10);
100
+ const inequalitySign = coinFlip();
101
+ const left = add(multiply(a, "x"), b).toIdentifiers();
102
+ const right = add(multiply(c, "x"), -d).toIdentifiers();
103
+ const identifiers = {
104
+ a,
105
+ b,
106
+ c,
107
+ d,
108
+ x,
109
+ inequalitySign,
110
+ left,
111
+ right,
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 isInequalityTrue = {
127
+ id: "isInequalityTrue",
128
+ label: "Vérifier si une inégalité est vraie",
129
+ isSingleStep: true,
130
+ generator: (nb, opts) => getDistinctQuestions(() => getIsInequalityTrueQuestion(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,13 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ aLimit: number;
5
+ bLimit: number;
6
+ x: number;
7
+ y: number;
8
+ case: "lt" | "lte" | "lt_gt";
9
+ expressionToCheck: NodeIdentifiers;
10
+ };
11
+ export declare const minNumberInequality: Exercise<Identifiers>;
12
+ export {};
13
+ //# sourceMappingURL=minNumberInequality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minNumberInequality.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/minNumberInequality.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAS7C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC;IAC7B,iBAAiB,EAAE,eAAe,CAAC;CACpC,CAAC;AA4NF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAiBrD,CAAC"}
@@ -0,0 +1,192 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
5
+ import { add, isAddNode } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
9
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
+ import { InequationNode } from "../../../../tree/nodes/inequations/inequationNode.js";
11
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
12
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
13
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
14
+ import { random } from "../../../../utils/alea/random.js";
15
+ const getPropositions = (n, { answer }) => {
16
+ const propositions = [];
17
+ addValidProp(propositions, answer);
18
+ while (propositions.length < n) {
19
+ const randomNumber = randint(0, 100).frenchify();
20
+ tryToAddWrongProp(propositions, randomNumber);
21
+ }
22
+ return shuffleProps(propositions, n);
23
+ };
24
+ const getAnswer = (identifiers) => {
25
+ const { aLimit, bLimit, expressionToCheck: formulaIdentifier } = identifiers;
26
+ const formulaNode = reifyAlgebraic(formulaIdentifier).toDetailedEvaluation({
27
+ a: aLimit.toTree(),
28
+ b: bLimit.toTree(),
29
+ });
30
+ const answer = formulaNode.simplify().toTex();
31
+ return answer;
32
+ };
33
+ const getInstruction = (identifiers) => {
34
+ const { aLimit, bLimit, case: inequalityCase, expressionToCheck, } = identifiers;
35
+ const modeSymbolsMap = {
36
+ lt: ["<", "<"],
37
+ lte: ["\\le", "\\le"],
38
+ lt_gt: ["<", ">"],
39
+ };
40
+ const symbols = modeSymbolsMap[inequalityCase];
41
+ if (!symbols)
42
+ throw new Error(`Unhandled mode: ${inequalityCase}`);
43
+ const [aSymbol, bSymbol] = symbols;
44
+ const a = new VariableNode("a");
45
+ const b = new VariableNode("b");
46
+ const aLimitNode = new NumberNode(aLimit);
47
+ const bLimitNode = new NumberNode(bLimit);
48
+ const aCondition = new InequationNode([a, aLimitNode], aSymbol);
49
+ const bCondition = new InequationNode([b, bLimitNode], bSymbol);
50
+ const v = new VariableNode("...");
51
+ const exprCondition = new InequationNode([reifyAlgebraic(expressionToCheck), v], aSymbol);
52
+ return `Compléter par le plus petit nombre réel possible :
53
+
54
+ "Si $a$ et $b$ sont deux nombres réels verifiant $${aCondition.toTex()}$ et $${bCondition.toTex()}$, alors $${exprCondition.toTex()}$"
55
+
56
+ `;
57
+ };
58
+ const getHint = (identifiers) => {
59
+ return `On peut additionner deux inégalités si elles sont de même sens :
60
+
61
+ Si $a < b$ et $c < d$, alors $a + c < b + d$.`;
62
+ };
63
+ const getCorrection = (identifiers) => {
64
+ const { aLimit, bLimit, x, y, case: inequalityCase, expressionToCheck, } = identifiers;
65
+ const exprNode = reifyAlgebraic(expressionToCheck);
66
+ let left;
67
+ let right;
68
+ if (isAddNode(exprNode)) {
69
+ left = exprNode.leftChild;
70
+ right = exprNode.rightChild;
71
+ }
72
+ else {
73
+ const exprNode = reifyAlgebraic(expressionToCheck);
74
+ const nominator = exprNode.leftChild;
75
+ const denominator = exprNode.rightChild;
76
+ left = frac(nominator.leftChild, denominator);
77
+ right = frac(nominator.rightChild, denominator);
78
+ }
79
+ const leftValue = left
80
+ .toDetailedEvaluation({ a: aLimit.toTree() })
81
+ .simplify()
82
+ .toTex();
83
+ const rightValue = right
84
+ .toDetailedEvaluation({ b: bLimit.toTree() })
85
+ .simplify()
86
+ .toTex();
87
+ const answer = getAnswer(identifiers);
88
+ const symbolMap = {
89
+ lt: "<",
90
+ lte: "\\le",
91
+ lt_gt: "<",
92
+ };
93
+ const finalSymbol = symbolMap[inequalityCase] ?? "<";
94
+ const leftCondition = new InequationNode(["a".toTree(), aLimit.toTree()], finalSymbol);
95
+ const leftExpr = new InequationNode([left, leftValue.toTree()], finalSymbol);
96
+ const rightCondition = new InequationNode(["b".toTree(), bLimit.toTree()], inequalityCase === "lt_gt" ? ">" : finalSymbol);
97
+ const rightExpr = new InequationNode([right, rightValue.toTree()], finalSymbol);
98
+ const exprInequality = new InequationNode([exprNode, add(leftValue.toTree(), rightValue.toTree())], finalSymbol);
99
+ const finishedExprInequality = new InequationNode([exprNode, answer.toTree()], finalSymbol);
100
+ const shouldWorkOnA = inequalityCase !== "lt_gt" && x !== 1;
101
+ const shouldWorkOnB = y !== 1 || inequalityCase === "lt_gt";
102
+ return `${shouldWorkOnA
103
+ ? `Puisque $${leftCondition.toTex()}$ alors $${leftExpr.toTex()}$.`
104
+ : ""}
105
+
106
+ ${shouldWorkOnB
107
+ ? `Puisque $${rightCondition.toTex()}$, alors $${rightExpr.toTex()}$. `
108
+ : ""}
109
+
110
+ On peut ${shouldWorkOnA || shouldWorkOnB ? "alors" : ""} additionner les deux inégalités :
111
+
112
+ $$
113
+ ${exprInequality.toTex()}
114
+ $$
115
+
116
+ donc
117
+
118
+ $$
119
+ ${finishedExprInequality.toTex()}
120
+ $$`;
121
+ };
122
+ const getKeys = (identifiers) => {
123
+ return [];
124
+ };
125
+ const isAnswerValid = (ans, { answer }) => {
126
+ try {
127
+ const parsed = parseAlgebraic(ans);
128
+ return parsed.simplify().toTex() === answer;
129
+ }
130
+ catch (err) {
131
+ return handleVEAError(err);
132
+ }
133
+ };
134
+ const getMinNumberInequalityQuestion = (ops) => {
135
+ const aLimit = randint(1, 10);
136
+ const bLimit = randint(1, 10);
137
+ const x = randint(1, 10);
138
+ const y = randint(1, 10);
139
+ const cases = ["lt", "lte", "lt_gt"];
140
+ const randomCase = random(cases);
141
+ const addNode = add(multiply(x, "a"), multiply(y, "b"));
142
+ const subNode = add("a", multiply(-1, "b"));
143
+ const Denominator = add(multiply(x, aLimit), multiply(y, bLimit)).simplify();
144
+ const fracNode = frac(add(multiply(x, "a"), multiply(y, "b")), Denominator);
145
+ let formulaNode;
146
+ if (randomCase === "lt") {
147
+ coinFlip() ? (formulaNode = addNode) : (formulaNode = fracNode);
148
+ }
149
+ else if (randomCase === "lte") {
150
+ formulaNode = addNode;
151
+ }
152
+ else if (randomCase === "lt_gt") {
153
+ formulaNode = subNode;
154
+ }
155
+ const identifiers = {
156
+ aLimit,
157
+ bLimit,
158
+ x,
159
+ y,
160
+ case: randomCase,
161
+ expressionToCheck: formulaNode.toIdentifiers(),
162
+ };
163
+ return getQuestionFromIdentifiers(identifiers);
164
+ };
165
+ const getQuestionFromIdentifiers = (identifiers) => {
166
+ return {
167
+ answer: getAnswer(identifiers),
168
+ instruction: getInstruction(identifiers),
169
+ keys: getKeys(identifiers),
170
+ answerFormat: "tex",
171
+ identifiers,
172
+ hint: getHint(identifiers),
173
+ correction: getCorrection(identifiers),
174
+ };
175
+ };
176
+ export const minNumberInequality = {
177
+ id: "minNumberInequality",
178
+ label: "Compléter une inégalité par le plus petit nombre possible",
179
+ isSingleStep: true,
180
+ generator: (nb, opts) => getDistinctQuestions(() => getMinNumberInequalityQuestion(opts), nb),
181
+ qcmTimer: 60,
182
+ freeTimer: 60,
183
+ getPropositions,
184
+ isAnswerValid,
185
+ subject: "Mathématiques",
186
+ getInstruction,
187
+ getHint,
188
+ getCorrection,
189
+ getAnswer,
190
+ getQuestionFromIdentifiers,
191
+ hasHintAndCorrection: true,
192
+ };
@@ -111,7 +111,7 @@ const getPropositions = (n, { answer, ...identifiers }) => {
111
111
  };
112
112
  export const verifySystemSolution = {
113
113
  id: "verifySystemSolution",
114
- label: "Vérifier si un couple est solution d'un système",
114
+ label: "Vérifier si un couple est solution d'un système d'équations",
115
115
  levels: ["2nde", "1reSpé"],
116
116
  isSingleStep: true,
117
117
  sections: ["Systèmes"],
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const calculateDistanceBetweenNumbers: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=calculateDistanceBetweenNumbers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateDistanceBetweenNumbers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/calculateDistanceBetweenNumbers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAyFF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAoBjE,CAAC"}
@@ -0,0 +1,102 @@
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 { abs } from "../../../../tree/nodes/functions/absNode.js";
6
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
8
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
12
+ const getPropositions = (n, { answer, a, b }) => {
13
+ const propositions = [];
14
+ addValidProp(propositions, answer);
15
+ // Au cas où l'élève répond à la question en inversant les deux nombres
16
+ tryToAddWrongProp(propositions, add(b, -a).simplify().evaluate().frenchify());
17
+ // Au cas où l'élève répond à la question en ajoutant les deux nombres
18
+ tryToAddWrongProp(propositions, add(a, b).simplify().evaluate().frenchify());
19
+ while (propositions.length < n) {
20
+ const randomAnswer = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
21
+ tryToAddWrongProp(propositions, randomAnswer.frenchify());
22
+ }
23
+ return shuffleProps(propositions, n);
24
+ };
25
+ const getAnswer = (identifiers) => {
26
+ const { a, b } = identifiers;
27
+ const sub = add(a, -b);
28
+ const absNode = abs(sub).simplify().evaluate();
29
+ return absNode.frenchify();
30
+ };
31
+ const getInstruction = (identifiers) => {
32
+ const { a, b } = identifiers;
33
+ return `Calculer la distance entre $${a.frenchify()}$ et $${b.frenchify()}$.`;
34
+ };
35
+ const getHint = (identifiers) => {
36
+ return `La distance entre deux nombres $a$ et $b$ est
37
+ :
38
+
39
+ $$
40
+ |a - b|
41
+ $$
42
+ `;
43
+ };
44
+ const getCorrection = (identifiers) => {
45
+ const { a, b } = identifiers;
46
+ const sub = substract(a, b);
47
+ const absNode = abs(sub);
48
+ const answer = getAnswer(identifiers);
49
+ return `La distance entre $${a.frenchify()}$ et $${b.frenchify()}$ est :
50
+
51
+ ${alignTex([
52
+ [absNode.toTex(), "=", abs(sub.simplify()).toTex()],
53
+ ["", "=", answer],
54
+ ])}`;
55
+ };
56
+ const getKeys = (identifiers) => {
57
+ return [];
58
+ };
59
+ const isAnswerValid = (ans, { answer }) => {
60
+ try {
61
+ const ansNode = parseAlgebraic(ans);
62
+ const answerNode = parseAlgebraic(answer);
63
+ return ansNode.equals(answerNode);
64
+ }
65
+ catch (err) {
66
+ return handleVEAError(err);
67
+ }
68
+ };
69
+ const getCalculateDistanceBetweenNumbersQuestion = (ops) => {
70
+ const a = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
71
+ const b = coinFlip() ? randint(-10, 10, [a]) : randfloat(-10, 10, 2, [a]);
72
+ const identifiers = { a, b };
73
+ return getQuestionFromIdentifiers(identifiers);
74
+ };
75
+ const getQuestionFromIdentifiers = (identifiers) => {
76
+ return {
77
+ answer: getAnswer(identifiers),
78
+ instruction: getInstruction(identifiers),
79
+ keys: getKeys(identifiers),
80
+ answerFormat: "tex",
81
+ identifiers,
82
+ hint: getHint(identifiers),
83
+ correction: getCorrection(identifiers),
84
+ };
85
+ };
86
+ export const calculateDistanceBetweenNumbers = {
87
+ id: "calculateDistanceBetweenNumbers",
88
+ label: "Calculer la distance entre deux nombres",
89
+ isSingleStep: true,
90
+ generator: (nb, opts) => getDistinctQuestions(() => getCalculateDistanceBetweenNumbersQuestion(opts), nb),
91
+ qcmTimer: 60,
92
+ freeTimer: 60,
93
+ getPropositions,
94
+ isAnswerValid,
95
+ subject: "Mathématiques",
96
+ getInstruction,
97
+ getHint,
98
+ getCorrection,
99
+ getAnswer,
100
+ getQuestionFromIdentifiers,
101
+ hasHintAndCorrection: true,
102
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ a: NodeIdentifiers;
5
+ b: number;
6
+ c: number;
7
+ };
8
+ export declare const calculateDistanceWithAbsoluteValue: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=calculateDistanceWithAbsoluteValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateDistanceWithAbsoluteValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/calculateDistanceWithAbsoluteValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IAEjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsHF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAqBpE,CAAC"}
@@ -0,0 +1,112 @@
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 { round } from "../../../../math/utils/round.js";
6
+ import { abs } from "../../../../tree/nodes/functions/absNode.js";
7
+ import { NodeIds } from "../../../../tree/nodes/node.js";
8
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
9
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
10
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
12
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
13
+ const getPropositions = (n, { answer, a, b, c }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ tryToAddWrongProp(propositions, substract(abs(b), abs(reifyAlgebraic(a))).toTex() + "=" + c.frenchify());
17
+ tryToAddWrongProp(propositions, substract(abs(reifyAlgebraic(a)), abs(b)).toTex() + "=" + c.frenchify());
18
+ tryToAddWrongProp(propositions, add(abs(b), reifyAlgebraic(a)).toTex() + "=" + c.frenchify());
19
+ return shuffleProps(propositions, n);
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { a, b, c } = identifiers;
23
+ return `${abs(substract(b, reifyAlgebraic(a))).toTex()}=${c.frenchify()}`;
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { a, b, c } = identifiers;
27
+ const proposition = a.id === NodeIds.variable
28
+ ? `la distance entre $${reifyAlgebraic(a).toTex()}$ et $${b.frenchify()}$ est égale à $${c.frenchify()}$`
29
+ : `$${reifyAlgebraic(a).toTex()}$ et $${b.frenchify()}$ sont situés à une distance de $${c.frenchify()}$ l'un de l'autre`;
30
+ return `Traduire par une égalité avec une valeur absolue la phrase suivante :
31
+
32
+ "${proposition}".`;
33
+ };
34
+ const getHint = (identifiers) => {
35
+ return `La distance entre deux nombres $a$ et $b$ est égale à :
36
+
37
+ $$
38
+ ${abs(substract("b", "a")).toTex()}
39
+ $$`;
40
+ };
41
+ const getCorrection = (identifiers) => {
42
+ const { a, b } = identifiers;
43
+ return `La distance entre $${reifyAlgebraic(a).toTex()}$ et $${b.frenchify()}$ est égale à $${abs(substract(b, reifyAlgebraic(a))).toTex()}$.
44
+
45
+ Ici, on a donc :
46
+
47
+ $$
48
+ ${getAnswer(identifiers)}
49
+ $$`;
50
+ };
51
+ const getKeys = (identifiers) => {
52
+ return ["abs", "x", "equal"];
53
+ };
54
+ const isAnswerValid = (ans, { answer, a, b, c }) => {
55
+ const aNode = reifyAlgebraic(a);
56
+ return [
57
+ `${abs(substract(b, aNode)).toTex()}=${c.frenchify()}`,
58
+ `${abs(substract(aNode, b)).toTex()}=${c.frenchify()}`,
59
+ ].includes(ans);
60
+ };
61
+ const getCalculateDistanceWithAbsoluteValueQuestion = (ops) => {
62
+ const containsVariable = coinFlip();
63
+ let a;
64
+ let b;
65
+ let c;
66
+ if (containsVariable) {
67
+ a = new VariableNode("x");
68
+ b = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
69
+ c = coinFlip() ? randint(1, 10, [b]) : randfloat(0, 10, 2, [b, 0]);
70
+ }
71
+ else {
72
+ const aNb = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
73
+ a = aNb.toTree();
74
+ b = randint(-10, 10, [aNb]);
75
+ c = round(Math.abs(b - aNb), 4);
76
+ }
77
+ const identifiers = {
78
+ a: a.toIdentifiers(),
79
+ b,
80
+ c,
81
+ };
82
+ return getQuestionFromIdentifiers(identifiers);
83
+ };
84
+ const getQuestionFromIdentifiers = (identifiers) => {
85
+ return {
86
+ answer: getAnswer(identifiers),
87
+ instruction: getInstruction(identifiers),
88
+ keys: getKeys(identifiers),
89
+ answerFormat: "tex",
90
+ identifiers,
91
+ hint: getHint(identifiers),
92
+ correction: getCorrection(identifiers),
93
+ };
94
+ };
95
+ export const calculateDistanceWithAbsoluteValue = {
96
+ id: "calculateDistanceWithAbsoluteValue",
97
+ connector: "=",
98
+ label: "Traduire une distance par une valeur absolue",
99
+ isSingleStep: true,
100
+ generator: (nb, opts) => getDistinctQuestions(() => getCalculateDistanceWithAbsoluteValueQuestion(opts), nb),
101
+ qcmTimer: 60,
102
+ freeTimer: 60,
103
+ getPropositions,
104
+ isAnswerValid,
105
+ subject: "Mathématiques",
106
+ getInstruction,
107
+ getHint,
108
+ getCorrection,
109
+ getAnswer,
110
+ getQuestionFromIdentifiers,
111
+ hasHintAndCorrection: true,
112
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ expression: NodeIdentifiers;
5
+ };
6
+ export declare const calculateWithAbsoluteValue: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=calculateWithAbsoluteValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateWithAbsoluteValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/calculateWithAbsoluteValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AAmHF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAkB5D,CAAC"}