math-exercises 3.0.187 → 3.0.189
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/derivation/derivative/exp/expDerivativeProductFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.js +22 -6
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.js +16 -8
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +44 -37
- package/lib/exercises/math/derivation/derivativeNumber/derivativeNumberAndImageReading.d.ts +9 -0
- package/lib/exercises/math/derivation/derivativeNumber/derivativeNumberAndImageReading.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivativeNumber/derivativeNumberAndImageReading.js +155 -0
- package/lib/exercises/math/derivation/derivativeNumber/index.d.ts +1 -0
- package/lib/exercises/math/derivation/derivativeNumber/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivativeNumber/index.js +1 -0
- package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.js +80 -29
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +30 -2
- package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +59 -16
- package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +23 -9
- package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +2 -7
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +18 -68
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +27 -35
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +129 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.js +108 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +92 -0
- package/lib/exercises/math/functions/affines/adjustment/index.d.ts +4 -0
- package/lib/exercises/math/functions/affines/adjustment/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/index.js +3 -0
- package/lib/exercises/math/functions/affines/index.d.ts +2 -4
- package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/index.js +2 -4
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.js +219 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.js +69 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.js +133 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.js +229 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.js +166 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts +9 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.js +78 -0
- package/lib/exercises/math/functions/affines/situations/index.d.ts +6 -0
- package/lib/exercises/math/functions/affines/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/index.js +5 -0
- package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts +1 -0
- package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/sign/equationFromSignTable.js +60 -33
- package/lib/exercises/math/functions/sign/partialSignTableFromGraph.d.ts +6 -4
- package/lib/exercises/math/functions/sign/partialSignTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/sign/partialSignTableFromGraph.js +160 -63
- package/lib/exercises/math/functions/sign/readSignTable.d.ts +4 -1
- package/lib/exercises/math/functions/sign/readSignTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/sign/readSignTable.js +32 -9
- package/lib/exercises/math/functions/sign/signTableFromGraph.d.ts +6 -4
- package/lib/exercises/math/functions/sign/signTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/sign/signTableFromGraph.js +160 -57
- package/lib/exercises/math/percent/evolutions/averageEvolutionRateFromStartAndEndValue.d.ts +9 -0
- package/lib/exercises/math/percent/evolutions/averageEvolutionRateFromStartAndEndValue.d.ts.map +1 -0
- package/lib/exercises/math/percent/evolutions/averageEvolutionRateFromStartAndEndValue.js +135 -0
- package/lib/exercises/math/percent/evolutions/index.d.ts +1 -0
- package/lib/exercises/math/percent/evolutions/index.d.ts.map +1 -1
- package/lib/exercises/math/percent/evolutions/index.js +1 -0
- package/lib/exercises/math/powers/equationOnePlusTPowerN.d.ts +9 -0
- package/lib/exercises/math/powers/equationOnePlusTPowerN.d.ts.map +1 -0
- package/lib/exercises/math/powers/equationOnePlusTPowerN.js +118 -0
- package/lib/exercises/math/powers/estimateNthRoot.d.ts +13 -0
- package/lib/exercises/math/powers/estimateNthRoot.d.ts.map +1 -0
- package/lib/exercises/math/powers/estimateNthRoot.js +126 -0
- package/lib/exercises/math/powers/index.d.ts +3 -0
- package/lib/exercises/math/powers/index.d.ts.map +1 -1
- package/lib/exercises/math/powers/index.js +3 -0
- package/lib/exercises/math/powers/solveNthRootEquation.d.ts +9 -0
- package/lib/exercises/math/powers/solveNthRootEquation.d.ts.map +1 -0
- package/lib/exercises/math/powers/solveNthRootEquation.js +111 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -7
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +1 -7
- package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/index.js +7 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts +11 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.js +112 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.js +176 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.js +94 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.js +166 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.js +133 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.js +211 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.js +113 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts +41 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js +173 -0
- package/lib/exercises/math/python/list/pyListMutationMix.d.ts.map +1 -1
- package/lib/exercises/math/python/list/pyListMutationMix.js +11 -6
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +2 -2
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.js +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoConsecutiveTerms.js +1 -1
- package/lib/exercises/vea/percentVEA.d.ts +6 -1
- package/lib/exercises/vea/percentVEA.d.ts.map +1 -1
- package/lib/exercises/vea/percentVEA.js +15 -1
- package/lib/index.d.ts +78 -33
- package/lib/index.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +5 -8
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +1 -3
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqGeometricSituations.js +8 -10
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +8 -0
- package/lib/tree/nodes/sets/closure.d.ts +1 -0
- package/lib/tree/nodes/sets/closure.d.ts.map +1 -1
- package/lib/tree/nodes/sets/closure.js +12 -0
- package/lib/tree/utilities/nodeUtils.d.ts +2 -0
- package/lib/tree/utilities/nodeUtils.d.ts.map +1 -1
- package/lib/tree/utilities/nodeUtils.js +40 -0
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { addValidProp, propWhile, 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 { round } from "../../../../../math/utils/round.js";
|
|
6
|
+
import { leastSquares } from "../../../../../math/utils/stats/leastSquares.js";
|
|
7
|
+
import { EqualNode } from "../../../../../tree/nodes/equations/equalNode.js";
|
|
8
|
+
import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
|
|
9
|
+
import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
|
|
10
|
+
import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
11
|
+
import { SubstractNode } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
12
|
+
import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
|
|
13
|
+
import { dollarize } from "../../../../../utils/latex/dollarize.js";
|
|
14
|
+
import { mdTable } from "../../../../../utils/markdown/mdTable.js";
|
|
15
|
+
const getInstruction = ({ xValues, yValues }) => {
|
|
16
|
+
const dataTable = mdTable([
|
|
17
|
+
["$x$", ...xValues.map((n) => dollarize(n.frenchify()))],
|
|
18
|
+
["$y$", ...yValues.map((n) => dollarize(n.frenchify()))],
|
|
19
|
+
]);
|
|
20
|
+
return `On considère la série statistique ci-dessous. Déterminer l'équation de la droite d'ajustement obtenue par la méthode des moindres carrés.
|
|
21
|
+
|
|
22
|
+
${dataTable}
|
|
23
|
+
|
|
24
|
+
Arrondir les coefficients au dixième.
|
|
25
|
+
`;
|
|
26
|
+
};
|
|
27
|
+
function generateLinearData(n) {
|
|
28
|
+
const slope = randint(-500, 500, [0]) / 100;
|
|
29
|
+
const intercept = randint(100, 5000) / 100;
|
|
30
|
+
const data = [];
|
|
31
|
+
const generatedXs = new Set();
|
|
32
|
+
let counter = 0;
|
|
33
|
+
while (data.length < n) {
|
|
34
|
+
counter++;
|
|
35
|
+
if (counter > 1000) {
|
|
36
|
+
throw new Error("affineAdjustement too many iterations");
|
|
37
|
+
}
|
|
38
|
+
let x = randint(1, 100);
|
|
39
|
+
let cnt = 0;
|
|
40
|
+
while (generatedXs.has(x)) {
|
|
41
|
+
cnt++;
|
|
42
|
+
if (cnt > 1000) {
|
|
43
|
+
throw new Error("affineAdjustement too many iterations");
|
|
44
|
+
}
|
|
45
|
+
x = randint(1, 100);
|
|
46
|
+
}
|
|
47
|
+
generatedXs.add(x);
|
|
48
|
+
const y = round(slope * x + intercept, 2);
|
|
49
|
+
data.push({ x, y });
|
|
50
|
+
}
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
const getAnswer = (identifiers) => {
|
|
54
|
+
const { xValues, yValues } = identifiers;
|
|
55
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
56
|
+
const aFixed = round(a, 1);
|
|
57
|
+
const bFixed = round(b, 1);
|
|
58
|
+
const answer = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
59
|
+
return answer;
|
|
60
|
+
};
|
|
61
|
+
const getAffineAdjustmentQuestion = () => {
|
|
62
|
+
const data = generateLinearData(5);
|
|
63
|
+
data.sort((a, b) => a.x - b.x);
|
|
64
|
+
const xValues = data.map((point) => point.x);
|
|
65
|
+
const yValues = data.map((point) => point.y);
|
|
66
|
+
const identifiers = { xValues, yValues };
|
|
67
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
68
|
+
};
|
|
69
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
70
|
+
const question = {
|
|
71
|
+
answer: getAnswer(identifiers),
|
|
72
|
+
instruction: getInstruction(identifiers),
|
|
73
|
+
keys: ["equal", "y", "x", "a", "b"],
|
|
74
|
+
answerFormat: "tex",
|
|
75
|
+
identifiers,
|
|
76
|
+
style: {
|
|
77
|
+
tableOptions: {
|
|
78
|
+
firstCellIsDivided: false,
|
|
79
|
+
firstColumnIsHeader: true,
|
|
80
|
+
firstRowIsHeader: false,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return question;
|
|
85
|
+
};
|
|
86
|
+
const getPropositions = (n, { answer, xValues, yValues }) => {
|
|
87
|
+
const propositions = [];
|
|
88
|
+
addValidProp(propositions, answer, "tex");
|
|
89
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
90
|
+
const aFixed = round(a, 1);
|
|
91
|
+
const bFixed = round(b, 1);
|
|
92
|
+
const wrongAnswer1 = new EqualNode(new VariableNode("y"), new SubstractNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
93
|
+
const awrong = randfloat(-5, 5, 1, [0]);
|
|
94
|
+
const bwrong = randfloat(-20, 20, 1);
|
|
95
|
+
const wrongAnswer2 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
96
|
+
const wrongAnswer3 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(round(bwrong, 1))).simplify({ forbidFactorize: true }));
|
|
97
|
+
const wrongAnswer4 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(round(bwrong, 1))).simplify({ forbidFactorize: true }));
|
|
98
|
+
tryToAddWrongProp(propositions, wrongAnswer1.toTex());
|
|
99
|
+
tryToAddWrongProp(propositions, wrongAnswer2.toTex());
|
|
100
|
+
tryToAddWrongProp(propositions, wrongAnswer3.toTex());
|
|
101
|
+
tryToAddWrongProp(propositions, wrongAnswer4.toTex());
|
|
102
|
+
propWhile(propositions, n, () => {
|
|
103
|
+
const a = randint(-10, 10, [0]);
|
|
104
|
+
const b = randint(-10, 10);
|
|
105
|
+
const wrongAnswer = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(a), new VariableNode("x")), new NumberNode(b)).simplify({ forbidFactorize: true }));
|
|
106
|
+
tryToAddWrongProp(propositions, wrongAnswer.toTex());
|
|
107
|
+
});
|
|
108
|
+
return shuffleProps(propositions, n);
|
|
109
|
+
};
|
|
110
|
+
const isAnswerValid = (ans, { xValues, yValues }) => {
|
|
111
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
112
|
+
const aFixed = round(a, 1);
|
|
113
|
+
const bFixed = round(b, 1);
|
|
114
|
+
const valid = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
115
|
+
const latexs = valid.toAllValidTexs({ allowRawRightChildAsSolution: true });
|
|
116
|
+
return latexs.includes(ans);
|
|
117
|
+
};
|
|
118
|
+
export const affineAdjustmentExercise = {
|
|
119
|
+
id: "affineAdjustment",
|
|
120
|
+
label: "Déterminer l'équation de la droite d'ajustement à partir d'un tableau de données",
|
|
121
|
+
isSingleStep: true,
|
|
122
|
+
generator: (nb) => getDistinctQuestions(getAffineAdjustmentQuestion, nb),
|
|
123
|
+
qcmTimer: 60,
|
|
124
|
+
freeTimer: 60,
|
|
125
|
+
getPropositions,
|
|
126
|
+
isAnswerValid,
|
|
127
|
+
subject: "Mathématiques",
|
|
128
|
+
getQuestionFromIdentifiers,
|
|
129
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
xValues: number[];
|
|
4
|
+
yValues: number[];
|
|
5
|
+
};
|
|
6
|
+
export declare const affineAdjustmentCompleteExercise: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=affineAdjustmentComplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affineAdjustmentComplete.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA4JF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { addValidProp, propWhile, 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 { round } from "../../../../../math/utils/round.js";
|
|
6
|
+
import { generateAffineCloud } from "../../../../../math/utils/stats/generateAffineCloud.js";
|
|
7
|
+
import { leastSquares } from "../../../../../math/utils/stats/leastSquares.js";
|
|
8
|
+
import { rSquared } from "../../../../../math/utils/stats/rSquared.js";
|
|
9
|
+
import { EqualNode } from "../../../../../tree/nodes/equations/equalNode.js";
|
|
10
|
+
import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
|
|
11
|
+
import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
|
|
12
|
+
import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
13
|
+
import { PowerNode } from "../../../../../tree/nodes/operators/powerNode.js";
|
|
14
|
+
import { SubstractNode } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
15
|
+
import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
|
|
16
|
+
import { dollarize } from "../../../../../utils/latex/dollarize.js";
|
|
17
|
+
import { mdTable } from "../../../../../utils/markdown/mdTable.js";
|
|
18
|
+
const getAnswer = (identifiers) => {
|
|
19
|
+
const { xValues, yValues } = identifiers;
|
|
20
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
21
|
+
const aFixed = round(a, 1);
|
|
22
|
+
const bFixed = round(b, 1);
|
|
23
|
+
const answerEq = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
24
|
+
const r2 = round(rSquared(xValues, yValues), 2);
|
|
25
|
+
const answerR = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree()).toTex();
|
|
26
|
+
return `${answerEq}\\newline ${answerR}`;
|
|
27
|
+
};
|
|
28
|
+
const getInstruction = (identifiers) => {
|
|
29
|
+
const { xValues, yValues } = identifiers;
|
|
30
|
+
const dataTable = mdTable([
|
|
31
|
+
["$x$", ...xValues.map((n) => dollarize(n.frenchify()))],
|
|
32
|
+
["$y$", ...yValues.map((n) => dollarize(n.frenchify()))],
|
|
33
|
+
]);
|
|
34
|
+
return `On considère la série statistique ci-dessous. A l'aide de la calculatrice, déterminer l'équation de la droite d'ajustement et la valeur du coefficient de détermination. ${dataTable}
|
|
35
|
+
`;
|
|
36
|
+
};
|
|
37
|
+
const getAffineAdjustmentCompleteQuestion = () => {
|
|
38
|
+
const data = generateAffineCloud(6);
|
|
39
|
+
data.sort((a, b) => a.x - b.x);
|
|
40
|
+
const xValues = data.map((point) => point.x);
|
|
41
|
+
const yValues = data.map((point) => point.y);
|
|
42
|
+
const identifiers = {
|
|
43
|
+
xValues,
|
|
44
|
+
yValues,
|
|
45
|
+
};
|
|
46
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
47
|
+
};
|
|
48
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
49
|
+
const question = {
|
|
50
|
+
answer: getAnswer(identifiers),
|
|
51
|
+
instruction: getInstruction(identifiers),
|
|
52
|
+
keys: [],
|
|
53
|
+
answerFormat: "tex",
|
|
54
|
+
identifiers,
|
|
55
|
+
style: {
|
|
56
|
+
tableOptions: {
|
|
57
|
+
firstCellIsDivided: false,
|
|
58
|
+
firstColumnIsHeader: true,
|
|
59
|
+
firstRowIsHeader: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
return question;
|
|
64
|
+
};
|
|
65
|
+
const getPropositions = (n, { answer, xValues, yValues }) => {
|
|
66
|
+
const propositions = [];
|
|
67
|
+
addValidProp(propositions, answer, "tex");
|
|
68
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
69
|
+
const r2 = round(rSquared(xValues, yValues), 2);
|
|
70
|
+
const aFixed = round(a, 1);
|
|
71
|
+
const bFixed = round(b, 1);
|
|
72
|
+
const answerEq = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
73
|
+
const answerR = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree()).toTex();
|
|
74
|
+
const wrongAnswerEq1 = new EqualNode(new VariableNode("y"), new SubstractNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
75
|
+
const awrong = randfloat(1, 10, 1);
|
|
76
|
+
const wrongAnswerEq2 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
77
|
+
const wrongAnswerR1 = new EqualNode(new VariableNode("R"), r2.toTree()).toTex();
|
|
78
|
+
const wrongAnswerR2 = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), (r2 + 0.01).toTree()).toTex();
|
|
79
|
+
const wrongAnswer1 = `${answerEq}\\newline ${wrongAnswerR1}`;
|
|
80
|
+
const wrongAnswer2 = `${answerEq}\\newline ${wrongAnswerR2}`;
|
|
81
|
+
const wrongAnswer3 = `${wrongAnswerEq1}\\newline ${answerR}`;
|
|
82
|
+
const wrongAnswer4 = `${wrongAnswerEq2}\\newline ${answerR}`;
|
|
83
|
+
tryToAddWrongProp(propositions, wrongAnswer1);
|
|
84
|
+
tryToAddWrongProp(propositions, wrongAnswer2);
|
|
85
|
+
tryToAddWrongProp(propositions, wrongAnswer3);
|
|
86
|
+
tryToAddWrongProp(propositions, wrongAnswer4);
|
|
87
|
+
propWhile(propositions, n, () => {
|
|
88
|
+
const a = randint(-10, 10, [0]);
|
|
89
|
+
const b = randint(-10, 10);
|
|
90
|
+
const wrongAnswerEq = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(a), new VariableNode("x")), new NumberNode(b)).simplify({ forbidFactorize: true })).toTex();
|
|
91
|
+
const wrongAnswerR = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), round(Math.random(), 2).toTree()).toTex();
|
|
92
|
+
const wrongAnswer = `${wrongAnswerEq}\\newline ${wrongAnswerR}`;
|
|
93
|
+
tryToAddWrongProp(propositions, wrongAnswer);
|
|
94
|
+
});
|
|
95
|
+
return shuffleProps(propositions, n);
|
|
96
|
+
};
|
|
97
|
+
export const affineAdjustmentCompleteExercise = {
|
|
98
|
+
id: "affineAdjustmentComplete",
|
|
99
|
+
label: "Déterminer l'équation de la droite d'ajustement et le coefficient de détermination",
|
|
100
|
+
isSingleStep: true,
|
|
101
|
+
generator: (nb) => getDistinctQuestions(getAffineAdjustmentCompleteQuestion, nb),
|
|
102
|
+
qcmTimer: 60,
|
|
103
|
+
freeTimer: 60,
|
|
104
|
+
getPropositions,
|
|
105
|
+
subject: "Mathématiques",
|
|
106
|
+
getQuestionFromIdentifiers,
|
|
107
|
+
answerType: "QCU",
|
|
108
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
xValues: number[];
|
|
4
|
+
yValues: number[];
|
|
5
|
+
};
|
|
6
|
+
export declare const affineAdjustmentRsquaredExercise: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=affineAdjustmentRsquared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affineAdjustmentRsquared.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAqHF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { round } from "../../../../../math/utils/round.js";
|
|
4
|
+
import { generateAffineCloud } from "../../../../../math/utils/stats/generateAffineCloud.js";
|
|
5
|
+
import { rSquared } from "../../../../../math/utils/stats/rSquared.js";
|
|
6
|
+
import { EqualNode } from "../../../../../tree/nodes/equations/equalNode.js";
|
|
7
|
+
import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
|
|
8
|
+
import { PowerNode } from "../../../../../tree/nodes/operators/powerNode.js";
|
|
9
|
+
import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
|
|
10
|
+
import { dollarize } from "../../../../../utils/latex/dollarize.js";
|
|
11
|
+
import { mdTable } from "../../../../../utils/markdown/mdTable.js";
|
|
12
|
+
const getInstruction = (identifiers) => {
|
|
13
|
+
const { xValues, yValues } = identifiers;
|
|
14
|
+
const dataTable = mdTable([
|
|
15
|
+
["$x$", ...xValues.map((n) => dollarize(n.frenchify()))],
|
|
16
|
+
["$y$", ...yValues.map((n) => dollarize(n.frenchify()))],
|
|
17
|
+
]);
|
|
18
|
+
return `On considère la série statistique ci-dessous :
|
|
19
|
+
|
|
20
|
+
${dataTable}
|
|
21
|
+
|
|
22
|
+
Déterminer la valeur du coefficient de détermination pour un ajustement affine de cette série.
|
|
23
|
+
`;
|
|
24
|
+
};
|
|
25
|
+
const getAnswer = (identifiers) => {
|
|
26
|
+
const { xValues, yValues } = identifiers;
|
|
27
|
+
const r2 = round(rSquared(xValues, yValues), 2);
|
|
28
|
+
const answer = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree()).toTex();
|
|
29
|
+
return answer;
|
|
30
|
+
};
|
|
31
|
+
const getAffineAdjustmentRsquaredQuestion = () => {
|
|
32
|
+
const data = generateAffineCloud(6);
|
|
33
|
+
data.sort((a, b) => a.x - b.x);
|
|
34
|
+
const xValues = data.map((point) => round(point.x, 1));
|
|
35
|
+
const yValues = data.map((point) => round(point.y, 1));
|
|
36
|
+
const identifiers = { xValues, yValues };
|
|
37
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
38
|
+
};
|
|
39
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
40
|
+
const question = {
|
|
41
|
+
answer: getAnswer(identifiers),
|
|
42
|
+
instruction: getInstruction(identifiers),
|
|
43
|
+
keys: ["R", "equal"],
|
|
44
|
+
answerFormat: "tex",
|
|
45
|
+
identifiers,
|
|
46
|
+
style: {
|
|
47
|
+
tableOptions: {
|
|
48
|
+
firstCellIsDivided: false,
|
|
49
|
+
firstColumnIsHeader: true,
|
|
50
|
+
firstRowIsHeader: false,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
return question;
|
|
55
|
+
};
|
|
56
|
+
const getPropositions = (n, { answer, xValues, yValues }) => {
|
|
57
|
+
const propositions = [];
|
|
58
|
+
const r2 = round(rSquared(xValues, yValues), 2);
|
|
59
|
+
addValidProp(propositions, answer, "tex");
|
|
60
|
+
const wrongAnswer1 = new EqualNode(new VariableNode("R"), r2.toTree()).toTex();
|
|
61
|
+
const wrongAnswer2 = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), (r2 + 0.01).toTree()).toTex();
|
|
62
|
+
const wrongAnswer3 = new EqualNode(new VariableNode("R"), (r2 - 0.01).toTree()).toTex();
|
|
63
|
+
tryToAddWrongProp(propositions, wrongAnswer1);
|
|
64
|
+
tryToAddWrongProp(propositions, wrongAnswer2);
|
|
65
|
+
tryToAddWrongProp(propositions, wrongAnswer3);
|
|
66
|
+
propWhile(propositions, n, () => {
|
|
67
|
+
const wrongAnswer = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(1)), round(Math.random(), 2).toTree()).toTex();
|
|
68
|
+
tryToAddWrongProp(propositions, wrongAnswer);
|
|
69
|
+
});
|
|
70
|
+
return shuffleProps(propositions, n);
|
|
71
|
+
};
|
|
72
|
+
const isAnswerValid = (ans, { xValues, yValues }) => {
|
|
73
|
+
const r2 = round(rSquared(xValues, yValues), 2);
|
|
74
|
+
const validanswer = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree());
|
|
75
|
+
const latexs = validanswer.toAllValidTexs({
|
|
76
|
+
allowRawRightChildAsSolution: true,
|
|
77
|
+
allowFractionToDecimal: true,
|
|
78
|
+
});
|
|
79
|
+
return latexs.includes(ans);
|
|
80
|
+
};
|
|
81
|
+
export const affineAdjustmentRsquaredExercise = {
|
|
82
|
+
id: "affineAdjustmentRsquared",
|
|
83
|
+
label: "Déterminer le coefficient de détermination à partir d'un tableau de données",
|
|
84
|
+
isSingleStep: true,
|
|
85
|
+
generator: (nb) => getDistinctQuestions(getAffineAdjustmentRsquaredQuestion, nb),
|
|
86
|
+
qcmTimer: 60,
|
|
87
|
+
freeTimer: 60,
|
|
88
|
+
getPropositions,
|
|
89
|
+
isAnswerValid,
|
|
90
|
+
subject: "Mathématiques",
|
|
91
|
+
getQuestionFromIdentifiers,
|
|
92
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC"}
|
|
@@ -6,12 +6,8 @@ export * from "./affineExpressionReading.js";
|
|
|
6
6
|
export * from "./interceptReading.js";
|
|
7
7
|
export * from "./algebricExpressionOfAffine.js";
|
|
8
8
|
export * from "./leadingCoeffAndOriginOrdinate.js";
|
|
9
|
-
export * from "./affineAdjustment.js";
|
|
10
|
-
export * from "./affineAdjustmentRsquared.js";
|
|
11
|
-
export * from "./affineAdjustmentComplete.js";
|
|
12
9
|
export * from "./affineMeanValue.js";
|
|
13
10
|
export * from "./affineExpressionFromTwoImages.js";
|
|
14
|
-
export * from "./affineFromExercise.js";
|
|
15
11
|
export * from "./drawAffineFromLitExp.js";
|
|
16
12
|
export * from "./recognizeExprAffine.js";
|
|
17
13
|
export * from "./drawAffineFrom2Points.js";
|
|
@@ -24,4 +20,6 @@ export * from "./drawAffineFromPointAndLeadingCoeff.js";
|
|
|
24
20
|
export * from "./drawAffineFromProgCalc.js";
|
|
25
21
|
export * from "./placePointsFromAffine.js";
|
|
26
22
|
export * from "./recognizeAffinePointsFromPoints.js";
|
|
23
|
+
export * from "./adjustment/index.js";
|
|
24
|
+
export * from "./situations/index.js";
|
|
27
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -6,12 +6,8 @@ export * from "./affineExpressionReading.js";
|
|
|
6
6
|
export * from "./interceptReading.js";
|
|
7
7
|
export * from "./algebricExpressionOfAffine.js";
|
|
8
8
|
export * from "./leadingCoeffAndOriginOrdinate.js";
|
|
9
|
-
export * from "./affineAdjustment.js";
|
|
10
|
-
export * from "./affineAdjustmentRsquared.js";
|
|
11
|
-
export * from "./affineAdjustmentComplete.js";
|
|
12
9
|
export * from "./affineMeanValue.js";
|
|
13
10
|
export * from "./affineExpressionFromTwoImages.js";
|
|
14
|
-
export * from "./affineFromExercise.js";
|
|
15
11
|
export * from "./drawAffineFromLitExp.js";
|
|
16
12
|
export * from "./recognizeExprAffine.js";
|
|
17
13
|
export * from "./drawAffineFrom2Points.js";
|
|
@@ -24,3 +20,5 @@ export * from "./drawAffineFromPointAndLeadingCoeff.js";
|
|
|
24
20
|
export * from "./drawAffineFromProgCalc.js";
|
|
25
21
|
export * from "./placePointsFromAffine.js";
|
|
26
22
|
export * from "./recognizeAffinePointsFromPoints.js";
|
|
23
|
+
export * from "./adjustment/index.js";
|
|
24
|
+
export * from "./situations/index.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
id: string;
|
|
4
|
+
situationIndex: number;
|
|
5
|
+
initial: number;
|
|
6
|
+
growth: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const affineFromExercise: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=affineFromExercise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affineFromExercise.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/situations/affineFromExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA6PF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAiBpD,CAAC"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
4
|
+
import { add } from "../../../../../tree/nodes/operators/addNode.js";
|
|
5
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
6
|
+
import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
|
|
7
|
+
import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
|
|
8
|
+
import { affineModelisationSituations } from "./affineModelisationSituations.js";
|
|
9
|
+
const situationsData = [
|
|
10
|
+
{
|
|
11
|
+
question: `Quelle est sa hauteur (en $\\textrm{cm}$) après $x$ jours ?`,
|
|
12
|
+
hint: `Quel calcul permet de trouver la hauteur de la plante au bout de $10$ jours ?
|
|
13
|
+
|
|
14
|
+
Inspire toi de ce calcul pour déterminer la hauteur de la plante au bout de $x$ jours.`,
|
|
15
|
+
correction: (initial, growth, answer) => `Chaque jour, la plante gagne $${growth.frenchify()}\\ \\textrm{cm}$. Au bout de $x$ jours, la plante a donc gagné $x\\times ${growth.frenchify()}\\ \\textrm{cm}$.
|
|
16
|
+
|
|
17
|
+
La hauteur initiale de la plante est de $${initial}\\ \\textrm{cm}$.
|
|
18
|
+
|
|
19
|
+
Au bout de $x$ jours, la plante a donc une hauteur de :
|
|
20
|
+
|
|
21
|
+
$$
|
|
22
|
+
${answer}\\ \\textrm{cm}
|
|
23
|
+
$$`,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
question: `Quel est le prix payé (en $€$) pour $x \\ \\textrm{km}$ parcourus ?`,
|
|
27
|
+
hint: `Quel calcul permet de trouver le prix payé pour $10$ kilomètres parcourus ?
|
|
28
|
+
|
|
29
|
+
Inspire toi de ce calcul pour déterminer le prix payé pour $x$ kilomètres parcourus.
|
|
30
|
+
`,
|
|
31
|
+
correction: (initial, growth, answer) => `Pour chaque kilomètre parcouru, le prix augmente de $${growth.frenchify()}\\ €$. Au bout de $x$ kilomètres, le prix augmente donc de $x\\times ${growth.frenchify()}\\ \\ €$.
|
|
32
|
+
|
|
33
|
+
Le montant fixe initial du trajet est de $${initial}\\ €$.
|
|
34
|
+
|
|
35
|
+
Pour $x$ kilomètres parcourus, le prix du trajet est donc de :
|
|
36
|
+
|
|
37
|
+
$$
|
|
38
|
+
${answer}\\ €
|
|
39
|
+
$$`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
question: `Quelle sera la facture (en $€$) pour $x \\ \\textrm{kWh}$ consommés ?`,
|
|
43
|
+
hint: `Quel calcul permet de trouver la facture pour $10$ kWh consommés ?
|
|
44
|
+
|
|
45
|
+
Inspire toi de ce calcul pour déterminer la facture pour $x$ kWh consommés.
|
|
46
|
+
`,
|
|
47
|
+
correction: (initial, growth, answer) => `Pour chaque kWh consommé, le prix augmente de $${growth.frenchify()}\\ €$.
|
|
48
|
+
Au bout de $x$ kWh, le prix augmente donc de $x\\times ${growth.frenchify()}\\ \\ €$.
|
|
49
|
+
|
|
50
|
+
Le montant de l'abonnement fixe est de $${initial}\\ €$.
|
|
51
|
+
|
|
52
|
+
Pour $x$ kWh consommés, la facture sera donc de :
|
|
53
|
+
|
|
54
|
+
$$
|
|
55
|
+
${answer}\\ €
|
|
56
|
+
$$`,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
question: `Quelle sera la température (en °C) pour $x$ centaines de km parcourus vers le Sud ?`,
|
|
60
|
+
hint: `Quel calcul permet de trouver la température pour $2$ centaines de km parcourus ?
|
|
61
|
+
|
|
62
|
+
Inspire toi de ce calcul pour déterminer la température pour $x$ centaines de km parcourus.
|
|
63
|
+
`,
|
|
64
|
+
correction: (initial, growth, answer) => `Pour chaque centaine de km parcourue, la température augmente de $${growth.frenchify()}$ °C.
|
|
65
|
+
Au bout de $x$ centaines de km, la température augmente donc de $x\\times ${growth.frenchify()}$ °C.
|
|
66
|
+
|
|
67
|
+
Au départ, la température est de $${initial}$ °C.
|
|
68
|
+
|
|
69
|
+
Pour $x$ centaines de km parcourus, la température sera donc de :
|
|
70
|
+
|
|
71
|
+
$$
|
|
72
|
+
${answer}\\ \\textrm{°C}
|
|
73
|
+
$$`,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
question: `Quel sera son salaire net (en €) quand elle aura $x$ années d'ancienneté ?`,
|
|
77
|
+
hint: `Quel calcul permet de trouver son salaire net pour $10$ années d'ancienneté ?
|
|
78
|
+
|
|
79
|
+
Inspire toi de ce calcul pour déterminer son salaire net pour $x$ années d'ancienneté.
|
|
80
|
+
`,
|
|
81
|
+
correction: (initial, growth, answer) => `Chaque année, son salaire net augmente de $${growth.frenchify()}\\ €$.
|
|
82
|
+
Au bout de $x$ années, son salaire net aura augmenté de $x\\times ${growth.frenchify()}\\ €$.
|
|
83
|
+
|
|
84
|
+
Au départ, son salaire net était de $${initial}\\ €$.
|
|
85
|
+
|
|
86
|
+
Pour $x$ années d'ancienneté, son salaire net sera donc de :
|
|
87
|
+
|
|
88
|
+
$$
|
|
89
|
+
${answer}\\ \\textrm{€}
|
|
90
|
+
$$`,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
question: `Quel sera son score s'il commet $x$ erreurs ?`,
|
|
94
|
+
hint: `Quel calcul permet de trouver son score net pour $10$ erreurs ?
|
|
95
|
+
|
|
96
|
+
Inspire toi de ce calcul pour déterminer son score pour $x$ erreurs.
|
|
97
|
+
`,
|
|
98
|
+
correction: (initial, growth, answer) => `Pour chaque erreur, son score baisse de $${Math.abs(growth).frenchify()}$ points.
|
|
99
|
+
Au bout de $x$ erreurs, son score aura baissé de $x\\times ${Math.abs(growth).frenchify()}$ points.
|
|
100
|
+
|
|
101
|
+
Au départ, son score était de $${initial}$ points.
|
|
102
|
+
|
|
103
|
+
Pour $x$ erreurs, son score sera donc de :
|
|
104
|
+
|
|
105
|
+
$$
|
|
106
|
+
${answer}
|
|
107
|
+
$$`,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
question: `De combien disposera l'entreprise au bout de $x$ jours ?`,
|
|
111
|
+
hint: `Quel calcul permet de trouver ce dont dispose l'entreprise après $10$ jours ?
|
|
112
|
+
|
|
113
|
+
Inspire toi de ce calcul pour déterminer ce dont elle dispose après $x$ jours.
|
|
114
|
+
`,
|
|
115
|
+
correction: (initial, growth, answer) => `Chaque jour, l'entreprise perd $${Math.abs(growth).frenchify()} \\ €$ de chiffres d'affaires.
|
|
116
|
+
Au bout de $x$ jours, son chiffre d'affaires aura donc réduit de $x\\times ${Math.abs(growth).frenchify()}\\ €$.
|
|
117
|
+
|
|
118
|
+
Au départ, l'entreprise faisait un chiffre d'affaires de $${initial}\\ €$.
|
|
119
|
+
|
|
120
|
+
Après $x$ jours, l'entreprise aura donc un chiffre d'affaries de :
|
|
121
|
+
|
|
122
|
+
$$
|
|
123
|
+
${answer}\\ €
|
|
124
|
+
$$`,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
question: `Quelle sera la température (en $\\textrm{°C}$) au bout de $x$ jours ?`,
|
|
128
|
+
hint: `Quel calcul permet de trouver la température après $2$ jours ?
|
|
129
|
+
|
|
130
|
+
Inspire toi de ce calcul pour déterminer la température après $x$ jours.
|
|
131
|
+
`,
|
|
132
|
+
correction: (initial, growth, answer) => `Chaque jour, la température baisse de $${Math.abs(growth).frenchify()}\\textrm{°C}$.
|
|
133
|
+
Au bout de $x$ jours, la température baissera donc de $x\\times ${Math.abs(growth).frenchify()}\\textrm{°C}$.
|
|
134
|
+
|
|
135
|
+
Au départ, la température est de $${initial}\\textrm{°C}$.
|
|
136
|
+
|
|
137
|
+
Après $x$ jours, la température sera donc de :
|
|
138
|
+
|
|
139
|
+
$$
|
|
140
|
+
${answer}\\ \\textrm{°C}
|
|
141
|
+
$$`,
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
145
|
+
const propositions = [];
|
|
146
|
+
const { initial, growth } = identifiers;
|
|
147
|
+
addValidProp(propositions, answer);
|
|
148
|
+
tryToAddWrongProp(propositions, add(multiply(initial, new VariableNode("x")), growth).toTex());
|
|
149
|
+
tryToAddWrongProp(propositions, add(multiply(growth, new VariableNode("n")), initial).toTex());
|
|
150
|
+
tryToAddWrongProp(propositions, add(multiply(initial, growth), new VariableNode("x")).toTex());
|
|
151
|
+
tryToAddWrongProp(propositions, multiply(add(initial, growth).simplify(), new VariableNode("x")).toTex());
|
|
152
|
+
return shuffleProps(propositions, n);
|
|
153
|
+
};
|
|
154
|
+
const getAnswer = (identifiers) => {
|
|
155
|
+
return add(multiply(identifiers.growth, new VariableNode("x")), identifiers.initial).toTex();
|
|
156
|
+
};
|
|
157
|
+
const getInstruction = (identifiers) => {
|
|
158
|
+
const { situationIndex, initial, growth } = identifiers;
|
|
159
|
+
const situation = affineModelisationSituations[situationIndex];
|
|
160
|
+
const situationData = situationsData[situationIndex];
|
|
161
|
+
return situation.context(initial, growth) + "\n \n" + situationData.question;
|
|
162
|
+
};
|
|
163
|
+
const getHint = (identifiers) => {
|
|
164
|
+
const { situationIndex } = identifiers;
|
|
165
|
+
const situation = situationsData[situationIndex];
|
|
166
|
+
return situation.hint;
|
|
167
|
+
};
|
|
168
|
+
const getCorrection = (identifiers) => {
|
|
169
|
+
const { situationIndex, initial, growth } = identifiers;
|
|
170
|
+
const situation = situationsData[situationIndex];
|
|
171
|
+
const answer = getAnswer(identifiers);
|
|
172
|
+
return situation.correction(initial, growth, answer);
|
|
173
|
+
};
|
|
174
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
175
|
+
return parseAlgebraic(ans)
|
|
176
|
+
.simplify()
|
|
177
|
+
.equals(parseAlgebraic(answer).simplify());
|
|
178
|
+
};
|
|
179
|
+
const getAffineFromExerciseQuestion = () => {
|
|
180
|
+
const situationIndex = randint(0, affineModelisationSituations.length);
|
|
181
|
+
const situation = affineModelisationSituations[situationIndex];
|
|
182
|
+
const initial = situation.randInitial();
|
|
183
|
+
const growth = situation.randGrowth();
|
|
184
|
+
const identifiers = {
|
|
185
|
+
id: situation.id,
|
|
186
|
+
situationIndex,
|
|
187
|
+
initial,
|
|
188
|
+
growth,
|
|
189
|
+
};
|
|
190
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
191
|
+
};
|
|
192
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
193
|
+
return {
|
|
194
|
+
answer: getAnswer(identifiers),
|
|
195
|
+
instruction: getInstruction(identifiers),
|
|
196
|
+
keys: ["x"],
|
|
197
|
+
answerFormat: "tex",
|
|
198
|
+
identifiers,
|
|
199
|
+
hint: getHint(identifiers),
|
|
200
|
+
correction: getCorrection(identifiers),
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
export const affineFromExercise = {
|
|
204
|
+
id: "affineFromExercise",
|
|
205
|
+
label: "Écrire la fonction affine correspondant à une situation donnée",
|
|
206
|
+
isSingleStep: true,
|
|
207
|
+
generator: (nb, opts) => getDistinctQuestions(() => getAffineFromExerciseQuestion(opts), nb),
|
|
208
|
+
qcmTimer: 60,
|
|
209
|
+
freeTimer: 60,
|
|
210
|
+
getPropositions,
|
|
211
|
+
isAnswerValid,
|
|
212
|
+
subject: "Mathématiques",
|
|
213
|
+
getInstruction,
|
|
214
|
+
getHint,
|
|
215
|
+
getCorrection,
|
|
216
|
+
getAnswer,
|
|
217
|
+
getQuestionFromIdentifiers,
|
|
218
|
+
hasHintAndCorrection: true,
|
|
219
|
+
};
|