math-exercises 2.2.48 → 2.2.49
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/exercise.d.ts +5 -1
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSum.js +12 -4
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +33 -5
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +39 -5
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +33 -8
- package/lib/exercises/math/geometry/index.d.ts +1 -0
- package/lib/exercises/math/geometry/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/index.js +1 -0
- package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts +8 -0
- package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts.map +1 -0
- package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.js +110 -0
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts +8 -0
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -0
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +108 -0
- package/lib/exercises/math/geometry/parametric/index.d.ts +4 -0
- package/lib/exercises/math/geometry/parametric/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/parametric/index.js +19 -0
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts +12 -0
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts.map +1 -0
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.js +95 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.js +66 -24
- package/lib/index.d.ts +14 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/parametricLine.d.ts +15 -0
- package/lib/math/geometry/parametricLine.d.ts.map +1 -0
- package/lib/math/geometry/parametricLine.js +47 -0
- package/lib/math/geometry/spacePoint.d.ts +3 -0
- package/lib/math/geometry/spacePoint.d.ts.map +1 -1
- package/lib/math/geometry/spacePoint.js +12 -0
- package/lib/math/geometry/spaceVector.d.ts +5 -0
- package/lib/math/geometry/spaceVector.d.ts.map +1 -1
- package/lib/math/geometry/spaceVector.js +20 -0
- package/lib/server.js +7 -3
- package/lib/tree/parsers/rationalParser.d.ts +2 -0
- package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
- package/lib/tree/parsers/rationalParser.js +33 -8
- package/lib/tree/parsers/spacePointParser.d.ts +3 -0
- package/lib/tree/parsers/spacePointParser.d.ts.map +1 -0
- package/lib/tree/parsers/spacePointParser.js +18 -0
- package/lib/tree/parsers/spaceVectorParser.d.ts +3 -0
- package/lib/tree/parsers/spaceVectorParser.d.ts.map +1 -0
- package/lib/tree/parsers/spaceVectorParser.js +18 -0
- package/lib/tree/parsers/valueParser.d.ts +2 -0
- package/lib/tree/parsers/valueParser.d.ts.map +1 -0
- package/lib/tree/parsers/valueParser.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./pointFromParametricLine"), exports);
|
|
18
|
+
__exportStar(require("./extractPointFromParametricLine"), exports);
|
|
19
|
+
__exportStar(require("./extractVectorFromParametricLine"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
startPoint: number[];
|
|
4
|
+
vector: number[];
|
|
5
|
+
askedPointCoords: number[];
|
|
6
|
+
askedPointName: string;
|
|
7
|
+
isOnLine: boolean;
|
|
8
|
+
coeff?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const pointFromParametricLine: Exercise<Identifiers>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=pointFromParametricLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/pointFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAqFF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAkBzD,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pointFromParametricLine = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const parametricLine_1 = require("../../../../math/geometry/parametricLine");
|
|
7
|
+
const spacePoint_1 = require("../../../../math/geometry/spacePoint");
|
|
8
|
+
const spaceVector_1 = require("../../../../math/geometry/spaceVector");
|
|
9
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
10
|
+
const coinFlip_1 = require("../../../../utils/alea/coinFlip");
|
|
11
|
+
const randomLetter_1 = require("../../../../utils/strings/randomLetter");
|
|
12
|
+
const getPropositions = (n, { answer }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
(0, exercise_1.addValidProp)(propositions, answer, "raw");
|
|
15
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
|
|
16
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
|
|
17
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
|
|
18
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
19
|
+
};
|
|
20
|
+
const getAnswer = (identifiers) => {
|
|
21
|
+
return identifiers.isOnLine ? "Oui" : "Non";
|
|
22
|
+
};
|
|
23
|
+
const getInstruction = (identifiers) => {
|
|
24
|
+
const point = spacePoint_1.SpacePointConstructor.fromScalars(identifiers.askedPointCoords, identifiers.askedPointName);
|
|
25
|
+
const line = new parametricLine_1.ParametricLine(point, spaceVector_1.SpaceVectorConstructor.fromScalars(identifiers.vector));
|
|
26
|
+
return `Soit $d$ la droite d'équation paramétrique :
|
|
27
|
+
|
|
28
|
+
$$
|
|
29
|
+
${line.toTex()}
|
|
30
|
+
$$
|
|
31
|
+
|
|
32
|
+
où $t\\in \\mathbb{R}$.
|
|
33
|
+
|
|
34
|
+
Le point $${point.toTexWithCoords()}$ appartient-il à $d$ ?
|
|
35
|
+
`;
|
|
36
|
+
};
|
|
37
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
38
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
39
|
+
const getKeys = (identifiers) => {
|
|
40
|
+
return [];
|
|
41
|
+
};
|
|
42
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
43
|
+
throw Error("VEA not implemented");
|
|
44
|
+
};
|
|
45
|
+
const getPointFromParametricLineQuestion = () => {
|
|
46
|
+
const startPoint = spacePoint_1.SpacePointConstructor.random("A");
|
|
47
|
+
const vector = spaceVector_1.SpaceVectorConstructor.random("B");
|
|
48
|
+
const isOnLine = (0, coinFlip_1.coinFlip)();
|
|
49
|
+
const askedPointName = (0, randomLetter_1.randomLetter)(true, ["O"]);
|
|
50
|
+
let askedPoint;
|
|
51
|
+
let coeff;
|
|
52
|
+
if (isOnLine) {
|
|
53
|
+
coeff = (0, randint_1.randint)(-10, 10);
|
|
54
|
+
const res = vector.times(coeff.toTree());
|
|
55
|
+
askedPoint = res.getEndPoint(startPoint);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
askedPoint = spacePoint_1.SpacePointConstructor.random(askedPointName);
|
|
59
|
+
}
|
|
60
|
+
// const askedPoint = SpacePointConstructor.random(askedPointName);
|
|
61
|
+
const identifiers = {
|
|
62
|
+
startPoint: startPoint.getEvaluatedCoords(),
|
|
63
|
+
vector: vector.getEvaluatedCoords(),
|
|
64
|
+
askedPointCoords: askedPoint.getEvaluatedCoords(),
|
|
65
|
+
askedPointName,
|
|
66
|
+
isOnLine,
|
|
67
|
+
};
|
|
68
|
+
const question = {
|
|
69
|
+
answer: getAnswer(identifiers),
|
|
70
|
+
instruction: getInstruction(identifiers),
|
|
71
|
+
keys: getKeys(identifiers),
|
|
72
|
+
answerFormat: "tex",
|
|
73
|
+
identifiers,
|
|
74
|
+
// hint: getHint(identifiers),
|
|
75
|
+
// correction: getCorrection(identifiers),
|
|
76
|
+
};
|
|
77
|
+
return question;
|
|
78
|
+
};
|
|
79
|
+
exports.pointFromParametricLine = {
|
|
80
|
+
id: "pointFromParametricLine",
|
|
81
|
+
connector: "=",
|
|
82
|
+
label: "Vérifier si un point appartient à une droite d'équation paramétrique donnée",
|
|
83
|
+
isSingleStep: true,
|
|
84
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getPointFromParametricLineQuestion, nb),
|
|
85
|
+
qcmTimer: 60,
|
|
86
|
+
freeTimer: 60,
|
|
87
|
+
getPropositions,
|
|
88
|
+
isAnswerValid,
|
|
89
|
+
subject: "Mathématiques",
|
|
90
|
+
// getHint,
|
|
91
|
+
// getCorrection,
|
|
92
|
+
getAnswer,
|
|
93
|
+
getKeys,
|
|
94
|
+
answerType: "QCU",
|
|
95
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arithmeticFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"arithmeticFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAiIF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}
|
|
@@ -8,34 +8,61 @@ const randint_1 = require("../../../../math/utils/random/randint");
|
|
|
8
8
|
const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
|
|
9
9
|
const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
|
|
10
10
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
11
|
-
const
|
|
12
|
-
const firstRank = 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
keys: ["un", "equal", "n"],
|
|
21
|
-
answerFormat: "tex",
|
|
22
|
-
identifiers: { firstValue, reason },
|
|
23
|
-
hint: `Utilise la formule générale d'une suite arithmétique :
|
|
11
|
+
const getInstruction = (identifiers, opts) => {
|
|
12
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
13
|
+
return `$(u_n)$ est une suite arithmétique de premier terme $u_{${firstRank}} = ${identifiers.firstValue}$ et de raison $r = ${identifiers.reason}$.
|
|
14
|
+
|
|
15
|
+
Donner l'expression de $u_n$ en fonction de $n$.`;
|
|
16
|
+
};
|
|
17
|
+
const getHint = (identifiers, opts) => {
|
|
18
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
19
|
+
return `Utilise la formule générale d'une suite arithmétique :
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
$$
|
|
22
|
+
${firstRank === 0 ? "u_n = u_0 + n \\times r" : "u_n = u_1 + (n-1) \\times r"}
|
|
23
|
+
$$
|
|
26
24
|
|
|
27
|
-
où $
|
|
28
|
-
|
|
25
|
+
où $u_${firstRank}$ est le premier terme et $r$ la raison.`;
|
|
26
|
+
};
|
|
27
|
+
const getCorrection = (identifiers, opts) => {
|
|
28
|
+
const firstRank = opts?.firstTermRankOne ? 1 : 0;
|
|
29
|
+
const answer = getAnswer(identifiers, opts);
|
|
30
|
+
return `La formule générale d'une suite arithmétique est :
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
$$
|
|
33
|
+
${firstRank === 0 ? "u_n = u_0 + n \\times r " : "u_n = u_1 + (n-1) \\times r "}
|
|
34
|
+
$$
|
|
31
35
|
|
|
32
|
-
où $
|
|
36
|
+
où $u_${firstRank}$ est le premier terme et $r$ la raison.
|
|
33
37
|
|
|
34
|
-
Ici, puisque $
|
|
38
|
+
Ici, puisque $u_${firstRank} = ${identifiers.firstValue}$ et $r = ${identifiers.reason}$, on a :
|
|
35
39
|
|
|
36
|
-
$$
|
|
40
|
+
$$
|
|
41
|
+
${answer}
|
|
42
|
+
$$
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
`;
|
|
45
|
+
};
|
|
46
|
+
const getAnswer = (identifiers, opts) => {
|
|
47
|
+
const { firstValue, reason } = identifiers;
|
|
48
|
+
const formula = opts?.firstTermRankOne
|
|
49
|
+
? new polynomial_1.Polynomial([firstValue - reason, reason], "n")
|
|
50
|
+
: new polynomial_1.Polynomial([firstValue, reason], "n");
|
|
51
|
+
const answer = "u_n=" + formula.toTex();
|
|
52
|
+
return answer;
|
|
53
|
+
};
|
|
54
|
+
const getArithmeticFindExplicitFormula = (opts) => {
|
|
55
|
+
const firstValue = (0, randint_1.randint)(-10, 10);
|
|
56
|
+
const reason = (0, randint_1.randint)(-10, 10, [0]);
|
|
57
|
+
const identifiers = { firstValue, reason };
|
|
58
|
+
const question = {
|
|
59
|
+
instruction: getInstruction(identifiers, opts),
|
|
60
|
+
answer: getAnswer(identifiers, opts),
|
|
61
|
+
keys: ["un", "equal", "n"],
|
|
62
|
+
answerFormat: "tex",
|
|
63
|
+
identifiers,
|
|
64
|
+
hint: getHint(identifiers, opts),
|
|
65
|
+
correction: getCorrection(identifiers, opts),
|
|
39
66
|
};
|
|
40
67
|
return question;
|
|
41
68
|
};
|
|
@@ -50,14 +77,24 @@ const getPropositions = (n, { answer, firstValue, reason }) => {
|
|
|
50
77
|
}
|
|
51
78
|
return (0, shuffle_1.shuffle)(propositions);
|
|
52
79
|
};
|
|
53
|
-
const isAnswerValid = (ans, { reason, firstValue }) => {
|
|
54
|
-
const formula =
|
|
80
|
+
const isAnswerValid = (ans, { reason, firstValue }, opts) => {
|
|
81
|
+
const formula = opts?.firstTermRankOne
|
|
82
|
+
? new polynomial_1.Polynomial([firstValue - reason, reason], "n")
|
|
83
|
+
: new polynomial_1.Polynomial([firstValue, reason], "n");
|
|
55
84
|
const equal = new equalNode_1.EqualNode(new variableNode_1.VariableNode("u_n"), formula.toTree(), {
|
|
56
85
|
allowRawRightChildAsSolution: true,
|
|
57
86
|
});
|
|
58
87
|
const texs = equal.toAllValidTexs();
|
|
59
88
|
return texs.includes(ans);
|
|
60
89
|
};
|
|
90
|
+
const options = [
|
|
91
|
+
{
|
|
92
|
+
id: "firstTermRankOne",
|
|
93
|
+
label: "Utiliser $u_1$ comme premier terme",
|
|
94
|
+
target: exercise_1.GeneratorOptionTarget.generation,
|
|
95
|
+
type: exercise_1.GeneratorOptionType.checkbox,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
61
98
|
exports.arithmeticFindExplicitFormula = {
|
|
62
99
|
id: "arithmeticFindExplicitFormula",
|
|
63
100
|
connector: "=",
|
|
@@ -65,11 +102,16 @@ exports.arithmeticFindExplicitFormula = {
|
|
|
65
102
|
levels: ["1reESM", "1reSpé", "1reTech", "1rePro", "TermTech", "TermPro"],
|
|
66
103
|
sections: ["Suites"],
|
|
67
104
|
isSingleStep: false,
|
|
68
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getArithmeticFindExplicitFormula, nb),
|
|
105
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getArithmeticFindExplicitFormula(opts), nb),
|
|
69
106
|
qcmTimer: 60,
|
|
70
107
|
freeTimer: 60,
|
|
71
108
|
getPropositions,
|
|
72
109
|
isAnswerValid,
|
|
73
110
|
subject: "Mathématiques",
|
|
74
111
|
hasHintAndCorrection: true,
|
|
112
|
+
options,
|
|
113
|
+
getAnswer,
|
|
114
|
+
getCorrection,
|
|
115
|
+
getHint,
|
|
116
|
+
getInstruction,
|
|
75
117
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
47
47
|
rational: [number, number];
|
|
48
48
|
rational2: [number, number];
|
|
49
49
|
}, {
|
|
50
|
-
allowNonIrreductible
|
|
50
|
+
allowNonIrreductible?: boolean | undefined;
|
|
51
51
|
}> | import("./exercises/exercise").Exercise<{
|
|
52
52
|
num: number;
|
|
53
53
|
denum: number;
|
|
@@ -1061,6 +1061,19 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
1061
1061
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1062
1062
|
type: number;
|
|
1063
1063
|
commands: string[];
|
|
1064
|
+
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1065
|
+
startPoint: number[];
|
|
1066
|
+
vector: number[];
|
|
1067
|
+
askedPointCoords: number[];
|
|
1068
|
+
askedPointName: string;
|
|
1069
|
+
isOnLine: boolean;
|
|
1070
|
+
coeff?: number | undefined;
|
|
1071
|
+
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1072
|
+
startPoint: number[];
|
|
1073
|
+
vector: number[];
|
|
1074
|
+
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1075
|
+
startPoint: number[];
|
|
1076
|
+
vector: number[];
|
|
1064
1077
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1065
1078
|
coeffs: number[];
|
|
1066
1079
|
to: string;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
|
+
import { SpacePoint } from "./spacePoint";
|
|
3
|
+
import { SpaceVector } from "./spaceVector";
|
|
4
|
+
export declare class ParametricLine {
|
|
5
|
+
startPoint: SpacePoint;
|
|
6
|
+
vector: SpaceVector;
|
|
7
|
+
equations: AlgebraicNode[];
|
|
8
|
+
constructor(startPoint: SpacePoint, vector: SpaceVector);
|
|
9
|
+
toDetailedEvaluation(t: AlgebraicNode): AlgebraicNode[];
|
|
10
|
+
getPointCoords(t: AlgebraicNode): AlgebraicNode[];
|
|
11
|
+
getPoint(t: AlgebraicNode): SpacePoint;
|
|
12
|
+
hasPoint(p: SpacePoint): boolean;
|
|
13
|
+
toTex(): string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=parametricLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parametricLine.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/parametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AAEpE,qBAAa,cAAc;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,aAAa,EAAE,CAAC;gBACf,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW;IAavD,oBAAoB,CAAC,CAAC,EAAE,aAAa;IAIrC,cAAc,CAAC,CAAC,EAAE,aAAa;IAG/B,QAAQ,CAAC,CAAC,EAAE,aAAa;IAKzB,QAAQ,CAAC,CAAC,EAAE,UAAU;IAYtB,KAAK;CAUN"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParametricLine = void 0;
|
|
4
|
+
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
5
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
6
|
+
const variableNode_1 = require("../../tree/nodes/variables/variableNode");
|
|
7
|
+
const spacePoint_1 = require("./spacePoint");
|
|
8
|
+
const spaceVector_1 = require("./spaceVector");
|
|
9
|
+
class ParametricLine {
|
|
10
|
+
constructor(startPoint, vector) {
|
|
11
|
+
this.startPoint = startPoint;
|
|
12
|
+
this.vector = vector;
|
|
13
|
+
const pointCoords = this.startPoint.getCoords();
|
|
14
|
+
const vectorCoords = this.vector.getCoords();
|
|
15
|
+
this.equations = [0, 1, 2].map((i) => new addNode_1.AddNode(pointCoords[i], new multiplyNode_1.MultiplyNode(vectorCoords[i], new variableNode_1.VariableNode("t"))).simplify({ forbidFactorize: true }));
|
|
16
|
+
}
|
|
17
|
+
toDetailedEvaluation(t) {
|
|
18
|
+
return this.equations.map((e) => e.toDetailedEvaluation({ t: t }));
|
|
19
|
+
}
|
|
20
|
+
getPointCoords(t) {
|
|
21
|
+
return this.toDetailedEvaluation(t).map((e) => e.simplify());
|
|
22
|
+
}
|
|
23
|
+
getPoint(t) {
|
|
24
|
+
const pointCoords = this.toDetailedEvaluation(t).map((e) => e.simplify());
|
|
25
|
+
return new spacePoint_1.SpacePoint("A", pointCoords[0], pointCoords[1], pointCoords[2]);
|
|
26
|
+
}
|
|
27
|
+
hasPoint(p) {
|
|
28
|
+
if (p.equals(this.startPoint))
|
|
29
|
+
return true;
|
|
30
|
+
const secondPoint = this.vector.getEndPoint(this.startPoint);
|
|
31
|
+
const vector1 = spaceVector_1.SpaceVectorConstructor.fromPoints(this.startPoint, p);
|
|
32
|
+
const vector2 = spaceVector_1.SpaceVectorConstructor.fromPoints(this.startPoint, secondPoint);
|
|
33
|
+
console.log(vector1.toInlineCoordsTex(), vector2.toInlineCoordsTex());
|
|
34
|
+
return vector1.isColinear(vector2);
|
|
35
|
+
}
|
|
36
|
+
toTex() {
|
|
37
|
+
return `
|
|
38
|
+
\\left\\{\\begin{matrix}
|
|
39
|
+
x=${this.equations[0].toTex()} \\\\
|
|
40
|
+
y=${this.equations[1].toTex()} \\\\
|
|
41
|
+
z=${this.equations[2].toTex()}
|
|
42
|
+
\\end{matrix}
|
|
43
|
+
\\right.
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.ParametricLine = ParametricLine;
|
|
@@ -7,6 +7,7 @@ type AleaBound = {
|
|
|
7
7
|
export declare abstract class SpacePointConstructor {
|
|
8
8
|
static random(name: string, xOpts?: AleaBound, yOpts?: AleaBound, zOpts?: AleaBound): SpacePoint;
|
|
9
9
|
static randomDifferent(names: string[]): SpacePoint[];
|
|
10
|
+
static fromScalars(arr: number[], name?: string): SpacePoint;
|
|
10
11
|
}
|
|
11
12
|
export declare class SpacePoint {
|
|
12
13
|
name: string;
|
|
@@ -14,6 +15,8 @@ export declare class SpacePoint {
|
|
|
14
15
|
y: AlgebraicNode;
|
|
15
16
|
z: AlgebraicNode;
|
|
16
17
|
constructor(name: string, x: AlgebraicNode, y: AlgebraicNode, z: AlgebraicNode);
|
|
18
|
+
getCoords(): AlgebraicNode[];
|
|
19
|
+
getEvaluatedCoords(): number[];
|
|
17
20
|
toTex(): string;
|
|
18
21
|
toTexWithCoords(): string;
|
|
19
22
|
toCoords(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacePoint.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/spacePoint.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa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ChB,CAAC,EAAE,aAAa;IAQlB,SAAS;IAGT,kBAAkB;IAIlB,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAKzB,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,SAAM,GAAG,UAAU;IAkB/C,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM;IAIjC,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU;IAOtC,YAAY;CAKb"}
|
|
@@ -27,6 +27,12 @@ class SpacePointConstructor {
|
|
|
27
27
|
}
|
|
28
28
|
return res;
|
|
29
29
|
}
|
|
30
|
+
static fromScalars(arr, name = "A") {
|
|
31
|
+
if (arr.length !== 3) {
|
|
32
|
+
throw new Error("array must have 3 elements");
|
|
33
|
+
}
|
|
34
|
+
return new SpacePoint(name, new numberNode_1.NumberNode(arr[0]), new numberNode_1.NumberNode(arr[1]), new numberNode_1.NumberNode(arr[2]));
|
|
35
|
+
}
|
|
30
36
|
}
|
|
31
37
|
exports.SpacePointConstructor = SpacePointConstructor;
|
|
32
38
|
class SpacePoint {
|
|
@@ -36,6 +42,12 @@ class SpacePoint {
|
|
|
36
42
|
this.y = y;
|
|
37
43
|
this.z = z;
|
|
38
44
|
}
|
|
45
|
+
getCoords() {
|
|
46
|
+
return [this.x, this.y, this.z];
|
|
47
|
+
}
|
|
48
|
+
getEvaluatedCoords() {
|
|
49
|
+
return this.getCoords().map((e) => e.evaluate({}));
|
|
50
|
+
}
|
|
39
51
|
toTex() {
|
|
40
52
|
return `${this.name}`;
|
|
41
53
|
}
|
|
@@ -5,6 +5,7 @@ export declare abstract class SpaceVectorConstructor {
|
|
|
5
5
|
static fromPoints(origin: SpacePoint, end: SpacePoint): SpaceVector;
|
|
6
6
|
static random(name: string, allowNull?: boolean): SpaceVector;
|
|
7
7
|
static randomDifferents(names: string[], allowNull?: boolean): SpaceVector[];
|
|
8
|
+
static fromScalars(arr: number[]): SpaceVector;
|
|
8
9
|
}
|
|
9
10
|
export declare class SpaceVector {
|
|
10
11
|
name: string;
|
|
@@ -13,11 +14,15 @@ export declare class SpaceVector {
|
|
|
13
14
|
y: AlgebraicNode;
|
|
14
15
|
z: AlgebraicNode;
|
|
15
16
|
constructor(name: string, x: AlgebraicNode, y: AlgebraicNode, z: AlgebraicNode);
|
|
17
|
+
getCoords(): AlgebraicNode[];
|
|
18
|
+
getEvaluatedCoords(): number[];
|
|
16
19
|
toTex(): string;
|
|
17
20
|
toCoordsTex(): string;
|
|
18
21
|
toInlineCoordsTex(): string;
|
|
19
22
|
toTexWithCoords(): string;
|
|
23
|
+
vetorialProduct(v: SpaceVector): SpaceVector;
|
|
20
24
|
isColinear(v: SpaceVector): boolean;
|
|
25
|
+
isCoplanar(v: SpaceVector): boolean;
|
|
21
26
|
determinant(v: SpaceVector): AlgebraicNode;
|
|
22
27
|
times(k: AlgebraicNode, name?: string): SpaceVector;
|
|
23
28
|
scalarProduct(v: SpaceVector): Node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaceVector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/spaceVector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"spaceVector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/spaceVector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;AASvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,8BAAsB,sBAAsB;IAC1C,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAA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aceVector = exports.SpaceVectorConstructor = void 0;
|
|
4
4
|
const sqrtNode_1 = require("../../tree/nodes/functions/sqrtNode");
|
|
5
|
+
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
5
6
|
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
6
7
|
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
7
8
|
const powerNode_1 = require("../../tree/nodes/operators/powerNode");
|
|
@@ -34,6 +35,12 @@ class SpaceVectorConstructor {
|
|
|
34
35
|
}
|
|
35
36
|
return res;
|
|
36
37
|
}
|
|
38
|
+
static fromScalars(arr) {
|
|
39
|
+
if (arr.length !== 3) {
|
|
40
|
+
throw new Error("array must have 3 elements");
|
|
41
|
+
}
|
|
42
|
+
return new SpaceVector("P", new numberNode_1.NumberNode(arr[0]), new numberNode_1.NumberNode(arr[1]), new numberNode_1.NumberNode(arr[2]));
|
|
43
|
+
}
|
|
37
44
|
}
|
|
38
45
|
exports.SpaceVectorConstructor = SpaceVectorConstructor;
|
|
39
46
|
class SpaceVector {
|
|
@@ -44,6 +51,12 @@ class SpaceVector {
|
|
|
44
51
|
this.y = y;
|
|
45
52
|
this.z = z;
|
|
46
53
|
}
|
|
54
|
+
getCoords() {
|
|
55
|
+
return [this.x, this.y, this.z];
|
|
56
|
+
}
|
|
57
|
+
getEvaluatedCoords() {
|
|
58
|
+
return this.getCoords().map((e) => e.evaluate({}));
|
|
59
|
+
}
|
|
47
60
|
toTex() {
|
|
48
61
|
return `\\overrightarrow{${this.name}}`;
|
|
49
62
|
}
|
|
@@ -58,7 +71,14 @@ class SpaceVector {
|
|
|
58
71
|
toTexWithCoords() {
|
|
59
72
|
return `\\overrightarrow{${this.name}}\\begin{pmatrix}${this.x.toTex()} \\\\ ${this.y.toTex()} \\\\ ${this.z.toTex()} \\end{pmatrix}`;
|
|
60
73
|
}
|
|
74
|
+
vetorialProduct(v) {
|
|
75
|
+
return new SpaceVector(`w`, new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(this.y, v.z), new multiplyNode_1.MultiplyNode(this.z, v.y)).simplify(), new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(this.z, v.x), new multiplyNode_1.MultiplyNode(this.x, v.z)).simplify(), new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(this.x, v.y), new multiplyNode_1.MultiplyNode(this.y, v.x)).simplify());
|
|
76
|
+
}
|
|
61
77
|
isColinear(v) {
|
|
78
|
+
const vectorialProduct = this.vetorialProduct(v);
|
|
79
|
+
return vectorialProduct.equals(new SpaceVector("0", (0).toTree(), (0).toTree(), (0).toTree()));
|
|
80
|
+
}
|
|
81
|
+
isCoplanar(v) {
|
|
62
82
|
throw Error("unimplemented");
|
|
63
83
|
}
|
|
64
84
|
determinant(v) {
|
package/lib/server.js
CHANGED
|
@@ -58,9 +58,11 @@ const runServer = () => {
|
|
|
58
58
|
});
|
|
59
59
|
app.get("/exo", (req, res) => {
|
|
60
60
|
const exoId = req.query.exoId;
|
|
61
|
+
console.log(req.query.options);
|
|
61
62
|
const options = req.query.options
|
|
62
63
|
? JSON.parse(req.query.options)
|
|
63
64
|
: undefined;
|
|
65
|
+
console.log("parsed", options);
|
|
64
66
|
const exoIndex = allExercises.findIndex((exo) => exo.id == exoId);
|
|
65
67
|
const exo = allExercises[exoIndex];
|
|
66
68
|
if (!exo)
|
|
@@ -76,18 +78,21 @@ const runServer = () => {
|
|
|
76
78
|
});
|
|
77
79
|
app.get("/qcmExo", (req, res) => {
|
|
78
80
|
const exoId = req.query.exoId;
|
|
81
|
+
const options = req.query.options
|
|
82
|
+
? JSON.parse(req.query.options)
|
|
83
|
+
: undefined;
|
|
79
84
|
const exoIndex = allExercises.findIndex((exo) => exo.id == exoId);
|
|
80
85
|
const exo = allExercises[exoIndex];
|
|
81
86
|
if (!exo)
|
|
82
87
|
res.send("Exo not found");
|
|
83
|
-
const questions = exo?.generator(10);
|
|
88
|
+
const questions = exo?.generator(10, options);
|
|
84
89
|
const populatedQuestions = questions?.map((q) => {
|
|
85
90
|
return {
|
|
86
91
|
...q,
|
|
87
92
|
propositions: exo.getPropositions?.(4, {
|
|
88
93
|
answer: q.answer,
|
|
89
94
|
...q.identifiers,
|
|
90
|
-
}),
|
|
95
|
+
}, options),
|
|
91
96
|
};
|
|
92
97
|
});
|
|
93
98
|
res.json({
|
|
@@ -103,7 +108,6 @@ const runServer = () => {
|
|
|
103
108
|
const options = req.query.options
|
|
104
109
|
? JSON.parse(req.query.options)
|
|
105
110
|
: undefined;
|
|
106
|
-
console.log("vea opts", options);
|
|
107
111
|
const { ans, veaProps } = req.body;
|
|
108
112
|
const exoIndex = allExercises.findIndex((exo) => exo.id == exoId);
|
|
109
113
|
const exo = allExercises[exoIndex];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rationalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/rationalParser.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"rationalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/rationalParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D,eAAO,MAAM,cAAc,QAAS,MAAM,sFAyBzC,CAAC"}
|
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rationalParser = void 0;
|
|
4
|
+
const fractionNode_1 = require("../nodes/operators/fractionNode");
|
|
5
|
+
const numberParser_1 = require("./numberParser");
|
|
6
|
+
const rationalParser = (ans) => {
|
|
7
|
+
const nb = (0, numberParser_1.numberParser)(ans);
|
|
8
|
+
if (nb !== false) {
|
|
9
|
+
return nb.toTree();
|
|
10
|
+
}
|
|
11
|
+
if (!ans.includes("\\frac"))
|
|
12
|
+
return false;
|
|
13
|
+
if (ans.startsWith("\\frac")) {
|
|
14
|
+
const fracs = ans.replaceAll("}", "").split("{").slice(1);
|
|
15
|
+
if (fracs.length !== 2)
|
|
16
|
+
return false;
|
|
17
|
+
const parsedFracs = fracs.map((e) => (0, numberParser_1.numberParser)(e));
|
|
18
|
+
if (parsedFracs.some((e) => e === false))
|
|
19
|
+
return false;
|
|
20
|
+
const nodeFracs = fracs.map((e) => e.unfrenchify().toTree());
|
|
21
|
+
return new fractionNode_1.FractionNode(nodeFracs[0], nodeFracs[1]);
|
|
22
|
+
}
|
|
23
|
+
// if(ans.startsWith("-")){
|
|
24
|
+
// const fracs = ans.replaceAll("}","").split('{').slice(1)
|
|
25
|
+
// if(fracs.length !== 2) return false
|
|
26
|
+
// const parsedFracs = fracs.map((e)=>numberParser(e))
|
|
27
|
+
// if(parsedFracs.some((e)=>e===false)) return false
|
|
28
|
+
// return ans;
|
|
29
|
+
// }
|
|
30
|
+
// const nb = ans.unfrenchify();
|
|
31
|
+
// if (isNaN(nb)) return false;
|
|
32
|
+
// return nb.frenchify();
|
|
33
|
+
};
|
|
34
|
+
exports.rationalParser = rationalParser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spacePointParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/spacePointParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,eAAO,MAAM,gBAAgB,QAAS,MAAM,uBAW3C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.spacePointParser = void 0;
|
|
4
|
+
const spacePoint_1 = require("../../math/geometry/spacePoint");
|
|
5
|
+
const valueParser_1 = require("./valueParser");
|
|
6
|
+
const spacePointParser = (ans) => {
|
|
7
|
+
const formated = ans
|
|
8
|
+
.replaceAll("\\left", "")
|
|
9
|
+
.replaceAll("\\right", "")
|
|
10
|
+
.replaceAll("(", "")
|
|
11
|
+
.replaceAll(")", "");
|
|
12
|
+
const coords = formated.split(";").map((e) => (0, valueParser_1.valueParser)(e));
|
|
13
|
+
if (coords?.some((e) => e === false))
|
|
14
|
+
return false;
|
|
15
|
+
const trees = coords.map((e) => e.toTree());
|
|
16
|
+
return new spacePoint_1.SpacePoint("A", trees[0], trees[1], trees[2]);
|
|
17
|
+
};
|
|
18
|
+
exports.spacePointParser = spacePointParser;
|