math-exercises 3.0.123 → 3.0.125

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 (75) hide show
  1. package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +20 -14
  4. package/lib/exercises/math/calcul/fractions/fractionsMix.js +1 -1
  5. package/lib/exercises/math/conversion/volumeConversion.d.ts.map +1 -1
  6. package/lib/exercises/math/conversion/volumeConversion.js +7 -1
  7. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.d.ts.map +1 -1
  8. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.js +9 -3
  9. package/lib/exercises/math/functions/affines/affineFromExercise.d.ts +1 -1
  10. package/lib/exercises/math/functions/affines/affineFromExercise.d.ts.map +1 -1
  11. package/lib/exercises/math/functions/affines/affineFromExercise.js +123 -48
  12. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.js +5 -5
  13. package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts +2 -1
  14. package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts.map +1 -1
  15. package/lib/exercises/math/functions/affines/recognizeAffineGraph.js +41 -24
  16. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -1
  17. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +29 -2
  18. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
  19. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +72 -61
  20. package/lib/exercises/math/functions/logarithm/powerEquation.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/logarithm/powerEquation.js +0 -1
  22. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts.map +1 -1
  23. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.js +41 -16
  24. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
  25. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +3 -2
  26. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts +1 -0
  27. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts.map +1 -1
  28. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.js +21 -13
  29. package/lib/exercises/math/geometry/perimeters/circleCircumference.d.ts.map +1 -1
  30. package/lib/exercises/math/geometry/perimeters/circleCircumference.js +15 -7
  31. package/lib/exercises/math/geometry/shapes/basicShapesNaming.d.ts.map +1 -1
  32. package/lib/exercises/math/geometry/shapes/basicShapesNaming.js +5 -3
  33. package/lib/exercises/math/geometry/vectors/vectorLinearCombination.d.ts.map +1 -1
  34. package/lib/exercises/math/geometry/vectors/vectorLinearCombination.js +0 -1
  35. package/lib/exercises/math/percent/evolutions/evolutionToCM.js +2 -2
  36. package/lib/exercises/math/percent/findProportion.d.ts +6 -1
  37. package/lib/exercises/math/percent/findProportion.d.ts.map +1 -1
  38. package/lib/exercises/math/percent/findProportion.js +162 -45
  39. package/lib/exercises/math/powers/calculateNegativePower.d.ts +5 -1
  40. package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
  41. package/lib/exercises/math/powers/calculateNegativePower.js +93 -29
  42. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
  43. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +10 -2
  44. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  45. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +2 -1
  46. package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts +4 -1
  47. package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts.map +1 -1
  48. package/lib/exercises/math/probaStat/stats1var/quartilesList.js +46 -27
  49. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
  50. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +14 -2
  51. package/lib/exercises/math/sequences/geometric/geometricReasonUsage.d.ts +1 -0
  52. package/lib/exercises/math/sequences/geometric/geometricReasonUsage.d.ts.map +1 -1
  53. package/lib/exercises/math/sequences/geometric/geometricReasonUsage.js +43 -19
  54. package/lib/exercises/math/sequences/sequenceEvaluation.d.ts.map +1 -1
  55. package/lib/exercises/math/sequences/sequenceEvaluation.js +18 -1
  56. package/lib/exercises/pc/chemicalReactions/chemicalEquations.d.ts.map +1 -1
  57. package/lib/exercises/pc/chemicalReactions/chemicalEquations.js +17 -2
  58. package/lib/exercises/pc/mole/molarMass.d.ts.map +1 -1
  59. package/lib/exercises/pc/mole/molarMass.js +7 -1
  60. package/lib/exercises/pc/motion/averageSpeed.d.ts +9 -4
  61. package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
  62. package/lib/exercises/pc/motion/averageSpeed.js +132 -61
  63. package/lib/exercises/pc/motion/averageSpeedCalculation.d.ts.map +1 -1
  64. package/lib/exercises/pc/motion/averageSpeedCalculation.js +10 -4
  65. package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.d.ts +2 -2
  66. package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.js +15 -15
  67. package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts +1 -0
  68. package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts.map +1 -1
  69. package/lib/exercises/utils/geogebra/toolBarConstructor.js +3 -1
  70. package/lib/index.d.ts +49 -13
  71. package/lib/index.d.ts.map +1 -1
  72. package/lib/pc/units/timeUnits.d.ts +5 -3
  73. package/lib/pc/units/timeUnits.d.ts.map +1 -1
  74. package/lib/pc/units/timeUnits.js +25 -19
  75. package/package.json +1 -1
@@ -56,74 +56,85 @@ const getGGBOptions = (identifiers) => {
56
56
  });
57
57
  };
58
58
  const getInverseImageFunctionGeogebra = () => {
59
- const isLine = coinFlip();
60
- const hasAntecedent = probaFlip(0.8);
61
- // const isLine = false;
62
- // const hasAntecedent = true;
63
- let yValue;
64
- const points = [];
65
- if (isLine) {
66
- if (hasAntecedent) {
67
- yValue = randint(-6, 7);
68
- const xIsDecimal = probaFlip(0.3);
69
- const xValue = xIsDecimal
70
- ? randfloat(-6, 7, 2, [yValue])
71
- : randint(-6, 7, [yValue]);
72
- const wrongY = randint(-6, 7);
73
- points.push([xValue, yValue], [yValue, wrongY]);
74
- }
75
- else {
76
- yValue = randint(-6, 7, [0]);
77
- const constante = randint(-6, 7, [yValue]);
78
- points.push([0, constante], [1, constante]);
79
- }
80
- }
81
- else {
82
- if (hasAntecedent) {
83
- yValue = randint(-6, 7);
84
- const xIsDecimal = coinFlip();
85
- const xValue = xIsDecimal
86
- ? randfloat(-6, 7, 2, [yValue])
87
- : randint(-6, 7, [yValue]);
88
- const hasTwoAntecedents = probaFlip(0.8);
89
- if (hasTwoAntecedents) {
90
- const wrongY = randint(-6, 7, [yValue]);
91
- const secondAntecedentPoint = [
92
- randint(-6, 7, [xValue, yValue]),
93
- yValue,
94
- ];
95
- points.push([xValue, yValue], [yValue, wrongY], secondAntecedentPoint);
59
+ function generateIdentifiers() {
60
+ const isLine = coinFlip();
61
+ const hasAntecedent = probaFlip(0.8);
62
+ // const isLine = false;
63
+ // const hasAntecedent = true;
64
+ let yValue;
65
+ const points = [];
66
+ if (isLine) {
67
+ if (hasAntecedent) {
68
+ yValue = randint(-6, 7);
69
+ const xIsDecimal = probaFlip(0.3);
70
+ const xValue = xIsDecimal
71
+ ? randfloat(-6, 7, 2, [yValue])
72
+ : randint(-6, 7, [yValue]);
73
+ const wrongY = randint(-6, 7);
74
+ points.push([xValue, yValue], [yValue, wrongY]);
96
75
  }
97
76
  else {
98
- //(x,y) is summit
99
- const wrongY = randint(-6, 7, [yValue]);
100
- points.push([xValue, yValue], [yValue, wrongY], [2 * xValue - yValue, wrongY]);
77
+ yValue = randint(-6, 7, [0]);
78
+ const constante = randint(-6, 7, [yValue]);
79
+ points.push([0, constante], [1, constante]);
101
80
  }
102
81
  }
103
82
  else {
104
- yValue = randint(-8, 9);
105
- const wrongY = randint(-3, 4, [yValue, yValue - 1, yValue + 1]);
106
- const below = wrongY < yValue;
107
- const summit = [
108
- randint(-6, 7, [yValue]),
109
- below
110
- ? randint(wrongY + 1, yValue, [wrongY])
111
- : randint(yValue + 1, wrongY, [wrongY]),
112
- ];
113
- const thirdPoint = [2 * summit[0] - yValue, wrongY];
114
- //construire deux autrs points au pif avec y sous/audssu yValus
115
- points.push([yValue, wrongY], summit, thirdPoint);
83
+ if (hasAntecedent) {
84
+ yValue = randint(-6, 7);
85
+ const xIsDecimal = coinFlip();
86
+ const xValue = xIsDecimal
87
+ ? randfloat(-6, 7, 2, [yValue])
88
+ : randint(-6, 7, [yValue]);
89
+ const hasTwoAntecedents = probaFlip(0.8);
90
+ if (hasTwoAntecedents) {
91
+ const wrongY = randint(-6, 7, [yValue]);
92
+ const secondAntecedentPoint = [
93
+ randint(-6, 7, [xValue, yValue]),
94
+ yValue,
95
+ ];
96
+ points.push([xValue, yValue], [yValue, wrongY], secondAntecedentPoint);
97
+ }
98
+ else {
99
+ //(x,y) is summit
100
+ const wrongY = randint(-6, 7, [yValue]);
101
+ points.push([xValue, yValue], [yValue, wrongY], [2 * xValue - yValue, wrongY]);
102
+ }
103
+ }
104
+ else {
105
+ yValue = randint(-8, 9);
106
+ const wrongY = randint(-3, 4, [yValue, yValue - 1, yValue + 1]);
107
+ const below = wrongY < yValue;
108
+ const summit = [
109
+ randint(-6, 7, [yValue]),
110
+ below
111
+ ? randint(wrongY + 1, yValue, [wrongY])
112
+ : randint(yValue + 1, wrongY, [wrongY]),
113
+ ];
114
+ const thirdPoint = [2 * summit[0] - yValue, wrongY];
115
+ //construire deux autrs points au pif avec y sous/audssu yValus
116
+ points.push([yValue, wrongY], summit, thirdPoint);
117
+ }
116
118
  }
119
+ points.sort((p1, p2) => p1[0] - p2[0]);
120
+ const identifiers = {
121
+ // xValue,
122
+ // affineCoeffs: isAffine ? affine!.coefficients : undefined,
123
+ // trinomCoeffs: isAffine ? undefined : trinom!.coefficients,
124
+ yValue,
125
+ points,
126
+ // isAffine,
127
+ };
128
+ return identifiers;
117
129
  }
118
- points.sort((p1, p2) => p1[0] - p2[0]);
119
- const identifiers = {
120
- // xValue,
121
- // affineCoeffs: isAffine ? affine!.coefficients : undefined,
122
- // trinomCoeffs: isAffine ? undefined : trinom!.coefficients,
123
- yValue,
124
- points,
125
- // isAffine,
126
- };
130
+ function isInfinityOfSolutions(identifiers) {
131
+ const { yValue, points } = identifiers;
132
+ return points.every((point) => point[1] === yValue);
133
+ }
134
+ let identifiers;
135
+ do {
136
+ identifiers = generateIdentifiers();
137
+ } while (isInfinityOfSolutions(identifiers));
127
138
  return getQuestionFromIdentifiers(identifiers);
128
139
  };
129
140
  const getHint = (identifiers) => {
@@ -1 +1 @@
1
- {"version":3,"file":"powerEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/powerEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoJF,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAUF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBxD,CAAC"}
1
+ {"version":3,"file":"powerEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/powerEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmJF,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAUF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBxD,CAAC"}
@@ -90,7 +90,6 @@ const isAnswerValid = (ans, { answer }) => {
90
90
  const parsed = parseAlgebraic(ans);
91
91
  const value = parsed.evaluate();
92
92
  const answerValue = parseAlgebraic(answer).evaluate();
93
- console.log(value, answerValue);
94
93
  if (Math.abs(value - answerValue) < 0.01)
95
94
  return true;
96
95
  return parsed.simplify().toTex() === answer;
@@ -1 +1 @@
1
- {"version":3,"file":"rootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
1
+ {"version":3,"file":"rootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4GF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
@@ -2,9 +2,11 @@ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../../exer
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
4
  import { randint } from "../../../../../math/utils/random/randint.js";
5
- import { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
6
- import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
5
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
7
+ import { discreteSetParser } from "../../../../../tree/parsers/discreteSetParser.js";
7
8
  import { shuffle } from "../../../../../utils/alea/shuffle.js";
9
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
8
10
  const getInstruction = (identifiers) => {
9
11
  const { a, b, c } = identifiers;
10
12
  const trinom = new Trinom(a, b, c);
@@ -49,20 +51,43 @@ const getPropositions = (n, { answer }) => {
49
51
  return shuffle(propositions);
50
52
  };
51
53
  const isAnswerValid = (ans, { a, b, c }) => {
52
- // try {
53
- // const parsed = discreteSetParser(ans);
54
- // if (!parsed) return false;
55
- // return (
56
- // "S=" + parsed.simplify({ decimalToFractions: true }).toTex() === answer
57
- // );
58
- // } catch (err) {
59
- // return handleVEAError(err);
60
- // }
61
- const trinom = new Trinom(a, b, c);
62
- const roots = trinom.getRootsNode();
63
- const answer = new EquationSolutionNode(new DiscreteSetNode(roots));
64
- const texs = answer.toAllValidTexs();
65
- return texs.includes(ans);
54
+ try {
55
+ const parsed = discreteSetParser(ans);
56
+ if (!parsed)
57
+ return false;
58
+ const trinom = new Trinom(a, b, c);
59
+ const roots = trinom.getRootsNode();
60
+ return isArrayOfNodesValid(parsed.elements, roots);
61
+ }
62
+ catch (err) {
63
+ return handleVEAError(err);
64
+ }
65
+ };
66
+ const isArrayOfNodesValid = (arrAns, arrAnswer) => {
67
+ //tried with toAllValidTexs() but there is always an unhandled case
68
+ function isNodesEqual(node1, node2) {
69
+ return [1, 1_000, 1_000_000].every((factor) => substract(multiply(factor, node1), multiply(factor, node2)).evaluate() === 0);
70
+ }
71
+ const dictAnswer = Object.fromEntries(arrAnswer.map((node, i) => [i, node]));
72
+ let isValid = true;
73
+ for (let i = 0; i < arrAns.length; i++) {
74
+ const nodeAns = arrAns[i];
75
+ let isFound = false;
76
+ const keys = Object.keys(dictAnswer);
77
+ for (let j = 0; j < keys.length; j++) {
78
+ const key = keys[j];
79
+ const answerNode = dictAnswer[key];
80
+ if (isNodesEqual(nodeAns, answerNode)) {
81
+ isFound = true;
82
+ delete dictAnswer[key]; //one-to-one correspondence
83
+ break;
84
+ }
85
+ }
86
+ isValid = isValid && isFound;
87
+ if (!isValid)
88
+ break;
89
+ }
90
+ return isValid;
66
91
  };
67
92
  export const rootsFromDevForm = {
68
93
  id: "rootsFromDevForm",
@@ -1 +1 @@
1
- {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmGF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAY9C,CAAC"}
1
+ {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoGF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAY9C,CAAC"}
@@ -80,8 +80,9 @@ const isAnswerValid = (ans, { a, b, c }) => {
80
80
  return ans === "\\text{Aucun}";
81
81
  }
82
82
  const studentNumbers = ans
83
- .replaceAll("\\text{ }", "")
84
- .split("\\text{ et }")
83
+ .replaceAll("\\text{", "")
84
+ .replaceAll("}", "") //as long as there's no \\frac{}{} involved, it's ok
85
+ .split("et")
85
86
  .map((n) => Number(n.replace(",", ".")))
86
87
  .filter((n) => !isNaN(n))
87
88
  .sort((a, b) => a - b);
@@ -2,6 +2,7 @@ import { Exercise } from "../../../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  trinomCoeffs: number[];
4
4
  isAskingPositive: boolean;
5
+ isStrict: boolean;
5
6
  };
6
7
  export declare const trinomSignFromFacto: Exercise<Identifiers>;
7
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"trinomSignFromFacto.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignFromFacto.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAyHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAqBrD,CAAC"}
1
+ {"version":3,"file":"trinomSignFromFacto.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignFromFacto.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAgJF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAqBrD,CAAC"}
@@ -8,11 +8,12 @@ import { UnionIntervalNode } from "../../../../../tree/nodes/sets/unionIntervalN
8
8
  import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
9
9
  import { unionIntervalParser } from "../../../../../tree/parsers/unionIntervalParser.js";
10
10
  import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
11
- const getPropositions = (n, { answer, trinomCoeffs, isAskingPositive }) => {
11
+ const getPropositions = (n, { answer, trinomCoeffs, isAskingPositive, isStrict }) => {
12
12
  const propositions = [];
13
13
  addValidProp(propositions, answer);
14
14
  const trinom = TrinomNodeConstructor.fromCoeffs(trinomCoeffs);
15
- tryToAddWrongProp(propositions, getAnswer({ trinomCoeffs, isAskingPositive: !isAskingPositive }));
15
+ tryToAddWrongProp(propositions, getAnswer({ trinomCoeffs, isAskingPositive: !isAskingPositive, isStrict }));
16
+ tryToAddWrongProp(propositions, getAnswer({ trinomCoeffs, isAskingPositive, isStrict: !isStrict }));
16
17
  tryToAddWrongProp(propositions, new IntervalNode(trinom.a, trinom.b, ClosureType.FF).toTex());
17
18
  propWhile(propositions, n, () => {
18
19
  const interval = IntervalNodeConstructor.random();
@@ -21,36 +22,41 @@ const getPropositions = (n, { answer, trinomCoeffs, isAskingPositive }) => {
21
22
  return shuffleProps(propositions, n);
22
23
  };
23
24
  const getAnswerNode = (identifiers) => {
24
- const trinom = TrinomNodeConstructor.fromCoeffs(identifiers.trinomCoeffs);
25
+ const { trinomCoeffs, isAskingPositive, isStrict } = identifiers;
26
+ const trinom = TrinomNodeConstructor.fromCoeffs(trinomCoeffs);
25
27
  const roots = trinom.getRoots();
26
- const a = identifiers.trinomCoeffs[2];
27
- return a > 0 === identifiers.isAskingPositive
28
+ const a = trinomCoeffs[2];
29
+ return a > 0 === isAskingPositive
28
30
  ? new UnionIntervalNode([
29
- new IntervalNode(MinusInfinityNode, roots[0], ClosureType.OF),
30
- new IntervalNode(roots[1], PlusInfinityNode, ClosureType.FO),
31
+ new IntervalNode(MinusInfinityNode, roots[0], isStrict ? ClosureType.OO : ClosureType.OF),
32
+ new IntervalNode(roots[1], PlusInfinityNode, isStrict ? ClosureType.OO : ClosureType.FO),
31
33
  ])
32
- : new IntervalNode(roots[0], roots[1], ClosureType.FF);
34
+ : new IntervalNode(roots[0], roots[1], isStrict ? ClosureType.OO : ClosureType.FF);
33
35
  };
34
36
  const getAnswer = (identifiers) => {
35
37
  return getAnswerNode(identifiers).toTex();
36
38
  };
37
39
  const getInstruction = (identifiers) => {
38
- const trinom = TrinomNodeConstructor.fromCoeffs(identifiers.trinomCoeffs);
40
+ const { trinomCoeffs, isAskingPositive, isStrict } = identifiers;
41
+ const trinom = TrinomNodeConstructor.fromCoeffs(trinomCoeffs);
39
42
  return `Soit $f$ une fonction polynôme de degré $2$ définie sur $\\mathbb{R}$ par :
40
43
 
41
44
  $$
42
45
  f(x) = ${trinom.toFactorized().toTex()}
43
46
  $$
44
47
 
45
- Sur quel(s) intervalle(s) les valeurs de la fonction $f$ sont-elles ${identifiers.isAskingPositive ? "positives" : "négatives"} ?`;
48
+ Sur quel(s) intervalle(s) les valeurs de la fonction $f$ sont-elles
49
+ ${isStrict ? "strictement" : ""} ${isAskingPositive ? "positives" : "négatives"}
50
+ ?`;
46
51
  };
47
52
  const getHint = () => {
48
53
  return `Une fonction polynôme de degré $2$ est du signe de son coefficient $a$, sauf entre ses racines.`;
49
54
  };
50
55
  const getCorrection = (identifiers) => {
51
- const trinom = TrinomNodeConstructor.fromCoeffs(identifiers.trinomCoeffs);
56
+ const { trinomCoeffs, isAskingPositive, isStrict } = identifiers;
57
+ const trinom = TrinomNodeConstructor.fromCoeffs(trinomCoeffs);
52
58
  const roots = trinom.getRoots();
53
- const a = identifiers.trinomCoeffs[2];
59
+ const a = trinomCoeffs[2];
54
60
  const answer = getAnswer(identifiers);
55
61
  const ineqSign = a > 0 ? ">" : "<";
56
62
  const sign = a > 0 ? "positive" : "négative";
@@ -60,7 +66,7 @@ Ici, $a = ${a}${ineqSign}0$, et les racines de $f$ sont $${roots[0].toTex()}$ et
60
66
 
61
67
  $f$ est donc ${sign} sauf sur l'intervalle $${new IntervalNode(roots[0], roots[1], ClosureType.FF).toTex()}$.
62
68
 
63
- On en déduit que $f$ est ${identifiers.isAskingPositive ? "positive" : "négative"} sur :
69
+ On en déduit que $f$ est ${isStrict ? "strictement" : ""} ${isAskingPositive ? "positive" : "négative"} sur :
64
70
 
65
71
  $$
66
72
  ${answer}
@@ -83,8 +89,10 @@ const isAnswerValid = (ans, { answer }) => {
83
89
  const getTrinomSignFromFactoQuestion = () => {
84
90
  const trinom = TrinomNodeConstructor.randomNiceRoots(2);
85
91
  const isAskingPositive = coinFlip();
92
+ const isStrict = coinFlip();
86
93
  const identifiers = {
87
94
  isAskingPositive,
95
+ isStrict,
88
96
  trinomCoeffs: trinom.getCoeffs(),
89
97
  };
90
98
  return getQuestionFromIdentifiers(identifiers);
@@ -1 +1 @@
1
- {"version":3,"file":"circleCircumference.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/perimeters/circleCircumference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAoGF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
1
+ {"version":3,"file":"circleCircumference.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/perimeters/circleCircumference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA2GF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
@@ -2,6 +2,8 @@ import { addValidProp, tryToAddWrongProp, propWhile, } from "../../../../exercis
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { round } from "../../../../math/utils/round.js";
5
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
6
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
5
7
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
6
8
  import { shuffle } from "../../../../utils/alea/shuffle.js";
7
9
  const getInstruction = (identifiers) => {
@@ -10,14 +12,15 @@ const getInstruction = (identifiers) => {
10
12
  ? "rayon " + `$${radius}\\ \\textrm{cm}$`
11
13
  : "diamètre " + `$${diametre} \\ \\textrm{cm}$`} (arrondir au centième de $\\textrm{cm}$).`;
12
14
  };
13
- const getAnswer = (identifiers) => {
15
+ const getAnswerNode = (identifiers) => {
14
16
  const { coin, radius, diametre } = identifiers;
15
17
  const answerNb = coin
16
18
  ? round(2 * Math.PI * radius, 2)
17
19
  : round(Math.PI * diametre, 2);
18
- const answer = answerNb.frenchify();
19
- const answerTex = answer + "\\text{cm}";
20
- return answerTex;
20
+ return answerNb.toTree();
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ return `${getAnswerNode(identifiers).toTex()} \\text{cm}`;
21
24
  };
22
25
  const getHint = () => {
23
26
  return `Le périmètre d'un cercle de rayon $r$ est donné par :
@@ -79,9 +82,14 @@ const getPropositions = (n, { answer }) => {
79
82
  });
80
83
  return shuffle(propositions);
81
84
  };
82
- const isAnswerValid = (ans, { answer }) => {
83
- const texs = [answer, answer.split("\\text")[0]];
84
- return texs.includes(ans);
85
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
86
+ if (ans.includes("\\text{cm}^2")) {
87
+ return false;
88
+ }
89
+ const refinedAns = ans.replace("\\text{cm}", "");
90
+ const ansNode = parseAlgebraic(refinedAns);
91
+ const answerNode = getAnswerNode(identifiers);
92
+ return substract(ansNode, answerNode).evaluate() === 0;
85
93
  };
86
94
  export const circleCircumference = {
87
95
  id: "circleCircumference",
@@ -1 +1 @@
1
- {"version":3,"file":"basicShapesNaming.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/shapes/basicShapesNaming.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAGL,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AAKxC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC;CAC/D,CAAC;AAiKF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAenD,CAAC"}
1
+ {"version":3,"file":"basicShapesNaming.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/shapes/basicShapesNaming.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAGL,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AAKxC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC;CAC/D,CAAC;AAmKF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAenD,CAAC"}
@@ -31,7 +31,7 @@ const getAnswer = (identifiers) => {
31
31
  break;
32
32
  case 3: //droite
33
33
  default:
34
- return obj.toTexNoLeftRight();
34
+ return `(${obj.toTexNoLeftRight()})`;
35
35
  break;
36
36
  }
37
37
  };
@@ -105,12 +105,14 @@ const getBasicShapesNamingQuestion = () => {
105
105
  const type = randint(1, 4);
106
106
  let objIds;
107
107
  switch (type) {
108
- case 1: { //segment
108
+ case 1: {
109
+ //segment
109
110
  const segment = SegmentConstructor.random();
110
111
  objIds = segment.toIdentifiers();
111
112
  break;
112
113
  }
113
- case 2: { //demi-droite
114
+ case 2: {
115
+ //demi-droite
114
116
  const ray = RayConstructor.random();
115
117
  objIds = ray.toIdentifiers();
116
118
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"vectorLinearCombination.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/vectorLinearCombination.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,YAAY,CAAC;IAChB,CAAC,EAAE,YAAY,CAAC;CACjB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsNF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
1
+ {"version":3,"file":"vectorLinearCombination.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/vectorLinearCombination.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,YAAY,CAAC;IAChB,CAAC,EAAE,YAAY,CAAC;CACjB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqNF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
@@ -154,7 +154,6 @@ const isAnswerValid = (ans, { answer, ...identifiers }) => {
154
154
  if (!isBinomialCoefficientNode(parsed))
155
155
  return false;
156
156
  const vec = new Vector("u", parsed.leftChild, parsed.rightChild);
157
- console.log(solVector.toCoords(), vec.toCoords());
158
157
  return solVector.simplify().toCoords() === vec.toCoords();
159
158
  }
160
159
  else {
@@ -32,7 +32,7 @@ $$
32
32
  1${isHausse ? "+" : "-"}\\frac{${Math.abs(evolution)}}{100} = ${CM}
33
33
  $$
34
34
 
35
- `;
35
+ `;
36
36
  };
37
37
  const getEvolutionToCmQuestion = () => {
38
38
  const evolution = randint(-99, 101, [0]);
@@ -43,7 +43,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
43
43
  const question = {
44
44
  answer: getAnswer(identifiers),
45
45
  instruction: getInstruction(identifiers),
46
- keys: ["percent"],
46
+ keys: [],
47
47
  answerFormat: "tex",
48
48
  identifiers,
49
49
  hint: getHint(identifiers),
@@ -1,8 +1,13 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
+ indexSituation: number;
3
4
  total: number;
4
5
  lefties: number;
6
+ opts: Options;
5
7
  };
6
- export declare const findProportion: Exercise<Identifiers>;
8
+ type Options = {
9
+ isPercentSymbolRequired: boolean;
10
+ };
11
+ export declare const findProportion: Exercise<Identifiers, Options>;
7
12
  export {};
8
13
  //# 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,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAgGF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAehD,CAAC"}
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"}