math-exercises 3.0.75 → 3.0.77
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/compareInverseValues.d.ts +10 -0
- package/lib/exercises/math/calcul/arithmetics/compareInverseValues.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/compareInverseValues.js +136 -0
- package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.js +143 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +3 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +3 -0
- package/lib/exercises/math/calcul/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/cube/compareCubeValues.d.ts +8 -0
- package/lib/exercises/math/functions/cube/compareCubeValues.d.ts.map +1 -0
- package/lib/exercises/math/functions/cube/compareCubeValues.js +113 -0
- package/lib/exercises/math/functions/cube/index.d.ts +1 -0
- package/lib/exercises/math/functions/cube/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/cube/index.js +1 -0
- package/lib/exercises/math/functions/index.d.ts +1 -0
- package/lib/exercises/math/functions/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/index.js +1 -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/functions/sqrt/compareSqrtValues.d.ts +8 -0
- package/lib/exercises/math/functions/sqrt/compareSqrtValues.d.ts.map +1 -0
- package/lib/exercises/math/functions/sqrt/compareSqrtValues.js +83 -0
- package/lib/exercises/math/functions/sqrt/index.d.ts +2 -0
- package/lib/exercises/math/functions/sqrt/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/sqrt/index.js +1 -0
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.js +26 -1
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +47 -13
- package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts.map +1 -1
- package/lib/exercises/math/geometry/lines/linesRelativePositions.js +29 -5
- package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.d.ts +8 -0
- package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.js +108 -0
- package/lib/exercises/math/probaStat/getComplementaryProbability.d.ts +7 -0
- package/lib/exercises/math/probaStat/getComplementaryProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/getComplementaryProbability.js +90 -0
- package/lib/exercises/math/probaStat/getMissingProbabilityValue.d.ts +9 -0
- package/lib/exercises/math/probaStat/getMissingProbabilityValue.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/getMissingProbabilityValue.js +109 -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/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/probaStat/unionIntersectionProba.d.ts +11 -0
- package/lib/exercises/math/probaStat/unionIntersectionProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/unionIntersectionProba.js +164 -0
- 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/conditionIfElifElse.d.ts +9 -0
- package/lib/exercises/math/python/conditionIfElifElse.d.ts.map +1 -0
- package/lib/exercises/math/python/conditionIfElifElse.js +121 -0
- 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 +3 -0
- package/lib/exercises/math/python/index.d.ts.map +1 -1
- package/lib/exercises/math/python/index.js +3 -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/pyNestedForLoopExercise.d.ts.map +1 -1
- package/lib/exercises/math/python/pyNestedForLoopExercise.js +26 -10
- package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts +0 -1
- package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/python/pyWhileLoop1Exercise.js +54 -30
- package/lib/exercises/math/python/pythonFunctionTrinom.d.ts.map +1 -1
- package/lib/exercises/math/python/pythonFunctionTrinom.js +24 -2
- 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 +3 -3
- package/lib/exercises/math/sequences/explicitFormulaUsage.js +3 -3
- package/lib/exercises/math/sequences/genericSequenceVariations.js +2 -2
- package/lib/exercises/math/sets/index.d.ts +1 -0
- package/lib/exercises/math/sets/index.d.ts.map +1 -1
- package/lib/exercises/math/sets/index.js +1 -0
- package/lib/exercises/math/sets/nameOfNumberSets.d.ts +8 -0
- package/lib/exercises/math/sets/nameOfNumberSets.d.ts.map +1 -0
- package/lib/exercises/math/sets/nameOfNumberSets.js +125 -0
- package/lib/index.d.ts +55 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.d.ts.map +1 -1
- package/lib/latexTester.js +24 -7
- 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
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
a: NodeIdentifiers;
|
|
5
|
+
b: NodeIdentifiers;
|
|
6
|
+
isMinusInside: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const compareInverseValues: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=compareInverseValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareInverseValues.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/compareInverseValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAM7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAuIF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
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 { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
6
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
7
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
8
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
9
|
+
const getPropositions = (n, { answer }) => {
|
|
10
|
+
const propositions = [];
|
|
11
|
+
const symbols = ["<", "=", ">"];
|
|
12
|
+
addValidProp(propositions, answer);
|
|
13
|
+
const remaining = symbols.filter((s) => s !== answer);
|
|
14
|
+
for (const sym of remaining) {
|
|
15
|
+
tryToAddWrongProp(propositions, sym);
|
|
16
|
+
}
|
|
17
|
+
return shuffleProps(propositions, n);
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = ({ a, b }) => {
|
|
20
|
+
const aNode = reifyAlgebraic(a);
|
|
21
|
+
const bNode = reifyAlgebraic(b);
|
|
22
|
+
const aVal = aNode.simplify().evaluate();
|
|
23
|
+
const bVal = bNode.simplify().evaluate();
|
|
24
|
+
return aVal === bVal ? "=" : aVal < bVal ? ">" : "<";
|
|
25
|
+
};
|
|
26
|
+
const getInstruction = ({ a, b, isMinusInside, }) => {
|
|
27
|
+
const aNode = reifyAlgebraic(a);
|
|
28
|
+
const bNode = reifyAlgebraic(b);
|
|
29
|
+
return `Compléter par le bon symbole :
|
|
30
|
+
|
|
31
|
+
$$
|
|
32
|
+
${frac(1, aNode).toTex({
|
|
33
|
+
allowMinusAnywhereInFraction: isMinusInside,
|
|
34
|
+
})}\\ \\ldots \\ ${frac(1, bNode).toTex({
|
|
35
|
+
allowMinusAnywhereInFraction: isMinusInside,
|
|
36
|
+
})}
|
|
37
|
+
$$`;
|
|
38
|
+
};
|
|
39
|
+
const getHint = ({ a, b }) => {
|
|
40
|
+
return `Si $a$ et $b$ sont deux nombres non nuls et de même signe, alors la fonction inverse ne conserve pas l'ordre :
|
|
41
|
+
|
|
42
|
+
- $\\frac{1}{a} < \\frac{1}{b}$ si et seulement si $a>b$ ;
|
|
43
|
+
- $\\frac{1}{a} > \\frac{1}{b}$ si et seulement si $a<b$ ;
|
|
44
|
+
- $\\frac{1}{a} = \\frac{1}{b}$ si et seulement si $a=b$ ; `;
|
|
45
|
+
};
|
|
46
|
+
const getCorrection = (identifiers) => {
|
|
47
|
+
const { a, b, isMinusInside } = identifiers;
|
|
48
|
+
const aNode = reifyAlgebraic(a);
|
|
49
|
+
const bNode = reifyAlgebraic(b);
|
|
50
|
+
const aVal = aNode.simplify().evaluate();
|
|
51
|
+
const bVal = bNode.simplify().evaluate();
|
|
52
|
+
const signe = aVal < bVal ? "<" : aVal > bVal ? ">" : "=";
|
|
53
|
+
const answer = getAnswer(identifiers);
|
|
54
|
+
// return aVal === bVal ? "=" : aVal < bVal ? ">" : "<";
|
|
55
|
+
return `Puisque $${aNode.toTex()} ${signe} ${bNode.toTex()}$, et puisque ce sont deux nombres de même signe, leurs inverses sont dans l'ordre contraire :
|
|
56
|
+
|
|
57
|
+
$$
|
|
58
|
+
${frac(1, aNode).toTex({
|
|
59
|
+
allowMinusAnywhereInFraction: isMinusInside,
|
|
60
|
+
})} ${answer} ${frac(1, bNode).toTex({
|
|
61
|
+
allowMinusAnywhereInFraction: isMinusInside,
|
|
62
|
+
})}
|
|
63
|
+
$$
|
|
64
|
+
`;
|
|
65
|
+
};
|
|
66
|
+
const getKeys = () => [];
|
|
67
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
68
|
+
try {
|
|
69
|
+
return ans === answer;
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return handleVEAError(err);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function randBetween(isInteger, min, max, roundTo, excludes) {
|
|
76
|
+
if (isInteger) {
|
|
77
|
+
return randint(min, max, excludes);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return randfloat(min, max, roundTo, excludes);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const getCompareInverseValuesQuestion = () => {
|
|
84
|
+
const min = 2;
|
|
85
|
+
const max = 50;
|
|
86
|
+
const roundTo = 2;
|
|
87
|
+
const isInteger = coinFlip();
|
|
88
|
+
let x;
|
|
89
|
+
let y;
|
|
90
|
+
if (coinFlip()) {
|
|
91
|
+
// tous deux positifs
|
|
92
|
+
x = randBetween(isInteger, min, max, roundTo);
|
|
93
|
+
y = randBetween(isInteger, min, max, roundTo, [x]);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// tous deux négatifs
|
|
97
|
+
x = -randBetween(isInteger, min, max, roundTo);
|
|
98
|
+
y = -randBetween(isInteger, min, max, roundTo, [Math.abs(x)]);
|
|
99
|
+
}
|
|
100
|
+
const isMinusOutside = coinFlip();
|
|
101
|
+
const identifiers = {
|
|
102
|
+
a: x.toTree().toIdentifiers(),
|
|
103
|
+
b: y.toTree().toIdentifiers(),
|
|
104
|
+
isMinusInside: coinFlip(),
|
|
105
|
+
};
|
|
106
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
107
|
+
};
|
|
108
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
109
|
+
return {
|
|
110
|
+
answer: getAnswer(identifiers),
|
|
111
|
+
instruction: getInstruction(identifiers),
|
|
112
|
+
keys: getKeys(identifiers),
|
|
113
|
+
answerFormat: "tex",
|
|
114
|
+
identifiers,
|
|
115
|
+
hint: getHint(identifiers),
|
|
116
|
+
correction: getCorrection(identifiers),
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export const compareInverseValues = {
|
|
120
|
+
id: "compareInverseValues",
|
|
121
|
+
label: "Comparer des inverses",
|
|
122
|
+
isSingleStep: true,
|
|
123
|
+
generator: (nb, opts) => getDistinctQuestions(() => getCompareInverseValuesQuestion(opts), nb),
|
|
124
|
+
qcmTimer: 60,
|
|
125
|
+
freeTimer: 60,
|
|
126
|
+
getPropositions,
|
|
127
|
+
isAnswerValid,
|
|
128
|
+
subject: "Mathématiques",
|
|
129
|
+
getInstruction,
|
|
130
|
+
getHint,
|
|
131
|
+
getCorrection,
|
|
132
|
+
getAnswer,
|
|
133
|
+
getQuestionFromIdentifiers,
|
|
134
|
+
hasHintAndCorrection: true,
|
|
135
|
+
answerType: "QCU",
|
|
136
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
a: NodeIdentifiers;
|
|
5
|
+
b: NodeIdentifiers;
|
|
6
|
+
};
|
|
7
|
+
export declare const compareSquaredValues: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=compareSquaredValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareSquaredValues.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/compareSquaredValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAkJF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
6
|
+
import { square } from "../../../../tree/nodes/operators/powerNode.js";
|
|
7
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
8
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
9
|
+
const getPropositions = (n, { answer }) => {
|
|
10
|
+
const propositions = [];
|
|
11
|
+
const symbols = ["<", "=", ">"];
|
|
12
|
+
addValidProp(propositions, answer);
|
|
13
|
+
let remaining = symbols.filter((s) => s !== answer);
|
|
14
|
+
while (remaining.length > 0) {
|
|
15
|
+
tryToAddWrongProp(propositions, remaining[remaining.length - 1]);
|
|
16
|
+
remaining.pop();
|
|
17
|
+
}
|
|
18
|
+
return shuffleProps(propositions, n);
|
|
19
|
+
};
|
|
20
|
+
const getAnswer = (identifiers) => {
|
|
21
|
+
const { a, b } = identifiers;
|
|
22
|
+
const aNode = square(reifyAlgebraic(a));
|
|
23
|
+
const bNode = square(reifyAlgebraic(b));
|
|
24
|
+
const aValue = aNode.simplify({ calculatePowers: true }).evaluate();
|
|
25
|
+
const bValue = bNode.simplify({ calculatePowers: true }).evaluate();
|
|
26
|
+
const res = aValue === bValue ? "=" : aValue < bValue ? "<" : ">";
|
|
27
|
+
return res;
|
|
28
|
+
};
|
|
29
|
+
const getInstruction = (identifiers) => {
|
|
30
|
+
const { a, b } = identifiers;
|
|
31
|
+
const aNode = square(reifyAlgebraic(a));
|
|
32
|
+
const bNode = square(reifyAlgebraic(b));
|
|
33
|
+
return `Compléter par le bon symbole :
|
|
34
|
+
|
|
35
|
+
$$
|
|
36
|
+
${aNode.toTex()} \\ \\ldots \\ ${bNode.toTex()}
|
|
37
|
+
$$`;
|
|
38
|
+
};
|
|
39
|
+
const getHint = (identifiers) => {
|
|
40
|
+
const { a, b } = identifiers;
|
|
41
|
+
const aNode = reifyAlgebraic(a);
|
|
42
|
+
const bNode = reifyAlgebraic(b);
|
|
43
|
+
return `Pour tous nombres $a$ et $b$ tels que $a<b$ :
|
|
44
|
+
|
|
45
|
+
- Si $a$ et $b$ sont positifs, alors $a^2 <b^2$ ;
|
|
46
|
+
- Si $a$ et $b$ sont négatifs, alors $a^2 > b^2$.`;
|
|
47
|
+
};
|
|
48
|
+
const getCorrection = (identifiers) => {
|
|
49
|
+
const { a, b } = identifiers;
|
|
50
|
+
const aNode = reifyAlgebraic(a);
|
|
51
|
+
const bNode = reifyAlgebraic(b);
|
|
52
|
+
const simplifiedA = aNode.simplify({
|
|
53
|
+
calculatePowers: true,
|
|
54
|
+
});
|
|
55
|
+
const simplifiedB = bNode.simplify({ calculatePowers: true });
|
|
56
|
+
const valueA = simplifiedA.evaluate();
|
|
57
|
+
const valueB = simplifiedB.evaluate();
|
|
58
|
+
const sign = valueA < 0 ? "négatif" : "positif";
|
|
59
|
+
const symbol = valueA < valueB ? "<" : valueA > valueB ? ">" : "=";
|
|
60
|
+
const answer = getAnswer(identifiers);
|
|
61
|
+
return `Puisque $${aNode.toTex()}$ et $${bNode.toTex()}$ sont ${sign}s, et puisque $${aNode.toTex()} ${symbol} ${bNode.toTex()}$, on a :
|
|
62
|
+
|
|
63
|
+
$$
|
|
64
|
+
${square(aNode).toTex()} ${answer} ${square(bNode).toTex()}
|
|
65
|
+
$$
|
|
66
|
+
|
|
67
|
+
`;
|
|
68
|
+
};
|
|
69
|
+
const getKeys = (identifiers) => {
|
|
70
|
+
return [];
|
|
71
|
+
};
|
|
72
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
73
|
+
try {
|
|
74
|
+
throw Error("VEA not implemented");
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
return handleVEAError(err);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const randCase = () => Math.floor(Math.random() * 2);
|
|
81
|
+
function randBetween(isInteger, min, max, roundTo, excludes) {
|
|
82
|
+
if (isInteger) {
|
|
83
|
+
return randint(min, max, excludes);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return randfloat(min, max, roundTo, excludes);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const getCompareSquaredValuesQuestion = (ops) => {
|
|
90
|
+
const min = 0;
|
|
91
|
+
const max = 50;
|
|
92
|
+
const roundTo = 2;
|
|
93
|
+
const caseType = randCase();
|
|
94
|
+
const isInteger = coinFlip();
|
|
95
|
+
let a;
|
|
96
|
+
let b;
|
|
97
|
+
switch (caseType) {
|
|
98
|
+
case 0:
|
|
99
|
+
// tous deux positifs
|
|
100
|
+
a = randBetween(isInteger, min, max, roundTo);
|
|
101
|
+
b = randBetween(isInteger, min, max, roundTo, [a]);
|
|
102
|
+
break;
|
|
103
|
+
case 1:
|
|
104
|
+
// tous deux négatifs
|
|
105
|
+
a = -randBetween(isInteger, min, max, roundTo);
|
|
106
|
+
b = -randBetween(isInteger, min, max, roundTo, [-a]);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
const identifiers = {
|
|
110
|
+
a: a.toTree().toIdentifiers(),
|
|
111
|
+
b: b.toTree().toIdentifiers(),
|
|
112
|
+
};
|
|
113
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
114
|
+
};
|
|
115
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
116
|
+
return {
|
|
117
|
+
answer: getAnswer(identifiers),
|
|
118
|
+
instruction: getInstruction(identifiers),
|
|
119
|
+
keys: getKeys(identifiers),
|
|
120
|
+
answerFormat: "tex",
|
|
121
|
+
identifiers,
|
|
122
|
+
hint: getHint(identifiers),
|
|
123
|
+
correction: getCorrection(identifiers),
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export const compareSquaredValues = {
|
|
127
|
+
id: "compareSquaredValues",
|
|
128
|
+
label: "Comparer des nombres élevés au carré",
|
|
129
|
+
isSingleStep: true,
|
|
130
|
+
generator: (nb, opts) => getDistinctQuestions(() => getCompareSquaredValuesQuestion(opts), nb),
|
|
131
|
+
qcmTimer: 60,
|
|
132
|
+
freeTimer: 60,
|
|
133
|
+
getPropositions,
|
|
134
|
+
isAnswerValid,
|
|
135
|
+
subject: "Mathématiques",
|
|
136
|
+
getInstruction,
|
|
137
|
+
getHint,
|
|
138
|
+
getCorrection,
|
|
139
|
+
getAnswer,
|
|
140
|
+
getQuestionFromIdentifiers,
|
|
141
|
+
hasHintAndCorrection: true,
|
|
142
|
+
answerType: "QCU",
|
|
143
|
+
};
|
|
@@ -17,4 +17,7 @@ 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 "./compareInverseValues.js";
|
|
21
|
+
export * from "./calculateDistanceBetweenNumbers.js";
|
|
22
|
+
export * from "./compareSquaredValues.js";
|
|
20
23
|
//# 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,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC"}
|
|
@@ -17,3 +17,6 @@ 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 "./compareInverseValues.js";
|
|
21
|
+
export * from "./calculateDistanceBetweenNumbers.js";
|
|
22
|
+
export * from "./compareSquaredValues.js";
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareCubeValues.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/cube/compareCubeValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuGF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAiBnD,CAAC"}
|