math-exercises 2.2.92 → 2.2.94

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.
Files changed (53) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionSquare.d.ts +8 -0
  2. package/lib/exercises/math/calcul/fractions/fractionSquare.d.ts.map +1 -0
  3. package/lib/exercises/math/calcul/fractions/fractionSquare.js +106 -0
  4. package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
  5. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/fractions/index.js +1 -0
  7. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts +9 -0
  8. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +160 -126
  10. package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
  11. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  12. package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
  13. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
  14. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.js +75 -41
  15. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
  16. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.js +70 -40
  17. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.js +78 -47
  19. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  20. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +0 -1
  21. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
  22. package/lib/exercises/math/functions/affines/affineExpressionReading.js +45 -23
  23. package/lib/exercises/math/percent/findRightCalcul.d.ts +10 -0
  24. package/lib/exercises/math/percent/findRightCalcul.d.ts.map +1 -0
  25. package/lib/exercises/math/percent/findRightCalcul.js +116 -0
  26. package/lib/exercises/math/percent/htToTTC.d.ts.map +1 -1
  27. package/lib/exercises/math/percent/htToTTC.js +34 -12
  28. package/lib/exercises/math/percent/index.d.ts +1 -0
  29. package/lib/exercises/math/percent/index.d.ts.map +1 -1
  30. package/lib/exercises/math/percent/index.js +2 -0
  31. package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
  32. package/lib/exercises/math/percent/percentToDecimal.js +6 -2
  33. package/lib/exercises/math/percent/percentWritings.d.ts +8 -0
  34. package/lib/exercises/math/percent/percentWritings.d.ts.map +1 -0
  35. package/lib/exercises/math/percent/percentWritings.js +136 -0
  36. package/lib/exercises/math/percent/ttcToHT.d.ts.map +1 -1
  37. package/lib/exercises/math/percent/ttcToHT.js +33 -12
  38. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.d.ts.map +1 -1
  39. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.js +54 -23
  40. package/lib/index.d.ts +13 -0
  41. package/lib/index.d.ts.map +1 -1
  42. package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
  43. package/lib/tree/nodes/functions/oppositeNode.js +1 -1
  44. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  45. package/lib/tree/nodes/operators/addNode.js +4 -0
  46. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  47. package/lib/tree/nodes/operators/fractionNode.js +6 -1
  48. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  49. package/lib/tree/nodes/operators/multiplyNode.js +4 -0
  50. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
  51. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  52. package/lib/tree/parsers/latexParser.js +14 -0
  53. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ num: number;
4
+ denum: number;
5
+ };
6
+ export declare const fractionSquare: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=fractionSquare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fractionSquare.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA6FF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAiBhD,CAAC"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fractionSquare = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const rational_1 = require("../../../../math/numbers/rationals/rational");
7
+ const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
8
+ const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
9
+ const latexParser_1 = require("../../../../tree/parsers/latexParser");
10
+ const alignTex_1 = require("../../../../utils/latex/alignTex");
11
+ const getPropositions = (n, { answer, denum, num }) => {
12
+ const propositions = [];
13
+ (0, exercise_1.addValidProp)(propositions, answer);
14
+ const fraction = (0, fractionNode_1.frac)(num, denum);
15
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, fractionNode_1.frac)(2 * num, 2 * denum).toTex());
16
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, fractionNode_1.frac)((0, powerNode_1.square)(num), denum).simplify().toTex());
17
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, fractionNode_1.frac)(num, (0, powerNode_1.square)(denum)).simplify().toTex());
18
+ while (propositions.length < n) {
19
+ (0, exercise_1.tryToAddWrongProp)(propositions, rational_1.RationalConstructor.randomIrreductible().toTree().toTex());
20
+ }
21
+ return (0, exercise_1.shuffleProps)(propositions, n);
22
+ };
23
+ const getStatementNode = (identifiers) => {
24
+ const { num, denum } = identifiers;
25
+ return (0, powerNode_1.square)((0, fractionNode_1.frac)(num, denum));
26
+ };
27
+ const getAnswer = (identifiers) => {
28
+ return getStatementNode(identifiers).simplify().toTex();
29
+ };
30
+ const getInstruction = (identifiers) => {
31
+ const statement = getStatementNode(identifiers);
32
+ return `Simplifier :
33
+
34
+ $$
35
+ ${statement.toTex()}
36
+ $$`;
37
+ };
38
+ const getHint = (identifiers) => {
39
+ return `Pour passer une fraction au carré, on met le numérateur au carré et le dénominateur au carré :
40
+
41
+ $$
42
+ \\left(\\frac ab\\right)^2 = \\frac{a^2}{b^2}
43
+ $$
44
+
45
+ Ensuite, on simplifie la fraction obtenue si possible.`;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const statement = getStatementNode(identifiers);
49
+ const midStep = (0, fractionNode_1.frac)((0, powerNode_1.square)(identifiers.num), (0, powerNode_1.square)(identifiers.denum));
50
+ return `On met le numérateur et le dénominateur au carré :
51
+
52
+ ${(0, alignTex_1.alignTex)([
53
+ [statement.toTex(), "=", midStep.toTex()],
54
+ ["", "=", getAnswer(identifiers)],
55
+ ])}`;
56
+ };
57
+ const getKeys = (identifiers) => {
58
+ return [];
59
+ };
60
+ const isAnswerValid = (ans, { answer }) => {
61
+ try {
62
+ const parsed = (0, latexParser_1.parseAlgebraic)(ans);
63
+ if (!parsed)
64
+ return false;
65
+ if (!(0, fractionNode_1.isFractionNode)(parsed))
66
+ return false;
67
+ return parsed.simplify().toTex() === answer;
68
+ }
69
+ catch (err) {
70
+ return false;
71
+ }
72
+ };
73
+ const getFractionSquareQuestion = (ops) => {
74
+ const rational = rational_1.RationalConstructor.randomIrreductible();
75
+ const identifiers = {
76
+ num: rational.num,
77
+ denum: rational.denum,
78
+ };
79
+ const question = {
80
+ answer: getAnswer(identifiers),
81
+ instruction: getInstruction(identifiers),
82
+ keys: getKeys(identifiers),
83
+ answerFormat: "tex",
84
+ identifiers,
85
+ hint: getHint(identifiers),
86
+ correction: getCorrection(identifiers),
87
+ };
88
+ return question;
89
+ };
90
+ exports.fractionSquare = {
91
+ id: "fractionSquare",
92
+ connector: "=",
93
+ label: "Passer une fraction au carré",
94
+ isSingleStep: true,
95
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getFractionSquareQuestion(opts), nb),
96
+ qcmTimer: 60,
97
+ freeTimer: 60,
98
+ getPropositions,
99
+ isAnswerValid,
100
+ subject: "Mathématiques",
101
+ getInstruction,
102
+ getHint,
103
+ getCorrection,
104
+ getAnswer,
105
+ hasHintAndCorrection: true,
106
+ };
@@ -11,4 +11,5 @@ export * from "./fractionsSumsSameDenominators";
11
11
  export * from "./fractionsSumsMultiplesDenominators";
12
12
  export * from "./fractionsSumsPrimeDenominators";
13
13
  export * from "./fractionsOperations";
14
+ export * from "./fractionSquare";
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
@@ -27,3 +27,4 @@ __exportStar(require("./fractionsSumsSameDenominators"), exports);
27
27
  __exportStar(require("./fractionsSumsMultiplesDenominators"), exports);
28
28
  __exportStar(require("./fractionsSumsPrimeDenominators"), exports);
29
29
  __exportStar(require("./fractionsOperations"), exports);
30
+ __exportStar(require("./fractionSquare"), exports);
@@ -1 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c?: number;
6
+ type: number;
7
+ };
8
+ export declare const choseOperationToSolveEquation: Exercise<Identifiers>;
9
+ export {};
1
10
  //# sourceMappingURL=choseOperationToSolveEquation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"choseOperationToSolveEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"choseOperationToSolveEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAqJF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAqB/D,CAAC"}
@@ -1,129 +1,163 @@
1
1
  "use strict";
2
- // import {
3
- // Exercise,
4
- // Proposition,
5
- // QCMGenerator,
6
- // Question,
7
- // QuestionGenerator,
8
- // VEA,
9
- // addValidProp,
10
- // shuffleProps,
11
- // GetAnswer,
12
- // GetHint,
13
- // GetCorrection,
14
- // GetInstruction,
15
- // GetKeys,
16
- // tryToAddWrongProp,
17
- // } from "../../../../exercises/exercise";
18
- // import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions";
19
- // import { randint } from "../../../../math/utils/random/randint";
20
- // import {
21
- // EqualNode,
22
- // EqualNodeConstructor,
23
- // EqualNodeIdentifiers,
24
- // } from "../../../../tree/nodes/equations/equalNode";
25
- // import {
26
- // NodeConstructor,
27
- // NodeIdentifiers,
28
- // } from "../../../../tree/nodes/nodeConstructor";
29
- // type Identifiers = {
30
- // equaIdentifiers: EqualNodeIdentifiers;
31
- // type: number
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.choseOperationToSolveEquation = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const randint_1 = require("../../../../math/utils/random/randint");
7
+ const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
8
+ const addNode_1 = require("../../../../tree/nodes/operators/addNode");
9
+ const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
10
+ const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
11
+ const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
12
+ const getPropositions = (n, { answer }) => {
13
+ const propositions = [];
14
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
15
+ (0, exercise_1.tryToAddWrongProp)(propositions, "une soustraction", "raw");
16
+ (0, exercise_1.tryToAddWrongProp)(propositions, "une addition", "raw");
17
+ (0, exercise_1.tryToAddWrongProp)(propositions, "une division", "raw");
18
+ (0, exercise_1.tryToAddWrongProp)(propositions, "une multiplication", "raw");
19
+ return (0, exercise_1.shuffleProps)(propositions, n);
20
+ };
21
+ const getAnswer = ({ a, b, type, c }) => {
22
+ switch (type) {
23
+ case 1:
24
+ //ax = b tous entiers
25
+ return "une division";
26
+ case 2:
27
+ // ax + b = c tous entiers
28
+ return "une soustraction";
29
+ case 3:
30
+ //ax-b = c tous entiers
31
+ return "une addition";
32
+ case 4:
33
+ //x/a = b tous entiers
34
+ return "une multiplication";
35
+ case 5:
36
+ //x+a = b
37
+ return "une soustraction";
38
+ case 6:
39
+ default:
40
+ //x-a = b
41
+ return "une addition";
42
+ }
43
+ };
44
+ const getStatementNode = (identifiers) => {
45
+ const { type } = identifiers;
46
+ const a = identifiers.a.toTree();
47
+ const b = identifiers.b.toTree();
48
+ const c = identifiers.c?.toTree();
49
+ switch (type) {
50
+ case 1:
51
+ //ax = b tous entiers
52
+ return new equalNode_1.EqualNode((0, multiplyNode_1.multiply)(a, "x"), b);
53
+ case 2:
54
+ // ax + b = c tous entiers
55
+ return new equalNode_1.EqualNode((0, addNode_1.add)((0, multiplyNode_1.multiply)(a, "x"), b), c);
56
+ case 3:
57
+ //ax-b = c tous entiers
58
+ return new equalNode_1.EqualNode((0, substractNode_1.substract)((0, multiplyNode_1.multiply)(a, "x"), b), c);
59
+ case 4:
60
+ //x/a = b tous entiers
61
+ return new equalNode_1.EqualNode((0, fractionNode_1.frac)("x", a), b);
62
+ case 5:
63
+ //x+a = b
64
+ return new equalNode_1.EqualNode((0, addNode_1.add)("x", a), b);
65
+ case 6:
66
+ default:
67
+ //x-a = b
68
+ return new equalNode_1.EqualNode((0, substractNode_1.substract)("x", a), b);
69
+ }
70
+ };
71
+ const getInstruction = (identifiers) => {
72
+ const { type, a, b, c } = identifiers;
73
+ const equation = getStatementNode(identifiers);
74
+ return `Pour résoudre l'équation :
75
+
76
+ $$
77
+ ${equation.toTex()}
78
+ $$
79
+
80
+ il faut d'abord effectuer :
81
+ `;
82
+ };
83
+ // const getHint: GetHint<Identifiers> = (identifiers) => {
32
84
  // };
33
- // const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
34
- // const propositions: Proposition[] = [];
35
- // addValidProp(propositions, answer);
36
- // tryToAddWrongProp(propositions, "une soustraction", "raw");
37
- // tryToAddWrongProp(propositions, "une addition", "raw");
38
- // tryToAddWrongProp(propositions, "une division", "raw");
39
- // tryToAddWrongProp(propositions, "une multiplication", "raw");
40
- // return shuffleProps(propositions, n);
41
- // };
42
- // const getAnswer: GetAnswer<Identifiers> = (identifiers) => {
43
- // return;
44
- // };
45
- // const getInstruction: GetInstruction<Identifiers> = (identifiers) => {
46
- // const equation = EqualNodeConstructor.fromIdentifiers(
47
- // identifiers.equaIdentifiers,
48
- // );
49
- // return `Pour résoudre l'équation :
50
- // $$
51
- // ${equation.toTex()}
52
- // $$
53
- // il faut d'abord effectuer :
54
- // `;
55
- // };
56
- // // const getHint: GetHint<Identifiers> = (identifiers) => {};
57
- // // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
58
- // const getKeys: GetKeys<Identifiers> = (identifiers) => {
59
- // return [];
60
- // };
61
- // const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
62
- // throw Error("VEA not implemented");
63
- // };
64
- // const getChoseOperationToSolveEquationQuestion: QuestionGenerator<
65
- // Identifiers
66
- // > = (ops) => {
67
- // //ax=b avec a entier, ax+b = c tout entier, x/a = b tout entier, x+-a = b entiers ,
68
- // let a: number;
69
- // let b: number;
70
- // let c: number | undefined;
71
- // const type = randint(1, 7);
72
- // switch (type) {
73
- // case 1:
74
- // //ax = b tous entiers
75
- // a = randint(2, 10);
76
- // b = randint(2, 10)
77
- // break;
78
- // case 2 :
79
- // // ax + b = c tous entiers
80
- // break;
81
- // case 3:
82
- // //ax-b = c tous entiers
83
- // break;
84
- // case 4:
85
- // //x/a = b tous entiers
86
- // break;
87
- // case 5:
88
- // //x+a = b
89
- // break;
90
- // case 6:
91
- // //x-a = b
92
- // break;
93
- // case 7:
94
- // break;
95
- // }
96
- // const identifiers: Identifiers = {type, };
97
- // const question: Question<Identifiers> = {
98
- // answer: getAnswer(identifiers),
99
- // instruction: getInstruction(identifiers),
100
- // keys: getKeys(identifiers),
101
- // answerFormat: "tex",
102
- // identifiers,
103
- // // hint: getHint(identifiers),
104
- // // correction: getCorrection(identifiers),
105
- // };
106
- // return question;
107
- // };
108
- // export const choseOperationToSolveEquation: Exercise<Identifiers> = {
109
- // id: "choseOperationToSolveEquation",
110
- // connector: "=",
111
- // label:
112
- // "Choisir la bonne opération pour résoudre une équation du premier degré",
113
- // isSingleStep: true,
114
- // generator: (nb, opts) =>
115
- // getDistinctQuestions(
116
- // () => getChoseOperationToSolveEquationQuestion(opts),
117
- // nb,
118
- // ),
119
- // qcmTimer: 60,
120
- // freeTimer: 60,
121
- // getPropositions,
122
- // isAnswerValid,
123
- // subject: "Mathématiques",
124
- // getInstruction,
125
- // // getHint,
126
- // // getCorrection,
127
- // getAnswer,
128
- // answerType: "QCU",
85
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
86
+ // return ``
129
87
  // };
88
+ const getKeys = (identifiers) => {
89
+ return [];
90
+ };
91
+ const isAnswerValid = (ans, { answer }) => {
92
+ throw Error("VEA not implemented");
93
+ };
94
+ const getChoseOperationToSolveEquationQuestion = (opts) => {
95
+ //ax=b avec a entier, ax+b = c tout entier, x/a = b tout entier, x+-a = b entiers ,
96
+ let a;
97
+ let b;
98
+ let c;
99
+ const type = (0, randint_1.randint)(1, 7);
100
+ switch (type) {
101
+ case 1:
102
+ //ax = b tous entiers
103
+ a = (0, randint_1.randint)(2, 10);
104
+ b = (0, randint_1.randint)(1, 10);
105
+ break;
106
+ case 2:
107
+ // ax + b = c tous entiers
108
+ a = (0, randint_1.randint)(2, 10);
109
+ b = (0, randint_1.randint)(1, 10);
110
+ c = (0, randint_1.randint)(1, 10);
111
+ break;
112
+ case 3:
113
+ //ax-b = c tous entiers
114
+ a = (0, randint_1.randint)(2, 10);
115
+ b = (0, randint_1.randint)(1, 10);
116
+ c = (0, randint_1.randint)(1, 10);
117
+ break;
118
+ case 4:
119
+ //x/a = b tous entiers
120
+ a = (0, randint_1.randint)(2, 10);
121
+ b = (0, randint_1.randint)(1, 10);
122
+ break;
123
+ case 5:
124
+ //x+a = b
125
+ a = (0, randint_1.randint)(1, 10);
126
+ b = (0, randint_1.randint)(1, 10);
127
+ break;
128
+ case 6:
129
+ default:
130
+ //x-a = b
131
+ a = (0, randint_1.randint)(1, 10);
132
+ b = (0, randint_1.randint)(1, 10);
133
+ break;
134
+ }
135
+ const identifiers = { type, a, b, c };
136
+ const question = {
137
+ answer: getAnswer(identifiers),
138
+ instruction: getInstruction(identifiers),
139
+ keys: getKeys(identifiers),
140
+ answerFormat: "tex",
141
+ identifiers,
142
+ // hint: getHint(identifiers),
143
+ // correction: getCorrection(identifiers),
144
+ };
145
+ return question;
146
+ };
147
+ exports.choseOperationToSolveEquation = {
148
+ id: "choseOperationToSolveEquation",
149
+ connector: "=",
150
+ label: "Choisir la bonne opération pour résoudre une équation du premier degré",
151
+ isSingleStep: true,
152
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getChoseOperationToSolveEquationQuestion(opts), nb),
153
+ qcmTimer: 60,
154
+ freeTimer: 60,
155
+ getPropositions,
156
+ isAnswerValid,
157
+ subject: "Mathématiques",
158
+ getInstruction,
159
+ // getHint,
160
+ // getCorrection,
161
+ getAnswer,
162
+ answerType: "QCU",
163
+ };
@@ -12,4 +12,5 @@ export * from "./firstDegreeEquationIntType3";
12
12
  export * from "./equationFromSentenceExercise";
13
13
  export * from "./binomialsTrinomialsProposedSolutions";
14
14
  export * from "./equationWithDistributivity";
15
+ export * from "./choseOperationToSolveEquation";
15
16
  //# 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,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC"}
@@ -28,3 +28,4 @@ __exportStar(require("./firstDegreeEquationIntType3"), exports);
28
28
  __exportStar(require("./equationFromSentenceExercise"), exports);
29
29
  __exportStar(require("./binomialsTrinomialsProposedSolutions"), exports);
30
30
  __exportStar(require("./equationWithDistributivity"), exports);
31
+ __exportStar(require("./choseOperationToSolveEquation"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"factoIdRmq1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoIdRmq1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgGF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAc7C,CAAC"}
1
+ {"version":3,"file":"factoIdRmq1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoIdRmq1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAsBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqIF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAkB7C,CAAC"}
@@ -11,47 +11,75 @@ const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
11
11
  const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
12
12
  const alignTex_1 = require("../../../../utils/latex/alignTex");
13
13
  const shuffle_1 = require("../../../../utils/alea/shuffle");
14
- const gcd_1 = require("../../../../math/utils/arithmetic/gcd");
15
- const getFactoType1Question = () => {
16
- const affine = affine_1.AffineConstructor.random({ min: 1, max: 10 }, {
17
- min: 1,
18
- max: 10,
19
- });
14
+ const latexParser_1 = require("../../../../tree/parsers/latexParser");
15
+ const getStatementNode = (identifiers) => {
16
+ const affine = new affine_1.Affine(identifiers.a, identifiers.b);
20
17
  const statementTree = affine.multiply(affine).toTree();
21
- const aMonom = new affine_1.Affine(affine.a, 0).toTree();
22
- const answerTree = new powerNode_1.PowerNode(affine.toTree(), new numberNode_1.NumberNode(2));
23
- const answer = answerTree.toTex();
18
+ return statementTree;
19
+ };
20
+ const getStartStatement = (identifiers) => {
21
+ const statementTree = getStatementNode(identifiers);
24
22
  const statementTex = statementTree.toTex();
25
- const question = {
26
- instruction: `Factoriser : $${statementTex}$`,
27
- startStatement: statementTex,
28
- answer,
29
- keys: ["x"],
30
- answerFormat: "tex",
31
- identifiers: { a: affine.a, b: affine.b },
32
- hint: `Essaie de réécrire cette expression sous la forme
23
+ return statementTex;
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ return `Factoriser :
27
+
28
+ $$
29
+ ${getStartStatement(identifiers)}
30
+ $$`;
31
+ };
32
+ const getHint = (identifiers) => {
33
+ return `Essaie de réécrire cette expression sous la forme
33
34
 
34
35
  $$
35
36
  a^2 + 2ab+b^2
36
- $$`,
37
- correction: `
38
- On utilise l'identité remarquable
39
-
37
+ $$`;
38
+ };
39
+ const getCorrection = (identifiers) => {
40
+ const affine = new affine_1.Affine(identifiers.a, identifiers.b);
41
+ const aMonom = new affine_1.Affine(affine.a, 0).toTree();
42
+ const statementTex = getStartStatement(identifiers);
43
+ const answer = getAnswer(identifiers);
44
+ return `On utilise l'identité remarquable
45
+
40
46
  $$
41
47
  a^2 + 2ab+b^2 = (a+b)^2
42
48
  $$
43
-
49
+
44
50
  en prenant $a=${aMonom.toTex()}$ et $b=${affine.b}$ :
45
51
 
46
52
  ${(0, alignTex_1.alignTex)([
47
- [
48
- statementTex,
49
- "=",
50
- new addNode_1.AddNode(new addNode_1.AddNode(new powerNode_1.SquareNode(aMonom), new multiplyNode_1.MultiplyNode((2).toTree(), new multiplyNode_1.MultiplyNode(aMonom, affine.b.toTree()))), new powerNode_1.SquareNode(affine.b.toTree())).toTex(),
51
- ],
52
- ["", "=", answer],
53
- ])}
54
- `,
53
+ [
54
+ statementTex,
55
+ "=",
56
+ new addNode_1.AddNode(new addNode_1.AddNode(new powerNode_1.SquareNode(aMonom), new multiplyNode_1.MultiplyNode((2).toTree(), new multiplyNode_1.MultiplyNode(aMonom, affine.b.toTree()))), new powerNode_1.SquareNode(affine.b.toTree())).toTex(),
57
+ ],
58
+ ["", "=", answer],
59
+ ])}
60
+ `;
61
+ };
62
+ const getAnswer = (identifiers) => {
63
+ const affine = new affine_1.Affine(identifiers.a, identifiers.b);
64
+ const answerTree = new powerNode_1.PowerNode(affine.toTree(), new numberNode_1.NumberNode(2));
65
+ const answer = answerTree.simplify().toTex();
66
+ return answer;
67
+ };
68
+ const getFactoType1Question = () => {
69
+ const affine = affine_1.AffineConstructor.random({ min: 1, max: 10 }, {
70
+ min: 1,
71
+ max: 10,
72
+ });
73
+ const identifiers = { a: affine.a, b: affine.b };
74
+ const question = {
75
+ instruction: getInstruction(identifiers),
76
+ startStatement: getStartStatement(identifiers),
77
+ answer: getAnswer(identifiers),
78
+ keys: ["x"],
79
+ answerFormat: "tex",
80
+ identifiers,
81
+ hint: getHint(identifiers),
82
+ correction: getCorrection(identifiers),
55
83
  };
56
84
  return question;
57
85
  };
@@ -65,18 +93,20 @@ const getPropositions = (n, { answer, a, b }) => {
65
93
  }
66
94
  return (0, shuffle_1.shuffle)(propositions);
67
95
  };
68
- const isAnswerValid = (ans, { a, b }) => {
69
- const affine = new affine_1.Affine(a, b);
70
- const answerTree = new powerNode_1.SquareNode(affine.toTree());
71
- const validLatexs = answerTree.toAllValidTexs();
72
- const pgcd = (0, gcd_1.gcd)(a, b);
73
- if (pgcd !== 1) {
74
- const affine2 = new affine_1.Affine(a / pgcd, b / pgcd);
75
- const coeff = pgcd ** 2;
76
- const answerTree2 = new multiplyNode_1.MultiplyNode(coeff.toTree(), affine2.toTree());
77
- validLatexs.push(...answerTree2.toAllValidTexs());
96
+ const isAnswerValid = (ans, { answer, a, b }) => {
97
+ try {
98
+ const parsed = (0, latexParser_1.parseAlgebraic)(ans);
99
+ if (!parsed)
100
+ return false;
101
+ if (!(0, multiplyNode_1.isMultiplyNode)(parsed) &&
102
+ !(0, powerNode_1.isSquareNode)(parsed) &&
103
+ !(0, powerNode_1.isPowerNode)(parsed))
104
+ return false;
105
+ return parsed.simplify().toTex() === answer;
106
+ }
107
+ catch (err) {
108
+ return false;
78
109
  }
79
- return validLatexs.includes(ans);
80
110
  };
81
111
  exports.factoIdRmq1 = {
82
112
  id: "factoIdRmq1",
@@ -92,4 +122,8 @@ exports.factoIdRmq1 = {
92
122
  isAnswerValid,
93
123
  subject: "Mathématiques",
94
124
  hasHintAndCorrection: true,
125
+ getInstruction,
126
+ getAnswer,
127
+ getHint,
128
+ getCorrection,
95
129
  };
@@ -1 +1 @@
1
- {"version":3,"file":"factoIdRmq2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoIdRmq2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAclC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgGF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAc7C,CAAC"}
1
+ {"version":3,"file":"factoIdRmq2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoIdRmq2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAuBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+HF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAkB7C,CAAC"}