math-exercises 3.0.133 → 3.0.134

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 (43) hide show
  1. package/lib/exercises/math/calculLitteral/distributivity/doubleDistri.d.ts.map +1 -1
  2. package/lib/exercises/math/calculLitteral/distributivity/doubleDistri.js +4 -0
  3. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts +4 -1
  4. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
  5. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +29 -9
  6. package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
  7. package/lib/exercises/math/geometry/cartesian/midpoint.js +8 -1
  8. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFirstRankOne.d.ts +8 -0
  9. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFirstRankOne.d.ts.map +1 -0
  10. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFirstRankOne.js +105 -0
  11. package/lib/exercises/math/sequences/arithmetic/arithmeticFindTermFirstRankOne.d.ts +9 -0
  12. package/lib/exercises/math/sequences/arithmetic/arithmeticFindTermFirstRankOne.d.ts.map +1 -0
  13. package/lib/exercises/math/sequences/arithmetic/arithmeticFindTermFirstRankOne.js +99 -0
  14. package/lib/exercises/math/sequences/arithmetic/arithmeticRecurrenceFormulaUsage.d.ts.map +1 -1
  15. package/lib/exercises/math/sequences/arithmetic/arithmeticRecurrenceFormulaUsage.js +9 -1
  16. package/lib/exercises/math/sequences/arithmetic/index.d.ts +2 -0
  17. package/lib/exercises/math/sequences/arithmetic/index.d.ts.map +1 -1
  18. package/lib/exercises/math/sequences/arithmetic/index.js +2 -0
  19. package/lib/exercises/math/sequences/genericSequenceVariations.d.ts.map +1 -1
  20. package/lib/exercises/math/sequences/genericSequenceVariations.js +5 -1
  21. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.d.ts.map +1 -1
  22. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.js +7 -1
  23. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
  24. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +1 -1
  25. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.d.ts +8 -0
  26. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.d.ts.map +1 -0
  27. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.js +112 -0
  28. package/lib/exercises/math/sequences/geometric/geometricFindTermFirstRankOne.d.ts +9 -0
  29. package/lib/exercises/math/sequences/geometric/geometricFindTermFirstRankOne.d.ts.map +1 -0
  30. package/lib/exercises/math/sequences/geometric/geometricFindTermFirstRankOne.js +97 -0
  31. package/lib/exercises/math/sequences/geometric/geometricReasonUsage.d.ts.map +1 -1
  32. package/lib/exercises/math/sequences/geometric/geometricReasonUsage.js +3 -1
  33. package/lib/exercises/math/sequences/geometric/geometricRecurrenceFormulaUsage.d.ts.map +1 -1
  34. package/lib/exercises/math/sequences/geometric/geometricRecurrenceFormulaUsage.js +9 -1
  35. package/lib/exercises/math/sequences/geometric/index.d.ts +2 -0
  36. package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
  37. package/lib/exercises/math/sequences/geometric/index.js +2 -0
  38. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts.map +1 -1
  39. package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +10 -3
  40. package/lib/index.d.ts +17 -1
  41. package/lib/index.d.ts.map +1 -1
  42. package/lib/server.js +7 -2
  43. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"doubleDistri.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/doubleDistri.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAgKF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
1
+ {"version":3,"file":"doubleDistri.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/doubleDistri.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAuKF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
@@ -103,6 +103,10 @@ const getPropositions = (n, { answer, affine1Coeffs, affine2Coeffs }) => {
103
103
  new Affine(affine1Coeffs[1], affine1Coeffs[0]),
104
104
  new Affine(affine2Coeffs[1], affine2Coeffs[0]),
105
105
  ];
106
+ tryToAddWrongProp(propositions, affines[0]
107
+ .multiply(new Affine(affines[1].a, randint(-9, 10, [affines[1].b])))
108
+ .toTree()
109
+ .toTex());
106
110
  tryToAddWrongProp(propositions, affines[0]
107
111
  .multiply(new Affine(-affines[1].a, randint(-9, 10, [affines[1].b])))
108
112
  .toTree()
@@ -4,6 +4,9 @@ type Identifiers = {
4
4
  b: number;
5
5
  c: number;
6
6
  };
7
- export declare const rootsReading: Exercise<Identifiers>;
7
+ type Options = {
8
+ withNoCoeffB: boolean;
9
+ };
10
+ export declare const rootsReading: Exercise<Identifiers, Options>;
8
11
  export {};
9
12
  //# sourceMappingURL=rootsReading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoGF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAY9C,CAAC"}
1
+ {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgHF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAUF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAcvD,CAAC"}
@@ -1,8 +1,9 @@
1
- import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randomColor } from "../../../../../geogebra/colors.js";
4
4
  import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
5
5
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
6
+ import { randfloat } from "../../../../../math/utils/random/randfloat.js";
6
7
  import { randint } from "../../../../../math/utils/random/randint.js";
7
8
  import { divide } from "../../../../../tree/nodes/operators/divideNode.js";
8
9
  import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
@@ -39,13 +40,22 @@ const getGGBOptions = (identifiers) => {
39
40
  });
40
41
  return ggb.getOptions({ coords: trinom.getCoords() });
41
42
  };
42
- const getRootsReadingQuestion = () => {
43
- const nbRoots = probaLawFlip([
44
- [0, 0.2],
45
- [1, 0.4],
46
- [2, 0.4],
47
- ]);
48
- const trinom = TrinomConstructor.randomNiceRoots(nbRoots);
43
+ const getRootsReadingQuestion = (opts) => {
44
+ let trinom;
45
+ if (opts?.withNoCoeffB) {
46
+ const x1 = randint(-10, 10);
47
+ const x2 = -x1;
48
+ const a = randfloat(-3, 3, 3, [0]);
49
+ trinom = TrinomConstructor.fromRoots([x1, x2], a);
50
+ }
51
+ else {
52
+ const nbRoots = probaLawFlip([
53
+ [0, 0.2],
54
+ [1, 0.4],
55
+ [2, 0.4],
56
+ ]);
57
+ trinom = TrinomConstructor.randomNiceRoots(nbRoots);
58
+ }
49
59
  const identifiers = { a: trinom.a, b: trinom.b, c: trinom.c };
50
60
  return getQuestionFromIdentifiers(identifiers);
51
61
  };
@@ -89,11 +99,20 @@ const isAnswerValid = (ans, { a, b, c }) => {
89
99
  return (!!studentNumbers.length &&
90
100
  studentNumbers.every((nb, index) => Math.abs(nb - roots[index]) < 0.2));
91
101
  };
102
+ const options = [
103
+ {
104
+ id: "withNoCoeffB",
105
+ label: "N'utiliser que des polynômes de la forme $ax^2 + b$",
106
+ target: GeneratorOptionTarget.generation,
107
+ type: GeneratorOptionType.checkbox,
108
+ defaultValue: false,
109
+ },
110
+ ];
92
111
  export const rootsReading = {
93
112
  id: "rootsReading",
94
113
  label: "Lire graphiquement les racines d'un trinôme",
95
114
  isSingleStep: true,
96
- generator: (nb) => getDistinctQuestions(getRootsReadingQuestion, nb),
115
+ generator: (nb, opts) => getDistinctQuestions(() => getRootsReadingQuestion(opts), nb),
97
116
  qcmTimer: 60,
98
117
  freeTimer: 60,
99
118
  getPropositions,
@@ -101,4 +120,5 @@ export const rootsReading = {
101
120
  hasGeogebra: true,
102
121
  subject: "Mathématiques",
103
122
  getQuestionFromIdentifiers,
123
+ options,
104
124
  };
@@ -1 +1 @@
1
- {"version":3,"file":"midpoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/midpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA+IF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAa1C,CAAC"}
1
+ {"version":3,"file":"midpoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/midpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAsKF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAa1C,CAAC"}
@@ -6,6 +6,7 @@ import { PointNode } from "../../../../tree/nodes/geometry/pointNode.js";
6
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
7
7
  import { add } from "../../../../tree/nodes/operators/addNode.js";
8
8
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
9
10
  import { shuffle } from "../../../../utils/alea/shuffle.js";
10
11
  import { alignTex } from "../../../../utils/latex/alignTex.js";
11
12
  const getPoints = (identifiers) => {
@@ -73,9 +74,15 @@ const getQuestionFromIdentifiers = (identifiers) => {
73
74
  };
74
75
  return question;
75
76
  };
76
- const getPropositions = (n, { answer }) => {
77
+ const getPropositions = (n, { answer, coordsA, coordsB }) => {
77
78
  const propositions = [];
78
79
  addValidProp(propositions, answer);
80
+ tryToAddWrongProp(propositions, new Point("I", frac(add(coordsA[0], coordsA[1]), 2), frac(add(coordsB[0], coordsB[1]), 2))
81
+ .simplify()
82
+ .toTexWithCoords());
83
+ tryToAddWrongProp(propositions, new Point("I", frac(substract(coordsA[0], coordsB[0]), 2), frac(substract(coordsB[0], coordsB[1]), 2))
84
+ .simplify()
85
+ .toTexWithCoords());
79
86
  propWhile(propositions, n, () => {
80
87
  const [tempCoords1, tempsCoords2] = distinctRandTupleInt(2, 2, {
81
88
  from: -9,
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ firstValue: number;
4
+ reason: number;
5
+ };
6
+ export declare const arithmeticFindExplicitFormulaFirstRankOne: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=arithmeticFindExplicitFormulaFirstRankOne.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arithmeticFindExplicitFormulaFirstRankOne.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFirstRankOne.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA4GF,eAAO,MAAM,yCAAyC,EAAE,QAAQ,CAAC,WAAW,CAgBzE,CAAC"}
@@ -0,0 +1,105 @@
1
+ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Polynomial } from "../../../../math/polynomials/polynomial.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
6
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ const getInstruction = (identifiers) => {
9
+ return `$(u_n)$ est une suite arithmétique de premier terme $u_{1} = ${identifiers.firstValue}$ et de raison $r = ${identifiers.reason}$.
10
+
11
+ Donner l'expression de $u_n$ en fonction de $n$.`;
12
+ };
13
+ const getHint = (_identifiers) => {
14
+ return `Utilise la formule générale d'une suite arithmétique :
15
+
16
+ $$
17
+ u_n = u_1 + (n-1) \\times r
18
+ $$
19
+
20
+ où $u_1$ est le premier terme et $r$ la raison.`;
21
+ };
22
+ const getCorrection = (identifiers) => {
23
+ const answer = getAnswer(identifiers);
24
+ return `La formule générale d'une suite arithmétique est :
25
+
26
+ $$
27
+ u_n = u_1 + (n-1) \\times r
28
+ $$
29
+
30
+ où $u_1$ est le premier terme et $r$ la raison.
31
+
32
+ Ici, puisque $u_1 = ${identifiers.firstValue}$ et $r = ${identifiers.reason}$, on a :
33
+
34
+ $$
35
+ ${answer}
36
+ $$
37
+
38
+ `;
39
+ };
40
+ const getAnswer = (identifiers) => {
41
+ const { firstValue, reason } = identifiers;
42
+ const formula = new Polynomial([firstValue - reason, reason], "n");
43
+ const answer = "u_n=" + formula.toTex();
44
+ return answer;
45
+ };
46
+ const getArithmeticFindExplicitFormula = () => {
47
+ const firstValue = randint(-10, 10);
48
+ const reason = randint(-10, 10, [0]);
49
+ const identifiers = { firstValue, reason };
50
+ return getQuestionFromIdentifiers(identifiers);
51
+ };
52
+ const getQuestionFromIdentifiers = (identifiers) => {
53
+ const question = {
54
+ instruction: getInstruction(identifiers),
55
+ answer: getAnswer(identifiers),
56
+ keys: ["un", "equal", "n"],
57
+ answerFormat: "tex",
58
+ identifiers,
59
+ hint: getHint(identifiers),
60
+ correction: getCorrection(identifiers),
61
+ };
62
+ return question;
63
+ };
64
+ const getPropositions = (n, { answer, firstValue, reason }) => {
65
+ const propositions = [];
66
+ addValidProp(propositions, answer);
67
+ propWhile(propositions, n, () => {
68
+ tryToAddWrongProp(propositions, "u_n=" +
69
+ new Polynomial([firstValue + randint(-3, 4), reason + randint(-3, 4, [-reason])], "n")
70
+ .toTree()
71
+ .toTex());
72
+ });
73
+ return shuffle(propositions);
74
+ };
75
+ const isAnswerValid = (ans, { answer }) => {
76
+ try {
77
+ const formated = ans.replaceAll("u_n", "").replaceAll("=", "");
78
+ const parsed = parseAlgebraic(formated);
79
+ if (!parsed)
80
+ return false;
81
+ return (parsed
82
+ .simplify({
83
+ towardsDistribute: true,
84
+ forbidFactorize: true,
85
+ })
86
+ .toTex() === answer.split("=")[1]);
87
+ }
88
+ catch (err) {
89
+ return handleVEAError(err);
90
+ }
91
+ };
92
+ export const arithmeticFindExplicitFormulaFirstRankOne = {
93
+ id: "arithmeticFindExplicitFormulaFirstRankOne",
94
+ connector: "=",
95
+ label: "Déterminer la formule générale d'une suite arithmétique (premier terme $u_1$)",
96
+ isSingleStep: false,
97
+ generator: (nb, opts) => getDistinctQuestions(() => getArithmeticFindExplicitFormula(opts), nb),
98
+ qcmTimer: 60,
99
+ freeTimer: 60,
100
+ getPropositions,
101
+ isAnswerValid,
102
+ subject: "Mathématiques",
103
+ hasHintAndCorrection: true,
104
+ getQuestionFromIdentifiers,
105
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ firstTerm: number;
4
+ reason: number;
5
+ askedRank: number;
6
+ };
7
+ export declare const arithmeticFindTermFirstRankOne: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=arithmeticFindTermFirstRankOne.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arithmeticFindTermFirstRankOne.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindTermFirstRankOne.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAsGF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAehE,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
5
+ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
7
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
8
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
9
+ const getInstruction = (identifiers) => {
10
+ const { firstTerm, reason, askedRank } = identifiers;
11
+ return `Soit $u$ la suite arithmétique de premier terme $u_1 = ${firstTerm}$ et de raison $r = ${reason}$.
12
+
13
+ Calculer $u_{${askedRank}}$.`;
14
+ };
15
+ const getAnswer = (identifiers) => {
16
+ const { firstTerm, reason, askedRank } = identifiers;
17
+ const answer = firstTerm + reason * (askedRank - 1);
18
+ return answer.frenchify();
19
+ };
20
+ const getHint = () => {
21
+ return `Le terme général d'une suite arithmétique est :
22
+
23
+ $$
24
+ u_n = u_1 + r \\times (n-1)
25
+ $$
26
+
27
+ où $u_1$ est le premier terme et $r$ la raison.`;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const { firstTerm, reason, askedRank } = identifiers;
31
+ return `Le terme général de la suite $u$ est :
32
+
33
+ ${alignTex([
34
+ [`u_n`, "=", `u_1 + r \\times (n-1)`],
35
+ [
36
+ "",
37
+ "=",
38
+ new AddNode(firstTerm.toTree(), new MultiplyNode(reason.toTree(), new SubstractNode(new VariableNode("n"), (1).toTree()))).toTex(),
39
+ ],
40
+ ])}
41
+
42
+ Il suffit alors de remplacer $n$ par $${askedRank}$ dans la formule :
43
+
44
+ ${alignTex([
45
+ [
46
+ `u_{${askedRank}}`,
47
+ "=",
48
+ `${new AddNode(firstTerm.toTree(), new MultiplyNode(reason.toTree(), (askedRank - 1).toTree())).toTex()}`,
49
+ ],
50
+ ["", "=", `${getAnswer(identifiers)}`],
51
+ ])}
52
+ `;
53
+ };
54
+ const getQuestionFromIdentifiers = (identifiers) => {
55
+ const question = {
56
+ answer: getAnswer(identifiers),
57
+ instruction: getInstruction(identifiers),
58
+ keys: [],
59
+ answerFormat: "tex",
60
+ identifiers,
61
+ hint: getHint(identifiers),
62
+ correction: getCorrection(identifiers),
63
+ };
64
+ return question;
65
+ };
66
+ const getArithmeticFindTermQuestion = () => {
67
+ const firstRank = 1;
68
+ const firstTerm = randint(-15, 15);
69
+ const reason = randint(-10, 10, [0]);
70
+ const askedRank = randint(5, 15);
71
+ const identifiers = { firstRank, askedRank, firstTerm, reason };
72
+ return getQuestionFromIdentifiers(identifiers);
73
+ };
74
+ const getPropositions = (n, { answer, askedRank, firstTerm, reason }) => {
75
+ const propositions = [];
76
+ addValidProp(propositions, answer);
77
+ propWhile(propositions, n, () => {
78
+ const fake = firstTerm + reason * (askedRank - randint(-4, 4, [1]));
79
+ tryToAddWrongProp(propositions, fake + "");
80
+ });
81
+ return shuffleProps(propositions, n);
82
+ };
83
+ const isAnswerValid = (ans, { answer }) => {
84
+ return ans === answer;
85
+ };
86
+ export const arithmeticFindTermFirstRankOne = {
87
+ id: "arithmeticFindTermFirstRankOne",
88
+ connector: "=",
89
+ label: "Calculer un terme d'une suite arithmétique à partir de son premier terme ($u_1$) et sa raison",
90
+ isSingleStep: true,
91
+ generator: (nb) => getDistinctQuestions(getArithmeticFindTermQuestion, nb),
92
+ qcmTimer: 60,
93
+ freeTimer: 60,
94
+ getPropositions,
95
+ isAnswerValid,
96
+ subject: "Mathématiques",
97
+ hasHintAndCorrection: true,
98
+ getQuestionFromIdentifiers,
99
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"arithmeticRecurrenceFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticRecurrenceFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAgEF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
1
+ {"version":3,"file":"arithmeticRecurrenceFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticRecurrenceFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAwEF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
@@ -5,7 +5,15 @@ import { shuffle } from "../../../../utils/alea/shuffle.js";
5
5
  const getInstruction = (identifiers) => {
6
6
  const { firstRank, firstValue, reason } = identifiers;
7
7
  const askedRank = firstRank + 1;
8
- return `$(u_n)$ est une suite définie par $u_{n+1} = ${reason} + u_n$ et $u_{${firstRank}} = ${firstValue}$. Calculer : $u_{${askedRank}}$`;
8
+ return `$(u_n)$ est une suite définie par :
9
+
10
+ $$
11
+ u_{n+1} = ${reason} + u_n
12
+ $$
13
+
14
+ et $u_{${firstRank}} = ${firstValue}$.
15
+
16
+ Calculer le terme $u_{${askedRank}}$.`;
9
17
  };
10
18
  const getAnswer = (identifiers) => {
11
19
  const { firstValue, reason } = identifiers;
@@ -1,5 +1,6 @@
1
1
  export * from "./arithmeticExplicitFormulaUsage.js";
2
2
  export * from "./arithmeticFindExplicitFormula.js";
3
+ export * from "./arithmeticFindExplicitFormulaFirstRankOne.js";
3
4
  export * from "./arithmeticFindReason.js";
4
5
  export * from "./arithmeticReasonUsage.js";
5
6
  export * from "./arithmeticRecurrenceFormulaUsage.js";
@@ -14,5 +15,6 @@ export * from "./arithmeticFindExplictFormulaFirstTermRandom.js";
14
15
  export * from "./arithmeticFindReasonRandomRange.js";
15
16
  export * from "./arithmeticFindRandomTermFromTwoTerms.js";
16
17
  export * from "./arithmeticFindTerm.js";
18
+ export * from "./arithmeticFindTermFirstRankOne.js";
17
19
  export * from "./arithmeticFindAntecedent.js";
18
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kDAAkD,CAAC;AACjE,cAAc,sCAAsC,CAAC;AACrD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AAEpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAE/D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kDAAkD,CAAC;AACjE,cAAc,sCAAsC,CAAC;AACrD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yBAAyB,CAAC;AACxC,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from "./arithmeticExplicitFormulaUsage.js";
2
2
  export * from "./arithmeticFindExplicitFormula.js";
3
+ export * from "./arithmeticFindExplicitFormulaFirstRankOne.js";
3
4
  export * from "./arithmeticFindReason.js";
4
5
  export * from "./arithmeticReasonUsage.js";
5
6
  export * from "./arithmeticRecurrenceFormulaUsage.js";
@@ -14,4 +15,5 @@ export * from "./arithmeticFindExplictFormulaFirstTermRandom.js";
14
15
  export * from "./arithmeticFindReasonRandomRange.js";
15
16
  export * from "./arithmeticFindRandomTermFromTwoTerms.js";
16
17
  export * from "./arithmeticFindTerm.js";
18
+ export * from "./arithmeticFindTermFirstRankOne.js";
17
19
  export * from "./arithmeticFindAntecedent.js";
@@ -1 +1 @@
1
- {"version":3,"file":"genericSequenceVariations.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sequences/genericSequenceVariations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAqEF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"genericSequenceVariations.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sequences/genericSequenceVariations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAyEF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
@@ -5,7 +5,11 @@ import { randint } from "../../../math/utils/random/randint.js";
5
5
  const getInstruction = (identifiers) => {
6
6
  const { coeffs } = identifiers;
7
7
  const u = new Polynomial(coeffs, "n");
8
- return `Soit $u$ la suite définie par $u_n = ${u.toTree().toTex()}$.
8
+ return `Soit $u$ la suite définie par :
9
+
10
+ $$
11
+ u_n = ${u.toTree().toTex()}
12
+ $$
9
13
 
10
14
  Quel est le sens de variations de $u$ ?`;
11
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"geometricExplicitFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAkGF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAmB/D,CAAC"}
1
+ {"version":3,"file":"geometricExplicitFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAwGF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAmB/D,CAAC"}
@@ -13,7 +13,13 @@ const getInstruction = (identifiers) => {
13
13
  const { firstValue, reason, askedRank } = identifiers;
14
14
  const formula = new MultiplyNode(new NumberNode(firstValue), new PowerNode(new NumberNode(reason), new VariableNode("n")));
15
15
  const formulaTex = formula.toTex();
16
- return `$(u_n)$ est une suite géométrique définie par $u_n = ${formulaTex}$. Calculer : $u_{${askedRank}}$`;
16
+ return `$(u_n)$ est une suite géométrique définie par :
17
+
18
+ $$
19
+ u_n = ${formulaTex}
20
+ $$
21
+
22
+ Calculer le terme $u_{${askedRank}}$.`;
17
23
  };
18
24
  const getAnswer = (identifiers) => {
19
25
  const { firstValue, reason, askedRank } = identifiers;
@@ -1 +1 @@
1
- {"version":3,"file":"geometricFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA8HF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAc9D,CAAC"}
1
+ {"version":3,"file":"geometricFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA8HF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAe9D,CAAC"}
@@ -98,7 +98,7 @@ const isAnswerValid = (ans, { reason, firstValue }) => {
98
98
  export const geometricFindExplicitFormula = {
99
99
  id: "geometricFindExplicitFormula",
100
100
  connector: "=",
101
- label: "Déterminer la formule générale d'une suite géométrique",
101
+ label: "Déterminer la formule générale d'une suite géométrique (premier rang $u_0$)",
102
102
  isSingleStep: false,
103
103
  generator: (nb) => getDistinctQuestions(getGeometricFindExplicitFormula, nb),
104
104
  qcmTimer: 60,
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ reason: number;
4
+ firstValue: number;
5
+ };
6
+ export declare const geometricFindExplicitFormulaFirstRankOne: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=geometricFindExplicitFormulaFirstRankOne.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometricFindExplicitFormulaFirstRankOne.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAoIF,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAAC,WAAW,CAe1E,CAAC"}
@@ -0,0 +1,112 @@
1
+ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
5
+ import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
6
+ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
8
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
9
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
10
+ import { parseLatex } from "../../../../tree/parsers/latexParser.js";
11
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
+ const getInstruction = (identifiers) => {
13
+ const { firstValue, reason } = identifiers;
14
+ const firstRank = 1;
15
+ return `$(u_n)$ est une suite géométrique de premier terme $u_{${firstRank}} = ${firstValue}$ et de raison $q = ${reason}$.
16
+
17
+ Donner l'expression de $u_n$ en fonction de $n$.`;
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { firstValue, reason } = identifiers;
21
+ const formula = new MultiplyNode(new NumberNode(firstValue), new PowerNode(new NumberNode(reason), substract("n", 1)));
22
+ const answer = "u_n=" + formula.toTex();
23
+ return answer;
24
+ };
25
+ const getHint = () => {
26
+ return `Utilise la formule générale d'une suite géométrique :
27
+
28
+ $$
29
+ u_n = u_1 \\times r^{n-1}
30
+ $$
31
+
32
+ où $u_1$ est le premier terme et $r$ la raison.`;
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const { firstValue, reason } = identifiers;
36
+ const answer = getAnswer(identifiers);
37
+ return `La formule générale d'une suite géométrique est :
38
+
39
+ $$
40
+ u_n = u_1 \\times r^{n-1}
41
+ $$
42
+
43
+ où $u_1$ est le premier terme et $r$ la raison.
44
+
45
+ Ici, puisque $u_1 = ${firstValue}$ et $r = ${reason}$, on a :
46
+
47
+ $$
48
+ ${answer}
49
+ $$`;
50
+ };
51
+ const getQuestionFromIdentifiers = (identifiers) => {
52
+ const question = {
53
+ instruction: getInstruction(identifiers),
54
+ answer: getAnswer(identifiers),
55
+ keys: ["un", "equal", "n"],
56
+ answerFormat: "tex",
57
+ identifiers,
58
+ hint: getHint(identifiers),
59
+ correction: getCorrection(identifiers),
60
+ };
61
+ return question;
62
+ };
63
+ const getGeometricFindExplicitFormula = () => {
64
+ const firstValue = randint(1, 10);
65
+ const reason = randint(2, 10);
66
+ const identifiers = { reason, firstValue };
67
+ return getQuestionFromIdentifiers(identifiers);
68
+ };
69
+ const getPropositions = (n, { answer, reason, firstValue }) => {
70
+ const propositions = [];
71
+ addValidProp(propositions, answer);
72
+ tryToAddWrongProp(propositions, "u_n=" +
73
+ new MultiplyNode(new NumberNode(firstValue), new PowerNode(new NumberNode(reason), new VariableNode("n"))).toTex());
74
+ tryToAddWrongProp(propositions, "u_n=" +
75
+ new MultiplyNode(new NumberNode(reason), new PowerNode(new NumberNode(firstValue), substract("n", 1))).toTex());
76
+ propWhile(propositions, n, () => {
77
+ const wrongAnswer = new MultiplyNode(new NumberNode(firstValue + randint(-firstValue, 2 * firstValue + 1)), new PowerNode(new NumberNode(reason + +randint(-reason + 1, 2 * reason + 1)), substract("n", 1)));
78
+ tryToAddWrongProp(propositions, "u_n=" + wrongAnswer.toTex());
79
+ });
80
+ return shuffle(propositions);
81
+ };
82
+ const isAnswerValid = (ans, { reason, firstValue }) => {
83
+ const formula = new MultiplyNode(new NumberNode(firstValue), new PowerNode(new NumberNode(reason), substract("n", 1)));
84
+ const equal = new EqualNode(new VariableNode("u_n"), formula, {
85
+ allowRawRightChildAsSolution: true,
86
+ });
87
+ const texs = equal.toAllValidTexs();
88
+ return (texs.includes(ans) ||
89
+ (() => {
90
+ const splitted = ans.split("=");
91
+ const rightTerm = splitted[1] ?? splitted[0];
92
+ const nodeAns = parseLatex(rightTerm);
93
+ const differenceNode = substract(nodeAns, formula);
94
+ return (differenceNode.evaluate({ n: 0 }) === 0 &&
95
+ differenceNode.evaluate({ n: 1 }) === 0 &&
96
+ differenceNode.evaluate({ n: 5 }) === 0);
97
+ })());
98
+ };
99
+ export const geometricFindExplicitFormulaFirstRankOne = {
100
+ id: "geometricFindExplicitFormulaFirstRankOne",
101
+ connector: "=",
102
+ label: "Déterminer la formule générale d'une suite géométrique (premier rang $u_1$)",
103
+ isSingleStep: false,
104
+ generator: (nb) => getDistinctQuestions(getGeometricFindExplicitFormula, nb),
105
+ qcmTimer: 60,
106
+ freeTimer: 60,
107
+ getPropositions,
108
+ isAnswerValid,
109
+ subject: "Mathématiques",
110
+ hasHintAndCorrection: true,
111
+ getQuestionFromIdentifiers,
112
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ firstTerm: number;
4
+ reason: number;
5
+ askedRank: number;
6
+ };
7
+ export declare const geometricFindTermFirstRankOne: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=geometricFindTermFirstRankOne.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometricFindTermFirstRankOne.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindTermFirstRankOne.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAiGF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAe/D,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
5
+ import { PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
6
+ import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
7
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
8
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
9
+ const getInstruction = (identifiers) => {
10
+ const { firstTerm, reason, askedRank } = identifiers;
11
+ return `Soit $u$ la suite géométrique de premier terme $u_1 = ${firstTerm}$ et de raison $q = ${reason}$. Calculer $u_{${askedRank}}$.`;
12
+ };
13
+ const getAnswer = (identifiers) => {
14
+ const { firstTerm, reason, askedRank } = identifiers;
15
+ const answer = firstTerm * Math.pow(reason, askedRank - 1);
16
+ return answer.frenchify();
17
+ };
18
+ const getHint = () => {
19
+ return `Le terme général d'une suite geométrique est :
20
+
21
+ $$
22
+ u_n = u_1 \\times q^{n-1}
23
+ $$
24
+
25
+ où $u_1$ est le premier terme et $q$ la raison.`;
26
+ };
27
+ const getCorrection = (identifiers) => {
28
+ const { firstTerm, reason, askedRank } = identifiers;
29
+ return `Le terme général de la suite $u$ est :
30
+
31
+ ${alignTex([
32
+ [`u_n`, "=", `u_1 \\times q^{n-1}`],
33
+ [
34
+ "",
35
+ "=",
36
+ new MultiplyNode(firstTerm.toTree(), new PowerNode(reason.toTree(), new SubstractNode(new VariableNode("n"), (1).toTree()))).toTex(),
37
+ ],
38
+ ])}
39
+
40
+ Il suffit alors de remplacer $n$ par $${askedRank}$ dans la formule :
41
+
42
+ ${alignTex([
43
+ [
44
+ `u_{${askedRank}}`,
45
+ "=",
46
+ `${new MultiplyNode(firstTerm.toTree(), new PowerNode(reason.toTree(), (askedRank - 1).toTree())).toTex()}`,
47
+ ],
48
+ ["", "=", getAnswer(identifiers)],
49
+ ])}
50
+ `;
51
+ };
52
+ const getQuestionFromIdentifiers = (identifiers) => {
53
+ const question = {
54
+ answer: getAnswer(identifiers),
55
+ instruction: getInstruction(identifiers),
56
+ keys: [],
57
+ answerFormat: "tex",
58
+ hint: getHint(identifiers),
59
+ correction: getCorrection(identifiers),
60
+ identifiers,
61
+ };
62
+ return question;
63
+ };
64
+ const getGeometricFindTermQuestion = () => {
65
+ const firstRank = 1;
66
+ const firstTerm = randint(-10, 10, [0]);
67
+ const reason = randint(2, 6);
68
+ const askedRank = randint(5, 12);
69
+ const identifiers = { firstRank, askedRank, firstTerm, reason };
70
+ return getQuestionFromIdentifiers(identifiers);
71
+ };
72
+ const getPropositions = (n, { answer, askedRank, firstTerm, reason }) => {
73
+ const propositions = [];
74
+ addValidProp(propositions, answer);
75
+ propWhile(propositions, n, () => {
76
+ const fake = firstTerm * Math.pow(reason, askedRank - randint(-5, 3, [1]));
77
+ tryToAddWrongProp(propositions, fake + "");
78
+ });
79
+ return shuffleProps(propositions, n);
80
+ };
81
+ const isAnswerValid = (ans, { answer }) => {
82
+ return ans === answer;
83
+ };
84
+ export const geometricFindTermFirstRankOne = {
85
+ id: "geometricFindTermFirstRankOne",
86
+ connector: "=",
87
+ label: "Calculer un terme d'une suite géométrique à partir de son premier terme ($u_1$) et sa raison",
88
+ isSingleStep: true,
89
+ generator: (nb) => getDistinctQuestions(getGeometricFindTermQuestion, nb),
90
+ qcmTimer: 60,
91
+ freeTimer: 60,
92
+ getPropositions,
93
+ isAnswerValid,
94
+ subject: "Mathématiques",
95
+ hasHintAndCorrection: true,
96
+ getQuestionFromIdentifiers,
97
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"geometricReasonUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricReasonUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAwGF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAYtD,CAAC"}
1
+ {"version":3,"file":"geometricReasonUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricReasonUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA0GF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAYtD,CAAC"}
@@ -9,7 +9,9 @@ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
9
  import { probaLawFlip } from "../../../../utils/alea/probaLawFlip.js";
10
10
  const getInstruction = (identifiers) => {
11
11
  const { reason, startRank, startValue, askedRank } = identifiers;
12
- return `$(u_n)$ est une suite géométrique de raison $q = ${reason}$ et on sait que $u_{${startRank}} = ${startValue}$. Calculer : $u_{${askedRank}}$`;
12
+ return `$(u_n)$ est une suite géométrique de raison $q = ${reason}$ et on sait que $u_{${startRank}} = ${startValue}$.
13
+
14
+ Calculer le terme $u_{${askedRank}}$.`;
13
15
  };
14
16
  const getAnswer = (identifiers) => {
15
17
  const answer = getAnswerNode(identifiers).evaluate().frenchify();
@@ -1 +1 @@
1
- {"version":3,"file":"geometricRecurrenceFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricRecurrenceFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAwEF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"geometricRecurrenceFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricRecurrenceFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAgFF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAajE,CAAC"}
@@ -5,7 +5,15 @@ import { shuffle } from "../../../../utils/alea/shuffle.js";
5
5
  const getInstruction = (identifiers) => {
6
6
  const { firstRank, firstValue, reason } = identifiers;
7
7
  const askedRank = firstRank + 1;
8
- return `$(u_n)$ est une suite définie par $u_{n+1} = ${reason}\\times u_n$ et $u_{${firstRank}} = ${firstValue}$. Calculer : $u_{${askedRank}}$`;
8
+ return `$(u_n)$ est une suite définie par :
9
+
10
+ $$
11
+ u_{n+1} = ${reason}\\times u_n
12
+ $$
13
+
14
+ et $u_{${firstRank}} = ${firstValue}$.
15
+
16
+ Calculer le terme $u_{${askedRank}}$.`;
9
17
  };
10
18
  const getAnswer = (identifiers) => {
11
19
  const { firstValue, reason } = identifiers;
@@ -1,11 +1,13 @@
1
1
  export * from "./geometricExplicitFormulaUsage.js";
2
2
  export * from "./geometricFindExplicitFormula.js";
3
+ export * from "./geometricFindExplicitFormulaFirstRankOne.js";
3
4
  export * from "./geometricFindReason.js";
4
5
  export * from "./geometricFirstTermsSum.js";
5
6
  export * from "./geometricReasonUsage.js";
6
7
  export * from "./geometricRecurrenceFormulaUsage.js";
7
8
  export * from "./geometricFindExplicitFormulaFirstTermRandom.js";
8
9
  export * from "./geometricFindTerm.js";
10
+ export * from "./geometricFindTermFirstRankOne.js";
9
11
  export * from "./geometricRecognizeReasonFromFirstTerms.js";
10
12
  export * from "./geometricFirstTermsGeneralSum.js";
11
13
  export * from "./geometricVariations.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wBAAwB,CAAC;AACvC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAE9D,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC"}
@@ -1,11 +1,13 @@
1
1
  export * from "./geometricExplicitFormulaUsage.js";
2
2
  export * from "./geometricFindExplicitFormula.js";
3
+ export * from "./geometricFindExplicitFormulaFirstRankOne.js";
3
4
  export * from "./geometricFindReason.js";
4
5
  export * from "./geometricFirstTermsSum.js";
5
6
  export * from "./geometricReasonUsage.js";
6
7
  export * from "./geometricRecurrenceFormulaUsage.js";
7
8
  export * from "./geometricFindExplicitFormulaFirstTermRandom.js";
8
9
  export * from "./geometricFindTerm.js";
10
+ export * from "./geometricFindTermFirstRankOne.js";
9
11
  export * from "./geometricRecognizeReasonFromFirstTerms.js";
10
12
  export * from "./geometricFirstTermsGeneralSum.js";
11
13
  export * from "./geometricVariations.js";
@@ -1 +1 @@
1
- {"version":3,"file":"recurrenceFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sequences/recurrenceFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAiEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAaxD,CAAC"}
1
+ {"version":3,"file":"recurrenceFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sequences/recurrenceFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAwEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAaxD,CAAC"}
@@ -5,9 +5,16 @@ import { randint } from "../../../math/utils/random/randint.js";
5
5
  const getInstruction = (identifiers) => {
6
6
  const { rank, u0, coeffs } = identifiers;
7
7
  const u = new Polynomial(coeffs, "u_n");
8
- return `Soit $u$ la suite définie par $u_0 = ${u0}$ et pour tout $n\\geq 1$, $u_{n+1} = ${u
9
- .toTree()
10
- .toTex()}$. Calculer $u_${rank}$.`;
8
+ return `Soit $u$ la suite définie par :
9
+
10
+ - $u_0 = ${u0}$,
11
+
12
+ - pour tout $n\\geq 1$ :
13
+ $$
14
+ u_{n+1} = ${u.toTree().toTex()}
15
+ $$
16
+
17
+ Calculer $u_${rank}$.`;
11
18
  };
12
19
  const getAnswer = (identifiers) => {
13
20
  const { rank, u0, coeffs } = identifiers;
package/lib/index.d.ts CHANGED
@@ -1197,7 +1197,9 @@ declare const mathExercises: (Exercise<{
1197
1197
  a: number;
1198
1198
  b: number;
1199
1199
  c: number;
1200
- }, Record<string, string | boolean | string[]>> | Exercise<{
1200
+ }, {
1201
+ withNoCoeffB: boolean;
1202
+ }> | Exercise<{
1201
1203
  trinomIdentifiers: import("./tree/nodes/polynomials/trinomNode.js").TrinomNodeIdentifiers;
1202
1204
  }, Record<string, string | boolean | string[]>> | Exercise<{
1203
1205
  trinomCoeffs: number[];
@@ -2492,6 +2494,9 @@ declare const mathExercises: (Exercise<{
2492
2494
  }, Record<string, string | boolean | string[]>> | Exercise<{
2493
2495
  firstValue: number;
2494
2496
  reason: number;
2497
+ }, Record<string, string | boolean | string[]>> | Exercise<{
2498
+ firstValue: number;
2499
+ reason: number;
2495
2500
  }, Record<string, string | boolean | string[]>> | Exercise<{
2496
2501
  rank1: number;
2497
2502
  reason: number;
@@ -2547,6 +2552,10 @@ declare const mathExercises: (Exercise<{
2547
2552
  firstTerm: number;
2548
2553
  reason: number;
2549
2554
  askedRank: number;
2555
+ }, Record<string, string | boolean | string[]>> | Exercise<{
2556
+ firstTerm: number;
2557
+ reason: number;
2558
+ askedRank: number;
2550
2559
  }, Record<string, string | boolean | string[]>> | Exercise<{
2551
2560
  a: number;
2552
2561
  b: number;
@@ -2558,6 +2567,9 @@ declare const mathExercises: (Exercise<{
2558
2567
  }, Record<string, string | boolean | string[]>> | Exercise<{
2559
2568
  reason: number;
2560
2569
  firstValue: number;
2570
+ }, Record<string, string | boolean | string[]>> | Exercise<{
2571
+ reason: number;
2572
+ firstValue: number;
2561
2573
  }, Record<string, string | boolean | string[]>> | Exercise<{
2562
2574
  value1: number;
2563
2575
  reason: number;
@@ -2583,6 +2595,10 @@ declare const mathExercises: (Exercise<{
2583
2595
  firstTerm: number;
2584
2596
  reason: number;
2585
2597
  askedRank: number;
2598
+ }, Record<string, string | boolean | string[]>> | Exercise<{
2599
+ firstTerm: number;
2600
+ reason: number;
2601
+ askedRank: number;
2586
2602
  }, Record<string, string | boolean | string[]>> | Exercise<{
2587
2603
  sequence: number[];
2588
2604
  reason: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
package/lib/server.js CHANGED
@@ -83,8 +83,11 @@ const runServer = () => {
83
83
  const identifiers = req.query.identifiers
84
84
  ? JSON.parse(req.query.identifiers)
85
85
  : undefined;
86
- const answer = req.query.answer;
86
+ console.log("raw", req.query.answer);
87
+ console.log("dec", decodeURI(req.query.answer));
88
+ const answer = JSON.parse(decodeURI(req.query.answer));
87
89
  const exo = allExercises.find((exo) => exo.id == exoId);
90
+ console.log("ans", answer);
88
91
  if (!exo) {
89
92
  res.send("Exo not found");
90
93
  return;
@@ -93,7 +96,7 @@ const runServer = () => {
93
96
  res.send("no getPropositions");
94
97
  return;
95
98
  }
96
- const props = exo.getPropositions(n, { answer, ...identifiers }, options);
99
+ const props = exo.getPropositions(n, { answer: exo.getAnswer?.(identifiers, options) ?? "", ...identifiers }, options);
97
100
  res.json(props);
98
101
  });
99
102
  app.get("/isAnswerTableValid", (req, res) => {
@@ -137,7 +140,9 @@ const runServer = () => {
137
140
  res.send("no isAnswerValid");
138
141
  return;
139
142
  }
143
+ console.log("there");
140
144
  const valid = exo.isAnswerValid(studentAnswer, { answer, ...identifiers }, options);
145
+ console.log(valid);
141
146
  res.json(valid);
142
147
  });
143
148
  app.get("/isGGBAnswerValid", (req, res) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.133",
4
+ "version": "3.0.134",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [