math-exercises 3.0.130 → 3.0.132

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 (100) hide show
  1. package/lib/exercises/exercise.d.ts +37 -30
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts +3 -3
  4. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +48 -44
  6. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts +1 -1
  7. package/lib/exercises/math/calcul/ordering/compareA10N.js +3 -3
  8. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.js +0 -1
  10. package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts +1 -1
  11. package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +1 -1
  12. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +1 -1
  13. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  14. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +2 -0
  15. package/lib/exercises/math/calcul/rounding/rounding.d.ts +1 -1
  16. package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
  17. package/lib/exercises/math/calcul/rounding/rounding.js +7 -6
  18. package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.d.ts.map +1 -1
  19. package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.js +15 -11
  20. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.js +6 -5
  22. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +0 -1
  23. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
  24. package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -1
  25. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts.map +1 -1
  26. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.js +15 -60
  27. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.js +14 -10
  28. package/lib/exercises/math/conversion/lengthConversion.d.ts.map +1 -1
  29. package/lib/exercises/math/conversion/lengthConversion.js +1 -0
  30. package/lib/exercises/math/conversion/prefixToNumber.d.ts.map +1 -1
  31. package/lib/exercises/math/conversion/prefixToNumber.js +10 -8
  32. package/lib/exercises/math/conversion/secondsToHours.js +1 -1
  33. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.js +2 -1
  35. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts +1 -1
  36. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.js +4 -5
  38. package/lib/exercises/math/functions/affines/leadingCoefficient.js +1 -1
  39. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts +1 -1
  40. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -1
  41. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +10 -11
  42. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts +1 -1
  43. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts.map +1 -1
  44. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.js +8 -8
  45. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +2 -2
  46. package/lib/exercises/math/percent/evolutions/evolutionRateFromValues.d.ts.map +1 -1
  47. package/lib/exercises/math/percent/evolutions/evolutionRateFromValues.js +29 -16
  48. package/lib/exercises/math/percent/evolutions/globalPercent.d.ts +4 -1
  49. package/lib/exercises/math/percent/evolutions/globalPercent.d.ts.map +1 -1
  50. package/lib/exercises/math/percent/evolutions/globalPercent.js +37 -21
  51. package/lib/exercises/math/percent/findProportion.d.ts +1 -5
  52. package/lib/exercises/math/percent/findProportion.d.ts.map +1 -1
  53. package/lib/exercises/math/percent/findProportion.js +67 -75
  54. package/lib/exercises/math/percent/percentToDecimal.d.ts +4 -1
  55. package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
  56. package/lib/exercises/math/percent/percentToDecimal.js +55 -35
  57. package/lib/exercises/math/powers/calculateNegativePower.d.ts +1 -1
  58. package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
  59. package/lib/exercises/math/powers/calculateNegativePower.js +17 -10
  60. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.d.ts +5 -1
  61. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.d.ts.map +1 -1
  62. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.js +76 -12
  63. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.js +1 -1
  64. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts +3 -3
  65. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts.map +1 -1
  66. package/lib/exercises/math/probaStat/probaAsSumOfProbas.js +17 -45
  67. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +12 -5
  68. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  69. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +354 -94
  70. package/lib/exercises/math/probaStat/randomVariable/randomVariableAverage.js +1 -1
  71. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts +4 -1
  72. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
  73. package/lib/exercises/math/probaStat/stats1var/medianWithList.js +43 -23
  74. package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts +1 -1
  75. package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts.map +1 -1
  76. package/lib/exercises/math/probaStat/stats1var/quartilesList.js +4 -4
  77. package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
  78. package/lib/exercises/pc/motion/averageSpeed.js +13 -10
  79. package/lib/exercises/pc/optics/lensFormula.d.ts +1 -2
  80. package/lib/exercises/pc/optics/lensFormula.d.ts.map +1 -1
  81. package/lib/exercises/pc/optics/lensFormula.js +7 -10
  82. package/lib/exercises/pc/weight/calculateWeight.d.ts +1 -2
  83. package/lib/exercises/pc/weight/calculateWeight.d.ts.map +1 -1
  84. package/lib/exercises/pc/weight/calculateWeight.js +15 -14
  85. package/lib/exercises/vea/isNodesEqual.d.ts +3 -0
  86. package/lib/exercises/vea/isNodesEqual.d.ts.map +1 -0
  87. package/lib/exercises/vea/isNodesEqual.js +6 -0
  88. package/lib/exercises/vea/setVEA.d.ts +5 -0
  89. package/lib/exercises/vea/setVEA.d.ts.map +1 -0
  90. package/lib/exercises/vea/setVEA.js +25 -0
  91. package/lib/index.d.ts +932 -934
  92. package/lib/index.d.ts.map +1 -1
  93. package/lib/math/progCalc/progCalc.d.ts +2 -2
  94. package/lib/math/progCalc/progCalc.d.ts.map +1 -1
  95. package/lib/math/progCalc/progCalc.js +4 -11
  96. package/lib/tests/exoTest.d.ts.map +1 -1
  97. package/lib/tests/exoTest.js +13 -0
  98. package/lib/types/keyIds.d.ts +1 -1
  99. package/lib/types/keyIds.d.ts.map +1 -1
  100. package/package.json +1 -1
@@ -4,9 +4,11 @@ import { randfloat } from "../../../../math/utils/random/randfloat.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { round } from "../../../../math/utils/round.js";
6
6
  import { percentParser } from "../../../../tree/parsers/percentParser.js";
7
+ import { valueParser } from "../../../../tree/parsers/valueParser.js";
7
8
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
8
9
  import { doWhile } from "../../../../utils/doWhile.js";
9
10
  import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
10
12
  const getPropositions = (n, { answer, vd, vf }) => {
11
13
  const propositions = [];
12
14
  addValidProp(propositions, answer);
@@ -25,42 +27,53 @@ const getAnswer = (identifiers) => {
25
27
  return taux.frenchify() + "\\%";
26
28
  };
27
29
  const getInstruction = (identifiers) => {
28
- return `Un prix passe de $${identifiers.vd.frenchify()}€$ à $${identifiers.vf.frenchify()}€$. Quel est le taux d'évolution du prix, en pourcentage ? Arrondir au centième de pourcentage.`;
30
+ return `Un prix passe de $${identifiers.vd.frenchify()}€$ à $${identifiers.vf.frenchify()}€$. Quel est le taux d'évolution du prix ? Arrondir au centième de pourcent.`;
29
31
  };
30
32
  const getHint = () => {
31
- return `Si une valeur passe d'une valeur de départ $V_d$ à une valeur d'arrivée $V_a$, alors le taux d'évolution $t$ en pourcentage est donné par la formule :
33
+ return `Si une valeur passe d'une valeur de départ $V_d$ à une valeur d'arrivée $V_a$, alors le taux d'évolution $t$ est donné par la formule :
32
34
 
33
35
  $$
34
- t = \\frac{V_a-V_d}{V_d}\\times 100
36
+ t = \\frac{V_a-V_d}{V_d}
35
37
  $$`;
36
38
  };
37
39
  const getCorrection = (identifiers) => {
38
- const answer = round(((identifiers.vf - identifiers.vd) / identifiers.vd) * 100, 2).frenchify();
39
- return `Si une valeur passe d'une valeur de départ $V_d$ à une valeur d'arrivée $V_a$, alors le taux d'évolution $t$ en pourcentage est donné par la formule :
40
+ const { vd, vf } = identifiers;
41
+ const percentAnswer = round(((identifiers.vf - identifiers.vd) / identifiers.vd) * 100, 2).frenchify();
42
+ return `Si une valeur passe d'une valeur de départ $V_d$ à une valeur d'arrivée $V_a$, alors le taux d'évolution $t$ est donné par la formule :
40
43
 
41
44
  $$
42
- t = \\frac{V_a-V_d}{V_d}\\times 100
45
+ t = \\frac{V_a-V_d}{V_d}
43
46
  $$
44
47
 
45
- Ici, on a $V_d = ${identifiers.vd.frenchify()}$ et $V_a = ${identifiers.vf.frenchify()}$.
48
+ Ici, on a $V_d = ${vd.frenchify()}$ et $V_a = ${vf.frenchify()}$.
46
49
 
47
- Donc, le taux d'évolution, en pourcentage, est :
50
+ Donc, le taux d'évolution est :
48
51
 
49
52
  ${alignTex([
50
- [
51
- "t",
52
- "=",
53
- `\\frac{${identifiers.vf.frenchify()}-${identifiers.vd.frenchify()}}{${identifiers.vd.frenchify()}}\\times 100`,
54
- ],
55
- ["", "\\approx", answer],
53
+ ["t", "=", `\\frac{${vf.frenchify()}-${vd.frenchify()}}{${vd.frenchify()}}`],
54
+ ["", "=", `\\frac{${round(vf - vd, 4).frenchify()}}{${vd.frenchify()}}`],
55
+ ["", ...approxOrEqual((vf - vd) / vd, 4)],
56
56
  ])}
57
+
58
+ Sous forme de pourcentage, le taux d'évolution est donc :
59
+
60
+ $$
61
+ ${percentAnswer}\\%
62
+ $$
57
63
  `;
58
64
  };
59
65
  const getKeys = () => {
60
66
  return ["percent"];
61
67
  };
62
- const isAnswerValid = (ans, { answer }) => {
63
- return percentParser(ans) === answer;
68
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
69
+ if (ans.includes("\\%")) {
70
+ const value = percentParser(ans);
71
+ return value === answer;
72
+ }
73
+ const refinedAns = ans.replaceAll("\\%", ``);
74
+ const nodeAns = valueParser(refinedAns);
75
+ const nodeAnswer = round((identifiers.vf - identifiers.vd) / identifiers.vd, 4);
76
+ return nodeAns === nodeAnswer;
64
77
  };
65
78
  const getEvolutionRateFromValuesQuestion = () => {
66
79
  const vd = coinFlip() ? randint(1, 100) : randfloat(1, 100, 2);
@@ -2,6 +2,9 @@ import { Exercise } from "../../../exercise.js";
2
2
  type Identifiers = {
3
3
  evolutions: string[];
4
4
  };
5
- export declare const globalPercent: Exercise<Identifiers>;
5
+ type Options = {
6
+ nbEvos: string;
7
+ };
8
+ export declare const globalPercent: Exercise<Identifiers, Options>;
6
9
  export {};
7
10
  //# sourceMappingURL=globalPercent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"globalPercent.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/globalPercent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAcT,MAAM,sBAAsB,CAAC;AAM9B,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA4GF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAe/C,CAAC"}
1
+ {"version":3,"file":"globalPercent.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/globalPercent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAiBT,MAAM,sBAAsB,CAAC;AAM9B,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAmHF,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAgBF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBxD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { randint } from "../../../../math/utils/random/randint.js";
2
- import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercise.js";
2
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercise.js";
3
3
  import { getDistinctQuestions } from "../../../utils/getDistinctQuestions.js";
4
4
  import { shuffle } from "../../../../utils/alea/shuffle.js";
5
5
  import { round } from "../../../../math/utils/round.js";
@@ -48,8 +48,26 @@ $$
48
48
  Le taux d'évolution global est donc de $${answer}$.
49
49
  `;
50
50
  };
51
- const getGlobalPercentQuestion = () => {
52
- const indice = randint(2, 4);
51
+ const getPropositions = (n, { answer }) => {
52
+ const propositions = [];
53
+ addValidProp(propositions, answer);
54
+ propWhile(propositions, n, () => {
55
+ let wrongAnswer = Number(answer.replace(",", ".").replace(`\\%`, ""));
56
+ const deviation = Math.random() < 0.5 ? -1 : 1;
57
+ const percentDeviation = Math.random() * 20 + 1;
58
+ wrongAnswer += deviation * percentDeviation;
59
+ wrongAnswer = round(wrongAnswer, 2);
60
+ tryToAddWrongProp(propositions, `${(wrongAnswer + "").replace(".", ",")} \\%`);
61
+ });
62
+ return shuffle(propositions);
63
+ };
64
+ const isAnswerValid = (ans, { answer }) => {
65
+ const parsed = percentParser(ans);
66
+ return parsed === answer.replace("+", "");
67
+ };
68
+ const getGlobalPercentQuestion = (optsIn) => {
69
+ const opts = optsIn ?? optsDefault;
70
+ const indice = Number(opts.nbEvos);
53
71
  const evolutions = [];
54
72
  for (let i = 0; i < indice; i++) {
55
73
  const randPercent = randint(1, 50);
@@ -59,7 +77,7 @@ const getGlobalPercentQuestion = () => {
59
77
  const identifiers = { evolutions };
60
78
  return getQuestionFromIdentifiers(identifiers);
61
79
  };
62
- const getQuestionFromIdentifiers = (identifiers) => {
80
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
63
81
  const question = {
64
82
  instruction: getInstruction(identifiers),
65
83
  answer: getAnswer(identifiers),
@@ -68,32 +86,30 @@ const getQuestionFromIdentifiers = (identifiers) => {
68
86
  identifiers,
69
87
  hint: getHint(identifiers),
70
88
  correction: getCorrection(identifiers),
89
+ options: opts,
71
90
  };
72
91
  return question;
73
92
  };
74
- const getPropositions = (n, { answer }) => {
75
- const propositions = [];
76
- addValidProp(propositions, answer);
77
- propWhile(propositions, n, () => {
78
- let wrongAnswer = Number(answer.replace(",", ".").replace(`\\%`, ""));
79
- const deviation = Math.random() < 0.5 ? -1 : 1;
80
- const percentDeviation = Math.random() * 20 + 1;
81
- wrongAnswer += deviation * percentDeviation;
82
- wrongAnswer = round(wrongAnswer, 2);
83
- tryToAddWrongProp(propositions, `${(wrongAnswer + "").replace(".", ",")} \\%`);
84
- });
85
- return shuffle(propositions);
86
- };
87
- const isAnswerValid = (ans, { answer }) => {
88
- const parsed = percentParser(ans);
89
- return parsed === answer.replace("+", "");
93
+ const optsDefault = {
94
+ nbEvos: "2",
90
95
  };
96
+ const options = [
97
+ {
98
+ id: "nbEvos",
99
+ label: "Nombre d'évolutions successives",
100
+ target: GeneratorOptionTarget.generation,
101
+ type: GeneratorOptionType.select,
102
+ values: ["2", "3", "4"],
103
+ defaultValue: optsDefault.nbEvos,
104
+ },
105
+ ];
91
106
  export const globalPercent = {
92
107
  id: "globalPercent",
93
108
  connector: "=",
94
109
  label: "Calculer un taux d'évolution global à partir de taux d'évolution successifs",
95
110
  isSingleStep: false,
96
- generator: (nb) => getDistinctQuestions(getGlobalPercentQuestion, nb),
111
+ generator: (nb, opts) => getDistinctQuestions(() => getGlobalPercentQuestion(opts), nb),
112
+ options,
97
113
  qcmTimer: 60,
98
114
  freeTimer: 60,
99
115
  getPropositions,
@@ -3,11 +3,7 @@ type Identifiers = {
3
3
  indexSituation: number;
4
4
  total: number;
5
5
  lefties: number;
6
- opts: Options;
7
6
  };
8
- type Options = {
9
- isPercentSymbolRequired: boolean;
10
- };
11
- export declare const findProportion: Exercise<Identifiers, Options>;
7
+ export declare const findProportion: Exercise<Identifiers>;
12
8
  export {};
13
9
  //# sourceMappingURL=findProportion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"findProportion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/findProportion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAwNF,KAAK,OAAO,GAAG;IACb,uBAAuB,EAAE,OAAO,CAAC;CAClC,CAAC;AAeF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBzD,CAAC"}
1
+ {"version":3,"file":"findProportion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/findProportion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA4NF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAehD,CAAC"}
@@ -1,26 +1,29 @@
1
- import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
1
+ import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randfloat } from "../../../math/utils/random/randfloat.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { round } from "../../../math/utils/round.js";
6
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
7
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
8
+ import { substract } from "../../../tree/nodes/operators/substractNode.js";
6
9
  import { percentParser } from "../../../tree/parsers/percentParser.js";
10
+ import { valueParser } from "../../../tree/parsers/valueParser.js";
7
11
  import { random } from "../../../utils/alea/random.js";
8
12
  import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
9
- import { approxOrEqual } from "../../../utils/latex/approxOrEqual.js";
10
13
  const situations = [
11
14
  {
12
15
  instruction: (total, lefties) => `${random([
13
16
  `Dans un lycée de $${total}$ élèves, $${lefties}$ sont gauchers.`,
14
17
  `Dans un lycée, $${lefties}$ élèves sont gauchers sur un total de $${total}$ élèves.`,
15
18
  ])}
16
- Quelle est la proportion de gauchers dans ce lycée, en pourcentage ?`,
17
- hint: `La proportion de gauchers en pourcents s'obtient par la formule :
19
+ Quelle est la proportion de gauchers dans ce lycée ?`,
20
+ hint: `La proportion de gauchers s'obtient par la formule :
18
21
 
19
22
  $$
20
- \\frac{\\text{nombre de gauchers}}{\\text{nombre total d'élèves}}\\times 100
23
+ \\frac{\\text{nombre de gauchers}}{\\text{nombre total d'élèves}}
21
24
  $$
22
25
  `,
23
- correction: `La proportion de gauchers en pourcentage dans ce lycée est de`,
26
+ correction: `La proportion de gauchers dans ce lycée est de`,
24
27
  randTotal: () => randint(500, 2000),
25
28
  },
26
29
  {
@@ -28,14 +31,14 @@ $$
28
31
  `Dans une casse automobile, il y a $${total}$ voitures dont $${lefties}$ ont le volant à gauche.`,
29
32
  `Dans une casse automobile, $${lefties}$ voitures ont le volant à gauche. Il y a au total $${total}$ voitures.`,
30
33
  ])}
31
- Quelle est la proportion de voitures avec le volant à gauche dans cette casse, en pourcentage ?`,
32
- hint: `La proportion, en pourcents, de voitures avec le volant à gauche s'obtient par la formule :
34
+ Quelle est la proportion de voitures avec le volant à gauche dans cette casse ?`,
35
+ hint: `La proportion de voitures avec le volant à gauche s'obtient par la formule :
33
36
 
34
37
  $$
35
- \\frac{\\text{nombre de voitures avec volant à gauche}}{\\text{nombre total de voitures}}\\times 100
38
+ \\frac{\\text{nombre de voitures avec volant à gauche}}{\\text{nombre total de voitures}}
36
39
  $$
37
40
  `,
38
- correction: `La proportion, en pourcentage, de voitures avec le volant à gauche est de`,
41
+ correction: `La proportion de voitures avec le volant à gauche est de`,
39
42
  randTotal: () => randint(100, 500),
40
43
  },
41
44
  {
@@ -43,14 +46,14 @@ $$
43
46
  `Dans un restaurant italien, sur un total de $${total}$ clients, $${lefties}$ ont commandé des pâtes.`,
44
47
  `Dans un restaurant italien, $${lefties}$ clients ont commandé des pâtes. Il y a au total $${total}$ clients.`,
45
48
  ])}
46
- Quelle est la proportion de clients qui ont commandé des pâtes, en pourcentage ?`,
47
- hint: `La proportion en pourcents de clients qui ont commandé des pâtes s'obtient par la formule :
49
+ Quelle est la proportion de clients qui ont commandé des pâtes ?`,
50
+ hint: `La proportion de clients qui ont commandé des pâtes s'obtient par la formule :
48
51
 
49
52
  $$
50
- \\frac{\\text{nombre de clients ayant commandé des pâtes}}{\\text{nombre total de clients}}\\times 100
53
+ \\frac{\\text{nombre de clients ayant commandé des pâtes}}{\\text{nombre total de clients}}
51
54
  $$
52
55
  `,
53
- correction: `La proportion en pourcentage de clients ayant commandé des pâtes est de`,
56
+ correction: `La proportion de clients ayant commandé des pâtes est de`,
54
57
  randTotal: () => randint(30, 200),
55
58
  },
56
59
  {
@@ -58,14 +61,14 @@ $$
58
61
  `Dans une cagette de $${total}$ pommes, $${lefties}$ sont véreuses.`,
59
62
  `Dans une cagette de pommes, $${lefties}$ sont véreuses. Il y a au total $${total}$ pommes.`,
60
63
  ])}
61
- Quelle est la proportion de pommes véreuses dans la cagette, en pourcentage ?`,
62
- hint: `La proportion, en pourcents, de pommes véreuses s'obtient par la formule :
64
+ Quelle est la proportion de pommes véreuses dans la cagette ?`,
65
+ hint: `La proportion de pommes véreuses s'obtient par la formule :
63
66
 
64
67
  $$
65
- \\frac{\\text{nombre de pommes véreuses}}{\\text{nombre total de pommes}}\\times 100
68
+ \\frac{\\text{nombre de pommes véreuses}}{\\text{nombre total de pommes}}
66
69
  $$
67
70
  `,
68
- correction: `La proportion, en pourcentage, de pommes véreuses est de`,
71
+ correction: `La proportion de pommes véreuses est de`,
69
72
  randTotal: () => randint(30, 100),
70
73
  },
71
74
  {
@@ -73,14 +76,14 @@ $$
73
76
  `Dans un car scolaire transportant $${total}$ élèves, $${lefties}$ sont du côté gauche.`,
74
77
  `Dans un car scolaire, $${lefties}$ élèves sont du côté gauche. Le car transporte $${total}$ élèves.`,
75
78
  ])}
76
- Quelle est la proportion d'élèves du côté gauche du car, en pourcentage ?`,
77
- hint: `La proportion en pourcents d'élèves du gauche du car s'obtient par la formule :
79
+ Quelle est la proportion d'élèves du côté gauche du car ?`,
80
+ hint: `La proportion d'élèves du gauche du car s'obtient par la formule :
78
81
 
79
82
  $$
80
- \\frac{\\text{nombre d'élèves du côté gauche}}{\\text{nombre d'élèves dans le car}}\\times 100
83
+ \\frac{\\text{nombre d'élèves du côté gauche}}{\\text{nombre d'élèves dans le car}}
81
84
  $$
82
85
  `,
83
- correction: `La proportion en pourcentage d'élèves du côté gauche est de`,
86
+ correction: `La proportion d'élèves du côté gauche est de`,
84
87
  randTotal: () => randint(20, 40),
85
88
  },
86
89
  {
@@ -88,54 +91,56 @@ $$
88
91
  `Dans un champ, au mois de septembre, sur $${total}$ champignons, $${lefties}$ sont vénéneux.`,
89
92
  `Dans un champ, au mois de septembre, $${lefties}$ champignons sont vénéneux sur un total de $${total}$ champignons.`,
90
93
  ])}
91
- Quelle est la proportion de champignons vénéneux dans ce champ, en pourcentage ?`,
92
- hint: `La proportion de champignons vénéneux dans ce champ, en pourcents, s'obtient par la formule :
94
+ Quelle est la proportion de champignons vénéneux dans ce champ ?`,
95
+ hint: `La proportion de champignons vénéneux dans ce champ s'obtient par la formule :
93
96
 
94
97
  $$
95
- \\frac{\\text{nombre de champignons vénéneux}}{\\text{nombre total de champignons}}\\times 100
98
+ \\frac{\\text{nombre de champignons vénéneux}}{\\text{nombre total de champignons}}
96
99
  $$
97
100
  `,
98
- correction: `La proportion en pourcentage de champignons vénéneux dans ce champ est de`,
101
+ correction: `La proportion de champignons vénéneux dans ce champ est de`,
99
102
  randTotal: () => randint(20, 400),
100
103
  },
101
104
  ];
102
105
  const getInstruction = (identifiers) => {
103
- const { indexSituation, total, lefties, opts } = identifiers;
106
+ const { indexSituation, total, lefties } = identifiers;
104
107
  const situation = situations[indexSituation];
105
108
  return `${situation.instruction(total, lefties)}
106
109
 
107
- Arrondir au centième de pourcent.
108
- ${opts.isPercentSymbolRequired
109
- ? `
110
-
111
- Ne pas oublier le symbole $\\%$ à la fin.`
112
- : ``}`;
110
+ Arrondir au centième de pourcent.`;
113
111
  };
114
112
  const getHint = (identifiers) => {
115
113
  const { indexSituation } = identifiers;
116
114
  const situation = situations[indexSituation];
117
- return situation.hint;
115
+ return `${situation.hint}
116
+
117
+ Pour transformer un nombre décimal en pourcentage, on le multiplie par $100$. Par exemple,
118
+
119
+ $$
120
+ 0,345 = 34,5\\%
121
+ $$
122
+
123
+ `;
118
124
  };
119
125
  const getCorrection = (identifiers) => {
120
- const { indexSituation, total, lefties, opts } = identifiers;
126
+ const { indexSituation, total, lefties } = identifiers;
121
127
  const situation = situations[indexSituation];
122
- const frac = (100 * lefties) / total;
128
+ const fractionNode = frac(lefties, total);
129
+ const roundedProportion = round(frac(lefties, total).evaluate(), 4);
130
+ const isEqual = substract(frac(lefties, total), round(frac(lefties, total).evaluate(), 4).toTree()).evaluate() === 0;
131
+ const middleSymbol = isEqual ? "=" : "\\approx";
123
132
  return `On a :
124
133
 
125
134
  $$
126
- \\frac{${lefties}}{${total}}\\times 100 ${approxOrEqual(frac, 2).join("")}
135
+ ${fractionNode.toTex()} ${middleSymbol} ${roundedProportion.frenchify()}
127
136
  $$
128
137
 
129
- ${situation.correction} $${getAnswer(identifiers)}$.
130
- ${opts.isPercentSymbolRequired
131
- ? `
132
-
133
- Attention, ici le symbole "$\\%$" est requis à la fin.`
134
- : ``}`;
138
+ ${situation.correction} $${getAnswer(identifiers)}$.`;
135
139
  };
136
140
  const getAnswer = (identifiers) => {
137
141
  const { total, lefties } = identifiers;
138
- const answer = round((lefties / total) * 100, 2).frenchify() + "\\%";
142
+ const answer = round(multiply(frac(lefties, total), 100).evaluate(), 2).frenchify() +
143
+ "\\%";
139
144
  return answer;
140
145
  };
141
146
  const getPropositions = (n, { answer, total, lefties }) => {
@@ -147,34 +152,36 @@ const getPropositions = (n, { answer, total, lefties }) => {
147
152
  });
148
153
  return shuffleProps(propositions, n);
149
154
  };
150
- const isAnswerValid = (ans, { answer, opts }) => {
155
+ const isAnswerValid = (ans, { answer, lefties, total }) => {
151
156
  try {
152
- if (opts.isPercentSymbolRequired) {
153
- if (!ans.includes("\\%")) {
154
- return false;
155
- }
156
- else {
157
- return percentParser(ans) === answer;
158
- }
157
+ if (ans.includes("\\%")) {
158
+ const parsed = percentParser(ans);
159
+ return parsed === answer;
159
160
  }
160
161
  else {
161
- const texs = [answer, answer.replace("\\%", "")];
162
- return texs.includes(ans);
162
+ const answerValue = round(lefties / total, 4);
163
+ const studentAns = valueParser(ans);
164
+ if (!studentAns)
165
+ return false;
166
+ return answerValue === studentAns;
163
167
  }
164
168
  }
165
169
  catch (err) {
166
170
  return handleVEAError(err);
167
171
  }
168
172
  };
169
- const getFindProportionQuestion = (optsIn) => {
170
- const opts = optsIn ?? optsDefault;
173
+ const getFindProportionQuestion = () => {
171
174
  const indexSituation = randint(0, situations.length);
172
175
  const situation = situations[indexSituation];
173
176
  const total = situation.randTotal();
174
177
  const lefties = round(randfloat(0.1, 0.9) * total, 0);
175
- return getQuestionFromIdentifiers({ indexSituation, total, lefties, opts });
178
+ return getQuestionFromIdentifiers({
179
+ indexSituation,
180
+ total,
181
+ lefties,
182
+ });
176
183
  };
177
- const getQuestionFromIdentifiers = (identifiers, opts) => {
184
+ const getQuestionFromIdentifiers = (identifiers) => {
178
185
  const question = {
179
186
  answer: getAnswer(identifiers),
180
187
  instruction: getInstruction(identifiers),
@@ -183,30 +190,15 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
183
190
  identifiers,
184
191
  hint: getHint(identifiers),
185
192
  correction: getCorrection(identifiers),
186
- options: opts,
187
193
  };
188
194
  return question;
189
195
  };
190
- const optsDefault = {
191
- isPercentSymbolRequired: false,
192
- };
193
- const options = [
194
- {
195
- id: "isPercentSymbolRequired",
196
- label: "Symbole pourcent requis",
197
- target: GeneratorOptionTarget.generation,
198
- type: GeneratorOptionType.checkbox,
199
- values: [false, true],
200
- defaultValue: optsDefault.isPercentSymbolRequired,
201
- },
202
- ];
203
196
  export const findProportion = {
204
197
  id: "findProportion",
205
198
  connector: "=",
206
- label: "Calculer une proportion en pourcentage",
199
+ label: "Calculer une proportion",
207
200
  isSingleStep: true,
208
- generator: (nb, opts) => getDistinctQuestions(() => getFindProportionQuestion(opts), nb),
209
- options,
201
+ generator: (nb) => getDistinctQuestions(getFindProportionQuestion, nb),
210
202
  qcmTimer: 60,
211
203
  freeTimer: 60,
212
204
  getPropositions,
@@ -3,6 +3,9 @@ type Identifiers = {
3
3
  isPercentToDecimal: boolean;
4
4
  nb: number;
5
5
  };
6
- export declare const percentToDecimal: Exercise<Identifiers>;
6
+ type Options = {
7
+ conversionType: string;
8
+ };
9
+ export declare const percentToDecimal: Exercise<Identifiers, Options>;
7
10
  export {};
8
11
  //# sourceMappingURL=percentToDecimal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"percentToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/percentToDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA8IF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"percentToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/percentToDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4JF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAsBF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAe3D,CAAC"}
@@ -1,4 +1,4 @@
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 { Decimal, DecimalConstructor, } from "../../../math/numbers/decimals/decimal.js";
4
4
  import { Integer, IntegerConstructor, } from "../../../math/numbers/integer/integer.js";
@@ -7,6 +7,7 @@ import { round } from "../../../math/utils/round.js";
7
7
  import { numberParser } from "../../../tree/parsers/numberParser.js";
8
8
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
9
9
  import { probaFlip } from "../../../utils/alea/probaFlip.js";
10
+ import { random } from "../../../utils/alea/random.js";
10
11
  const getAnswer = ({ nb, isPercentToDecimal }) => {
11
12
  const dec = new Decimal(nb);
12
13
  const tex = dec.toTree().toTex();
@@ -48,39 +49,6 @@ En effet, on a bien $${answer} = \\frac{${answer.replace("\\%", "")}}{100} = ${n
48
49
  const getKeys = () => {
49
50
  return ["percent"];
50
51
  };
51
- const getPercentToDecimalQuestion = () => {
52
- const isPercentToDecimal = coinFlip();
53
- const isNatural = coinFlip();
54
- const percentNb = probaFlip(0.3)
55
- ? isNatural
56
- ? new Integer(IntegerConstructor.random(1, [0]))
57
- : DecimalConstructor.random(0, 10)
58
- : coinFlip()
59
- ? isNatural
60
- ? new Integer(IntegerConstructor.random(2))
61
- : DecimalConstructor.random(10, 100)
62
- : isNatural
63
- ? new Integer(IntegerConstructor.random(3))
64
- : DecimalConstructor.random(100, 200);
65
- const nb = percentNb.times(0.01);
66
- const identifiers = {
67
- isPercentToDecimal,
68
- nb: round(nb.value, 10),
69
- };
70
- return getQuestionFromIdentifiers(identifiers);
71
- };
72
- const getQuestionFromIdentifiers = (identifiers) => {
73
- const question = {
74
- answer: getAnswer(identifiers),
75
- instruction: getInstruction(identifiers),
76
- keys: getKeys(identifiers),
77
- answerFormat: "tex",
78
- identifiers,
79
- hint: getHint(identifiers),
80
- correction: getCorrection(identifiers),
81
- };
82
- return question;
83
- };
84
52
  const getPropositions = (n, { answer, isPercentToDecimal, nb }) => {
85
53
  const propositions = [];
86
54
  addValidProp(propositions, answer);
@@ -113,12 +81,64 @@ const isAnswerValid = (ans, { answer, isPercentToDecimal }) => {
113
81
  return parsed + "\\%" === answer;
114
82
  }
115
83
  };
84
+ const getPercentToDecimalQuestion = (optsIn) => {
85
+ const arrayedOptions = optsIn ?? optsDefault;
86
+ const opts = {
87
+ conversionType: random(arrayedOptions.conversionType),
88
+ };
89
+ const isPercentToDecimal = opts.conversionType === "Pourcentage vers Décimal";
90
+ const isNatural = coinFlip();
91
+ const percentNb = probaFlip(0.3)
92
+ ? isNatural
93
+ ? new Integer(IntegerConstructor.random(1, [0]))
94
+ : DecimalConstructor.random(0, 10)
95
+ : coinFlip()
96
+ ? isNatural
97
+ ? new Integer(IntegerConstructor.random(2))
98
+ : DecimalConstructor.random(10, 100)
99
+ : isNatural
100
+ ? new Integer(IntegerConstructor.random(3))
101
+ : DecimalConstructor.random(100, 200);
102
+ const nb = percentNb.times(0.01);
103
+ const identifiers = {
104
+ isPercentToDecimal,
105
+ nb: round(nb.value, 10),
106
+ };
107
+ return getQuestionFromIdentifiers(identifiers, opts);
108
+ };
109
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
110
+ const question = {
111
+ answer: getAnswer(identifiers),
112
+ instruction: getInstruction(identifiers),
113
+ keys: getKeys(identifiers),
114
+ answerFormat: "tex",
115
+ identifiers,
116
+ hint: getHint(identifiers),
117
+ correction: getCorrection(identifiers),
118
+ options: opts,
119
+ };
120
+ return question;
121
+ };
122
+ const optsDefault = {
123
+ conversionType: ["Pourcentage vers Décimal", "Décimal vers Pourcentage"],
124
+ };
125
+ const options = [
126
+ {
127
+ id: "conversionType",
128
+ label: "Type de conversion",
129
+ target: GeneratorOptionTarget.generation,
130
+ type: GeneratorOptionType.multiselect,
131
+ values: ["Pourcentage vers Décimal", "Décimal vers Pourcentage"],
132
+ defaultValue: optsDefault.conversionType,
133
+ },
134
+ ];
116
135
  export const percentToDecimal = {
117
136
  id: "percentToDecimal",
118
137
  connector: "=",
119
138
  label: "Écrire un pourcentage sous forme décimale et vice-versa",
120
139
  isSingleStep: true,
121
- generator: (nb) => getDistinctQuestions(getPercentToDecimalQuestion, nb),
140
+ generator: (nb, opts) => getDistinctQuestions(() => getPercentToDecimalQuestion(opts), nb),
141
+ options,
122
142
  qcmTimer: 60,
123
143
  freeTimer: 60,
124
144
  getPropositions,
@@ -2,7 +2,7 @@ import { Exercise } from "../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  int: number;
4
4
  power: number;
5
- opts: Options;
5
+ isPowerAllowed: boolean;
6
6
  };
7
7
  type Options = {
8
8
  isPowerAllowed: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"calculateNegativePower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/calculateNegativePower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AA0CrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA4JF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAeF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBjE,CAAC"}
1
+ {"version":3,"file":"calculateNegativePower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/calculateNegativePower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AA0CrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AA4KF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAcF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBjE,CAAC"}