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
@@ -1,6 +1,7 @@
1
1
  import { randint } from "../../../../math/utils/random/randint.js";
2
2
  import { median } from "../../../../math/utils/stats/median.js";
3
- import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercise.js";
3
+ import { random } from "../../../../utils/alea/random.js";
4
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercise.js";
4
5
  import { getDistinctQuestions } from "../../../utils/getDistinctQuestions.js";
5
6
  const getInstruction = (identifiers) => {
6
7
  const { sortedValues } = identifiers;
@@ -16,15 +17,6 @@ const getAnswer = (identifiers) => {
16
17
  const { sortedValues } = identifiers;
17
18
  return median(sortedValues).frenchify();
18
19
  };
19
- const getMedianList = () => {
20
- const randomValues = [];
21
- const length = randint(6, 10);
22
- for (let i = 0; i < length; i++)
23
- randomValues.push(randint(1, 20));
24
- const sortedValues = randomValues.sort((a, b) => a - b);
25
- const identifiers = { sortedValues };
26
- return getQuestionFromIdentifiers(identifiers);
27
- };
28
20
  const getHint = () => {
29
21
  return `La médiane est la valeur centrale de la série : il y a autant de valeur inférieures à la médiane que de valeurs supérieures à la médiane.`;
30
22
  };
@@ -40,18 +32,6 @@ Puisque $\\frac{${total}}{2} = ${rank.frenchify()}$, la médiane est ${rank % 1
40
32
 
41
33
  La médiane est donc $${getAnswer(identifiers)}$.`;
42
34
  };
43
- const getQuestionFromIdentifiers = (identifiers) => {
44
- const question = {
45
- instruction: getInstruction(identifiers),
46
- answer: getAnswer(identifiers),
47
- keys: [],
48
- answerFormat: "tex",
49
- identifiers,
50
- hint: getHint(identifiers),
51
- correction: getCorrection(identifiers),
52
- };
53
- return question;
54
- };
55
35
  const getPropositions = (n, { answer, sortedValues }) => {
56
36
  const propositions = [];
57
37
  addValidProp(propositions, answer);
@@ -64,12 +44,52 @@ const getPropositions = (n, { answer, sortedValues }) => {
64
44
  const isAnswerValid = (ans, { answer }) => {
65
45
  return ans === answer;
66
46
  };
47
+ const getMedianList = (optsIn) => {
48
+ const arrayedOptions = optsIn ?? optsDefault;
49
+ const opts = {
50
+ nbValues: random(arrayedOptions.nbValues),
51
+ };
52
+ const randomValues = [];
53
+ const length = Number(opts.nbValues);
54
+ for (let i = 0; i < length; i++)
55
+ randomValues.push(randint(1, 20));
56
+ const sortedValues = randomValues.sort((a, b) => a - b);
57
+ const identifiers = { sortedValues };
58
+ return getQuestionFromIdentifiers(identifiers);
59
+ };
60
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
61
+ const question = {
62
+ instruction: getInstruction(identifiers),
63
+ answer: getAnswer(identifiers),
64
+ keys: [],
65
+ answerFormat: "tex",
66
+ identifiers,
67
+ hint: getHint(identifiers),
68
+ correction: getCorrection(identifiers),
69
+ options: opts,
70
+ };
71
+ return question;
72
+ };
73
+ const optsDefault = {
74
+ nbValues: ["7", "8"],
75
+ };
76
+ const options = [
77
+ {
78
+ id: "nbValues",
79
+ label: "Nombre de valeurs dans la liste",
80
+ target: GeneratorOptionTarget.generation,
81
+ type: GeneratorOptionType.multiselect,
82
+ values: ["4", "5", "7", "8", "11", "12", "19", "20"],
83
+ defaultValue: optsDefault.nbValues,
84
+ },
85
+ ];
67
86
  export const medianWithList = {
68
87
  id: "medianWithList",
69
88
  connector: "=",
70
89
  label: "Calcul de la médiane d'une liste de valeurs",
71
90
  isSingleStep: false,
72
- generator: (nb) => getDistinctQuestions(getMedianList, nb),
91
+ generator: (nb, opts) => getDistinctQuestions(() => getMedianList(opts), nb),
92
+ options,
73
93
  qcmTimer: 60,
74
94
  freeTimer: 60,
75
95
  getPropositions,
@@ -4,7 +4,7 @@ type Identifiers = {
4
4
  randomQuartile: number;
5
5
  };
6
6
  type Options = {
7
- nbValues: number;
7
+ nbValues: string;
8
8
  };
9
9
  export declare const quartilesList: Exercise<Identifiers, Options>;
10
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"quartilesList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartilesList.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EAkBT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAyGF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAeF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBxD,CAAC"}
1
+ {"version":3,"file":"quartilesList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartilesList.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EAkBT,MAAM,sBAAsB,CAAC;AAG9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AA2GF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAeF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBxD,CAAC"}
@@ -61,9 +61,9 @@ const isAnswerValid = (ans, { answer }) => {
61
61
  const getQuartiles = (optsIn) => {
62
62
  const opts = optsIn ?? optsDefault;
63
63
  const randomValues = [];
64
- const length = Array.isArray(opts.nbValues)
64
+ const length = Number(Array.isArray(opts.nbValues)
65
65
  ? random(opts.nbValues.map((v) => +v))
66
- : opts.nbValues;
66
+ : opts.nbValues);
67
67
  for (let i = 0; i < length; i++)
68
68
  randomValues.push(randint(1, 20));
69
69
  const randomQuartile = randint(0, 2);
@@ -87,7 +87,7 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
87
87
  return question;
88
88
  };
89
89
  const optsDefault = {
90
- nbValues: 12,
90
+ nbValues: "12",
91
91
  };
92
92
  const options = [
93
93
  {
@@ -95,7 +95,7 @@ const options = [
95
95
  label: "Nombre de valeurs dans la liste",
96
96
  target: GeneratorOptionTarget.generation,
97
97
  type: GeneratorOptionType.multiselect,
98
- values: [4, 5, 7, 8, 11, 12, 19, 20],
98
+ values: ["4", "5", "7", "8", "11", "12", "19", "20"],
99
99
  defaultValue: [optsDefault.nbValues],
100
100
  },
101
101
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"averageSpeed.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/motion/averageSpeed.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA0NF,KAAK,OAAO,GAAG;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAsBF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAcvD,CAAC"}
1
+ {"version":3,"file":"averageSpeed.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/motion/averageSpeed.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA8NF,KAAK,OAAO,GAAG;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAsBF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAcvD,CAAC"}
@@ -32,17 +32,18 @@ const getInstruction = (identifiers) => {
32
32
  })}$ en $${timeMeasure.toTex({ notScientific: true })}$.
33
33
 
34
34
 
35
- Calculer la vitesse moyenne de cet objet en $${opts.unitTex}$.
35
+ Calculer la vitesse moyenne de cet objet en ${opts.unitTex}.
36
36
 
37
37
  ${getAcceptedInputTypesSentence(identifiers)}
38
38
  `;
39
39
  return instruction;
40
40
  };
41
41
  const getHint = ({ opts }) => {
42
+ const unlatexUnit = opts.unitTex.substring(1, opts.unitTex.length - 1);
42
43
  return `La vitesse moyenne est donnée par :
43
44
 
44
45
  $$
45
- \\frac{\\text{distance}}{\\text{temps}} \\ ${opts.unitTex}
46
+ \\frac{\\text{distance}}{\\text{temps}} \\ ${unlatexUnit}
46
47
  $$`;
47
48
  };
48
49
  const getCorrection = (identifiers) => {
@@ -52,6 +53,7 @@ const getCorrection = (identifiers) => {
52
53
  const timeMeasure = new Measure(time.value, 0, timeUnits[time.unitIndex]).convert("s");
53
54
  const calcul = new FractionNode(new VariableNode(distanceMeasure.toTex()), new VariableNode(timeMeasure.toTex()));
54
55
  const answer = getAnswer(identifiers);
56
+ const unlatexUnit = opts.unitTex.substring(1, opts.unitTex.length - 1);
55
57
  if (distance.unitIndex === 0)
56
58
  correction = `- On convertit les $\\textrm{km}$ en $\\textrm{m}$ : $1\\ \\textrm{km}=1000\\ \\textrm{m}$.
57
59
 
@@ -84,7 +86,7 @@ $$
84
86
  }
85
87
  return `${correction}
86
88
  - On applique la règle de calcul pour la vitesse moyenne : $${calcul.toTex()}$
87
- - On arrondit à la toute fin : $${calcul.toTex()} \\approx ${answer} \\ ${opts.unitTex}$`;
89
+ - On arrondit à la toute fin : $${calcul.toTex()} \\approx ${answer} \\ ${unlatexUnit}$`;
88
90
  };
89
91
  const getAnswer = (identifiers) => {
90
92
  return getAnswerMeasure(identifiers).toTex({ hideUnit: true });
@@ -105,10 +107,11 @@ const isAnswerValid = (ans, { answer, ...identifiers }) => {
105
107
  };
106
108
  const getPropositions = (n, { answer, distance, time, opts }) => {
107
109
  const propositions = [];
108
- addValidProp(propositions, `${answer} \\ ${opts.unitTex}`);
110
+ const unlatexUnit = opts.unitTex.substring(1, opts.unitTex.length - 1);
111
+ addValidProp(propositions, `${answer} \\ ${unlatexUnit}`);
109
112
  const distanceMeasure = new Measure(distance.value, 0, distanceUnitValues[distance.unitIndex]);
110
113
  const timeMeasure = new Measure(time.value, 0, timeUnits[time.unitIndex]);
111
- generatePropositions(distanceMeasure, timeMeasure).forEach((value) => tryToAddWrongProp(propositions, `${value} \\ ${opts.unitTex}`));
114
+ generatePropositions(distanceMeasure, timeMeasure).forEach((value) => tryToAddWrongProp(propositions, `${value} \\ ${unlatexUnit}`));
112
115
  const division = distanceMeasure
113
116
  .convert("m")
114
117
  .divide(timeMeasure.convert("s"));
@@ -118,7 +121,7 @@ const getPropositions = (n, { answer, distance, time, opts }) => {
118
121
  const valueTex = new Measure(random, 0, division.getUnit())
119
122
  .toSignificant(2)
120
123
  .toTex({ hideUnit: true });
121
- tryToAddWrongProp(propositions, `${valueTex} \\ ${opts.unitTex}`);
124
+ tryToAddWrongProp(propositions, `${valueTex} \\ ${unlatexUnit}`);
122
125
  });
123
126
  return shuffleProps(propositions, n);
124
127
  };
@@ -170,7 +173,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
170
173
  };
171
174
  const optsDefault = {
172
175
  acceptedInputType: "significant(3)",
173
- unitTex: "\\text{m} \\cdot \\text{s}^{-1}",
176
+ unitTex: "$\\text{m} \\cdot \\text{s}^{-1}$",
174
177
  };
175
178
  const options = [
176
179
  {
@@ -179,9 +182,9 @@ const options = [
179
182
  target: GeneratorOptionTarget.generation,
180
183
  type: GeneratorOptionType.select,
181
184
  values: [
182
- "\\text{m} \\cdot \\text{s}^{-1}",
183
- "\\text{m/s}",
184
- "\\text{s} \\cdot \\text{m}^{-1}",
185
+ "$\\text{m} \\cdot \\text{s}^{-1}$",
186
+ "$\\text{m/s}$",
187
+ "$\\text{s} \\cdot \\text{m}^{-1}$",
185
188
  ],
186
189
  defaultValue: optsDefault.unitTex,
187
190
  },
@@ -9,12 +9,11 @@ type Identifiers = {
9
9
  type DistanceType = "distance focale" | "distance image" | "distance objet";
10
10
  type ImageType = "réelle finie" | "réelle infinie" | "imaginaire finie" | "imaginaire infinie";
11
11
  type UnitType = "cm" | "m";
12
- type RoundToType = 0 | 1 | 2;
13
12
  type Options = {
14
13
  typeDistance: DistanceType;
15
14
  typeImage: ImageType;
16
15
  unit: UnitType;
17
- roundTo: RoundToType;
16
+ roundTo: string;
18
17
  };
19
18
  export declare const lensFormula: Exercise<Identifiers, Options>;
20
19
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"lensFormula.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/optics/lensFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,CAAC;IACzB,EAAE,EAAE,eAAe,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;IACzB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAC5E,KAAK,SAAS,GACV,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,oBAAoB,CAAC;AACzB,KAAK,QAAQ,GAAG,IAAI,GAAG,GAAG,CAAC;AAC3B,KAAK,WAAW,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC7B,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAwiBF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqBtD,CAAC"}
1
+ {"version":3,"file":"lensFormula.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/optics/lensFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,CAAC;IACzB,EAAE,EAAE,eAAe,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;IACzB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAC5E,KAAK,SAAS,GACV,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,oBAAoB,CAAC;AACzB,KAAK,QAAQ,GAAG,IAAI,GAAG,GAAG,CAAC;AAE3B,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAqiBF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqBtD,CAAC"}
@@ -24,7 +24,7 @@ const optsDefault = {
24
24
  "imaginaire infinie",
25
25
  ],
26
26
  unit: ["cm", "m"],
27
- roundTo: [0, 1, 2],
27
+ roundTo: ["0", "1", "2"],
28
28
  };
29
29
  const options = [
30
30
  {
@@ -62,7 +62,7 @@ const options = [
62
62
  target: GeneratorOptionTarget.generation,
63
63
  type: GeneratorOptionType.multiselect,
64
64
  defaultValue: optsDefault.roundTo,
65
- values: [0, 1, 2],
65
+ values: ["0", "1", "2"],
66
66
  },
67
67
  ];
68
68
  const getLensFormulaEqualNode = () => {
@@ -76,11 +76,11 @@ const getInstruction = (identifiers) => {
76
76
  const nodeOAPrime = NodeConstructor.fromIdentifiers(OAPrime);
77
77
  const strRounTo = (() => {
78
78
  switch (opts.roundTo) {
79
- case 0:
79
+ case "0":
80
80
  return "à l'unité";
81
- case 1:
81
+ case "1":
82
82
  return "au dixième";
83
- case 2:
83
+ case "2":
84
84
  return "au centième";
85
85
  }
86
86
  })();
@@ -206,7 +206,7 @@ const getAnswer = (identifiers) => {
206
206
  case "distance objet":
207
207
  return nodeOA;
208
208
  }
209
- })().evaluate(), opts.roundTo).frenchify()}${opts.unit}`;
209
+ })().evaluate(), Number(opts.roundTo)).frenchify()}${opts.unit}`;
210
210
  };
211
211
  const isAnswerValid = (ans, { answer, ...identifiers }) => {
212
212
  const { opts } = identifiers;
@@ -287,11 +287,9 @@ const getLensFormulaQuestion = (optsIn) => {
287
287
  unit: optsIn?.unit,
288
288
  roundTo: (optsIn?.roundTo)
289
289
  .filter((a) => typeof a === "string")
290
- .map((str) => +str),
290
+ .map((str) => str),
291
291
  }
292
292
  : undefined;
293
- console.log("optsIn", optsIn);
294
- console.log("optsInRetyped", optsInRetyped);
295
293
  let nodeOFPrime = NaN.toTree();
296
294
  let nodeOA = NaN.toTree();
297
295
  let nodeOAPrime = NaN.toTree();
@@ -310,7 +308,6 @@ const getLensFormulaQuestion = (optsIn) => {
310
308
  unit: random(optsDefault.unit),
311
309
  roundTo: random(optsDefault.roundTo),
312
310
  };
313
- console.log("opts", opts);
314
311
  //objet réel: \\overline {OA} < 0
315
312
  //image réelle : \\overline {OA'} > 0
316
313
  function factorNodeForTypeImage(typeImage) {
@@ -4,10 +4,9 @@ type Identifiers = {
4
4
  optsIdent: Options;
5
5
  };
6
6
  type InputType = "decimal" | "sci";
7
- type NbDigitsType = 0 | 1 | 2;
8
7
  type Options = {
9
8
  inputType: InputType;
10
- nbDigits: NbDigitsType;
9
+ nbDigits: string;
11
10
  };
12
11
  export declare const calculateWeight: Exercise<Identifiers, Options>;
13
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"calculateWeight.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/weight/calculateWeight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC;AACnC,KAAK,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE9B,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAuMF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAc1D,CAAC"}
1
+ {"version":3,"file":"calculateWeight.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/weight/calculateWeight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC;AAEnC,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAuMF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAc1D,CAAC"}
@@ -8,7 +8,7 @@ import { random } from "../../../utils/alea/random.js";
8
8
  const g = +earthGravity.measure.significantPart.toFixed(2);
9
9
  const optsDefault = {
10
10
  inputType: "sci",
11
- nbDigits: 2,
11
+ nbDigits: "2",
12
12
  };
13
13
  const options = [
14
14
  {
@@ -24,7 +24,7 @@ const options = [
24
24
  label: "Nombre de décimales",
25
25
  type: GeneratorOptionType.multiselect,
26
26
  target: GeneratorOptionTarget.generation,
27
- values: [0, 1, 2],
27
+ values: ["0", "1", "2"],
28
28
  defaultValue: [optsDefault.nbDigits],
29
29
  },
30
30
  ];
@@ -46,11 +46,11 @@ ${(() => {
46
46
  })()}
47
47
  ${(() => {
48
48
  switch (optsIdent.nbDigits) {
49
- case 0:
49
+ case "0":
50
50
  return `arrondie à l'unité`;
51
- case 1:
51
+ case "1":
52
52
  return `arrondie à une décimale`;
53
- case 2:
53
+ case "2":
54
54
  return `arrondie à deux décimales`;
55
55
  }
56
56
  })()}.
@@ -91,11 +91,11 @@ const getAnswer = (identifiers) => {
91
91
  const { mass, optsIdent } = identifiers;
92
92
  switch (optsIdent.inputType) {
93
93
  case "decimal": {
94
- const answer = round(mass * g, optsIdent.nbDigits);
94
+ const answer = round(mass * g, Number(optsIdent.nbDigits));
95
95
  return `${answer.frenchify()}N`;
96
96
  }
97
97
  case "sci": {
98
- const answer = (mass * g).toScientific(optsIdent.nbDigits);
98
+ const answer = (mass * g).toScientific(Number(optsIdent.nbDigits));
99
99
  return `${answer.toTex()}N`;
100
100
  }
101
101
  }
@@ -107,26 +107,27 @@ const getPropositions = (n, { answer, mass, optsIdent }) => {
107
107
  const propositions = [];
108
108
  const weight = mass * g;
109
109
  addValidProp(propositions, answer);
110
+ const nbDigits = Number(optsIdent.nbDigits);
110
111
  switch (optsIdent.inputType) {
111
112
  case "decimal":
112
113
  {
113
- tryToAddWrongProp(propositions, `${round(weight * 10, optsIdent.nbDigits).frenchify()}N`);
114
- tryToAddWrongProp(propositions, `${round(randfloat(weight - 100, weight + 100, 2, [weight]) / 10, optsIdent.nbDigits).frenchify()}N`);
114
+ tryToAddWrongProp(propositions, `${round(weight * 10, nbDigits).frenchify()}N`);
115
+ tryToAddWrongProp(propositions, `${round(randfloat(weight - 100, weight + 100, 2, [weight]) / 10, nbDigits).frenchify()}N`);
115
116
  propWhile(propositions, n, () => {
116
117
  const random = randfloat(weight - 50, weight + 50, 2, [weight]);
117
- tryToAddWrongProp(propositions, `${round(random, optsIdent.nbDigits).frenchify()}N`);
118
+ tryToAddWrongProp(propositions, `${round(random, nbDigits).frenchify()}N`);
118
119
  });
119
120
  }
120
121
  break;
121
122
  case "sci":
122
123
  {
123
- tryToAddWrongProp(propositions, `${(weight * 10).toScientific(optsIdent.nbDigits).toTex()}N`);
124
+ tryToAddWrongProp(propositions, `${(weight * 10).toScientific(nbDigits).toTex()}N`);
124
125
  tryToAddWrongProp(propositions, `${(randfloat(weight - 100, weight + 100, 2, [weight]) / 10)
125
- .toScientific(optsIdent.nbDigits)
126
+ .toScientific(nbDigits)
126
127
  .toTex()}N`);
127
128
  propWhile(propositions, n, () => {
128
129
  const random = randfloat(weight - 50, weight + 50, 2, [weight]);
129
- tryToAddWrongProp(propositions, `${random.toScientific(optsIdent.nbDigits).toTex()}N`);
130
+ tryToAddWrongProp(propositions, `${random.toScientific(nbDigits).toTex()}N`);
130
131
  });
131
132
  }
132
133
  break;
@@ -137,7 +138,7 @@ const getCalculateWeightQuestion = (optsIn) => {
137
138
  const opts = optsIn
138
139
  ? Object.assign(optsDefault, {
139
140
  inputType: random(optsIn.inputType),
140
- nbDigits: +random(optsIn.nbDigits),
141
+ nbDigits: random(optsIn.nbDigits),
141
142
  })
142
143
  : optsDefault;
143
144
  const mass = randint(30, 151);
@@ -0,0 +1,3 @@
1
+ import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
2
+ export declare function isNodesEqual(node1: AlgebraicNode, node2: AlgebraicNode): boolean;
3
+ //# sourceMappingURL=isNodesEqual.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isNodesEqual.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/isNodesEqual.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAIlE,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,WAMtE"}
@@ -0,0 +1,6 @@
1
+ import { multiply } from "../../tree/nodes/operators/multiplyNode.js";
2
+ import { substract } from "../../tree/nodes/operators/substractNode.js";
3
+ export function isNodesEqual(node1, node2) {
4
+ return [1, 1_000, 1_000_000].every((factor) => substract(multiply(factor, node1), multiply(factor, node2)).evaluate() ===
5
+ 0);
6
+ }
@@ -0,0 +1,5 @@
1
+ import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
2
+ export declare abstract class SetVEA {
3
+ static isArrayOfNodesValid: (arrAns: AlgebraicNode[], arrAnswer: AlgebraicNode[]) => boolean;
4
+ }
5
+ //# sourceMappingURL=setVEA.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/setVEA.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,8BAAsB,MAAM;IAC1B,MAAM,CAAC,mBAAmB,GACxB,QAAQ,aAAa,EAAE,EACvB,WAAW,aAAa,EAAE,aA2B1B;CACH"}
@@ -0,0 +1,25 @@
1
+ import { isNodesEqual } from "./isNodesEqual.js";
2
+ export class SetVEA {
3
+ static isArrayOfNodesValid = (arrAns, arrAnswer) => {
4
+ const dictAnswer = Object.fromEntries(arrAnswer.map((node, i) => [i, node]));
5
+ let isValid = true;
6
+ for (let i = 0; i < arrAns.length; i++) {
7
+ const nodeAns = arrAns[i];
8
+ let isFound = false;
9
+ const keys = Object.keys(dictAnswer);
10
+ for (let j = 0; j < keys.length; j++) {
11
+ const key = keys[j];
12
+ const answerNode = dictAnswer[key];
13
+ if (isNodesEqual(nodeAns, answerNode)) {
14
+ isFound = true;
15
+ delete dictAnswer[key]; //one-to-one correspondence
16
+ break;
17
+ }
18
+ }
19
+ isValid = isValid && isFound;
20
+ if (!isValid)
21
+ break;
22
+ }
23
+ return isValid;
24
+ };
25
+ }