math-exercises 3.0.22 → 3.0.24

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 (79) hide show
  1. package/lib/exercises/exercise.d.ts +2 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.js +1 -1
  4. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.js +60 -28
  6. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts +104 -0
  7. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts.map +1 -1
  8. package/lib/exercises/math/dataRepresentations/functionGraphReading.js +119 -94
  9. package/lib/exercises/math/dataRepresentations/index.d.ts +1 -0
  10. package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
  11. package/lib/exercises/math/dataRepresentations/index.js +1 -0
  12. package/lib/exercises/math/dataRepresentations/pieChartReading.d.ts +8 -0
  13. package/lib/exercises/math/dataRepresentations/pieChartReading.d.ts.map +1 -0
  14. package/lib/exercises/math/dataRepresentations/pieChartReading.js +171 -0
  15. package/lib/exercises/math/derivation/derivative/constanteDerivative.js +2 -2
  16. package/lib/exercises/math/derivation/derivative/secondDegreeDerivative.d.ts.map +1 -1
  17. package/lib/exercises/math/derivation/derivative/secondDegreeDerivative.js +5 -3
  18. package/lib/exercises/math/derivation/derivative/thirdDegreeDerivative.d.ts.map +1 -1
  19. package/lib/exercises/math/derivation/derivative/thirdDegreeDerivative.js +5 -3
  20. package/lib/exercises/math/functions/exponential/expFactorization.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/exponential/expFactorization.js +5 -2
  22. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -1
  23. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +3 -0
  24. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.js +2 -1
  25. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  26. package/lib/exercises/math/primitive/polynomialPrimitive.js +47 -16
  27. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +3 -3
  28. package/lib/exercises/math/probaStat/stats1var/averageList.js +1 -1
  29. package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.d.ts +8 -0
  30. package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.d.ts.map +1 -0
  31. package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.js +105 -0
  32. package/lib/exercises/math/probaStat/stats1var/index.d.ts +1 -0
  33. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  34. package/lib/exercises/math/probaStat/stats1var/index.js +1 -0
  35. package/lib/exercises/math/spaceGeometry/basis/index.d.ts +2 -0
  36. package/lib/exercises/math/spaceGeometry/basis/index.d.ts.map +1 -0
  37. package/lib/exercises/math/spaceGeometry/basis/index.js +1 -0
  38. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.d.ts +11 -0
  39. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.d.ts.map +1 -0
  40. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.js +167 -0
  41. package/lib/exercises/math/spaceGeometry/index.d.ts +1 -0
  42. package/lib/exercises/math/spaceGeometry/index.d.ts.map +1 -1
  43. package/lib/exercises/math/spaceGeometry/index.js +1 -0
  44. package/lib/exercises/math/trigonometry/calculateCosSinAndTan.d.ts.map +1 -1
  45. package/lib/exercises/math/trigonometry/calculateCosSinAndTan.js +38 -26
  46. package/lib/geogebra/colors.d.ts +1 -0
  47. package/lib/geogebra/colors.d.ts.map +1 -1
  48. package/lib/geogebra/colors.js +3 -0
  49. package/lib/geogebra/geogebraConstructor.d.ts +2 -0
  50. package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
  51. package/lib/geogebra/geogebraConstructor.js +6 -0
  52. package/lib/index.d.ts +12 -0
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/latexTester.d.ts.map +1 -1
  55. package/lib/latexTester.js +7 -1
  56. package/lib/math/geometry/angle.d.ts +2 -0
  57. package/lib/math/geometry/angle.d.ts.map +1 -1
  58. package/lib/math/geometry/angle.js +11 -4
  59. package/lib/math/geometry/spacePoint.d.ts +3 -1
  60. package/lib/math/geometry/spacePoint.d.ts.map +1 -1
  61. package/lib/math/geometry/spacePoint.js +19 -2
  62. package/lib/math/spaceGeometry/prism.d.ts +4 -0
  63. package/lib/math/spaceGeometry/prism.d.ts.map +1 -0
  64. package/lib/math/spaceGeometry/prism.js +3 -0
  65. package/lib/tree/nodes/algebraicNode.d.ts +4 -1
  66. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  67. package/lib/tree/nodes/functions/cosNode.d.ts +2 -2
  68. package/lib/tree/nodes/functions/cosNode.d.ts.map +1 -1
  69. package/lib/tree/nodes/functions/cosNode.js +4 -1
  70. package/lib/tree/nodes/functions/sinNode.d.ts +2 -2
  71. package/lib/tree/nodes/functions/sinNode.d.ts.map +1 -1
  72. package/lib/tree/nodes/functions/sinNode.js +4 -1
  73. package/lib/tree/nodes/functions/tanNode.d.ts +2 -2
  74. package/lib/tree/nodes/functions/tanNode.d.ts.map +1 -1
  75. package/lib/tree/nodes/functions/tanNode.js +4 -1
  76. package/lib/utils/strings/getLetter.d.ts +2 -0
  77. package/lib/utils/strings/getLetter.d.ts.map +1 -0
  78. package/lib/utils/strings/getLetter.js +3 -0
  79. package/package.json +1 -1
@@ -0,0 +1,171 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { blueExtraDark, colorWithOpacity, greenDark, orange, pinkDark, purpleDark, red, } from "../../../geogebra/colors.js";
4
+ import { GeogebraConstructor } from "../../../geogebra/geogebraConstructor.js";
5
+ import { Angle } from "../../../math/geometry/angle.js";
6
+ import { Point } from "../../../math/geometry/point.js";
7
+ import { randfloat } from "../../../math/utils/random/randfloat.js";
8
+ import { randint } from "../../../math/utils/random/randint.js";
9
+ import { round } from "../../../math/utils/round.js";
10
+ import { percentParser } from "../../../tree/parsers/percentParser.js";
11
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
12
+ import { getLetter } from "../../../utils/strings/getLetter.js";
13
+ const getPropositions = (n, { answer, ...identifiers }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ const { points } = identifiers;
17
+ const pointsObj = points.map((p, i) => new Point(getLetter(i, true), p[0], p[1]));
18
+ const angle = new Angle([pointsObj[1], new Point("O", 0, 0), pointsObj[0]]);
19
+ const angleValue = angle.evaluate();
20
+ tryToAddWrongProp(propositions, angleValue.frenchify() + "\\%");
21
+ tryToAddWrongProp(propositions, `${round(100 / points.length, 1)}\\%`);
22
+ tryToAddWrongProp(propositions, round((angleValue * 100) / 180, 2).frenchify() + "\\%");
23
+ while (propositions.length < n) {
24
+ tryToAddWrongProp(propositions, randfloat(8, 80, 2).frenchify() + "\\%");
25
+ }
26
+ return shuffleProps(propositions, n);
27
+ };
28
+ const getAnswer = (identifiers) => {
29
+ const { points } = identifiers;
30
+ const pointsObj = points.map((p, i) => new Point(getLetter(i, true), p[0], p[1]));
31
+ const angle = new Angle([pointsObj[1], new Point("O", 0, 0), pointsObj[0]]);
32
+ const angleValue = angle.evaluate();
33
+ return round((angleValue * 100) / 360, 2).frenchify() + "\\%";
34
+ };
35
+ const getInstruction = (identifiers) => {
36
+ return `Ci-dessous est donnée la répartition des communications effectuées par des lycéens avec leur téléphone portable.
37
+
38
+ Quelle proportion des communications effectuées, les communications audio représentent-elles ?
39
+
40
+ Arrondir au centième.`;
41
+ };
42
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
43
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
44
+ const getGGBOptions = (identifiers) => {
45
+ const { points, labels } = identifiers;
46
+ const pointsObj = points.map((p, i) => new Point(getLetter(i, true), p[0], p[1]));
47
+ // const reversedPoints = pointsObj.reverse();
48
+ const colors = [greenDark, orange, pinkDark, purpleDark, red];
49
+ const angle = new Angle([pointsObj[1], new Point("O", 0, 0), pointsObj[0]]);
50
+ const getMidPoint = (nextPoint, prevPoint) => {
51
+ const [xA, yA] = prevPoint;
52
+ const angleA = Math.atan2(yA, xA);
53
+ const [xB, yB] = nextPoint;
54
+ const angleB = Math.atan2(yB, xB);
55
+ // const angleM = (angleA + angleB) / 2;
56
+ const angleM = angleA +
57
+ Math.atan2(Math.sin(angleB - angleA), Math.cos(angleB - angleA)) / 2;
58
+ return [1.2 * Math.cos(angleM), 1.2 * Math.sin(angleM)];
59
+ return [
60
+ (1.2 * (xA + xB)) / Math.sqrt((xA + xB) ** 2 + (yA + yB) ** 2 + 0.1),
61
+ (1.2 * (yA + yB)) / Math.sqrt((xA + xB) ** 2 + (yA + yB) ** 2 + 0.1),
62
+ ];
63
+ };
64
+ const ggb = new GeogebraConstructor({
65
+ commands: [
66
+ `C = Circle((0,0), 1)`,
67
+ `SetLineThickness(C, 1)`,
68
+ // ...pointsObj.flatMap((p) => p.toGGBCommand()),
69
+ ...pointsObj.flatMap((p, i) => [
70
+ `C_${i} = CircularSector((0,0), ${pointsObj[(i + 1 + pointsObj.length) % pointsObj.length].toMathString()}, ${p.toMathString()})`,
71
+ `SetColor(C_${i}, "${colorWithOpacity(colors[i], 80)}")`,
72
+ `SetLineThickness(C_${i}, 0)`,
73
+ // `SetCaption(C_${i}, "$\\tiny \\text{${labels[i]}}$")`,
74
+ // `ShowLabel(C_${i}, true)`,
75
+ // `Text("$\\tiny \\text{${labels[i]
76
+ // .split(" ")
77
+ // .join("\\\\")}}$", (${getMidPoint(
78
+ // points[(i + 1 + points.length) % points.length],
79
+ // points[i],
80
+ // ).join(",")}), true, true, 1, 0)`,
81
+ `Text("$\\tiny \\text{${labels[i]
82
+ .split(" ")
83
+ .join("\\\\")}}$", (${getMidPoint(points[(i + 1 + points.length) % points.length], points[i]).join(",")}), true, true, 0, 0)`,
84
+ ]),
85
+ ...angle.toCommands({
86
+ showValue: points[1][0] === 1 ? false : true,
87
+ pointsAreNotBuilt: true,
88
+ thickness: 1,
89
+ color: blueExtraDark,
90
+ }),
91
+ ],
92
+ hideAxes: true,
93
+ hideGrid: true,
94
+ forbidShiftDragZoom: true,
95
+ });
96
+ return ggb.getOptions({
97
+ coords: [-1.4, 1.4, -1.4, 1.4],
98
+ });
99
+ };
100
+ const getKeys = (identifiers) => {
101
+ return ["percent"];
102
+ };
103
+ const isAnswerValid = (ans, { answer }) => {
104
+ try {
105
+ const parsed = percentParser(ans, true);
106
+ return parsed === answer;
107
+ }
108
+ catch (err) {
109
+ return handleVEAError(err);
110
+ }
111
+ };
112
+ const getPieChartReadingQuestion = (opts) => {
113
+ const labels = [
114
+ "communications audio",
115
+ "communications vidéo",
116
+ "messagerie électronique",
117
+ "autre",
118
+ "messages SMS",
119
+ ];
120
+ const getPointFromPrev = (prevPoint, degAngle) => {
121
+ const radAngle = -(degAngle * Math.PI) / 180;
122
+ return [
123
+ round(prevPoint[0] * Math.cos(radAngle) - prevPoint[1] * Math.sin(radAngle), 6),
124
+ round(prevPoint[0] * Math.sin(radAngle) + prevPoint[1] * Math.cos(radAngle), 6),
125
+ ];
126
+ };
127
+ const angles = [5 * randint(6, 30)];
128
+ for (let i = 0; i < labels.length - 1; i++) {
129
+ const remaining = 360 - angles.reduce((acc, curr) => acc + curr);
130
+ if (i === labels.length - 1)
131
+ angles.push(remaining);
132
+ else
133
+ angles.push(randint(30, Math.min(100, remaining - 30)));
134
+ }
135
+ const points = [[0, 1]];
136
+ for (let i = 0; i < angles.length - 1; i++) {
137
+ points.push(getPointFromPrev(points[i], angles[i]));
138
+ }
139
+ const identifiers = {
140
+ labels,
141
+ points,
142
+ };
143
+ const question = {
144
+ answer: getAnswer(identifiers),
145
+ instruction: getInstruction(identifiers),
146
+ keys: getKeys(identifiers),
147
+ answerFormat: "tex",
148
+ identifiers,
149
+ // hint: getHint(identifiers),
150
+ // correction: getCorrection(identifiers),
151
+ ggbOptions: getGGBOptions(identifiers),
152
+ };
153
+ return question;
154
+ };
155
+ export const pieChartReading = {
156
+ id: "pieChartReading",
157
+ label: "Convertir un angle en pourcentage dans un diagramme circulaire",
158
+ isSingleStep: true,
159
+ generator: (nb, opts) => getDistinctQuestions(() => getPieChartReadingQuestion(opts), nb),
160
+ qcmTimer: 60,
161
+ freeTimer: 60,
162
+ getPropositions,
163
+ isAnswerValid,
164
+ subject: "Mathématiques",
165
+ // getHint,
166
+ // getCorrection,
167
+ getInstruction,
168
+ getAnswer,
169
+ getGGBOptions,
170
+ hasGeogebra: true,
171
+ };
@@ -12,10 +12,10 @@ const getAnswer = () => "0";
12
12
  const getInstruction = (identifiers) => {
13
13
  const tex = identifiers.tex;
14
14
  return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par :
15
-
15
+
16
16
  $$
17
17
  f(x) = ${tex}
18
- $$.`;
18
+ $$`;
19
19
  };
20
20
  export const getConstanteDerivative = () => {
21
21
  const c = NombreConstructor.random();
@@ -1 +1 @@
1
- {"version":3,"file":"secondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA4CF,eAAO,MAAM,yBAAyB,EAAE,iBAAiB,CAAC,WAAW,CAgBpE,CAAC;AAEF,eAAO,MAAM,qCAAqC,EAAE,YAAY,CAC9D,WAAW,CA+BZ,CAAC;AACF,eAAO,MAAM,mCAAmC,EAAE,GAAG,CAAC,WAAW,CAQhE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAyBxD,CAAC"}
1
+ {"version":3,"file":"secondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA8CF,eAAO,MAAM,yBAAyB,EAAE,iBAAiB,CAAC,WAAW,CAgBpE,CAAC;AAEF,eAAO,MAAM,qCAAqC,EAAE,YAAY,CAC9D,WAAW,CA+BZ,CAAC;AACF,eAAO,MAAM,mCAAmC,EAAE,GAAG,CAAC,WAAW,CAQhE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAyBxD,CAAC"}
@@ -40,9 +40,11 @@ $$
40
40
  };
41
41
  const getInstruction = (identifiers) => {
42
42
  const polynomial = new Polynomial(identifiers.coefficients);
43
- return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) = ${polynomial
44
- .toTree()
45
- .toTex()}$.`;
43
+ return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par :
44
+
45
+ $$
46
+ f(x) = ${polynomial.toTree().toTex()}
47
+ $$`;
46
48
  };
47
49
  export const getSecondDegreeDerivative = () => {
48
50
  const coefficients = [randint(-9, 10), randint(-9, 10), randint(-9, 10, [0])];
@@ -1 +1 @@
1
- {"version":3,"file":"thirdDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/thirdDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAIJ,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA4CF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,WAAW,CAmBnE,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,YAAY,CAAC,WAAW,CAwC1E,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,GAAG,CAAC,WAAW,CAe/D,CAAC;AACF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CA0BvD,CAAC"}
1
+ {"version":3,"file":"thirdDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/thirdDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAIJ,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA8CF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,WAAW,CAmBnE,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,YAAY,CAAC,WAAW,CAwC1E,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,GAAG,CAAC,WAAW,CAe/D,CAAC;AACF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CA0BvD,CAAC"}
@@ -36,9 +36,11 @@ $$
36
36
  };
37
37
  const getInstruction = (identifiers) => {
38
38
  const polynomial = new Polynomial(identifiers.coefficients);
39
- return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) = ${polynomial
40
- .toTree()
41
- .toTex()}$.`;
39
+ return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par :
40
+
41
+ $$
42
+ f(x) = ${polynomial.toTree().toTex()}
43
+ $$`;
42
44
  };
43
45
  const getAnswer = (identifiers) => {
44
46
  const polynomial = new Polynomial(identifiers.coefficients);
@@ -1 +1 @@
1
- {"version":3,"file":"expFactorization.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expFactorization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAwJF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}
1
+ {"version":3,"file":"expFactorization.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expFactorization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA6JF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}
@@ -3,12 +3,13 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  // import { expressionVEA } from "#root/exercises/vea/expressionVEA.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { add } from "../../../../tree/nodes/operators/addNode.js";
6
- import { exp } from "../../../../tree/nodes/functions/expNode.js";
6
+ import { exp, isExpNode } from "../../../../tree/nodes/functions/expNode.js";
7
7
  import { isMultiplyNode, multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  // import { variable } from "../../../../tree/nodes/variables/variableNode.js";
9
9
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
10
  import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
11
  import { AffineConstructor } from "../../../../math/polynomials/affine.js";
12
+ import { isOppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
12
13
  const getPropositions = (n, { answer, ...identifiers }) => {
13
14
  const propositions = [];
14
15
  const { uA } = identifiers;
@@ -82,7 +83,9 @@ const isAnswerValid = (ans, { answer, ...identifiers }) => {
82
83
  const parsed = parseAlgebraic(ans);
83
84
  if (!parsed)
84
85
  return false;
85
- if (!isMultiplyNode(parsed))
86
+ if (!isMultiplyNode(parsed) &&
87
+ !isExpNode(parsed) &&
88
+ !(isOppositeNode(parsed) && isExpNode(parsed.child)))
86
89
  return false;
87
90
  const simp = parsed.simplify({
88
91
  forbidFactorize: true,
@@ -1 +1 @@
1
- {"version":3,"file":"pythagoreOrThales.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidian/pythagoreOrThales.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAkBtC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IAEzB,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;CAQnB,CAAC;AA+MF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAkBnD,CAAC"}
1
+ {"version":3,"file":"pythagoreOrThales.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidian/pythagoreOrThales.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAkBtC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IAEzB,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;CAQnB,CAAC;AA+MF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAqBnD,CAAC"}
@@ -191,6 +191,9 @@ export const pythagoreOrThales = {
191
191
  getGGBOptions,
192
192
  hasGeogebra: true,
193
193
  answerType: "QCU",
194
+ pdfOptions: {
195
+ shouldSpreadPropositions: true,
196
+ },
194
197
  };
195
198
  const getSubTriangle = ({ triangle, insidePointsNames, ratio, isPapillon, }) => {
196
199
  const [A, B, C] = triangle.points;
@@ -149,9 +149,10 @@ const getGGBOptions = (identifiers) => {
149
149
  shapeObject.drawSidesDecoration();
150
150
  }
151
151
  const cmds = shapeObject.toGGBCommands();
152
+ shapeObject.points;
152
153
  const ggb = new GeogebraConstructor({ hideAxes: true, hideGrid: true });
153
154
  ggb.commands = cmds;
154
- return ggb.getOptions({ coords: [-10, 10, -10, 10] });
155
+ return ggb.getOptions({ coords: ggb.getCoordsForPoints(shapeObject.points) });
155
156
  };
156
157
  const getKeys = (identifiers) => {
157
158
  return [];
@@ -1 +1 @@
1
- {"version":3,"file":"polynomialPrimitive.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/primitive/polynomialPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,WAAW,CAiBjE,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,YAAY,CAAC,WAAW,CAexE,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,GAAG,CAAC,WAAW,CAa7D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAarD,CAAC"}
1
+ {"version":3,"file":"polynomialPrimitive.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/primitive/polynomialPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAiBF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,WAAW,CAcjE,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,YAAY,CAAC,WAAW,CAexE,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,GAAG,CAAC,WAAW,CA8B7D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAWrD,CAAC"}
@@ -2,19 +2,34 @@ import { addValidProp, tryToAddWrongProp, } from "../../../exercises/exercise.js
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Polynomial, PolynomialConstructor, } from "../../../math/polynomials/polynomial.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
5
6
  import { shuffle } from "../../../utils/alea/shuffle.js";
7
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
8
+ const getInstruction = (identifiers) => {
9
+ const polynomial = new Polynomial(identifiers.coeffs);
10
+ return `Déterminer la forme générale des primitives de la fonction polynomiale $f$ définie par :
11
+
12
+ $$
13
+ f(x) = ${polynomial.toTex()}
14
+ $$`;
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const polynomial = new Polynomial(identifiers.coeffs);
18
+ const integralPolynomial = polynomial.integrateToNode();
19
+ const answer = `${integralPolynomial.toTex()}`;
20
+ return answer;
21
+ };
6
22
  export const getPolynomialPrimitive = () => {
7
23
  const degree = randint(1, 4);
8
24
  const polynomial = PolynomialConstructor.randomWithOrder(degree);
9
- const integralPolynomial = polynomial.integrateToNode();
10
- const answer = `${integralPolynomial.toTex()}`;
25
+ const identifiers = { coeffs: polynomial.coefficients };
11
26
  const question = {
12
- instruction: `Déterminer la forme générale des primitives de la fonction polynomiale $f$ définie par $f(x) = ${polynomial.toTex()}$.`,
27
+ instruction: getInstruction(identifiers),
13
28
  startStatement: `F(x)`,
14
- answer,
29
+ answer: getAnswer(identifiers),
15
30
  keys: ["x", "C"],
16
31
  answerFormat: "tex",
17
- identifiers: { coeffs: polynomial.coefficients },
32
+ identifiers,
18
33
  };
19
34
  return question;
20
35
  };
@@ -28,22 +43,38 @@ export const getPolynomialPrimitivePropositions = (n, { answer, coeffs }) => {
28
43
  }
29
44
  return shuffle(propositions);
30
45
  };
31
- export const isPolynomialPrimitiveAnswerValid = (ans, { coeffs }) => {
32
- const opts = {
33
- allowFractionToDecimal: true,
34
- forbidPowerToProduct: true,
35
- };
36
- const polynomial = new Polynomial(coeffs);
37
- const integralPolynomial = polynomial.integrateToNode(opts);
38
- const texs = integralPolynomial.toAllValidTexs(opts);
39
- return texs.includes(ans);
46
+ export const isPolynomialPrimitiveAnswerValid = (ans, { coeffs, answer }) => {
47
+ try {
48
+ const parsed = parseAlgebraic(ans);
49
+ if (!parsed)
50
+ return false;
51
+ // console.log(
52
+ // parsed
53
+ // .simplify({
54
+ // towardsDistribute: true,
55
+ // forbidFactorize: true,
56
+ // decimalToFractions: true,
57
+ // forceDistributeFractions: true,
58
+ // forceIsolateMonomCoeffs: true,
59
+ // })
60
+ // .toTex(),
61
+ // );
62
+ return (parsed
63
+ .simplify({
64
+ towardsDistribute: true,
65
+ forbidFactorize: true,
66
+ forceDistributeFractions: true,
67
+ })
68
+ .toTex() === answer);
69
+ }
70
+ catch (err) {
71
+ return handleVEAError(err);
72
+ }
40
73
  };
41
74
  export const polynomialPrimitive = {
42
75
  id: "polynomialPrimitive",
43
76
  connector: "=",
44
77
  label: "Primitive d'une fonction polynomiale",
45
- levels: ["TermSpé", "MathComp"],
46
- sections: ["Primitives"],
47
78
  isSingleStep: false,
48
79
  generator: (nb) => getDistinctQuestions(getPolynomialPrimitive, nb),
49
80
  qcmTimer: 60,
@@ -46,9 +46,9 @@ const getAnswer = (identifiers) => {
46
46
  };
47
47
  const getProbaFromTableWithContextQuestion = () => {
48
48
  const aCapB = randint(1, 20);
49
- const aCapBBarre = randint(1, 20);
50
- const aBarreCapB = randint(1, 20);
51
- const aBarreCapBBarre = randint(1, 20);
49
+ const aCapBBarre = randint(1, 20, [aCapB]);
50
+ const aBarreCapB = randint(1, 20, [aCapB, aCapBBarre]);
51
+ const aBarreCapBBarre = randint(1, 20, [aCapB, aCapBBarre, aBarreCapB]);
52
52
  const total = aBarreCapB + aBarreCapBBarre + aCapB + aCapBBarre;
53
53
  const aTotal = aCapB + aCapBBarre;
54
54
  const bTotal = aCapB + aBarreCapB;
@@ -31,7 +31,7 @@ const getAverageListQuestion = () => {
31
31
  keys: [],
32
32
  answerFormat: "tex",
33
33
  identifiers,
34
- hint: "La moyenne d'une liste de valeurs est la somme de ses valeurs divisé par le nombre de valeurs.",
34
+ hint: "La moyenne d'une liste de valeurs est la somme des valeurs divisée par le nombre de valeurs.",
35
35
  correction: `
36
36
  On additionne toutes les valeurs :
37
37
 
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ indicatorAsked: string;
4
+ values: number[];
5
+ };
6
+ export declare const choseReasoningForIndicator: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=choseReasoningForIndicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choseReasoningForIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/choseReasoningForIndicator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAuHF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAgB5D,CAAC"}
@@ -0,0 +1,105 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
5
+ import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
6
+ import { random } from "../../../../utils/alea/random.js";
7
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
8
+ import { average } from "../../../../utils/average.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ const getPropositions = (n, { answer, ...identifiers }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer, "raw");
13
+ const { values, indicatorAsked } = identifiers;
14
+ const avg = average(values);
15
+ const max = Math.max(...values);
16
+ tryToAddWrongProp(propositions, `La ${indicatorAsked} est $${avg}$ car $\\frac{${operatorComposition(AddNode, values.map((v) => v.toTree())).toTex()}}{${values.length}} = ${avg}$`, "raw");
17
+ tryToAddWrongProp(propositions, `La ${indicatorAsked} est $${avg}$ car c'est la moitié de $${max}$.`, "raw");
18
+ tryToAddWrongProp(propositions, `La ${indicatorAsked} est $${avg}$ car la valeur $${avg}$ est au milieu de la série.`, "raw");
19
+ tryToAddWrongProp(propositions, `La ${indicatorAsked} est $${avg}$ car il y a dans la série autant de valeurs inférieures à $${avg}$ que de valeurs supérieures à $${avg}$.`, "raw");
20
+ return shuffleProps(propositions, n);
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ const { values, indicatorAsked } = identifiers;
24
+ const avg = average(values);
25
+ return indicatorAsked === "moyenne"
26
+ ? `La moyenne est $${avg}$ car $\\frac{${operatorComposition(AddNode, values.map((v) => v.toTree())).toTex()}}{${values.length}} = ${avg}$`
27
+ : `La médiane est $${avg}$ car il y a dans la série autant de valeurs inférieures à $${avg}$ que de valeurs supérieures à $${avg}$.`;
28
+ };
29
+ const getInstruction = (identifiers) => {
30
+ const { values, indicatorAsked } = identifiers;
31
+ const avg = average(values);
32
+ return `Voici une série de valeurs :
33
+
34
+ $$
35
+ ${values.join("\\ ; \\ ")}
36
+ $$
37
+
38
+ La ${indicatorAsked} de cette série est $${avg}$.
39
+
40
+ Quelle est la justification correcte ?`;
41
+ };
42
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
43
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
44
+ const getKeys = (identifiers) => {
45
+ return [];
46
+ };
47
+ const isAnswerValid = (ans, { answer }) => {
48
+ try {
49
+ throw Error("VEA not implemented");
50
+ }
51
+ catch (err) {
52
+ return handleVEAError(err);
53
+ }
54
+ };
55
+ const getChoseReasoningForIndicatorQuestion = (ops) => {
56
+ const max = 2 * randint(5, 20);
57
+ const x = max / 2;
58
+ let otherValues = [];
59
+ const miserablyDo = () => {
60
+ const b = randint(x + 1, 2 * x);
61
+ const c = randint(x + 1, 2 * x);
62
+ let remaining = 4 * x - b - c;
63
+ const d = randint(0, Math.min(remaining + 1, x));
64
+ remaining -= d;
65
+ const e = randint(0, Math.min(remaining + 1, x));
66
+ remaining -= e;
67
+ const f = remaining;
68
+ otherValues = [max, b, c, d, e, f];
69
+ };
70
+ do {
71
+ miserablyDo();
72
+ } while (otherValues[otherValues.length - 1] >= x);
73
+ const shuffled = shuffle(otherValues);
74
+ shuffled.splice(3, 0, x);
75
+ const identifiers = {
76
+ values: shuffled,
77
+ indicatorAsked: random(["moyenne", "médiane"]),
78
+ };
79
+ const question = {
80
+ answer: getAnswer(identifiers),
81
+ instruction: getInstruction(identifiers),
82
+ keys: getKeys(identifiers),
83
+ answerFormat: "raw",
84
+ identifiers,
85
+ // hint: getHint(identifiers),
86
+ // correction: getCorrection(identifiers),
87
+ };
88
+ return question;
89
+ };
90
+ export const choseReasoningForIndicator = {
91
+ id: "choseReasoningForIndicator",
92
+ label: "Trouver le bon raisonnement pour déterminer une moyenne/une médiane",
93
+ isSingleStep: true,
94
+ generator: (nb, opts) => getDistinctQuestions(() => getChoseReasoningForIndicatorQuestion(opts), nb),
95
+ qcmTimer: 60,
96
+ freeTimer: 60,
97
+ getPropositions,
98
+ isAnswerValid,
99
+ subject: "Mathématiques",
100
+ getInstruction,
101
+ // getHint,
102
+ // getCorrection,
103
+ getAnswer,
104
+ answerType: "QCU",
105
+ };
@@ -12,4 +12,5 @@ export * from "./standardDeviationList.js";
12
12
  export * from "./standardDeviationTable.js";
13
13
  export * from "./interquartilesList.js";
14
14
  export * from "./interquartilesTable.js";
15
+ export * from "./choseReasoningForIndicator.js";
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC"}
@@ -12,3 +12,4 @@ export * from "./standardDeviationList.js";
12
12
  export * from "./standardDeviationTable.js";
13
13
  export * from "./interquartilesList.js";
14
14
  export * from "./interquartilesTable.js";
15
+ export * from "./choseReasoningForIndicator.js";
@@ -0,0 +1,2 @@
1
+ export * from "./spaceCoordinatesInPrism.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/basis/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./spaceCoordinatesInPrism.js";
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ l: number;
4
+ L: number;
5
+ h: number;
6
+ askedPoint: string;
7
+ givenPoints: string[];
8
+ };
9
+ export declare const spaceCoordinatesInPrism: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=spaceCoordinatesInPrism.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spaceCoordinatesInPrism.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAyKF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAiBzD,CAAC"}