math-exercises 3.0.99 → 3.0.100
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.
- package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.d.ts +9 -0
- package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.d.ts.map +1 -0
- package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.js +156 -0
- package/lib/exercises/math/geometry/areas/index.d.ts +1 -0
- package/lib/exercises/math/geometry/areas/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/index.js +1 -0
- package/lib/exercises/math/geometry/euclidian/index.d.ts +1 -0
- package/lib/exercises/math/geometry/euclidian/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidian/index.js +1 -0
- package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.d.ts +8 -0
- package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.js +197 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +9 -4
- package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.d.ts +9 -0
- package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.d.ts.map +1 -0
- package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.js +155 -0
- package/lib/exercises/math/geometry/pythagore/index.d.ts +1 -0
- package/lib/exercises/math/geometry/pythagore/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/index.js +2 -0
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +1 -1
- package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts +9 -0
- package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts.map +1 -0
- package/lib/exercises/math/geometry/pythagore/triangleHeight.js +105 -0
- package/lib/exercises/math/geometry/quadrilaterals/index.d.ts +2 -0
- package/lib/exercises/math/geometry/quadrilaterals/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/quadrilaterals/index.js +2 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.d.ts +11 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.d.ts.map +1 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.js +140 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.d.ts +11 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.d.ts.map +1 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.js +144 -0
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts +9 -0
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.js +201 -0
- package/lib/exercises/math/geometry/vectors/colinearity/determinant.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/colinearity/determinant.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/colinearity/determinant.js +101 -0
- package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts +2 -0
- package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/colinearity/index.js +2 -0
- package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.js +78 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.js +7 -0
- package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.d.ts +9 -0
- package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.js +179 -0
- package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.d.ts +12 -0
- package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.js +171 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.d.ts +10 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.js +110 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.js +123 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.js +115 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.js +123 -0
- package/lib/exercises/math/geometry/vectors/coordinatesReading.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/coordinatesReading.js +63 -14
- package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.d.ts +3 -0
- package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.js +63 -2
- package/lib/exercises/math/geometry/vectors/index.d.ts +4 -8
- package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/index.js +4 -8
- package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.d.ts +14 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.js +78 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/index.d.ts +4 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/index.js +3 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.js +193 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.d.ts +14 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.js +116 -0
- package/lib/exercises/math/geometry/vectors/translationFromPicture.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/translationFromPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/translationFromPicture.js +104 -0
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.js +161 -0
- package/lib/exercises/math/geometry/volumes/index.d.ts +1 -0
- package/lib/exercises/math/geometry/volumes/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/index.js +1 -0
- package/lib/exercises/math/geometry/volumes/variableVolume.d.ts +9 -0
- package/lib/exercises/math/geometry/volumes/variableVolume.d.ts.map +1 -0
- package/lib/exercises/math/geometry/volumes/variableVolume.js +203 -0
- package/lib/index.d.ts +89 -40
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts +1 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +3 -0
- package/lib/math/geometry/vector.d.ts +1 -0
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +3 -0
- package/lib/playground.d.ts.map +1 -1
- package/lib/tests/pdfs/quizPdfPreambule.js +1 -1
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +4 -4
- package/lib/tree/nodes/functions/sqrtNode.d.ts +1 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +8 -2
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
4
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
5
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
6
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
7
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
8
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
9
|
+
import { randomMany } from "../../../../../utils/alea/random.js";
|
|
10
|
+
const getSolutionPoint = (identifiers) => {
|
|
11
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
12
|
+
const origin = points[identifiers.startPointIndex];
|
|
13
|
+
const vec = VectorConstructor.fromPoints(points[identifiers.vectorPointsIndexes[0]], points[identifiers.vectorPointsIndexes[1]]);
|
|
14
|
+
return vec.opposite().getEndPoint(origin, "K");
|
|
15
|
+
};
|
|
16
|
+
const getInstruction = (identifiers) => {
|
|
17
|
+
const { startPointIndex, vectorPointsIndexes } = identifiers;
|
|
18
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
19
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
20
|
+
return `Placer le point $K$ tel que :
|
|
21
|
+
|
|
22
|
+
$$
|
|
23
|
+
\\overrightarrow{${origin}K} = -\\overrightarrow{${vec}}
|
|
24
|
+
$$`;
|
|
25
|
+
};
|
|
26
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
27
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
28
|
+
const getGGBAnswer = (identifiers) => {
|
|
29
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
30
|
+
};
|
|
31
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
32
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
33
|
+
const ggb = new GeogebraConstructor({
|
|
34
|
+
commands,
|
|
35
|
+
customToolBar: toolBarConstructor({
|
|
36
|
+
point: true,
|
|
37
|
+
}),
|
|
38
|
+
hideAxes: true,
|
|
39
|
+
});
|
|
40
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
41
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
42
|
+
return ggb.getOptions({
|
|
43
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
47
|
+
const studentAns = ans.filter((c) => !["A", "B", "C"].includes(c[0]));
|
|
48
|
+
if (studentAns.length !== 1)
|
|
49
|
+
return false;
|
|
50
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
51
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
52
|
+
if (pointCoords.length !== 1)
|
|
53
|
+
return false;
|
|
54
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
55
|
+
};
|
|
56
|
+
const getTraceOppositeVectorQuestion = () => {
|
|
57
|
+
const names = ["A", "B", "C"];
|
|
58
|
+
let points = [];
|
|
59
|
+
let startPointIndex;
|
|
60
|
+
let vectorPointsIndexes;
|
|
61
|
+
while (true) {
|
|
62
|
+
points = [];
|
|
63
|
+
points.push(...PointConstructor.randomDifferent(3, {
|
|
64
|
+
minDistance: 2,
|
|
65
|
+
names,
|
|
66
|
+
minDistanceToOrigin: 3,
|
|
67
|
+
}));
|
|
68
|
+
startPointIndex = randint(0, names.length);
|
|
69
|
+
vectorPointsIndexes = randomMany([0, 1, 2], 2);
|
|
70
|
+
const vec = VectorConstructor.fromPoints(points[vectorPointsIndexes[0]], points[vectorPointsIndexes[1]]);
|
|
71
|
+
const endPoint = vec.opposite().getEndPoint(points[startPointIndex], "K");
|
|
72
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
73
|
+
points.some((p) => p.equals(endPoint)))
|
|
74
|
+
continue;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
const identifiers = {
|
|
78
|
+
vectorPointsIndexes,
|
|
79
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
80
|
+
startPointIndex,
|
|
81
|
+
};
|
|
82
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
83
|
+
};
|
|
84
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
85
|
+
const question = {
|
|
86
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
87
|
+
instruction: getInstruction(identifiers),
|
|
88
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
89
|
+
identifiers,
|
|
90
|
+
// hint: getHint(identifiers),
|
|
91
|
+
// correction: getCorrection(identifiers),
|
|
92
|
+
};
|
|
93
|
+
return question;
|
|
94
|
+
};
|
|
95
|
+
export const traceOppositeVector = {
|
|
96
|
+
id: "traceOppositeVector",
|
|
97
|
+
label: "Placer un point $K$ tel que $\\overrightarrow{AK} = -\\overrightarrow{BC}$",
|
|
98
|
+
isSingleStep: true,
|
|
99
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceOppositeVectorQuestion(opts), nb),
|
|
100
|
+
ggbTimer: 60,
|
|
101
|
+
isGGBAnswerValid,
|
|
102
|
+
subject: "Mathématiques",
|
|
103
|
+
// getHint,
|
|
104
|
+
getInstruction,
|
|
105
|
+
// getCorrection,
|
|
106
|
+
getGGBAnswer,
|
|
107
|
+
getStudentGGBOptions,
|
|
108
|
+
answerType: "GGB",
|
|
109
|
+
getQuestionFromIdentifiers,
|
|
110
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
firstVectorPointsIndexes: number[];
|
|
7
|
+
secondVectorPointsIndexes: number[];
|
|
8
|
+
};
|
|
9
|
+
export declare const traceVectorDifference: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=traceVectorDifference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceVectorDifference.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/traceVectorDifference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAMtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AAsJF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAgBvD,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
4
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
5
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
6
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
7
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
8
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
9
|
+
import { randomMany } from "../../../../../utils/alea/random.js";
|
|
10
|
+
import { doWhile } from "../../../../../utils/doWhile.js";
|
|
11
|
+
const getSolutionPoint = (identifiers) => {
|
|
12
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
13
|
+
const origin = points[identifiers.startPointIndex];
|
|
14
|
+
const vecs = [
|
|
15
|
+
VectorConstructor.fromPoints(points[identifiers.firstVectorPointsIndexes[0]], points[identifiers.firstVectorPointsIndexes[1]]),
|
|
16
|
+
VectorConstructor.fromPoints(points[identifiers.secondVectorPointsIndexes[0]], points[identifiers.secondVectorPointsIndexes[1]]),
|
|
17
|
+
];
|
|
18
|
+
return vecs[0].substract(vecs[1]).getEndPoint(origin, "K");
|
|
19
|
+
};
|
|
20
|
+
const getInstruction = (identifiers) => {
|
|
21
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, } = identifiers;
|
|
22
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
23
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
24
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
25
|
+
return `Placer le point $K$ tel que :
|
|
26
|
+
|
|
27
|
+
$$
|
|
28
|
+
\\overrightarrow{${origin}K} = \\overrightarrow{${firstVec}} - \\overrightarrow{${secondVec}}
|
|
29
|
+
$$`;
|
|
30
|
+
};
|
|
31
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
32
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
33
|
+
const getGGBAnswer = (identifiers) => {
|
|
34
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
35
|
+
};
|
|
36
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
37
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
38
|
+
const ggb = new GeogebraConstructor({
|
|
39
|
+
commands,
|
|
40
|
+
customToolBar: toolBarConstructor({
|
|
41
|
+
point: true,
|
|
42
|
+
}),
|
|
43
|
+
hideAxes: true,
|
|
44
|
+
});
|
|
45
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
46
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
47
|
+
return ggb.getOptions({
|
|
48
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
52
|
+
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
53
|
+
if (studentAns.length !== 1)
|
|
54
|
+
return false;
|
|
55
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
56
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
57
|
+
if (pointCoords.length !== 1)
|
|
58
|
+
return false;
|
|
59
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
60
|
+
};
|
|
61
|
+
const getTraceVectorDifferenceQuestion = () => {
|
|
62
|
+
const names = ["A", "B", "C", "D"];
|
|
63
|
+
let points = [];
|
|
64
|
+
let startPointIndex;
|
|
65
|
+
let firstVectorPointsIndexes;
|
|
66
|
+
let secondVectorPointsIndexes;
|
|
67
|
+
while (true) {
|
|
68
|
+
points = [];
|
|
69
|
+
points.push(...PointConstructor.randomDifferent(4, {
|
|
70
|
+
minDistance: 2,
|
|
71
|
+
names,
|
|
72
|
+
minDistanceToOrigin: 3,
|
|
73
|
+
}));
|
|
74
|
+
startPointIndex = randint(0, names.length);
|
|
75
|
+
firstVectorPointsIndexes = randomMany([0, 1, 2, 3], 2);
|
|
76
|
+
secondVectorPointsIndexes = doWhile(() => randomMany([0, 1, 2, 3], 2), (arr) => arr[0] === firstVectorPointsIndexes[0] &&
|
|
77
|
+
arr[1] === firstVectorPointsIndexes[1]);
|
|
78
|
+
//AC = AB+BC
|
|
79
|
+
const firstVec = VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
80
|
+
const second = VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]);
|
|
81
|
+
const endPoint = firstVec
|
|
82
|
+
.substract(second)
|
|
83
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
84
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
85
|
+
points.some((p) => p.equals(endPoint)))
|
|
86
|
+
continue;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
const identifiers = {
|
|
90
|
+
firstVectorPointsIndexes,
|
|
91
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
92
|
+
secondVectorPointsIndexes,
|
|
93
|
+
startPointIndex,
|
|
94
|
+
};
|
|
95
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
96
|
+
};
|
|
97
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
98
|
+
const question = {
|
|
99
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
100
|
+
instruction: getInstruction(identifiers),
|
|
101
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
102
|
+
identifiers,
|
|
103
|
+
// hint: getHint(identifiers),
|
|
104
|
+
// correction: getCorrection(identifiers),
|
|
105
|
+
};
|
|
106
|
+
return question;
|
|
107
|
+
};
|
|
108
|
+
export const traceVectorDifference = {
|
|
109
|
+
id: "traceVectorDifference",
|
|
110
|
+
label: "Placer un point défini par une différence de vecteurs",
|
|
111
|
+
isSingleStep: true,
|
|
112
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceVectorDifferenceQuestion(opts), nb),
|
|
113
|
+
ggbTimer: 60,
|
|
114
|
+
isGGBAnswerValid,
|
|
115
|
+
subject: "Mathématiques",
|
|
116
|
+
// getHint,
|
|
117
|
+
getInstruction,
|
|
118
|
+
// getCorrection,
|
|
119
|
+
getGGBAnswer,
|
|
120
|
+
getStudentGGBOptions,
|
|
121
|
+
answerType: "GGB",
|
|
122
|
+
getQuestionFromIdentifiers,
|
|
123
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
vectorPointsIndexes: number[];
|
|
7
|
+
coeff: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const traceVectorMultiple: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=traceVectorMultiple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceVectorMultiple.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/traceVectorMultiple.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAOtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA+HF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAiBrD,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
4
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
5
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
6
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
7
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
8
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
9
|
+
import { random, randomMany } from "../../../../../utils/alea/random.js";
|
|
10
|
+
const getSolutionPoint = (identifiers) => {
|
|
11
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
12
|
+
const origin = points[identifiers.startPointIndex];
|
|
13
|
+
const vec = VectorConstructor.fromPoints(points[identifiers.vectorPointsIndexes[0]], points[identifiers.vectorPointsIndexes[1]]);
|
|
14
|
+
return vec.times(identifiers.coeff.toTree()).getEndPoint(origin, "K");
|
|
15
|
+
};
|
|
16
|
+
const getInstruction = (identifiers) => {
|
|
17
|
+
const { startPointIndex, vectorPointsIndexes } = identifiers;
|
|
18
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
19
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
20
|
+
return `Placer le point $K$ tel que :
|
|
21
|
+
|
|
22
|
+
$$
|
|
23
|
+
\\overrightarrow{${origin}K} = ${identifiers.coeff}\\overrightarrow{${vec}}
|
|
24
|
+
$$`;
|
|
25
|
+
};
|
|
26
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
27
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
28
|
+
const getGGBAnswer = (identifiers) => {
|
|
29
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
30
|
+
};
|
|
31
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
32
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
33
|
+
const ggb = new GeogebraConstructor({
|
|
34
|
+
commands,
|
|
35
|
+
customToolBar: toolBarConstructor({
|
|
36
|
+
point: true,
|
|
37
|
+
}),
|
|
38
|
+
hideAxes: true,
|
|
39
|
+
});
|
|
40
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
41
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
42
|
+
return ggb.getOptions({
|
|
43
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
47
|
+
const studentAns = ans.filter((c) => !["A", "B", "C"].includes(c[0]));
|
|
48
|
+
if (studentAns.length !== 1)
|
|
49
|
+
return false;
|
|
50
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
51
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
52
|
+
if (pointCoords.length !== 1)
|
|
53
|
+
return false;
|
|
54
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
55
|
+
};
|
|
56
|
+
const getTraceVectorMultipleQuestion = () => {
|
|
57
|
+
const names = ["A", "B", "C"];
|
|
58
|
+
let points = [];
|
|
59
|
+
let startPointIndex;
|
|
60
|
+
let vectorPointsIndexes;
|
|
61
|
+
let coeff = 0;
|
|
62
|
+
while (true) {
|
|
63
|
+
points = [];
|
|
64
|
+
coeff = random([-3, -2, 2, 3]);
|
|
65
|
+
points.push(...PointConstructor.randomDifferent(3, {
|
|
66
|
+
minDistance: 2,
|
|
67
|
+
names,
|
|
68
|
+
minDistanceToOrigin: 3,
|
|
69
|
+
}));
|
|
70
|
+
startPointIndex = randint(0, names.length);
|
|
71
|
+
vectorPointsIndexes = randomMany([0, 1, 2], 2);
|
|
72
|
+
const vec = VectorConstructor.fromPoints(points[vectorPointsIndexes[0]], points[vectorPointsIndexes[1]]);
|
|
73
|
+
const endPoint = vec
|
|
74
|
+
.times(coeff.toTree())
|
|
75
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
76
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
77
|
+
points.some((p) => p.equals(endPoint)))
|
|
78
|
+
continue;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
const identifiers = {
|
|
82
|
+
vectorPointsIndexes,
|
|
83
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
84
|
+
startPointIndex,
|
|
85
|
+
coeff,
|
|
86
|
+
};
|
|
87
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
88
|
+
};
|
|
89
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
90
|
+
const question = {
|
|
91
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
92
|
+
instruction: getInstruction(identifiers),
|
|
93
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
94
|
+
identifiers,
|
|
95
|
+
// hint: getHint(identifiers),
|
|
96
|
+
// correction: getCorrection(identifiers),
|
|
97
|
+
};
|
|
98
|
+
return question;
|
|
99
|
+
};
|
|
100
|
+
export const traceVectorMultiple = {
|
|
101
|
+
id: "traceVectorMultiple",
|
|
102
|
+
label: "Placer un point $M$ tel que $\\overrightarrow{AM} = k\\overrightarrow{BC}$",
|
|
103
|
+
isSingleStep: true,
|
|
104
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceVectorMultipleQuestion(opts), nb),
|
|
105
|
+
ggbTimer: 60,
|
|
106
|
+
isGGBAnswerValid,
|
|
107
|
+
subject: "Mathématiques",
|
|
108
|
+
// getHint,
|
|
109
|
+
getInstruction,
|
|
110
|
+
// getCorrection,
|
|
111
|
+
getGGBAnswer,
|
|
112
|
+
getStudentGGBOptions,
|
|
113
|
+
answerType: "GGB",
|
|
114
|
+
getQuestionFromIdentifiers,
|
|
115
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
firstVectorPointsIndexes: number[];
|
|
7
|
+
secondVectorPointsIndexes: number[];
|
|
8
|
+
};
|
|
9
|
+
export declare const traceVectorSum: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=traceVectorSum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceVectorSum.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/traceVectorSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAMtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AAsJF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAgBhD,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
4
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
5
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
6
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
7
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
8
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
9
|
+
import { randomMany } from "../../../../../utils/alea/random.js";
|
|
10
|
+
import { doWhile } from "../../../../../utils/doWhile.js";
|
|
11
|
+
const getSolutionPoint = (identifiers) => {
|
|
12
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
13
|
+
const origin = points[identifiers.startPointIndex];
|
|
14
|
+
const vecs = [
|
|
15
|
+
VectorConstructor.fromPoints(points[identifiers.firstVectorPointsIndexes[0]], points[identifiers.firstVectorPointsIndexes[1]]),
|
|
16
|
+
VectorConstructor.fromPoints(points[identifiers.secondVectorPointsIndexes[0]], points[identifiers.secondVectorPointsIndexes[1]]),
|
|
17
|
+
];
|
|
18
|
+
return vecs[0].add(vecs[1]).getEndPoint(origin, "K");
|
|
19
|
+
};
|
|
20
|
+
const getInstruction = (identifiers) => {
|
|
21
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, } = identifiers;
|
|
22
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
23
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
24
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
25
|
+
return `Placer le point $K$ tel que :
|
|
26
|
+
|
|
27
|
+
$$
|
|
28
|
+
\\overrightarrow{${origin}K} = \\overrightarrow{${firstVec}} + \\overrightarrow{${secondVec}}
|
|
29
|
+
$$`;
|
|
30
|
+
};
|
|
31
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
32
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
33
|
+
const getGGBAnswer = (identifiers) => {
|
|
34
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
35
|
+
};
|
|
36
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
37
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
38
|
+
const ggb = new GeogebraConstructor({
|
|
39
|
+
commands,
|
|
40
|
+
customToolBar: toolBarConstructor({
|
|
41
|
+
point: true,
|
|
42
|
+
}),
|
|
43
|
+
hideAxes: true,
|
|
44
|
+
});
|
|
45
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
46
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
47
|
+
return ggb.getOptions({
|
|
48
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
52
|
+
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
53
|
+
if (studentAns.length !== 1)
|
|
54
|
+
return false;
|
|
55
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
56
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
57
|
+
if (pointCoords.length !== 1)
|
|
58
|
+
return false;
|
|
59
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
60
|
+
};
|
|
61
|
+
const getTraceVectorSumQuestion = () => {
|
|
62
|
+
const names = ["A", "B", "C", "D"];
|
|
63
|
+
let points = [];
|
|
64
|
+
let startPointIndex;
|
|
65
|
+
let firstVectorPointsIndexes;
|
|
66
|
+
let secondVectorPointsIndexes;
|
|
67
|
+
while (true) {
|
|
68
|
+
points = [];
|
|
69
|
+
points.push(...PointConstructor.randomDifferent(4, {
|
|
70
|
+
minDistance: 2,
|
|
71
|
+
names,
|
|
72
|
+
minDistanceToOrigin: 3,
|
|
73
|
+
}));
|
|
74
|
+
startPointIndex = randint(0, names.length);
|
|
75
|
+
firstVectorPointsIndexes = randomMany([0, 1, 2, 3], 2);
|
|
76
|
+
secondVectorPointsIndexes = doWhile(() => randomMany([0, 1, 2, 3], 2), (arr) => arr[0] === firstVectorPointsIndexes[0] &&
|
|
77
|
+
arr[1] === firstVectorPointsIndexes[1]);
|
|
78
|
+
//AC = AB+BC
|
|
79
|
+
const firstVec = VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
80
|
+
const second = VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]);
|
|
81
|
+
const endPoint = firstVec
|
|
82
|
+
.add(second)
|
|
83
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
84
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
85
|
+
points.some((p) => p.equals(endPoint)))
|
|
86
|
+
continue;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
const identifiers = {
|
|
90
|
+
firstVectorPointsIndexes,
|
|
91
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
92
|
+
secondVectorPointsIndexes,
|
|
93
|
+
startPointIndex,
|
|
94
|
+
};
|
|
95
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
96
|
+
};
|
|
97
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
98
|
+
const question = {
|
|
99
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
100
|
+
instruction: getInstruction(identifiers),
|
|
101
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
102
|
+
identifiers,
|
|
103
|
+
// hint: getHint(identifiers),
|
|
104
|
+
// correction: getCorrection(identifiers),
|
|
105
|
+
};
|
|
106
|
+
return question;
|
|
107
|
+
};
|
|
108
|
+
export const traceVectorSum = {
|
|
109
|
+
id: "traceVectorSum",
|
|
110
|
+
label: "Placer un point défini par une somme de vecteurs",
|
|
111
|
+
isSingleStep: true,
|
|
112
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceVectorSumQuestion(opts), nb),
|
|
113
|
+
ggbTimer: 60,
|
|
114
|
+
isGGBAnswerValid,
|
|
115
|
+
subject: "Mathématiques",
|
|
116
|
+
// getHint,
|
|
117
|
+
getInstruction,
|
|
118
|
+
// getCorrection,
|
|
119
|
+
getGGBAnswer,
|
|
120
|
+
getStudentGGBOptions,
|
|
121
|
+
answerType: "GGB",
|
|
122
|
+
getQuestionFromIdentifiers,
|
|
123
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinatesReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/coordinatesReading.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,
|
|
1
|
+
{"version":3,"file":"coordinatesReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/coordinatesReading.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAkIF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
|
|
@@ -2,17 +2,24 @@ import { shuffleProps, tryToAddWrongProp, addValidProp, } from "../../../../exer
|
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randomColor } from "../../../../geogebra/colors.js";
|
|
4
4
|
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { Vector } from "../../../../math/geometry/vector.js";
|
|
5
6
|
import { IntegerConstructor } from "../../../../math/numbers/integer/integer.js";
|
|
6
7
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
8
|
+
import { binom, isBinomialCoefficientNode, } from "../../../../tree/nodes/operators/binomialCoefficientNode.js";
|
|
9
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
10
|
+
import { vectorParser } from "../../../../tree/parsers/vectorParser.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
const getVector = (identifiers) => {
|
|
11
13
|
const { xA, xB, yA, yB } = identifiers;
|
|
12
14
|
const xDelta = xB - xA;
|
|
13
15
|
const yDelta = yB - yA;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
return new Vector("u", xDelta.toTree(), yDelta.toTree());
|
|
17
|
+
};
|
|
18
|
+
const getInstruction = (identifiers) => {
|
|
19
|
+
return `Donner les coordonnées du vecteur $\\overrightarrow u$ représenté ci-dessous :`;
|
|
20
|
+
};
|
|
21
|
+
const getAnswer = (identifiers) => {
|
|
22
|
+
return getVector(identifiers).toBinomCoords().toTex();
|
|
16
23
|
};
|
|
17
24
|
const getGGBOptions = (identifiers) => {
|
|
18
25
|
const { xA, xB, yA, yB } = identifiers;
|
|
@@ -34,14 +41,36 @@ const getGGBOptions = (identifiers) => {
|
|
|
34
41
|
coords: ggb.getAdaptedCoords({ xMax, xMin, yMax, yMin }),
|
|
35
42
|
});
|
|
36
43
|
};
|
|
44
|
+
const getHint = (identifiers) => {
|
|
45
|
+
const vec = new Vector("u", "x".toTree(), "y".toTree());
|
|
46
|
+
return `L'abscisse d'un vecteur est le déplacement en abscisse représenté par le vecteur. L'ordonnée est le déplacement en ordonnée représenté par le vecteur.
|
|
47
|
+
|
|
48
|
+
Si un vecteur a pour abscisse $x$ et pour ordonnée $y$, alors on note :
|
|
49
|
+
|
|
50
|
+
$$
|
|
51
|
+
${vec.toTexWithBinomCoords()}
|
|
52
|
+
$$`;
|
|
53
|
+
};
|
|
54
|
+
const getCorrection = (identifiers) => {
|
|
55
|
+
const vec = getVector(identifiers);
|
|
56
|
+
return `On lit graphiquement que la flèche représentant $\\overrightarrow{u}$ est un déplacement de $${vec.x.toTex()}$ unité(s) en abscisse, et de $${vec.y.toTex()}$ unité(s) en ordonnée.
|
|
57
|
+
|
|
58
|
+
Les coordonnées du vecteur $\\overrightarrow u$ sont donc :
|
|
59
|
+
|
|
60
|
+
$$
|
|
61
|
+
\\overrightarrow{u}${getAnswer(identifiers)}
|
|
62
|
+
$$`;
|
|
63
|
+
};
|
|
37
64
|
const getQuestionFromIdentifiers = (identifiers) => {
|
|
38
65
|
const question = {
|
|
39
66
|
answer: getAnswer(identifiers),
|
|
40
67
|
instruction: getInstruction(identifiers),
|
|
41
|
-
keys: ["semicolon", "
|
|
68
|
+
keys: ["semicolon", "binom"],
|
|
42
69
|
answerFormat: "tex",
|
|
43
70
|
ggbOptions: getGGBOptions(identifiers),
|
|
44
71
|
identifiers,
|
|
72
|
+
hint: getHint(identifiers),
|
|
73
|
+
correction: getCorrection(identifiers),
|
|
45
74
|
};
|
|
46
75
|
return question;
|
|
47
76
|
};
|
|
@@ -57,17 +86,36 @@ const getCoordinatesReadingQuestion = () => {
|
|
|
57
86
|
const getPropositions = (n, { answer, xA, xB, yA, yB }) => {
|
|
58
87
|
const propositions = [];
|
|
59
88
|
addValidProp(propositions, answer);
|
|
60
|
-
tryToAddWrongProp(propositions,
|
|
61
|
-
tryToAddWrongProp(propositions,
|
|
62
|
-
tryToAddWrongProp(propositions,
|
|
63
|
-
tryToAddWrongProp(propositions,
|
|
89
|
+
tryToAddWrongProp(propositions, binom(xA - xB, yA - yB).toTex());
|
|
90
|
+
tryToAddWrongProp(propositions, binom(xA + xB, yA + yB).toTex());
|
|
91
|
+
tryToAddWrongProp(propositions, binom(xA - yA, xB - yB).toTex());
|
|
92
|
+
tryToAddWrongProp(propositions, binom(yA - xA, yB - xB).toTex());
|
|
64
93
|
while (propositions.length < n) {
|
|
65
|
-
tryToAddWrongProp(propositions,
|
|
94
|
+
tryToAddWrongProp(propositions, binom(randint(-10, 10), randint(-10, 10)).toTex());
|
|
66
95
|
}
|
|
67
96
|
return shuffleProps(propositions, n);
|
|
68
97
|
};
|
|
69
|
-
const isAnswerValid = (ans, { answer }) => {
|
|
70
|
-
return [answer, "\\overrightarrow{u}" + answer].includes(ans);
|
|
98
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
99
|
+
// return [answer, "\\overrightarrow{u}" + answer].includes(ans);
|
|
100
|
+
try {
|
|
101
|
+
const solVector = getVector(identifiers);
|
|
102
|
+
if (ans.includes("binom")) {
|
|
103
|
+
const parsed = parseAlgebraic(ans);
|
|
104
|
+
if (!isBinomialCoefficientNode(parsed))
|
|
105
|
+
return false;
|
|
106
|
+
const vec = new Vector("u", parsed.leftChild, parsed.rightChild).simplify();
|
|
107
|
+
return solVector.equals(vec);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const vec = vectorParser(ans);
|
|
111
|
+
if (!vec)
|
|
112
|
+
return false;
|
|
113
|
+
return solVector.equals(vec.simplify());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
return handleVEAError(err);
|
|
118
|
+
}
|
|
71
119
|
};
|
|
72
120
|
export const coordinatesReading = {
|
|
73
121
|
id: "coordinatesReading",
|
|
@@ -82,4 +130,5 @@ export const coordinatesReading = {
|
|
|
82
130
|
hasGeogebra: true,
|
|
83
131
|
subject: "Mathématiques",
|
|
84
132
|
getQuestionFromIdentifiers,
|
|
133
|
+
hasHintAndCorrection: true,
|
|
85
134
|
};
|