math-exercises 3.0.153 → 3.0.154
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/probaStat/basicProbas/index.js +1 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableSituations.d.ts +11 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableSituations.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableSituations.js +136 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.js +3 -79
- package/lib/exercises/math/probaStat/stats1var/medianWithList.js +4 -4
- package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.js +1 -1
- package/lib/exercises/math/spaceGeometry/sphere/index.d.ts +0 -1
- package/lib/exercises/math/spaceGeometry/sphere/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/sphere/index.js +1 -1
- package/lib/geogebra/probas/probaWheelGGBCommands.d.ts +7 -0
- package/lib/geogebra/probas/probaWheelGGBCommands.d.ts.map +1 -0
- package/lib/geogebra/probas/probaWheelGGBCommands.js +79 -0
- package/lib/index.d.ts +0 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/server.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type WheelItem = {
|
|
3
|
+
value: number;
|
|
4
|
+
indexColor: number;
|
|
5
|
+
};
|
|
6
|
+
type Identifiers = {
|
|
7
|
+
items: WheelItem[];
|
|
8
|
+
};
|
|
9
|
+
export declare const pickEquiprobableSituations: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=pickEquiprobableSituations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickEquiprobableSituations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicProbas/pickEquiprobableSituations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AA4IF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAkB5D,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
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 { probaWheelGGBCommands } from "../../../../geogebra/probas/probaWheelGGBCommands.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
//on note le numéro du secteur obtenu
|
|
7
|
+
//on note la couleur du secteur obtenu
|
|
8
|
+
//on note la parité du numéro obtenu
|
|
9
|
+
const getPropositions = (n, { answer, items }) => {
|
|
10
|
+
const propositions = [];
|
|
11
|
+
addValidProp(propositions, answer);
|
|
12
|
+
const colors = [0, 0, 0, 0];
|
|
13
|
+
const nums = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
14
|
+
const pars = [0, 0];
|
|
15
|
+
for (let i = 0; i < items.length; i++) {
|
|
16
|
+
colors[items[i].indexColor]++;
|
|
17
|
+
nums[items[i].value]++;
|
|
18
|
+
if (items[i].value % 2 === 0)
|
|
19
|
+
pars[0]++;
|
|
20
|
+
else
|
|
21
|
+
pars[1]++;
|
|
22
|
+
}
|
|
23
|
+
if (colors.filter((e) => !!e).every((i) => i === colors[0]))
|
|
24
|
+
addValidProp(propositions, "On note la couleur du secteur obtenu", "raw");
|
|
25
|
+
else
|
|
26
|
+
tryToAddWrongProp(propositions, "On note la couleur du secteur obtenu", "raw");
|
|
27
|
+
if (nums.filter((e) => !!e).every((i) => i === nums[0]))
|
|
28
|
+
addValidProp(propositions, "On note le numéro du secteur obtenu", "raw");
|
|
29
|
+
else
|
|
30
|
+
tryToAddWrongProp(propositions, "On note le numéro du secteur obtenu", "raw");
|
|
31
|
+
if (pars.every((i) => i === pars[0]))
|
|
32
|
+
addValidProp(propositions, "On note la parité du secteur obtenu (pair ou impair)", "raw");
|
|
33
|
+
else
|
|
34
|
+
tryToAddWrongProp(propositions, "On note la parité du secteur obtenu (pair ou impair)", "raw");
|
|
35
|
+
return shuffleProps(propositions, n);
|
|
36
|
+
};
|
|
37
|
+
const getInstruction = (identifiers) => {
|
|
38
|
+
const { items } = identifiers;
|
|
39
|
+
return `On fait tourner la roue ci-dessous, dont les $${items.length}$ secteurs ont la même aire.
|
|
40
|
+
|
|
41
|
+
Parmi les situations proposées, laquelle ou lesquelles sont des situations d'équiprobabilité ?`;
|
|
42
|
+
};
|
|
43
|
+
const getHint = () => {
|
|
44
|
+
return "On est dans une situation d'équiprobabilité lorsque toutes les issues ont la même probabilité de se réaliser.";
|
|
45
|
+
};
|
|
46
|
+
const getCorrection = (identifiers) => {
|
|
47
|
+
const { items } = identifiers;
|
|
48
|
+
const colors = [0, 0, 0, 0];
|
|
49
|
+
const nums = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
50
|
+
const pars = [0, 0];
|
|
51
|
+
for (let i = 0; i < items.length; i++) {
|
|
52
|
+
colors[items[i].indexColor]++;
|
|
53
|
+
nums[items[i].value]++;
|
|
54
|
+
if (items[i].value % 2 === 0)
|
|
55
|
+
pars[0]++;
|
|
56
|
+
else
|
|
57
|
+
pars[1]++;
|
|
58
|
+
}
|
|
59
|
+
return `On détaille chaque situation :
|
|
60
|
+
|
|
61
|
+
-
|
|
62
|
+
-
|
|
63
|
+
- `;
|
|
64
|
+
};
|
|
65
|
+
const getGGBOptions = (identifiers) => {
|
|
66
|
+
const { items } = identifiers;
|
|
67
|
+
const ggb = new GeogebraConstructor({
|
|
68
|
+
commands: [...probaWheelGGBCommands(items)],
|
|
69
|
+
hideAxes: true,
|
|
70
|
+
hideGrid: true,
|
|
71
|
+
forbidShiftDragZoom: true,
|
|
72
|
+
});
|
|
73
|
+
return ggb.getOptions({
|
|
74
|
+
coords: [-15, 15, -15, 15],
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const hasRightAnswer = (items) => {
|
|
78
|
+
const colors = [0, 0, 0, 0];
|
|
79
|
+
const nums = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
80
|
+
const pars = [0, 0];
|
|
81
|
+
for (let i = 0; i < items.length; i++) {
|
|
82
|
+
colors[items[i].indexColor]++;
|
|
83
|
+
nums[items[i].value]++;
|
|
84
|
+
if (items[i].value % 2 === 0)
|
|
85
|
+
pars[0]++;
|
|
86
|
+
else
|
|
87
|
+
pars[1]++;
|
|
88
|
+
}
|
|
89
|
+
return (colors.filter((e) => !!e).every((i) => i === colors[0]) ||
|
|
90
|
+
nums
|
|
91
|
+
.filter((e) => !!e)
|
|
92
|
+
.every((i) => i === nums[0] || pars.every((i) => i === pars[0])));
|
|
93
|
+
};
|
|
94
|
+
const getPickEquiprobableSituationsQuestion = () => {
|
|
95
|
+
let items = [];
|
|
96
|
+
do {
|
|
97
|
+
items = [];
|
|
98
|
+
for (let i = 0; i < 9; i++) {
|
|
99
|
+
items.push({
|
|
100
|
+
value: randint(1, 10),
|
|
101
|
+
indexColor: randint(0, 4),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
} while (!hasRightAnswer(items));
|
|
105
|
+
const identifiers = { items };
|
|
106
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
107
|
+
};
|
|
108
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
109
|
+
return {
|
|
110
|
+
instruction: getInstruction(identifiers),
|
|
111
|
+
keys: [],
|
|
112
|
+
answerFormat: "tex",
|
|
113
|
+
identifiers,
|
|
114
|
+
hint: getHint(identifiers),
|
|
115
|
+
correction: getCorrection(identifiers),
|
|
116
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export const pickEquiprobableSituations = {
|
|
120
|
+
id: "pickEquiprobableSituations",
|
|
121
|
+
label: "Déterminer les situations d'équiprobabilité",
|
|
122
|
+
isSingleStep: true,
|
|
123
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPickEquiprobableSituationsQuestion(opts), nb),
|
|
124
|
+
qcmTimer: 60,
|
|
125
|
+
freeTimer: 60,
|
|
126
|
+
getPropositions,
|
|
127
|
+
subject: "Mathématiques",
|
|
128
|
+
getHint,
|
|
129
|
+
getCorrection,
|
|
130
|
+
getInstruction,
|
|
131
|
+
getGGBOptions,
|
|
132
|
+
hasGeogebra: true,
|
|
133
|
+
getQuestionFromIdentifiers,
|
|
134
|
+
answerType: "QCM",
|
|
135
|
+
isQCM: true,
|
|
136
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickEquiprobableTo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicProbas/pickEquiprobableTo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"pickEquiprobableTo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicProbas/pickEquiprobableTo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAgIF,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA2NF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAmBpD,CAAC"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
-
import { blueMain,
|
|
3
|
+
import { blueMain, greenLight, orange, red } from "../../../../geogebra/colors.js";
|
|
4
4
|
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
-
import {
|
|
6
|
-
import { Vector } from "../../../../math/geometry/vector.js";
|
|
5
|
+
import { probaWheelGGBCommands } from "../../../../geogebra/probas/probaWheelGGBCommands.js";
|
|
7
6
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
8
|
-
import { round } from "../../../../math/utils/round.js";
|
|
9
|
-
import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
|
|
10
|
-
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
11
7
|
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
12
8
|
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
13
9
|
import { random, randomMany } from "../../../../utils/alea/random.js";
|
|
@@ -15,78 +11,6 @@ import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
|
15
11
|
import { mdTable } from "../../../../utils/markdown/mdTable.js";
|
|
16
12
|
const colors = [red, blueMain, greenLight, orange];
|
|
17
13
|
const colorNames = ["rouge", "bleu", "vert", "orange"];
|
|
18
|
-
const createVector = (from, to, name, precision = 5) => {
|
|
19
|
-
return new Vector(name, round(substract(to.x, from.x).evaluate(), precision).toTree(), round(substract(to.y, from.y).evaluate(), precision).toTree());
|
|
20
|
-
};
|
|
21
|
-
const createPoint = (x, y, name, precision = 5) => {
|
|
22
|
-
return new Point(name, round(x, precision), round(y, precision));
|
|
23
|
-
};
|
|
24
|
-
const rotatePoint = (target, angle, center, name, precision = 2) => {
|
|
25
|
-
const vSrc = createVector(center, target, "vSrc", precision);
|
|
26
|
-
const vRotated = vSrc.rotate(angle, "vRotated");
|
|
27
|
-
return createPoint(add(center.x, vRotated.x).evaluate(), add(center.y, vRotated.y).evaluate(), name, precision);
|
|
28
|
-
};
|
|
29
|
-
const createPointWithWeights = (arrPointAndWeight) => {
|
|
30
|
-
return arrPointAndWeight.reduce((acc, [p, w]) => {
|
|
31
|
-
return new Point("acc", acc.x.evaluate() + w * p.x.evaluate(), acc.y.evaluate() + w * p.y.evaluate());
|
|
32
|
-
}, new Point("O", 0, 0));
|
|
33
|
-
};
|
|
34
|
-
const probaWheelGGBCommands = (arrItem) => {
|
|
35
|
-
const radius = 12;
|
|
36
|
-
const point0 = new Point("O", 0, 0);
|
|
37
|
-
function createWheelItemGGBCommands(wheelItem, i, angleInDegreesSector) {
|
|
38
|
-
const angleInRadiansSector = (angleInDegreesSector * PiNode.evaluate()) / 180.0;
|
|
39
|
-
const point1Raw = new Point("P1", radius, 0);
|
|
40
|
-
const point2Raw = new Point("P2", radius * Math.cos(angleInRadiansSector), radius * Math.sin(angleInRadiansSector));
|
|
41
|
-
const angleInRadiansRotate = (2 * PiNode.evaluate() * (1.0 * i + 0.5)) / arrItem.length + //center wrt sector
|
|
42
|
-
(PiNode.evaluate() * 3.0) / 2.0; //put first sector on top
|
|
43
|
-
const [point1, point2] = [point1Raw, point2Raw].map((pointRaw) => {
|
|
44
|
-
return rotatePoint(pointRaw, -angleInRadiansRotate, point0, "rotated", 3);
|
|
45
|
-
});
|
|
46
|
-
const pointForLabel = createPointWithWeights([
|
|
47
|
-
[point0, 0.24],
|
|
48
|
-
[point1, 0.38],
|
|
49
|
-
[point2, 0.38],
|
|
50
|
-
]);
|
|
51
|
-
return [
|
|
52
|
-
//circular sector
|
|
53
|
-
`C_${i} = CircularSector(${point0.toMathString()}, ${point1.toMathString()}, ${point2.toMathString()})`,
|
|
54
|
-
`SetFixed(C_${i}, true, false)`,
|
|
55
|
-
`SetColor(C_${i}, "${colorWithOpacity(colors[wheelItem.indexColor], 80)}")`,
|
|
56
|
-
`SetLineThickness(C_${i}, 1)`,
|
|
57
|
-
//border
|
|
58
|
-
`Cb_${i} = CircularSector(${point0.toMathString()}, ${point1.toMathString()}, ${point2.toMathString()})`,
|
|
59
|
-
`SetFixed(Cb_${i}, true, false)`,
|
|
60
|
-
`SetColor(Cb_${i}, "#FF000000")`,
|
|
61
|
-
`SetLineThickness(Cb_${i}, 1)`,
|
|
62
|
-
//label
|
|
63
|
-
`L_${i} = Text("$\\large \\text{${wheelItem.value}}$", ${pointForLabel.toMathString()}, false, true, 0, 0)`,
|
|
64
|
-
`SetFixed(L_${i}, true, false)`,
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
return [
|
|
68
|
-
...arrItem.flatMap((wheelItem, i) => {
|
|
69
|
-
const angleInDegreesSector = 360.0 * (1.0 / arrItem.length);
|
|
70
|
-
const itemCommands = createWheelItemGGBCommands(wheelItem, i, angleInDegreesSector);
|
|
71
|
-
return [...itemCommands];
|
|
72
|
-
}),
|
|
73
|
-
//circle border
|
|
74
|
-
`C = Circle(${point0.toMathString()}, ${radius * 1.05})`,
|
|
75
|
-
`SetFixed(C, true, false)`,
|
|
76
|
-
//triangle
|
|
77
|
-
...(() => {
|
|
78
|
-
const pointTL = new Point("TL", -0.03 * radius, radius + 0.03 * radius);
|
|
79
|
-
const pointTR = new Point("TR", +0.03 * radius, radius + 0.03 * radius);
|
|
80
|
-
const pointB = new Point("TB", 0, radius - 0.03 * radius);
|
|
81
|
-
return [
|
|
82
|
-
`T = Polygon(${pointTL.toMathString()},${pointTR.toMathString()},${pointB.toMathString()})`,
|
|
83
|
-
`SetFilling(T, 1)`,
|
|
84
|
-
`SetColor(T, "#FF000000")`,
|
|
85
|
-
`SetFixed(T, true, false)`,
|
|
86
|
-
];
|
|
87
|
-
})(),
|
|
88
|
-
];
|
|
89
|
-
};
|
|
90
14
|
const getDictEventsAndProba = (arrItem) => {
|
|
91
15
|
const outDict = {};
|
|
92
16
|
const indexesColorsUsed = [
|
|
@@ -356,7 +280,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
356
280
|
export const pickEquiprobableTo = {
|
|
357
281
|
id: "pickEquiprobableTo",
|
|
358
282
|
connector: "=",
|
|
359
|
-
label: "Déterminer les situations équiprobables",
|
|
283
|
+
label: "Déterminer les situations équiprobables à une situation donnée",
|
|
360
284
|
isSingleStep: true,
|
|
361
285
|
generator: (nb, opts) => getDistinctQuestions(() => getPickEquiprobableToQuestion(opts), nb),
|
|
362
286
|
qcmTimer: 60,
|
|
@@ -70,7 +70,7 @@ const getMedianList = (optsIn) => {
|
|
|
70
70
|
const arrayedOptions = optsIn;
|
|
71
71
|
const opts = {
|
|
72
72
|
nbValues: random(arrayedOptions.nbValues ?? optsDefault.nbValues),
|
|
73
|
-
isOrdered: optsIn?.isOrdered ??
|
|
73
|
+
isOrdered: optsIn?.isOrdered ?? false,
|
|
74
74
|
};
|
|
75
75
|
const length = Number(opts.nbValues);
|
|
76
76
|
const randomValues = [...Array(length).keys()].map(() => randint(1, 20));
|
|
@@ -123,9 +123,9 @@ const options = [
|
|
|
123
123
|
},
|
|
124
124
|
];
|
|
125
125
|
export const medianWithList = {
|
|
126
|
-
id: "
|
|
126
|
+
id: "medianWithListOrdered",
|
|
127
127
|
connector: "=",
|
|
128
|
-
label: "Calcul de la médiane d'une liste de valeurs",
|
|
128
|
+
label: "Calcul de la médiane d'une liste de valeurs ordonnée",
|
|
129
129
|
isSingleStep: false,
|
|
130
130
|
generator: (nb, opts) => getDistinctQuestions(() => getMedianList(Object.assign({}, opts, { isOrdered: true })), nb),
|
|
131
131
|
options,
|
|
@@ -138,7 +138,7 @@ export const medianWithList = {
|
|
|
138
138
|
hasHintAndCorrection: true,
|
|
139
139
|
};
|
|
140
140
|
export const medianWithListUnorderedVariant = {
|
|
141
|
-
id: "
|
|
141
|
+
id: "medianWithList",
|
|
142
142
|
connector: "=",
|
|
143
143
|
label: "Calcul de la médiane d'une liste de valeurs non ordonnée",
|
|
144
144
|
isSingleStep: false,
|
|
@@ -275,7 +275,7 @@ const getGGBOptions = (identifiers, optsIn) => {
|
|
|
275
275
|
const projection = +opts.projection;
|
|
276
276
|
const ggb = new GeogebraConstructor({
|
|
277
277
|
commands,
|
|
278
|
-
forbidShiftDragZoom: projection
|
|
278
|
+
forbidShiftDragZoom: projection !== 1,
|
|
279
279
|
is3D: true,
|
|
280
280
|
projection,
|
|
281
281
|
projectionParam: projection === 1 ? 500 : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/sphere/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/sphere/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./pickIsPointInSphereOrBall.js";
|
|
2
|
-
export * from "./sphereLatLonReading.js";
|
|
2
|
+
// export * from "./sphereLatLonReading.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probaWheelGGBCommands.d.ts","sourceRoot":"","sources":["../../../src/geogebra/probas/probaWheelGGBCommands.ts"],"names":[],"mappings":"AAwDA,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,qBAAqB,GAAI,SAAS,SAAS,EAAE,aAwFzD,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Point } from "../../math/geometry/point.js";
|
|
2
|
+
import { Vector } from "../../math/geometry/vector.js";
|
|
3
|
+
import { round } from "../../math/utils/round.js";
|
|
4
|
+
import { PiNode } from "../../tree/nodes/numbers/piNode.js";
|
|
5
|
+
import { add } from "../../tree/nodes/operators/addNode.js";
|
|
6
|
+
import { substract } from "../../tree/nodes/operators/substractNode.js";
|
|
7
|
+
import { colors, colorWithOpacity } from "../colors.js";
|
|
8
|
+
const createVector = (from, to, name, precision = 5) => {
|
|
9
|
+
return new Vector(name, round(substract(to.x, from.x).evaluate(), precision).toTree(), round(substract(to.y, from.y).evaluate(), precision).toTree());
|
|
10
|
+
};
|
|
11
|
+
const createPoint = (x, y, name, precision = 5) => {
|
|
12
|
+
return new Point(name, round(x, precision), round(y, precision));
|
|
13
|
+
};
|
|
14
|
+
const rotatePoint = (target, angle, center, name, precision = 2) => {
|
|
15
|
+
const vSrc = createVector(center, target, "vSrc", precision);
|
|
16
|
+
const vRotated = vSrc.rotate(angle, "vRotated");
|
|
17
|
+
return createPoint(add(center.x, vRotated.x).evaluate(), add(center.y, vRotated.y).evaluate(), name, precision);
|
|
18
|
+
};
|
|
19
|
+
const createPointWithWeights = (arrPointAndWeight) => {
|
|
20
|
+
return arrPointAndWeight.reduce((acc, [p, w]) => {
|
|
21
|
+
return new Point("acc", acc.x.evaluate() + w * p.x.evaluate(), acc.y.evaluate() + w * p.y.evaluate());
|
|
22
|
+
}, new Point("O", 0, 0));
|
|
23
|
+
};
|
|
24
|
+
export const probaWheelGGBCommands = (arrItem) => {
|
|
25
|
+
const radius = 12;
|
|
26
|
+
const point0 = new Point("O", 0, 0);
|
|
27
|
+
function createWheelItemGGBCommands(wheelItem, i, angleInDegreesSector) {
|
|
28
|
+
const angleInRadiansSector = (angleInDegreesSector * PiNode.evaluate()) / 180.0;
|
|
29
|
+
const point1Raw = new Point("P1", radius, 0);
|
|
30
|
+
const point2Raw = new Point("P2", radius * Math.cos(angleInRadiansSector), radius * Math.sin(angleInRadiansSector));
|
|
31
|
+
const angleInRadiansRotate = (2 * PiNode.evaluate() * (1.0 * i + 0.5)) / arrItem.length + //center wrt sector
|
|
32
|
+
(PiNode.evaluate() * 3.0) / 2.0; //put first sector on top
|
|
33
|
+
const [point1, point2] = [point1Raw, point2Raw].map((pointRaw) => {
|
|
34
|
+
return rotatePoint(pointRaw, -angleInRadiansRotate, point0, "rotated", 3);
|
|
35
|
+
});
|
|
36
|
+
const pointForLabel = createPointWithWeights([
|
|
37
|
+
[point0, 0.24],
|
|
38
|
+
[point1, 0.38],
|
|
39
|
+
[point2, 0.38],
|
|
40
|
+
]);
|
|
41
|
+
return [
|
|
42
|
+
//circular sector
|
|
43
|
+
`C_${i} = CircularSector(${point0.toMathString()}, ${point1.toMathString()}, ${point2.toMathString()})`,
|
|
44
|
+
`SetFixed(C_${i}, true, false)`,
|
|
45
|
+
`SetColor(C_${i}, "${colorWithOpacity(colors[wheelItem.indexColor], 80)}")`,
|
|
46
|
+
`SetLineThickness(C_${i}, 1)`,
|
|
47
|
+
//border
|
|
48
|
+
`Cb_${i} = CircularSector(${point0.toMathString()}, ${point1.toMathString()}, ${point2.toMathString()})`,
|
|
49
|
+
`SetFixed(Cb_${i}, true, false)`,
|
|
50
|
+
`SetColor(Cb_${i}, "#FF000000")`,
|
|
51
|
+
`SetLineThickness(Cb_${i}, 1)`,
|
|
52
|
+
//label
|
|
53
|
+
`L_${i} = Text("$\\large \\text{${wheelItem.value}}$", ${pointForLabel.toMathString()}, false, true, 0, 0)`,
|
|
54
|
+
`SetFixed(L_${i}, true, false)`,
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
return [
|
|
58
|
+
...arrItem.flatMap((wheelItem, i) => {
|
|
59
|
+
const angleInDegreesSector = 360.0 * (1.0 / arrItem.length);
|
|
60
|
+
const itemCommands = createWheelItemGGBCommands(wheelItem, i, angleInDegreesSector);
|
|
61
|
+
return [...itemCommands];
|
|
62
|
+
}),
|
|
63
|
+
//circle border
|
|
64
|
+
`C = Circle(${point0.toMathString()}, ${radius * 1.05})`,
|
|
65
|
+
`SetFixed(C, true, false)`,
|
|
66
|
+
//triangle
|
|
67
|
+
...(() => {
|
|
68
|
+
const pointTL = new Point("TL", -0.03 * radius, radius + 0.03 * radius);
|
|
69
|
+
const pointTR = new Point("TR", +0.03 * radius, radius + 0.03 * radius);
|
|
70
|
+
const pointB = new Point("TB", 0, radius - 0.03 * radius);
|
|
71
|
+
return [
|
|
72
|
+
`T = Polygon(${pointTL.toMathString()},${pointTR.toMathString()},${pointB.toMathString()})`,
|
|
73
|
+
`SetFilling(T, 1)`,
|
|
74
|
+
`SetColor(T, "#FF000000")`,
|
|
75
|
+
`SetFixed(T, true, false)`,
|
|
76
|
+
];
|
|
77
|
+
})(),
|
|
78
|
+
];
|
|
79
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -3102,13 +3102,6 @@ declare const mathExercises: (Exercise<{
|
|
|
3102
3102
|
nbs: number[];
|
|
3103
3103
|
radius: number;
|
|
3104
3104
|
isSphere: boolean;
|
|
3105
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3106
|
-
pointsDict: Record<string, {
|
|
3107
|
-
latLon: import("./math/geometry/point.js").PointIdentifiers;
|
|
3108
|
-
"3d": import("./math/geometry/spacePoint.js").SpacePointIdentifiers;
|
|
3109
|
-
}>;
|
|
3110
|
-
isLatitude: boolean;
|
|
3111
|
-
namePointTarget: string;
|
|
3112
3105
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3113
3106
|
indexFamily: number;
|
|
3114
3107
|
indexPattern: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"A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;;;;;;;;;;;;;;kDAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
package/lib/server.js
CHANGED
|
@@ -84,7 +84,10 @@ const runServer = () => {
|
|
|
84
84
|
const identifiers = req.query.identifiers
|
|
85
85
|
? JSON.parse(decodeURIComponent(req.query.identifiers))
|
|
86
86
|
: undefined;
|
|
87
|
-
const
|
|
87
|
+
const hasAnswer = !!req.query.answer && req.query.answer !== "undefined";
|
|
88
|
+
const answer = hasAnswer
|
|
89
|
+
? JSON.parse(decodeURIComponent(req.query.answer))
|
|
90
|
+
: "";
|
|
88
91
|
const exo = allExercises.find((exo) => exo.id == exoId);
|
|
89
92
|
if (!exo) {
|
|
90
93
|
res.send("Exo not found");
|