math-exercises 3.0.172 → 3.0.173
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/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +12 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/parabole/index.js +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts +8 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.js +106 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts +14 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.js +186 -0
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts +6 -2
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.js +98 -13
- package/lib/exercises/math/geometry/lines/index.d.ts +1 -0
- package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/lines/index.js +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts +13 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.js +195 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +1 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.js +119 -0
- package/lib/exercises/math/python/sequences/index.d.ts +8 -0
- package/lib/exercises/math/python/sequences/index.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/index.js +7 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.js +274 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.js +368 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts +13 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.js +254 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts +14 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.js +365 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.js +298 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.js +408 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts +17 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.js +498 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts +12 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.js +191 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.js +153 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +184 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +210 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.js +161 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +188 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +6 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.js +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.js +233 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.js +111 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.js +216 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts +7 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.js +94 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.js +4 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +301 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +260 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +186 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.js +142 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.js +205 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.js +208 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.js +152 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/index.js +5 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.js +248 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.js +126 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts +8 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.js +91 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/index.js +3 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts +2 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.js +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts +14 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.js +202 -0
- package/lib/exercises/options/optionFirstTermRankOne.d.ts +16 -0
- package/lib/exercises/options/optionFirstTermRankOne.d.ts.map +1 -0
- package/lib/exercises/options/optionFirstTermRankOne.js +17 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts +16 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts.map +1 -0
- package/lib/exercises/options/optionIsUsePythonDef.js +17 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts +16 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts.map +1 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.js +17 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
- package/lib/exercises/vea/colinearVectorVEA.d.ts +2 -0
- package/lib/exercises/vea/colinearVectorVEA.d.ts.map +1 -0
- package/lib/exercises/vea/colinearVectorVEA.js +11 -0
- package/lib/exercises/vea/varLineVEA.d.ts.map +1 -1
- package/lib/exercises/vea/varLineVEA.js +5 -2
- package/lib/index.d.ts +25 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +3 -3
- package/lib/math/geometry/point.d.ts +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +4 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +53 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +1928 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +15 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +136 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts +42 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.js +932 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts +12 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.js +90 -0
- package/lib/tests/exosTest.d.ts.map +1 -1
- package/lib/tests/exosTest.js +0 -2
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +3 -3
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/binomialCoefficientNode.js +6 -3
- package/lib/tree/parsers/vectorParser.d.ts.map +1 -1
- package/lib/tree/parsers/vectorParser.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getOptionFirstTermRankOneStuff, } from "../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { round } from "../../../../math/utils/round.js";
|
|
6
|
+
import { EqualNode, isEqualNode, } from "../../../../tree/nodes/equations/equalNode.js";
|
|
7
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
8
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
9
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
10
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
11
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
12
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
13
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
14
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
15
|
+
const getInstruction = (identifiers) => {
|
|
16
|
+
const { rank1, value1, rank2, value2 } = identifiers;
|
|
17
|
+
return `Soit $u$ une suite arithmétique telle que $u_{${rank1}} = ${value1}$ et $u_{${rank2}} = ${value2}$.
|
|
18
|
+
|
|
19
|
+
Donner l'expression de $u_n$ en fonction de $n$.`;
|
|
20
|
+
};
|
|
21
|
+
const getAnswerNode = (identifiers, opts) => {
|
|
22
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
23
|
+
const { rank1, value1, rank2, value2 } = identifiers;
|
|
24
|
+
const reason = frac(substract(value2, value1), substract(rank2, rank1)).evaluate();
|
|
25
|
+
const valueFirstRank = value1 - (rank1 - firstRank) * reason;
|
|
26
|
+
const nodeFormula = add(valueFirstRank, multiply(reason, substract("n".toTree(), firstRank).simplify()));
|
|
27
|
+
const equalNode = new EqualNode("u_n".toTree(), nodeFormula);
|
|
28
|
+
return equalNode;
|
|
29
|
+
};
|
|
30
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
31
|
+
const opts = optsIn ?? optsDefault;
|
|
32
|
+
return getAnswerNode(identifiers, opts).toTex();
|
|
33
|
+
};
|
|
34
|
+
const getHint = (_, optsIn) => {
|
|
35
|
+
const opts = optsIn ?? optsDefault;
|
|
36
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
37
|
+
return `Commence par déterminer la raison $r$ de la suite $u$.
|
|
38
|
+
|
|
39
|
+
Puis, utilise cette raison et un des termes connus de la suite pour déterminer $u_{${firstRank}}$.`;
|
|
40
|
+
};
|
|
41
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
42
|
+
const opts = optsIn ?? optsDefault;
|
|
43
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
44
|
+
const { rank1, value1, rank2, value2 } = identifiers;
|
|
45
|
+
const reason = round((value2 - value1) / (rank2 - rank1), 0);
|
|
46
|
+
const closest = Math.abs(firstRank - rank1) < Math.abs(firstRank - rank2) ? rank1 : rank2;
|
|
47
|
+
const diff = firstRank - closest;
|
|
48
|
+
const closestValue = closest === rank1 ? value1 : value2;
|
|
49
|
+
return `On commence par déterminer la raison $r$ de la suite $u$ :
|
|
50
|
+
|
|
51
|
+
${alignTex([
|
|
52
|
+
["r", "=", `\\frac{u_{${rank2}} - u_{${rank1}}}{${rank2}-${rank1}}`],
|
|
53
|
+
[
|
|
54
|
+
"",
|
|
55
|
+
"=",
|
|
56
|
+
frac(substract(value2, value1), substract(rank2, rank1).simplify()).toTex(),
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
"",
|
|
60
|
+
"=",
|
|
61
|
+
frac(substract(value2, value1), substract(rank2, rank1)).simplify().toTex(),
|
|
62
|
+
],
|
|
63
|
+
])}
|
|
64
|
+
|
|
65
|
+
On peut alors déterminer $u_{${firstRank}}$ en utilisant $u_{${closest}}$ et $r$. En effet, on a :
|
|
66
|
+
|
|
67
|
+
${alignTex([
|
|
68
|
+
[`u_{${firstRank}}`, "=", add(`u_{${closest}}`, multiply(diff, "r")).toTex()],
|
|
69
|
+
["", "=", add(closestValue, multiply(diff, reason)).toTex()],
|
|
70
|
+
["", "=", add(closestValue, multiply(diff, reason)).simplify().toTex()],
|
|
71
|
+
])}
|
|
72
|
+
|
|
73
|
+
On a donc :
|
|
74
|
+
|
|
75
|
+
${(() => {
|
|
76
|
+
const texFormulaAbstract = firstRank === 0 ? "u_0 + r \\times n" : "u_1 + r \\times (n-1)";
|
|
77
|
+
return alignTex([
|
|
78
|
+
["u_n", "=", texFormulaAbstract],
|
|
79
|
+
["", "=", getAnswerNode(identifiers, opts).rightChild.toTex()],
|
|
80
|
+
]);
|
|
81
|
+
})()}
|
|
82
|
+
|
|
83
|
+
`;
|
|
84
|
+
};
|
|
85
|
+
const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
86
|
+
const opts = optsIn ?? optsDefault;
|
|
87
|
+
// const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
88
|
+
const propositions = [];
|
|
89
|
+
addValidProp(propositions, answer);
|
|
90
|
+
const { rank1, value1, rank2, value2 } = identifiers;
|
|
91
|
+
const reason = frac(substract(value2, value1), substract(rank2, rank1)).evaluate();
|
|
92
|
+
// const valueFirstRank = value1 - (rank1 - firstRank) * reason;
|
|
93
|
+
// //student: geometric instead of arithmetic
|
|
94
|
+
// {
|
|
95
|
+
// const nodeFormula = multiply(
|
|
96
|
+
// valueFirstRank,
|
|
97
|
+
// power(reason, substract("n".toTree(), firstRank).simplify()),
|
|
98
|
+
// );
|
|
99
|
+
// const equalNode = new EqualNode("u_n".toTree(), nodeFormula);
|
|
100
|
+
// tryToAddWrongProp(propositions, equalNode.toTex());
|
|
101
|
+
// }
|
|
102
|
+
//student: starts at rank1 instead of firstRank
|
|
103
|
+
{
|
|
104
|
+
const nodeFormula = add(value1, multiply(reason, substract("n".toTree(), rank1).simplify()));
|
|
105
|
+
const equalNode = new EqualNode("u_n".toTree(), nodeFormula);
|
|
106
|
+
tryToAddWrongProp(propositions, equalNode.toTex());
|
|
107
|
+
}
|
|
108
|
+
propWhile(propositions, n, () => {
|
|
109
|
+
const reasonWrong = reason + randint(-2, 2, [0]);
|
|
110
|
+
const value2 = reasonWrong * (rank2 - rank1) + value1;
|
|
111
|
+
const identifiersWrong = Object.assign({}, identifiers, { value2 });
|
|
112
|
+
const texAnswerWrong = getAnswer(identifiersWrong, opts);
|
|
113
|
+
tryToAddWrongProp(propositions, texAnswerWrong);
|
|
114
|
+
});
|
|
115
|
+
return shuffle(propositions);
|
|
116
|
+
};
|
|
117
|
+
const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
|
|
118
|
+
const opts = optsIn ?? optsDefault;
|
|
119
|
+
try {
|
|
120
|
+
if (!ans.includes("=")) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
//TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
|
|
124
|
+
// const nodeAns = parseAlgebraic(ans);
|
|
125
|
+
const nodeAns = (() => {
|
|
126
|
+
const [lhs, rhs] = ans.split("=");
|
|
127
|
+
const nodeLhs = lhs.toTree();
|
|
128
|
+
const nodeRhs = parseAlgebraic(rhs);
|
|
129
|
+
return new EqualNode(nodeLhs, nodeRhs);
|
|
130
|
+
})();
|
|
131
|
+
if (!isEqualNode(nodeAns)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const nodeAnswer = getAnswerNode(identifiers, opts);
|
|
135
|
+
const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
|
|
136
|
+
const isValidRhs = () => {
|
|
137
|
+
const nodeAnsRhs = nodeAns.rightChild;
|
|
138
|
+
const nodeAnswerRhs = nodeAnswer.rightChild;
|
|
139
|
+
return [0, 1, 2, 10].every((n) => {
|
|
140
|
+
return (substract(nodeAnsRhs.evaluate({ n }), nodeAnswerRhs.evaluate({ n })).evaluate() === 0);
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
return isValidLhs() && isValidRhs();
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
handleVEAError(e);
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const getArithmeticFindExplicitFormulaFromTwoTermsQuestion = (optsIn) => {
|
|
151
|
+
const opts = optsIn ?? optsDefault;
|
|
152
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
153
|
+
const rank1 = randint(firstRank + 1, 10);
|
|
154
|
+
const rank2 = rank1 + randint(2, 6);
|
|
155
|
+
const reason = randint(-10, 10, [0]);
|
|
156
|
+
const value1 = randint(-10, 10);
|
|
157
|
+
const value2 = reason * (rank2 - rank1) + value1;
|
|
158
|
+
const identifiers = { rank1, value1, rank2, value2 };
|
|
159
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
160
|
+
};
|
|
161
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
162
|
+
const question = {
|
|
163
|
+
answer: getAnswer(identifiers, opts),
|
|
164
|
+
instruction: getInstruction(identifiers, opts),
|
|
165
|
+
keys: ["un", "equal", "n"],
|
|
166
|
+
answerFormat: "tex",
|
|
167
|
+
identifiers,
|
|
168
|
+
hint: getHint(identifiers, opts),
|
|
169
|
+
correction: getCorrection(identifiers, opts),
|
|
170
|
+
options: opts,
|
|
171
|
+
};
|
|
172
|
+
return question;
|
|
173
|
+
};
|
|
174
|
+
const { optsDefaultFirstTermRankOne, generatorOptionFirstTermRankOne } = getOptionFirstTermRankOneStuff(false);
|
|
175
|
+
const optsDefault = Object.assign({}, optsDefaultFirstTermRankOne);
|
|
176
|
+
const options = [generatorOptionFirstTermRankOne];
|
|
177
|
+
export const arithmeticFindExplicitFormulaFromTwoTerms = {
|
|
178
|
+
id: "arithmeticFindExplicitFormulaFromTwoTerms",
|
|
179
|
+
connector: "=",
|
|
180
|
+
label: "Connaissant deux termes d'une suite arithmétique, en donner une formule générale",
|
|
181
|
+
isSingleStep: true,
|
|
182
|
+
generator: (nb, opts) => getDistinctQuestions(() => getArithmeticFindExplicitFormulaFromTwoTermsQuestion(opts), nb),
|
|
183
|
+
options,
|
|
184
|
+
qcmTimer: 60,
|
|
185
|
+
freeTimer: 60,
|
|
186
|
+
getPropositions,
|
|
187
|
+
isAnswerValid,
|
|
188
|
+
subject: "Mathématiques",
|
|
189
|
+
getQuestionFromIdentifiers,
|
|
190
|
+
hasHintAndCorrection: true,
|
|
191
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionFirstTermRankOne } from "../../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { OptionIsWithSuperfluousData } from "../../../../../exercises/options/optionIsWithSuperfluousData.js";
|
|
4
|
+
import { SituationArithmeticSuperfluousData } from "../../../../../math/utils/sequences/situations/seqArithmeticSituations.js";
|
|
5
|
+
type Identifiers = {
|
|
6
|
+
situationIndex: number;
|
|
7
|
+
initial: number;
|
|
8
|
+
reason: number;
|
|
9
|
+
superfluousData?: SituationArithmeticSuperfluousData;
|
|
10
|
+
};
|
|
11
|
+
type Options = OptionFirstTermRankOne & OptionIsWithSuperfluousData;
|
|
12
|
+
export declare const arithmeticFindExplicitFormulaFromSituation: Exercise<Identifiers, Options>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=arithmeticFindExplicitFormulaFromSituation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arithmeticFindExplicitFormulaFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAGhE,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAgB1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;CACtD,CAAC;AA+MF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,0CAA0C,EAAE,QAAQ,CAC/D,WAAW,EACX,OAAO,CAoBR,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getOptionFirstTermRankOneStuff, } from "../../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { getOptionIsWithSuperfluousData, } from "../../../../../exercises/options/optionIsWithSuperfluousData.js";
|
|
4
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
5
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
6
|
+
import { situationsArithmetic, } from "../../../../../math/utils/sequences/situations/seqArithmeticSituations.js";
|
|
7
|
+
import { EqualNode, isEqualNode, } from "../../../../../tree/nodes/equations/equalNode.js";
|
|
8
|
+
import { add } from "../../../../../tree/nodes/operators/addNode.js";
|
|
9
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
10
|
+
import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
11
|
+
import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
|
|
12
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
13
|
+
const getNodeFactor = (firstRank, varName = "n") => {
|
|
14
|
+
const nodeN = varName.toTree();
|
|
15
|
+
return firstRank === 0 ? nodeN : substract(nodeN, 1);
|
|
16
|
+
};
|
|
17
|
+
const situations = situationsArithmetic;
|
|
18
|
+
const getInstruction = (identifiers, optsIn) => {
|
|
19
|
+
const opts = optsIn ?? optsDefault;
|
|
20
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
21
|
+
const { situationIndex, initial, reason, superfluousData } = identifiers;
|
|
22
|
+
const situation = situations[situationIndex];
|
|
23
|
+
return `${situation.getStrSituation(initial, reason, firstRank, superfluousData)}
|
|
24
|
+
|
|
25
|
+
Donner l'expression de $u_n$ en fonction de $n$.`;
|
|
26
|
+
};
|
|
27
|
+
const getAnswerNode = (identifiers, opts) => {
|
|
28
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
29
|
+
const { situationIndex, initial, reason } = identifiers;
|
|
30
|
+
const situation = situations[situationIndex];
|
|
31
|
+
return situation.variationFindExplicitFormula.getAnswerNode(initial, reason, firstRank);
|
|
32
|
+
};
|
|
33
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
34
|
+
const opts = optsIn ?? optsDefault;
|
|
35
|
+
return getAnswerNode(identifiers, opts).toTex();
|
|
36
|
+
};
|
|
37
|
+
const getHint = (identifiers, optsIn) => {
|
|
38
|
+
const opts = optsIn ?? optsDefault;
|
|
39
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
40
|
+
const { situationIndex } = identifiers;
|
|
41
|
+
const situation = situations[situationIndex];
|
|
42
|
+
return situation.variationFindExplicitFormula.getHint(firstRank);
|
|
43
|
+
};
|
|
44
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
45
|
+
const opts = optsIn ?? optsDefault;
|
|
46
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
47
|
+
const { situationIndex, initial, reason } = identifiers;
|
|
48
|
+
const situation = situations[situationIndex];
|
|
49
|
+
return situation.variationFindExplicitFormula.getCorrectionStuff(initial, reason, firstRank).str;
|
|
50
|
+
};
|
|
51
|
+
const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
52
|
+
const opts = optsIn ?? optsDefault;
|
|
53
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
54
|
+
const propositions = [];
|
|
55
|
+
const { initial, reason } = identifiers;
|
|
56
|
+
const nodeFactor = getNodeFactor(firstRank);
|
|
57
|
+
addValidProp(propositions, answer);
|
|
58
|
+
//student: swaps(initial, reason)
|
|
59
|
+
tryToAddWrongProp(propositions, new EqualNode("u_n".toTree(), add(multiply(initial, nodeFactor), reason)).toTex());
|
|
60
|
+
//student: uses "x"
|
|
61
|
+
tryToAddWrongProp(propositions, new EqualNode("u_n".toTree(), add(multiply(reason, getNodeFactor(firstRank, "x")), initial)).toTex());
|
|
62
|
+
//student: u_n = initial * reason + n
|
|
63
|
+
tryToAddWrongProp(propositions, new EqualNode("u_n".toTree(), add(multiply(initial, reason), nodeFactor)).toTex());
|
|
64
|
+
//student: u_n = (initial + reason) * n
|
|
65
|
+
tryToAddWrongProp(propositions, new EqualNode("u_n".toTree(), multiply(add(initial, reason).simplify(), nodeFactor)).toTex());
|
|
66
|
+
return shuffleProps(propositions, n);
|
|
67
|
+
};
|
|
68
|
+
const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
|
|
69
|
+
const opts = optsIn ?? optsDefault;
|
|
70
|
+
try {
|
|
71
|
+
if (!ans.includes("=")) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
//TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
|
|
75
|
+
// const nodeAns = parseAlgebraic(ans);
|
|
76
|
+
const nodeAns = (() => {
|
|
77
|
+
const [lhs, rhs] = ans.split("=");
|
|
78
|
+
const nodeLhs = lhs.toTree();
|
|
79
|
+
const nodeRhs = parseAlgebraic(rhs);
|
|
80
|
+
return new EqualNode(nodeLhs, nodeRhs);
|
|
81
|
+
})();
|
|
82
|
+
if (!isEqualNode(nodeAns)) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const nodeAnswer = getAnswerNode(identifiers, opts);
|
|
86
|
+
const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
|
|
87
|
+
const isValidRhs = () => {
|
|
88
|
+
const nodeAnsRhs = nodeAns.rightChild;
|
|
89
|
+
const nodeAnswerRhs = nodeAnswer.rightChild;
|
|
90
|
+
return [0, 1, 2, 10].every((n) => {
|
|
91
|
+
return (substract(nodeAnsRhs.evaluate({ n }), nodeAnswerRhs.evaluate({ n })).evaluate() === 0);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return isValidLhs() && isValidRhs();
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
handleVEAError(e);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const getArithmeticFindExplicitFormulaFromSituationQuestion = (optsIn) => {
|
|
102
|
+
const opts = optsIn ?? optsDefault;
|
|
103
|
+
const { isWithSuperfluousData } = opts;
|
|
104
|
+
const situationIndex = randint(0, situations.length);
|
|
105
|
+
const situation = situations[situationIndex];
|
|
106
|
+
const initial = situation.randInitial();
|
|
107
|
+
const reason = situation.randReason();
|
|
108
|
+
const superfluousData = isWithSuperfluousData
|
|
109
|
+
? situation.randSuperfluousData()
|
|
110
|
+
: undefined;
|
|
111
|
+
const identifiers = {
|
|
112
|
+
situationIndex,
|
|
113
|
+
initial,
|
|
114
|
+
reason,
|
|
115
|
+
superfluousData,
|
|
116
|
+
};
|
|
117
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
118
|
+
};
|
|
119
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
120
|
+
const question = {
|
|
121
|
+
answer: getAnswer(identifiers, opts),
|
|
122
|
+
instruction: getInstruction(identifiers, opts),
|
|
123
|
+
keys: ["un", "equal", "n"],
|
|
124
|
+
answerFormat: "tex",
|
|
125
|
+
identifiers,
|
|
126
|
+
hint: getHint(identifiers, opts),
|
|
127
|
+
correction: getCorrection(identifiers, opts),
|
|
128
|
+
options: opts,
|
|
129
|
+
};
|
|
130
|
+
return question;
|
|
131
|
+
};
|
|
132
|
+
const optionsStuffFirstTermRankOne = getOptionFirstTermRankOneStuff(false);
|
|
133
|
+
const optionsStuffIsWithSuperfluousData = getOptionIsWithSuperfluousData(false);
|
|
134
|
+
const optsDefault = Object.assign({}, optionsStuffFirstTermRankOne.optsDefaultFirstTermRankOne, optionsStuffIsWithSuperfluousData.optsDefaultIsWithSuperfluousData);
|
|
135
|
+
const options = [
|
|
136
|
+
optionsStuffFirstTermRankOne.generatorOptionFirstTermRankOne,
|
|
137
|
+
optionsStuffIsWithSuperfluousData.generatorOptionIsWithSuperfluousData,
|
|
138
|
+
];
|
|
139
|
+
export const arithmeticFindExplicitFormulaFromSituation = {
|
|
140
|
+
id: "arithmeticFindExplicitFormulaFromSituation",
|
|
141
|
+
connector: "=",
|
|
142
|
+
label: "À partir d'une situation décrivant une évolution arithmétique, exprimer $u_n$ en fonction de $n$",
|
|
143
|
+
isSingleStep: true,
|
|
144
|
+
generator: (nb, opts) => getDistinctQuestions(() => getArithmeticFindExplicitFormulaFromSituationQuestion(opts), nb),
|
|
145
|
+
options,
|
|
146
|
+
qcmTimer: 60,
|
|
147
|
+
freeTimer: 60,
|
|
148
|
+
getPropositions,
|
|
149
|
+
isAnswerValid,
|
|
150
|
+
subject: "Mathématiques",
|
|
151
|
+
getQuestionFromIdentifiers,
|
|
152
|
+
hasHintAndCorrection: true,
|
|
153
|
+
};
|
package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionFirstTermRankOne } from "../../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { OptionIsWithSuperfluousData } from "../../../../../exercises/options/optionIsWithSuperfluousData.js";
|
|
4
|
+
import { SituationArithmeticSuperfluousData } from "../../../../../math/utils/sequences/situations/seqArithmeticSituations.js";
|
|
5
|
+
type Identifiers = {
|
|
6
|
+
situationIndex: number;
|
|
7
|
+
initial: number;
|
|
8
|
+
reason: number;
|
|
9
|
+
superfluousData?: SituationArithmeticSuperfluousData;
|
|
10
|
+
valueAsked: number;
|
|
11
|
+
};
|
|
12
|
+
type Options = OptionFirstTermRankOne & OptionIsWithSuperfluousData;
|
|
13
|
+
export declare const arithmeticFindRankFromSituation: Exercise<Identifiers, Options>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=arithmeticFindRankFromSituation.d.ts.map
|
package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arithmeticFindRankFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAKhE,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAK1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA6NF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmB1E,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getOptionFirstTermRankOneStuff, } from "../../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { getOptionIsWithSuperfluousData, } from "../../../../../exercises/options/optionIsWithSuperfluousData.js";
|
|
4
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
5
|
+
import { numberVEA } from "../../../../../exercises/vea/numberVEA.js";
|
|
6
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
7
|
+
import { round } from "../../../../../math/utils/round.js";
|
|
8
|
+
import { situationsArithmetic, } from "../../../../../math/utils/sequences/situations/seqArithmeticSituations.js";
|
|
9
|
+
import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
|
|
10
|
+
import { random } from "../../../../../utils/alea/random.js";
|
|
11
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
const situations = situationsArithmetic;
|
|
13
|
+
const getInstruction = (identifiers, optsIn) => {
|
|
14
|
+
const opts = optsIn ?? optsDefault;
|
|
15
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
16
|
+
const { situationIndex, initial, reason, superfluousData, valueAsked } = identifiers;
|
|
17
|
+
const situation = situations[situationIndex];
|
|
18
|
+
return `${situation.getStrSituation(initial, reason, firstRank, superfluousData)}
|
|
19
|
+
|
|
20
|
+
${situation.variationFindRank.getStrQuestion(initial, reason, firstRank, valueAsked)}`;
|
|
21
|
+
};
|
|
22
|
+
const getAnswerNode = (identifiers, opts) => {
|
|
23
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
24
|
+
const { situationIndex, initial, reason, valueAsked } = identifiers;
|
|
25
|
+
const situation = situations[situationIndex];
|
|
26
|
+
return situation.variationFindRank.getAnswerNode(initial, reason, firstRank, valueAsked);
|
|
27
|
+
};
|
|
28
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
29
|
+
const opts = optsIn ?? optsDefault;
|
|
30
|
+
return getAnswerNode(identifiers, opts).simplify().toTex();
|
|
31
|
+
};
|
|
32
|
+
const getHint = (identifiers, optsIn) => {
|
|
33
|
+
const opts = optsIn ?? optsDefault;
|
|
34
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
35
|
+
const { situationIndex, valueAsked } = identifiers;
|
|
36
|
+
const situation = situations[situationIndex];
|
|
37
|
+
return situation.variationFindRank.getHint(firstRank, valueAsked);
|
|
38
|
+
};
|
|
39
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
40
|
+
const opts = optsIn ?? optsDefault;
|
|
41
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
42
|
+
const { situationIndex, initial, reason, valueAsked } = identifiers;
|
|
43
|
+
const situation = situations[situationIndex];
|
|
44
|
+
return situation.variationFindRank.getCorrectionStuff(initial, reason, firstRank, valueAsked).str;
|
|
45
|
+
};
|
|
46
|
+
const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
47
|
+
const opts = optsIn ?? optsDefault;
|
|
48
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
49
|
+
const { situationIndex, initial, reason, valueAsked } = identifiers;
|
|
50
|
+
const situation = situations[situationIndex];
|
|
51
|
+
const propositions = [];
|
|
52
|
+
addValidProp(propositions, answer);
|
|
53
|
+
const arrNodeWrong = [];
|
|
54
|
+
//student: uses valueAsked as if it were rankAsked
|
|
55
|
+
{
|
|
56
|
+
const nodeWrong = situation.variationFindRandomTerm.getAnswerNode(initial, reason, firstRank, valueAsked);
|
|
57
|
+
tryToAddWrongProp(propositions, nodeWrong.simplify().toTex());
|
|
58
|
+
arrNodeWrong.push(nodeWrong);
|
|
59
|
+
}
|
|
60
|
+
const rankValid = round(situation.variationFindRank
|
|
61
|
+
.getAnswerNode(initial, reason, firstRank, valueAsked)
|
|
62
|
+
.evaluate(), 0);
|
|
63
|
+
//pseudo terror
|
|
64
|
+
if (coinFlip()) {
|
|
65
|
+
if (coinFlip()) {
|
|
66
|
+
//student: rankValid - 1
|
|
67
|
+
{
|
|
68
|
+
const nodeWrong = (rankValid - 1).toTree();
|
|
69
|
+
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
70
|
+
arrNodeWrong.push(nodeWrong);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
//student: rankValid + 1
|
|
75
|
+
{
|
|
76
|
+
const nodeWrong = (rankValid + 1).toTree();
|
|
77
|
+
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
78
|
+
arrNodeWrong.push(nodeWrong);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//random around
|
|
83
|
+
{
|
|
84
|
+
const nodeWrong = Math.max(1, rankValid + randint(-5, 6, [0])).toTree();
|
|
85
|
+
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
86
|
+
arrNodeWrong.push(nodeWrong);
|
|
87
|
+
}
|
|
88
|
+
//terror
|
|
89
|
+
{
|
|
90
|
+
const nodePicked = random(arrNodeWrong);
|
|
91
|
+
if (coinFlip()) {
|
|
92
|
+
if (coinFlip()) {
|
|
93
|
+
//student: rankValid - 1
|
|
94
|
+
{
|
|
95
|
+
const nodeWrong = (nodePicked.evaluate() - 1).toTree();
|
|
96
|
+
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
97
|
+
arrNodeWrong.push(nodeWrong);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
//student: rankValid + 1
|
|
102
|
+
{
|
|
103
|
+
const nodeWrong = (nodePicked.evaluate() + 1).toTree();
|
|
104
|
+
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
105
|
+
arrNodeWrong.push(nodeWrong);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//filler
|
|
111
|
+
{
|
|
112
|
+
propWhile(propositions, n, () => {
|
|
113
|
+
tryToAddWrongProp(propositions, randint(1, 25).frenchify());
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return shuffleProps(propositions, n);
|
|
117
|
+
};
|
|
118
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
119
|
+
try {
|
|
120
|
+
return numberVEA(ans, answer);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
return handleVEAError(err);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const getArithmeticFindRankFromSituationQuestion = (optsIn) => {
|
|
127
|
+
const opts = optsIn ?? optsDefault;
|
|
128
|
+
const { isWithSuperfluousData } = opts;
|
|
129
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
130
|
+
const situationIndex = randint(0, situations.length);
|
|
131
|
+
const situation = situations[situationIndex];
|
|
132
|
+
const initial = situation.randInitial();
|
|
133
|
+
const reason = situation.randReason();
|
|
134
|
+
const superfluousData = isWithSuperfluousData
|
|
135
|
+
? situation.randSuperfluousData()
|
|
136
|
+
: undefined;
|
|
137
|
+
const rankAsked = randint(4, 15);
|
|
138
|
+
const valueAsked = situation.variationFindRandomTerm
|
|
139
|
+
.getAnswerNode(initial, reason, firstRank, rankAsked)
|
|
140
|
+
.evaluate();
|
|
141
|
+
const identifiers = {
|
|
142
|
+
situationIndex,
|
|
143
|
+
initial,
|
|
144
|
+
reason,
|
|
145
|
+
superfluousData,
|
|
146
|
+
valueAsked,
|
|
147
|
+
};
|
|
148
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
149
|
+
};
|
|
150
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
151
|
+
const question = {
|
|
152
|
+
answer: getAnswer(identifiers, opts),
|
|
153
|
+
instruction: getInstruction(identifiers, opts),
|
|
154
|
+
keys: [],
|
|
155
|
+
answerFormat: "tex",
|
|
156
|
+
identifiers,
|
|
157
|
+
hint: getHint(identifiers, opts),
|
|
158
|
+
correction: getCorrection(identifiers, opts),
|
|
159
|
+
options: opts,
|
|
160
|
+
};
|
|
161
|
+
return question;
|
|
162
|
+
};
|
|
163
|
+
const optionsStuffFirstTermRankOne = getOptionFirstTermRankOneStuff(false);
|
|
164
|
+
const optionsStuffIsWithSuperfluousData = getOptionIsWithSuperfluousData(false);
|
|
165
|
+
const optsDefault = Object.assign({}, optionsStuffFirstTermRankOne.optsDefaultFirstTermRankOne, optionsStuffIsWithSuperfluousData.optsDefaultIsWithSuperfluousData);
|
|
166
|
+
const options = [
|
|
167
|
+
optionsStuffFirstTermRankOne.generatorOptionFirstTermRankOne,
|
|
168
|
+
optionsStuffIsWithSuperfluousData.generatorOptionIsWithSuperfluousData,
|
|
169
|
+
];
|
|
170
|
+
export const arithmeticFindRankFromSituation = {
|
|
171
|
+
id: "arithmeticFindRankFromSituation",
|
|
172
|
+
connector: "=",
|
|
173
|
+
label: "À partir d'une situation décrivant une évolution arithmétique, retrouver le rang d'une valeur donnée",
|
|
174
|
+
isSingleStep: true,
|
|
175
|
+
generator: (nb, opts) => getDistinctQuestions(() => getArithmeticFindRankFromSituationQuestion(opts), nb),
|
|
176
|
+
options,
|
|
177
|
+
qcmTimer: 60,
|
|
178
|
+
freeTimer: 60,
|
|
179
|
+
getPropositions,
|
|
180
|
+
isAnswerValid,
|
|
181
|
+
subject: "Mathématiques",
|
|
182
|
+
getQuestionFromIdentifiers,
|
|
183
|
+
hasHintAndCorrection: true,
|
|
184
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionFirstTermRankOne } from "../../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { OptionIsWithSuperfluousData } from "../../../../../exercises/options/optionIsWithSuperfluousData.js";
|
|
4
|
+
import { SituationArithmeticSuperfluousData } from "../../../../../math/utils/sequences/situations/seqArithmeticSituations.js";
|
|
5
|
+
type Identifiers = {
|
|
6
|
+
situationIndex: number;
|
|
7
|
+
initial: number;
|
|
8
|
+
reason: number;
|
|
9
|
+
superfluousData?: SituationArithmeticSuperfluousData;
|
|
10
|
+
};
|
|
11
|
+
type Options = OptionFirstTermRankOne & OptionIsWithSuperfluousData;
|
|
12
|
+
export declare const arithmeticFindRecurrenceFormulaFromSituation: Exercise<Identifiers, Options>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=arithmeticFindRecurrenceFormulaFromSituation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arithmeticFindRecurrenceFormulaFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAGhE,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAgB1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;CACtD,CAAC;AAiRF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,4CAA4C,EAAE,QAAQ,CACjE,WAAW,EACX,OAAO,CAoBR,CAAC"}
|