math-exercises 3.0.20 → 3.0.21

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 (52) hide show
  1. package/lib/exercises/math/dataRepresentations/barChartReading.d.ts.map +1 -1
  2. package/lib/exercises/math/dataRepresentations/barChartReading.js +0 -1
  3. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts +9 -0
  4. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts.map +1 -0
  5. package/lib/exercises/math/dataRepresentations/functionGraphReading.js +174 -0
  6. package/lib/exercises/math/dataRepresentations/index.js +1 -0
  7. package/lib/exercises/math/derivation/derivative/inflexionPointQuadrinomials.d.ts.map +1 -1
  8. package/lib/exercises/math/derivation/derivative/inflexionPointQuadrinomials.js +68 -14
  9. package/lib/exercises/math/functions/exponential/expFactorization.d.ts +13 -0
  10. package/lib/exercises/math/functions/exponential/expFactorization.d.ts.map +1 -0
  11. package/lib/exercises/math/functions/exponential/expFactorization.js +147 -0
  12. package/lib/exercises/math/functions/exponential/index.d.ts +1 -0
  13. package/lib/exercises/math/functions/exponential/index.d.ts.map +1 -1
  14. package/lib/exercises/math/functions/exponential/index.js +1 -0
  15. package/lib/exercises/math/geometry/euclidian/index.js +1 -0
  16. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts +2 -0
  17. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -0
  18. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +187 -0
  19. package/lib/exercises/math/geometry/index.d.ts +1 -0
  20. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  21. package/lib/exercises/math/geometry/index.js +2 -1
  22. package/lib/exercises/math/geometry/lines/index.d.ts +2 -0
  23. package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -0
  24. package/lib/exercises/math/geometry/lines/index.js +1 -0
  25. package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts +12 -0
  26. package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts.map +1 -0
  27. package/lib/exercises/math/geometry/lines/linesRelativePositions.js +140 -0
  28. package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts +1 -0
  29. package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts.map +1 -1
  30. package/lib/exercises/math/geometry/vectors/scalarProduct/index.js +1 -1
  31. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts +6 -2
  32. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
  33. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +99 -67
  34. package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
  35. package/lib/geogebra/geogebraConstructor.js +12 -4
  36. package/lib/index.d.ts +23 -0
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/math/geometry/point.d.ts +2 -1
  39. package/lib/math/geometry/point.d.ts.map +1 -1
  40. package/lib/math/geometry/point.js +3 -3
  41. package/lib/math/geometry/vector.d.ts +2 -0
  42. package/lib/math/geometry/vector.d.ts.map +1 -1
  43. package/lib/math/geometry/vector.js +3 -0
  44. package/lib/playground.d.ts.map +1 -1
  45. package/lib/playground.js +1 -3
  46. package/lib/tree/nodes/numbers/numberNode.d.ts +1 -0
  47. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  48. package/lib/tree/nodes/numbers/numberNode.js +3 -0
  49. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  50. package/lib/tree/nodes/operators/fractionNode.js +1 -1
  51. package/lib/tree/parsers/powerParser.d.ts +1 -1
  52. package/package.json +1 -1
@@ -0,0 +1,187 @@
1
+ // import {
2
+ // Exercise,
3
+ // Proposition,
4
+ // QCMGenerator,
5
+ // Question,
6
+ // QuestionGenerator,
7
+ // VEA,
8
+ // GGBVEA,
9
+ // addValidProp,
10
+ // shuffleProps,
11
+ // tryToAddWrongProp,
12
+ // GetAnswer,
13
+ // GetHint,
14
+ // GetCorrection,
15
+ // GetInstruction,
16
+ // GetKeys,
17
+ // GetGGBOptions,
18
+ // GetStudentGGBOptions,
19
+ // GetGGBAnswer,
20
+ // } from "../../../../exercises/exercise.js";
21
+ // import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
22
+ // import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
23
+ // import { Line, LineConstructor } from "../../../../math/geometry/line.js";
24
+ // import {
25
+ // Point,
26
+ // PointConstructor,
27
+ // PointIdentifiers,
28
+ // } from "../../../../math/geometry/point.js";
29
+ // import {
30
+ // Segment,
31
+ // SegmentConstructor,
32
+ // SegmentIdentifiers,
33
+ // } from "../../../../math/geometry/segment.js";
34
+ // import {
35
+ // Triangle,
36
+ // TriangleConstructor,
37
+ // TriangleIdentifiers,
38
+ // } from "../../../../math/geometry/triangle.js";
39
+ // import { coinFlip } from "../../../../utils/alea/coinFlip.js";
40
+ export {};
41
+ // type Identifiers = {
42
+ // isAskingLength: boolean;
43
+ // triangleIdentifiers: TriangleIdentifiers;
44
+ // extraPoints: PointIdentifiers[];
45
+ // isSegmentHeight: boolean; // si hauteur alors configuration pythagore
46
+ // };
47
+ // const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
48
+ // const propositions: Proposition[] = [];
49
+ // addValidProp(propositions, answer, "raw");
50
+ // tryToAddWrongProp(propositions, "Le théorème de Thalès", "raw");
51
+ // tryToAddWrongProp(propositions, "La réciproque du théorème de Thalès", "raw");
52
+ // tryToAddWrongProp(propositions, "Le théorème de Pythagore", "raw");
53
+ // tryToAddWrongProp(
54
+ // propositions,
55
+ // "La réciproque du théorème de Pythagore",
56
+ // "raw",
57
+ // );
58
+ // return shuffleProps(propositions, n);
59
+ // };
60
+ // const getAnswer: GetAnswer<Identifiers> = (identifiers) => {
61
+ // const { isAskingLength, triangleIdentifiers, isSegmentHeight } = identifiers;
62
+ // return isSegmentHeight
63
+ // ? isAskingLength
64
+ // ? "Le théorème de Pythagore"
65
+ // : "La réciproque du théorème de Pythagore"
66
+ // : isAskingLength
67
+ // ? "Le théorème de Thalès"
68
+ // : "La réciproque du théorème de Thalès";
69
+ // };
70
+ // const getInstruction: GetInstruction<Identifiers> = (identifiers) => {
71
+ // const { isAskingLength, triangleIdentifiers, isSegmentHeight, extraPoints } = identifiers;
72
+ // const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
73
+ // const points = extraPoints.map((e) => PointConstructor.fromIdentifiers(e));
74
+ // let instruction = ``;
75
+ // if(isSegmentHeight){
76
+ // if(isAskingLength){
77
+ // instruction = `calculer la longueur $${triangle.sides[2].toInsideName()}$`
78
+ // } else {
79
+ // instruction = `prouver que le triangle $${triangle.points[1].name}${triangle.points[2].name}${points[0].name}$ est rectangle en $${points[0].name}$`
80
+ // }
81
+ // } else {
82
+ // if(isAskingLength){
83
+ // instruction = `calculer la longueur $${points[0].name}${points[1].name}$`
84
+ // } else {
85
+ // instruction = `prouver que les droites $${}$ et $${}$ sont parallèles`
86
+ // }
87
+ // }
88
+ // return `On donne la figure ci-dessous.
89
+ // Pour ${instruction}, il faut utiliser... `;
90
+ // };
91
+ // // const getHint: GetHint<Identifiers> = (identifiers) => {};
92
+ // // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
93
+ // const getGGBOptions: GetGGBOptions<Identifiers> = (identifiers) => {
94
+ // const { isAskingLength, triangleIdentifiers, extraPoints, isSegmentHeight } =
95
+ // identifiers;
96
+ // const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
97
+ // const points = extraPoints.map((e) => PointConstructor.fromIdentifiers(e));
98
+ // const commands = [
99
+ // ...triangle.commands,
100
+ // ...points.flatMap((p) => p.toGGBCommand()),
101
+ // ];
102
+ // if (isSegmentHeight) {
103
+ // commands.push(
104
+ // ...new Segment(triangle.points[1], points[0]).toGGBCommands(false),
105
+ // );
106
+ // } else {
107
+ // commands.push(...new Segment(points[0], points[1]).toGGBCommands(false));
108
+ // }
109
+ // const ggb = new GeogebraConstructor({
110
+ // commands,
111
+ // hideAxes: true,
112
+ // hideGrid: true,
113
+ // });
114
+ // return ggb.getOptions({
115
+ // coords: triangle.generateCoords(),
116
+ // });
117
+ // };
118
+ // const getKeys: GetKeys<Identifiers> = (identifiers) => {
119
+ // return [];
120
+ // };
121
+ // const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
122
+ // throw Error("VEA not implemented");
123
+ // };
124
+ // const getPythagoreOrThalesQuestion: QuestionGenerator<Identifiers> = (opts) => {
125
+ // // const triangle = TriangleConstructor.randomNiceSides({});
126
+ // const A = new Point("A", 0, 0);
127
+ // const B = new Point("B", 4, 4);
128
+ // const C = new Point("C", 8, 0);
129
+ // const triangle = new Triangle([A, B, C]);
130
+ // const isSegmentHeight = coinFlip();
131
+ // const isAskingLength = coinFlip();
132
+ // let extraPoints: PointIdentifiers[] = [];
133
+ // if (isSegmentHeight) {
134
+ // const baseLine = LineConstructor.fromSegment(triangle.sides[1]);
135
+ // const height = baseLine.getPerpendicular(triangle.points[1]);
136
+ // extraPoints.push(height.intersect(baseLine, "H").toIdentifiers());
137
+ // } else {
138
+ // const baseLine = LineConstructor.fromSegment(triangle.sides[1]);
139
+ // const D = PointConstructor.onSegment(triangle.sides[2], "D", {
140
+ // spacing: 0.3,
141
+ // });
142
+ // const para = baseLine.getParallele(D);
143
+ // const E = para.intersect(
144
+ // LineConstructor.fromSegment(triangle.sides[0]),
145
+ // "E",
146
+ // );
147
+ // extraPoints.push(D.toIdentifiers());
148
+ // extraPoints.push(E.toIdentifiers());
149
+ // }
150
+ // const identifiers: Identifiers = {
151
+ // triangleIdentifiers: triangle.toIdentifiers(),
152
+ // // segmentIdentifiers: triangle.sides[0].toIdentifiers(),
153
+ // extraPoints,
154
+ // isAskingLength,
155
+ // isSegmentHeight,
156
+ // };
157
+ // const question: Question<Identifiers> = {
158
+ // answer: getAnswer(identifiers),
159
+ // instruction: getInstruction(identifiers),
160
+ // keys: getKeys(identifiers),
161
+ // answerFormat: "raw",
162
+ // identifiers,
163
+ // // hint: getHint(identifiers),
164
+ // // correction: getCorrection(identifiers),
165
+ // ggbOptions: getGGBOptions(identifiers),
166
+ // };
167
+ // return question;
168
+ // };
169
+ // export const pythagoreOrThales: Exercise<Identifiers> = {
170
+ // id: "pythagoreOrThales",
171
+ // label: "",
172
+ // isSingleStep: true,
173
+ // generator: (nb, opts) =>
174
+ // getDistinctQuestions(() => getPythagoreOrThalesQuestion(opts), nb),
175
+ // qcmTimer: 60,
176
+ // freeTimer: 60,
177
+ // getPropositions,
178
+ // isAnswerValid,
179
+ // subject: "Mathématiques",
180
+ // // getHint,
181
+ // // getCorrection,
182
+ // getInstruction,
183
+ // getAnswer,
184
+ // getGGBOptions,
185
+ // hasGeogebra: true,
186
+ // answerType: "QCU",
187
+ // };
@@ -11,4 +11,5 @@ export * from "./shapes/index.js";
11
11
  export * from "./parametric/index.js";
12
12
  export * from "./quadrilaterals/index.js";
13
13
  export * from "./angles/index.js";
14
+ export * from "./lines/index.js";
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAElC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAElC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -9,7 +9,8 @@ export * from "./volumes/index.js";
9
9
  // export * from "./triangles.js";
10
10
  export * from "./euclidianConstructions/index.js";
11
11
  export * from "./shapes/index.js";
12
- // export * from "./euclidian.js";
12
+ // export * from "./euclidian/index.js";
13
13
  export * from "./parametric/index.js";
14
14
  export * from "./quadrilaterals/index.js";
15
15
  export * from "./angles/index.js";
16
+ export * from "./lines/index.js";
@@ -0,0 +1,2 @@
1
+ export * from "./linesRelativePositions.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/lines/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./linesRelativePositions.js";
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lines: {
4
+ pointA: number[];
5
+ pointB: number[];
6
+ label: string;
7
+ }[];
8
+ coupleAsked: number;
9
+ };
10
+ export declare const linesRelativePositions: Exercise<Identifiers>;
11
+ export {};
12
+ //# sourceMappingURL=linesRelativePositions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linesRelativePositions.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/lines/linesRelativePositions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAE/D,WAAW,EAAE,MAAM,CAAC;CAKrB,CAAC;AA+IF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAmBxD,CAAC"}
@@ -0,0 +1,140 @@
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 { Line } from "../../../../math/geometry/line.js";
5
+ import { Point } from "../../../../math/geometry/point.js";
6
+ import { randint } from "../../../../math/utils/random/randint.js";
7
+ const getPropositions = (n, { answer, coupleAsked, lines }) => {
8
+ const propositions = [];
9
+ addValidProp(propositions, answer, "raw");
10
+ tryToAddWrongProp(propositions, "perpendiculaires", "raw");
11
+ tryToAddWrongProp(propositions, "parallèles", "raw");
12
+ tryToAddWrongProp(propositions, "sécantes mais non perpendiculaires", "raw");
13
+ return shuffleProps(propositions, n);
14
+ };
15
+ const getAnswer = (identifiers) => {
16
+ const { coupleAsked, lines } = identifiers;
17
+ switch (coupleAsked) {
18
+ case 0:
19
+ return `perpendiculaires`;
20
+ case 1:
21
+ return "parallèles";
22
+ case 2:
23
+ case 3:
24
+ default:
25
+ return "sécantes mais non perpendiculaires";
26
+ }
27
+ };
28
+ const getInstruction = (identifiers) => {
29
+ const { coupleAsked, lines } = identifiers;
30
+ const askedLines = coupleAsked === 0
31
+ ? [lines[0], lines[4]]
32
+ : coupleAsked === 3
33
+ ? [lines[2], lines[4]]
34
+ : [lines[coupleAsked], lines[coupleAsked + 1]];
35
+ return `On donne la figure ci-dessous.
36
+
37
+ $${askedLines[0].label}$ et $${askedLines[1].label}$ semblent...`;
38
+ };
39
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
40
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
41
+ const getGGBOptions = (identifiers) => {
42
+ const lines = identifiers.lines.map((d, i) => new Line(new Point(`A_${d.label}`, d.pointA[0], d.pointA[1]), new Point(`B_${d.label}`, d.pointB[0], d.pointB[1]), d.label));
43
+ const ggb = new GeogebraConstructor({
44
+ commands: lines.flatMap((l) => l.toGGBCommands(false, { showLabel: true, color: "black" })),
45
+ forbidShiftDragZoom: true,
46
+ hideAxes: true,
47
+ hideGrid: true,
48
+ });
49
+ return ggb.getOptions({
50
+ coords: [-3, 5, -2, 6],
51
+ });
52
+ };
53
+ const getKeys = (identifiers) => {
54
+ return [];
55
+ };
56
+ const isAnswerValid = (ans, { answer }) => {
57
+ throw Error("VEA not implemented");
58
+ };
59
+ const getLinesRelativePositionsQuestion = (opts) => {
60
+ // const permut = shuffle([1, 2, 3, 4, 5]);
61
+ const permut = [1, 2, 3, 4, 5];
62
+ // const v2 = VectorConstructor.random("v2", false);
63
+ // const v3 = v2;
64
+ // let v1: Vector;
65
+ // let v4: Vector;
66
+ // let v5: Vector;
67
+ // do {
68
+ // v1 = VectorConstructor.random("v1", false);
69
+ // } while (Math.abs(v1.determinant(v2).evaluate()) < 2);
70
+ // v5 = v1.getOrthogonal();
71
+ // // do {
72
+ // v4 = VectorConstructor.random("v4", false);
73
+ // console.log("iter");
74
+ // } while (
75
+ // Math.abs(v4.determinant(v3).evaluate()) > 10 ||
76
+ // Math.abs(v4.determinant(v3).evaluate()) < 1
77
+ // );
78
+ // console.log("det", Math.abs(v4.determinant(v3).evaluate()));
79
+ // let pointA = [randint(-9, 10), randint(-9, 10)];
80
+ // let B = v1.getEndPoint(new Point("A", pointA[0], pointA[1]));
81
+ // let pointB = [B.x.evaluate(), B.y.evaluate()];
82
+ const d1 = {
83
+ label: `d_{${permut[0]}}`,
84
+ pointA: [-2, 5],
85
+ pointB: [-1, 4],
86
+ };
87
+ const d2 = {
88
+ label: `d_{${permut[1]}}`,
89
+ pointA: [1, 6],
90
+ pointB: [0, 3],
91
+ };
92
+ const d3 = {
93
+ label: `d_{${permut[2]}}`,
94
+ pointA: [2, 5],
95
+ pointB: [1, 2],
96
+ };
97
+ const d4 = {
98
+ label: `d_{${permut[3]}}`,
99
+ pointA: [6, 7],
100
+ pointB: [3, 1],
101
+ };
102
+ const d5 = {
103
+ label: `d_{${permut[4]}}`,
104
+ pointA: [0, 1],
105
+ pointB: [1, 2],
106
+ };
107
+ const lines = [d1, d2, d3, d4, d5];
108
+ const coupleAsked = randint(0, 4);
109
+ const identifiers = { lines, coupleAsked };
110
+ const question = {
111
+ answer: getAnswer(identifiers),
112
+ instruction: getInstruction(identifiers),
113
+ keys: getKeys(identifiers),
114
+ answerFormat: "raw",
115
+ identifiers,
116
+ // hint: getHint(identifiers),
117
+ // correction: getCorrection(identifiers),
118
+ ggbOptions: getGGBOptions(identifiers),
119
+ };
120
+ return question;
121
+ };
122
+ export const linesRelativePositions = {
123
+ id: "linesRelativePositions",
124
+ label: "Déterminer la position relative de deux droites",
125
+ isSingleStep: true,
126
+ generator: (nb, opts) => getDistinctQuestions(() => getLinesRelativePositionsQuestion(opts), nb, 4),
127
+ qcmTimer: 60,
128
+ freeTimer: 60,
129
+ getPropositions,
130
+ isAnswerValid,
131
+ subject: "Mathématiques",
132
+ // getHint,
133
+ // getCorrection,
134
+ getInstruction,
135
+ getAnswer,
136
+ getGGBOptions,
137
+ hasGeogebra: true,
138
+ maxAllowedQuestions: 4,
139
+ answerType: "QCU",
140
+ };
@@ -1,4 +1,5 @@
1
1
  export * from "./scalarProductViaCoords.js";
2
2
  export * from "./scalarProductViaCos.js";
3
+ export * from "./scalarProductOrthoInSquare.js";
3
4
  export * from "./scalarProductViaNorms.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AAGzC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export * from "./scalarProductViaCoords.js";
2
2
  export * from "./scalarProductViaCos.js";
3
- // export * from "./scalarProductOrthoInSquare.js";
3
+ export * from "./scalarProductOrthoInSquare.js";
4
4
  export * from "./scalarProductViaNorms.js";
@@ -1,8 +1,12 @@
1
1
  import { Exercise } from "../../../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  c: number;
4
- vector1Name: string;
5
- vector2Name: string;
4
+ vec1Name: string;
5
+ vec2Name: string;
6
+ areSameDirection: boolean;
7
+ vec1ProjLength: number;
8
+ vec2ProjLength: number;
9
+ rotationAngle: number;
6
10
  };
7
11
  export declare const scalarProductOrthoInSquare: Exercise<Identifiers>;
8
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"scalarProductOrthoInSquare.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA4HF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAiB5D,CAAC"}
1
+ {"version":3,"file":"scalarProductOrthoInSquare.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAgKF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAiB5D,CAAC"}
@@ -1,57 +1,75 @@
1
- import { addValidProp, shuffleProps, } from "../../../../../exercises/exercise.js";
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
3
4
  import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
4
5
  import { Point } from "../../../../../math/geometry/point.js";
5
- import { Rational } from "../../../../../math/numbers/rationals/rational.js";
6
6
  import { randint } from "../../../../../math/utils/random/randint.js";
7
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
8
+ import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
9
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
10
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
7
12
  import { random } from "../../../../../utils/alea/random.js";
8
- const getPoints = (c) => {
9
- const midC = new Rational(c, 2).simplify().toTree();
13
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
14
+ const getPoints = (identifiers) => {
15
+ const { c, rotationAngle } = identifiers;
16
+ // const midC = new Rational(c, 2).simplify().toTree();
17
+ const midC = c / 2;
18
+ const oppMidC = -c / 2;
10
19
  const zeroTree = (0).toTree();
11
- const cTree = c.toTree();
20
+ const center = new Point("O", zeroTree, zeroTree);
12
21
  const points = [
13
- { name: "A", x: zeroTree, y: zeroTree },
14
- { name: "I", x: midC, y: zeroTree },
15
- { name: "B", x: cTree, y: zeroTree },
16
- { name: "J", x: cTree, y: midC },
17
- { name: "C", x: cTree, y: cTree },
18
- { name: "K", x: midC, y: cTree },
19
- { name: "D", x: zeroTree, y: cTree },
20
- { name: "L", x: zeroTree, y: midC },
21
- { name: "O", x: midC, y: midC },
22
- ];
23
- return points;
22
+ { name: "A", x: oppMidC, y: oppMidC },
23
+ { name: "I", x: zeroTree, y: oppMidC },
24
+ { name: "B", x: midC, y: oppMidC },
25
+ { name: "J", x: midC, y: zeroTree },
26
+ { name: "C", x: midC, y: midC },
27
+ { name: "K", x: zeroTree, y: midC },
28
+ { name: "D", x: oppMidC, y: midC },
29
+ { name: "L", x: oppMidC, y: zeroTree },
30
+ ].map((d) => new Point(d.name, d.x, d.y).rotate(rotationAngle, center));
31
+ return [...points, center];
24
32
  };
25
33
  const buildFromIdentifiers = (identifiers) => { };
26
- const getPropositions = (n, { answer }) => {
34
+ const getPropositions = (n, { answer, c }) => {
27
35
  const propositions = [];
28
36
  addValidProp(propositions, answer);
37
+ const wrongAnswers = [
38
+ c.toTree(),
39
+ frac(c, 2),
40
+ (c * c).toTree(),
41
+ frac(c ** 2, 4),
42
+ ];
29
43
  while (propositions.length < n) {
30
- throw Error("QCM not implemented");
44
+ let wrongItem = random(wrongAnswers);
45
+ if (coinFlip())
46
+ wrongItem = opposite(wrongItem);
47
+ tryToAddWrongProp(propositions, wrongItem.simplify().toTex());
31
48
  }
32
49
  return shuffleProps(propositions, n);
33
50
  };
34
51
  const getAnswer = (identifiers) => {
35
- return Math.random() + "";
52
+ const { areSameDirection, c, vec1Name, vec1ProjLength, vec2Name, vec2ProjLength, } = identifiers;
53
+ const frac1 = new NumberNode(vec1ProjLength).toFrac();
54
+ const frac2 = new NumberNode(vec2ProjLength).toFrac();
55
+ if (areSameDirection) {
56
+ return multiply(frac1, frac2).simplify().toTex();
57
+ }
58
+ return opposite(multiply(frac1, frac2)).simplify().toTex();
36
59
  };
37
- const getInstruction = ({ c, vector1Name, vector2Name, }) => {
60
+ const getInstruction = ({ c, vec1Name, vec2Name, }) => {
38
61
  return `$ABCD$ est un carré de côté $${c}$ et de centre $O$. Les points $I$,$J$,$K$ et $L$ sont les milieux respectifs des segments $[AB]$, $[BC]$, $[CD]$ et $[AD]$. Calculer :
39
62
 
40
63
  $$
41
- \\overrightarrow{${vector1Name}}\\cdot \\overrightarrow{${vector2Name}}
64
+ \\overrightarrow{${vec1Name}}\\cdot \\overrightarrow{${vec2Name}}
42
65
  $$`;
43
66
  };
44
- const getHint = (identifiers) => {
45
- return "";
46
- };
47
- const getCorrection = (identifiers) => {
48
- return "";
49
- };
50
- const getGGBOptions = ({ c }) => {
51
- const points = getPoints(c).map((d) => new Point(d.name, d.x, d.y));
67
+ const getGGBOptions = (identifiers) => {
68
+ const { c } = identifiers;
69
+ const points = getPoints(identifiers);
52
70
  const ggb = new GeogebraConstructor({
53
71
  commands: [
54
- ...points.flatMap((p) => p.toGGBCommand()),
72
+ ...points.flatMap((p) => p.toGGBCommand({ style: 1 })),
55
73
  `Polygon(A,B,C,D)`,
56
74
  `Segment(A,C)`,
57
75
  `Segment(B,D)`,
@@ -60,56 +78,70 @@ const getGGBOptions = ({ c }) => {
60
78
  hideGrid: true,
61
79
  });
62
80
  return ggb.getOptions({
63
- coords: [-1, c + 1, -1, c + 1],
81
+ coords: ggb.getCoordsForPoints(points),
64
82
  });
65
83
  };
66
84
  const getKeys = (identifiers) => {
67
85
  return [];
68
86
  };
69
87
  const isAnswerValid = (ans, { answer }) => {
70
- throw Error("VEA not implemented");
88
+ try {
89
+ return rationalVEA(ans, answer);
90
+ }
91
+ catch (err) {
92
+ return handleVEAError(err);
93
+ }
71
94
  };
72
95
  const getScalarProductOrthoInSquareQuestion = () => {
73
96
  const c = randint(1, 10);
74
- // AB AO
75
- // AB AK
76
- // AB AJ
77
- // AB AC
78
- //ou
79
- // AI AO
80
- // AI AK
81
- // AI AC
82
- // AI AJ
83
- //ou
84
- // AB IJ
85
- // AB OC
86
- // AB LK
87
- // AB OJ
88
- // AB LO
89
- //ou
90
- // AI IJ
91
- // AI OC
92
- // AI LK
93
- // AI OJ
94
- // AI LO
95
- // puis on shuffle dans tous les sens
96
- const firstPointIndex = random([0, 2, 4, 6]); //A,B,C,D
97
- const isD = firstPointIndex === 6;
98
- const delta = isD ? 3 : 2;
99
- const secondPointIndex = random([
100
- (firstPointIndex + delta) % 8,
101
- (firstPointIndex + 1) % 8,
102
- ]); //si first=A alors B ou I, idem par translation pour les autres
103
- const thirdPointIndex = random([(1 + delta) % 8, (7 + delta * 8) % 8, 8]);
104
- const identifiers = { c, vector1Name: "BC", vector2Name: "AC" };
97
+ // A(B,I) * A(J,C,O,K)
98
+ // A(D,L) * A(J,C,O,K)
99
+ //puis on reverse tout possiblement
100
+ const isFirstVecOnAB = coinFlip();
101
+ const vecs = {
102
+ AB: { projLength: c, reps: ["AB", "DC"] },
103
+ AC: { projLength: c, reps: ["AC"] },
104
+ AD: { projLength: c, reps: ["AD", "IK", "BC"] },
105
+ AJ: { projLength: isFirstVecOnAB ? c : c / 2, reps: ["AJ", "LC"] },
106
+ AO: { projLength: c / 2, reps: ["AO", "LK", "OC", "IJ"] },
107
+ AK: { projLength: isFirstVecOnAB ? c / 2 : c, reps: ["AK", "IC"] },
108
+ AI: {
109
+ projLength: c / 2,
110
+ reps: ["AI", "IB", "LO", "OJ", "DK", "KC"],
111
+ },
112
+ AL: {
113
+ projLength: c / 2,
114
+ reps: ["AL", "LD", "IO", "OK", "BJ", "BC"],
115
+ },
116
+ };
117
+ const vec1Choices = random(isFirstVecOnAB ? ["AB", "AI"] : ["AD", "AL"]);
118
+ const vec2Choices = random(["AJ", "AC", "AO", "AK"]);
119
+ let vec1 = random(vecs[vec1Choices].reps);
120
+ let vec2 = random(vecs[vec2Choices].reps);
121
+ let inversionsCount = 0;
122
+ if (coinFlip()) {
123
+ inversionsCount++;
124
+ vec1 = vec1.split("").reverse().join("");
125
+ }
126
+ if (coinFlip()) {
127
+ inversionsCount++;
128
+ vec2 = vec2.split("").reverse().join("");
129
+ }
130
+ const identifiers = {
131
+ c,
132
+ vec1Name: vec1,
133
+ vec2Name: vec2,
134
+ areSameDirection: inversionsCount % 2 === 0,
135
+ vec1ProjLength: vecs[vec1Choices].projLength,
136
+ vec2ProjLength: vecs[vec2Choices].projLength,
137
+ rotationAngle: Math.random() * 2 * Math.PI,
138
+ };
105
139
  const question = {
106
140
  answer: getAnswer(identifiers),
107
141
  instruction: getInstruction(identifiers),
108
142
  keys: getKeys(identifiers),
109
143
  answerFormat: "tex",
110
144
  identifiers,
111
- hint: getHint(identifiers),
112
- correction: getCorrection(identifiers),
113
145
  ggbOptions: getGGBOptions(identifiers),
114
146
  };
115
147
  return question;
@@ -126,8 +158,8 @@ export const scalarProductOrthoInSquare = {
126
158
  getPropositions,
127
159
  isAnswerValid,
128
160
  subject: "Mathématiques",
129
- getHint,
130
- getCorrection,
131
161
  getAnswer,
132
162
  getGGBOptions,
163
+ getInstruction,
164
+ hasGeogebra: true,
133
165
  };
@@ -1 +1 @@
1
- {"version":3,"file":"geogebraConstructor.d.ts","sourceRoot":"","sources":["../../src/geogebra/geogebraConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAErD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAA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