math-exercises 3.0.128 → 3.0.130

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 (41) hide show
  1. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts +6 -1
  2. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/ordering/compareA10N.js +56 -49
  4. package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.js +3 -18
  6. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts +4 -1
  7. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.js +34 -10
  9. package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts +2 -6
  10. package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +81 -197
  12. package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.js +1 -40
  14. package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.js +1 -15
  16. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts.map +1 -1
  17. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.js +1 -13
  18. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -1
  19. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +7 -2
  20. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.js +1 -4
  22. package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.d.ts.map +1 -1
  23. package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.js +1 -4
  24. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts.map +1 -1
  25. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.js +27 -46
  26. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.d.ts.map +1 -1
  27. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +25 -42
  28. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.js +1 -1
  29. package/lib/exercises/math/conversion/minutesToHours.d.ts.map +1 -1
  30. package/lib/exercises/math/conversion/minutesToHours.js +6 -3
  31. package/lib/exercises/math/conversion/secondsToHours.d.ts.map +1 -1
  32. package/lib/exercises/math/conversion/secondsToHours.js +6 -3
  33. package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -1
  34. package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +27 -17
  35. package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.d.ts.map +1 -1
  36. package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.js +5 -103
  37. package/lib/index.d.ts +11 -9
  38. package/lib/index.d.ts.map +1 -1
  39. package/lib/tests/questionTest.d.ts.map +1 -1
  40. package/lib/tests/questionTest.js +4 -2
  41. package/package.json +1 -1
@@ -3,9 +3,14 @@ type A10N = {
3
3
  a: number;
4
4
  n: number;
5
5
  };
6
+ type Item = {
7
+ tex: string;
8
+ isValid: boolean;
9
+ };
6
10
  type Identifiers = {
7
11
  signType: string;
8
- items: A10N[];
12
+ a10Ns: A10N[];
13
+ items: Item[];
9
14
  };
10
15
  type Options = {
11
16
  signTypes: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"compareA10N.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareA10N.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,IAAI,GAAG;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAwTF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA0CF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAetD,CAAC"}
1
+ {"version":3,"file":"compareA10N.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareA10N.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,IAAI,GAAG;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AA2TF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAyCF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBtD,CAAC"}
@@ -6,12 +6,11 @@ import { round } from "../../../../math/utils/round.js";
6
6
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
7
  import { multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  import { power } from "../../../../tree/nodes/operators/powerNode.js";
9
- import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
10
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
10
  import { probaLawFlip } from "../../../../utils/alea/probaLawFlip.js";
12
11
  import { random, randomMany } from "../../../../utils/alea/random.js";
13
12
  import { shuffle } from "../../../../utils/alea/shuffle.js";
14
- import { permute } from "../../../../utils/arrays/permutations.js";
13
+ import { getAllPicks } from "../../../../utils/arrays/getAllPicks.js";
15
14
  const getTexForA10N = (a10N) => {
16
15
  const { a, n } = a10N;
17
16
  return `${a.frenchify()} \\times 10^{${n}}`;
@@ -55,12 +54,14 @@ const compareFuncForA10N = (a10N1, a10N2) => {
55
54
  }
56
55
  };
57
56
  const getInstruction = (identifiers) => {
58
- const { items } = identifiers;
59
- return `Ranger par ordre croissant les nombres suivants :
57
+ const { a10Ns } = identifiers;
58
+ return `Voici une liste de nombres :
60
59
 
61
- $$
62
- ${items.map((item) => getTexForA10N(item)).join(" ; ")}
63
- $$`;
60
+ ${a10Ns.map((a10N) => `- $${getTexForA10N(a10N)}$`).join(`
61
+
62
+ `)}
63
+
64
+ Parmi les propositions suivantes, lesquelles sont vraies ?`;
64
65
  };
65
66
  const getHint = (identifiers) => {
66
67
  const { signType } = identifiers;
@@ -87,15 +88,15 @@ On range les puissances de $10$ en ordre croissant, puis pour chaque puissance d
87
88
  `;
88
89
  };
89
90
  const getCorrection = (identifiers) => {
90
- const { signType, items } = identifiers;
91
+ const { signType, a10Ns } = identifiers;
91
92
  return `Même si on a l'impression que les nombres sont écris en écriture scientifique, ce n'est pas le cas.
92
93
  Il faut les convertir en écriture scientifique et utiliser cette écriture pour les ranger dans l'ordre croissant.
93
94
 
94
- ${items
95
- .map((item) => `
95
+ ${a10Ns
96
+ .map((a10N) => `
96
97
 
97
98
  $$
98
- ${getTexForA10N(item)} = ${getSciMultNodeForA10N(item).toTex()}
99
+ ${getTexForA10N(a10N)} = ${getSciMultNodeForA10N(a10N).toTex()}
99
100
  $$
100
101
 
101
102
  `)
@@ -104,45 +105,45 @@ $$
104
105
  ${(() => {
105
106
  switch (signType) {
106
107
  case "positifs": {
107
- const positive = items.toSorted(compareFuncForA10N);
108
+ const positive = a10Ns.toSorted(compareFuncForA10N);
108
109
  return `Ici, tous les nombres sont positifs, donc
109
110
  on range les puissances de $10$ en ordre croissant, puis pour chaque puissance de $10$, les facteurs en ordre croissant.
110
111
  C'est un double tri.
111
112
 
112
113
  $$
113
- ${positive.map((item) => getSciMultNodeForA10N(item).toTex()).join("<")}
114
+ ${positive.map((a10N) => getSciMultNodeForA10N(a10N).toTex()).join("<")}
114
115
  $$
115
116
 
116
117
  Conclusion :
117
118
 
118
119
  $$
119
- ${positive.map((item) => getTexForA10N(item)).join("<")}
120
+ ${positive.map((a10N) => getTexForA10N(a10N)).join("<")}
120
121
  $$
121
122
 
122
123
  `;
123
124
  }
124
125
  case "négatifs": {
125
- const negative = items.toSorted(compareFuncForA10N);
126
+ const negative = a10Ns.toSorted(compareFuncForA10N);
126
127
  return `Ici, tous les nombres sont négatifs, donc
127
128
  on range les puissances de $10$ en ordre décroissant, puis pour chaque puissance de $10$, les facteurs en ordre décroissant.
128
129
  C'est un double tri.
129
130
 
130
131
  $$
131
- ${negative.map((item) => getSciMultNodeForA10N(item).toTex()).join("<")}
132
+ ${negative.map((a10N) => getSciMultNodeForA10N(a10N).toTex()).join("<")}
132
133
  $$
133
134
 
134
135
  Conclusion :
135
136
 
136
137
  $$
137
- ${negative.map((item) => getTexForA10N(item)).join("<")}
138
+ ${negative.map((a10N) => getTexForA10N(a10N)).join("<")}
138
139
  $$
139
140
  `;
140
141
  }
141
142
  case "mélange": {
142
- const positive = items
143
+ const positive = a10Ns
143
144
  .filter(({ a }) => a >= 0)
144
145
  .toSorted(compareFuncForA10N);
145
- const negative = items
146
+ const negative = a10Ns
146
147
  .filter(({ a }) => a < 0)
147
148
  .toSorted(compareFuncForA10N);
148
149
  return `Ici, il y a des nombres négatifs et des nombres positifs.
@@ -150,20 +151,20 @@ On commence par les négatifs :
150
151
  on range les puissances de $10$ en ordre décroissant, puis pour chaque puissance de $10$, les facteurs en ordre décroissant.
151
152
 
152
153
  $$
153
- ${negative.map((item) => getSciMultNodeForA10N(item).toTex()).join("<")}
154
+ ${negative.map((a10N) => getSciMultNodeForA10N(a10N).toTex()).join("<")}
154
155
  $$
155
156
 
156
157
  Puis on range les positifs :
157
158
  on range les puissances de $10$ en ordre croissant, puis pour chaque puissance de $10$, les facteurs en ordre croissant.
158
159
 
159
160
  $$
160
- ${positive.map((item) => getSciMultNodeForA10N(item).toTex()).join("<")}
161
+ ${positive.map((a10N) => getSciMultNodeForA10N(a10N).toTex()).join("<")}
161
162
  $$
162
163
 
163
164
  Conclusion :
164
165
 
165
166
  $$
166
- ${[...negative, ...positive].map((item) => getTexForA10N(item)).join("<")}
167
+ ${[...negative, ...positive].map((a10N) => getTexForA10N(a10N)).join("<")}
167
168
  $$
168
169
  `;
169
170
  }
@@ -174,37 +175,23 @@ $$
174
175
  const getPropositions = (n, { answer, ...identifiers }) => {
175
176
  const { items } = identifiers;
176
177
  const propositions = [];
177
- addValidProp(propositions, answer);
178
- permute(items)
179
- .slice(0, 5)
180
- .forEach((permutedItems) => {
181
- const arrayOfTex = permutedItems.map((item) => getTexForA10N(item));
182
- tryToAddWrongProp(propositions, arrayOfTex.join("<"));
183
- tryToAddWrongProp(propositions, arrayOfTex.join(">"));
178
+ items.forEach((item) => {
179
+ if (item.isValid) {
180
+ addValidProp(propositions, item.tex);
181
+ }
182
+ else {
183
+ tryToAddWrongProp(propositions, item.tex);
184
+ }
184
185
  });
185
186
  return shuffleProps(propositions, n);
186
187
  };
187
- const getAnswer = (identifiers) => {
188
- const { items } = identifiers;
189
- const answer = items
190
- .toSorted(compareFuncForA10N)
191
- .map((item) => getTexForA10N(item))
192
- .join("<");
193
- return answer;
194
- };
195
- const isAnswerValid = (ans, { answer, items }) => {
196
- const nbItems = items.length;
197
- const [ansNodes, answerNodes] = [ans, answer].map((str) => str.split("<").map((tex) => parseAlgebraic(tex)));
198
- return (ansNodes.length === nbItems &&
199
- [...Array(nbItems).keys()].every((i) => ansNodes[i].equals(answerNodes[i])));
200
- };
201
188
  const getKeys = (identifiers) => {
202
- const { items } = identifiers;
189
+ const { a10Ns } = identifiers;
203
190
  return [
204
191
  "sup",
205
192
  "inf",
206
- ...items.map((item) => {
207
- const tex = getTexForA10N(item);
193
+ ...a10Ns.map((a10N) => {
194
+ const tex = getTexForA10N(a10N);
208
195
  return {
209
196
  id: "custom",
210
197
  label: tex,
@@ -263,14 +250,34 @@ const getCompareA10NQuestion = (optsIn) => {
263
250
  arrayOfN.push(random(subPoolOfN) + random([-2, -1, 0, 1, 2]));
264
251
  }
265
252
  arrayOfN = shuffle(arrayOfN);
266
- const items = [...Array(nbItems).keys()].map((i) => {
253
+ const a10Ns = [...Array(nbItems).keys()].map((i) => {
267
254
  return {
268
255
  a: arrayOfA[i],
269
256
  n: arrayOfN[i],
270
257
  };
271
258
  });
259
+ const nbTotal = 4;
260
+ const nbValid = randint(1, 4);
261
+ const ascOrderedA10Ns = a10Ns.toSorted(compareFuncForA10N);
262
+ const items = shuffle(shuffle(getAllPicks(ascOrderedA10Ns).filter((arr) => arr.length === 2))
263
+ .slice(0, nbTotal)
264
+ .map(([a10N1, a10N2], i) => {
265
+ if (i < nbValid) {
266
+ return {
267
+ tex: `${getTexForA10N(a10N1)}<${getTexForA10N(a10N2)}`,
268
+ isValid: true,
269
+ };
270
+ }
271
+ else {
272
+ return {
273
+ tex: `${getTexForA10N(a10N2)}<${getTexForA10N(a10N1)}`,
274
+ isValid: false,
275
+ };
276
+ }
277
+ }));
272
278
  return getQuestionFromIdentifiers({
273
279
  signType,
280
+ a10Ns,
274
281
  items,
275
282
  });
276
283
  };
@@ -298,7 +305,6 @@ const options = [
298
305
  ];
299
306
  const getQuestionFromIdentifiers = (identifiers, opts) => {
300
307
  const question = {
301
- answer: getAnswer(identifiers),
302
308
  instruction: getInstruction(identifiers),
303
309
  keys: getKeys(identifiers),
304
310
  answerFormat: "tex",
@@ -318,9 +324,10 @@ export const compareA10N = {
318
324
  qcmTimer: 60,
319
325
  freeTimer: 60,
320
326
  getPropositions,
321
- isAnswerValid,
322
327
  subject: "Mathématiques",
323
328
  maxAllowedQuestions: 30,
324
329
  getQuestionFromIdentifiers,
325
330
  hasHintAndCorrection: true,
331
+ answerType: "QCM",
332
+ isQCM: true,
326
333
  };
@@ -1 +1 @@
1
- {"version":3,"file":"compareABUsingQuotient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareABUsingQuotient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,eAAe,EAAE,CAAC;CACnC,CAAC;AA+IF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAgBxD,CAAC"}
1
+ {"version":3,"file":"compareABUsingQuotient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareABUsingQuotient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,eAAe,EAAE,CAAC;CACnC,CAAC;AA2HF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAgBxD,CAAC"}
@@ -10,7 +10,7 @@ const getInstruction = (identifiers) => {
10
10
  const [A, B] = orderedNodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds).toTex());
11
11
  return `Sachant que $\\frac{${B}}{${A}} > 1$,
12
12
 
13
- comparer $${B}$ et $${A}$.;`;
13
+ comparer $${B}$ et $${A}$.`;
14
14
  };
15
15
  const getHint = (identifiers) => {
16
16
  const { orderedNodeIds } = identifiers;
@@ -44,21 +44,6 @@ const getAnswer = (identifiers) => {
44
44
  const [A, B] = orderedNodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds).toTex());
45
45
  return `${B}>${A}`;
46
46
  };
47
- const isAnswerValid = (ans, { ...identifiers }) => {
48
- const { orderedNodeIds } = identifiers;
49
- const [A, B] = orderedNodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds).toTex());
50
- const compSymbol = ans.includes(">")
51
- ? ">"
52
- : ans.includes("<")
53
- ? "<"
54
- : undefined;
55
- if (!compSymbol) {
56
- return false;
57
- }
58
- else {
59
- return (compSymbol === ">" ? [B, A] : [A, B]).every((tex, i) => tex === ans.split(compSymbol)[i]);
60
- }
61
- };
62
47
  const getPropositions = (nbProps, { ...identifiers }) => {
63
48
  const { orderedNodeIds } = identifiers;
64
49
  const [A, B] = orderedNodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds).toTex());
@@ -88,7 +73,7 @@ const getKeys = (identifiers) => {
88
73
  };
89
74
  const getCompareABUsingQuotientQuestion = () => {
90
75
  const n = randint(2, 150);
91
- const orderedNodesIncreasing = [add(1, sqrt(add(1, n))), add(2, sqrt(n))];
76
+ const orderedNodesIncreasing = [add(1, sqrt(1 + n)), add(2, sqrt(n))];
92
77
  return getQuestionFromIdentifiers({
93
78
  orderedNodeIds: orderedNodesIncreasing.map((node) => node.toIdentifiers()),
94
79
  });
@@ -113,10 +98,10 @@ export const compareABUsingQuotient = {
113
98
  qcmTimer: 60,
114
99
  freeTimer: 60,
115
100
  getPropositions,
116
- isAnswerValid,
117
101
  getAnswer,
118
102
  subject: "Mathématiques",
119
103
  maxAllowedQuestions: 30,
120
104
  getQuestionFromIdentifiers,
121
105
  hasHintAndCorrection: true,
106
+ answerType: "QCU",
122
107
  };
@@ -4,6 +4,9 @@ type Identifiers = {
4
4
  nodeIds: NodeIdentifiers[];
5
5
  texAnswers: string[];
6
6
  };
7
- export declare const compareFracABWithFracAPlusCBPlusC: Exercise<Identifiers>;
7
+ type Options = {
8
+ isFracOfSums: boolean;
9
+ };
10
+ export declare const compareFracABWithFracAPlusCBPlusC: Exercise<Identifiers, Options>;
8
11
  export {};
9
12
  //# sourceMappingURL=compareFracABWithFracAPlusCBPlusC.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compareFracABWithFracAPlusCBPlusC.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA4LF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAmBnE,CAAC"}
1
+ {"version":3,"file":"compareFracABWithFracAPlusCBPlusC.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA0MF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAgBF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqB1E,CAAC"}
@@ -1,9 +1,9 @@
1
- import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { lcm } from "../../../../math/utils/arithmetic/lcm.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
6
- import { add } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { add, isAddNode } from "../../../../tree/nodes/operators/addNode.js";
7
7
  import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
8
8
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
@@ -33,12 +33,17 @@ const getCorrection = (identifiers) => {
33
33
  ? frac(multiply(node.leftChild.simplify(), frac(sameDen, node.rightChild)).simplify(), sameDen)
34
34
  : frac(multiply(node, sameDen).simplify(), sameDen));
35
35
  const answer = getAnswer(identifiers);
36
- return `On a :
36
+ const isFracOfSums = isAddNode(nodes[1].leftChild);
37
+ return `${isFracOfSums
38
+ ? `On a :
37
39
 
38
40
  $$
39
41
  ${nodes[1].toSimplificationTex()}
40
42
  $$
41
43
 
44
+ `
45
+ : ``}
46
+
42
47
  On veut donc comparer $${nodesSimplified[0].toTex()}$ et $${nodesSimplified[1].toTex()}$.
43
48
 
44
49
  On peut choisir $${sameDen.frenchify()}$ comme dénominateur commun.
@@ -84,14 +89,19 @@ const getAnswer = (identifiers) => {
84
89
  const { texAnswers } = identifiers;
85
90
  return texAnswers[0];
86
91
  };
87
- const isAnswerValid = (ans, { texAnswers }) => {
88
- return texAnswers.includes(ans);
89
- };
90
- const getCompareFracABWithFracAPlusCBPlusCQuestion = () => {
92
+ const getCompareFracABWithFracAPlusCBPlusCQuestion = (optsIn) => {
93
+ const opts = optsIn ?? optsDefault;
91
94
  const a = randint(1, 10);
92
- const b = randint(1, 10, [a]);
95
+ const b = randint(2, 10, [a]);
93
96
  const c = randint(1, 10);
94
- const nodes = [frac(a, b), frac(add(a, c), add(b, c))];
97
+ const nodes = [
98
+ frac(a, b),
99
+ (() => {
100
+ const nodeNum = opts.isFracOfSums ? add(a, c) : (a + c).toTree();
101
+ const nodeDec = opts.isFracOfSums ? add(b, c) : (b + c).toTree();
102
+ return frac(nodeNum, nodeDec);
103
+ })(),
104
+ ];
95
105
  const isOrderAsc = coinFlip();
96
106
  const sortedNodes = nodes.toSorted((node1, node2) => (isOrderAsc ? +1 : -1) * (node1.evaluate() - node2.evaluate()));
97
107
  const texAnswers = [
@@ -132,17 +142,31 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
132
142
  };
133
143
  return question;
134
144
  };
145
+ const optsDefault = {
146
+ isFracOfSums: false,
147
+ };
148
+ const options = [
149
+ {
150
+ id: "isFracOfSums",
151
+ label: "Fraction de sommes ?",
152
+ target: GeneratorOptionTarget.generation,
153
+ type: GeneratorOptionType.checkbox,
154
+ values: [true, false],
155
+ defaultValue: optsDefault.isFracOfSums,
156
+ },
157
+ ];
135
158
  export const compareFracABWithFracAPlusCBPlusC = {
136
159
  id: "compareFracABWithFracAPlusCBPlusC",
137
160
  label: "Effectuer des comparaisons entre des fractions simples (de la forme $\\frac{a}{b}$ et $\\frac{a+c}{b+c}$)",
138
161
  isSingleStep: true,
139
162
  generator: (nb, opts) => getDistinctQuestions(() => getCompareFracABWithFracAPlusCBPlusCQuestion(opts), nb, 30),
163
+ options,
140
164
  qcmTimer: 60,
141
165
  freeTimer: 60,
142
- isAnswerValid,
143
166
  getPropositions,
144
167
  subject: "Mathématiques",
145
168
  maxAllowedQuestions: 30,
146
169
  getQuestionFromIdentifiers,
147
170
  hasHintAndCorrection: true,
171
+ answerType: "QCU",
148
172
  };
@@ -5,18 +5,14 @@ type QCMItem = {
5
5
  isValidAnswer: boolean;
6
6
  };
7
7
  type QuestionParam = {
8
- fakeName: string;
8
+ letter: string;
9
9
  trueName: string;
10
10
  tex: string;
11
11
  nodeIds: NodeIdentifiers;
12
12
  explainTex: string;
13
13
  };
14
14
  type Identifiers = {
15
- sign: number;
16
- a: number;
17
- b: number;
18
- c: number;
19
- dictFakeNameToQuestionParam: Record<string, QuestionParam>;
15
+ questionParams: QuestionParam[];
20
16
  items: QCMItem[];
21
17
  };
22
18
  type Options = {
@@ -1 +1 @@
1
- {"version":3,"file":"compareFracAndDec.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracAndDec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3D,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB,CAAC;AAkYF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AA+BF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB5D,CAAC"}
1
+ {"version":3,"file":"compareFracAndDec.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracAndDec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB,CAAC;AA6RF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AAuBF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB5D,CAAC"}