math-exercises 2.2.65 → 2.2.67

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 (86) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts +1 -0
  2. package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.js +51 -37
  4. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +8 -3
  9. package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.js +1 -1
  10. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts +1 -0
  11. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -0
  12. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +122 -0
  13. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts +9 -3
  14. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
  15. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +64 -17
  16. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.js +1 -1
  17. package/lib/exercises/math/functions/trinoms/coefficientsIdentification.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/trinoms/coefficientsIdentification.js +8 -3
  19. package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.d.ts.map +1 -1
  20. package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.js +3 -1
  21. package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.d.ts.map +1 -1
  22. package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.js +1 -2
  23. package/lib/exercises/math/geometry/cartesian/placeAPoint.d.ts.map +1 -1
  24. package/lib/exercises/math/geometry/cartesian/placeAPoint.js +1 -2
  25. package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.d.ts.map +1 -1
  26. package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.js +1 -2
  27. package/lib/exercises/math/geometry/vectors/drawAVectorInGGB.d.ts.map +1 -1
  28. package/lib/exercises/math/geometry/vectors/drawAVectorInGGB.js +1 -2
  29. package/lib/exercises/math/percent/applyPercent.d.ts.map +1 -1
  30. package/lib/exercises/math/percent/applyPercent.js +2 -4
  31. package/lib/exercises/math/probaStat/probabilityTree.d.ts +10 -7
  32. package/lib/exercises/math/probaStat/probabilityTree.d.ts.map +1 -1
  33. package/lib/exercises/math/probaStat/probabilityTree.js +194 -90
  34. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
  35. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +7 -3
  36. package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
  37. package/lib/exercises/math/squareRoots/squareRootIdentities.js +5 -1
  38. package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
  39. package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +5 -1
  40. package/lib/exercises/pc/calibrationCurveOfSolution.d.ts.map +1 -1
  41. package/lib/exercises/pc/calibrationCurveOfSolution.js +1 -2
  42. package/lib/exercises/vea/rationalVEA.d.ts +7 -1
  43. package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
  44. package/lib/exercises/vea/rationalVEA.js +34 -4
  45. package/lib/index.d.ts +24 -13
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/math/complex/complex.d.ts +1 -1
  48. package/lib/math/numbers/rationals/rational.d.ts +1 -1
  49. package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
  50. package/lib/math/polynomials/generalAffine.d.ts +10 -0
  51. package/lib/math/polynomials/generalAffine.d.ts.map +1 -0
  52. package/lib/math/polynomials/generalAffine.js +32 -0
  53. package/lib/math/polynomials/generalTrinom.d.ts +1 -1
  54. package/lib/math/polynomials/trinom.d.ts +3 -3
  55. package/lib/playground.d.ts.map +1 -1
  56. package/lib/playground.js +2 -3
  57. package/lib/prototypesEnhancement.d.ts +3 -1
  58. package/lib/prototypesEnhancement.d.ts.map +1 -1
  59. package/lib/tree/nodes/equations/equalNode.d.ts +13 -9
  60. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  61. package/lib/tree/nodes/equations/equalNode.js +17 -1
  62. package/lib/tree/nodes/functions/absNode.d.ts +1 -1
  63. package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +1 -1
  64. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  65. package/lib/tree/nodes/operators/addNode.js +2 -1
  66. package/lib/tree/nodes/operators/fractionNode.d.ts +8 -9
  67. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  68. package/lib/tree/nodes/operators/fractionNode.js +15 -0
  69. package/lib/tree/parsers/affineParser.d.ts +1 -2
  70. package/lib/tree/parsers/affineParser.d.ts.map +1 -1
  71. package/lib/tree/parsers/affineParser.js +22 -17
  72. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  73. package/lib/tree/parsers/latexParser.js +34 -9
  74. package/lib/tree/parsers/monomParser.d.ts +9 -1
  75. package/lib/tree/parsers/monomParser.d.ts.map +1 -1
  76. package/lib/tree/parsers/monomParser.js +65 -2
  77. package/lib/tree/parsers/powerParser.d.ts +1 -1
  78. package/lib/tree/parsers/purifyLatex.d.ts +9 -0
  79. package/lib/tree/parsers/purifyLatex.d.ts.map +1 -0
  80. package/lib/tree/parsers/purifyLatex.js +17 -0
  81. package/lib/tree/parsers/rationalParser.d.ts +1 -1
  82. package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
  83. package/lib/tree/parsers/trinomParser.d.ts +2 -0
  84. package/lib/tree/parsers/trinomParser.d.ts.map +1 -0
  85. package/lib/tree/parsers/trinomParser.js +31 -0
  86. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyPercent = void 0;
4
+ const numberVEA_1 = require("../../../exercises/vea/numberVEA");
4
5
  const randint_1 = require("../../../math/utils/random/randint");
5
6
  const round_1 = require("../../../math/utils/round");
6
- const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
7
7
  const coinFlip_1 = require("../../../utils/alea/coinFlip");
8
8
  const shuffle_1 = require("../../../utils/alea/shuffle");
9
9
  const exercise_1 = require("../../exercise");
@@ -74,9 +74,7 @@ const getPropositions = (n, { answer }) => {
74
74
  return (0, shuffle_1.shuffle)(propositions);
75
75
  };
76
76
  const isAnswerValid = (ans, { answer }) => {
77
- const answerTree = new numberNode_1.NumberNode(Number(answer.replace(",", ".")));
78
- const texs = answerTree.toAllValidTexs();
79
- return texs.includes(ans);
77
+ return (0, numberVEA_1.numberVEA)(ans, answer);
80
78
  };
81
79
  exports.applyPercent = {
82
80
  id: "applyPercent",
@@ -1,15 +1,18 @@
1
+ import { NodeIdentifiers } from "../../../tree/nodes/nodeConstructor";
1
2
  import { Exercise } from "../../exercise";
2
3
  type Identifiers = {
3
- type: number;
4
- A: number;
5
- B: number;
6
- AC: number;
7
- AD: number;
8
- BC: number;
9
- BD: number;
4
+ A: NodeIdentifiers;
5
+ B: NodeIdentifiers;
6
+ AC: NodeIdentifiers;
7
+ AD: NodeIdentifiers;
8
+ BC: NodeIdentifiers;
9
+ BD: NodeIdentifiers;
10
+ probaName: string;
10
11
  };
11
12
  type Options = {
12
13
  allowApproximate: string;
14
+ eventTypes: string[];
15
+ probaType: string;
13
16
  };
14
17
  export declare const probabilityTree: Exercise<Identifiers, Options>;
15
18
  export {};
@@ -1 +1 @@
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;AA0CF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAwB1D,CAAC"}
1
+ {"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAY1C,OAAO,EACL,QAAQ,EAeT,MAAM,gBAAgB,CAAC;AAmCxB,KAAK,WAAW,GAAG;IAIjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4MF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA+CF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB1D,CAAC"}
@@ -1,72 +1,181 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.probabilityTree = void 0;
4
+ const rationalVEA_1 = require("../../../exercises/vea/rationalVEA");
4
5
  const geogebraConstructor_1 = require("../../../geogebra/geogebraConstructor");
5
- const gcd_1 = require("../../../math/utils/arithmetic/gcd");
6
+ const rational_1 = require("../../../math/numbers/rationals/rational");
7
+ const randfloat_1 = require("../../../math/utils/random/randfloat");
6
8
  const randint_1 = require("../../../math/utils/random/randint");
7
9
  const round_1 = require("../../../math/utils/round");
10
+ const nodeConstructor_1 = require("../../../tree/nodes/nodeConstructor");
11
+ const addNode_1 = require("../../../tree/nodes/operators/addNode");
8
12
  const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
9
13
  const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
10
- const latexParser_1 = require("../../../tree/parsers/latexParser");
14
+ const substractNode_1 = require("../../../tree/nodes/operators/substractNode");
15
+ const random_1 = require("../../../utils/alea/random");
11
16
  const shuffle_1 = require("../../../utils/alea/shuffle");
12
17
  const exercise_1 = require("../../exercise");
13
18
  const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
14
- const getAnswerNode = ({ type, A, B, AC, AD, BC, BD }) => {
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);
21
- switch (type) {
19
+ const rebuildIdentifiers = (oldIdentifiers) => {
20
+ if (oldIdentifiers.probaName)
21
+ return oldIdentifiers;
22
+ const ABTotal = oldIdentifiers.A + oldIdentifiers.B;
23
+ const ASubTotal = oldIdentifiers.AC + oldIdentifiers.AD;
24
+ const BSubTotal = oldIdentifiers.BC + oldIdentifiers.BD;
25
+ let probaName = "";
26
+ switch (oldIdentifiers.type) {
22
27
  case 1:
23
- return (0, multiplyNode_1.multiply)(pA, pA_C).simplify();
28
+ probaName = "P(A\\cap C)";
29
+ break;
24
30
  case 2:
25
- return (0, multiplyNode_1.multiply)(pA, pA_D).simplify();
31
+ probaName = "P(A\\cap D)";
32
+ break;
26
33
  case 3:
27
- return (0, multiplyNode_1.multiply)(pB, pB_C).simplify();
34
+ probaName = "P(B\\cap C)";
35
+ break;
28
36
  case 4:
37
+ probaName = "P(B\\cap D)";
38
+ break;
39
+ }
40
+ return {
41
+ probaName,
42
+ A: (0, fractionNode_1.frac)(oldIdentifiers.A, ABTotal).simplify().toIdentifiers(),
43
+ B: (0, fractionNode_1.frac)(oldIdentifiers.B, ABTotal).simplify().toIdentifiers(),
44
+ AC: (0, fractionNode_1.frac)(oldIdentifiers.AC, ASubTotal).simplify().toIdentifiers(),
45
+ AD: (0, fractionNode_1.frac)(oldIdentifiers.AD, ASubTotal).simplify().toIdentifiers(),
46
+ BC: (0, fractionNode_1.frac)(oldIdentifiers.BC, BSubTotal).simplify().toIdentifiers(),
47
+ BD: (0, fractionNode_1.frac)(oldIdentifiers.BD, BSubTotal).simplify().toIdentifiers(),
48
+ };
49
+ };
50
+ const optionValues = [
51
+ "Probabilité d'intersection $P(A\\cap C)$",
52
+ "Probabilité totale $P(C)$",
53
+ "Probabilité conditionnelle $P_B(A)$",
54
+ "Probabilité 'simple' $P(A)$",
55
+ ];
56
+ const defaultOptionValues = [
57
+ "Probabilité d'intersection $P(A\\cap C)$",
58
+ "Probabilité totale $P(C)$",
59
+ "Probabilité conditionnelle $P_B(A)$",
60
+ ];
61
+ const buildAll = (identifiers) => {
62
+ return {
63
+ pA: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.A),
64
+ pAC: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.AC),
65
+ pAD: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.AD),
66
+ pB: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.B),
67
+ pBC: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.BC),
68
+ pBD: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.BD),
69
+ };
70
+ };
71
+ const getAnswerNode = (identifiers) => {
72
+ const probas = buildAll(identifiers);
73
+ switch (identifiers.probaName) {
74
+ case "P(A)":
75
+ return probas.pA;
76
+ case "P(B)":
77
+ return probas.pB;
78
+ case "P(A\\cap C)":
79
+ return (0, multiplyNode_1.multiply)(probas.pA, probas.pAC).simplify();
80
+ case "P(A\\cap D)":
81
+ return (0, multiplyNode_1.multiply)(probas.pA, probas.pAD).simplify();
82
+ case "P(B\\cap C)":
83
+ return (0, multiplyNode_1.multiply)(probas.pB, probas.pBC).simplify();
84
+ case "P(B\\cap D)":
85
+ return (0, multiplyNode_1.multiply)(probas.pB, probas.pBD).simplify();
86
+ case "P_A(C)":
87
+ return probas.pAC;
88
+ case "P_A(D)":
89
+ return probas.pAD;
90
+ case "P_B(C)":
91
+ return probas.pBC;
92
+ case "P_B(D)":
93
+ return probas.pBD;
94
+ case "P(C)":
95
+ return (0, addNode_1.add)((0, multiplyNode_1.multiply)(probas.pA, probas.pAC), (0, multiplyNode_1.multiply)(probas.pB, probas.pBC)).simplify();
96
+ case "P(D)":
29
97
  default:
30
- return (0, multiplyNode_1.multiply)(pB, pB_D).simplify();
98
+ return (0, addNode_1.add)((0, multiplyNode_1.multiply)(probas.pA, probas.pAD), (0, multiplyNode_1.multiply)(probas.pB, probas.pBD)).simplify();
99
+ }
100
+ };
101
+ const getAnswer = (identifiers) => {
102
+ return getAnswerNode(identifiers).toTex();
103
+ };
104
+ const getInstruction = (identifiers, options) => {
105
+ let instr = `On considère l'arbre de probabilités ci-dessous. Calculer :
106
+
107
+ $$
108
+ ${identifiers.probaName}
109
+ $$`;
110
+ if (options?.allowApproximate) {
111
+ instr += `
112
+
113
+ Donner la valeur exacte ou une valeur arrondie au ${options.allowApproximate}.`;
114
+ }
115
+ return instr;
116
+ };
117
+ const getProbaAndOpposite = (decimal = false) => {
118
+ if (!decimal) {
119
+ const proba = rational_1.RationalConstructor.randomIrreductibleProba().toTree();
120
+ return [proba, (0, substractNode_1.substract)(1, proba).simplify()];
121
+ }
122
+ else {
123
+ const proba = (0, round_1.round)((0, randfloat_1.randfloat)(0.01, 1, 2), 2);
124
+ return [proba.toTree(), (0, round_1.round)(1 - proba, 2).toTree()];
31
125
  }
32
126
  };
33
127
  const getProbabilityTree = (opts) => {
34
- const A = (0, randint_1.randint)(2, 9);
35
- const B = (0, randint_1.randint)(2, 10 - A);
36
- const AC = (0, randint_1.randint)(2, 9);
37
- const AD = (0, randint_1.randint)(2, 10 - AC);
38
- const BC = (0, randint_1.randint)(2, 9);
39
- const BD = (0, randint_1.randint)(2, 10 - BC);
40
- let instruction = `En utilisant l'arbre de probabilité suivant, `;
41
- let startStatement = "";
42
- const type = (0, randint_1.randint)(1, 5);
43
- const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
44
- const answerTex = answer.toTex();
45
- switch (type) {
46
- case 1: {
47
- instruction += `calculer $P(A \\cap C)$.`;
48
- startStatement = `P(A \\cap C)`;
128
+ const isDecimal = opts?.probaType === "Décimales";
129
+ const [pA, pB] = getProbaAndOpposite(isDecimal);
130
+ const [pC_A, pD_A] = getProbaAndOpposite(isDecimal);
131
+ const [pC_B, pD_B] = getProbaAndOpposite(isDecimal);
132
+ const eventTypes = opts?.eventTypes?.length
133
+ ? opts.eventTypes
134
+ : defaultOptionValues;
135
+ const type = (0, random_1.random)(eventTypes);
136
+ const index = optionValues.indexOf(type);
137
+ let probaName = "";
138
+ switch (index) {
139
+ case 0: //inter
140
+ probaName = (0, random_1.random)([
141
+ "P(A\\cap C)",
142
+ "P(A\\cap D)",
143
+ "P(B\\cap C)",
144
+ "P(B\\cap D)",
145
+ ]);
49
146
  break;
50
- }
51
- case 2: {
52
- instruction += `calculer $P(A \\cap D)$.`;
53
- startStatement = `P(A \\cap D)`;
147
+ case 1: //totale
148
+ probaName = (0, random_1.random)(["P(C)", "P(D)"]);
54
149
  break;
55
- }
56
- case 3: {
57
- instruction += `calculer $P(B \\cap C)$.`;
58
- startStatement = `P(B \\cap C)`;
150
+ case 2: //conditionnal
151
+ probaName = (0, random_1.random)(["P_A(C)", "P_A(D)", "P_B(C)", "P_B(D)"]);
59
152
  break;
60
- }
61
- case 4: {
62
- instruction += `calculer $P(B \\cap D)$.`;
63
- startStatement = `P(B \\cap D)`;
153
+ case 3: //simple
154
+ probaName = (0, random_1.random)(["P(A)", "P(B)"]);
64
155
  break;
65
- }
66
- }
67
- if (opts?.allowApproximate) {
68
- instruction += ` Donner la valeur exacte ou une valeur arrondie au ${opts.allowApproximate}.`;
69
156
  }
157
+ const identifiers = {
158
+ A: pA.toIdentifiers(),
159
+ B: pB.toIdentifiers(),
160
+ AC: pC_A.toIdentifiers(),
161
+ AD: pD_A.toIdentifiers(),
162
+ BC: pC_B.toIdentifiers(),
163
+ BD: pD_B.toIdentifiers(),
164
+ probaName,
165
+ };
166
+ const question = {
167
+ instruction: getInstruction(identifiers, opts),
168
+ startStatement: probaName,
169
+ answer: getAnswer(identifiers),
170
+ keys: [],
171
+ ggbOptions: getGGBOptions(identifiers, opts),
172
+ answerFormat: "tex",
173
+ identifiers,
174
+ };
175
+ return question;
176
+ };
177
+ const getGGBOptions = (identifiers, opts) => {
178
+ const probas = buildAll(identifiers);
70
179
  let commands = [
71
180
  "A = Point({2,2})",
72
181
  "B = Point({2,-2})",
@@ -80,12 +189,12 @@ const getProbabilityTree = (opts) => {
80
189
  "Segment(Point({0,0}),B)",
81
190
  "Segment(B,BC)",
82
191
  "Segment(B,BD)",
83
- `Text("\\scriptsize ${A / (0, gcd_1.gcd)(A, A + B)}/${(A + B) / (0, gcd_1.gcd)(A, A + B)}", (0.3, 2.1), true, true)`,
84
- `Text("\\scriptsize ${AC / (0, gcd_1.gcd)(AC, AC + AD)}/${(AC + AD) / (0, gcd_1.gcd)(AC, AC + AD)}", (2.8, 3.5), true, true)`,
85
- `Text("\\scriptsize ${AD / (0, gcd_1.gcd)(AD, AC + AD)}/${(AC + AD) / (0, gcd_1.gcd)(AD, AC + AD)}", (2.8, 1.4), true, true)`,
86
- `Text("\\scriptsize ${B / (0, gcd_1.gcd)(B, A + B)}/${(A + B) / (0, gcd_1.gcd)(B, A + B)}", (0.3, -1.2), true, true)`,
87
- `Text("\\scriptsize ${BC / (0, gcd_1.gcd)(BC, BC + BD)}/${(BC + BD) / (0, gcd_1.gcd)(BC, BC + BD)}", (2.8, -0.6), true, true)`,
88
- `Text("\\scriptsize ${BD / (0, gcd_1.gcd)(BD, BC + BD)}/${(BC + BD) / (0, gcd_1.gcd)(BD, BC + BD)}", (2.8, -2.5), true, true)`,
192
+ `Text("\\scriptsize ${probas.pA.toTex()}", (0.1, 2.2), true, true)`,
193
+ `Text("\\scriptsize ${probas.pAC.toTex()}", (2.8, 4), true, true)`,
194
+ `Text("\\scriptsize ${probas.pAD.toTex()}", (2.8, 1.6), true, true)`,
195
+ `Text("\\scriptsize ${probas.pB.toTex()}", (0.1, -0.8), true, true)`,
196
+ `Text("\\scriptsize ${probas.pBC.toTex()}", (2.8, -0.6), true, true)`,
197
+ `Text("\\scriptsize ${probas.pBD.toTex()}", (2.8, -2.5), true, true)`,
89
198
  'Text("A", (1.85 , 2.5))',
90
199
  'Text("B", (1.85 , -2.8))',
91
200
  'Text("C", (5.5 , 2.85))',
@@ -98,44 +207,30 @@ const getProbabilityTree = (opts) => {
98
207
  hideAxes: true,
99
208
  hideGrid: true,
100
209
  });
101
- const question = {
102
- instruction,
103
- startStatement,
104
- answer: answerTex,
105
- keys: [],
106
- ggbOptions: ggb.getOptions({
107
- coords: [-2, 8, -5, 5],
108
- }),
109
- answerFormat: "tex",
110
- identifiers: { A, AC, AD, B, BC, BD, type },
111
- };
112
- return question;
210
+ return ggb.getOptions({
211
+ coords: [-2, 8, -5, 5],
212
+ });
113
213
  };
114
- const getPropositions = (n, { answer, A, AC, AD, B, BC, BD, type }) => {
214
+ const getPropositions = (n, { answer, ...identifiers }) => {
115
215
  const propositions = [];
116
216
  (0, exercise_1.addValidProp)(propositions, answer);
117
- const answerNode = getAnswerNode({ A, AC, AD, B, BC, BD, type });
217
+ const answerNode = getAnswerNode(identifiers);
118
218
  while (propositions.length < n) {
119
219
  const wrongAnswer = (0, multiplyNode_1.multiply)(answerNode, (0, randint_1.randint)(2, 11)).simplify();
120
220
  (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer.toTex());
121
221
  }
122
222
  return (0, shuffle_1.shuffle)(propositions);
123
223
  };
124
- const isAnswerValid = (ans, { answer, A, AC, AD, B, BC, BD, type }, opts) => {
224
+ const isAnswerValid = (ans, { answer, ...identifiers }, opts) => {
125
225
  try {
126
- const parsed = (0, latexParser_1.parseAlgebraic)(ans);
127
- if (!parsed)
128
- return false;
129
- const simplified = parsed.simplify();
130
- if (opts?.allowApproximate) {
131
- const rank = ["dixième", "centième", "millième"].indexOf(opts.allowApproximate);
132
- return (answer === simplified.toTex() ||
133
- simplified.evaluate() ===
134
- (0, round_1.round)(getAnswerNode({ type, A, AC, AD, B, BC, BD }).evaluate(), rank + 1));
135
- }
136
- return answer === simplified.toTex();
137
- // const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
138
- // const texs = answer.toTree({ allowFractionToDecimal: true }).toAllValidTexs();
226
+ const rank = opts?.allowApproximate
227
+ ? ["dixième", "centième", "millième"].indexOf(opts.allowApproximate) + 1
228
+ : undefined;
229
+ return (0, rationalVEA_1.rationalVEA)(ans, answer, {
230
+ allowNonIrreductible: true,
231
+ allowDecimal: true,
232
+ decimalPrecision: rank,
233
+ });
139
234
  }
140
235
  catch (err) {
141
236
  return false;
@@ -147,25 +242,31 @@ const options = [
147
242
  label: "Autoriser les valeurs approchées au : ",
148
243
  target: exercise_1.GeneratorOptionTarget.vea,
149
244
  type: exercise_1.GeneratorOptionType.select,
150
- defaultValue: "centieme",
245
+ defaultValue: "centième",
151
246
  values: ["dixième", "centième", "millième"],
152
247
  },
248
+ {
249
+ id: "eventTypes",
250
+ label: "Types de questions",
251
+ target: exercise_1.GeneratorOptionTarget.generation,
252
+ type: exercise_1.GeneratorOptionType.multiselect,
253
+ defaultValue: defaultOptionValues,
254
+ values: optionValues,
255
+ },
256
+ {
257
+ id: "probaType",
258
+ label: "Format des probabilités",
259
+ target: exercise_1.GeneratorOptionTarget.generation,
260
+ type: exercise_1.GeneratorOptionType.select,
261
+ defaultValue: "Fractions",
262
+ values: ["Fractions", "Décimales"],
263
+ },
153
264
  ];
154
265
  exports.probabilityTree = {
155
266
  id: "probabilityTree",
156
267
  connector: "=",
157
268
  label: "Calculs de probabilités à l'aide d'un arbre pondéré",
158
- levels: [
159
- "2nde",
160
- "1reESM",
161
- "1reSpé",
162
- "1reTech",
163
- "1rePro",
164
- "TermPro",
165
- "TermTech",
166
- ],
167
269
  isSingleStep: false,
168
- sections: ["Probabilités"],
169
270
  generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getProbabilityTree(opts), nb),
170
271
  qcmTimer: 60,
171
272
  freeTimer: 60,
@@ -174,4 +275,7 @@ exports.probabilityTree = {
174
275
  hasGeogebra: true,
175
276
  subject: "Mathématiques",
176
277
  options,
278
+ rebuildIdentifiers,
279
+ getInstruction,
280
+ getAnswer,
177
281
  };
@@ -1 +1 @@
1
- {"version":3,"file":"spaceVectorNormCalculation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2FF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAkB5D,CAAC"}
1
+ {"version":3,"file":"spaceVectorNormCalculation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+FF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAkB5D,CAAC"}
@@ -10,11 +10,11 @@ const addNode_1 = require("../../../../tree/nodes/operators/addNode");
10
10
  const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
11
11
  const alignTex_1 = require("../../../../utils/latex/alignTex");
12
12
  const getHint = (identifiers) => {
13
- return "La norme d'un vecteur de l'espace est la racine carrée de la somme des carrés de ses coordonnées.";
13
+ return "Dans un repère dans l'espace orthonormé, la norme d'un vecteur est la racine carrée de la somme des carrés de ses coordonnées.";
14
14
  };
15
15
  const getCorrection = ({ x, y, z }) => {
16
16
  const answer = getAnswer({ x, y, z });
17
- return `La norme d'un vecteur de l'espace est la racine carrée de la somme des carrés de ses coordonnées. Ici, on a donc :
17
+ return `Dans un repère de l'espace orthonormé, la norme d'un vecteur est la racine carrée de la somme des carrés de ses coordonnées. Ici, on a donc :
18
18
 
19
19
  ${(0, alignTex_1.alignTex)([
20
20
  [
@@ -35,7 +35,11 @@ const getAnswer = (identifiers) => {
35
35
  };
36
36
  const getInstruction = (identifiers) => {
37
37
  const u = new spaceVector_1.SpaceVector("u", identifiers.x.toTree(), identifiers.y.toTree(), identifiers.z.toTree());
38
- return `Cacluler la norme du vecteur $${u.toTexWithCoords()}$`;
38
+ return `On se place dans un repère de l'espace orthonormé. Calculer la norme du vecteur :
39
+
40
+ $$
41
+ ${u.toTexWithCoords()}
42
+ $$`;
39
43
  };
40
44
  const getSpaceVectorNormCalculationQuestion = () => {
41
45
  const u = spaceVector_1.SpaceVectorConstructor.random("u", false);
@@ -1 +1 @@
1
- {"version":3,"file":"squareRootIdentities.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootIdentities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAmBlC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2KF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
1
+ {"version":3,"file":"squareRootIdentities.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootIdentities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAmBlC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+KF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
@@ -57,7 +57,11 @@ const getSquareRootIdentitiesQuestion = () => {
57
57
  const answer = getAnswer(type, firstTerm, secondTerm).toTex();
58
58
  const question = {
59
59
  answer,
60
- instruction: `Développer et simplifier : $${statement.toTex()}$`,
60
+ instruction: `Développer et simplifier :
61
+
62
+ $$
63
+ ${statement.toTex()}
64
+ $$`,
61
65
  keys: [],
62
66
  answerFormat: "tex",
63
67
  identifiers: { type, a: a.operand, b: b?.operand, x, y },
@@ -1 +1 @@
1
- {"version":3,"file":"squareRootsDistributivity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootsDistributivity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiEF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"squareRootsDistributivity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootsDistributivity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqEF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
@@ -27,7 +27,11 @@ const getSquareRootsDistributivityQuestion = () => {
27
27
  .toTex();
28
28
  const question = {
29
29
  answer,
30
- instruction: `Développer et simplifier : $${statement.toTex()}$`,
30
+ instruction: `Développer et simplifier :
31
+
32
+ $$
33
+ ${statement.toTex()}
34
+ $$`,
31
35
  keys: [],
32
36
  answerFormat: "tex",
33
37
  identifiers: { a, b: b.operand, c, d },
@@ -1 +1 @@
1
- {"version":3,"file":"calibrationCurveOfSolution.d.ts","sourceRoot":"","sources":["../../../src/exercises/pc/calibrationCurveOfSolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA0FF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAc5D,CAAC"}
1
+ {"version":3,"file":"calibrationCurveOfSolution.d.ts","sourceRoot":"","sources":["../../../src/exercises/pc/calibrationCurveOfSolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA0FF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAa5D,CAAC"}
@@ -89,8 +89,7 @@ exports.calibrationCurveOfSolution = {
89
89
  isSingleStep: true,
90
90
  sections: ["Spectrophotométrie"],
91
91
  generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getCalibrationCurveOfSolutionQuestion, nb),
92
- qcmTimer: 60,
93
- freeTimer: 60,
92
+ ggbTimer: 60,
94
93
  isGGBAnswerValid,
95
94
  answerType: "GGB",
96
95
  subject: "Physique",
@@ -1,2 +1,8 @@
1
- export declare const rationalVEA: (studentAns: string, answer: string) => boolean;
1
+ type Opts = {
2
+ allowNonIrreductible?: boolean;
3
+ allowDecimal?: boolean;
4
+ decimalPrecision?: number;
5
+ };
6
+ export declare const rationalVEA: (studentAns: string, answer: string, { allowNonIrreductible, decimalPrecision, allowDecimal }?: Opts) => boolean;
7
+ export {};
2
8
  //# sourceMappingURL=rationalVEA.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rationalVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/rationalVEA.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,eAAgB,MAAM,UAAU,MAAM,YAK7D,CAAC"}
1
+ {"version":3,"file":"rationalVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/rationalVEA.ts"],"names":[],"mappings":"AAKA,KAAK,IAAI,GAAG;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AACF,eAAO,MAAM,WAAW,eACV,MAAM,UACV,MAAM,6DAC4C,IAAI,YAqC/D,CAAC"}
@@ -1,14 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rationalVEA = void 0;
4
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
4
5
  const latexParser_1 = require("../../tree/parsers/latexParser");
5
6
  const rationalParser_1 = require("../../tree/parsers/rationalParser");
6
- //return true if studentAns is a number or rational, and if it evaluates to answer
7
- const rationalVEA = (studentAns, answer) => {
7
+ const rationalVEA = (studentAns, answer, { allowNonIrreductible, decimalPrecision, allowDecimal } = {
8
+ allowNonIrreductible: true,
9
+ decimalPrecision: undefined,
10
+ allowDecimal: true,
11
+ }) => {
12
+ allowDecimal = allowDecimal ?? true;
13
+ allowNonIrreductible = allowNonIrreductible ?? true;
14
+ decimalPrecision = decimalPrecision ?? undefined;
8
15
  const parsed = (0, rationalParser_1.rationalParser)(studentAns);
9
16
  if (!parsed)
10
17
  return false;
11
- const parsedAnswer = (0, latexParser_1.parseAlgebraic)(answer);
12
- return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001;
18
+ try {
19
+ const parsedAnswer = (0, latexParser_1.parseAlgebraic)(answer);
20
+ if ((0, numberNode_1.isNumberNode)(parsed)) {
21
+ if (!allowDecimal)
22
+ return false;
23
+ if (decimalPrecision === undefined)
24
+ return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001);
25
+ else {
26
+ //! accepte bien les arrondis au centième par ex, mais va aussi accepter les arrondis au millième
27
+ //! je juge ca ok
28
+ return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
29
+ Math.pow(10, -decimalPrecision - 1));
30
+ }
31
+ }
32
+ else if (allowNonIrreductible) {
33
+ return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001;
34
+ }
35
+ else {
36
+ //parsed est une fraction ou opposite(frac)
37
+ return parsed.equals(parsedAnswer);
38
+ }
39
+ }
40
+ catch (err) {
41
+ return false;
42
+ }
13
43
  };
14
44
  exports.rationalVEA = rationalVEA;
package/lib/index.d.ts CHANGED
@@ -35,6 +35,7 @@ declare const mathExercises: (Exercise<{
35
35
  }, {
36
36
  allowNonIrreductible?: boolean | undefined;
37
37
  }> | Exercise<{
38
+ isIntegerFirst: boolean;
38
39
  integer: number;
39
40
  rational: [number, number];
40
41
  }, {
@@ -233,9 +234,13 @@ declare const mathExercises: (Exercise<{
233
234
  a: number;
234
235
  b: number;
235
236
  }, {}> | Exercise<{
236
- a: number;
237
- b: number;
238
- }, {}> | Exercise<{
237
+ a: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
238
+ b: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
239
+ isXRight: boolean;
240
+ aNumberType: string;
241
+ }, {
242
+ aNumberType: string[];
243
+ }> | Exercise<{
239
244
  a: number;
240
245
  b: number;
241
246
  c: number;
@@ -1323,15 +1328,17 @@ declare const mathExercises: (Exercise<{
1323
1328
  nbFaces: number;
1324
1329
  faceAsked: number;
1325
1330
  }, {}> | Exercise<{
1326
- type: number;
1327
- A: number;
1328
- B: number;
1329
- AC: number;
1330
- AD: number;
1331
- BC: number;
1332
- BD: number;
1331
+ A: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1332
+ B: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1333
+ AC: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1334
+ AD: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1335
+ BC: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1336
+ BD: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1337
+ probaName: string;
1333
1338
  }, {
1334
1339
  allowApproximate: string;
1340
+ eventTypes: string[];
1341
+ probaType: string;
1335
1342
  }> | Exercise<{
1336
1343
  randomValues: number[];
1337
1344
  randomEffectives: number[];
@@ -1711,9 +1718,13 @@ declare const pcExercises: (Exercise<{
1711
1718
  a: number;
1712
1719
  b: number;
1713
1720
  }, {}> | Exercise<{
1714
- a: number;
1715
- b: number;
1716
- }, {}> | Exercise<{
1721
+ a: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1722
+ b: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1723
+ isXRight: boolean;
1724
+ aNumberType: string;
1725
+ }, {
1726
+ aNumberType: string[];
1727
+ }> | Exercise<{
1717
1728
  a: number;
1718
1729
  b: number;
1719
1730
  c: number;