math-exercises 3.0.75 → 3.0.76
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/calculateDistanceBetweenNumbers.d.ts +8 -0
- package/lib/exercises/math/calcul/arithmetics/calculateDistanceBetweenNumbers.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/calculateDistanceBetweenNumbers.js +102 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
- package/lib/exercises/math/calcul/sign/index.d.ts +1 -0
- package/lib/exercises/math/calcul/sign/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/sign/index.js +1 -0
- package/lib/exercises/math/calcul/sign/inverseOrOpposite.d.ts +8 -0
- package/lib/exercises/math/calcul/sign/inverseOrOpposite.d.ts.map +1 -0
- package/lib/exercises/math/calcul/sign/inverseOrOpposite.js +89 -0
- package/lib/exercises/math/functions/parity/parityFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/parity/parityFromGraph.js +16 -0
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +87 -127
- package/lib/exercises/math/python/conditionIf.d.ts.map +1 -1
- package/lib/exercises/math/python/conditionIf.js +32 -1
- package/lib/exercises/math/python/conditionIfElse.d.ts +10 -0
- package/lib/exercises/math/python/conditionIfElse.d.ts.map +1 -0
- package/lib/exercises/math/python/conditionIfElse.js +119 -0
- package/lib/exercises/math/python/forLoop.d.ts.map +1 -1
- package/lib/exercises/math/python/forLoop.js +28 -0
- package/lib/exercises/math/python/inOutCalcul.d.ts.map +1 -1
- package/lib/exercises/math/python/inOutCalcul.js +31 -4
- package/lib/exercises/math/python/index.d.ts +2 -0
- package/lib/exercises/math/python/index.d.ts.map +1 -1
- package/lib/exercises/math/python/index.js +2 -0
- package/lib/exercises/math/python/pyForLoop1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/python/pyForLoop1Exercise.js +29 -0
- package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/python/pyWhileLoop1Exercise.js +1 -0
- package/lib/exercises/math/python/pythonFunctionTrinom.js +1 -1
- package/lib/exercises/math/python/variableAffectation.d.ts +10 -0
- package/lib/exercises/math/python/variableAffectation.d.ts.map +1 -0
- package/lib/exercises/math/python/variableAffectation.js +144 -0
- package/lib/exercises/math/python/whileLoop.d.ts +0 -1
- package/lib/exercises/math/python/whileLoop.d.ts.map +1 -1
- package/lib/exercises/math/python/whileLoop.js +37 -6
- package/lib/exercises/math/python/whileLoopCount.js +2 -2
- package/lib/index.d.ts +15 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.js +1 -0
- package/lib/math/polynomials/affine.d.ts +2 -1
- package/lib/math/polynomials/affine.d.ts.map +1 -1
- package/lib/math/polynomials/affine.js +5 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts +2 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +4 -2
- package/lib/tree/nodes/node.d.ts +2 -0
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +8 -7
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const calculateDistanceBetweenNumbers: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=calculateDistanceBetweenNumbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateDistanceBetweenNumbers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/calculateDistanceBetweenNumbers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAyFF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAoBjE,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { abs } from "../../../../tree/nodes/functions/absNode.js";
|
|
6
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
7
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
8
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
9
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
11
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
12
|
+
const getPropositions = (n, { answer, a, b }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
addValidProp(propositions, answer);
|
|
15
|
+
// Au cas où l'élève répond à la question en inversant les deux nombres
|
|
16
|
+
tryToAddWrongProp(propositions, add(b, -a).simplify().evaluate().frenchify());
|
|
17
|
+
// Au cas où l'élève répond à la question en ajoutant les deux nombres
|
|
18
|
+
tryToAddWrongProp(propositions, add(a, b).simplify().evaluate().frenchify());
|
|
19
|
+
while (propositions.length < n) {
|
|
20
|
+
const randomAnswer = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
|
|
21
|
+
tryToAddWrongProp(propositions, randomAnswer.frenchify());
|
|
22
|
+
}
|
|
23
|
+
return shuffleProps(propositions, n);
|
|
24
|
+
};
|
|
25
|
+
const getAnswer = (identifiers) => {
|
|
26
|
+
const { a, b } = identifiers;
|
|
27
|
+
const sub = add(a, -b);
|
|
28
|
+
const absNode = abs(sub).simplify().evaluate();
|
|
29
|
+
return absNode.frenchify();
|
|
30
|
+
};
|
|
31
|
+
const getInstruction = (identifiers) => {
|
|
32
|
+
const { a, b } = identifiers;
|
|
33
|
+
return `Calculer la distance entre $${a.frenchify()}$ et $${b.frenchify()}$.`;
|
|
34
|
+
};
|
|
35
|
+
const getHint = (identifiers) => {
|
|
36
|
+
return `La distance entre deux nombres $a$ et $b$ est
|
|
37
|
+
:
|
|
38
|
+
|
|
39
|
+
$$
|
|
40
|
+
|a - b|
|
|
41
|
+
$$
|
|
42
|
+
`;
|
|
43
|
+
};
|
|
44
|
+
const getCorrection = (identifiers) => {
|
|
45
|
+
const { a, b } = identifiers;
|
|
46
|
+
const sub = substract(a, b);
|
|
47
|
+
const absNode = abs(sub);
|
|
48
|
+
const answer = getAnswer(identifiers);
|
|
49
|
+
return `La distance entre $${a.frenchify()}$ et $${b.frenchify()}$ est :
|
|
50
|
+
|
|
51
|
+
${alignTex([
|
|
52
|
+
[absNode.toTex(), "=", abs(sub.simplify()).toTex()],
|
|
53
|
+
["", "=", answer],
|
|
54
|
+
])}`;
|
|
55
|
+
};
|
|
56
|
+
const getKeys = (identifiers) => {
|
|
57
|
+
return [];
|
|
58
|
+
};
|
|
59
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
60
|
+
try {
|
|
61
|
+
const ansNode = parseAlgebraic(ans);
|
|
62
|
+
const answerNode = parseAlgebraic(answer);
|
|
63
|
+
return ansNode.equals(answerNode);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return handleVEAError(err);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const getCalculateDistanceBetweenNumbersQuestion = (ops) => {
|
|
70
|
+
const a = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
|
|
71
|
+
const b = coinFlip() ? randint(-10, 10, [a]) : randfloat(-10, 10, 2, [a]);
|
|
72
|
+
const identifiers = { a, b };
|
|
73
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
74
|
+
};
|
|
75
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
76
|
+
return {
|
|
77
|
+
answer: getAnswer(identifiers),
|
|
78
|
+
instruction: getInstruction(identifiers),
|
|
79
|
+
keys: getKeys(identifiers),
|
|
80
|
+
answerFormat: "tex",
|
|
81
|
+
identifiers,
|
|
82
|
+
hint: getHint(identifiers),
|
|
83
|
+
correction: getCorrection(identifiers),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export const calculateDistanceBetweenNumbers = {
|
|
87
|
+
id: "calculateDistanceBetweenNumbers",
|
|
88
|
+
label: "Calculer la distance entre deux nombres",
|
|
89
|
+
isSingleStep: true,
|
|
90
|
+
generator: (nb, opts) => getDistinctQuestions(() => getCalculateDistanceBetweenNumbersQuestion(opts), nb),
|
|
91
|
+
qcmTimer: 60,
|
|
92
|
+
freeTimer: 60,
|
|
93
|
+
getPropositions,
|
|
94
|
+
isAnswerValid,
|
|
95
|
+
subject: "Mathématiques",
|
|
96
|
+
getInstruction,
|
|
97
|
+
getHint,
|
|
98
|
+
getCorrection,
|
|
99
|
+
getAnswer,
|
|
100
|
+
getQuestionFromIdentifiers,
|
|
101
|
+
hasHintAndCorrection: true,
|
|
102
|
+
};
|
|
@@ -17,4 +17,5 @@ export * from "./isPointOnReciprocalFunction.js";
|
|
|
17
17
|
export * from "./isPointOnFunction.js";
|
|
18
18
|
export * from "./whichMultipleAmI.js";
|
|
19
19
|
export * from "./isMultipleOrDivisor.js";
|
|
20
|
+
export * from "./calculateDistanceBetweenNumbers.js";
|
|
20
21
|
//# 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,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"}
|
|
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,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,sCAAsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inverseOrOpposite.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/sign/inverseOrOpposite.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IAEV,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AA2EF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAiBnD,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
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 { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
5
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
6
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
7
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
8
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
9
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
10
|
+
const getPropositions = (n, { answer, a }) => {
|
|
11
|
+
const propositions = [];
|
|
12
|
+
addValidProp(propositions, answer);
|
|
13
|
+
tryToAddWrongProp(propositions, substract(1, a).simplify().toTex());
|
|
14
|
+
tryToAddWrongProp(propositions, `${-a}`);
|
|
15
|
+
tryToAddWrongProp(propositions, frac(1, a).toTex());
|
|
16
|
+
tryToAddWrongProp(propositions, frac(1, -a).toTex());
|
|
17
|
+
return shuffleProps(propositions, n);
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = (identifiers) => {
|
|
20
|
+
const { a, isOpposite } = identifiers;
|
|
21
|
+
return isOpposite ? `${-a}` : frac(1, a).simplify().toTex();
|
|
22
|
+
};
|
|
23
|
+
const getInstruction = (identifiers) => {
|
|
24
|
+
const { a, isOpposite } = identifiers;
|
|
25
|
+
return `Quel est l'${isOpposite ? "opposé" : "inverse"} de $${a}$ ?`;
|
|
26
|
+
};
|
|
27
|
+
const getHint = (identifiers) => {
|
|
28
|
+
return `L'opposé d'un nombre $x$ est $-x$.
|
|
29
|
+
|
|
30
|
+
L'inverse d'un nombre $x$ (différent de $0$) est $\\frac{1}{x}$.`;
|
|
31
|
+
};
|
|
32
|
+
const getCorrection = (identifiers) => {
|
|
33
|
+
const { a, isOpposite } = identifiers;
|
|
34
|
+
const node = isOpposite ? opposite(a) : frac(1, a);
|
|
35
|
+
const nodeTex = node.toTex({
|
|
36
|
+
allowDoubleMinus: true,
|
|
37
|
+
allowMinusAnywhereInFraction: true,
|
|
38
|
+
});
|
|
39
|
+
const simp = node.simplify();
|
|
40
|
+
const isSimplifiable = nodeTex !== simp.toTex();
|
|
41
|
+
return `L'${isOpposite ? "opposé" : "inverse"} de $${a}$ est :
|
|
42
|
+
|
|
43
|
+
$$
|
|
44
|
+
${nodeTex} ${isSimplifiable ? `= ${simp.toTex()}` : ""}
|
|
45
|
+
$$`;
|
|
46
|
+
};
|
|
47
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
48
|
+
try {
|
|
49
|
+
const parsed = parseAlgebraic(ans);
|
|
50
|
+
return parsed.simplify({ decimalToFractions: true }).toTex() === answer;
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
return handleVEAError(err);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const getInverseOrOppositeQuestion = (ops) => {
|
|
57
|
+
const a = randint(-50, 50, [0]);
|
|
58
|
+
const isOpposite = coinFlip();
|
|
59
|
+
const identifiers = { a, isOpposite };
|
|
60
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
61
|
+
};
|
|
62
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
63
|
+
return {
|
|
64
|
+
answer: getAnswer(identifiers),
|
|
65
|
+
instruction: getInstruction(identifiers),
|
|
66
|
+
keys: [],
|
|
67
|
+
answerFormat: "tex",
|
|
68
|
+
identifiers,
|
|
69
|
+
hint: getHint(identifiers),
|
|
70
|
+
correction: getCorrection(identifiers),
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export const inverseOrOpposite = {
|
|
74
|
+
id: "inverseOrOpposite",
|
|
75
|
+
label: "Distinguer inverse et opposé",
|
|
76
|
+
isSingleStep: true,
|
|
77
|
+
generator: (nb, opts) => getDistinctQuestions(() => getInverseOrOppositeQuestion(opts), nb),
|
|
78
|
+
qcmTimer: 60,
|
|
79
|
+
freeTimer: 60,
|
|
80
|
+
getPropositions,
|
|
81
|
+
isAnswerValid,
|
|
82
|
+
subject: "Mathématiques",
|
|
83
|
+
getInstruction,
|
|
84
|
+
getHint,
|
|
85
|
+
getCorrection,
|
|
86
|
+
getAnswer,
|
|
87
|
+
getQuestionFromIdentifiers,
|
|
88
|
+
hasHintAndCorrection: true,
|
|
89
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parityFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/parity/parityFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"parityFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/parity/parityFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmJF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
|
|
@@ -79,6 +79,19 @@ const getParityFromGraphQuestion = () => {
|
|
|
79
79
|
const identifiers = { type, fctCmd: fct };
|
|
80
80
|
return getQuestionFromIdentifiers(identifiers);
|
|
81
81
|
};
|
|
82
|
+
const getHint = (identifiers) => {
|
|
83
|
+
return `Une fonction $f$ est paire si sa courbe représentative est symétrique par rapport à l'axe des ordonnées.
|
|
84
|
+
|
|
85
|
+
Une fonction $f$ est impaire si sa courbe représentative est symétrique par rapport à l'origine du repère.`;
|
|
86
|
+
};
|
|
87
|
+
const getCorrection = (identifiers) => {
|
|
88
|
+
const type = identifiers.type;
|
|
89
|
+
if (type === "even")
|
|
90
|
+
return `La courbe représentative de $f$ est symétrique par rapport à l'axe des ordonnées : la fonction $f$ est donc paire.`;
|
|
91
|
+
if (type === "uneven")
|
|
92
|
+
return `La courbe représentative de $f$ est symétrique par rapport à l'origine du repère : la fonction $f$ est donc impaire.`;
|
|
93
|
+
return `La courbe représentative de $f$ n'est ni symétrique par rapport à l'axe des ordonnées, ni symétrique par rapport à l'origine du repère : la fonction $f$ n'est donc ni paire, ni impaire.`;
|
|
94
|
+
};
|
|
82
95
|
const getInstruction = (identifiers) => {
|
|
83
96
|
return `La fonction $f$ représentée ci-dessous est-elle paire, impaire, ou ni paire ni impaire ?`;
|
|
84
97
|
};
|
|
@@ -113,6 +126,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
113
126
|
ggbOptions: getGGBOptions(identifiers),
|
|
114
127
|
answerFormat: "tex",
|
|
115
128
|
identifiers,
|
|
129
|
+
hint: getHint(identifiers),
|
|
130
|
+
correction: getCorrection(identifiers),
|
|
116
131
|
};
|
|
117
132
|
return question;
|
|
118
133
|
};
|
|
@@ -136,5 +151,6 @@ export const parityFromGraph = {
|
|
|
136
151
|
answerType: "QCU",
|
|
137
152
|
hasGeogebra: true,
|
|
138
153
|
subject: "Mathématiques",
|
|
154
|
+
hasHintAndCorrection: true,
|
|
139
155
|
getQuestionFromIdentifiers,
|
|
140
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probaFromTableNoContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableNoContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,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":"probaFromTableNoContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableNoContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,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;AAyTF,KAAK,OAAO,GAAG;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAuBF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBlE,CAAC"}
|
|
@@ -149,7 +149,7 @@ const getCorrection = (identifiers) => {
|
|
|
149
149
|
: event === "P(\\overline A)"
|
|
150
150
|
? "\\overline{A}"
|
|
151
151
|
: "\\overline{B}";
|
|
152
|
-
return `On lit le total de la ligne $${singleEvnmt}$ : c'est $${probaFrac[0]}$. La probabilité $${event}$ vaut donc :
|
|
152
|
+
return `On lit le total de la ${singleEvnmt.includes("A") ? "ligne" : "colonne"} $${singleEvnmt}$ : c'est $${probaFrac[0]}$. La probabilité $${event}$ vaut donc :
|
|
153
153
|
|
|
154
154
|
$$
|
|
155
155
|
${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
|
|
@@ -2,6 +2,7 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercis
|
|
|
2
2
|
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { Rational } from "../../../math/numbers/rationals/rational.js";
|
|
4
4
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
5
|
+
import { frac } from "../../../tree/nodes/operators/fractionNode.js";
|
|
5
6
|
import { rationalParser } from "../../../tree/parsers/rationalParser.js";
|
|
6
7
|
import { random } from "../../../utils/alea/random.js";
|
|
7
8
|
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
@@ -145,133 +146,92 @@ const isAnswerValid = (ans, { answer, probaFrac }, options) => {
|
|
|
145
146
|
return handleVEAError(err);
|
|
146
147
|
}
|
|
147
148
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
// : event === "P(\\overline A \\cup B)"
|
|
235
|
-
// ? ["\\overline{A}", "B"]
|
|
236
|
-
// : ["\\overline{A}", "\\overline{B}"];
|
|
237
|
-
// return `On lit la case à l'intersection de la colonne $${
|
|
238
|
-
// interEvemnts[1]
|
|
239
|
-
// }$ et de la ligne $${interEvemnts[0]}$ : c'est $${
|
|
240
|
-
// probaFrac[0]
|
|
241
|
-
// }$. La probabilité $${event}$ vaut donc :
|
|
242
|
-
// $$
|
|
243
|
-
// ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
|
|
244
|
-
// $$`;
|
|
245
|
-
// const condEvents =
|
|
246
|
-
// event === "P_A(B)"
|
|
247
|
-
// ? ["A", "B"]
|
|
248
|
-
// : event === "P_{\\overline A}(B)"
|
|
249
|
-
// ? ["\\overline{A}", "B"]
|
|
250
|
-
// : event === "P_A(\\overline B)"
|
|
251
|
-
// ? ["A", "\\overline{B}"]
|
|
252
|
-
// : event === "P_{\\overline B}(A)"
|
|
253
|
-
// ? ["\\overline{B}", "A"]
|
|
254
|
-
// : event === "P_B(A)"
|
|
255
|
-
// ? ["B", "A"]
|
|
256
|
-
// : event === "P_B(\\overline{A})"
|
|
257
|
-
// ? ["B", "\\overline{A}"]
|
|
258
|
-
// : event === "P_{\\overline A}(\\overline B)"
|
|
259
|
-
// ? ["\\overline{A}", "\\overline{B}"]
|
|
260
|
-
// : ["\\overline{B}", "\\overline{A}"];
|
|
261
|
-
// return `On cherche la probabilité de $${condEvents[1]}$ sachant que $${
|
|
262
|
-
// condEvents[0]
|
|
263
|
-
// }$ est vrai. On lit la case à l'intersection de $${
|
|
264
|
-
// condEvents[1]
|
|
265
|
-
// }$ et $${condEvents[0]}$ : c'est $${
|
|
266
|
-
// probaFrac[0]
|
|
267
|
-
// }$. On doit ensuite diviser par le total de l'évènement $${
|
|
268
|
-
// condEvents[0]
|
|
269
|
-
// }$. La probabilité $${event}$ vaut donc :
|
|
270
|
-
// $$
|
|
271
|
-
// ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
|
|
272
|
-
// $$`;
|
|
273
|
-
// }
|
|
274
|
-
// };
|
|
149
|
+
const getHint = (identifiers) => {
|
|
150
|
+
const { aBarreCapB, aBarreCapBBarre, aCapB, aCapBBarre, probaFrac, type, event, } = identifiers;
|
|
151
|
+
switch (type) {
|
|
152
|
+
case "singleEvent":
|
|
153
|
+
return `Lit le total d'issues de l'évènement demandé, puis divise par le total des issues.`;
|
|
154
|
+
case "union":
|
|
155
|
+
return `Compte toutes les issues qui sont soit dans le premier événement, soit dans le second (ou à la fois dans les deux). Attention à ne pas compter certaines issues en double.`;
|
|
156
|
+
case "intersection":
|
|
157
|
+
default:
|
|
158
|
+
return `Lit la case qui correspond aux issues appartenant à la fois aux deux événements demandés.`;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const getCorrection = (identifiers) => {
|
|
162
|
+
const { aBarreCapB, aBarreCapBBarre, aCapB, aCapBBarre, probaFrac, type, event, } = identifiers;
|
|
163
|
+
const aTotal = aCapB + aCapBBarre;
|
|
164
|
+
const bTotal = aCapB + aBarreCapB;
|
|
165
|
+
const aBarreTotal = aBarreCapB + aBarreCapBBarre;
|
|
166
|
+
const bBarreTotal = aBarreCapBBarre + aCapBBarre;
|
|
167
|
+
switch (type) {
|
|
168
|
+
case "singleEvent":
|
|
169
|
+
const singleEvnmt = event === "une fille"
|
|
170
|
+
? "A"
|
|
171
|
+
: event === "un garçon"
|
|
172
|
+
? "\\overline{A}"
|
|
173
|
+
: event === "un élève qui porte des lunettes"
|
|
174
|
+
? "B"
|
|
175
|
+
: "\\overline{B}";
|
|
176
|
+
return `On lit le total de la ligne $${singleEvnmt}$ : c'est $${probaFrac[0]}$. La probabilité recherchée vaut donc :
|
|
177
|
+
|
|
178
|
+
$$
|
|
179
|
+
${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
|
|
180
|
+
$$`;
|
|
181
|
+
case "union":
|
|
182
|
+
const unionEvements = event === "P(A\\cup B)"
|
|
183
|
+
? ["A", "B"]
|
|
184
|
+
: event === "P(A\\cup \\overline B)"
|
|
185
|
+
? ["A", "\\overline{B}"]
|
|
186
|
+
: event === "P(\\overline A \\cup B)"
|
|
187
|
+
? ["\\overline{A}", "B"]
|
|
188
|
+
: ["\\overline{A}", "\\overline{B}"];
|
|
189
|
+
const rowTotal = unionEvements[0] === "A" ? aTotal : aBarreTotal;
|
|
190
|
+
const columnTotal = unionEvements[1] === "B" ? bTotal : bBarreTotal;
|
|
191
|
+
return `On additionne les totaux de la ligne $${unionEvements[0]}$ et de la colonne $${unionEvements[1]}$ : cela donne $${rowTotal} + ${columnTotal} = ${rowTotal + columnTotal}$. On doit ensuite soustraire la case à l'intersection de la ligne $${unionEvements[0]}$ et de la colonne $${unionEvements[1]}$, car on l'a compté deux fois dans les totaux. Cela donne $${rowTotal + columnTotal} - ${rowTotal + columnTotal - probaFrac[0]} = ${probaFrac[0]}
|
|
192
|
+
$.
|
|
193
|
+
|
|
194
|
+
La probabilité $${event}$ vaut donc :
|
|
195
|
+
|
|
196
|
+
$$
|
|
197
|
+
${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
|
|
198
|
+
$$`;
|
|
199
|
+
case "intersection":
|
|
200
|
+
default:
|
|
201
|
+
const interEvemnts = event === "P(A\\cup B)"
|
|
202
|
+
? ["A", "B"]
|
|
203
|
+
: event === "P(A\\cup \\overline B)"
|
|
204
|
+
? ["A", "\\overline{B}"]
|
|
205
|
+
: event === "P(\\overline A \\cup B)"
|
|
206
|
+
? ["\\overline{A}", "B"]
|
|
207
|
+
: ["\\overline{A}", "\\overline{B}"];
|
|
208
|
+
return `On lit la case à l'intersection de la colonne $${interEvemnts[1]}$ et de la ligne $${interEvemnts[0]}$ : c'est $${probaFrac[0]}$. La probabilité $${event}$ vaut donc :
|
|
209
|
+
|
|
210
|
+
$$
|
|
211
|
+
${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
|
|
212
|
+
$$`;
|
|
213
|
+
const condEvents = event === "P_A(B)"
|
|
214
|
+
? ["A", "B"]
|
|
215
|
+
: event === "P_{\\overline A}(B)"
|
|
216
|
+
? ["\\overline{A}", "B"]
|
|
217
|
+
: event === "P_A(\\overline B)"
|
|
218
|
+
? ["A", "\\overline{B}"]
|
|
219
|
+
: event === "P_{\\overline B}(A)"
|
|
220
|
+
? ["\\overline{B}", "A"]
|
|
221
|
+
: event === "P_B(A)"
|
|
222
|
+
? ["B", "A"]
|
|
223
|
+
: event === "P_B(\\overline{A})"
|
|
224
|
+
? ["B", "\\overline{A}"]
|
|
225
|
+
: event === "P_{\\overline A}(\\overline B)"
|
|
226
|
+
? ["\\overline{A}", "\\overline{B}"]
|
|
227
|
+
: ["\\overline{B}", "\\overline{A}"];
|
|
228
|
+
return `On cherche la probabilité de $${condEvents[1]}$ sachant que $${condEvents[0]}$ est vrai. On lit la case à l'intersection de $${condEvents[1]}$ et $${condEvents[0]}$ : c'est $${probaFrac[0]}$. On doit ensuite diviser par le total de l'évènement $${condEvents[0]}$. La probabilité $${event}$ vaut donc :
|
|
229
|
+
|
|
230
|
+
$$
|
|
231
|
+
${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
|
|
232
|
+
$$`;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
275
235
|
export const probaFromTableWithContext = {
|
|
276
236
|
id: "probaFromTableWithContext",
|
|
277
237
|
connector: "=",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditionIf.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/conditionIf.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"conditionIf.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/conditionIf.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CAGnB,CAAC;AAgHF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAY7C,CAAC"}
|
|
@@ -18,7 +18,7 @@ const getAnswer = (identifiers) => {
|
|
|
18
18
|
};
|
|
19
19
|
const getInstruction = (identifiers) => {
|
|
20
20
|
const { a, b, opName, condition } = identifiers;
|
|
21
|
-
return `Quel sera l'affichage du
|
|
21
|
+
return `Quel sera l'affichage du script en Python suivant ?
|
|
22
22
|
\`\`\`
|
|
23
23
|
a = ${a}
|
|
24
24
|
b = ${b}
|
|
@@ -38,6 +38,34 @@ const getConditionIfQuestion = () => {
|
|
|
38
38
|
const identifiers = { a, b, opName: operation.name, condition };
|
|
39
39
|
return getQuestionFromIdentifiers(identifiers);
|
|
40
40
|
};
|
|
41
|
+
const getHint = (identifiers) => {
|
|
42
|
+
const { opName, condition } = identifiers;
|
|
43
|
+
return `Calcule la valeur de $a$ après l'exécution de l'instruction $a = a ${opName} b$.
|
|
44
|
+
|
|
45
|
+
Ensuite, vérifie si la condition $${condition}$ est vraie ou fausse.`;
|
|
46
|
+
};
|
|
47
|
+
const getCorrection = (identifiers) => {
|
|
48
|
+
const { a, b, opName, condition } = identifiers;
|
|
49
|
+
const operation = operations.find((op) => op.name === opName);
|
|
50
|
+
const opresult = operation.func(a, b);
|
|
51
|
+
const finalValue = (condition === "a <= b" ? opresult <= b : opresult >= b)
|
|
52
|
+
? b
|
|
53
|
+
: opresult;
|
|
54
|
+
const branch = condition === "a <= b" ? opresult <= b : opresult >= b;
|
|
55
|
+
const branchText = branch
|
|
56
|
+
? `La condition $${condition}$ est donc vraie. On exécute alors le bloc \`if\` donc : $a = ${b}$.`
|
|
57
|
+
: `La condition $${condition}$ est donc fausse.`;
|
|
58
|
+
return `On calcule l'opération $a ${opName} b$ :
|
|
59
|
+
|
|
60
|
+
$$
|
|
61
|
+
${a} ${opName} ${b} = ${opresult}
|
|
62
|
+
$$
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
${branchText}
|
|
66
|
+
|
|
67
|
+
Le résultat final affiché sera : $${finalValue}$.`;
|
|
68
|
+
};
|
|
41
69
|
const getQuestionFromIdentifiers = (identifiers) => {
|
|
42
70
|
const question = {
|
|
43
71
|
answer: getAnswer(identifiers),
|
|
@@ -45,6 +73,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
45
73
|
keys: ["a", "b", "equal"],
|
|
46
74
|
answerFormat: "tex",
|
|
47
75
|
identifiers,
|
|
76
|
+
hint: getHint(identifiers),
|
|
77
|
+
correction: getCorrection(identifiers),
|
|
48
78
|
};
|
|
49
79
|
return question;
|
|
50
80
|
};
|
|
@@ -75,4 +105,5 @@ export const conditionIf = {
|
|
|
75
105
|
isAnswerValid,
|
|
76
106
|
subject: "Mathématiques",
|
|
77
107
|
getQuestionFromIdentifiers,
|
|
108
|
+
hasHintAndCorrection: true,
|
|
78
109
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
opName: string;
|
|
6
|
+
condition: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const conditionIfElse: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=conditionIfElse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionIfElse.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/conditionIfElse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA0HF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
|