math-exercises 3.0.83 → 3.0.85
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.
- package/lib/exercises/math/calcul/arithmetics/decimalBoundingOnLine.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/decimalBoundingOnLine.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/decimalBoundingOnLine.js +171 -0
- package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.js +112 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +3 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +3 -0
- package/lib/exercises/math/calcul/arithmetics/simplifyToFraction.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/simplifyToFraction.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/simplifyToFraction.js +168 -0
- package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.d.ts +10 -0
- package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.d.ts.map +1 -0
- package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.js +100 -0
- package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
- package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/index.js +1 -0
- package/lib/exercises/math/calcul/ordering/framing.d.ts.map +1 -1
- package/lib/exercises/math/calcul/ordering/framing.js +43 -6
- package/lib/exercises/math/functions/absolute/absoluteValueInequations.d.ts.map +1 -1
- package/lib/exercises/math/functions/absolute/absoluteValueInequations.js +34 -1
- package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.d.ts.map +1 -1
- package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.js +26 -1
- package/lib/exercises/math/geometry/index.d.ts +1 -0
- package/lib/exercises/math/geometry/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/index.js +1 -0
- package/lib/exercises/math/geometry/intervals/index.d.ts +2 -0
- package/lib/exercises/math/geometry/intervals/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/intervals/index.js +1 -0
- package/lib/exercises/math/geometry/intervals/intervalOnGraph.d.ts +8 -0
- package/lib/exercises/math/geometry/intervals/intervalOnGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/intervals/intervalOnGraph.js +156 -0
- package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.d.ts +8 -0
- package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.js +96 -0
- package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.d.ts +10 -0
- package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.js +153 -0
- package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.d.ts +10 -0
- package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.js +130 -0
- package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.d.ts +7 -0
- package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.js +90 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts +9 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.js +109 -0
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts +8 -0
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/index.js +7 -0
- package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.d.ts +8 -0
- package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.js +114 -0
- package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.d.ts +8 -0
- package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.js +139 -0
- package/lib/exercises/math/probaStat/basicStats/index.d.ts +1 -0
- package/lib/exercises/math/probaStat/basicStats/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicStats/index.js +1 -0
- package/lib/exercises/math/probaStat/basicStats/samplingFrequency.d.ts +7 -0
- package/lib/exercises/math/probaStat/basicStats/samplingFrequency.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicStats/samplingFrequency.js +106 -0
- package/lib/exercises/math/probaStat/events/describeEvent.d.ts +15 -0
- package/lib/exercises/math/probaStat/events/describeEvent.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/events/describeEvent.js +182 -0
- package/lib/exercises/math/probaStat/events/eventNotation.d.ts +15 -0
- package/lib/exercises/math/probaStat/events/eventNotation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/events/eventNotation.js +156 -0
- package/lib/exercises/math/probaStat/events/index.d.ts +3 -0
- package/lib/exercises/math/probaStat/events/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/events/index.js +2 -0
- package/lib/exercises/math/probaStat/getQuartileProportionQuestion.d.ts +12 -0
- package/lib/exercises/math/probaStat/getQuartileProportionQuestion.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/getQuartileProportionQuestion.js +178 -0
- package/lib/exercises/math/probaStat/index.d.ts +3 -10
- package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/index.js +3 -10
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +35 -52
- package/lib/exercises/math/probaStat/stats1var/averageLinearity.d.ts +16 -0
- package/lib/exercises/math/probaStat/stats1var/averageLinearity.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/averageLinearity.js +217 -0
- package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts +8 -0
- package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +108 -0
- package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.d.ts +4 -1
- package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.js +23 -9
- package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.d.ts +9 -0
- package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.js +139 -0
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts +9 -0
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +105 -0
- package/lib/exercises/math/probaStat/stats1var/index.d.ts +4 -0
- package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/index.js +4 -0
- package/lib/index.d.ts +78 -34
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +4 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +1 -11
- package/lib/tree/nodes/functions/absNode.d.ts +2 -2
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +2 -2
- package/lib/tree/nodes/functions/sqrtNode.d.ts +1 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +2 -1
- package/lib/tree/nodes/numbers/constantNode.d.ts +1 -1
- package/lib/tree/nodes/numbers/constantNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/constantNode.js +2 -1
- package/lib/tree/nodes/operators/fractionNode.js +44 -9
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +14 -4
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
point: PointIdentifiers;
|
|
5
|
+
bounding: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const decimalBoundingOnLine: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=decimalBoundingOnLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimalBoundingOnLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/decimalBoundingOnLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAUtC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAkMF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAmBvD,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { Point, PointConstructor, } from "../../../../math/geometry/point.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
6
|
+
import { round } from "../../../../math/utils/round.js";
|
|
7
|
+
import { InequationNode } from "../../../../tree/nodes/inequations/inequationNode.js";
|
|
8
|
+
import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
|
|
9
|
+
import { doWhile } from "../../../../utils/doWhile.js";
|
|
10
|
+
const getPropositions = (n, context) => {
|
|
11
|
+
const { answer, point, bounding } = context;
|
|
12
|
+
const propositions = [];
|
|
13
|
+
addValidProp(propositions, answer);
|
|
14
|
+
const pointObj = PointConstructor.fromIdentifiers(point);
|
|
15
|
+
const x = round(pointObj.x.evaluate(), 2);
|
|
16
|
+
const vNode = new VariableNode(pointObj.name.toLocaleLowerCase());
|
|
17
|
+
const correctLower = round(Math.floor(x / bounding) * bounding, 2);
|
|
18
|
+
const correctUpper = round(correctLower + bounding, 2);
|
|
19
|
+
while (propositions.length < n) {
|
|
20
|
+
let wrongLower = round(correctLower + randfloat(-2, 2, 1), 1);
|
|
21
|
+
let wrongUpper = round(correctUpper + randfloat(-2, 2, 1), 1);
|
|
22
|
+
const node = new InequationNode([wrongLower.toTree(), vNode, wrongUpper.toTree()], ["<", "<"]);
|
|
23
|
+
tryToAddWrongProp(propositions, node.toTex());
|
|
24
|
+
}
|
|
25
|
+
return shuffleProps(propositions, n);
|
|
26
|
+
};
|
|
27
|
+
const getAnswer = ({ point, bounding }) => {
|
|
28
|
+
const pointObj = PointConstructor.fromIdentifiers(point);
|
|
29
|
+
const x = round(pointObj.x.evaluate(), 2);
|
|
30
|
+
const lowerBound = round(Math.floor(x / bounding) * bounding, 2);
|
|
31
|
+
const upperBound = round(lowerBound + bounding, 2);
|
|
32
|
+
const vNode = new VariableNode(pointObj.name.toLocaleLowerCase());
|
|
33
|
+
const inequation = new InequationNode([lowerBound.toTree(), vNode, upperBound.toTree()], ["<", "<"]);
|
|
34
|
+
return `${inequation.toTex()}`;
|
|
35
|
+
};
|
|
36
|
+
const getInstruction = ({ point, bounding }) => {
|
|
37
|
+
const pointObj = PointConstructor.fromIdentifiers(point);
|
|
38
|
+
return `Déterminer un encadrement décimal d'amplitude $${bounding.frenchify()}$ du nombre réel $${pointObj.name.toLocaleLowerCase()}$.
|
|
39
|
+
|
|
40
|
+
Donner une réponse sous la forme : $x < a < y$.`;
|
|
41
|
+
};
|
|
42
|
+
const getHint = ({ point }) => {
|
|
43
|
+
return `Pour encadrer le nombre, repère les deux nombres décimaux consécutifs de part et d'autre du nombre $${point.name.toLocaleLowerCase()}$. Cela donne un encadrement sous la forme $x<a<y$.
|
|
44
|
+
|
|
45
|
+
Par exemple, un encadrement à $10^{-1}$ de $14,25$ est :
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
14,2 < 14,25 < 14,3
|
|
49
|
+
$$`;
|
|
50
|
+
};
|
|
51
|
+
const getCorrection = ({ point, bounding }) => {
|
|
52
|
+
const pointObj = PointConstructor.fromIdentifiers(point);
|
|
53
|
+
const x = round(pointObj.x.evaluate(), 2);
|
|
54
|
+
const firstDiv = round(x / bounding, 2);
|
|
55
|
+
const quotient = Math.floor(x / bounding);
|
|
56
|
+
const lowerBound = round(quotient * bounding, 2);
|
|
57
|
+
const upperBound = round(lowerBound + bounding, 2);
|
|
58
|
+
const inequation = getAnswer({ point, bounding });
|
|
59
|
+
const name = pointObj.name.toLocaleLowerCase();
|
|
60
|
+
return `On lit sur la droite que $${name} > ${lowerBound.frenchify()}$ et $${name} < ${upperBound.frenchify()}$.
|
|
61
|
+
|
|
62
|
+
Ainsi, un encadrement à $${bounding.frenchify()}$ de $${name}$ est :
|
|
63
|
+
|
|
64
|
+
$$
|
|
65
|
+
${inequation}
|
|
66
|
+
$$`;
|
|
67
|
+
};
|
|
68
|
+
const getGGBOptions = ({ point, bounding }) => {
|
|
69
|
+
const A = PointConstructor.fromIdentifiers(point);
|
|
70
|
+
const commands = [
|
|
71
|
+
...A.toGGBCommand({
|
|
72
|
+
style: 3,
|
|
73
|
+
size: 4,
|
|
74
|
+
label: "a",
|
|
75
|
+
}),
|
|
76
|
+
];
|
|
77
|
+
const ggb = new GeogebraConstructor({
|
|
78
|
+
commands,
|
|
79
|
+
forbidShiftDragZoom: true,
|
|
80
|
+
// gridDistance: [0.5, 1],
|
|
81
|
+
xAxis: {
|
|
82
|
+
hideNumbers: false,
|
|
83
|
+
steps: 0.1,
|
|
84
|
+
},
|
|
85
|
+
yAxis: {
|
|
86
|
+
hidden: true,
|
|
87
|
+
},
|
|
88
|
+
maxHeight: 100,
|
|
89
|
+
fontSize: 20,
|
|
90
|
+
});
|
|
91
|
+
return ggb.getOptions({
|
|
92
|
+
coords: [A.x.evaluate() - 2.2, A.x.evaluate() + 2.2, -0.2, 0.2],
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const getKeys = (identifiers) => {
|
|
96
|
+
return ["inf", "a"];
|
|
97
|
+
};
|
|
98
|
+
function parseInequationFromUser(input) {
|
|
99
|
+
const clean = input.replace(/\\text\{([A-Za-z])\}/g, "$1").replace(/\s/g, "");
|
|
100
|
+
const match = clean.match(/^([-\d,]+)(<|\\leq)([A-Za-z])(<|\\leq)([-\d,]+)$/);
|
|
101
|
+
if (!match)
|
|
102
|
+
return null;
|
|
103
|
+
const [, lowerStr, sym1, variableRaw, sym2, upperStr] = match;
|
|
104
|
+
const symbolMap = {
|
|
105
|
+
"<": "<",
|
|
106
|
+
"\\le": "\\le",
|
|
107
|
+
};
|
|
108
|
+
const variable = variableRaw.toUpperCase();
|
|
109
|
+
return {
|
|
110
|
+
lower: lowerStr.unfrenchify(),
|
|
111
|
+
upper: upperStr.unfrenchify(),
|
|
112
|
+
variable,
|
|
113
|
+
symbols: [symbolMap[sym1], symbolMap[sym2]],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function constructInequationNodeFromParsed(parsed) {
|
|
117
|
+
const lowerNode = parsed.lower.toTree();
|
|
118
|
+
const upperNode = parsed.upper.toTree();
|
|
119
|
+
const variableNode = new VariableNode(parsed.variable);
|
|
120
|
+
return new InequationNode([lowerNode, variableNode, upperNode], parsed.symbols);
|
|
121
|
+
}
|
|
122
|
+
const isAnswerValid = (ans, { point, bounding, answer }) => {
|
|
123
|
+
// const parsed = parseInequationFromUser(ans);
|
|
124
|
+
// if (!parsed) return false;
|
|
125
|
+
// const userNode = constructInequationNodeFromParsed(parsed);
|
|
126
|
+
// return userNode.toTex() === answer;
|
|
127
|
+
return ans === answer;
|
|
128
|
+
};
|
|
129
|
+
const getDecimalBoundingOnLineQuestion = () => {
|
|
130
|
+
const x = doWhile(() => randfloat(-5, 5, 7), (a) => Math.abs(round(a, 1) - a) < 0.025);
|
|
131
|
+
const point = new Point("A", x, 0);
|
|
132
|
+
// const bounding = randfloat(0.1, 0.4, 1);
|
|
133
|
+
const bounding = 0.1;
|
|
134
|
+
const pointIdentifier = point.toIdentifiers();
|
|
135
|
+
const identifiers = {
|
|
136
|
+
point: pointIdentifier,
|
|
137
|
+
bounding,
|
|
138
|
+
};
|
|
139
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
140
|
+
};
|
|
141
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
142
|
+
return {
|
|
143
|
+
answer: getAnswer(identifiers),
|
|
144
|
+
instruction: getInstruction(identifiers),
|
|
145
|
+
keys: getKeys(identifiers),
|
|
146
|
+
answerFormat: "tex",
|
|
147
|
+
identifiers,
|
|
148
|
+
hint: getHint(identifiers),
|
|
149
|
+
correction: getCorrection(identifiers),
|
|
150
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
export const decimalBoundingOnLine = {
|
|
154
|
+
id: "decimalBoundingOnLine",
|
|
155
|
+
label: "Donner un encadrement d’un nombre placé sur une droite graduée",
|
|
156
|
+
isSingleStep: true,
|
|
157
|
+
generator: (nb) => getDistinctQuestions(() => getDecimalBoundingOnLineQuestion(), nb),
|
|
158
|
+
qcmTimer: 60,
|
|
159
|
+
freeTimer: 60,
|
|
160
|
+
getPropositions,
|
|
161
|
+
isAnswerValid,
|
|
162
|
+
subject: "Mathématiques",
|
|
163
|
+
getHint,
|
|
164
|
+
getCorrection,
|
|
165
|
+
getInstruction,
|
|
166
|
+
getAnswer,
|
|
167
|
+
getGGBOptions,
|
|
168
|
+
hasGeogebra: true,
|
|
169
|
+
getQuestionFromIdentifiers,
|
|
170
|
+
hasHintAndCorrection: true,
|
|
171
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
expr: NodeIdentifiers;
|
|
5
|
+
x: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const evalFractionExpression: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=evalFractionExpression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evalFractionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/evalFractionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;IACtB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
4
|
+
import { AffineConstructor } from "../../../../math/polynomials/affine.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
7
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
8
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
9
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
|
+
import { doWhile } from "../../../../utils/doWhile.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
13
|
+
const getPropositions = (n, { answer }) => {
|
|
14
|
+
const propositions = [];
|
|
15
|
+
addValidProp(propositions, answer);
|
|
16
|
+
while (propositions.length < n) {
|
|
17
|
+
const newFrac = RationalConstructor.randomIrreductible().toTree().toTex();
|
|
18
|
+
const a = randint(-10, 11).frenchify();
|
|
19
|
+
const newValue = coinFlip() ? newFrac : a;
|
|
20
|
+
tryToAddWrongProp(propositions, newValue);
|
|
21
|
+
}
|
|
22
|
+
return shuffleProps(propositions, n);
|
|
23
|
+
};
|
|
24
|
+
const getAnswer = (identifiers) => {
|
|
25
|
+
const { expr, x } = identifiers;
|
|
26
|
+
const exprNode = reifyAlgebraic(expr);
|
|
27
|
+
const fractionTex = exprNode
|
|
28
|
+
.toDetailedEvaluation({ x: x.toTree() })
|
|
29
|
+
.simplify()
|
|
30
|
+
.toTex();
|
|
31
|
+
return fractionTex;
|
|
32
|
+
};
|
|
33
|
+
const getInstruction = (identifiers) => {
|
|
34
|
+
const { expr, x } = identifiers;
|
|
35
|
+
const exprTex = reifyAlgebraic(expr).toTex();
|
|
36
|
+
return `On note :
|
|
37
|
+
|
|
38
|
+
$$
|
|
39
|
+
A = ${exprTex}
|
|
40
|
+
$$
|
|
41
|
+
|
|
42
|
+
Calculer, si possible, la valeur de $A$ pour $x = ${x}$.`;
|
|
43
|
+
};
|
|
44
|
+
const getHint = (identifiers) => {
|
|
45
|
+
return `Remplace $x$ par $${identifiers.x}$ dans l'expression, puis simplifie.`;
|
|
46
|
+
};
|
|
47
|
+
const getCorrection = ({ expr, x }) => {
|
|
48
|
+
const exprNode = reifyAlgebraic(expr);
|
|
49
|
+
const replaced = exprNode.toDetailedEvaluation({ x: x.toTree() });
|
|
50
|
+
const simplified = replaced.simplify();
|
|
51
|
+
const exprTex = exprNode.toTex();
|
|
52
|
+
const replacedTex = replaced.toTex();
|
|
53
|
+
const simplifiedTex = simplified.toTex();
|
|
54
|
+
return `On peut bien calculer la valeur de $A$ pour $x = ${x}$, car le dénominateur ne s'annule pas en remplaçant $x$ par $${x}$.
|
|
55
|
+
|
|
56
|
+
On remplace donc $x$ par $${x}$ dans l'expression :
|
|
57
|
+
|
|
58
|
+
${alignTex([
|
|
59
|
+
[exprTex, "=", replacedTex],
|
|
60
|
+
["", "=", simplifiedTex],
|
|
61
|
+
])}
|
|
62
|
+
`;
|
|
63
|
+
};
|
|
64
|
+
const getKeys = (identifiers) => {
|
|
65
|
+
return [];
|
|
66
|
+
};
|
|
67
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
68
|
+
try {
|
|
69
|
+
const ansNode = parseAlgebraic(ans);
|
|
70
|
+
const answerNode = parseAlgebraic(answer);
|
|
71
|
+
return ansNode.simplify().equals(answerNode.simplify());
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
return handleVEAError(err);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const getEvalFractionExpressionQuestion = (ops) => {
|
|
78
|
+
const nominator = AffineConstructor.random().toTree();
|
|
79
|
+
const denominator = AffineConstructor.random().toTree();
|
|
80
|
+
const expr = frac(nominator, denominator);
|
|
81
|
+
const x = doWhile(() => randint(-10, 11), (a) => denominator.evaluate({ x: a }) === 0);
|
|
82
|
+
const identifiers = { expr: expr.toIdentifiers(), x };
|
|
83
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
84
|
+
};
|
|
85
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
86
|
+
return {
|
|
87
|
+
answer: getAnswer(identifiers),
|
|
88
|
+
instruction: getInstruction(identifiers),
|
|
89
|
+
keys: getKeys(identifiers),
|
|
90
|
+
answerFormat: "tex",
|
|
91
|
+
identifiers,
|
|
92
|
+
hint: getHint(identifiers),
|
|
93
|
+
correction: getCorrection(identifiers),
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export const evalFractionExpression = {
|
|
97
|
+
id: "evalFractionExpression",
|
|
98
|
+
label: "Calculer une expression fractionnaire pour une valeur de x donnée",
|
|
99
|
+
isSingleStep: true,
|
|
100
|
+
generator: (nb, opts) => getDistinctQuestions(() => getEvalFractionExpressionQuestion(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
|
+
};
|
|
@@ -25,4 +25,7 @@ export * from "./calculateWithAbsoluteValue.js";
|
|
|
25
25
|
export * from "./sqrtInequality.js";
|
|
26
26
|
export * from "./calculateDistanceWithAbsoluteValue.js";
|
|
27
27
|
export * from "./isNumberInInterval.js";
|
|
28
|
+
export * from "./evalFractionExpression.js";
|
|
29
|
+
export * from "./simplifyToFraction.js";
|
|
30
|
+
export * from "./decimalBoundingOnLine.js";
|
|
28
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
|
|
@@ -25,3 +25,6 @@ export * from "./calculateWithAbsoluteValue.js";
|
|
|
25
25
|
export * from "./sqrtInequality.js";
|
|
26
26
|
export * from "./calculateDistanceWithAbsoluteValue.js";
|
|
27
27
|
export * from "./isNumberInInterval.js";
|
|
28
|
+
export * from "./evalFractionExpression.js";
|
|
29
|
+
export * from "./simplifyToFraction.js";
|
|
30
|
+
export * from "./decimalBoundingOnLine.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
type: number;
|
|
5
|
+
expr: NodeIdentifiers;
|
|
6
|
+
};
|
|
7
|
+
export declare const simplifyToFraction: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=simplifyToFraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplifyToFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/simplifyToFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAoB7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAqKF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAiBpD,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
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 { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
5
|
+
import { add, isAddNode } from "../../../../tree/nodes/operators/addNode.js";
|
|
6
|
+
import { frac, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
7
|
+
import { isMultiplyNode, multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
8
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
9
|
+
import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
|
|
10
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
11
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
12
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
13
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
14
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
15
|
+
const getPropositions = (n, { answer }) => {
|
|
16
|
+
const propositions = [];
|
|
17
|
+
addValidProp(propositions, answer);
|
|
18
|
+
while (propositions.length < n) {
|
|
19
|
+
const a = randint(-10, 11, [0]);
|
|
20
|
+
const b = randint(-10, 11, [0]);
|
|
21
|
+
const powerExpr = power("x", randint(2, 5));
|
|
22
|
+
const expressions = [
|
|
23
|
+
add(a, frac(b, "x")),
|
|
24
|
+
multiply(frac(a, powerExpr), frac(b, powerExpr)),
|
|
25
|
+
multiply(frac(powerExpr, a), frac(powerExpr, b)),
|
|
26
|
+
];
|
|
27
|
+
const chosenExpr = random(expressions).simplify({
|
|
28
|
+
calculatePowers: true,
|
|
29
|
+
keepPowers: true,
|
|
30
|
+
});
|
|
31
|
+
tryToAddWrongProp(propositions, chosenExpr.toTex());
|
|
32
|
+
}
|
|
33
|
+
return shuffleProps(propositions, n);
|
|
34
|
+
};
|
|
35
|
+
const getAnswer = (identifiers) => {
|
|
36
|
+
const { expr } = identifiers;
|
|
37
|
+
const exprNode = reifyAlgebraic(expr);
|
|
38
|
+
const simplified = exprNode.simplify({ forbidFactorize: true });
|
|
39
|
+
return `${simplified.toTex()}`;
|
|
40
|
+
};
|
|
41
|
+
const getInstruction = (identifiers) => {
|
|
42
|
+
const { expr } = identifiers;
|
|
43
|
+
const exprNode = reifyAlgebraic(expr);
|
|
44
|
+
return `Écrire l'expression suivante sous forme d'une fraction :
|
|
45
|
+
|
|
46
|
+
$$
|
|
47
|
+
${exprNode.toTex()}
|
|
48
|
+
$$`;
|
|
49
|
+
};
|
|
50
|
+
const getHint = ({ expr }) => {
|
|
51
|
+
const exprNode = reifyAlgebraic(expr);
|
|
52
|
+
if (isAddNode(exprNode)) {
|
|
53
|
+
return `Écris le nombre entier sous la forme d'un fraction, en le mettant au même dénominateur que la fraction. Puis, additionne les deux fractions obtenues.`;
|
|
54
|
+
}
|
|
55
|
+
return `Multiplie les deux fractions entre elles (en multipliant les numérateurs entre eux et les dénominateurs entre eux). Puis, simplifie la fraction obtenue.`;
|
|
56
|
+
};
|
|
57
|
+
const getCorrection = ({ expr }) => {
|
|
58
|
+
const exprNode = reifyAlgebraic(expr);
|
|
59
|
+
const simplified = exprNode.simplify({ forbidFactorize: true });
|
|
60
|
+
let explanation = ``;
|
|
61
|
+
if (isAddNode(exprNode)) {
|
|
62
|
+
const entier = exprNode.leftChild;
|
|
63
|
+
const fraction = exprNode.rightChild;
|
|
64
|
+
explanation += `On met les deux termes au même dénominateur pour les additionner :
|
|
65
|
+
|
|
66
|
+
${alignTex([
|
|
67
|
+
[
|
|
68
|
+
exprNode.toTex(),
|
|
69
|
+
"=",
|
|
70
|
+
add(frac(multiply(entier, fraction.rightChild), fraction.rightChild), fraction).toTex(),
|
|
71
|
+
],
|
|
72
|
+
["", "=", simplified.toTex()],
|
|
73
|
+
])}`;
|
|
74
|
+
}
|
|
75
|
+
else if (isMultiplyNode(exprNode)) {
|
|
76
|
+
const frac1 = exprNode.leftChild;
|
|
77
|
+
const frac2 = exprNode.rightChild;
|
|
78
|
+
explanation += `
|
|
79
|
+
On multiplie les fractions, puis on simplifie :
|
|
80
|
+
|
|
81
|
+
${alignTex([
|
|
82
|
+
[
|
|
83
|
+
exprNode.toTex(),
|
|
84
|
+
"=",
|
|
85
|
+
frac(multiply(frac1.leftChild, frac2.leftChild), multiply(frac1.rightChild, frac2.rightChild)).toTex(),
|
|
86
|
+
],
|
|
87
|
+
["", "=", simplified.toTex()],
|
|
88
|
+
])}`;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const num = exprNode.leftChild;
|
|
92
|
+
const denum = exprNode.rightChild;
|
|
93
|
+
explanation += `Diviser par une fraction revient à multiplier par son inverse. On a donc :
|
|
94
|
+
|
|
95
|
+
${alignTex([
|
|
96
|
+
[exprNode.toTex(), "=", multiply(num, denum.toInversed()).toTex()],
|
|
97
|
+
["", "=", simplified.toTex()],
|
|
98
|
+
])}`;
|
|
99
|
+
}
|
|
100
|
+
return explanation;
|
|
101
|
+
};
|
|
102
|
+
const getKeys = (identifiers) => {
|
|
103
|
+
return [];
|
|
104
|
+
};
|
|
105
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
106
|
+
try {
|
|
107
|
+
const ansNode = parseAlgebraic(ans);
|
|
108
|
+
return ansNode.simplify({ forbidFactorize: true }).toTex() === answer;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
return handleVEAError(err);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const getSimplifyToFractionQuestion = (ops) => {
|
|
115
|
+
const type = randint(1, 4);
|
|
116
|
+
const a = randint(-10, 11, [-1, 0, 1]);
|
|
117
|
+
const b = randint(-10, 11, [-1, 0, 1]);
|
|
118
|
+
const powerA = randint(1, 5);
|
|
119
|
+
const powerB = randint(1, 5, type === 3 ? [powerA] : []);
|
|
120
|
+
const powerANode = powerA === 1 ? new VariableNode("x") : power("x", powerA);
|
|
121
|
+
const powerBNode = powerB === 1 ? new VariableNode("x") : power("x", powerB);
|
|
122
|
+
let expr;
|
|
123
|
+
let order = [];
|
|
124
|
+
switch (type) {
|
|
125
|
+
case 1:
|
|
126
|
+
expr = add(a, frac(b, "x")).toIdentifiers();
|
|
127
|
+
break;
|
|
128
|
+
case 2:
|
|
129
|
+
order = shuffle([a.toTree(), b.toTree(), powerANode, powerBNode]);
|
|
130
|
+
expr = multiply(frac(order[0], order[1]), frac(order[2], order[3])).toIdentifiers();
|
|
131
|
+
break;
|
|
132
|
+
case 3:
|
|
133
|
+
default:
|
|
134
|
+
order = shuffle([a.toTree(), powerANode, powerBNode]);
|
|
135
|
+
expr = frac(order[0], frac(order[1], order[2])).toIdentifiers();
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
const identifiers = { type, expr };
|
|
139
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
140
|
+
};
|
|
141
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
142
|
+
return {
|
|
143
|
+
answer: getAnswer(identifiers),
|
|
144
|
+
instruction: getInstruction(identifiers),
|
|
145
|
+
keys: getKeys(identifiers),
|
|
146
|
+
answerFormat: "tex",
|
|
147
|
+
identifiers,
|
|
148
|
+
hint: getHint(identifiers),
|
|
149
|
+
correction: getCorrection(identifiers),
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export const simplifyToFraction = {
|
|
153
|
+
id: "simplifyToFraction",
|
|
154
|
+
label: "Écrire sous la forme d'une expression fractionnaire",
|
|
155
|
+
isSingleStep: true,
|
|
156
|
+
generator: (nb, opts) => getDistinctQuestions(() => getSimplifyToFractionQuestion(opts), nb),
|
|
157
|
+
qcmTimer: 60,
|
|
158
|
+
freeTimer: 60,
|
|
159
|
+
getPropositions,
|
|
160
|
+
isAnswerValid,
|
|
161
|
+
subject: "Mathématiques",
|
|
162
|
+
getInstruction,
|
|
163
|
+
getHint,
|
|
164
|
+
getCorrection,
|
|
165
|
+
getAnswer,
|
|
166
|
+
getQuestionFromIdentifiers,
|
|
167
|
+
hasHintAndCorrection: true,
|
|
168
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
c: number;
|
|
6
|
+
d: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const fractionForbiddenValue: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=fractionForbiddenValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fractionForbiddenValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionForbiddenValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { Rational } from "../../../../math/numbers/rationals/rational.js";
|
|
4
|
+
import { Affine } from "../../../../math/polynomials/affine.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { equationResolutionTex } from "../../../../tree/nodes/equations/equalNode.js";
|
|
7
|
+
import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
8
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
9
|
+
const getInstruction = (identifiers) => {
|
|
10
|
+
const { a, b, c, d } = identifiers;
|
|
11
|
+
const affine1 = new Affine(a, b);
|
|
12
|
+
const affine2 = new Affine(c, d);
|
|
13
|
+
const fct = new FractionNode(affine1.toTree(), affine2.toTree());
|
|
14
|
+
const fctTex = fct.toTex();
|
|
15
|
+
return `On note :
|
|
16
|
+
|
|
17
|
+
$$
|
|
18
|
+
A = ${fctTex}
|
|
19
|
+
$$
|
|
20
|
+
|
|
21
|
+
Pour quelle valeur de $x$ ne peut-on pas calculer $A$ ?`;
|
|
22
|
+
};
|
|
23
|
+
const getAnswer = (identifiers) => {
|
|
24
|
+
const { a, b, c, d } = identifiers;
|
|
25
|
+
const answerTree = new Rational(-d, c).simplify().toTree();
|
|
26
|
+
const answer = answerTree.toTex();
|
|
27
|
+
return answer;
|
|
28
|
+
};
|
|
29
|
+
const getHint = (identifiers) => {
|
|
30
|
+
return `Il est interdit de diviser par $0$. Cherche donc la valeur de $x$ pour laquelle le dénominateur de $A$ vaut $0$.`;
|
|
31
|
+
};
|
|
32
|
+
const getCorrection = (identifiers) => {
|
|
33
|
+
const { a, b, c, d } = identifiers;
|
|
34
|
+
const equa = equationResolutionTex(c.toTree(), d.toTree(), (0).toTree(), (0).toTree());
|
|
35
|
+
return `On cherche la valeur de $x$ qui rend le dénominateur de $A$ nul.
|
|
36
|
+
|
|
37
|
+
On résout donc l'équation :
|
|
38
|
+
|
|
39
|
+
$$
|
|
40
|
+
${equa}
|
|
41
|
+
$$
|
|
42
|
+
|
|
43
|
+
On ne peut donc pas calculer $A$ pour $x = ${getAnswer(identifiers)}$.
|
|
44
|
+
`;
|
|
45
|
+
};
|
|
46
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
47
|
+
const question = {
|
|
48
|
+
answer: getAnswer(identifiers),
|
|
49
|
+
instruction: getInstruction(identifiers),
|
|
50
|
+
keys: [],
|
|
51
|
+
answerFormat: "tex",
|
|
52
|
+
identifiers,
|
|
53
|
+
hint: getHint(identifiers),
|
|
54
|
+
correction: getCorrection(identifiers),
|
|
55
|
+
};
|
|
56
|
+
return question;
|
|
57
|
+
};
|
|
58
|
+
const getRationalFractionForbiddenValueQuestion = () => {
|
|
59
|
+
const a = randint(-10, 11, [0]);
|
|
60
|
+
const b = randint(-10, 11);
|
|
61
|
+
//pour éviter affine2 = k*affine1
|
|
62
|
+
let c, d;
|
|
63
|
+
do {
|
|
64
|
+
c = randint(-10, 11, [0]);
|
|
65
|
+
d = randint(-10, 11);
|
|
66
|
+
} while (a * d - b * c === 0);
|
|
67
|
+
const identifiers = { a, b, c, d };
|
|
68
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
69
|
+
};
|
|
70
|
+
const getPropositions = (n, { answer, a, b, c, d }) => {
|
|
71
|
+
const propositions = [];
|
|
72
|
+
addValidProp(propositions, answer);
|
|
73
|
+
tryToAddWrongProp(propositions, new Rational(-b, a).simplify().toTree().toTex());
|
|
74
|
+
tryToAddWrongProp(propositions, d + "");
|
|
75
|
+
while (propositions.length < n) {
|
|
76
|
+
tryToAddWrongProp(propositions, randint(-10, 11) + "");
|
|
77
|
+
}
|
|
78
|
+
return shuffle(propositions);
|
|
79
|
+
};
|
|
80
|
+
const isAnswerValid = (ans, { c, d }) => {
|
|
81
|
+
const answerTree = new Rational(-d, c)
|
|
82
|
+
.simplify()
|
|
83
|
+
.toTree({ allowFractionToDecimal: true });
|
|
84
|
+
const texs = answerTree.toAllValidTexs();
|
|
85
|
+
return texs.includes(ans);
|
|
86
|
+
};
|
|
87
|
+
export const fractionForbiddenValue = {
|
|
88
|
+
id: "fractionForbiddenValue",
|
|
89
|
+
connector: "=",
|
|
90
|
+
label: "Déterminer la valeur interdite d'une fraction",
|
|
91
|
+
isSingleStep: true,
|
|
92
|
+
generator: (nb) => getDistinctQuestions(getRationalFractionForbiddenValueQuestion, nb),
|
|
93
|
+
qcmTimer: 60,
|
|
94
|
+
freeTimer: 60,
|
|
95
|
+
getPropositions,
|
|
96
|
+
isAnswerValid,
|
|
97
|
+
subject: "Mathématiques",
|
|
98
|
+
getQuestionFromIdentifiers,
|
|
99
|
+
hasHintAndCorrection: true,
|
|
100
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framing.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/framing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"framing.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/framing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AA+NF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAczC,CAAC"}
|