math-exercises 3.0.78 → 3.0.80
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/getParityBetweenTwoNumbers.js +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +2 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +2 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.d.ts +11 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.js +133 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.js +174 -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/fractions/simplifyFractionWithPrimeFactorization.d.ts +8 -0
- package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.d.ts.map +1 -0
- package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.js +104 -0
- package/lib/exercises/math/calcul/index.d.ts +1 -0
- package/lib/exercises/math/calcul/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/index.js +1 -0
- package/lib/exercises/math/calcul/rationals/index.d.ts +2 -0
- package/lib/exercises/math/calcul/rationals/index.d.ts.map +1 -0
- package/lib/exercises/math/calcul/rationals/index.js +1 -0
- package/lib/exercises/math/calcul/rationals/rationalNumbers.d.ts +11 -0
- package/lib/exercises/math/calcul/rationals/rationalNumbers.d.ts.map +1 -0
- package/lib/exercises/math/calcul/rationals/rationalNumbers.js +185 -0
- package/lib/exercises/math/dataRepresentations/index.js +1 -0
- package/lib/exercises/math/probaStat/averageLinearity.d.ts +16 -0
- package/lib/exercises/math/probaStat/averageLinearity.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/averageLinearity.js +217 -0
- package/lib/exercises/math/probaStat/cumulativeSum.d.ts +9 -0
- package/lib/exercises/math/probaStat/cumulativeSum.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/cumulativeSum.js +105 -0
- package/lib/exercises/math/probaStat/describeEvent.d.ts +15 -0
- package/lib/exercises/math/probaStat/describeEvent.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/describeEvent.js +182 -0
- package/lib/exercises/math/probaStat/getSampleCountAndSize.d.ts +9 -0
- package/lib/exercises/math/probaStat/getSampleCountAndSize.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/getSampleCountAndSize.js +95 -0
- package/lib/exercises/math/probaStat/index.d.ts +4 -0
- package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/index.js +4 -0
- package/lib/index.d.ts +44 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.d.ts +1 -1
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +5 -5
- package/lib/tree/nodes/numbers/numberNode.d.ts +3 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +34 -2
- package/package.json +1 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { DecimalConstructor } from "../../../../math/numbers/decimals/decimal.js";
|
|
4
|
+
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { isOppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
7
|
+
import { SqrtNode } from "../../../../tree/nodes/functions/sqrtNode.js";
|
|
8
|
+
import { NodeIds } from "../../../../tree/nodes/node.js";
|
|
9
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
10
|
+
import { isNumberNode, NumberNode, } from "../../../../tree/nodes/numbers/numberNode.js";
|
|
11
|
+
import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
|
|
12
|
+
import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
13
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
14
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
15
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
16
|
+
const getPropositions = (n, { answer, choices }) => {
|
|
17
|
+
const propositions = [];
|
|
18
|
+
for (const choice of choices) {
|
|
19
|
+
if (!choice.irrationalUsed) {
|
|
20
|
+
addValidProp(propositions, reifyAlgebraic(choice.node).toTex());
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
tryToAddWrongProp(propositions, reifyAlgebraic(choice.node).simplify().toTex());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return shuffleProps(propositions, n);
|
|
27
|
+
};
|
|
28
|
+
const getInstruction = (identifiers) => {
|
|
29
|
+
return "Parmi ces nombres, lesquels sont rationnels ?";
|
|
30
|
+
};
|
|
31
|
+
const getHint = (identifiers) => {
|
|
32
|
+
return `Un nombre $n$ est rationnel s'il peut s'écrire sous la forme :
|
|
33
|
+
|
|
34
|
+
$$
|
|
35
|
+
n = ${frac("a", "b").toTex()}
|
|
36
|
+
$$
|
|
37
|
+
|
|
38
|
+
avec $a \\in \\mathbb{Z}$ et $b \\in \\mathbb{Z}^*$.`;
|
|
39
|
+
};
|
|
40
|
+
const getCorrection = (identifiers) => {
|
|
41
|
+
let corrections = [];
|
|
42
|
+
for (const choice of identifiers.choices) {
|
|
43
|
+
const node = reifyAlgebraic(choice.node);
|
|
44
|
+
if (choice.irrationalUsed) {
|
|
45
|
+
const irrationalUsed = reifyAlgebraic(choice.irrationalUsed);
|
|
46
|
+
if (irrationalUsed.equals(node)) {
|
|
47
|
+
corrections.push(`- $${irrationalUsed.toTex()}$ est un nombre irrationnel.`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
corrections.push(`- $${irrationalUsed.toTex()}$ est un nombre irrationnel, donc $${node
|
|
51
|
+
.simplify()
|
|
52
|
+
.toTex()}$ est irrationnel.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const nodeId = node.toIdentifiers();
|
|
57
|
+
if (nodeId.id === NodeIds.fraction ||
|
|
58
|
+
(isOppositeNode(node) && isFractionNode(node.child))) {
|
|
59
|
+
corrections.push(`- $${node.toTex()}$ est un nombre rationnel car c'est une fraction de deux nombres entiers.`);
|
|
60
|
+
}
|
|
61
|
+
else if (isNumberNode(node)) {
|
|
62
|
+
corrections.push(`- $${node.toTex()}$ est un nombre rationnel car il peut être écrit sous la forme d'une fraction d'entiers :
|
|
63
|
+
|
|
64
|
+
$$
|
|
65
|
+
${node.toTex()} = ${node.toFrac(false).toTex()}
|
|
66
|
+
$$`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return corrections.join("\n");
|
|
71
|
+
};
|
|
72
|
+
const getRationalNumbersQuestion = (ops) => {
|
|
73
|
+
let choices = [];
|
|
74
|
+
const knownIrrationals = [
|
|
75
|
+
PiNode,
|
|
76
|
+
new SqrtNode(new NumberNode(2)),
|
|
77
|
+
new SqrtNode(new NumberNode(3)),
|
|
78
|
+
new SqrtNode(new NumberNode(5)),
|
|
79
|
+
];
|
|
80
|
+
let node;
|
|
81
|
+
const generateRational = () => {
|
|
82
|
+
switch (randint(0, 3)) {
|
|
83
|
+
case 0:
|
|
84
|
+
// Integer
|
|
85
|
+
do {
|
|
86
|
+
node = new NumberNode(randint(-20, 20));
|
|
87
|
+
} while (choices.some((choice) => choice.node.toTex() === node.toTex()));
|
|
88
|
+
choices.push({
|
|
89
|
+
node,
|
|
90
|
+
irrationalUsed: null,
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
case 1:
|
|
94
|
+
// Decimal
|
|
95
|
+
do {
|
|
96
|
+
node = DecimalConstructor.random(-10, 10, 2).toTree();
|
|
97
|
+
} while (choices.some((choice) => choice.node.toTex() === node.toTex()));
|
|
98
|
+
choices.push({
|
|
99
|
+
node,
|
|
100
|
+
irrationalUsed: null,
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
case 2:
|
|
104
|
+
default:
|
|
105
|
+
// Fraction
|
|
106
|
+
do {
|
|
107
|
+
node = RationalConstructor.randomIrreductibleWithSign().toTree();
|
|
108
|
+
} while (choices.some((choice) => choice.node.toTex() === node.toTex()));
|
|
109
|
+
choices.push({
|
|
110
|
+
node,
|
|
111
|
+
irrationalUsed: null,
|
|
112
|
+
});
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const generateIrrational = () => {
|
|
117
|
+
switch (randint(0, 2)) {
|
|
118
|
+
case 0:
|
|
119
|
+
// Irrational
|
|
120
|
+
do {
|
|
121
|
+
node = random(knownIrrationals);
|
|
122
|
+
} while (choices.some((choice) => choice.node.toTex() === node.toTex()));
|
|
123
|
+
choices.push({
|
|
124
|
+
node,
|
|
125
|
+
irrationalUsed: node.toIdentifiers(),
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
case 1:
|
|
129
|
+
default:
|
|
130
|
+
let irrational;
|
|
131
|
+
do {
|
|
132
|
+
irrational = random(knownIrrationals);
|
|
133
|
+
node = multiply(irrational, RationalConstructor.randomPureRational(10).toTree());
|
|
134
|
+
} while (choices.some((choice) => choice.node.toTex() === node.toTex()));
|
|
135
|
+
// Irrational fraction
|
|
136
|
+
choices.push({
|
|
137
|
+
node,
|
|
138
|
+
irrationalUsed: irrational.toIdentifiers(),
|
|
139
|
+
});
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
// Generer au moins un choix rationnel et un choix irrationnel
|
|
144
|
+
generateRational();
|
|
145
|
+
generateIrrational();
|
|
146
|
+
for (let i = 0; i < 2; i++) {
|
|
147
|
+
coinFlip() ? generateRational() : generateIrrational();
|
|
148
|
+
}
|
|
149
|
+
const identifiers = {
|
|
150
|
+
choices: choices.map((c) => {
|
|
151
|
+
return {
|
|
152
|
+
node: c.node.toIdentifiers(),
|
|
153
|
+
irrationalUsed: c.irrationalUsed,
|
|
154
|
+
};
|
|
155
|
+
}),
|
|
156
|
+
};
|
|
157
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
158
|
+
};
|
|
159
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
160
|
+
return {
|
|
161
|
+
instruction: getInstruction(identifiers),
|
|
162
|
+
keys: [],
|
|
163
|
+
answerFormat: "tex",
|
|
164
|
+
identifiers,
|
|
165
|
+
hint: getHint(identifiers),
|
|
166
|
+
correction: getCorrection(identifiers),
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
export const rationalNumbers = {
|
|
170
|
+
id: "rationalNumbers",
|
|
171
|
+
label: "Dire si un nombre est rationnel",
|
|
172
|
+
answerType: "QCM",
|
|
173
|
+
isQCM: true,
|
|
174
|
+
isSingleStep: true,
|
|
175
|
+
generator: (nb, opts) => getDistinctQuestions(() => getRationalNumbersQuestion(opts), nb),
|
|
176
|
+
qcmTimer: 60,
|
|
177
|
+
freeTimer: 60,
|
|
178
|
+
getPropositions,
|
|
179
|
+
subject: "Mathématiques",
|
|
180
|
+
getInstruction,
|
|
181
|
+
getHint,
|
|
182
|
+
getCorrection,
|
|
183
|
+
getQuestionFromIdentifiers,
|
|
184
|
+
hasHintAndCorrection: true,
|
|
185
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Operators = "multiplication" | "division" | "soustraction" | "addition";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
kind: "factor";
|
|
5
|
+
a: number;
|
|
6
|
+
operator: Operators;
|
|
7
|
+
factor: number;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "series";
|
|
10
|
+
series: number[];
|
|
11
|
+
operator: Operators;
|
|
12
|
+
factor: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const averageLinearity: Exercise<Identifiers>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=averageLinearity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"averageLinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/averageLinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAarC,KAAK,SAAS,GAAG,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAC7E,KAAK,WAAW,GACZ;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmON,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAkBlD,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
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 { add } from "../../../tree/nodes/operators/addNode.js";
|
|
5
|
+
import { divide } from "../../../tree/nodes/operators/divideNode.js";
|
|
6
|
+
import { frac } from "../../../tree/nodes/operators/fractionNode.js";
|
|
7
|
+
import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
|
|
8
|
+
import { substract } from "../../../tree/nodes/operators/substractNode.js";
|
|
9
|
+
import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
|
|
10
|
+
import { coinFlip } from "../../../utils/alea/coinFlip.js";
|
|
11
|
+
import { random } from "../../../utils/alea/random.js";
|
|
12
|
+
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
13
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
14
|
+
const propositions = [];
|
|
15
|
+
addValidProp(propositions, answer);
|
|
16
|
+
const moyenne = isSeriesQuestion(identifiers)
|
|
17
|
+
? (identifiers.series[0] +
|
|
18
|
+
identifiers.series[1] +
|
|
19
|
+
identifiers.series[2] +
|
|
20
|
+
identifiers.series[3]) /
|
|
21
|
+
4
|
|
22
|
+
: identifiers.a;
|
|
23
|
+
const { operator, factor } = identifiers;
|
|
24
|
+
switch (operator) {
|
|
25
|
+
case "addition":
|
|
26
|
+
tryToAddWrongProp(propositions, (moyenne + factor + 1).frenchify());
|
|
27
|
+
tryToAddWrongProp(propositions, (moyenne + factor - 1).frenchify());
|
|
28
|
+
tryToAddWrongProp(propositions, (moyenne + factor + factor).frenchify());
|
|
29
|
+
tryToAddWrongProp(propositions, (moyenne + factor - 2).frenchify());
|
|
30
|
+
break;
|
|
31
|
+
case "soustraction":
|
|
32
|
+
tryToAddWrongProp(propositions, (moyenne - factor + 1).frenchify());
|
|
33
|
+
tryToAddWrongProp(propositions, (moyenne - factor - 1).frenchify());
|
|
34
|
+
tryToAddWrongProp(propositions, (moyenne - factor - factor).frenchify());
|
|
35
|
+
tryToAddWrongProp(propositions, (moyenne - factor - 2).frenchify());
|
|
36
|
+
break;
|
|
37
|
+
case "multiplication":
|
|
38
|
+
tryToAddWrongProp(propositions, (moyenne * factor + 1).frenchify());
|
|
39
|
+
tryToAddWrongProp(propositions, (moyenne * factor - 1).frenchify());
|
|
40
|
+
tryToAddWrongProp(propositions, (moyenne * factor + 2).frenchify());
|
|
41
|
+
tryToAddWrongProp(propositions, (moyenne * factor - 2).frenchify());
|
|
42
|
+
break;
|
|
43
|
+
case "division":
|
|
44
|
+
tryToAddWrongProp(propositions, frac(moyenne + 1, factor).toTex());
|
|
45
|
+
tryToAddWrongProp(propositions, frac(moyenne - 1, factor).toTex());
|
|
46
|
+
tryToAddWrongProp(propositions, frac(moyenne, factor + 1).toTex());
|
|
47
|
+
tryToAddWrongProp(propositions, frac(moyenne, factor - 1).toTex());
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
return shuffleProps(propositions, n);
|
|
51
|
+
};
|
|
52
|
+
const isSeriesQuestion = (identifiers) => {
|
|
53
|
+
return identifiers.kind === "series";
|
|
54
|
+
};
|
|
55
|
+
const getAnswer = (identifiers) => {
|
|
56
|
+
const moyenne = isSeriesQuestion(identifiers)
|
|
57
|
+
? (identifiers.series[0] +
|
|
58
|
+
identifiers.series[1] +
|
|
59
|
+
identifiers.series[2] +
|
|
60
|
+
identifiers.series[3]) /
|
|
61
|
+
4
|
|
62
|
+
: identifiers.a;
|
|
63
|
+
const { operator, factor } = identifiers;
|
|
64
|
+
switch (operator) {
|
|
65
|
+
case "addition":
|
|
66
|
+
return add(moyenne, factor).simplify().toTex();
|
|
67
|
+
case "soustraction":
|
|
68
|
+
return substract(moyenne, factor).simplify().toTex();
|
|
69
|
+
case "multiplication":
|
|
70
|
+
return multiply(moyenne, factor).simplify().toTex();
|
|
71
|
+
case "division":
|
|
72
|
+
default:
|
|
73
|
+
return frac(moyenne, factor).simplify().toTex();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const getInstruction = (identifiers) => {
|
|
77
|
+
if (isSeriesQuestion(identifiers)) {
|
|
78
|
+
const { series: [a, b, c, d], operator, factor, } = identifiers;
|
|
79
|
+
let factorResult = (x) => {
|
|
80
|
+
switch (operator) {
|
|
81
|
+
case "addition":
|
|
82
|
+
return x + factor;
|
|
83
|
+
case "soustraction":
|
|
84
|
+
return x - factor;
|
|
85
|
+
case "multiplication":
|
|
86
|
+
return x * factor;
|
|
87
|
+
case "division":
|
|
88
|
+
default:
|
|
89
|
+
return x / factor;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return `La moyenne de la série ${[a, b, c, d]
|
|
93
|
+
.map((x) => `$${x.frenchify()}$`)
|
|
94
|
+
.join(" ; ")} vaut $${((a + b + c + d) / 4).frenchify()}$.
|
|
95
|
+
|
|
96
|
+
Que vaut la moyenne de la série ${[a, b, c, d]
|
|
97
|
+
.map((x) => `$${factorResult(x).frenchify()}$`)
|
|
98
|
+
.join(" ; ")} ?`;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const { a, operator, factor } = identifiers;
|
|
102
|
+
const text = operator === "division"
|
|
103
|
+
? "divisées par"
|
|
104
|
+
: operator === "multiplication"
|
|
105
|
+
? "multipliées par"
|
|
106
|
+
: operator === "soustraction"
|
|
107
|
+
? "diminuées de"
|
|
108
|
+
: "augmentées de";
|
|
109
|
+
return `La moyenne d'une série statistique vaut $${a.frenchify()}$. Calculer la nouvelle moyenne de la série si toutes ses valeurs sont ${text} $${factor.frenchify()}$.`;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const getHint = (identifiers) => {
|
|
113
|
+
return `Si on effectue une ${identifiers.operator} sur toutes les valeurs d'une série par un nombre $a$, alors la nouvelle moyenne de la série est obtenue en faisant une ${identifiers.operator} par ce même nombre sur la moyenne précédente.`;
|
|
114
|
+
};
|
|
115
|
+
const getCorrection = (identifiers) => {
|
|
116
|
+
const moyenne = isSeriesQuestion(identifiers)
|
|
117
|
+
? (identifiers.series[0] +
|
|
118
|
+
identifiers.series[1] +
|
|
119
|
+
identifiers.series[2] +
|
|
120
|
+
identifiers.series[3]) /
|
|
121
|
+
4
|
|
122
|
+
: identifiers.a;
|
|
123
|
+
const { operator, factor } = identifiers;
|
|
124
|
+
let latexFormula = "";
|
|
125
|
+
switch (operator) {
|
|
126
|
+
case "addition":
|
|
127
|
+
latexFormula = `${add(moyenne, factor).toTex()} = ${(moyenne + factor).frenchify()}`;
|
|
128
|
+
break;
|
|
129
|
+
case "soustraction":
|
|
130
|
+
latexFormula = `${substract(moyenne, factor).toTex()} = ${(moyenne - factor).frenchify()}`;
|
|
131
|
+
break;
|
|
132
|
+
case "multiplication":
|
|
133
|
+
latexFormula = `${multiply(moyenne, factor).toTex()} = ${(moyenne * factor).frenchify()}`;
|
|
134
|
+
break;
|
|
135
|
+
case "division":
|
|
136
|
+
default:
|
|
137
|
+
latexFormula = `${divide(moyenne, factor).toTex()} = ${frac(moyenne, factor).toTex()}`;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return `Il y a eu une ${operator} de $${factor.frenchify()}$ sur les valeurs de la série, donc la moyenne devient :
|
|
141
|
+
|
|
142
|
+
$$
|
|
143
|
+
${latexFormula}
|
|
144
|
+
$$`;
|
|
145
|
+
};
|
|
146
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
147
|
+
try {
|
|
148
|
+
const parsed = parseAlgebraic(ans);
|
|
149
|
+
return parsed.simplify().toTex() === answer;
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
return handleVEAError(err);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const getAverageLinearityQuestion = (ops) => {
|
|
156
|
+
const isSeries = coinFlip();
|
|
157
|
+
if (isSeries) {
|
|
158
|
+
const a = randint(1, 10);
|
|
159
|
+
const b = randint(10, 20);
|
|
160
|
+
const c = randint(20, 30);
|
|
161
|
+
const d = randint(30, 40);
|
|
162
|
+
const operator = random([
|
|
163
|
+
"multiplication",
|
|
164
|
+
"division",
|
|
165
|
+
"soustraction",
|
|
166
|
+
"addition",
|
|
167
|
+
]);
|
|
168
|
+
const factor = randint(2, 5);
|
|
169
|
+
const identifiers = {
|
|
170
|
+
kind: "series",
|
|
171
|
+
series: [a, b, c, d],
|
|
172
|
+
operator,
|
|
173
|
+
factor,
|
|
174
|
+
};
|
|
175
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const a = randint(2, 20);
|
|
179
|
+
const operator = random([
|
|
180
|
+
"multiplication",
|
|
181
|
+
"division",
|
|
182
|
+
"soustraction",
|
|
183
|
+
"addition",
|
|
184
|
+
]);
|
|
185
|
+
const factor = randint(2, 10, [a, 7, 9]);
|
|
186
|
+
const identifiers = { kind: "factor", a, operator, factor };
|
|
187
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
191
|
+
return {
|
|
192
|
+
answer: getAnswer(identifiers),
|
|
193
|
+
instruction: getInstruction(identifiers),
|
|
194
|
+
keys: [],
|
|
195
|
+
answerFormat: "tex",
|
|
196
|
+
identifiers,
|
|
197
|
+
hint: getHint(identifiers),
|
|
198
|
+
correction: getCorrection(identifiers),
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
export const averageLinearity = {
|
|
202
|
+
id: "averageLinearity",
|
|
203
|
+
label: "Calculer la moyenne d'une série à partir de la moyenne d'une autre série en utilisant la linéarité de la moyenne",
|
|
204
|
+
isSingleStep: true,
|
|
205
|
+
generator: (nb, opts) => getDistinctQuestions(() => getAverageLinearityQuestion(opts), nb),
|
|
206
|
+
qcmTimer: 60,
|
|
207
|
+
freeTimer: 60,
|
|
208
|
+
getPropositions,
|
|
209
|
+
isAnswerValid,
|
|
210
|
+
subject: "Mathématiques",
|
|
211
|
+
getInstruction,
|
|
212
|
+
getHint,
|
|
213
|
+
getCorrection,
|
|
214
|
+
getAnswer,
|
|
215
|
+
getQuestionFromIdentifiers,
|
|
216
|
+
hasHintAndCorrection: true,
|
|
217
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cumulativeSum.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/cumulativeSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4GF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { numberVEA } from "../../../exercises/vea/numberVEA.js";
|
|
4
|
+
import { randint } from "../../../math/utils/random/randint.js";
|
|
5
|
+
import { AddNode } from "../../../tree/nodes/operators/addNode.js";
|
|
6
|
+
import { operatorComposition } from "../../../tree/utilities/operatorComposition.js";
|
|
7
|
+
import { dollarize } from "../../../utils/latex/dollarize.js";
|
|
8
|
+
import { mdTable } from "../../../utils/markdown/mdTable.js";
|
|
9
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
10
|
+
const propositions = [];
|
|
11
|
+
const { xVals, yVals, x } = identifiers;
|
|
12
|
+
addValidProp(propositions, answer);
|
|
13
|
+
tryToAddWrongProp(propositions, `${xVals[x]}`);
|
|
14
|
+
tryToAddWrongProp(propositions, `${xVals[x]}`);
|
|
15
|
+
for (let k = 0; k < yVals.length; k++) {
|
|
16
|
+
let sum = 0;
|
|
17
|
+
for (let i = 0; i <= k; i++) {
|
|
18
|
+
sum += yVals[i];
|
|
19
|
+
}
|
|
20
|
+
tryToAddWrongProp(propositions, `${sum}`);
|
|
21
|
+
}
|
|
22
|
+
return shuffleProps(propositions, n);
|
|
23
|
+
};
|
|
24
|
+
const getAnswer = (identifiers) => {
|
|
25
|
+
const { yVals, x } = identifiers;
|
|
26
|
+
let sum = 0;
|
|
27
|
+
for (let i = 0; i <= x; i++) {
|
|
28
|
+
sum += yVals[i];
|
|
29
|
+
}
|
|
30
|
+
return `${sum}`;
|
|
31
|
+
};
|
|
32
|
+
const getInstruction = (identifiers) => {
|
|
33
|
+
const { xVals, yVals, x } = identifiers;
|
|
34
|
+
return `On considère la série statistique suivante :
|
|
35
|
+
|
|
36
|
+
${mdTable([
|
|
37
|
+
["Valeur", ...xVals.map((x) => dollarize(x))],
|
|
38
|
+
["Effectif", ...yVals.map((y) => dollarize(y))],
|
|
39
|
+
])}
|
|
40
|
+
|
|
41
|
+
Calculez l'effectif cumulé croissant de la valeur $${xVals[x]}$.
|
|
42
|
+
`;
|
|
43
|
+
};
|
|
44
|
+
const getHint = (identifiers) => {
|
|
45
|
+
return `L'effectif cumulé croissant d'une valeur correspond à la somme des effectifs des valeurs inférieures ou égales à cette valeur`;
|
|
46
|
+
};
|
|
47
|
+
const getCorrection = (identifiers) => {
|
|
48
|
+
const { xVals, yVals, x } = identifiers;
|
|
49
|
+
let sum = 0;
|
|
50
|
+
for (let i = 0; i <= x; i++) {
|
|
51
|
+
sum += yVals[i];
|
|
52
|
+
}
|
|
53
|
+
return `L'effectif cumulé croissant de $${xVals[x]}$ correspond à la somme des effectifs des valeurs inférieures ou égales à $${xVals[x]}$ :
|
|
54
|
+
|
|
55
|
+
$$
|
|
56
|
+
${x > 0
|
|
57
|
+
? `${operatorComposition(AddNode, yVals.slice(0, x + 1).map((e) => e.toTree())).toTex()} = ${sum}`
|
|
58
|
+
: `${sum}`}
|
|
59
|
+
$$`;
|
|
60
|
+
};
|
|
61
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
62
|
+
return numberVEA(ans, answer);
|
|
63
|
+
};
|
|
64
|
+
const getCumulativeSumQuestion = (ops) => {
|
|
65
|
+
let xVals = [randint(1, 10)];
|
|
66
|
+
let yVals = [randint(1, 10, xVals)];
|
|
67
|
+
for (let i = 1; i < randint(3, 6); i++) {
|
|
68
|
+
xVals.push(xVals[i - 1] + randint(1, 10));
|
|
69
|
+
yVals.push(yVals[i - 1] + randint(1, 10));
|
|
70
|
+
}
|
|
71
|
+
const identifiers = {
|
|
72
|
+
xVals,
|
|
73
|
+
yVals,
|
|
74
|
+
x: randint(1, xVals.length),
|
|
75
|
+
};
|
|
76
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
77
|
+
};
|
|
78
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
79
|
+
return {
|
|
80
|
+
answer: getAnswer(identifiers),
|
|
81
|
+
instruction: getInstruction(identifiers),
|
|
82
|
+
keys: [],
|
|
83
|
+
answerFormat: "tex",
|
|
84
|
+
identifiers,
|
|
85
|
+
hint: getHint(identifiers),
|
|
86
|
+
correction: getCorrection(identifiers),
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export const cumulativeSum = {
|
|
90
|
+
id: "cumulativeSum",
|
|
91
|
+
label: "Calculer des effectifs cumulés croissants",
|
|
92
|
+
isSingleStep: true,
|
|
93
|
+
generator: (nb, opts) => getDistinctQuestions(() => getCumulativeSumQuestion(opts), nb),
|
|
94
|
+
qcmTimer: 60,
|
|
95
|
+
freeTimer: 60,
|
|
96
|
+
getPropositions,
|
|
97
|
+
isAnswerValid,
|
|
98
|
+
subject: "Mathématiques",
|
|
99
|
+
getInstruction,
|
|
100
|
+
getHint,
|
|
101
|
+
getCorrection,
|
|
102
|
+
getAnswer,
|
|
103
|
+
getQuestionFromIdentifiers,
|
|
104
|
+
hasHintAndCorrection: true,
|
|
105
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
eventA: {
|
|
4
|
+
desc: string;
|
|
5
|
+
isComplementary: boolean;
|
|
6
|
+
};
|
|
7
|
+
eventB: {
|
|
8
|
+
desc: string;
|
|
9
|
+
isComplementary: boolean;
|
|
10
|
+
};
|
|
11
|
+
question: "union" | "intersection" | "comp";
|
|
12
|
+
};
|
|
13
|
+
export declare const describeEvent: Exercise<Identifiers>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=describeEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describeEvent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/describeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,QAAQ,EAAE,OAAO,GAAG,cAAc,GAAG,MAAM,CAAC;CAC7C,CAAC;AA0LF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAkB/C,CAAC"}
|