math-exercises 3.0.101 → 3.0.102

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 (66) hide show
  1. package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.js +1 -1
  2. package/lib/exercises/math/curve/sqrtCurvePoint.js +3 -3
  3. package/lib/exercises/math/dataRepresentations/barChartReading.d.ts +1 -1
  4. package/lib/exercises/math/dataRepresentations/barChartReading.js +1 -1
  5. package/lib/exercises/math/functions/basics/imageFunction.d.ts.map +1 -1
  6. package/lib/exercises/math/functions/basics/imageFunction.js +8 -8
  7. package/lib/exercises/math/functions/sqrt/compareSqrtValues.js +1 -1
  8. package/lib/exercises/math/geometry/index.d.ts +1 -0
  9. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  10. package/lib/exercises/math/geometry/index.js +1 -0
  11. package/lib/exercises/math/geometry/optimisation/geometryExtremaReadingOnGraph.d.ts +8 -0
  12. package/lib/exercises/math/geometry/optimisation/geometryExtremaReadingOnGraph.d.ts.map +1 -0
  13. package/lib/exercises/math/geometry/optimisation/geometryExtremaReadingOnGraph.js +145 -0
  14. package/lib/exercises/math/geometry/optimisation/index.d.ts +4 -0
  15. package/lib/exercises/math/geometry/optimisation/index.d.ts.map +1 -0
  16. package/lib/exercises/math/geometry/optimisation/index.js +3 -0
  17. package/lib/exercises/math/geometry/optimisation/lengthIntervalOnPicture.d.ts +8 -0
  18. package/lib/exercises/math/geometry/optimisation/lengthIntervalOnPicture.d.ts.map +1 -0
  19. package/lib/exercises/math/geometry/optimisation/lengthIntervalOnPicture.js +93 -0
  20. package/lib/exercises/math/geometry/optimisation/lengthWithXOnPicture.d.ts +8 -0
  21. package/lib/exercises/math/geometry/optimisation/lengthWithXOnPicture.d.ts.map +1 -0
  22. package/lib/exercises/math/geometry/optimisation/lengthWithXOnPicture.js +99 -0
  23. package/lib/exercises/math/geometry/pythagore/index.d.ts +1 -0
  24. package/lib/exercises/math/geometry/pythagore/index.d.ts.map +1 -1
  25. package/lib/exercises/math/geometry/pythagore/index.js +1 -1
  26. package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts.map +1 -1
  27. package/lib/exercises/math/geometry/pythagore/triangleHeight.js +78 -32
  28. package/lib/exercises/math/probaStat/events/describeEvent.js +1 -1
  29. package/lib/exercises/math/probaStat/events/eventNotation.js +1 -1
  30. package/lib/exercises/math/probaStat/randomVariable/randomVariableStandardDeviation.js +4 -4
  31. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +1 -1
  32. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.js +1 -1
  33. package/lib/exercises/math/probaStat/stats1var/interquartilesList.js +3 -3
  34. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -1
  35. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +22 -7
  36. package/lib/exercises/math/probaStat/stats1var/median.js +1 -1
  37. package/lib/exercises/math/probaStat/stats1var/medianList.js +1 -1
  38. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +4 -4
  39. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +4 -4
  40. package/lib/exercises/math/probaStat/unionIntersectionProba.js +1 -1
  41. package/lib/exercises/math/python/inOutCalcul.js +1 -1
  42. package/lib/exercises/math/python/index.d.ts +6 -0
  43. package/lib/exercises/math/python/index.d.ts.map +1 -1
  44. package/lib/exercises/math/python/index.js +6 -0
  45. package/lib/exercises/math/python/pythonForLoopInstructionCompletion.d.ts +9 -0
  46. package/lib/exercises/math/python/pythonForLoopInstructionCompletion.d.ts.map +1 -0
  47. package/lib/exercises/math/python/pythonForLoopInstructionCompletion.js +129 -0
  48. package/lib/exercises/math/python/pythonIfStatementCompletion.d.ts +8 -0
  49. package/lib/exercises/math/python/pythonIfStatementCompletion.d.ts.map +1 -0
  50. package/lib/exercises/math/python/pythonIfStatementCompletion.js +114 -0
  51. package/lib/exercises/math/python/pythonRangeCompletion.d.ts +9 -0
  52. package/lib/exercises/math/python/pythonRangeCompletion.d.ts.map +1 -0
  53. package/lib/exercises/math/python/pythonRangeCompletion.js +105 -0
  54. package/lib/exercises/math/python/pythonSimpleFunctionInstructionCompletion.d.ts +8 -0
  55. package/lib/exercises/math/python/pythonSimpleFunctionInstructionCompletion.d.ts.map +1 -0
  56. package/lib/exercises/math/python/pythonSimpleFunctionInstructionCompletion.js +89 -0
  57. package/lib/exercises/math/python/pythonWhileStatementCompletion.d.ts +7 -0
  58. package/lib/exercises/math/python/pythonWhileStatementCompletion.d.ts.map +1 -0
  59. package/lib/exercises/math/python/pythonWhileStatementCompletion.js +87 -0
  60. package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.d.ts +8 -0
  61. package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.d.ts.map +1 -0
  62. package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.js +120 -0
  63. package/lib/exercises/math/sampling/samplingFrequency.js +1 -1
  64. package/lib/index.d.ts +32 -0
  65. package/lib/index.d.ts.map +1 -1
  66. package/package.json +1 -1
@@ -1,69 +1,116 @@
1
- import { addValidProp, shuffleProps, } from "../../../../exercises/exercise.js";
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
- import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
3
+ import { SquareRootConstructor } from "../../../../math/numbers/reals/real.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { sqrt } from "../../../../tree/nodes/functions/sqrtNode.js";
6
6
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
7
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  import { square } from "../../../../tree/nodes/operators/powerNode.js";
9
9
  import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
- import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
- const getPropositions = (n, { answer }) => {
10
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
13
+ const getPropositions = (n, { answer, isEqui, side, base }) => {
12
14
  const propositions = [];
13
15
  addValidProp(propositions, answer);
16
+ tryToAddWrongProp(propositions, frac(side, 2).simplify().toTex());
14
17
  while (propositions.length < n) {
15
- throw Error("QCM not implemented");
18
+ tryToAddWrongProp(propositions, multiply(randint(2, 10), SquareRootConstructor.randomIrreductible().toTree())
19
+ .simplify()
20
+ .toTex());
16
21
  }
17
22
  return shuffleProps(propositions, n);
18
23
  };
19
- const getAnswer = (identifiers) => {
24
+ const getAnswerNode = (identifiers) => {
20
25
  const { isEqui, side, base } = identifiers;
21
26
  if (isEqui) {
22
- return sqrt(multiply(frac(3, 4), square(side)))
23
- .simplify()
24
- .toTex();
27
+ return sqrt(multiply(frac(3, 4), square(side))).simplify();
25
28
  }
26
29
  else {
27
- return sqrt(substract(square(side), frac(square(base), 4)))
28
- .simplify()
29
- .toTex();
30
+ return sqrt(substract(square(side), frac(square(base), 4))).simplify();
30
31
  }
31
32
  };
33
+ const getAnswer = (identifiers) => {
34
+ return getAnswerNode(identifiers).toTex();
35
+ };
32
36
  const getInstruction = (identifiers) => {
33
37
  const { isEqui, side, base } = identifiers;
34
38
  if (isEqui) {
35
39
  return `Le triangle équilatéral ci-dessous a pour côté $${side}$.
36
40
 
37
- Calculer sa hauteur $h$.`;
41
+ Calculer sa hauteur $h$.
42
+
43
+ ![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/mathliveV2/activities/quizzes/generator/triangleEqui.png)
44
+ `;
38
45
  }
39
46
  return `Le triangle isocèle ci-dessous a deux côtés valant $${side}$ et son troisième côté vaut $${base}$.
40
47
 
41
48
  Calculer sa hauteur $h$.`;
42
49
  };
43
50
  const getHint = (identifiers) => {
44
- return ``;
51
+ const { isEqui, side, base } = identifiers;
52
+ if (!isEqui)
53
+ return "";
54
+ return `Dans un triangle équilatéral, les hauteurs sont également les médianes. Le projeté orthogonal de $A$ sur $(BC)$ est donc le milieu de $[BC]$. Tu peux ensuite utiliser un célèbre théorème pour en déduire $h$.`;
45
55
  };
46
56
  const getCorrection = (identifiers) => {
47
- return ``;
48
- };
49
- const getGGBOptions = (identifiers) => {
50
- const ggb = new GeogebraConstructor({
51
- commands: [],
52
- hideAxes: true,
53
- hideGrid: true,
54
- });
55
- return ggb.getOptions({
56
- coords: [-1, 1, -1, 1],
57
- });
57
+ const { isEqui, side, base } = identifiers;
58
+ if (!isEqui)
59
+ return "";
60
+ return `Puisque $ABC$ est un triangle équilatéral, la hauteur issue de $A$ est également la médiane. Le projeté orthogonal de $A$ sur $(BC)$ est donc le milieu de $[BC]$. Appelons $H$ ce point. On a alors $AB = ${side}$, et $AH = ${frac(side, 2)
61
+ .simplify()
62
+ .toTex()}$.
63
+
64
+ ![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/mathliveV2/activities/quizzes/generator/triangleEqui2.png)
65
+
66
+ Le triangle $ABH$ est rectangle en $H$. On peut donc utiliser le théorème de Pythagore pour en déduire $AH$ :
67
+
68
+ $$
69
+ AB^2 = AH^2 + BH^2
70
+ $$
71
+
72
+ donc
73
+
74
+ $$
75
+ AH^2 = AB^2 - BH^2
76
+ $$
77
+
78
+ d'où
79
+
80
+ ${alignTex([
81
+ ["AH^2", "=", substract(square(side), square(frac(side, 2))).toTex()],
82
+ [
83
+ "",
84
+ "=",
85
+ substract(square(side), square(frac(side, 2)))
86
+ .simplify()
87
+ .toTex(),
88
+ ],
89
+ ])}
90
+
91
+ La hauteur $AH$ vaut donc :
92
+
93
+ $$
94
+ AH = ${sqrt(substract(square(side), square(frac(side, 2))).simplify()).toTex()} = ${getAnswer(identifiers)}
95
+ $$`;
58
96
  };
59
97
  const getKeys = (identifiers) => {
60
98
  return [];
61
99
  };
62
100
  const isAnswerValid = (ans, { answer }) => {
63
- throw Error("VEA not implemented");
101
+ try {
102
+ const parsed = parseAlgebraic(ans);
103
+ const ansParsed = parseAlgebraic(answer);
104
+ if (Math.abs(parsed.evaluate() - ansParsed.evaluate()) < 0.01)
105
+ return true;
106
+ return parsed.simplify().toTex() === answer;
107
+ }
108
+ catch (err) {
109
+ return handleVEAError(err);
110
+ }
64
111
  };
65
112
  const getTriangleHeightQuestion = (opts) => {
66
- const isEqui = coinFlip();
113
+ const isEqui = true;
67
114
  const side = randint(1, 11);
68
115
  const base = isEqui ? undefined : randint(1, 11, [side]);
69
116
  const identifiers = {
@@ -82,14 +129,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
82
129
  identifiers,
83
130
  hint: getHint(identifiers),
84
131
  correction: getCorrection(identifiers),
85
- ggbOptions: getGGBOptions(identifiers),
86
132
  };
87
133
  };
88
134
  export const triangleHeight = {
89
135
  id: "triangleHeight",
90
- label: "Calculer la hauteur d'un triangle équilatéral ou isocèle",
136
+ label: "Calculer la hauteur d'un triangle équilatéral",
91
137
  isSingleStep: true,
92
- generator: (nb, opts) => getDistinctQuestions(() => getTriangleHeightQuestion(opts), nb),
138
+ generator: (nb, opts) => getDistinctQuestions(() => getTriangleHeightQuestion(opts), nb, 8),
93
139
  qcmTimer: 60,
94
140
  freeTimer: 60,
95
141
  getPropositions,
@@ -99,7 +145,7 @@ export const triangleHeight = {
99
145
  getCorrection,
100
146
  getInstruction,
101
147
  getAnswer,
102
- getGGBOptions,
103
- hasGeogebra: true,
104
148
  getQuestionFromIdentifiers,
149
+ hasHintAndCorrection: true,
150
+ maxAllowedQuestions: 8,
105
151
  };
@@ -124,7 +124,7 @@ const isAnswerValid = (ans, { answer }) => {
124
124
  };
125
125
  const getDescribeEventQuestion = (ops) => {
126
126
  const allEvents = [
127
- "trouver des mures",
127
+ "trouver des mûres",
128
128
  "trouver des fraises",
129
129
  "trouver des pommes",
130
130
  "perdre son parapluie",
@@ -98,7 +98,7 @@ const isAnswerValid = (ans, { answer }) => {
98
98
  };
99
99
  const getEventNotationQuestion = (ops) => {
100
100
  const allEvents = [
101
- "trouver des mures",
101
+ "trouver des mûres",
102
102
  "trouver des fraises",
103
103
  "trouver des pommes",
104
104
  "perdre son parapluie",
@@ -27,13 +27,13 @@ const getInstruction = (identifiers) => {
27
27
 
28
28
  ${va.getLawTable()}
29
29
 
30
- Que vaut l'écart-type $\\sigma(X)$ de $X$ ?
30
+ Que vaut l'écart type $\\sigma(X)$ de $X$ ?
31
31
 
32
32
  Arrondir au centième.
33
33
  `;
34
34
  };
35
35
  const getHint = (identifiers) => {
36
- return `L'écart-type $\\sigma(X)$ est la racine carrée de la variance $V(X)$.`;
36
+ return `L'écart type $\\sigma(X)$ est la racine carrée de la variance $V(X)$.`;
37
37
  };
38
38
  const getCorrection = (identifiers) => {
39
39
  const { xValuesIds, yValuesIds } = identifiers;
@@ -47,7 +47,7 @@ ${alignTex([
47
47
  ["=", `${variance.simplify().toTex()}`],
48
48
  ])}
49
49
 
50
- L'écart-type $\\sigma(X)$ est la racine carrée de la variance, donc :
50
+ L'écart type $\\sigma(X)$ est la racine carrée de la variance, donc :
51
51
 
52
52
  ${alignTex([
53
53
  ["", "\\sigma(X)"],
@@ -89,7 +89,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
89
89
  export const randomVariableStandardDeviation = {
90
90
  id: "randomVariableStandardDeviation",
91
91
  connector: "=",
92
- label: "Calculer l'écart-type d'une variable aléatoire à partir de sa loi de probabilité",
92
+ label: "Calculer l'écart type d'une variable aléatoire à partir de sa loi de probabilité",
93
93
  isSingleStep: true,
94
94
  generator: (nb, opts) => getDistinctQuestions(() => getRandomVariableStandardDeviationQuestion(opts), nb),
95
95
  qcmTimer: 60,
@@ -38,7 +38,7 @@ ${mdTable([
38
38
  ["Effectif", ...yVals.map((y) => dollarize(y))],
39
39
  ])}
40
40
 
41
- Calculez l'effectif cumulé croissant de la valeur $${xVals[x]}$.
41
+ Calculer l'effectif cumulé croissant de la valeur $${xVals[x]}$.
42
42
  `;
43
43
  };
44
44
  const getHint = (identifiers) => {
@@ -54,7 +54,7 @@ const getHint = (identifiers) => {
54
54
  Les quartiles permettent de découper une série en quatre parties égales :
55
55
 
56
56
  - $Q_1$ (premier quartile) : au moins $25 \\%$ des valeurs sont inférieures ou égales à cette valeur.
57
- - Médiane : au moins $50 \\%$ des valeurs sont inférieures ou égales à cette valeur.
57
+ - Méd (médiane) : au moins $50 \\%$ des valeurs sont inférieures ou égales à cette valeur.
58
58
  - $Q_3$ (troisième quartile) : au moins $75 \\%$ des valeurs sont inférieures ou égales à cette valeur.
59
59
  `;
60
60
  };
@@ -18,7 +18,7 @@ const getAnswer = (identifiers) => {
18
18
  return (thrid - first).frenchify();
19
19
  };
20
20
  const getInstruction = (identifiers) => {
21
- return `Calculer l'écart interquartiles de la série statistique suivante :
21
+ return `Calculer l'écart interquartile de la série statistique suivante :
22
22
 
23
23
  $$
24
24
  ${identifiers.sortedValues.map((e) => e.frenchify()).join("\\ ; \\ ")}
@@ -26,7 +26,7 @@ $$
26
26
  `;
27
27
  };
28
28
  const getHint = (identifiers) => {
29
- return `L'écart interquartiles est la différence entre le troisième quartile et le premier quartile, c'est à dire $Q_3-Q_1$.`;
29
+ return `L'écart interquartile est la différence entre le troisième quartile et le premier quartile, c'est à dire $Q_3-Q_1$.`;
30
30
  };
31
31
  const getCorrection = (identifiers) => {
32
32
  const first = firstQuartile(identifiers.sortedValues);
@@ -77,7 +77,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
77
77
  export const interquartilesList = {
78
78
  id: "interquartilesList",
79
79
  connector: "=",
80
- label: "Calcul de l'écart interquartiles d'une liste de valeurs",
80
+ label: "Calcul de l'écart interquartile d'une liste de valeurs",
81
81
  isSingleStep: true,
82
82
  generator: (nb, opts) => getDistinctQuestions(() => getInterquartilesListQuestion(opts), nb),
83
83
  qcmTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"interquartilesTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/interquartilesTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAmGF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
1
+ {"version":3,"file":"interquartilesTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/interquartilesTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAqHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
@@ -19,7 +19,7 @@ const getAnswer = (identifiers) => {
19
19
  return (thrid - first).frenchify();
20
20
  };
21
21
  const getInstruction = (identifiers) => {
22
- return `Calculer l'écart interquartiles de la série statistique suivante :
22
+ return `Calculer l'écart interquartile de la série statistique suivante :
23
23
 
24
24
  ${mdTable([
25
25
  ["$x_i$", ...identifiers.sortedValues.map((e) => `$${e.frenchify()}$`)],
@@ -28,13 +28,28 @@ ${mdTable([
28
28
  `;
29
29
  };
30
30
  const getHint = (identifiers) => {
31
- return `L'écart interquartiles est la différence entre le troisième quartile et le premier quartile, c'est à dire $Q_3-Q_1$.`;
31
+ return `L'écart interquartile est la différence entre le troisième quartile et le premier quartile, c'est à dire $Q_3-Q_1$.`;
32
32
  };
33
33
  const getCorrection = (identifiers) => {
34
- const first = firstQuartile(identifiers.sortedValues, identifiers.effectifs);
35
- const thrid = thirdQuartile(identifiers.sortedValues, identifiers.effectifs);
36
- const n = identifiers.effectifs.reduce((acc, curr) => acc + curr, 0);
37
- return `Il y a $${n}$ valeurs dans cette liste.
34
+ const { effectifs, sortedValues } = identifiers;
35
+ const first = firstQuartile(sortedValues, effectifs);
36
+ const thrid = thirdQuartile(sortedValues, effectifs);
37
+ const n = effectifs.reduce((acc, curr) => acc + curr, 0);
38
+ return `On dresse le tableau des effectifs cumulés :
39
+
40
+ ${mdTable([
41
+ ["$x_i$", ...sortedValues.map((e) => `$${e.frenchify()}$`)],
42
+ ["$n_i$", ...effectifs.map((e) => `$${e.frenchify()}$`)],
43
+ [
44
+ "ECC",
45
+ ...effectifs.map((e, i) => `$${effectifs
46
+ .slice(0, i + 1)
47
+ .reduce((acc, curr) => acc + curr)
48
+ .frenchify()}$`),
49
+ ],
50
+ ])}
51
+
52
+ Il y a $${n}$ valeurs dans cette liste.
38
53
 
39
54
  Puisque $0,25 \\times ${n} ${approxOrEqual(0.25 * n, 2).join("")}$, le premier quartile est la valeur de rang $${Math.ceil(n / 4)}$. On a donc $Q_1 = ${first}$.
40
55
 
@@ -85,7 +100,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
85
100
  export const interquartilesTable = {
86
101
  id: "interquartilesTable",
87
102
  connector: "=",
88
- label: "Calcul de l'écart interquartiles d'un tableau d'effectifs",
103
+ label: "Calcul de l'écart interquartile d'un tableau d'effectifs",
89
104
  isSingleStep: true,
90
105
  generator: (nb, opts) => getDistinctQuestions(() => getInterquartilesTableQuestion(opts), nb),
91
106
  qcmTimer: 60,
@@ -13,7 +13,7 @@ ${mdTable([
13
13
  ["Effectif", ...randomEffectives.map((e) => dollarize(e))],
14
14
  ])}
15
15
 
16
- Calculer la médiane de cette série de valeurs.`;
16
+ Déterminer la médiane de cette série de valeurs.`;
17
17
  };
18
18
  const getAnswer = (identifiers) => {
19
19
  const { randomEffectives, randomValues } = identifiers;
@@ -10,7 +10,7 @@ $$
10
10
  ${sortedValues.join(";\\ ")}
11
11
  $$
12
12
 
13
- Calculer la médiane de cette liste de valeurs.`;
13
+ Déterminer la médiane de cette liste de valeurs.`;
14
14
  };
15
15
  const getAnswer = (identifiers) => {
16
16
  const { sortedValues } = identifiers;
@@ -23,7 +23,7 @@ const getAnswer = (identifiers) => {
23
23
  return round(sigma, 2).frenchify();
24
24
  };
25
25
  const getInstruction = (identifiers) => {
26
- return `Calculer l'écart-type de la série statistique suivante :
26
+ return `Calculer l'écart type de la série statistique suivante :
27
27
 
28
28
  $$
29
29
  ${identifiers.sortedValues.map((e) => e.frenchify()).join("\\ ; \\ ")}
@@ -38,7 +38,7 @@ $$
38
38
  V = \\frac{(x_1-\\overline{x})^2 + (x_2-\\overline{x})^2 + \\ldots + (x_N-\\overline{x})^2}{N}
39
39
  $$
40
40
 
41
- Puis l'écart-type est la racine carrée de la variance.`;
41
+ Puis l'écart type est la racine carrée de la variance.`;
42
42
  };
43
43
  const getCorrection = (identifiers) => {
44
44
  const n = identifiers.sortedValues.length;
@@ -77,7 +77,7 @@ ${alignTex([
77
77
  ["", ...approxOrEqual(vce, 2)],
78
78
  ])}
79
79
 
80
- L'écart-type est donc :
80
+ L'écart type est donc :
81
81
 
82
82
  $$
83
83
  \\sigma = \\sqrt{V} ${approxOrEqual(sigma, 2).join("")}
@@ -115,7 +115,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
115
115
  export const standardDeviationList = {
116
116
  id: "standardDeviationList",
117
117
  connector: "=",
118
- label: "Calcul de l'écart-type d'une liste de valeurs",
118
+ label: "Calcul de l'écart type d'une liste de valeurs",
119
119
  isSingleStep: true,
120
120
  generator: (nb, opts) => getDistinctQuestions(() => getStandardDeviationListQuestion(opts), nb),
121
121
  qcmTimer: 60,
@@ -24,7 +24,7 @@ const getAnswer = (identifiers) => {
24
24
  return round(sigma, 2).frenchify();
25
25
  };
26
26
  const getInstruction = (identifiers) => {
27
- return `Calculer l'écart-type de la série statistique suivante :
27
+ return `Calculer l'écart type de la série statistique suivante :
28
28
 
29
29
  ${mdTable([
30
30
  ["$x_i$", ...identifiers.sortedValues.map((e) => `$${e.frenchify()}$`)],
@@ -47,7 +47,7 @@ $$
47
47
  V = \\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}
48
48
  $$
49
49
 
50
- Puis l'écart-type est la racine carrée de la variance.`;
50
+ Puis l'écart type est la racine carrée de la variance.`;
51
51
  };
52
52
  const getCorrection = (identifiers) => {
53
53
  const { sortedValues, effectifs } = identifiers;
@@ -87,7 +87,7 @@ ${alignTex([
87
87
  ["", ...approxOrEqual(vce, 2)],
88
88
  ])}
89
89
 
90
- L'écart-type vaut alors :
90
+ L'écart type vaut alors :
91
91
 
92
92
  $$
93
93
  \\sigma = \\sqrt{V} ${approxOrEqual(sigma, 2).join("")}
@@ -131,7 +131,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
131
131
  export const standardDeviationTable = {
132
132
  id: "standardDeviationTable",
133
133
  connector: "=",
134
- label: "Calcul de l'écart-type d'un tableau d'effectifs",
134
+ label: "Calcul de l'écart type d'un tableau d'effectifs",
135
135
  isSingleStep: true,
136
136
  generator: (nb, opts) => getDistinctQuestions(() => getStandardDeviationTableQuestion(opts), nb),
137
137
  qcmTimer: 60,
@@ -147,7 +147,7 @@ const getQuestionFromIdentifiers = (identifiers) => ({
147
147
  });
148
148
  export const unionIntersectionProba = {
149
149
  id: "unionIntersectionProba",
150
- label: "Calculer une probabilité via les formules de lunion et de lintersection",
150
+ label: "Calculer une probabilité via les formules de l'union et de l'intersection",
151
151
  isSingleStep: true,
152
152
  generator: (nb, opts) => getDistinctQuestions(() => getUnionIntersectionProbaQuestion(opts), nb),
153
153
  qcmTimer: 60,
@@ -95,7 +95,7 @@ const isAnswerValid = (ans, { answer }) => {
95
95
  };
96
96
  export const inOutCalcul = {
97
97
  id: "inOutCalcul",
98
- label: "Attribution de variables $1$",
98
+ label: "Attribution de variables $1$ (Python)",
99
99
  isSingleStep: true,
100
100
  generator: (nb) => getDistinctQuestions(getInOutCalculQuestion, nb),
101
101
  qcmTimer: 60,
@@ -12,4 +12,10 @@ export * from "./whileLoopCount.js";
12
12
  export * from "./conditionIfElse.js";
13
13
  export * from "./variableAffectation.js";
14
14
  export * from "./conditionIfElifElse.js";
15
+ export * from "./pythonRangeCompletion.js";
16
+ export * from "./pythonIfStatementCompletion.js";
17
+ export * from "./pythonWhileStatementCompletion.js";
18
+ export * from "./pythonWhileStatementOperationCompletion.js";
19
+ export * from "./pythonForLoopInstructionCompletion.js";
20
+ export * from "./pythonSimpleFunctionInstructionCompletion.js";
15
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC"}
@@ -12,3 +12,9 @@ export * from "./whileLoopCount.js";
12
12
  export * from "./conditionIfElse.js";
13
13
  export * from "./variableAffectation.js";
14
14
  export * from "./conditionIfElifElse.js";
15
+ export * from "./pythonRangeCompletion.js";
16
+ export * from "./pythonIfStatementCompletion.js";
17
+ export * from "./pythonWhileStatementCompletion.js";
18
+ export * from "./pythonWhileStatementOperationCompletion.js";
19
+ export * from "./pythonForLoopInstructionCompletion.js";
20
+ export * from "./pythonSimpleFunctionInstructionCompletion.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeff: number;
4
+ iterations: number;
5
+ operation: string;
6
+ };
7
+ export declare const pythonForLoopInstructionCompletion: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=pythonForLoopInstructionCompletion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pythonForLoopInstructionCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonForLoopInstructionCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4HF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAkBpE,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../math/utils/random/randint.js";
4
+ import { random } from "../../../utils/alea/random.js";
5
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer, coeff, iterations, operation }) => {
7
+ const propositions = [];
8
+ addValidProp(propositions, answer, "raw");
9
+ tryToAddWrongProp(propositions, `\`${operation}${coeff}\``, "raw");
10
+ tryToAddWrongProp(propositions, `\`x${operation}${iterations}\``, "raw");
11
+ tryToAddWrongProp(propositions, `\`${coeff}\``, "raw");
12
+ return shuffleProps(propositions, n);
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ return `a${identifiers.operation}${identifiers.coeff}`;
16
+ };
17
+ const getInstruction = (identifiers) => {
18
+ let word = "";
19
+ const { coeff, iterations, operation } = identifiers;
20
+ switch (operation) {
21
+ case "+":
22
+ word = "l'additionner";
23
+ break;
24
+ case "-":
25
+ word = "le soustraire";
26
+ break;
27
+ case "*":
28
+ word = "le multiplier";
29
+ break;
30
+ case "/":
31
+ default:
32
+ word = "le diviser";
33
+ break;
34
+ }
35
+ return `On considère la fonction en Python suivante. Cette fonction doit permettre, pour un paramètre \`a\` saisi en entrée, de ${word} à $${iterations}$ reprises par $${coeff}$, puis de renvoyer le résultat du calcul.
36
+
37
+ Par quoi faut-il remplacer les trois points ?
38
+
39
+ \`\`\`
40
+ def boucle(a):
41
+ for num in range(${iterations}):
42
+ a=...
43
+ return a
44
+ \`\`\`
45
+ `;
46
+ };
47
+ const getHint = (identifiers) => {
48
+ const { coeff, operation } = identifiers;
49
+ const fakeCoeff = randint(2, 10, [coeff]);
50
+ const fakeOperation = random(["+", "-", "*", "/"], [operation]);
51
+ const word = fakeOperation === "/"
52
+ ? "diviser"
53
+ : fakeOperation === "+"
54
+ ? "additionner"
55
+ : fakeOperation === "-"
56
+ ? "soustraire"
57
+ : "multiplier";
58
+ return `Sers-toi de cet exemple : en Python, si l'on veut ${word} une variable \`x\` par $${fakeCoeff}$, on écrit :
59
+
60
+ \`\`\`
61
+ x = x${fakeOperation}${fakeCoeff}
62
+ \`\`\``;
63
+ };
64
+ const getCorrection = (identifiers) => {
65
+ const { coeff, iterations, operation } = identifiers;
66
+ const word = operation === "/"
67
+ ? "diviser"
68
+ : operation === "+"
69
+ ? "additionner"
70
+ : operation === "-"
71
+ ? "soustraire"
72
+ : "multiplier";
73
+ return `On veut ${word} \`a\` par $${coeff}$ à chaque exécution de la boucle \`for\`. En python, cela se traduit par :
74
+
75
+ \`\`\`
76
+ a=a${operation}${coeff}
77
+ \`\`\``;
78
+ };
79
+ const getKeys = (identifiers) => {
80
+ return [];
81
+ };
82
+ const isAnswerValid = (ans, { answer }) => {
83
+ try {
84
+ return ans === answer;
85
+ }
86
+ catch (err) {
87
+ return handleVEAError(err);
88
+ }
89
+ };
90
+ const getPythonRangeCompletionQuestion = (ops) => {
91
+ const iterations = randint(2, 11);
92
+ const operation = random(["+", "-", "*", "/"]);
93
+ const coeff = randint(2, 11);
94
+ const identifiers = {
95
+ coeff,
96
+ iterations,
97
+ operation,
98
+ };
99
+ return getQuestionFromIdentifiers(identifiers);
100
+ };
101
+ const getQuestionFromIdentifiers = (identifiers) => {
102
+ return {
103
+ answer: getAnswer(identifiers),
104
+ instruction: getInstruction(identifiers),
105
+ keys: getKeys(identifiers),
106
+ answerFormat: "raw",
107
+ identifiers,
108
+ hint: getHint(identifiers),
109
+ correction: getCorrection(identifiers),
110
+ };
111
+ };
112
+ export const pythonForLoopInstructionCompletion = {
113
+ id: "pythonForLoopInstructionCompletion",
114
+ label: "Compléter une instruction dans une boucle `for` en Python",
115
+ isSingleStep: true,
116
+ generator: (nb, opts) => getDistinctQuestions(() => getPythonRangeCompletionQuestion(opts), nb),
117
+ qcmTimer: 60,
118
+ freeTimer: 60,
119
+ getPropositions,
120
+ isAnswerValid,
121
+ subject: "Mathématiques",
122
+ getInstruction,
123
+ getHint,
124
+ getCorrection,
125
+ getAnswer,
126
+ getQuestionFromIdentifiers,
127
+ hasHintAndCorrection: true,
128
+ answerType: "QCU",
129
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ ineq: string;
4
+ coeff: number;
5
+ };
6
+ export declare const pythonIfStatementCompletion: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=pythonIfStatementCompletion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pythonIfStatementCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonIfStatementCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA8GF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAqB7D,CAAC"}