math-exercises 3.0.99 → 3.0.101

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 (114) hide show
  1. package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.d.ts +9 -0
  2. package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.d.ts.map +1 -0
  3. package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.js +156 -0
  4. package/lib/exercises/math/geometry/areas/index.d.ts +1 -0
  5. package/lib/exercises/math/geometry/areas/index.d.ts.map +1 -1
  6. package/lib/exercises/math/geometry/areas/index.js +1 -0
  7. package/lib/exercises/math/geometry/euclidian/index.d.ts +1 -0
  8. package/lib/exercises/math/geometry/euclidian/index.d.ts.map +1 -1
  9. package/lib/exercises/math/geometry/euclidian/index.js +1 -0
  10. package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.d.ts +8 -0
  11. package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.d.ts.map +1 -0
  12. package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.js +197 -0
  13. package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map +1 -1
  14. package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +45 -17
  15. package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.d.ts +9 -0
  16. package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.d.ts.map +1 -0
  17. package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.js +155 -0
  18. package/lib/exercises/math/geometry/pythagore/index.d.ts +1 -0
  19. package/lib/exercises/math/geometry/pythagore/index.d.ts.map +1 -1
  20. package/lib/exercises/math/geometry/pythagore/index.js +2 -0
  21. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +1 -1
  22. package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts +9 -0
  23. package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts.map +1 -0
  24. package/lib/exercises/math/geometry/pythagore/triangleHeight.js +105 -0
  25. package/lib/exercises/math/geometry/quadrilaterals/index.d.ts +2 -0
  26. package/lib/exercises/math/geometry/quadrilaterals/index.d.ts.map +1 -1
  27. package/lib/exercises/math/geometry/quadrilaterals/index.js +2 -0
  28. package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.d.ts +11 -0
  29. package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.d.ts.map +1 -0
  30. package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.js +140 -0
  31. package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.d.ts +11 -0
  32. package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.d.ts.map +1 -0
  33. package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.js +144 -0
  34. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts +9 -0
  35. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts.map +1 -0
  36. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.js +201 -0
  37. package/lib/exercises/math/geometry/vectors/colinearity/determinant.d.ts +8 -0
  38. package/lib/exercises/math/geometry/vectors/colinearity/determinant.d.ts.map +1 -0
  39. package/lib/exercises/math/geometry/vectors/colinearity/determinant.js +101 -0
  40. package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts +2 -0
  41. package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts.map +1 -1
  42. package/lib/exercises/math/geometry/vectors/colinearity/index.js +2 -0
  43. package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.d.ts +8 -0
  44. package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.d.ts.map +1 -0
  45. package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.js +78 -0
  46. package/lib/exercises/math/geometry/vectors/constructions/index.d.ts +8 -0
  47. package/lib/exercises/math/geometry/vectors/constructions/index.d.ts.map +1 -0
  48. package/lib/exercises/math/geometry/vectors/constructions/index.js +7 -0
  49. package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.d.ts +9 -0
  50. package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.d.ts.map +1 -0
  51. package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.js +179 -0
  52. package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.d.ts +12 -0
  53. package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.d.ts.map +1 -0
  54. package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.js +171 -0
  55. package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.d.ts +10 -0
  56. package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.d.ts.map +1 -0
  57. package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.js +135 -0
  58. package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.d.ts +11 -0
  59. package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.d.ts.map +1 -0
  60. package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.js +163 -0
  61. package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.d.ts +11 -0
  62. package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.d.ts.map +1 -0
  63. package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.js +148 -0
  64. package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.d.ts +11 -0
  65. package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.d.ts.map +1 -0
  66. package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.js +160 -0
  67. package/lib/exercises/math/geometry/vectors/coordinatesReading.d.ts.map +1 -1
  68. package/lib/exercises/math/geometry/vectors/coordinatesReading.js +63 -14
  69. package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.d.ts +3 -0
  70. package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.d.ts.map +1 -1
  71. package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.js +63 -2
  72. package/lib/exercises/math/geometry/vectors/index.d.ts +4 -8
  73. package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
  74. package/lib/exercises/math/geometry/vectors/index.js +4 -8
  75. package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.d.ts +14 -0
  76. package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.d.ts.map +1 -0
  77. package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.js +78 -0
  78. package/lib/exercises/math/geometry/vectors/parallelogram/index.d.ts +4 -0
  79. package/lib/exercises/math/geometry/vectors/parallelogram/index.d.ts.map +1 -0
  80. package/lib/exercises/math/geometry/vectors/parallelogram/index.js +3 -0
  81. package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.d.ts +8 -0
  82. package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.d.ts.map +1 -0
  83. package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.js +193 -0
  84. package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.d.ts +14 -0
  85. package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.d.ts.map +1 -0
  86. package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.js +116 -0
  87. package/lib/exercises/math/geometry/vectors/translationFromPicture.d.ts +8 -0
  88. package/lib/exercises/math/geometry/vectors/translationFromPicture.d.ts.map +1 -0
  89. package/lib/exercises/math/geometry/vectors/translationFromPicture.js +104 -0
  90. package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts +8 -0
  91. package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts.map +1 -0
  92. package/lib/exercises/math/geometry/vectors/vectorRepresentative.js +161 -0
  93. package/lib/exercises/math/geometry/volumes/index.d.ts +1 -0
  94. package/lib/exercises/math/geometry/volumes/index.d.ts.map +1 -1
  95. package/lib/exercises/math/geometry/volumes/index.js +1 -0
  96. package/lib/exercises/math/geometry/volumes/variableVolume.d.ts +9 -0
  97. package/lib/exercises/math/geometry/volumes/variableVolume.d.ts.map +1 -0
  98. package/lib/exercises/math/geometry/volumes/variableVolume.js +203 -0
  99. package/lib/index.d.ts +89 -40
  100. package/lib/index.d.ts.map +1 -1
  101. package/lib/math/geometry/point.d.ts +1 -0
  102. package/lib/math/geometry/point.d.ts.map +1 -1
  103. package/lib/math/geometry/point.js +3 -0
  104. package/lib/math/geometry/vector.d.ts +1 -0
  105. package/lib/math/geometry/vector.d.ts.map +1 -1
  106. package/lib/math/geometry/vector.js +3 -0
  107. package/lib/playground.d.ts.map +1 -1
  108. package/lib/tests/pdfs/quizPdfPreambule.js +1 -1
  109. package/lib/tests/questionTest.d.ts.map +1 -1
  110. package/lib/tests/questionTest.js +4 -4
  111. package/lib/tree/nodes/functions/sqrtNode.d.ts +1 -1
  112. package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
  113. package/lib/tree/nodes/functions/sqrtNode.js +8 -2
  114. package/package.json +1 -1
@@ -0,0 +1,193 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
4
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
5
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
6
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
7
+ import { randomLetter } from "../../../../../utils/strings/randomLetter.js";
8
+ const getPropositions = (n, { answer, isAskingParallelogramName, pointNames }) => {
9
+ const propositions = [];
10
+ addValidProp(propositions, answer);
11
+ while (propositions.length < n) {
12
+ if (isAskingParallelogramName) {
13
+ const reversed = answer.split("").reverse().join("");
14
+ let fake = "";
15
+ do {
16
+ fake = shuffle(pointNames).join("");
17
+ } while (isParaNameValid(fake, answer));
18
+ tryToAddWrongProp(propositions, fake);
19
+ }
20
+ else {
21
+ let vec1 = "";
22
+ let vec2 = "";
23
+ do {
24
+ const shuffled = shuffle(pointNames);
25
+ vec1 = shuffled[0] + shuffled[1];
26
+ vec2 = shuffled[2] + shuffled[3];
27
+ } while (isVectorEqualityValid(vec1, vec2, pointNames.join("")));
28
+ tryToAddWrongProp(propositions, `\\overrightarrow{${vec1}}=\\overrightarrow{${vec2}}`);
29
+ }
30
+ }
31
+ return shuffleProps(propositions, n);
32
+ };
33
+ const isParaNameValid = (name, expectedName) => {
34
+ //exemple ABCDABCD contient bien tous les noms possibles dans un sens, et DCBADCBA dans l'autre
35
+ const reversed = expectedName.split("").reverse().join("");
36
+ return ((expectedName + expectedName).includes(name) ||
37
+ (reversed + reversed).includes(name));
38
+ };
39
+ const isVectorEqualityValid = (vec1, vec2, expectedName) => {
40
+ const reversed = expectedName.split("").reverse().join("");
41
+ const name = vec1 + vec2.split("").reverse().join("");
42
+ return ((expectedName + expectedName).includes(name) ||
43
+ (reversed + reversed).includes(name));
44
+ };
45
+ const getAnswer = (identifiers) => {
46
+ const { isAskingParallelogramName, pointNames } = identifiers;
47
+ if (isAskingParallelogramName) {
48
+ return pointNames.join("");
49
+ }
50
+ else {
51
+ const vec1 = `\\overrightarrow{${pointNames.slice(0, 2).join("")}}`;
52
+ const vec2 = `\\overrightarrow{${pointNames
53
+ .slice(2, 4)
54
+ .reverse()
55
+ .join("")}}`;
56
+ return `${vec1}=${vec2}`;
57
+ }
58
+ };
59
+ const getInstruction = (identifiers) => {
60
+ const { isAskingParallelogramName, pointNames } = identifiers;
61
+ if (isAskingParallelogramName) {
62
+ const vec1 = `\\overrightarrow{${pointNames.slice(0, 2).join("")}}`;
63
+ const vec2 = `\\overrightarrow{${pointNames
64
+ .slice(2, 4)
65
+ .reverse()
66
+ .join("")}}`;
67
+ return `Soient deux vecteurs $${vec1}$ et $${vec2}$ tels que $${vec1} = ${vec2}$.
68
+
69
+ Donner le nom du parallélogramme formé par ces vecteurs.`;
70
+ }
71
+ return `Soit un parallélogramme $${pointNames.join("")}$.
72
+
73
+ Donner une égalité entre deux vecteurs issus de ce parallélogramme.`;
74
+ };
75
+ const getHint = (identifiers) => {
76
+ return `$ABCD$ est un parallélogramme si et seulemtne si les vecteurs $\\overrightarrow{AB}$ et $\\overrightarrow{DC}$ sont égaux.`;
77
+ };
78
+ const getCorrection = (identifiers) => {
79
+ const { isAskingParallelogramName, pointNames } = identifiers;
80
+ if (isAskingParallelogramName) {
81
+ return `On sait que $ABCD$ est un parallélogramme si et seulement si les vecteurs $\\overrightarrow{AB}$ et $\\overrightarrow{DC}$ sont égaux.
82
+
83
+ Ici, le quadrilatère $${pointNames.join("")}$ est donc un parallélogramme.`;
84
+ }
85
+ return `On sait que $ABCD$ est un parallélogramme si et seulement si les vecteurs $\\overrightarrow{AB}$ et $\\overrightarrow{DC}$ sont égaux.
86
+
87
+ Ici, les vecteurs $${pointNames.slice(0, 2).join("")}$ et $${pointNames
88
+ .slice(2, 4)
89
+ .reverse()
90
+ .join("")}$ sont donc égaux.
91
+ `;
92
+ };
93
+ const getCorrectionGGBOptions = (identifiers) => {
94
+ const { isAskingParallelogramName, pointNames } = identifiers;
95
+ const ggb = new GeogebraConstructor({
96
+ commands: [
97
+ `${pointNames[0]} = (-1, 0)`,
98
+ `ShowLabel(${pointNames[0]}, true)`,
99
+ `SetFixed(${pointNames[0]}, true)`,
100
+ `${pointNames[1]} = (1,2)`,
101
+ `ShowLabel(${pointNames[1]}, true)`,
102
+ `SetFixed(${pointNames[1]}, true)`,
103
+ `${pointNames[2]} = (2, 0)`,
104
+ `ShowLabel(${pointNames[2]}, true)`,
105
+ `SetFixed(${pointNames[2]}, true)`,
106
+ `${pointNames[3]} = (0, -2)`,
107
+ `ShowLabel(${pointNames[3]}, true)`,
108
+ `SetFixed(${pointNames[3]}, true)`,
109
+ `Polygon(${pointNames.join(",")})`,
110
+ `Vector(${pointNames[0]}, ${pointNames[1]})`,
111
+ `Vector(${pointNames[3]}, ${pointNames[2]})`,
112
+ ],
113
+ hideAxes: true,
114
+ });
115
+ return ggb.getOptions({
116
+ coords: [-2, 3, -3, 3],
117
+ });
118
+ };
119
+ const getKeys = (identifiers) => {
120
+ const { isAskingParallelogramName, pointNames } = identifiers;
121
+ const sorted = [...pointNames].sort((a, b) => a.localeCompare(b));
122
+ if (isAskingParallelogramName) {
123
+ return sorted;
124
+ }
125
+ else {
126
+ return ["overrightarrow", "equal", ...sorted];
127
+ }
128
+ return [];
129
+ };
130
+ const isAnswerValid = (ans, { answer, isAskingParallelogramName, pointNames }) => {
131
+ try {
132
+ if (isAskingParallelogramName) {
133
+ if (ans.length !== 4)
134
+ return false;
135
+ return isParaNameValid(ans, answer);
136
+ }
137
+ else {
138
+ //on crée le nom du parallélogramme ici de l'égalité et on check comme au dessus
139
+ let splitted = ans.split("=");
140
+ if (splitted.length !== 2)
141
+ return false;
142
+ if (splitted.some((e) => !e.startsWith("\\overrightarrow")))
143
+ return false;
144
+ splitted = splitted.map((e) => e.replace("\\overrightarrow{", "").replace("}", ""));
145
+ if (splitted.some((e) => e.length !== 2))
146
+ return false;
147
+ return isVectorEqualityValid(splitted[0], splitted[1], pointNames.join(""));
148
+ }
149
+ }
150
+ catch (err) {
151
+ return handleVEAError(err);
152
+ }
153
+ };
154
+ const getParallelogramCriterionQuestion = (ops) => {
155
+ const A = randomLetter(true);
156
+ const B = randomLetter(true, [A]);
157
+ const C = randomLetter(true, [A, B]);
158
+ const D = randomLetter(true, [A, B, C]);
159
+ const identifiers = {
160
+ isAskingParallelogramName: coinFlip(),
161
+ pointNames: [A, B, C, D],
162
+ };
163
+ return getQuestionFromIdentifiers(identifiers);
164
+ };
165
+ const getQuestionFromIdentifiers = (identifiers) => {
166
+ return {
167
+ answer: getAnswer(identifiers),
168
+ instruction: getInstruction(identifiers),
169
+ keys: getKeys(identifiers),
170
+ answerFormat: "tex",
171
+ identifiers,
172
+ hint: getHint(identifiers),
173
+ correction: getCorrection(identifiers),
174
+ correctionGgbOptions: getCorrectionGGBOptions(identifiers),
175
+ };
176
+ };
177
+ export const parallelogramCriterion = {
178
+ id: "parallelogramCriterion",
179
+ label: "Utiliser la propriété caractéristique du parallélogramme",
180
+ isSingleStep: true,
181
+ generator: (nb, opts) => getDistinctQuestions(() => getParallelogramCriterionQuestion(opts), nb),
182
+ qcmTimer: 60,
183
+ freeTimer: 60,
184
+ getPropositions,
185
+ isAnswerValid,
186
+ subject: "Mathématiques",
187
+ getInstruction,
188
+ getHint,
189
+ getCorrection,
190
+ getAnswer,
191
+ getQuestionFromIdentifiers,
192
+ hasHintAndCorrection: true,
193
+ };
@@ -0,0 +1,14 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ xA: number;
4
+ xB: number;
5
+ xC: number;
6
+ xD: number;
7
+ yA: number;
8
+ yB: number;
9
+ yC: number;
10
+ yD: number;
11
+ };
12
+ export declare const parallelogramViaEqualVectors: Exercise<Identifiers>;
13
+ export {};
14
+ //# sourceMappingURL=parallelogramViaEqualVectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parallelogramViaEqualVectors.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4GF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAa9D,CAAC"}
@@ -0,0 +1,116 @@
1
+ import { addValidProp, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Point, PointConstructor } from "../../../../../math/geometry/point.js";
4
+ import { Vector, VectorConstructor } from "../../../../../math/geometry/vector.js";
5
+ import { substract, } from "../../../../../tree/nodes/operators/substractNode.js";
6
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
7
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
8
+ const getInstruction = (identifiers) => {
9
+ const A = new Point("A", identifiers.xA, identifiers.yA);
10
+ const B = new Point("B", identifiers.xB, identifiers.yB);
11
+ const C = new Point("C", identifiers.xC, identifiers.yC);
12
+ const D = new Point("D", identifiers.xD, identifiers.yD);
13
+ return `Soient les points $${A.toTexWithCoords()}$, $${B.toTexWithCoords()}$, $${C.toTexWithCoords()}$ et $${D.toTexWithCoords()}$.
14
+
15
+ $ABCD$ est-il un parallélogramme ?`;
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const A = new Point("A", identifiers.xA, identifiers.yA);
19
+ const B = new Point("B", identifiers.xB, identifiers.yB);
20
+ const C = new Point("C", identifiers.xC, identifiers.yC);
21
+ const D = new Point("D", identifiers.xD, identifiers.yD);
22
+ const vec1 = VectorConstructor.fromPoints(A, B);
23
+ const vec2 = VectorConstructor.fromPoints(D, C);
24
+ const isParallelogram = vec1.equals(vec2);
25
+ const answer = isParallelogram ? "Oui" : "Non";
26
+ return answer;
27
+ };
28
+ const getHint = (identifiers) => {
29
+ return `$ABCD$ est un parallélogramme si et seulement si les vecteurs $\\overrightarrow{AB}$ et $\\overrightarrow{DC}$ sont égaux.`;
30
+ };
31
+ const getCorrection = (identifiers) => {
32
+ const A = new Point("A", identifiers.xA, identifiers.yA);
33
+ const B = new Point("B", identifiers.xB, identifiers.yB);
34
+ const C = new Point("C", identifiers.xC, identifiers.yC);
35
+ const D = new Point("D", identifiers.xD, identifiers.yD);
36
+ const vec1 = new Vector("AB", substract(B.x, A.x), substract(B.y, A.y));
37
+ const vec2 = new Vector("DC", substract(C.x, D.x), substract(C.y, D.y));
38
+ const vec1Simp = vec1.simplify();
39
+ const vec2Simp = vec2.simplify();
40
+ const isParallelogram = vec1Simp.equals(vec2Simp);
41
+ return `$ABCD$ est un parallélogramme si et seulement si les vecteurs $\\overrightarrow{AB}$ et $\\overrightarrow{DC}$ sont égaux. On calcule donc les coordonnées de ces vecteurs :
42
+
43
+ $$
44
+ ${vec1.toTexWithCoords()}=${vec1Simp.toBinomCoords().toTex()}
45
+ $$
46
+
47
+ $$
48
+ ${vec2.toTexWithCoords()}=${vec2Simp.toBinomCoords().toTex()}
49
+ $$
50
+
51
+ ${isParallelogram
52
+ ? `Puisque les vecteurs sont égaux, $ABCD$ est un parallélogramme.`
53
+ : `Puisque les vecteurs ne sont pas égaux, $ABCD$ n'est pas un parallélogramme.`}`;
54
+ };
55
+ const getQuestionFromIdentifiers = (identifiers) => {
56
+ const question = {
57
+ answer: getAnswer(identifiers),
58
+ instruction: getInstruction(identifiers),
59
+ keys: [],
60
+ answerFormat: "raw",
61
+ identifiers,
62
+ hint: getHint(identifiers),
63
+ correction: getCorrection(identifiers),
64
+ };
65
+ return question;
66
+ };
67
+ const getParallelogramViaEqualVectorsQuestion = () => {
68
+ const points = PointConstructor.randomDifferent(2, { names: ["A", "B"] });
69
+ const AB = VectorConstructor.fromPoints(points[0], points[1]);
70
+ let D;
71
+ do {
72
+ D = PointConstructor.random("D");
73
+ } while (AB.isColinear(VectorConstructor.fromPoints(D, points[0])));
74
+ let C;
75
+ const isParallelogram = coinFlip();
76
+ if (isParallelogram) {
77
+ C = AB.getEndPoint(D, "C");
78
+ }
79
+ else {
80
+ do {
81
+ C = PointConstructor.random("C");
82
+ } while (AB.equals(VectorConstructor.fromPoints(D, C)));
83
+ }
84
+ const identifiers = {
85
+ xA: points[0].x.evaluate({}),
86
+ xB: points[1].x.evaluate({}),
87
+ xC: C.x.evaluate({}),
88
+ xD: D.x.evaluate({}),
89
+ yA: points[0].y.evaluate({}),
90
+ yB: points[1].y.evaluate({}),
91
+ yC: C.y.evaluate({}),
92
+ yD: D.y.evaluate({}),
93
+ };
94
+ return getQuestionFromIdentifiers(identifiers);
95
+ };
96
+ const getPropositions = (n, { answer }) => {
97
+ const propositions = [];
98
+ addValidProp(propositions, answer, "raw");
99
+ tryToAddWrongProp(propositions, "Oui", "raw");
100
+ tryToAddWrongProp(propositions, "Non", "raw");
101
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
102
+ return shuffle(propositions);
103
+ };
104
+ export const parallelogramViaEqualVectors = {
105
+ id: "parallelogramViaEqualVectors",
106
+ label: "Utiliser les vecteurs pour reconnaître un parallélogramme",
107
+ isSingleStep: true,
108
+ generator: (nb) => getDistinctQuestions(getParallelogramViaEqualVectorsQuestion, nb),
109
+ qcmTimer: 60,
110
+ freeTimer: 60,
111
+ getPropositions,
112
+ answerType: "QCU",
113
+ subject: "Mathématiques",
114
+ getQuestionFromIdentifiers,
115
+ hasHintAndCorrection: true,
116
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ points: string[][];
4
+ pointAskedIndex: number[];
5
+ };
6
+ export declare const translationFromPicture: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=translationFromPicture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translationFromPicture.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/translationFromPicture.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAG3B,CAAC;AAqGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
@@ -0,0 +1,104 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
4
+ import { random } from "../../../../utils/alea/random.js";
5
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer }) => {
7
+ const propositions = [];
8
+ addValidProp(propositions, answer);
9
+ while (propositions.length < n) {
10
+ tryToAddWrongProp(propositions, random(["A", "B", "C", "D", "E", "F", "G", "H"]));
11
+ }
12
+ return shuffleProps(propositions, n);
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const { points, pointAskedIndex } = identifiers;
16
+ return points[pointAskedIndex[0]][pointAskedIndex[1]];
17
+ };
18
+ const getInstruction = (identifiers) => {
19
+ const { points, pointAskedIndex } = identifiers;
20
+ const displayed = [[...points[0]], [...points[1]]];
21
+ displayed[pointAskedIndex[0]][pointAskedIndex[1]] = "\\ldots ";
22
+ return `On considère la figure ci-dessous :
23
+
24
+ ![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/mathliveV2/activities/quizzes/generator/figureTranslations2nde.png)
25
+
26
+ Compléter la phrase suivante :
27
+
28
+ *Le point $${displayed[0][1]}$ est l'image du point $${displayed[0][0]}$ par la translation de vecteur $\\overrightarrow{${displayed[1][0]}${displayed[1][1]}}$.*`;
29
+ };
30
+ const getHint = (identifiers) => {
31
+ const { points, pointAskedIndex } = identifiers;
32
+ const displayed = [[...points[0]], [...points[1]]];
33
+ displayed[pointAskedIndex[0]][pointAskedIndex[1]] = "X";
34
+ return `La question revient à déterminer le point $X$ tel que :
35
+
36
+ $$
37
+ \\overrightarrow{${displayed[0][0]}${displayed[0][1]}}=\\overrightarrow{${displayed[1][0]}${displayed[1][1]}}
38
+ $$`;
39
+ };
40
+ const getCorrection = (identifiers) => {
41
+ const { points, pointAskedIndex } = identifiers;
42
+ return `Puisque les vecteurs $\\overrightarrow{${points[0][0]}${points[0][1]}}$ et $\\overrightarrow{${points[1][0]}${points[1][1]}}$ sont égaux, le point $${points[0][1]}$ est l'image du point $${points[0][0]}$ par la translation de vecteur $\\overrightarrow{${points[1][0]}${points[1][1]}}$.`;
43
+ };
44
+ const getKeys = (identifiers) => {
45
+ return ["A", "B", "C", "D", "E", "F", "G", "H"];
46
+ };
47
+ const isAnswerValid = (ans, { answer }) => {
48
+ try {
49
+ return ans === answer;
50
+ }
51
+ catch (err) {
52
+ return handleVEAError(err);
53
+ }
54
+ };
55
+ const getTranslationFromPictureQuestion = (ops) => {
56
+ const equalVectors = [
57
+ ["EF", "BC", "AD"],
58
+ ["EA", "FD"],
59
+ ["EG", "GC", "BD"],
60
+ ["BH", "HD"],
61
+ ["AB", "BG", "GF", "DC"],
62
+ ["AH", "HC"],
63
+ ["EB", "FC", "GD"],
64
+ ];
65
+ const chosen = random(equalVectors);
66
+ const willReverse = coinFlip();
67
+ let first = random(chosen);
68
+ willReverse && first.split("").reverse().join("");
69
+ let second = random(chosen, [first]);
70
+ willReverse && second.split("").reverse().join("");
71
+ const identifiers = {
72
+ pointAskedIndex: [random([0, 1]), random([0, 1])],
73
+ points: [first.split(""), second.split("")],
74
+ };
75
+ return getQuestionFromIdentifiers(identifiers);
76
+ };
77
+ const getQuestionFromIdentifiers = (identifiers) => {
78
+ return {
79
+ answer: getAnswer(identifiers),
80
+ instruction: getInstruction(identifiers),
81
+ keys: getKeys(identifiers),
82
+ answerFormat: "tex",
83
+ identifiers,
84
+ hint: getHint(identifiers),
85
+ correction: getCorrection(identifiers),
86
+ };
87
+ };
88
+ export const translationFromPicture = {
89
+ id: "translationFromPicture",
90
+ label: "Identifier une translation à partir d'une figure",
91
+ isSingleStep: true,
92
+ generator: (nb, opts) => getDistinctQuestions(() => getTranslationFromPictureQuestion(opts), nb),
93
+ qcmTimer: 60,
94
+ freeTimer: 60,
95
+ getPropositions,
96
+ isAnswerValid,
97
+ subject: "Mathématiques",
98
+ getInstruction,
99
+ getHint,
100
+ getCorrection,
101
+ getAnswer,
102
+ getQuestionFromIdentifiers,
103
+ hasHintAndCorrection: true,
104
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ vec: string;
4
+ vecsProposed: string[];
5
+ };
6
+ export declare const vectorRepresentative: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=vectorRepresentative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectorRepresentative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/vectorRepresentative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA6LF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAiBtD,CAAC"}
@@ -0,0 +1,161 @@
1
+ import { addValidProp, addWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Point } from "../../../../math/geometry/point.js";
4
+ import { VectorConstructor } from "../../../../math/geometry/vector.js";
5
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
6
+ import { random } from "../../../../utils/alea/random.js";
7
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
8
+ import { doWhile } from "../../../../utils/doWhile.js";
9
+ const getPoints = () => {
10
+ const points = [];
11
+ let letter = 65; // A
12
+ for (let j = 0; j < 5; j++) {
13
+ for (let i = 0; i < 4; i++) {
14
+ points.push(new Point(String.fromCharCode(letter), i, j));
15
+ letter++;
16
+ }
17
+ }
18
+ return points;
19
+ };
20
+ const getPropositions = (n, { answer, vec, vecsProposed }) => {
21
+ const propositions = [];
22
+ // addValidProp(propositions, answer);
23
+ const points = getPoints();
24
+ const vector = VectorConstructor.fromPoints(points.find((p) => p.name === vec[0]), points.find((p) => p.name === vec[1]));
25
+ for (let i = 0; i < vecsProposed.length; i++) {
26
+ const vecProp = VectorConstructor.fromPoints(points.find((p) => p.name === vecsProposed[i][0]), points.find((p) => p.name === vecsProposed[i][1]));
27
+ if (vector.equals(vecProp)) {
28
+ addValidProp(propositions, vecsProposed[i]);
29
+ }
30
+ else {
31
+ addWrongProp(propositions, vecsProposed[i]);
32
+ }
33
+ }
34
+ return propositions;
35
+ };
36
+ const getInstruction = (identifiers) => {
37
+ return `On considère la figure ci-dessous :
38
+
39
+ ![](https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/mathliveV2/activities/quizzes/generator/pointsOnParallelogram2.png)
40
+
41
+ Parmi les vecteurs suivants, lequel, ou lesquels, sont des représentants du vecteur $\\overrightarrow{${identifiers.vec}}$ ?`;
42
+ };
43
+ const getHint = (identifiers) => {
44
+ return `On appelle représentant d'un vecteur $\\overrightarrow{u}$ tout vecteur qui est égal à $\\overrightarrow{u}$.`;
45
+ };
46
+ const getCorrection = (identifiers) => {
47
+ const { vec, vecsProposed } = identifiers;
48
+ const points = getPoints();
49
+ const vector = VectorConstructor.fromPoints(points.find((p) => p.name === vec[0]), points.find((p) => p.name === vec[1]));
50
+ const vectors = vecsProposed.map((vecProp) => VectorConstructor.fromPoints(points.find((p) => p.name === vecProp[0]), points.find((p) => p.name === vecProp[1])));
51
+ const booleans = vectors.map((vecProp) => vector.equals(vecProp));
52
+ return `Pour chaque vecteur proposé, on vérifie s'il est égal au vecteur $\\overrightarrow{${vec}}$.
53
+
54
+ Pour cela, on peut compter les déplacements sur le quadrillage. On voit que le vecteur $\\overrightarrow{${vec}}$ représente un déplacement de $${vector.x.toTex()}$ unité(s) en "horizontal" et de $${vector.y.toTex()}$ unité(s) en "vertical". On cherche donc les vecteurs qui représentent le même déplacement.
55
+
56
+ ${vectors
57
+ .map((vecProposed, i) => `- $\\overrightarrow{${vecsProposed[i]}}$ est un déplacement de $${vecProposed.x.toTex()}$ unité(s) en "horizontal" et de $${vecProposed.y.toTex()}$ unité(s) en "vertical". ${booleans[i]
58
+ ? `C'est donc bien un représentant de $\\overrightarrow{${vec}}$.`
59
+ : `Ce n'est donc pas un représentant de $\\overrightarrow{${vec}}$.`}`)
60
+ .join("\n\n")}`;
61
+ };
62
+ const getVectorRepresentativeQuestion = (ops) => {
63
+ const lettres = Array.from({ length: 20 }, (_, i) => String.fromCharCode(65 + i));
64
+ let vec = "";
65
+ do {
66
+ const vecA = random(lettres);
67
+ const vecB = random(lettres, [vecA]);
68
+ vec = `${vecA}${vecB}`;
69
+ } while (
70
+ //AT et QD n'ont pas de représentants
71
+ (vec.includes("A") && vec.includes("T")) ||
72
+ (vec.includes("Q") && vec.includes("D")));
73
+ const points = getPoints();
74
+ const vector = VectorConstructor.fromPoints(points.find((p) => p.name === vec[0]), points.find((p) => p.name === vec[1]));
75
+ //les problemes de performance sont une construction sociale de la classe capitaliste, il ne faut pas s'en occuper
76
+ const getRepresentant = () => {
77
+ const shuffled = shuffle(points);
78
+ for (let i = 0; i < shuffled.length; i++) {
79
+ const point = shuffled[i];
80
+ if (point.name === vec[0])
81
+ continue;
82
+ const end = vector.getEndPoint(point);
83
+ const endPoint = points.find((p) => p.x.evaluate() === end.x.evaluate() &&
84
+ p.y.evaluate() === end.y.evaluate());
85
+ if (endPoint) {
86
+ return `${point.name}${endPoint.name}`;
87
+ }
88
+ }
89
+ return "";
90
+ };
91
+ const vecsProposed = [getRepresentant()];
92
+ const coordsWith1Rep = [
93
+ [2, 4],
94
+ [3, 3],
95
+ ];
96
+ const coordsWith2Rep = [
97
+ [1, 4],
98
+ [3, 2],
99
+ ];
100
+ const vecCoords = [
101
+ Math.abs(vector.x.evaluate()),
102
+ Math.abs(vector.y.evaluate()),
103
+ ];
104
+ const vecRepCount = coordsWith1Rep.some((v) => v[0] === vecCoords[0] && v[1] === vecCoords[1])
105
+ ? 1
106
+ : coordsWith2Rep.some((v) => v[0] === vecCoords[0] && v[1] === vecCoords[1])
107
+ ? 2
108
+ : 3;
109
+ let repCounter = 1;
110
+ for (let i = 0; i < 3; i++) {
111
+ const isRep = repCounter >= vecRepCount ? false : coinFlip();
112
+ if (isRep) {
113
+ repCounter++;
114
+ const rep = doWhile(() => {
115
+ return getRepresentant();
116
+ }, (v) => vecsProposed.includes(v));
117
+ vecsProposed.push(rep);
118
+ }
119
+ else {
120
+ let point1;
121
+ let point2;
122
+ do {
123
+ point1 = random(points);
124
+ point2 = random(points);
125
+ } while (VectorConstructor.fromPoints(point1, point2).equals(vector) ||
126
+ vecsProposed.includes(`${point1.name}${point2.name}`));
127
+ vecsProposed.push(`${point1.name}${point2.name}`);
128
+ }
129
+ }
130
+ const identifiers = {
131
+ vec,
132
+ vecsProposed: shuffle(vecsProposed),
133
+ };
134
+ return getQuestionFromIdentifiers(identifiers);
135
+ };
136
+ const getQuestionFromIdentifiers = (identifiers) => {
137
+ return {
138
+ instruction: getInstruction(identifiers),
139
+ answerFormat: "tex",
140
+ identifiers,
141
+ hint: getHint(identifiers),
142
+ correction: getCorrection(identifiers),
143
+ };
144
+ };
145
+ export const vectorRepresentative = {
146
+ id: "vectorRepresentative",
147
+ label: "Citer des représentants d'un vecteur",
148
+ isSingleStep: true,
149
+ generator: (nb, opts) => getDistinctQuestions(() => getVectorRepresentativeQuestion(opts), nb),
150
+ qcmTimer: 60,
151
+ freeTimer: 60,
152
+ getPropositions,
153
+ subject: "Mathématiques",
154
+ getInstruction,
155
+ getHint,
156
+ getCorrection,
157
+ getQuestionFromIdentifiers,
158
+ hasHintAndCorrection: true,
159
+ isQCM: true,
160
+ answerType: "QCM",
161
+ };
@@ -5,4 +5,5 @@ export * from "./volumeOfPyramidWithTriangleBase.js";
5
5
  export * from "./coneVolume.js";
6
6
  export * from "./sphereVolume.js";
7
7
  export * from "./parallelepipedVolume.js";
8
+ export * from "./variableVolume.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/volumes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/volumes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
@@ -5,3 +5,4 @@ export * from "./volumeOfPyramidWithTriangleBase.js";
5
5
  export * from "./coneVolume.js";
6
6
  export * from "./sphereVolume.js";
7
7
  export * from "./parallelepipedVolume.js";
8
+ export * from "./variableVolume.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ width: number;
4
+ height: number;
5
+ depth: number;
6
+ };
7
+ export declare const variableVolume: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=variableVolume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variableVolume.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/volumes/variableVolume.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA6NF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAoBhD,CAAC"}