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.
Files changed (55) hide show
  1. package/lib/exercises/exercise.d.ts +5 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts +1 -1
  4. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/fractionsSum.js +12 -4
  6. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +33 -5
  8. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +39 -5
  10. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +33 -8
  12. package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +2 -2
  13. package/lib/exercises/math/geometry/index.d.ts +1 -0
  14. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  15. package/lib/exercises/math/geometry/index.js +1 -0
  16. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts +8 -0
  17. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts.map +1 -0
  18. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.js +110 -0
  19. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts +8 -0
  20. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -0
  21. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +108 -0
  22. package/lib/exercises/math/geometry/parametric/index.d.ts +4 -0
  23. package/lib/exercises/math/geometry/parametric/index.d.ts.map +1 -0
  24. package/lib/exercises/math/geometry/parametric/index.js +19 -0
  25. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts +12 -0
  26. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts.map +1 -0
  27. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.js +95 -0
  28. package/lib/exercises/math/percent/reciprocalPercentage.js +1 -1
  29. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.d.ts.map +1 -1
  30. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.js +66 -24
  31. package/lib/index.d.ts +14 -1
  32. package/lib/index.d.ts.map +1 -1
  33. package/lib/math/geometry/parametricLine.d.ts +15 -0
  34. package/lib/math/geometry/parametricLine.d.ts.map +1 -0
  35. package/lib/math/geometry/parametricLine.js +47 -0
  36. package/lib/math/geometry/spacePoint.d.ts +3 -0
  37. package/lib/math/geometry/spacePoint.d.ts.map +1 -1
  38. package/lib/math/geometry/spacePoint.js +12 -0
  39. package/lib/math/geometry/spaceVector.d.ts +5 -0
  40. package/lib/math/geometry/spaceVector.d.ts.map +1 -1
  41. package/lib/math/geometry/spaceVector.js +20 -0
  42. package/lib/server.js +7 -3
  43. package/lib/tree/parsers/rationalParser.d.ts +2 -0
  44. package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
  45. package/lib/tree/parsers/rationalParser.js +33 -8
  46. package/lib/tree/parsers/spacePointParser.d.ts +3 -0
  47. package/lib/tree/parsers/spacePointParser.d.ts.map +1 -0
  48. package/lib/tree/parsers/spacePointParser.js +18 -0
  49. package/lib/tree/parsers/spaceVectorParser.d.ts +3 -0
  50. package/lib/tree/parsers/spaceVectorParser.d.ts.map +1 -0
  51. package/lib/tree/parsers/spaceVectorParser.js +18 -0
  52. package/lib/tree/parsers/valueParser.d.ts +2 -0
  53. package/lib/tree/parsers/valueParser.d.ts.map +1 -0
  54. package/lib/tree/parsers/valueParser.js +10 -0
  55. 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,3 @@
1
+ import { FractionNode } from "../nodes/operators/fractionNode";
2
+ export declare const rationalParser: (ans: string) => false | import("../nodes/algebraicNode").AlgebraicNode | FractionNode | undefined;
1
3
  //# sourceMappingURL=rationalParser.d.ts.map
@@ -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
- // export const rationalParser = (ans: string) => {
3
- // if(ans.startsWith("\\frac")){
4
- // const num
5
- // }
6
- // const nb = ans.unfrenchify();
7
- // if (isNaN(nb)) return false;
8
- // return nb.frenchify();
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,3 @@
1
+ import { SpacePoint } from "../../math/geometry/spacePoint";
2
+ export declare const spacePointParser: (ans: string) => false | SpacePoint;
3
+ //# sourceMappingURL=spacePointParser.d.ts.map
@@ -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,3 @@
1
+ import { SpaceVector } from "../../math/geometry/spaceVector";
2
+ export declare const spaceVectorParser: (ans: string) => false | SpaceVector;
3
+ //# sourceMappingURL=spaceVectorParser.d.ts.map
@@ -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,2 @@
1
+ export declare const valueParser: (ans: string) => number | false;
2
+ //# sourceMappingURL=valueParser.d.ts.map
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.2.47",
3
+ "version": "2.2.49",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [