math-exercises 2.2.50 → 2.2.52

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.
@@ -18,7 +18,7 @@ export declare enum GeneratorOptionTarget {
18
18
  export declare enum GeneratorOptionType {
19
19
  checkbox = "checkbox",
20
20
  select = "select",
21
- multiSelect = "multiSelect"
21
+ multiselect = "multiselect"
22
22
  }
23
23
  export type GeneratorOption<TValue = any> = {
24
24
  id: string;
@@ -52,5 +52,5 @@ var GeneratorOptionType;
52
52
  (function (GeneratorOptionType) {
53
53
  GeneratorOptionType["checkbox"] = "checkbox";
54
54
  GeneratorOptionType["select"] = "select";
55
- GeneratorOptionType["multiSelect"] = "multiSelect";
55
+ GeneratorOptionType["multiselect"] = "multiselect";
56
56
  })(GeneratorOptionType || (exports.GeneratorOptionType = GeneratorOptionType = {}));
@@ -78,7 +78,7 @@ const options = [
78
78
  {
79
79
  id: "units",
80
80
  label: "N'utiliser que les unités suivantes :",
81
- type: exercise_1.GeneratorOptionType.multiSelect,
81
+ type: exercise_1.GeneratorOptionType.multiselect,
82
82
  target: exercise_1.GeneratorOptionTarget.generation,
83
83
  values: units,
84
84
  },
@@ -8,6 +8,9 @@ type Identifiers = {
8
8
  BC: number;
9
9
  BD: number;
10
10
  };
11
- export declare const probabilityTree: Exercise<Identifiers>;
11
+ type Options = {
12
+ allowApproximate: string;
13
+ };
14
+ export declare const probabilityTree: Exercise<Identifiers, Options>;
12
15
  export {};
13
16
  //# sourceMappingURL=probabilityTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,QAAQ,EAQT,MAAM,gBAAgB,CAAC;AAGxB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA+IF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAsBjD,CAAC"}
1
+ {"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,QAAQ,EAWT,MAAM,gBAAgB,CAAC;AAGxB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAwIF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AA2CF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAwB1D,CAAC"}
@@ -2,33 +2,35 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.probabilityTree = void 0;
4
4
  const geogebraConstructor_1 = require("../../../geogebra/geogebraConstructor");
5
- const integer_1 = require("../../../math/numbers/integer/integer");
6
- const rational_1 = require("../../../math/numbers/rationals/rational");
7
5
  const gcd_1 = require("../../../math/utils/arithmetic/gcd");
8
6
  const randint_1 = require("../../../math/utils/random/randint");
7
+ const round_1 = require("../../../math/utils/round");
8
+ const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
9
+ const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
10
+ const latexParser_1 = require("../../../tree/parsers/latexParser");
9
11
  const shuffle_1 = require("../../../utils/alea/shuffle");
10
12
  const exercise_1 = require("../../exercise");
11
13
  const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
12
14
  const getAnswerNode = ({ type, A, B, AC, AD, BC, BD }) => {
13
- const pA = new rational_1.Rational(A, A + B).simplify();
14
- const pB = new rational_1.Rational(B, A + B).simplify();
15
- const pA_C = new rational_1.Rational(AC, AC + AD).simplify();
16
- const pA_D = new rational_1.Rational(AD, AC + AD).simplify();
17
- const pB_C = new rational_1.Rational(BC, BC + BD).simplify();
18
- const pB_D = new rational_1.Rational(BD, BC + BD).simplify();
15
+ const pA = (0, fractionNode_1.frac)(A, A + B);
16
+ const pB = (0, fractionNode_1.frac)(B, A + B);
17
+ const pA_C = (0, fractionNode_1.frac)(AC, AC + AD);
18
+ const pA_D = (0, fractionNode_1.frac)(AD, AC + AD);
19
+ const pB_C = (0, fractionNode_1.frac)(BC, BC + BD);
20
+ const pB_D = (0, fractionNode_1.frac)(BD, BC + BD);
19
21
  switch (type) {
20
22
  case 1:
21
- return pA.multiply(pA_C);
23
+ return (0, multiplyNode_1.multiply)(pA, pA_C).simplify();
22
24
  case 2:
23
- return pA.multiply(pA_D);
25
+ return (0, multiplyNode_1.multiply)(pA, pA_D).simplify();
24
26
  case 3:
25
- return pB.multiply(pB_C);
27
+ return (0, multiplyNode_1.multiply)(pB, pB_C).simplify();
26
28
  case 4:
27
29
  default:
28
- return pB.multiply(pB_D);
30
+ return (0, multiplyNode_1.multiply)(pB, pB_D).simplify();
29
31
  }
30
32
  };
31
- const getProbabilityTree = () => {
33
+ const getProbabilityTree = (opts) => {
32
34
  const A = (0, randint_1.randint)(2, 9);
33
35
  const B = (0, randint_1.randint)(2, 10 - A);
34
36
  const AC = (0, randint_1.randint)(2, 9);
@@ -39,7 +41,7 @@ const getProbabilityTree = () => {
39
41
  let startStatement = "";
40
42
  const type = (0, randint_1.randint)(1, 5);
41
43
  const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
42
- const answerTex = answer.toTree().toTex();
44
+ const answerTex = answer.toTex();
43
45
  switch (type) {
44
46
  case 1: {
45
47
  instruction += `calculer $P(A \\cap C)$.`;
@@ -62,6 +64,9 @@ const getProbabilityTree = () => {
62
64
  break;
63
65
  }
64
66
  }
67
+ if (opts?.allowApproximate) {
68
+ instruction += ` Donner la valeur exacte ou une valeur arrondie au ${opts.allowApproximate}.`;
69
+ }
65
70
  let commands = [
66
71
  "A = Point({2,2})",
67
72
  "B = Point({2,-2})",
@@ -111,16 +116,42 @@ const getPropositions = (n, { answer, A, AC, AD, B, BC, BD, type }) => {
111
116
  (0, exercise_1.addValidProp)(propositions, answer);
112
117
  const answerNode = getAnswerNode({ A, AC, AD, B, BC, BD, type });
113
118
  while (propositions.length < n) {
114
- const wrongAnswer = answerNode.multiply(new integer_1.Integer((0, randint_1.randint)(2, 11)));
115
- (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer.toTree().toTex());
119
+ const wrongAnswer = (0, multiplyNode_1.multiply)(answerNode, (0, randint_1.randint)(2, 11)).simplify();
120
+ (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer.toTex());
116
121
  }
117
122
  return (0, shuffle_1.shuffle)(propositions);
118
123
  };
119
- const isAnswerValid = (ans, { A, AC, AD, B, BC, BD, type }) => {
120
- const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
121
- const texs = answer.toTree({ allowFractionToDecimal: true }).toAllValidTexs();
122
- return texs.includes(ans);
124
+ const isAnswerValid = (ans, { answer, A, AC, AD, B, BC, BD, type }, opts) => {
125
+ try {
126
+ console.log(opts);
127
+ const parsed = (0, latexParser_1.parseAlgebraic)(ans);
128
+ if (!parsed)
129
+ return false;
130
+ const simplified = parsed.simplify();
131
+ if (opts?.allowApproximate) {
132
+ const rank = ["dixième", "centième", "millième"].indexOf(opts.allowApproximate);
133
+ return (answer === simplified.toTex() ||
134
+ simplified.evaluate() ===
135
+ (0, round_1.round)(getAnswerNode({ type, A, AC, AD, B, BC, BD }).evaluate(), rank + 1));
136
+ }
137
+ return answer === simplified.toTex();
138
+ // const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
139
+ // const texs = answer.toTree({ allowFractionToDecimal: true }).toAllValidTexs();
140
+ }
141
+ catch (err) {
142
+ return false;
143
+ }
123
144
  };
145
+ const options = [
146
+ {
147
+ id: "allowApproximate",
148
+ label: "Autoriser les valeurs approchées au : ",
149
+ target: exercise_1.GeneratorOptionTarget.vea,
150
+ type: exercise_1.GeneratorOptionType.select,
151
+ defaultValue: "centieme",
152
+ values: ["dixième", "centième", "millième"],
153
+ },
154
+ ];
124
155
  exports.probabilityTree = {
125
156
  id: "probabilityTree",
126
157
  connector: "=",
@@ -136,11 +167,12 @@ exports.probabilityTree = {
136
167
  ],
137
168
  isSingleStep: false,
138
169
  sections: ["Probabilités"],
139
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getProbabilityTree, nb),
170
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getProbabilityTree(opts), nb),
140
171
  qcmTimer: 60,
141
172
  freeTimer: 60,
142
173
  getPropositions,
143
174
  isAnswerValid,
144
175
  hasGeogebra: true,
145
176
  subject: "Mathématiques",
177
+ options,
146
178
  };
package/lib/index.d.ts CHANGED
@@ -1247,7 +1247,9 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
1247
1247
  AD: number;
1248
1248
  BC: number;
1249
1249
  BD: number;
1250
- }, {}> | import("./exercises/exercise").Exercise<{
1250
+ }, {
1251
+ allowApproximate: string;
1252
+ }> | import("./exercises/exercise").Exercise<{
1251
1253
  randomValues: number[];
1252
1254
  randomEffectives: number[];
1253
1255
  }, {}> | import("./exercises/exercise").Exercise<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.2.50",
3
+ "version": "2.2.52",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [