math-exercises 2.2.47 → 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/functions/affines/affineExpressionFromTwoImages.js +2 -2
- 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/percent/reciprocalPercentage.js +1 -1
- 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
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spaceVectorParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/spaceVectorParser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,eAAO,MAAM,iBAAiB,QAAS,MAAM,wBAW5C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.spaceVectorParser = void 0;
|
|
4
|
+
const valueParser_1 = require("./valueParser");
|
|
5
|
+
const spaceVector_1 = require("../../math/geometry/spaceVector");
|
|
6
|
+
const spaceVectorParser = (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 spaceVector_1.SpaceVector("A", trees[0], trees[1], trees[2]);
|
|
17
|
+
};
|
|
18
|
+
exports.spaceVectorParser = spaceVectorParser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/valueParser.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAS,MAAM,mBAItC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.valueParser = void 0;
|
|
4
|
+
const valueParser = (ans) => {
|
|
5
|
+
const nb = ans.unfrenchify();
|
|
6
|
+
if (isNaN(nb))
|
|
7
|
+
return false;
|
|
8
|
+
return nb;
|
|
9
|
+
};
|
|
10
|
+
exports.valueParser = valueParser;
|