math-exercises 3.0.123 → 3.0.125
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/primeNumbers.d.ts +1 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +20 -14
- package/lib/exercises/math/calcul/fractions/fractionsMix.js +1 -1
- package/lib/exercises/math/conversion/volumeConversion.d.ts.map +1 -1
- package/lib/exercises/math/conversion/volumeConversion.js +7 -1
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.js +9 -3
- package/lib/exercises/math/functions/affines/affineFromExercise.d.ts +1 -1
- package/lib/exercises/math/functions/affines/affineFromExercise.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineFromExercise.js +123 -48
- package/lib/exercises/math/functions/affines/drawAffineFromLitExp.js +5 -5
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts +2 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.js +41 -24
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +29 -2
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +72 -61
- package/lib/exercises/math/functions/logarithm/powerEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/powerEquation.js +0 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.js +41 -16
- package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +3 -2
- package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts +1 -0
- package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.js +21 -13
- package/lib/exercises/math/geometry/perimeters/circleCircumference.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/circleCircumference.js +15 -7
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.d.ts.map +1 -1
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.js +5 -3
- package/lib/exercises/math/geometry/vectors/vectorLinearCombination.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/vectorLinearCombination.js +0 -1
- package/lib/exercises/math/percent/evolutions/evolutionToCM.js +2 -2
- package/lib/exercises/math/percent/findProportion.d.ts +6 -1
- package/lib/exercises/math/percent/findProportion.d.ts.map +1 -1
- package/lib/exercises/math/percent/findProportion.js +162 -45
- package/lib/exercises/math/powers/calculateNegativePower.d.ts +5 -1
- package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
- package/lib/exercises/math/powers/calculateNegativePower.js +93 -29
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +10 -2
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +2 -1
- package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts +4 -1
- package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/quartilesList.js +46 -27
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +14 -2
- package/lib/exercises/math/sequences/geometric/geometricReasonUsage.d.ts +1 -0
- package/lib/exercises/math/sequences/geometric/geometricReasonUsage.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricReasonUsage.js +43 -19
- package/lib/exercises/math/sequences/sequenceEvaluation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/sequenceEvaluation.js +18 -1
- package/lib/exercises/pc/chemicalReactions/chemicalEquations.d.ts.map +1 -1
- package/lib/exercises/pc/chemicalReactions/chemicalEquations.js +17 -2
- package/lib/exercises/pc/mole/molarMass.d.ts.map +1 -1
- package/lib/exercises/pc/mole/molarMass.js +7 -1
- package/lib/exercises/pc/motion/averageSpeed.d.ts +9 -4
- package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
- package/lib/exercises/pc/motion/averageSpeed.js +132 -61
- package/lib/exercises/pc/motion/averageSpeedCalculation.d.ts.map +1 -1
- package/lib/exercises/pc/motion/averageSpeedCalculation.js +10 -4
- package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.d.ts +2 -2
- package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.js +15 -15
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts.map +1 -1
- package/lib/exercises/utils/geogebra/toolBarConstructor.js +3 -1
- package/lib/index.d.ts +49 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/pc/units/timeUnits.d.ts +5 -3
- package/lib/pc/units/timeUnits.d.ts.map +1 -1
- package/lib/pc/units/timeUnits.js +25 -19
- package/package.json +1 -1
|
@@ -1,60 +1,143 @@
|
|
|
1
|
-
import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
1
|
+
import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
-
import { rationalVEA } from "../../../exercises/vea/rationalVEA.js";
|
|
4
3
|
import { randfloat } from "../../../math/utils/random/randfloat.js";
|
|
5
4
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
6
5
|
import { round } from "../../../math/utils/round.js";
|
|
7
|
-
import { frac } from "../../../tree/nodes/operators/fractionNode.js";
|
|
8
6
|
import { percentParser } from "../../../tree/parsers/percentParser.js";
|
|
7
|
+
import { random } from "../../../utils/alea/random.js";
|
|
9
8
|
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
10
9
|
import { approxOrEqual } from "../../../utils/latex/approxOrEqual.js";
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const situations = [
|
|
11
|
+
{
|
|
12
|
+
instruction: (total, lefties) => `${random([
|
|
13
|
+
`Dans un lycée de $${total}$ élèves, $${lefties}$ sont gauchers.`,
|
|
14
|
+
`Dans un lycée, $${lefties}$ élèves sont gauchers sur un total de $${total}$ élèves.`,
|
|
15
|
+
])}
|
|
16
|
+
Quelle est la proportion de gauchers dans ce lycée, en pourcentage ?`,
|
|
17
|
+
hint: `La proportion de gauchers en pourcents s'obtient par la formule :
|
|
18
|
+
|
|
19
|
+
$$
|
|
20
|
+
\\frac{\\text{nombre de gauchers}}{\\text{nombre total d'élèves}}\\times 100
|
|
21
|
+
$$
|
|
22
|
+
`,
|
|
23
|
+
correction: `La proportion de gauchers en pourcentage dans ce lycée est de`,
|
|
24
|
+
randTotal: () => randint(500, 2000),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
instruction: (total, lefties) => `${random([
|
|
28
|
+
`Dans une casse automobile, il y a $${total}$ voitures dont $${lefties}$ ont le volant à gauche.`,
|
|
29
|
+
`Dans une casse automobile, $${lefties}$ voitures ont le volant à gauche. Il y a au total $${total}$ voitures.`,
|
|
30
|
+
])}
|
|
31
|
+
Quelle est la proportion de voitures avec le volant à gauche dans cette casse, en pourcentage ?`,
|
|
32
|
+
hint: `La proportion, en pourcents, de voitures avec le volant à gauche s'obtient par la formule :
|
|
33
|
+
|
|
34
|
+
$$
|
|
35
|
+
\\frac{\\text{nombre de voitures avec volant à gauche}}{\\text{nombre total de voitures}}\\times 100
|
|
36
|
+
$$
|
|
37
|
+
`,
|
|
38
|
+
correction: `La proportion, en pourcentage, de voitures avec le volant à gauche est de`,
|
|
39
|
+
randTotal: () => randint(100, 500),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
instruction: (total, lefties) => `${random([
|
|
43
|
+
`Dans un restaurant italien, sur un total de $${total}$ clients, $${lefties}$ ont commandé des pâtes.`,
|
|
44
|
+
`Dans un restaurant italien, $${lefties}$ clients ont commandé des pâtes. Il y a au total $${total}$ clients.`,
|
|
45
|
+
])}
|
|
46
|
+
Quelle est la proportion de clients qui ont commandé des pâtes, en pourcentage ?`,
|
|
47
|
+
hint: `La proportion en pourcents de clients qui ont commandé des pâtes s'obtient par la formule :
|
|
48
|
+
|
|
49
|
+
$$
|
|
50
|
+
\\frac{\\text{nombre de clients ayant commandé des pâtes}}{\\text{nombre total de clients}}\\times 100
|
|
51
|
+
$$
|
|
52
|
+
`,
|
|
53
|
+
correction: `La proportion en pourcentage de clients ayant commandé des pâtes est de`,
|
|
54
|
+
randTotal: () => randint(30, 200),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
instruction: (total, lefties) => `${random([
|
|
58
|
+
`Dans une cagette de $${total}$ pommes, $${lefties}$ sont véreuses.`,
|
|
59
|
+
`Dans une cagette de pommes, $${lefties}$ sont véreuses. Il y a au total $${total}$ pommes.`,
|
|
60
|
+
])}
|
|
61
|
+
Quelle est la proportion de pommes véreuses dans la cagette, en pourcentage ?`,
|
|
62
|
+
hint: `La proportion, en pourcents, de pommes véreuses s'obtient par la formule :
|
|
17
63
|
|
|
18
64
|
$$
|
|
19
|
-
\\frac{\\text{nombre de
|
|
65
|
+
\\frac{\\text{nombre de pommes véreuses}}{\\text{nombre total de pommes}}\\times 100
|
|
20
66
|
$$
|
|
21
|
-
|
|
67
|
+
`,
|
|
68
|
+
correction: `La proportion, en pourcentage, de pommes véreuses est de`,
|
|
69
|
+
randTotal: () => randint(30, 100),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
instruction: (total, lefties) => `${random([
|
|
73
|
+
`Dans un car scolaire transportant $${total}$ élèves, $${lefties}$ sont du côté gauche.`,
|
|
74
|
+
`Dans un car scolaire, $${lefties}$ élèves sont du côté gauche. Le car transporte $${total}$ élèves.`,
|
|
75
|
+
])}
|
|
76
|
+
Quelle est la proportion d'élèves du côté gauche du car, en pourcentage ?`,
|
|
77
|
+
hint: `La proportion en pourcents d'élèves du gauche du car s'obtient par la formule :
|
|
78
|
+
|
|
79
|
+
$$
|
|
80
|
+
\\frac{\\text{nombre d'élèves du côté gauche}}{\\text{nombre d'élèves dans le car}}\\times 100
|
|
81
|
+
$$
|
|
82
|
+
`,
|
|
83
|
+
correction: `La proportion en pourcentage d'élèves du côté gauche est de`,
|
|
84
|
+
randTotal: () => randint(20, 40),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
instruction: (total, lefties) => `${random([
|
|
88
|
+
`Dans un champ, au mois de septembre, sur $${total}$ champignons, $${lefties}$ sont vénéneux.`,
|
|
89
|
+
`Dans un champ, au mois de septembre, $${lefties}$ champignons sont vénéneux sur un total de $${total}$ champignons.`,
|
|
90
|
+
])}
|
|
91
|
+
Quelle est la proportion de champignons vénéneux dans ce champ, en pourcentage ?`,
|
|
92
|
+
hint: `La proportion de champignons vénéneux dans ce champ, en pourcents, s'obtient par la formule :
|
|
93
|
+
|
|
94
|
+
$$
|
|
95
|
+
\\frac{\\text{nombre de champignons vénéneux}}{\\text{nombre total de champignons}}\\times 100
|
|
96
|
+
$$
|
|
97
|
+
`,
|
|
98
|
+
correction: `La proportion en pourcentage de champignons vénéneux dans ce champ est de`,
|
|
99
|
+
randTotal: () => randint(20, 400),
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
const getInstruction = (identifiers) => {
|
|
103
|
+
const { indexSituation, total, lefties, opts } = identifiers;
|
|
104
|
+
const situation = situations[indexSituation];
|
|
105
|
+
return `${situation.instruction(total, lefties)}
|
|
106
|
+
|
|
107
|
+
Arrondir au centième de pourcent.
|
|
108
|
+
${opts.isPercentSymbolRequired
|
|
109
|
+
? `
|
|
110
|
+
|
|
111
|
+
Ne pas oublier le symbole $\\%$ à la fin.`
|
|
112
|
+
: ``}`;
|
|
113
|
+
};
|
|
114
|
+
const getHint = (identifiers) => {
|
|
115
|
+
const { indexSituation } = identifiers;
|
|
116
|
+
const situation = situations[indexSituation];
|
|
117
|
+
return situation.hint;
|
|
22
118
|
};
|
|
23
119
|
const getCorrection = (identifiers) => {
|
|
24
|
-
const { total, lefties } = identifiers;
|
|
120
|
+
const { indexSituation, total, lefties, opts } = identifiers;
|
|
121
|
+
const situation = situations[indexSituation];
|
|
25
122
|
const frac = (100 * lefties) / total;
|
|
26
|
-
return `
|
|
123
|
+
return `On a :
|
|
27
124
|
|
|
28
125
|
$$
|
|
29
126
|
\\frac{${lefties}}{${total}}\\times 100 ${approxOrEqual(frac, 2).join("")}
|
|
30
127
|
$$
|
|
31
128
|
|
|
32
|
-
|
|
33
|
-
|
|
129
|
+
${situation.correction} $${getAnswer(identifiers)}$.
|
|
130
|
+
${opts.isPercentSymbolRequired
|
|
131
|
+
? `
|
|
132
|
+
|
|
133
|
+
Attention, ici le symbole "$\\%$" est requis à la fin.`
|
|
134
|
+
: ``}`;
|
|
34
135
|
};
|
|
35
136
|
const getAnswer = (identifiers) => {
|
|
36
137
|
const { total, lefties } = identifiers;
|
|
37
138
|
const answer = round((lefties / total) * 100, 2).frenchify() + "\\%";
|
|
38
139
|
return answer;
|
|
39
140
|
};
|
|
40
|
-
const getFindProportionQuestion = () => {
|
|
41
|
-
const total = randint(120, 200);
|
|
42
|
-
const lefties = randint(30, 120);
|
|
43
|
-
const identifiers = { total, lefties };
|
|
44
|
-
return getQuestionFromIdentifiers(identifiers);
|
|
45
|
-
};
|
|
46
|
-
const getQuestionFromIdentifiers = (identifiers) => {
|
|
47
|
-
const question = {
|
|
48
|
-
answer: getAnswer(identifiers),
|
|
49
|
-
instruction: getInstruction(identifiers),
|
|
50
|
-
keys: ["percent"],
|
|
51
|
-
answerFormat: "tex",
|
|
52
|
-
identifiers,
|
|
53
|
-
hint: getHint(identifiers),
|
|
54
|
-
correction: getCorrection(identifiers),
|
|
55
|
-
};
|
|
56
|
-
return question;
|
|
57
|
-
};
|
|
58
141
|
const getPropositions = (n, { answer, total, lefties }) => {
|
|
59
142
|
const propositions = [];
|
|
60
143
|
addValidProp(propositions, answer);
|
|
@@ -64,32 +147,66 @@ const getPropositions = (n, { answer, total, lefties }) => {
|
|
|
64
147
|
});
|
|
65
148
|
return shuffleProps(propositions, n);
|
|
66
149
|
};
|
|
67
|
-
const isAnswerValid = (ans, { answer,
|
|
150
|
+
const isAnswerValid = (ans, { answer, opts }) => {
|
|
68
151
|
try {
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
152
|
+
if (opts.isPercentSymbolRequired) {
|
|
153
|
+
if (!ans.includes("\\%")) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return percentParser(ans) === answer;
|
|
158
|
+
}
|
|
76
159
|
}
|
|
77
160
|
else {
|
|
78
|
-
|
|
161
|
+
const texs = [answer, answer.replace("\\%", "")];
|
|
162
|
+
return texs.includes(ans);
|
|
79
163
|
}
|
|
80
164
|
}
|
|
81
165
|
catch (err) {
|
|
82
166
|
return handleVEAError(err);
|
|
83
167
|
}
|
|
84
|
-
const texs = [answer, answer.replace("\\%", "")];
|
|
85
|
-
return texs.includes(ans);
|
|
86
168
|
};
|
|
169
|
+
const getFindProportionQuestion = (optsIn) => {
|
|
170
|
+
const opts = optsIn ?? optsDefault;
|
|
171
|
+
const indexSituation = randint(0, situations.length);
|
|
172
|
+
const situation = situations[indexSituation];
|
|
173
|
+
const total = situation.randTotal();
|
|
174
|
+
const lefties = round(randfloat(0.1, 0.9) * total, 0);
|
|
175
|
+
return getQuestionFromIdentifiers({ indexSituation, total, lefties, opts });
|
|
176
|
+
};
|
|
177
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
178
|
+
const question = {
|
|
179
|
+
answer: getAnswer(identifiers),
|
|
180
|
+
instruction: getInstruction(identifiers),
|
|
181
|
+
keys: ["percent"],
|
|
182
|
+
answerFormat: "tex",
|
|
183
|
+
identifiers,
|
|
184
|
+
hint: getHint(identifiers),
|
|
185
|
+
correction: getCorrection(identifiers),
|
|
186
|
+
options: opts,
|
|
187
|
+
};
|
|
188
|
+
return question;
|
|
189
|
+
};
|
|
190
|
+
const optsDefault = {
|
|
191
|
+
isPercentSymbolRequired: false,
|
|
192
|
+
};
|
|
193
|
+
const options = [
|
|
194
|
+
{
|
|
195
|
+
id: "isPercentSymbolRequired",
|
|
196
|
+
label: "Symbole pourcent requis",
|
|
197
|
+
target: GeneratorOptionTarget.generation,
|
|
198
|
+
type: GeneratorOptionType.checkbox,
|
|
199
|
+
values: [false, true],
|
|
200
|
+
defaultValue: optsDefault.isPercentSymbolRequired,
|
|
201
|
+
},
|
|
202
|
+
];
|
|
87
203
|
export const findProportion = {
|
|
88
204
|
id: "findProportion",
|
|
89
205
|
connector: "=",
|
|
90
206
|
label: "Calculer une proportion en pourcentage",
|
|
91
207
|
isSingleStep: true,
|
|
92
|
-
generator: (nb) => getDistinctQuestions(getFindProportionQuestion, nb),
|
|
208
|
+
generator: (nb, opts) => getDistinctQuestions(() => getFindProportionQuestion(opts), nb),
|
|
209
|
+
options,
|
|
93
210
|
qcmTimer: 60,
|
|
94
211
|
freeTimer: 60,
|
|
95
212
|
getPropositions,
|
|
@@ -2,7 +2,11 @@ import { Exercise } from "../../../exercises/exercise.js";
|
|
|
2
2
|
type Identifiers = {
|
|
3
3
|
int: number;
|
|
4
4
|
power: number;
|
|
5
|
+
opts: Options;
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
type Options = {
|
|
8
|
+
isPowerAllowed: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const calculateNegativePower: Exercise<Identifiers, Options>;
|
|
7
11
|
export {};
|
|
8
12
|
//# sourceMappingURL=calculateNegativePower.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateNegativePower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/calculateNegativePower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"calculateNegativePower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/calculateNegativePower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AA0CrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA4JF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAeF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBjE,CAAC"}
|
|
@@ -1,23 +1,47 @@
|
|
|
1
|
-
import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
1
|
+
import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
4
|
+
import { isFunctionNode } from "../../../tree/nodes/functions/functionNode.js";
|
|
4
5
|
import { isNumberNode, NumberNode, } from "../../../tree/nodes/numbers/numberNode.js";
|
|
5
6
|
import { frac, isFractionNode, } from "../../../tree/nodes/operators/fractionNode.js";
|
|
7
|
+
import { isOperatorNode, OperatorIds, } from "../../../tree/nodes/operators/operatorNode.js";
|
|
6
8
|
import { PowerNode } from "../../../tree/nodes/operators/powerNode.js";
|
|
7
9
|
import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
|
|
8
10
|
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
11
|
+
const isNodeContainingOperatorId = (node, opId) => {
|
|
12
|
+
if (isFunctionNode(node)) {
|
|
13
|
+
return isNodeContainingOperatorId(node.child, opId);
|
|
14
|
+
}
|
|
15
|
+
else if (isOperatorNode(node)) {
|
|
16
|
+
if (node.id === opId) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return (isNodeContainingOperatorId(node.leftChild, opId) ||
|
|
21
|
+
isNodeContainingOperatorId(node.rightChild, opId));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
9
28
|
const getInstruction = (identifiers) => {
|
|
10
|
-
const { int, power } = identifiers;
|
|
29
|
+
const { int, power, opts } = identifiers;
|
|
11
30
|
const statement = new PowerNode(new NumberNode(int), new NumberNode(power)).toTex();
|
|
12
31
|
return `Calculer et donner le résultat sous la forme d'une fraction ou d'un entier :
|
|
13
32
|
|
|
14
33
|
$$
|
|
15
34
|
${statement}
|
|
16
|
-
|
|
35
|
+
$$
|
|
36
|
+
|
|
37
|
+
${opts.isPowerAllowed
|
|
38
|
+
? `La réponse pourra comporter un exposant.`
|
|
39
|
+
: `La réponse ne devra comporter aucun exposant.`}`;
|
|
17
40
|
};
|
|
18
41
|
const getAnswer = (identifiers) => {
|
|
19
|
-
const { int, power } = identifiers;
|
|
20
|
-
const
|
|
42
|
+
const { int, power, opts } = identifiers;
|
|
43
|
+
const powerNode = new PowerNode(int.toTree(), Math.abs(power).toTree());
|
|
44
|
+
const fraction = frac(1, opts.isPowerAllowed ? powerNode : powerNode.evaluate().toTree());
|
|
21
45
|
const answer = fraction.simplify();
|
|
22
46
|
return answer.toTex();
|
|
23
47
|
};
|
|
@@ -29,32 +53,35 @@ a^{-x} = \\frac{1}{a^x}
|
|
|
29
53
|
$$`;
|
|
30
54
|
};
|
|
31
55
|
const getCorrection = (identifiers) => {
|
|
32
|
-
const { int, power } = identifiers;
|
|
56
|
+
const { int, power, opts } = identifiers;
|
|
33
57
|
const statement = new PowerNode(new NumberNode(int), new NumberNode(power)).toTex();
|
|
34
58
|
const fraction = frac(1, new PowerNode(int.toTree(), Math.abs(power).toTree()));
|
|
59
|
+
const simplificationTex = fraction.toSimplificationTex();
|
|
35
60
|
return `Puisque $a^{-x} = \\frac{1}{a^x}$, on a :
|
|
36
61
|
|
|
37
62
|
$$
|
|
38
|
-
${statement} = ${
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
${statement} = ${simplificationTex}
|
|
64
|
+
$$
|
|
65
|
+
|
|
66
|
+
${(() => {
|
|
67
|
+
if (!opts.isPowerAllowed) {
|
|
68
|
+
const fractionNoPower = frac(1, new PowerNode(int.toTree(), Math.abs(power).toTree()).evaluate().toTree());
|
|
69
|
+
const texNoPower = fractionNoPower.toTex();
|
|
70
|
+
return !simplificationTex.includes(texNoPower)
|
|
71
|
+
? `
|
|
72
|
+
|
|
73
|
+
$$
|
|
74
|
+
${statement} = ${texNoPower}
|
|
75
|
+
$$
|
|
76
|
+
|
|
77
|
+
`
|
|
78
|
+
: ``;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return ``;
|
|
82
|
+
}
|
|
83
|
+
})()}
|
|
84
|
+
`;
|
|
58
85
|
};
|
|
59
86
|
const getPropositions = (n, { answer, int, power }) => {
|
|
60
87
|
const propositions = [];
|
|
@@ -78,10 +105,13 @@ const getPropositions = (n, { answer, int, power }) => {
|
|
|
78
105
|
});
|
|
79
106
|
return shuffleProps(propositions, n);
|
|
80
107
|
};
|
|
81
|
-
const isAnswerValid = (ans, { answer }) => {
|
|
108
|
+
const isAnswerValid = (ans, { answer, opts }) => {
|
|
82
109
|
try {
|
|
83
110
|
const parsed = parseAlgebraic(ans);
|
|
84
|
-
if (!isNumberNode(parsed) &&
|
|
111
|
+
if (!isNumberNode(parsed) &&
|
|
112
|
+
!(isFractionNode(parsed) &&
|
|
113
|
+
(opts.isPowerAllowed ||
|
|
114
|
+
!isNodeContainingOperatorId(parsed, OperatorIds.power)))) {
|
|
85
115
|
return false;
|
|
86
116
|
}
|
|
87
117
|
return parsed.simplify().toTex() === answer;
|
|
@@ -90,12 +120,46 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
90
120
|
return handleVEAError(err);
|
|
91
121
|
}
|
|
92
122
|
};
|
|
123
|
+
const getCalculatePowerQuestion = (optsIn) => {
|
|
124
|
+
const opts = optsIn ?? optsDefault;
|
|
125
|
+
const int = randint(1, 11);
|
|
126
|
+
const power = randint(-5, 0);
|
|
127
|
+
const identifiers = { int, power, opts };
|
|
128
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
129
|
+
};
|
|
130
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
131
|
+
const question = {
|
|
132
|
+
answer: getAnswer(identifiers),
|
|
133
|
+
instruction: getInstruction(identifiers),
|
|
134
|
+
keys: [],
|
|
135
|
+
answerFormat: "tex",
|
|
136
|
+
identifiers,
|
|
137
|
+
hint: getHint(identifiers),
|
|
138
|
+
correction: getCorrection(identifiers),
|
|
139
|
+
options: opts,
|
|
140
|
+
};
|
|
141
|
+
return question;
|
|
142
|
+
};
|
|
143
|
+
const optsDefault = {
|
|
144
|
+
isPowerAllowed: true,
|
|
145
|
+
};
|
|
146
|
+
const options = [
|
|
147
|
+
{
|
|
148
|
+
id: "isPowerAllowed",
|
|
149
|
+
label: "Exposant accepté dans la réponse",
|
|
150
|
+
target: GeneratorOptionTarget.generation,
|
|
151
|
+
type: GeneratorOptionType.checkbox,
|
|
152
|
+
values: [true, false],
|
|
153
|
+
defaultValue: optsDefault.isPowerAllowed,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
93
156
|
export const calculateNegativePower = {
|
|
94
157
|
id: "calculateNegativePower",
|
|
95
158
|
connector: "=",
|
|
96
159
|
label: "Calculer une puissance négative",
|
|
97
160
|
isSingleStep: true,
|
|
98
|
-
generator: (nb) => getDistinctQuestions(getCalculatePowerQuestion, nb),
|
|
161
|
+
generator: (nb, opts) => getDistinctQuestions(() => getCalculatePowerQuestion(opts), nb),
|
|
162
|
+
options,
|
|
99
163
|
qcmTimer: 60,
|
|
100
164
|
freeTimer: 60,
|
|
101
165
|
getPropositions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probaFromTableNoContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableNoContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"probaFromTableNoContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableNoContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA2TF,KAAK,OAAO,GAAG;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AA+BF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBlE,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuesti
|
|
|
3
3
|
import { Rational } from "../../../math/numbers/rationals/rational.js";
|
|
4
4
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
5
5
|
import { frac } from "../../../tree/nodes/operators/fractionNode.js";
|
|
6
|
+
import { substract } from "../../../tree/nodes/operators/substractNode.js";
|
|
6
7
|
import { rationalParser } from "../../../tree/parsers/rationalParser.js";
|
|
7
8
|
import { random } from "../../../utils/alea/random.js";
|
|
8
9
|
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
@@ -248,12 +249,19 @@ const options = [
|
|
|
248
249
|
type: GeneratorOptionType.checkbox,
|
|
249
250
|
},
|
|
250
251
|
];
|
|
251
|
-
const isAnswerValid = (ans, { answer }) => {
|
|
252
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
252
253
|
try {
|
|
253
254
|
const parsed = rationalParser(ans);
|
|
254
255
|
if (!parsed)
|
|
255
256
|
return false;
|
|
256
|
-
return parsed.simplify().toTex() === answer
|
|
257
|
+
return (parsed.simplify().toTex() === answer ||
|
|
258
|
+
(() => {
|
|
259
|
+
const { probaFrac } = identifiers;
|
|
260
|
+
const answerNode = new Rational(probaFrac[0], probaFrac[1])
|
|
261
|
+
.simplify()
|
|
262
|
+
.toTree();
|
|
263
|
+
return substract(parsed.simplify(), answerNode).evaluate() === 0;
|
|
264
|
+
})());
|
|
257
265
|
}
|
|
258
266
|
catch (err) {
|
|
259
267
|
return handleVEAError(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAyRF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAkB3D,CAAC"}
|
|
@@ -3,6 +3,9 @@ type Identifiers = {
|
|
|
3
3
|
randomValues: number[];
|
|
4
4
|
randomQuartile: number;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
type Options = {
|
|
7
|
+
nbValues: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const quartilesList: Exercise<Identifiers, Options>;
|
|
7
10
|
export {};
|
|
8
11
|
//# sourceMappingURL=quartilesList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quartilesList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartilesList.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quartilesList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartilesList.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EAkBT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAyGF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAeF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBxD,CAAC"}
|
|
@@ -2,7 +2,8 @@ import { randint } from "../../../../math/utils/random/randint.js";
|
|
|
2
2
|
import { firstQuartile, thirdQuartile, } from "../../../../math/utils/stats/quartiles.js";
|
|
3
3
|
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
4
4
|
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
5
|
-
import {
|
|
5
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
6
|
+
import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercise.js";
|
|
6
7
|
import { getDistinctQuestions } from "../../../utils/getDistinctQuestions.js";
|
|
7
8
|
const getInstruction = ({ randomQuartile, randomValues, }) => {
|
|
8
9
|
let quartileToString = "";
|
|
@@ -15,7 +16,7 @@ $$
|
|
|
15
16
|
${randomValues.join(";\\ ")}
|
|
16
17
|
$$
|
|
17
18
|
|
|
18
|
-
Calculer le ${quartileToString} de cette série de valeurs.`;
|
|
19
|
+
Calculer le ${quartileToString} de cette série de $${randomValues.length}$ valeurs.`;
|
|
19
20
|
};
|
|
20
21
|
const getAnswer = (identifiers) => {
|
|
21
22
|
const { randomValues, randomQuartile } = identifiers;
|
|
@@ -24,18 +25,6 @@ const getAnswer = (identifiers) => {
|
|
|
24
25
|
else
|
|
25
26
|
return thirdQuartile(randomValues).frenchify();
|
|
26
27
|
};
|
|
27
|
-
const getQuartiles = () => {
|
|
28
|
-
const randomValues = [];
|
|
29
|
-
const length = randint(5, 9);
|
|
30
|
-
for (let i = 0; i < length; i++)
|
|
31
|
-
randomValues.push(randint(1, 20));
|
|
32
|
-
const randomQuartile = randint(0, 2);
|
|
33
|
-
const identifiers = {
|
|
34
|
-
randomValues: randomValues.sort((a, b) => a - b),
|
|
35
|
-
randomQuartile,
|
|
36
|
-
};
|
|
37
|
-
return getQuestionFromIdentifiers(identifiers);
|
|
38
|
-
};
|
|
39
28
|
const getHint = (identifiers) => {
|
|
40
29
|
const { randomQuartile } = identifiers;
|
|
41
30
|
if (randomQuartile === 0)
|
|
@@ -54,18 +43,6 @@ Puisque $${rank.toTex()} = ${rankEv.frenchify()}$, le ${numeral} quartile est la
|
|
|
54
43
|
|
|
55
44
|
Le ${numeral} quartile est donc $${getAnswer(identifiers)}$.`;
|
|
56
45
|
};
|
|
57
|
-
const getQuestionFromIdentifiers = (identifiers) => {
|
|
58
|
-
const question = {
|
|
59
|
-
instruction: getInstruction(identifiers),
|
|
60
|
-
answer: getAnswer(identifiers),
|
|
61
|
-
keys: [],
|
|
62
|
-
answerFormat: "tex",
|
|
63
|
-
identifiers,
|
|
64
|
-
hint: getHint(identifiers),
|
|
65
|
-
correction: getCorrection(identifiers),
|
|
66
|
-
};
|
|
67
|
-
return question;
|
|
68
|
-
};
|
|
69
46
|
const getPropositions = (n, { answer, randomValues }) => {
|
|
70
47
|
const propositions = [];
|
|
71
48
|
addValidProp(propositions, answer);
|
|
@@ -81,12 +58,54 @@ const getPropositions = (n, { answer, randomValues }) => {
|
|
|
81
58
|
const isAnswerValid = (ans, { answer }) => {
|
|
82
59
|
return ans === answer;
|
|
83
60
|
};
|
|
61
|
+
const getQuartiles = (optsIn) => {
|
|
62
|
+
const opts = optsIn ?? optsDefault;
|
|
63
|
+
const randomValues = [];
|
|
64
|
+
const length = Array.isArray(opts.nbValues)
|
|
65
|
+
? random(opts.nbValues.map((v) => +v))
|
|
66
|
+
: opts.nbValues;
|
|
67
|
+
for (let i = 0; i < length; i++)
|
|
68
|
+
randomValues.push(randint(1, 20));
|
|
69
|
+
const randomQuartile = randint(0, 2);
|
|
70
|
+
const identifiers = {
|
|
71
|
+
randomValues: randomValues.sort((a, b) => a - b),
|
|
72
|
+
randomQuartile,
|
|
73
|
+
};
|
|
74
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
75
|
+
};
|
|
76
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
77
|
+
const question = {
|
|
78
|
+
instruction: getInstruction(identifiers),
|
|
79
|
+
answer: getAnswer(identifiers),
|
|
80
|
+
keys: [],
|
|
81
|
+
answerFormat: "tex",
|
|
82
|
+
identifiers,
|
|
83
|
+
hint: getHint(identifiers),
|
|
84
|
+
correction: getCorrection(identifiers),
|
|
85
|
+
options: opts,
|
|
86
|
+
};
|
|
87
|
+
return question;
|
|
88
|
+
};
|
|
89
|
+
const optsDefault = {
|
|
90
|
+
nbValues: 12,
|
|
91
|
+
};
|
|
92
|
+
const options = [
|
|
93
|
+
{
|
|
94
|
+
id: "nbValues",
|
|
95
|
+
label: "Nombre de valeurs dans la liste",
|
|
96
|
+
target: GeneratorOptionTarget.generation,
|
|
97
|
+
type: GeneratorOptionType.multiselect,
|
|
98
|
+
values: [4, 5, 7, 8, 11, 12, 19, 20],
|
|
99
|
+
defaultValue: [optsDefault.nbValues],
|
|
100
|
+
},
|
|
101
|
+
];
|
|
84
102
|
export const quartilesList = {
|
|
85
103
|
id: "quartilesList",
|
|
86
104
|
connector: "=",
|
|
87
105
|
label: "Calcul des quartiles d'une liste de valeurs",
|
|
88
106
|
isSingleStep: false,
|
|
89
|
-
generator: (nb) => getDistinctQuestions(getQuartiles, nb),
|
|
107
|
+
generator: (nb, opts) => getDistinctQuestions(() => getQuartiles(opts ?? optsDefault), nb),
|
|
108
|
+
options,
|
|
90
109
|
qcmTimer: 60,
|
|
91
110
|
freeTimer: 60,
|
|
92
111
|
getPropositions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometricFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"geometricFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA8HF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAc9D,CAAC"}
|