math-exercises 3.0.132 → 3.0.133

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 (48) hide show
  1. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts +1 -1
  2. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +5 -5
  4. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/ordering/compareA10N.js +12 -7
  6. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.js +8 -6
  8. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +8 -9
  10. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts.map +1 -1
  11. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.js +4 -4
  12. package/lib/exercises/math/conversion/prefixToNumber.d.ts +0 -2
  13. package/lib/exercises/math/conversion/prefixToNumber.d.ts.map +1 -1
  14. package/lib/exercises/math/conversion/prefixToNumber.js +27 -22
  15. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.js +1 -2
  17. package/lib/exercises/math/geometry/cartesian/index.d.ts +1 -0
  18. package/lib/exercises/math/geometry/cartesian/index.d.ts.map +1 -1
  19. package/lib/exercises/math/geometry/cartesian/index.js +1 -0
  20. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts +6 -9
  21. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
  22. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +60 -137
  23. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts +16 -0
  24. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -0
  25. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +213 -0
  26. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +2 -2
  27. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.js +6 -6
  28. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts +0 -1
  29. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts.map +1 -1
  30. package/lib/exercises/math/probaStat/probaAsSumOfProbas.js +52 -59
  31. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts.map +1 -1
  32. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +70 -23
  33. package/lib/exercises/pc/index.d.ts +0 -1
  34. package/lib/exercises/pc/index.d.ts.map +1 -1
  35. package/lib/exercises/pc/index.js +0 -1
  36. package/lib/exercises/pc/motion/averageSpeed.d.ts +0 -2
  37. package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
  38. package/lib/exercises/pc/motion/averageSpeed.js +28 -36
  39. package/lib/exercises/pc/weight/calculateWeight.d.ts +0 -1
  40. package/lib/exercises/pc/weight/calculateWeight.d.ts.map +1 -1
  41. package/lib/exercises/pc/weight/calculateWeight.js +26 -19
  42. package/lib/index.d.ts +9 -38
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/playgroundUtils.d.ts +3 -0
  45. package/lib/playgroundUtils.d.ts.map +1 -0
  46. package/lib/playgroundUtils.js +13 -0
  47. package/lib/server.js +121 -0
  48. package/package.json +1 -1
@@ -216,8 +216,7 @@ class FiniteProbDistr {
216
216
  const dictPToArrayOfIndexes = {};
217
217
  for (let i = 0; i < arrProba.length; i++) {
218
218
  const p = arrProba[i];
219
- console.log("will simplify", p);
220
- const tex = p.simplify().toTex();
219
+ const tex = p.toTex();
221
220
  if (dictPToArrayOfIndexes[tex] === undefined) {
222
221
  dictPToArrayOfIndexes[tex] = [];
223
222
  }
@@ -233,7 +232,7 @@ class FiniteProbDistr {
233
232
  return p;
234
233
  }
235
234
  getArrIndexForP(p) {
236
- return this.dictPToArrayOfIndexes[p.simplify().toTex()];
235
+ return this.dictPToArrayOfIndexes[p.toTex()];
237
236
  }
238
237
  getArrFrenchStrings(isDisplayingValue) {
239
238
  return Object.entries(this.dictPToArrayOfIndexes)
@@ -273,12 +272,15 @@ const getAnswerValueNode = (identifiers) => {
273
272
  const { eventIds, arrProba } = identifiers;
274
273
  const evUnion = EventConstructor.fromIdentifiers(eventIds);
275
274
  const finiteProbDistr = FiniteProbDistrConstructor.fromArrProba(arrProba.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds)));
276
- const nodeSumSimplified = operatorComposition(AddNode, evUnion
275
+ const arrFrac = evUnion
277
276
  .getArrElem()
278
- .map((evElem) => finiteProbDistr.getPForIndex(evElem.index))).simplify({
279
- //!TODO Sebastien : ne doit pas être nécessaire, à fix
280
- //nbMaxSteps: 100,
281
- });
277
+ .map((evElem) => finiteProbDistr.getPForIndex(evElem.index));
278
+ const nodeSumSimplified = (() => {
279
+ const den = arrFrac[0].rightChild.evaluate();
280
+ return frac(arrFrac
281
+ .map((fNode) => fNode.leftChild.evaluate())
282
+ .reduce((acc, x) => acc + x, 0), den);
283
+ })();
282
284
  return nodeSumSimplified;
283
285
  };
284
286
  const getAnswerNode = (identifiers) => {
@@ -320,11 +322,7 @@ $$
320
322
  p_{${evElem.id}} = ${finiteProbDistr.getPForIndex(evElem.index).toTex()}
321
323
  $$`).join(`
322
324
  `)}`;
323
- const nodeSumSimplified = operatorComposition(AddNode, evUnion
324
- .getArrElem()
325
- .map((evElem) => finiteProbDistr.getPForIndex(evElem.index))).simplify({
326
- //nbMaxSteps: 100,
327
- });
325
+ const nodeSumSimplified = getAnswerNode(identifiers);
328
326
  strCorrection += `
329
327
  Donc:
330
328
 
@@ -344,7 +342,6 @@ $$`;
344
342
  const optsDefault = {
345
343
  nbElem: ["4", "6", "10", "12"],
346
344
  unionLength: ["2", "3", "4", "5"],
347
- isProbasAreNumbers: true,
348
345
  };
349
346
  const options = [
350
347
  {
@@ -363,13 +360,6 @@ const options = [
363
360
  values: ["2", "3", "4", "5", "6"],
364
361
  defaultValue: optsDefault.unionLength,
365
362
  },
366
- // {
367
- // id: "isProbasAreNumbers",
368
- // label: "Probabilités sous forme de nombres ?",
369
- // type: GeneratorOptionType.checkbox,
370
- // target: GeneratorOptionTarget.generation,
371
- // defaultValue: optsDefault.isProbasAreNumbers,
372
- // },
373
363
  ];
374
364
  const getKeys = () => {
375
365
  return [];
@@ -382,39 +372,41 @@ const getPropositions = (n, { answer, ...identifiers }) => {
382
372
  addValidProp(propositions, answer);
383
373
  if (isProbasAreNumbers) {
384
374
  const finiteProbDistr = FiniteProbDistrConstructor.fromArrProba(arrProba.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds)));
385
- tryToAddWrongProp(propositions, operatorComposition(MultiplyNode, evUnion
386
- .getArrElem()
387
- .map((evElem) => finiteProbDistr.getPForIndex(evElem.index)))
388
- .simplify({
389
- //nbMaxSteps: 100,
390
- })
391
- .toTex());
392
- tryToAddWrongProp(propositions, substract(1, operatorComposition(MultiplyNode, evUnion
393
- .getArrElem()
394
- .map((evElem) => finiteProbDistr.getPForIndex(evElem.index))))
395
- .simplify({
396
- //nbMaxSteps: 100,
397
- })
398
- .toTex());
399
- tryToAddWrongProp(propositions, substract(1, operatorComposition(AddNode, evUnion
400
- .getArrElem()
401
- .map((evElem) => finiteProbDistr.getPForIndex(evElem.index))).simplify({
402
- //nbMaxSteps: 100,
403
- })).toTex());
404
- tryToAddWrongProp(propositions, operatorComposition(AddNode, evUnion
375
+ const arrFrac = evUnion
405
376
  .getArrElem()
406
- .map((evElem) => multiply(evElem.index, finiteProbDistr.getPForIndex(evElem.index))))
407
- .simplify({
408
- //nbMaxSteps: 100,
409
- })
410
- .toTex());
411
- tryToAddWrongProp(propositions, multiply(frac(1, evUnion.getArrElem().length), operatorComposition(AddNode, evUnion
412
- .getArrElem()
413
- .map((evElem) => finiteProbDistr.getPForIndex(evElem.index))))
414
- .simplify({
415
- //nbMaxSteps: 100,
416
- })
417
- .toTex());
377
+ .map((evElem) => finiteProbDistr.getPForIndex(evElem.index));
378
+ tryToAddWrongProp(propositions, (() => {
379
+ const den = arrFrac[0].rightChild.evaluate();
380
+ return frac(arrFrac
381
+ .map((fNode) => fNode.leftChild.evaluate())
382
+ .reduce((acc, x) => acc * x, 0), den);
383
+ })().toTex());
384
+ tryToAddWrongProp(propositions, (() => {
385
+ const den = arrFrac[0].rightChild.evaluate();
386
+ return frac(den -
387
+ arrFrac
388
+ .map((fNode) => fNode.leftChild.evaluate())
389
+ .reduce((acc, x) => acc * x, 0), den);
390
+ })().toTex());
391
+ tryToAddWrongProp(propositions, (() => {
392
+ const den = arrFrac[0].rightChild.evaluate();
393
+ return frac(den -
394
+ arrFrac
395
+ .map((fNode) => fNode.leftChild.evaluate())
396
+ .reduce((acc, x) => acc + x, 0), den);
397
+ })().toTex());
398
+ tryToAddWrongProp(propositions, (() => {
399
+ const den = arrFrac[0].rightChild.evaluate();
400
+ return frac(arrFrac
401
+ .map((fNode, i) => fNode.leftChild.evaluate() * i)
402
+ .reduce((acc, x) => acc + x, 0), den);
403
+ })().toTex());
404
+ tryToAddWrongProp(propositions, (() => {
405
+ const den = arrFrac[0].rightChild.evaluate();
406
+ return frac(arrFrac
407
+ .map((fNode) => fNode.leftChild.evaluate())
408
+ .reduce((acc, x) => acc + x, 0), den * evUnion.getArrElem().length);
409
+ })().toTex());
418
410
  }
419
411
  else {
420
412
  tryToAddWrongProp(propositions, operatorComposition(MultiplyNode, evUnion.getArrElem().map((evElem) => evElem.p))
@@ -451,10 +443,13 @@ const getValueNode = (tex, arrProba) => {
451
443
  return parseInt(texVar.substring(texVar.indexOf("E_{") + 3, texVar.indexOf("}}")));
452
444
  }
453
445
  });
454
- const arrayOfNodes = arrayOfIndexes.map((i) => finiteProbDistr.getPForIndex(i));
455
- return operatorComposition(AddNode, arrayOfNodes).simplify({
456
- //nbMaxSteps: 100,
457
- });
446
+ const arrFrac = arrayOfIndexes.map((i) => finiteProbDistr.getPForIndex(i));
447
+ return (() => {
448
+ const den = arrFrac[0].rightChild.evaluate();
449
+ return frac(arrFrac
450
+ .map((fNode) => fNode.leftChild.evaluate())
451
+ .reduce((acc, x) => acc + x, 0), den);
452
+ })();
458
453
  };
459
454
  const isAnswerValid = (ans, { answer, ...identifiers }) => {
460
455
  const { arrProba } = identifiers;
@@ -481,12 +476,10 @@ const getProbaAsSumOfProbasQuestion = (optsIn) => {
481
476
  const eventIds = evUnion.toIdentifiers();
482
477
  const nbUnique = Math.min(randint(3, 7), situation.allElem.length - 1);
483
478
  const finiteProbDistr = FiniteProbDistrConstructor.randomDistr(situation.allElem.length, nbUnique);
484
- const isProbasAreNumbers = opts.isProbasAreNumbers;
485
479
  const identifiers = {
486
480
  indexSituation,
487
481
  eventIds,
488
482
  arrProba: finiteProbDistr.arrProba.map((node) => node.toIdentifiers()),
489
- isProbasAreNumbers,
490
483
  };
491
484
  return getQuestionFromIdentifiers(identifiers, opts);
492
485
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plausibilityOfAverage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/plausibilityOfAverage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAoKF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
1
+ {"version":3,"file":"plausibilityOfAverage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/plausibilityOfAverage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAiOF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
@@ -3,7 +3,6 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
5
5
  import { random } from "../../../../utils/alea/random.js";
6
- import { mdTable } from "../../../../utils/markdown/mdTable.js";
7
6
  const getInstruction = (identifiers) => {
8
7
  const { a, values, isQuestionIsAboveA } = identifiers;
9
8
  return `Si on considère la série suivante :
@@ -20,36 +19,84 @@ La proposition suivante est-elle vraie ?
20
19
  const getHint = ({ a }) => {
21
20
  return `Regarde l'écart des valeurs par rapport à $${a.frenchify()}$.`;
22
21
  };
22
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
23
+ // const { a, values, isAboveA } = identifiers;
24
+ // const answer = getAnswer(identifiers);
25
+ // const valuesBelowA = values.filter((v) => v < a);
26
+ // const valuesAboveA = values.filter((v) => v > a);
27
+ // return `${answer}, car si l'on regarde les écarts par rapport à $${a.frenchify()}$ :
28
+ // $\\ $
29
+ // ${mdTable(
30
+ // [
31
+ // ["\\text{Valeur}", "\\text{Écart}"],
32
+ // [`\\text{Valeurs inférieures à } ${a.frenchify()}`, "\\text{}"],
33
+ // ...valuesBelowA.map((v) => [v.frenchify(), (v - a).frenchify()]),
34
+ // [
35
+ // "\\text{Total inférieur}",
36
+ // valuesBelowA
37
+ // .map((v) => v - a)
38
+ // .reduce((acc, v) => acc + v, 0)
39
+ // .frenchify(),
40
+ // ],
41
+ // [`\\text{Valeurs supérieures à } ${a.frenchify()}`, "\\text{}"],
42
+ // ...valuesAboveA.map((v) => [v.frenchify(), `+${(v - a).frenchify()}`]),
43
+ // [
44
+ // "\\text{Total supérieur}",
45
+ // `+${valuesAboveA
46
+ // .map((v) => v - a)
47
+ // .reduce((acc, v) => acc + v, 0)
48
+ // .frenchify()}`,
49
+ // ],
50
+ // ],
51
+ // true,
52
+ // )}
53
+ // $\\ $
54
+ // Le total ${
55
+ // isAboveA ? `supérieur` : `inférieur`
56
+ // } est plus grand, en valeur absolue, que le total ${
57
+ // isAboveA ? `inférieur` : `supérieur`
58
+ // } donc on peut affirmer que la moyenne de cette série est strictement ${
59
+ // isAboveA ? `supérieure` : `inférieure`
60
+ // } à $${a.frenchify()}$.`;
61
+ // };
23
62
  const getCorrection = (identifiers) => {
24
63
  const { a, values, isAboveA } = identifiers;
25
64
  const answer = getAnswer(identifiers);
26
65
  const valuesBelowA = values.filter((v) => v < a);
27
66
  const valuesAboveA = values.filter((v) => v > a);
28
- return `${answer}, car si l'on regarde les écarts par rapport à $${a.frenchify()}$ :
67
+ return `${answer}. En effet :
29
68
 
30
69
  $\\ $
70
+
71
+ Si l'on regarde les valeurs strictement inférieures à $${a.frenchify()}$ :
72
+
73
+ ${valuesBelowA
74
+ .map((v) => `
75
+
76
+ $${v.frenchify()}$ est $${(a - v).frenchify()}$ points en dessous de $${a.frenchify()}$
31
77
 
32
- ${mdTable([
33
- ["\\text{Valeur}", "\\text{Écart}"],
34
- [`\\text{Valeurs inférieures à } ${a.frenchify()}`, "\\text{}"],
35
- ...valuesBelowA.map((v) => [v.frenchify(), (v - a).frenchify()]),
36
- [
37
- "\\text{Total inférieur}",
38
- valuesBelowA
39
- .map((v) => v - a)
40
- .reduce((acc, v) => acc + v, 0)
41
- .frenchify(),
42
- ],
43
- [`\\text{Valeurs supérieures à } ${a.frenchify()}`, "\\text{}"],
44
- ...valuesAboveA.map((v) => [v.frenchify(), `+${(v - a).frenchify()}`]),
45
- [
46
- "\\text{Total supérieur}",
47
- `+${valuesAboveA
48
- .map((v) => v - a)
49
- .reduce((acc, v) => acc + v, 0)
50
- .frenchify()}`,
51
- ],
52
- ], true)}
78
+ `)
79
+ .join("")}
80
+ Ce qui fait en tout $${valuesBelowA
81
+ .map((v) => a - v)
82
+ .reduce((acc, v) => acc + v, 0)
83
+ .frenchify()}$ points en dessous de $${a.frenchify()}$.
84
+
85
+ $\\ $
86
+
87
+ Si l'on regarde les valeurs strictement supérieures à $${a.frenchify()}$ :
88
+
89
+ ${valuesAboveA
90
+ .map((v) => `
91
+
92
+ $${v.frenchify()}$ est $${(v - a).frenchify()}$ points en dessus de $${a.frenchify()}$
93
+
94
+ `)
95
+ .join("")}
96
+ Ce qui fait en tout $${valuesAboveA
97
+ .map((v) => v - a)
98
+ .reduce((acc, v) => acc + v, 0)
99
+ .frenchify()}$ points au dessus de $${a.frenchify()}$.
53
100
 
54
101
  $\\ $
55
102
 
@@ -28,6 +28,5 @@ export * from "./motion/index.js";
28
28
  export * from "./dosage/index.js";
29
29
  export * from "./spectral/index.js";
30
30
  export * from "./power/index.js";
31
- export * from "./optics/index.js";
32
31
  export * from "./mathExosInPC.js";
33
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/pc/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uBAAuB,CAAC;AAEtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/pc/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uBAAuB,CAAC;AAEtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
@@ -28,5 +28,4 @@ export * from "./motion/index.js";
28
28
  export * from "./dosage/index.js";
29
29
  export * from "./spectral/index.js";
30
30
  export * from "./power/index.js";
31
- export * from "./optics/index.js";
32
31
  export * from "./mathExosInPC.js";
@@ -6,10 +6,8 @@ type Msr = {
6
6
  type Identifiers = {
7
7
  distance: Msr;
8
8
  time: Msr;
9
- opts: Options;
10
9
  };
11
10
  type Options = {
12
- acceptedInputType: string;
13
11
  unitTex: string;
14
12
  };
15
13
  export declare const averageSpeed: Exercise<Identifiers, Options>;
@@ -1 +1 @@
1
- {"version":3,"file":"averageSpeed.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/motion/averageSpeed.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA8NF,KAAK,OAAO,GAAG;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAsBF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAcvD,CAAC"}
1
+ {"version":3,"file":"averageSpeed.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/motion/averageSpeed.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAkOF,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAqBF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAcvD,CAAC"}
@@ -11,20 +11,23 @@ import { VariableNode } from "../../../tree/nodes/variables/variableNode.js";
11
11
  import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
12
12
  const timeUnits = [TimeUnit.h, TimeUnit.min];
13
13
  const distanceUnitValues = [DistanceUnit.km, DistanceUnit.m];
14
- const getAcceptedInputTypesSentence = (identifiers) => {
15
- const { opts } = identifiers;
14
+ const getAcceptedInputTypesSentence = (acceptedInputType) => {
16
15
  return `Donner le résultat
17
16
  ${(() => {
18
- switch (opts.acceptedInputType) {
17
+ switch (acceptedInputType) {
19
18
  case "exact":
20
19
  return "sous forme exacte";
21
- case "significant(3)":
20
+ default:
21
+ case "arrondi avec 3 chiffres significatifs":
22
22
  return "approché avec $3$ chiffres significatifs";
23
23
  }
24
24
  })()}.`;
25
25
  };
26
- const getInstruction = (identifiers) => {
27
- const { distance, time, opts } = identifiers;
26
+ const getInstruction = (identifiers, optsIn) => {
27
+ const opts = optsIn ?? optsDefault;
28
+ const acceptedInputType = "arrondi avec 3 chiffres significatifs";
29
+ const { distance, time } = identifiers;
30
+ const { unitTex } = opts;
28
31
  const distanceMeasure = new Measure(distance.value, 0, distanceUnitValues[distance.unitIndex]);
29
32
  const timeMeasure = new Measure(time.value, 0, timeUnits[time.unitIndex]);
30
33
  const instruction = `Soit un objet parcourant $${distanceMeasure.toTex({
@@ -32,13 +35,14 @@ const getInstruction = (identifiers) => {
32
35
  })}$ en $${timeMeasure.toTex({ notScientific: true })}$.
33
36
 
34
37
 
35
- Calculer la vitesse moyenne de cet objet en ${opts.unitTex}.
38
+ Calculer la vitesse moyenne de cet objet en ${unitTex}.
36
39
 
37
- ${getAcceptedInputTypesSentence(identifiers)}
40
+ ${getAcceptedInputTypesSentence(acceptedInputType)}
38
41
  `;
39
42
  return instruction;
40
43
  };
41
- const getHint = ({ opts }) => {
44
+ const getHint = (_, optsIn) => {
45
+ const opts = optsIn ?? optsDefault;
42
46
  const unlatexUnit = opts.unitTex.substring(1, opts.unitTex.length - 1);
43
47
  return `La vitesse moyenne est donnée par :
44
48
 
@@ -46,8 +50,9 @@ $$
46
50
  \\frac{\\text{distance}}{\\text{temps}} \\ ${unlatexUnit}
47
51
  $$`;
48
52
  };
49
- const getCorrection = (identifiers) => {
50
- const { distance, time, opts } = identifiers;
53
+ const getCorrection = (identifiers, optsIn) => {
54
+ const opts = optsIn ?? optsDefault;
55
+ const { distance, time } = identifiers;
51
56
  let correction = ``;
52
57
  const distanceMeasure = new Measure(distance.value, 0, distanceUnitValues[distance.unitIndex]).convert("m");
53
58
  const timeMeasure = new Measure(time.value, 0, timeUnits[time.unitIndex]).convert("s");
@@ -105,7 +110,8 @@ const isAnswerValid = (ans, { answer, ...identifiers }) => {
105
110
  const answerNode = parseAlgebraic(getAnswerMeasure(identifiers).toTex({ hideUnit: true }));
106
111
  return substract(ansNode, answerNode).simplify().evaluate() === 0;
107
112
  };
108
- const getPropositions = (n, { answer, distance, time, opts }) => {
113
+ const getPropositions = (n, { answer, distance, time }, optsIn) => {
114
+ const opts = optsIn ?? optsDefault;
109
115
  const propositions = [];
110
116
  const unlatexUnit = opts.unitTex.substring(1, opts.unitTex.length - 1);
111
117
  addValidProp(propositions, `${answer} \\ ${unlatexUnit}`);
@@ -138,41 +144,27 @@ const generatePropositions = (distance, time) => {
138
144
  distance.divide(time).toSignificant(2).toTex({ hideUnit: true }),
139
145
  ];
140
146
  };
141
- const getKeys = () => {
142
- return [];
143
- // return [`\\text{m} \\cdot \\text{s}^{-1}`].map((tex) => {
144
- // return {
145
- // id: "custom",
146
- // label: tex,
147
- // labelType: "raw",
148
- // mathfieldInstructions: {
149
- // method: "write",
150
- // content: tex,
151
- // },
152
- // } as KeyProps;
153
- // });
154
- };
155
147
  const getAverageSpeedQuestion = (optsIn) => {
156
- const opts = Object.assign(optsDefault, optsIn) ?? optsDefault;
148
+ const opts = optsIn ?? optsDefault;
157
149
  const distance = { value: randint(70, 151), unitIndex: randint(0, 2) };
158
150
  const time = { value: randint(10, 61), unitIndex: randint(0, 2) };
159
- const identifiers = { distance, time, opts };
160
- return getQuestionFromIdentifiers(identifiers);
151
+ const identifiers = { distance, time };
152
+ return getQuestionFromIdentifiers(identifiers, opts);
161
153
  };
162
- const getQuestionFromIdentifiers = (identifiers) => {
154
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
163
155
  const question = {
164
- answer: getAnswer(identifiers),
165
- instruction: getInstruction(identifiers),
166
- keys: getKeys(identifiers),
167
- hint: getHint(identifiers),
168
- correction: getCorrection(identifiers),
156
+ answer: getAnswer(identifiers, opts),
157
+ instruction: getInstruction(identifiers, opts),
158
+ keys: [],
159
+ hint: getHint(identifiers, opts),
160
+ correction: getCorrection(identifiers, opts),
169
161
  answerFormat: "tex",
170
162
  identifiers,
163
+ options: opts,
171
164
  };
172
165
  return question;
173
166
  };
174
167
  const optsDefault = {
175
- acceptedInputType: "significant(3)",
176
168
  unitTex: "$\\text{m} \\cdot \\text{s}^{-1}$",
177
169
  };
178
170
  const options = [
@@ -1,7 +1,6 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  mass: number;
4
- optsIdent: Options;
5
4
  };
6
5
  type InputType = "decimal" | "sci";
7
6
  type Options = {
@@ -1 +1 @@
1
- {"version":3,"file":"calculateWeight.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/weight/calculateWeight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC;AAEnC,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAuMF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAc1D,CAAC"}
1
+ {"version":3,"file":"calculateWeight.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/weight/calculateWeight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC;AAEnC,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAkNF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAc1D,CAAC"}
@@ -28,8 +28,9 @@ const options = [
28
28
  defaultValue: [optsDefault.nbDigits],
29
29
  },
30
30
  ];
31
- const getInstruction = (identifiers) => {
32
- const { mass, optsIdent } = identifiers;
31
+ const getInstruction = (identifiers, optsIn) => {
32
+ const opts = optsIn ?? optsDefault;
33
+ const { mass } = identifiers;
33
34
  const instruction = `Soit un objet avec une masse de $${mass}\\ \\textrm{kg}$.
34
35
 
35
36
  L'accélération due à la gravité vaut $${g.frenchify()}$ $\\textrm{m} \\cdot \\textrm{s}^{${-2}}$.
@@ -37,7 +38,7 @@ L'accélération due à la gravité vaut $${g.frenchify()}$ $\\textrm{m} \\cdot
37
38
  Calculer le poids de cet objet en Newtons.
38
39
  Donner le résultat
39
40
  ${(() => {
40
- switch (optsIdent.inputType) {
41
+ switch (opts.inputType) {
41
42
  case "decimal":
42
43
  return `en écriture décimale`;
43
44
  case "sci":
@@ -45,7 +46,7 @@ ${(() => {
45
46
  }
46
47
  })()}
47
48
  ${(() => {
48
- switch (optsIdent.nbDigits) {
49
+ switch (opts.nbDigits) {
49
50
  case "0":
50
51
  return `arrondie à l'unité`;
51
52
  case "1":
@@ -77,25 +78,30 @@ const getCorrection = (identifiers) => {
77
78
  const correction = `Pour calculer le poids de l'objet, on utilise la formule :
78
79
 
79
80
  $$
80
- P=m \\cdot g
81
+ P = m \\cdot g
81
82
  $$
82
83
 
83
84
  On a :
84
85
 
85
86
  $$
86
- P = ${mass.frenchify()} \\times ${g.frenchify()} \\Rightarrow P=${answer}
87
+ P = ${mass.frenchify()} \\times ${g.frenchify()}
88
+ $$
89
+
90
+ $$
91
+ P \\approx ${answer}
87
92
  $$`;
88
93
  return correction;
89
94
  };
90
- const getAnswer = (identifiers) => {
91
- const { mass, optsIdent } = identifiers;
92
- switch (optsIdent.inputType) {
95
+ const getAnswer = (identifiers, optsIn) => {
96
+ const opts = optsIn ?? optsDefault;
97
+ const { mass } = identifiers;
98
+ switch (opts.inputType) {
93
99
  case "decimal": {
94
- const answer = round(mass * g, Number(optsIdent.nbDigits));
100
+ const answer = round(mass * g, Number(opts.nbDigits));
95
101
  return `${answer.frenchify()}N`;
96
102
  }
97
103
  case "sci": {
98
- const answer = (mass * g).toScientific(Number(optsIdent.nbDigits));
104
+ const answer = (mass * g).toScientific(Number(opts.nbDigits));
99
105
  return `${answer.toTex()}N`;
100
106
  }
101
107
  }
@@ -103,12 +109,13 @@ const getAnswer = (identifiers) => {
103
109
  const isAnswerValid = (ans, { answer }) => {
104
110
  return ans === answer;
105
111
  };
106
- const getPropositions = (n, { answer, mass, optsIdent }) => {
112
+ const getPropositions = (n, { answer, mass }, optsIn) => {
113
+ const opts = optsIn ?? optsDefault;
107
114
  const propositions = [];
108
115
  const weight = mass * g;
109
116
  addValidProp(propositions, answer);
110
- const nbDigits = Number(optsIdent.nbDigits);
111
- switch (optsIdent.inputType) {
117
+ const nbDigits = Number(opts.nbDigits);
118
+ switch (opts.inputType) {
112
119
  case "decimal":
113
120
  {
114
121
  tryToAddWrongProp(propositions, `${round(weight * 10, nbDigits).frenchify()}N`);
@@ -142,16 +149,16 @@ const getCalculateWeightQuestion = (optsIn) => {
142
149
  })
143
150
  : optsDefault;
144
151
  const mass = randint(30, 151);
145
- const identifiers = { mass: mass, optsIdent: opts };
152
+ const identifiers = { mass: mass };
146
153
  return getQuestionFromIdentifiers(identifiers, opts);
147
154
  };
148
155
  const getQuestionFromIdentifiers = (identifiers, opts) => {
149
156
  const question = {
150
- answer: getAnswer(identifiers),
151
- instruction: getInstruction(identifiers),
157
+ answer: getAnswer(identifiers, opts),
158
+ instruction: getInstruction(identifiers, opts),
152
159
  keys: ["N"],
153
- hint: getHint(identifiers),
154
- correction: getCorrection(identifiers),
160
+ hint: getHint(identifiers, opts),
161
+ correction: getCorrection(identifiers, opts),
155
162
  answerFormat: "tex",
156
163
  identifiers,
157
164
  options: opts,