math-exercises 3.0.136 → 3.0.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.d.ts.map +1 -1
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.js +0 -2
- package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +0 -14
- package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.d.ts +14 -0
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +314 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoType3.d.ts +12 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoType3.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoType3.js +115 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoType4.d.ts +12 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoType4.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoType4.js +112 -0
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +2 -0
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/index.js +2 -0
- package/lib/exercises/math/dataRepresentations/compareBoxPlot.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/compareBoxPlot.js +1 -5
- package/lib/exercises/math/derivation/derivative/sqrt/index.d.ts +1 -0
- package/lib/exercises/math/derivation/derivative/sqrt/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/sqrt/index.js +1 -1
- package/lib/exercises/math/derivation/derivative/sqrt/sqrtProductDerivative.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/sqrt/sqrtProductDerivative.js +83 -26
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +4 -12
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/index.js +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromHomothety.d.ts +16 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromHomothety.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromHomothety.js +241 -0
- package/lib/exercises/math/geometry/euclidianConstructions/segmentImageFromHomothety.d.ts +16 -0
- package/lib/exercises/math/geometry/euclidianConstructions/segmentImageFromHomothety.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/segmentImageFromHomothety.js +258 -0
- package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +20 -0
- package/lib/geogebra/parsers/geogebraParser.d.ts +1 -0
- package/lib/geogebra/parsers/geogebraParser.d.ts.map +1 -1
- package/lib/geogebra/parsers/geogebraParser.js +38 -0
- package/lib/index.d.ts +40 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.d.ts.map +1 -1
- package/lib/latexTester.js +1 -0
- package/lib/math/utils/functions/functionComparison.d.ts.map +1 -1
- package/lib/math/utils/functions/functionComparison.js +0 -4
- package/lib/math/utils/functions/functionComposition.d.ts.map +1 -1
- package/lib/math/utils/functions/functionComposition.js +0 -10
- package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -1
- package/lib/math/utils/functions/functionDecomposition.js +0 -42
- package/lib/utils/arrays/arrayIntersection.d.ts +2 -0
- package/lib/utils/arrays/arrayIntersection.d.ts.map +1 -0
- package/lib/utils/arrays/arrayIntersection.js +8 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimalFractionToDecimal.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/decimals/decimalFractionToDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;
|
|
1
|
+
{"version":3,"file":"decimalFractionToDecimal.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/decimals/decimalFractionToDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAgQF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AA4BF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBnE,CAAC"}
|
|
@@ -102,7 +102,6 @@ Si on continue à décaler et diviser, on obtient d'autres fractions décimales
|
|
|
102
102
|
`;
|
|
103
103
|
};
|
|
104
104
|
const getPropositions = (n, { answer, isFractionToDigital, nb }) => {
|
|
105
|
-
console.log("getPropositions", nb);
|
|
106
105
|
const propositions = [];
|
|
107
106
|
addValidProp(propositions, answer);
|
|
108
107
|
const dec = new Decimal(nb);
|
|
@@ -110,7 +109,6 @@ const getPropositions = (n, { answer, isFractionToDigital, nb }) => {
|
|
|
110
109
|
const denNodeSrc = fractionNode.rightChild;
|
|
111
110
|
const log10OfDen = Math.log10(denNodeSrc.evaluate());
|
|
112
111
|
const maxExponentExcluded = log10OfDen;
|
|
113
|
-
console.log("maxExponentExcluded", maxExponentExcluded);
|
|
114
112
|
const mandatoryExponents = [-1, ...(maxExponentExcluded > 1 ? [1] : [])];
|
|
115
113
|
const fillerExponents = [
|
|
116
114
|
-3,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equationFromProblem.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationFromProblem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAatE,KAAK,WAAW,GAAG;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAC;
|
|
1
|
+
{"version":3,"file":"equationFromProblem.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationFromProblem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAatE,KAAK,WAAW,GAAG;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAC;AAqqBF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
|
|
@@ -267,20 +267,6 @@ Quel est le prix, noté a, d'un pot de sauce ?`, (_group, mysteryVar, groups, sh
|
|
|
267
267
|
}, (_group, _mysteryVar, groups, shuffleFuncs) => {
|
|
268
268
|
const { total, ...groupsWithoutTotal } = groups;
|
|
269
269
|
const orderedNodes = shuffleFuncs[0](Object.values(groupsWithoutTotal)).map((group) => group.getNode());
|
|
270
|
-
// console.log(
|
|
271
|
-
// "orderedNodes[0].leftChild",
|
|
272
|
-
// (orderedNodes[0] as MultiplyNode).leftChild,
|
|
273
|
-
// );
|
|
274
|
-
// console.log(
|
|
275
|
-
// "isAlgebraicNode((orderedNodes[0] as MultiplyNode).leftChild)",
|
|
276
|
-
// isAlgebraicNode((orderedNodes[0] as MultiplyNode).leftChild),
|
|
277
|
-
// );
|
|
278
|
-
// console.log(
|
|
279
|
-
// "orderedNodes[0].leftChild.evaluate",
|
|
280
|
-
// (orderedNodes[0] as MultiplyNode).leftChild.evaluate,
|
|
281
|
-
// );
|
|
282
|
-
// console.log("orderedNodes[0].evaluate()", orderedNodes[0].evaluate());
|
|
283
|
-
// console.log("orderedNodes[1].evaluate()", orderedNodes[1].evaluate());
|
|
284
270
|
return round(add(orderedNodes[0], orderedNodes[1]).evaluate(), 2).toTree();
|
|
285
271
|
}, false, true),
|
|
286
272
|
}, [["pizza", "sauce"]]),
|
|
@@ -15,4 +15,5 @@ export * from "./equationWithDistributivity.js";
|
|
|
15
15
|
export * from "./choseOperationToSolveEquation.js";
|
|
16
16
|
export * from "./factorizeEquation.js";
|
|
17
17
|
export * from "./equationFromProblem.js";
|
|
18
|
+
export * from "./isEqualityTrue.js";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
evaluationDict: Record<string, NodeIdentifiers>;
|
|
5
|
+
equalNodeIds: NodeIdentifiers;
|
|
6
|
+
isEqual: boolean;
|
|
7
|
+
};
|
|
8
|
+
type Options = {
|
|
9
|
+
typeCoeff: "Entier" | "Fraction" | "Décimal";
|
|
10
|
+
typeTestValue: "Entier" | "Fraction" | "Décimal";
|
|
11
|
+
};
|
|
12
|
+
export declare const isEqualityTrue1: Exercise<Identifiers, Options>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=isEqualityTrue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEqualityTrue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/isEqualityTrue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAkB7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAChD,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAkUF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAC7C,aAAa,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;CAClD,CAAC;AA6BF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB1D,CAAC"}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
|
|
4
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
|
|
7
|
+
import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
8
|
+
import { isNumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
|
|
9
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
10
|
+
import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
11
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
12
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
13
|
+
import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
|
|
14
|
+
import { parseLatex } from "../../../../tree/parsers/latexParser.js";
|
|
15
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
16
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
17
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
18
|
+
import { joinanded } from "../../../../utils/strings/joinanded.js";
|
|
19
|
+
const varNames = ["x", "y", "z", "t", "u", "v"];
|
|
20
|
+
const getPropositions = (_, { answer }) => {
|
|
21
|
+
const propositions = [];
|
|
22
|
+
["Oui", "Non"].forEach((strYN) => {
|
|
23
|
+
if (strYN === answer) {
|
|
24
|
+
addValidProp(propositions, strYN);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
tryToAddWrongProp(propositions, strYN);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return propositions;
|
|
31
|
+
};
|
|
32
|
+
const getAnswer = (identifiers) => {
|
|
33
|
+
const { isEqual } = identifiers;
|
|
34
|
+
return isEqual ? "Oui" : "Non";
|
|
35
|
+
};
|
|
36
|
+
const getInstruction = (identifiers) => {
|
|
37
|
+
const { evaluationDict, equalNodeIds } = identifiers;
|
|
38
|
+
const equalNode = NodeConstructor.fromIdentifiers(equalNodeIds);
|
|
39
|
+
const strEvaluation = `${joinanded(Object.entries(evaluationDict).map(([varName, nodeIds]) => {
|
|
40
|
+
const node = NodeConstructor.fromIdentifiers(nodeIds);
|
|
41
|
+
return `$${varName} = ${node.toTex()}$`;
|
|
42
|
+
}), ", ", " et ")}`;
|
|
43
|
+
return `En considérant l'équation ci-dessous, l'égalité est-elle vérifiée pour ${strEvaluation} ?
|
|
44
|
+
|
|
45
|
+
$$
|
|
46
|
+
${equalNode.toTex()}
|
|
47
|
+
$$
|
|
48
|
+
|
|
49
|
+
`;
|
|
50
|
+
};
|
|
51
|
+
const getHint = () => {
|
|
52
|
+
return `L'expression $3x$ vaut $3,3$ pour $x = 1,1$.`;
|
|
53
|
+
};
|
|
54
|
+
const getCorrection = (identifiers) => {
|
|
55
|
+
const { evaluationDict, equalNodeIds, isEqual } = identifiers;
|
|
56
|
+
const evaluationEntries = Object.entries(evaluationDict).map(([varName, nodeIds]) => [
|
|
57
|
+
varName,
|
|
58
|
+
NodeConstructor.fromIdentifiers(nodeIds),
|
|
59
|
+
]);
|
|
60
|
+
const equalNode = NodeConstructor.fromIdentifiers(equalNodeIds);
|
|
61
|
+
const [lhsNode, rhsNode] = [equalNode.leftChild, equalNode.rightChild];
|
|
62
|
+
const [evaluatedLhsNode, evaluatedRhsNode] = [lhsNode, rhsNode].map((nodeCarrier) => evaluationEntries.reduce((acc, [varName, nodeInjected]) => nodeBySubstitutingVar(acc, nodeInjected, new VariableNode(varName)), nodeCarrier));
|
|
63
|
+
return `Pour tester si l'égalité est vérifiée, on évalue chaque membre de l'équation.
|
|
64
|
+
|
|
65
|
+
On évalue le membre de gauche :
|
|
66
|
+
|
|
67
|
+
${alignTex([
|
|
68
|
+
["", lhsNode.toTex()],
|
|
69
|
+
["=", evaluatedLhsNode.toTex()],
|
|
70
|
+
[
|
|
71
|
+
"=",
|
|
72
|
+
(() => {
|
|
73
|
+
const evLhsAsAddNode = evaluatedLhsNode;
|
|
74
|
+
return add(evLhsAsAddNode.leftChild.simplify(), evLhsAsAddNode.rightChild);
|
|
75
|
+
})().toTex(),
|
|
76
|
+
],
|
|
77
|
+
["=", evaluatedLhsNode.simplify().toTex()],
|
|
78
|
+
])}
|
|
79
|
+
|
|
80
|
+
On évalue le membre de droite :
|
|
81
|
+
|
|
82
|
+
${alignTex([
|
|
83
|
+
["", rhsNode.toTex()],
|
|
84
|
+
["=", evaluatedRhsNode.toTex()],
|
|
85
|
+
[
|
|
86
|
+
"=",
|
|
87
|
+
(() => {
|
|
88
|
+
const evRhsAsAddNode = evaluatedRhsNode;
|
|
89
|
+
return add(evRhsAsAddNode.leftChild.simplify(), evRhsAsAddNode.rightChild);
|
|
90
|
+
})().toTex(),
|
|
91
|
+
],
|
|
92
|
+
["=", evaluatedRhsNode.simplify().toTex()],
|
|
93
|
+
])}
|
|
94
|
+
|
|
95
|
+
${isEqual
|
|
96
|
+
? `Les deux valeurs sont égales donc l'égalité est vérifiée.`
|
|
97
|
+
: `Les deux valeurs sont différentes. L'égalité n'est pas vérifiée.`}
|
|
98
|
+
|
|
99
|
+
`;
|
|
100
|
+
};
|
|
101
|
+
const getKeys = () => {
|
|
102
|
+
return [];
|
|
103
|
+
};
|
|
104
|
+
const getIsEqualityTrue1Question = (optsIn) => {
|
|
105
|
+
const arrayedOptions = optsIn ?? optsDefault;
|
|
106
|
+
const opts = {
|
|
107
|
+
typeCoeff: random(arrayedOptions.typeCoeff),
|
|
108
|
+
typeTestValue: random(arrayedOptions.typeTestValue),
|
|
109
|
+
};
|
|
110
|
+
const roundDecimalTo = 1;
|
|
111
|
+
const varName = random(varNames);
|
|
112
|
+
function getRandomIntNode(excludes = []) {
|
|
113
|
+
let outNode = (1).toTree();
|
|
114
|
+
let counter = -1;
|
|
115
|
+
let isFound = false;
|
|
116
|
+
while (!isFound && counter < 100) {
|
|
117
|
+
counter++;
|
|
118
|
+
const intExcludes = excludes
|
|
119
|
+
.filter((node) => isNumberNode(node))
|
|
120
|
+
.map((node) => node.evaluate())
|
|
121
|
+
.filter((value) => value % 1 === 0);
|
|
122
|
+
let n;
|
|
123
|
+
try {
|
|
124
|
+
n = randint(-9, 10, intExcludes);
|
|
125
|
+
}
|
|
126
|
+
catch (_) {
|
|
127
|
+
(() => { })();
|
|
128
|
+
}
|
|
129
|
+
if (n) {
|
|
130
|
+
outNode = n.toTree();
|
|
131
|
+
isFound = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return outNode;
|
|
135
|
+
}
|
|
136
|
+
function getRandomFractionNode(excludes = []) {
|
|
137
|
+
let outNode = (1).toTree();
|
|
138
|
+
let counter = -1;
|
|
139
|
+
let isFound = false;
|
|
140
|
+
while (!isFound && counter < 100) {
|
|
141
|
+
counter++;
|
|
142
|
+
const num = randint(-9, 10);
|
|
143
|
+
const den = randint(0, 10, [0, num]);
|
|
144
|
+
const fractionNode = frac(num, den);
|
|
145
|
+
const isExcluded = excludes.some((excludedNode) => substract(excludedNode, fractionNode).evaluate() === 0);
|
|
146
|
+
if (!isExcluded) {
|
|
147
|
+
outNode = fractionNode;
|
|
148
|
+
isFound = true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return outNode;
|
|
152
|
+
}
|
|
153
|
+
function getRandomDecimalNode(excludes = [], roundTo) {
|
|
154
|
+
let outNode = (1).toTree();
|
|
155
|
+
let counter = -1;
|
|
156
|
+
let isFound = false;
|
|
157
|
+
while (!isFound && counter < 100) {
|
|
158
|
+
counter++;
|
|
159
|
+
const decimalNode = randfloat(-10, 10, roundTo).toTree();
|
|
160
|
+
const isExcluded = excludes.some((excludedNode) => substract(excludedNode, decimalNode).evaluate() === 0);
|
|
161
|
+
if (!isExcluded) {
|
|
162
|
+
outNode = decimalNode;
|
|
163
|
+
isFound = true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return outNode;
|
|
167
|
+
}
|
|
168
|
+
function getRandomNode(typeCoeff, excludes = []) {
|
|
169
|
+
switch (typeCoeff) {
|
|
170
|
+
case "Fraction":
|
|
171
|
+
return getRandomFractionNode(excludes);
|
|
172
|
+
case "Décimal": {
|
|
173
|
+
return getRandomDecimalNode(excludes, roundDecimalTo);
|
|
174
|
+
}
|
|
175
|
+
case "Entier":
|
|
176
|
+
default:
|
|
177
|
+
return getRandomIntNode(excludes);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function createRandomIdentifiers() {
|
|
181
|
+
const [a, b] = [
|
|
182
|
+
getRandomNode(opts.typeCoeff),
|
|
183
|
+
getRandomNode(opts.typeCoeff),
|
|
184
|
+
];
|
|
185
|
+
const [c, d] = [
|
|
186
|
+
getRandomNode(opts.typeCoeff, [a]),
|
|
187
|
+
getRandomNode(opts.typeCoeff),
|
|
188
|
+
];
|
|
189
|
+
const lhsNode = add(multiply(a, varName.toTree()), b);
|
|
190
|
+
const rhsNode = add(multiply(c, varName.toTree()), d);
|
|
191
|
+
const equalNode = new EqualNode(lhsNode, rhsNode);
|
|
192
|
+
//ax+b=cx+d
|
|
193
|
+
//x=(d-b)/(a-c)
|
|
194
|
+
const solutionNode = frac(substract(d, b), substract(a, c)).simplify();
|
|
195
|
+
const isEqual = coinFlip();
|
|
196
|
+
const evaluationDict = {};
|
|
197
|
+
if (isEqual) {
|
|
198
|
+
let isSalvation = true;
|
|
199
|
+
switch (opts.typeTestValue) {
|
|
200
|
+
case "Entier":
|
|
201
|
+
{
|
|
202
|
+
const value = solutionNode.evaluate();
|
|
203
|
+
const isInteger = value % 1 === 0;
|
|
204
|
+
if (isInteger) {
|
|
205
|
+
evaluationDict[varName] = value.toTree().toIdentifiers();
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
isSalvation = false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
case "Décimal":
|
|
213
|
+
{
|
|
214
|
+
const value = solutionNode.evaluate();
|
|
215
|
+
const strValue = value.toString();
|
|
216
|
+
const isDecimalWithNbDigits = strValue.split(".")?.[1]?.length === roundDecimalTo;
|
|
217
|
+
if (isDecimalWithNbDigits) {
|
|
218
|
+
evaluationDict[varName] = value.toTree().toIdentifiers();
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
isSalvation = false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case "Fraction": {
|
|
226
|
+
if (isFractionNode(solutionNode)) {
|
|
227
|
+
evaluationDict[varName] = solutionNode.toIdentifiers();
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
isSalvation = false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (!isSalvation) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const missNode = getRandomNode(opts.typeTestValue, [solutionNode]);
|
|
240
|
+
evaluationDict[varName] = missNode.toIdentifiers();
|
|
241
|
+
}
|
|
242
|
+
const identifiers = {
|
|
243
|
+
evaluationDict,
|
|
244
|
+
equalNodeIds: equalNode.toIdentifiers(),
|
|
245
|
+
isEqual,
|
|
246
|
+
};
|
|
247
|
+
return identifiers;
|
|
248
|
+
}
|
|
249
|
+
let identifiers;
|
|
250
|
+
let counter = -1;
|
|
251
|
+
while (!identifiers && counter < 100) {
|
|
252
|
+
counter++;
|
|
253
|
+
identifiers = createRandomIdentifiers();
|
|
254
|
+
}
|
|
255
|
+
const defaultIdentifiers = {
|
|
256
|
+
evaluationDict: { x: (0).toTree().toIdentifiers() },
|
|
257
|
+
equalNodeIds: parseLatex("3x+4=-5x+4").toIdentifiers(),
|
|
258
|
+
isEqual: true,
|
|
259
|
+
};
|
|
260
|
+
return getQuestionFromIdentifiers(identifiers ?? defaultIdentifiers, opts);
|
|
261
|
+
};
|
|
262
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
263
|
+
const question = {
|
|
264
|
+
answer: getAnswer(identifiers, opts),
|
|
265
|
+
instruction: getInstruction(identifiers, opts),
|
|
266
|
+
keys: getKeys(identifiers, opts),
|
|
267
|
+
answerFormat: "tex",
|
|
268
|
+
identifiers,
|
|
269
|
+
hint: getHint(identifiers, opts),
|
|
270
|
+
correction: getCorrection(identifiers, opts),
|
|
271
|
+
options: opts,
|
|
272
|
+
};
|
|
273
|
+
return question;
|
|
274
|
+
};
|
|
275
|
+
const optsDefault = {
|
|
276
|
+
typeCoeff: ["Entier"],
|
|
277
|
+
typeTestValue: ["Entier", "Fraction", "Décimal"],
|
|
278
|
+
};
|
|
279
|
+
const options = [
|
|
280
|
+
{
|
|
281
|
+
id: "typeCoeff",
|
|
282
|
+
label: "Type des coefficients",
|
|
283
|
+
target: GeneratorOptionTarget.generation,
|
|
284
|
+
type: GeneratorOptionType.multiselect,
|
|
285
|
+
values: ["Entier", "Fraction", "Décimal"],
|
|
286
|
+
defaultValue: optsDefault.typeCoeff,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
id: "typeTestValue",
|
|
290
|
+
label: "Type des valeurs de test",
|
|
291
|
+
target: GeneratorOptionTarget.generation,
|
|
292
|
+
type: GeneratorOptionType.multiselect,
|
|
293
|
+
values: ["Entier", "Fraction", "Décimal"],
|
|
294
|
+
defaultValue: optsDefault.typeTestValue,
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
export const isEqualityTrue1 = {
|
|
298
|
+
id: "isEqualityTrue1",
|
|
299
|
+
label: "Tester une égalité pour une certaine valeur de la variable",
|
|
300
|
+
isSingleStep: true,
|
|
301
|
+
generator: (nb, opts) => getDistinctQuestions(() => getIsEqualityTrue1Question(opts), nb),
|
|
302
|
+
options,
|
|
303
|
+
qcmTimer: 60,
|
|
304
|
+
freeTimer: 60,
|
|
305
|
+
getPropositions,
|
|
306
|
+
subject: "Mathématiques",
|
|
307
|
+
getInstruction,
|
|
308
|
+
getHint,
|
|
309
|
+
getCorrection,
|
|
310
|
+
getAnswer,
|
|
311
|
+
answerType: "QCU",
|
|
312
|
+
hasHintAndCorrection: true,
|
|
313
|
+
getQuestionFromIdentifiers,
|
|
314
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
c: number;
|
|
6
|
+
d: number;
|
|
7
|
+
k: number;
|
|
8
|
+
isSubstract: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const factoType3: Exercise<Identifiers>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=factoType3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factoType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAyJF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
|
|
6
|
+
import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
7
|
+
import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
|
|
8
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
9
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
|
+
const getPropositions = (n, { answer, a, b, c, d, k, isSubstract }) => {
|
|
11
|
+
const propositions = [];
|
|
12
|
+
const affine1 = new Affine(a, b);
|
|
13
|
+
const affine2 = new Affine(c, d);
|
|
14
|
+
addValidProp(propositions, answer);
|
|
15
|
+
//erreur de signe
|
|
16
|
+
tryToAddWrongProp(propositions, getAnswer({ a, b, c, d, k, isSubstract: !isSubstract }));
|
|
17
|
+
//k(ax+b) -> kx(ax+b)
|
|
18
|
+
tryToAddWrongProp(propositions, new MultiplyNode(affine1.toTree(), add(affine2.toTree(), multiply(isSubstract ? -k : k, "x")).simplify({
|
|
19
|
+
towardsDistribute: true,
|
|
20
|
+
})).toTex());
|
|
21
|
+
//(ax+b)(cx+d)+-k(ax+b) -> (ax+b)(cx+d+-k(ax+b))
|
|
22
|
+
tryToAddWrongProp(propositions, new MultiplyNode(affine1.toTree(), add(affine2.toTree(), multiply(isSubstract ? -k : k, affine1.toTree())).simplify({ towardsDistribute: true })).toTex());
|
|
23
|
+
propWhile(propositions, n, () => {
|
|
24
|
+
tryToAddWrongProp(propositions, new MultiplyNode(affine1.toTree(), AffineConstructor.random().toTree()).toTex());
|
|
25
|
+
});
|
|
26
|
+
return shuffleProps(propositions, n);
|
|
27
|
+
};
|
|
28
|
+
const getAnswerTree = (identifiers) => {
|
|
29
|
+
const affine1 = new Affine(identifiers.a, identifiers.b);
|
|
30
|
+
const affine2 = new Affine(identifiers.c, identifiers.d);
|
|
31
|
+
return new MultiplyNode(affine1.toTree(), affine2
|
|
32
|
+
.add(identifiers.isSubstract ? -identifiers.k : identifiers.k)
|
|
33
|
+
.toTree());
|
|
34
|
+
};
|
|
35
|
+
const getAnswer = (identifiers) => {
|
|
36
|
+
return getAnswerTree(identifiers).toTex();
|
|
37
|
+
};
|
|
38
|
+
const getInstruction = (identifiers) => {
|
|
39
|
+
const affine1 = new Affine(identifiers.a, identifiers.b);
|
|
40
|
+
const affine2 = new Affine(identifiers.c, identifiers.d);
|
|
41
|
+
const statement = new (identifiers.isSubstract ? SubstractNode : AddNode)(new MultiplyNode(affine1.toTree(), affine2.toTree()), multiply(identifiers.k, affine1.toTree()));
|
|
42
|
+
return `Factoriser et réduire :
|
|
43
|
+
|
|
44
|
+
$$
|
|
45
|
+
${statement.toTex()}
|
|
46
|
+
$$`;
|
|
47
|
+
};
|
|
48
|
+
const getHint = () => {
|
|
49
|
+
return `Repère d'abord le facteur commun dans cette expression. Puis multiplie ce facteur commun par les autres termes de l'expression.`;
|
|
50
|
+
};
|
|
51
|
+
const getCorrection = (identifiers) => {
|
|
52
|
+
const affine1 = new Affine(identifiers.a, identifiers.b);
|
|
53
|
+
const affine2 = new Affine(identifiers.c, identifiers.d);
|
|
54
|
+
const answer = getAnswer(identifiers);
|
|
55
|
+
const statement = new (identifiers.isSubstract ? SubstractNode : AddNode)(new MultiplyNode(affine1.toTree(), affine2.toTree()), multiply(identifiers.k, affine1.toTree()));
|
|
56
|
+
const corr = `
|
|
57
|
+
${alignTex([
|
|
58
|
+
["", statement.toTex()],
|
|
59
|
+
[
|
|
60
|
+
"=",
|
|
61
|
+
new AddNode(new MultiplyNode(affine1.toTree(), affine2.toTree()), multiply(affine1.toTree(), (identifiers.isSubstract ? -1 : 1) * identifiers.k)).toTex(),
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"=",
|
|
65
|
+
new MultiplyNode(affine1.toTree(), add(affine2.toTree(), (identifiers.isSubstract ? -1 : 1) * identifiers.k)).toTex(),
|
|
66
|
+
],
|
|
67
|
+
["=", answer],
|
|
68
|
+
])}
|
|
69
|
+
`;
|
|
70
|
+
return corr;
|
|
71
|
+
};
|
|
72
|
+
const getKeys = () => {
|
|
73
|
+
return ["x"];
|
|
74
|
+
};
|
|
75
|
+
const isAnswerValid = (ans, { answer, a, b, c, d, k, isSubstract }) => {
|
|
76
|
+
const tree = getAnswerTree({ a, b, c, d, k, isSubstract });
|
|
77
|
+
return ans === answer || tree.toAllValidTexs().includes(ans);
|
|
78
|
+
};
|
|
79
|
+
const getFactoType3Question = () => {
|
|
80
|
+
const b = randint(-10, 11);
|
|
81
|
+
const a = randint(-10, 11, [0, b, -b]);
|
|
82
|
+
const c = randint(-10, 11, [0]);
|
|
83
|
+
const d = randint(-10, 11, b === 0 ? [0, -1] : [0, c, -c]);
|
|
84
|
+
const k = randint(-10, 11, [0]);
|
|
85
|
+
const isSubstract = coinFlip();
|
|
86
|
+
const identifiers = { a, b, c, d, k, isSubstract };
|
|
87
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
88
|
+
};
|
|
89
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
90
|
+
const question = {
|
|
91
|
+
answer: getAnswer(identifiers),
|
|
92
|
+
instruction: getInstruction(identifiers),
|
|
93
|
+
keys: getKeys(identifiers),
|
|
94
|
+
answerFormat: "tex",
|
|
95
|
+
identifiers,
|
|
96
|
+
hint: getHint(identifiers),
|
|
97
|
+
correction: getCorrection(identifiers),
|
|
98
|
+
};
|
|
99
|
+
return question;
|
|
100
|
+
};
|
|
101
|
+
export const factoType3 = {
|
|
102
|
+
id: "factoType3",
|
|
103
|
+
connector: "=",
|
|
104
|
+
label: "Factorisation du type $\\left(ax+b\\right)\\left(cx+d\\right)\\pm k \\left(ax+b\\right)$",
|
|
105
|
+
isSingleStep: true,
|
|
106
|
+
generator: (nb) => getDistinctQuestions(getFactoType3Question, nb),
|
|
107
|
+
qcmTimer: 60,
|
|
108
|
+
freeTimer: 60,
|
|
109
|
+
ggbTimer: 60,
|
|
110
|
+
getPropositions,
|
|
111
|
+
isAnswerValid,
|
|
112
|
+
subject: "Mathématiques",
|
|
113
|
+
getQuestionFromIdentifiers,
|
|
114
|
+
hasHintAndCorrection: true,
|
|
115
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
c: number;
|
|
6
|
+
d: number;
|
|
7
|
+
k: number;
|
|
8
|
+
isSubstract: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const factoType4: Exercise<Identifiers>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=factoType4.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factoType4.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType4.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAoKF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
|
|
6
|
+
import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
7
|
+
import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
|
|
8
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
9
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
11
|
+
const getPropositions = (n, { answer, a, b, c, d, k, isSubstract }) => {
|
|
12
|
+
const propositions = [];
|
|
13
|
+
const affine1 = new Affine(a, b);
|
|
14
|
+
const affine2 = new Affine(c, d);
|
|
15
|
+
addValidProp(propositions, answer);
|
|
16
|
+
//erreur de signe
|
|
17
|
+
tryToAddWrongProp(propositions, getAnswer({ a, b, c, d, k, isSubstract: !isSubstract }));
|
|
18
|
+
//k(ax+b)^2 -> k(ax+b)
|
|
19
|
+
tryToAddWrongProp(propositions, new MultiplyNode(affine1.toTree(), affine2.add(isSubstract ? -k : k).toTree()).toTex());
|
|
20
|
+
//(ax+b)(cx+d)+-k(ax+b)^2 -> (ax+b)(cx+d+-kx)
|
|
21
|
+
tryToAddWrongProp(propositions, new MultiplyNode(affine1.toTree(), add(affine2.toTree(), multiply(isSubstract ? -k : k, "x".toTree())).simplify({ towardsDistribute: true })).toTex());
|
|
22
|
+
propWhile(propositions, n, () => {
|
|
23
|
+
tryToAddWrongProp(propositions, new MultiplyNode(affine1.toTree(), AffineConstructor.random().toTree()).toTex());
|
|
24
|
+
});
|
|
25
|
+
return shuffleProps(propositions, n);
|
|
26
|
+
};
|
|
27
|
+
const getAnswerTree = (identifiers) => {
|
|
28
|
+
const affine1 = new Affine(identifiers.a, identifiers.b);
|
|
29
|
+
const affine2 = new Affine(identifiers.c, identifiers.d);
|
|
30
|
+
return new MultiplyNode(affine1.toTree(), add(affine2.toTree(), multiply(identifiers.isSubstract ? -identifiers.k : identifiers.k, affine1.toTree()).simplify({ towardsDistribute: true })).simplify({ towardsDistribute: true }));
|
|
31
|
+
};
|
|
32
|
+
const getAnswer = (identifiers) => {
|
|
33
|
+
return getAnswerTree(identifiers).toTex();
|
|
34
|
+
};
|
|
35
|
+
const getInstruction = (identifiers) => {
|
|
36
|
+
const affine1 = new Affine(identifiers.a, identifiers.b);
|
|
37
|
+
const affine2 = new Affine(identifiers.c, identifiers.d);
|
|
38
|
+
const statement = new (identifiers.isSubstract ? SubstractNode : AddNode)(new MultiplyNode(affine1.toTree(), affine2.toTree()), multiply(identifiers.k, power(affine1.toTree(), 2)));
|
|
39
|
+
return `Factoriser et réduire :
|
|
40
|
+
|
|
41
|
+
$$
|
|
42
|
+
${statement.toTex()}
|
|
43
|
+
$$`;
|
|
44
|
+
};
|
|
45
|
+
const getHint = () => {
|
|
46
|
+
return `Repère d'abord le facteur commun dans cette expression. Puis multiplie ce facteur commun par les autres termes de l'expression.`;
|
|
47
|
+
};
|
|
48
|
+
const getCorrection = (identifiers) => {
|
|
49
|
+
const affine1 = new Affine(identifiers.a, identifiers.b);
|
|
50
|
+
const affine2 = new Affine(identifiers.c, identifiers.d);
|
|
51
|
+
const answer = getAnswer(identifiers);
|
|
52
|
+
const statement = new (identifiers.isSubstract ? SubstractNode : AddNode)(new MultiplyNode(affine1.toTree(), affine2.toTree()), multiply(identifiers.k, power(affine1.toTree(), 2)));
|
|
53
|
+
const corr = `
|
|
54
|
+
${alignTex([
|
|
55
|
+
["", statement.toTex()],
|
|
56
|
+
[
|
|
57
|
+
"=",
|
|
58
|
+
new AddNode(new MultiplyNode(affine1.toTree(), affine2.toTree()), new MultiplyNode(affine1.toTree(), multiply((identifiers.isSubstract ? -1 : 1) * identifiers.k, affine1.toTree()))).toTex(),
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
"=",
|
|
62
|
+
new MultiplyNode(affine1.toTree(), add(affine2.toTree(), multiply((identifiers.isSubstract ? -1 : 1) * identifiers.k, affine1.toTree()).simplify({ towardsDistribute: true }))).toTex(),
|
|
63
|
+
],
|
|
64
|
+
["=", answer],
|
|
65
|
+
])}
|
|
66
|
+
`;
|
|
67
|
+
return corr;
|
|
68
|
+
};
|
|
69
|
+
const getKeys = () => {
|
|
70
|
+
return ["x"];
|
|
71
|
+
};
|
|
72
|
+
const isAnswerValid = (ans, { answer, a, b, c, d, k, isSubstract }) => {
|
|
73
|
+
const tree = getAnswerTree({ a, b, c, d, k, isSubstract });
|
|
74
|
+
return ans === answer || tree.toAllValidTexs().includes(ans);
|
|
75
|
+
};
|
|
76
|
+
const getFactoType4Question = () => {
|
|
77
|
+
const b = randint(-10, 11);
|
|
78
|
+
const a = randint(-10, 11, [0, b, -b]);
|
|
79
|
+
const c = randint(-10, 11, [0]);
|
|
80
|
+
const d = randint(-10, 11, b === 0 ? [0, -1] : [0, c, -c]);
|
|
81
|
+
const k = randint(-10, 11, [0]);
|
|
82
|
+
const isSubstract = coinFlip();
|
|
83
|
+
const identifiers = { a, b, c, d, k, isSubstract };
|
|
84
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
85
|
+
};
|
|
86
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
87
|
+
const question = {
|
|
88
|
+
answer: getAnswer(identifiers),
|
|
89
|
+
instruction: getInstruction(identifiers),
|
|
90
|
+
keys: getKeys(identifiers),
|
|
91
|
+
answerFormat: "tex",
|
|
92
|
+
identifiers,
|
|
93
|
+
hint: getHint(identifiers),
|
|
94
|
+
correction: getCorrection(identifiers),
|
|
95
|
+
};
|
|
96
|
+
return question;
|
|
97
|
+
};
|
|
98
|
+
export const factoType4 = {
|
|
99
|
+
id: "factoType4",
|
|
100
|
+
connector: "=",
|
|
101
|
+
label: "Factorisation du type $\\left(ax+b\\right)\\left(cx+d\\right)\\pm k {\\left(ax+b\\right)}^2$",
|
|
102
|
+
isSingleStep: true,
|
|
103
|
+
generator: (nb) => getDistinctQuestions(getFactoType4Question, nb),
|
|
104
|
+
qcmTimer: 60,
|
|
105
|
+
freeTimer: 60,
|
|
106
|
+
ggbTimer: 60,
|
|
107
|
+
getPropositions,
|
|
108
|
+
isAnswerValid,
|
|
109
|
+
subject: "Mathématiques",
|
|
110
|
+
getQuestionFromIdentifiers,
|
|
111
|
+
hasHintAndCorrection: true,
|
|
112
|
+
};
|