math-exercises 3.0.145 → 3.0.146

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 (92) hide show
  1. package/lib/exercises/math/calcul/addAndSub.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/addAndSub.js +20 -1
  3. package/lib/exercises/math/calcul/index.d.ts +1 -0
  4. package/lib/exercises/math/calcul/index.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/index.js +1 -0
  6. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +2 -0
  7. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/mentalCaluls/index.js +2 -0
  9. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +22 -0
  11. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.d.ts +9 -0
  12. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.d.ts.map +1 -0
  13. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.js +152 -0
  14. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.d.ts +15 -0
  15. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.d.ts.map +1 -0
  16. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.js +412 -0
  17. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  18. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +37 -7
  19. package/lib/exercises/math/calcul/ratio/index.d.ts +2 -0
  20. package/lib/exercises/math/calcul/ratio/index.d.ts.map +1 -0
  21. package/lib/exercises/math/calcul/ratio/index.js +2 -0
  22. package/lib/exercises/math/calcul/ratio/partUsingRatio.d.ts +14 -0
  23. package/lib/exercises/math/calcul/ratio/partUsingRatio.d.ts.map +1 -0
  24. package/lib/exercises/math/calcul/ratio/partUsingRatio.js +388 -0
  25. package/lib/exercises/math/calcul/ratio/ratioFromParts.d.ts +10 -0
  26. package/lib/exercises/math/calcul/ratio/ratioFromParts.d.ts.map +1 -0
  27. package/lib/exercises/math/calcul/ratio/ratioFromParts.js +198 -0
  28. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.d.ts.map +1 -1
  29. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.js +50 -0
  30. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +1 -1
  31. package/lib/exercises/math/index.d.ts +1 -0
  32. package/lib/exercises/math/index.d.ts.map +1 -1
  33. package/lib/exercises/math/index.js +1 -0
  34. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +1 -0
  35. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
  36. package/lib/exercises/math/probaStat/basicProbas/index.js +1 -0
  37. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.d.ts +10 -0
  38. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.d.ts.map +1 -0
  39. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.js +113 -0
  40. package/lib/exercises/math/probaStat/index.d.ts +1 -0
  41. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  42. package/lib/exercises/math/probaStat/index.js +1 -0
  43. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts +8 -0
  44. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts.map +1 -0
  45. package/lib/exercises/math/probaStat/stats1var/etendueTable.js +89 -0
  46. package/lib/exercises/math/probaStat/stats1var/index.d.ts +1 -0
  47. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  48. package/lib/exercises/math/probaStat/stats1var/index.js +1 -0
  49. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.d.ts +8 -0
  50. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.d.ts.map +1 -0
  51. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.js +244 -0
  52. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts +3 -0
  53. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts.map +1 -0
  54. package/lib/exercises/math/probaStat/twoStepExperiments/index.js +2 -0
  55. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.d.ts +8 -0
  56. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.d.ts.map +1 -0
  57. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.js +452 -0
  58. package/lib/exercises/math/scratch/index.d.ts +2 -0
  59. package/lib/exercises/math/scratch/index.d.ts.map +1 -0
  60. package/lib/exercises/math/scratch/index.js +1 -0
  61. package/lib/exercises/math/scratch/scratchLoopStepsCount.d.ts +8 -0
  62. package/lib/exercises/math/scratch/scratchLoopStepsCount.d.ts.map +1 -0
  63. package/lib/exercises/math/scratch/scratchLoopStepsCount.js +85 -0
  64. package/lib/exercises/math/scratch/testScratch.d.ts +8 -0
  65. package/lib/exercises/math/scratch/testScratch.d.ts.map +1 -0
  66. package/lib/exercises/math/scratch/testScratch.js +79 -0
  67. package/lib/exercises/math/trigonometry/index.d.ts +3 -0
  68. package/lib/exercises/math/trigonometry/index.d.ts.map +1 -1
  69. package/lib/exercises/math/trigonometry/index.js +3 -0
  70. package/lib/exercises/math/trigonometry/trigonometrySideName.d.ts +13 -0
  71. package/lib/exercises/math/trigonometry/trigonometrySideName.d.ts.map +1 -0
  72. package/lib/exercises/math/trigonometry/trigonometrySideName.js +189 -0
  73. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.d.ts +13 -0
  74. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.d.ts.map +1 -0
  75. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.js +290 -0
  76. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.d.ts +18 -0
  77. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.d.ts.map +1 -0
  78. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.js +386 -0
  79. package/lib/index.d.ts +58 -0
  80. package/lib/index.d.ts.map +1 -1
  81. package/lib/latexTester.d.ts.map +1 -1
  82. package/lib/latexTester.js +5 -0
  83. package/lib/math/geometry/triangles/triangle.d.ts +1 -0
  84. package/lib/math/geometry/triangles/triangle.d.ts.map +1 -1
  85. package/lib/math/geometry/triangles/triangle.js +1 -0
  86. package/lib/math/numbers/fractions/isDecimalFraction.d.ts +3 -0
  87. package/lib/math/numbers/fractions/isDecimalFraction.d.ts.map +1 -0
  88. package/lib/math/numbers/fractions/isDecimalFraction.js +14 -0
  89. package/lib/math/polynomials/polynomial.js +1 -1
  90. package/lib/types/keyIds.d.ts +1 -1
  91. package/lib/types/keyIds.d.ts.map +1 -1
  92. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"addAndSub.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/calcul/addAndSub.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EAgBT,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AAEH,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAgBzC,KAAK,OAAO,GAAG;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AA0FF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
1
+ {"version":3,"file":"addAndSub.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/calcul/addAndSub.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EAkBT,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AAEH,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAgBzC,KAAK,OAAO,GAAG;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAmHF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB5D,CAAC"}
@@ -2,7 +2,7 @@ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuesti
2
2
  import { numberVEA } from "../../../exercises/vea/numberVEA.js";
3
3
  import { randint } from "../../../math/utils/random/randint.js";
4
4
  import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
5
- import { AddNode } from "../../../tree/nodes/operators/addNode.js";
5
+ import { add, AddNode } from "../../../tree/nodes/operators/addNode.js";
6
6
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
7
7
  import { shuffle } from "../../../utils/alea/shuffle.js";
8
8
  import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, tryToAddWrongProp, } from "../../exercise.js";
@@ -66,6 +66,22 @@ const getAddAndSubQuestions = (opts) => {
66
66
  const identifiers = { numbers };
67
67
  return getQuestionFromIdentifiers(identifiers, opts);
68
68
  };
69
+ const getHint = () => {
70
+ return `Fais les calculs de gauche à droite, en respectant bien les signes.`;
71
+ };
72
+ const getCorrection = (identifiers) => {
73
+ const { numbers } = identifiers;
74
+ return `On effectue les opérations dans l'ordre :
75
+
76
+ ${numbers
77
+ .slice(1)
78
+ .map((n, i) => `$$
79
+ ${add(numbers.slice(0, i + 1).reduce((acc, curr) => acc + curr, 0), n).toSimplificationTex()}
80
+ $$`)
81
+ .join("\n \n")}
82
+
83
+ Le résultat est donc $${getAnswer(identifiers)}$.`;
84
+ };
69
85
  const getQuestionFromIdentifiers = (identifiers, opts) => {
70
86
  const question = {
71
87
  instruction: getInstruction(identifiers, opts),
@@ -74,6 +90,8 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
74
90
  keys: [],
75
91
  answerFormat: "tex",
76
92
  identifiers,
93
+ hint: getHint(identifiers),
94
+ correction: getCorrection(identifiers),
77
95
  };
78
96
  return question;
79
97
  };
@@ -106,4 +124,5 @@ export const addAndSubExercise = {
106
124
  getStartStatement,
107
125
  options,
108
126
  getQuestionFromIdentifiers,
127
+ hasHintAndCorrection: true,
109
128
  };
@@ -14,4 +14,5 @@ export * from "./ordering/index.js";
14
14
  export * from "./decimals/index.js";
15
15
  export * from "./rationals/index.js";
16
16
  export * from "./sign/index.js";
17
+ export * from "./ratio/index.js";
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/calcul/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/calcul/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -15,3 +15,4 @@ export * from "./decimals/index.js";
15
15
  // export * from "./writing";
16
16
  export * from "./rationals/index.js";
17
17
  export * from "./sign/index.js";
18
+ export * from "./ratio/index.js";
@@ -5,4 +5,6 @@ export * from "./mentalPercentage.js";
5
5
  export * from "./mentalAddAndSubNoRelative.js";
6
6
  export * from "./mentalMultiplicationsNoRelative.js";
7
7
  export * from "./mentalProgramSolve.js";
8
+ export * from "./mentalFractionageOfInteger.js";
9
+ export * from "./mentalFractionageOfQuantity.js";
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC"}
@@ -5,3 +5,5 @@ export * from "./mentalPercentage.js";
5
5
  export * from "./mentalAddAndSubNoRelative.js";
6
6
  export * from "./mentalMultiplicationsNoRelative.js";
7
7
  export * from "./mentalProgramSolve.js";
8
+ export * from "./mentalFractionageOfInteger.js";
9
+ export * from "./mentalFractionageOfQuantity.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mentalAddAndSub.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA+FF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
1
+ {"version":3,"file":"mentalAddAndSub.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAyHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
@@ -34,6 +34,25 @@ const getAnswer = (identifiers) => {
34
34
  // [getStartStatement(identifiers), "=", add(numbers[])],
35
35
  // ])}`
36
36
  // }
37
+ // const getHint: GetHint<Identifiers> = () => {
38
+ // return `Fais les calculs de gauche à droite, en respectant bien les signes.`;
39
+ // };
40
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
41
+ // const { numbers } = identifiers;
42
+ // return `On effectue les opérations dans l'ordre :
43
+ // ${numbers
44
+ // .slice(1)
45
+ // .map(
46
+ // (n, i) => `$$
47
+ // ${add(
48
+ // numbers.slice(0, i + 1).reduce((acc, curr) => acc + curr, 0),
49
+ // n,
50
+ // ).toSimplificationTex()}
51
+ // $$`,
52
+ // )
53
+ // .join("\n \n")}
54
+ // Le résultat est donc $${getAnswer(identifiers)}$.`;
55
+ // };
37
56
  const getQuestionFromIdentifiers = (identifiers) => {
38
57
  const question = {
39
58
  instruction: getInstruction(identifiers),
@@ -42,6 +61,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
42
61
  keys: [],
43
62
  answerFormat: "tex",
44
63
  identifiers,
64
+ // hint: getHint(identifiers),
65
+ // correction: getCorrection(identifiers),
45
66
  };
46
67
  return question;
47
68
  };
@@ -91,4 +112,5 @@ export const mentalAddAndSub = {
91
112
  isAnswerValid,
92
113
  subject: "Mathématiques",
93
114
  getQuestionFromIdentifiers,
115
+ // hasHintAndCorrection: true,
94
116
  };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nodeIdsFrac: NodeIdentifiers;
5
+ b: number;
6
+ };
7
+ export declare const mentalFractionageOfInteger: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=mentalFractionageOfInteger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentalFractionageOfInteger.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,eAAe,CAAC;IAC7B,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmLF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAc5D,CAAC"}
@@ -0,0 +1,152 @@
1
+ import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
+ import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { random, randomMany } from "../../../../utils/alea/random.js";
10
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { nodeIdsFrac, b } = identifiers;
13
+ const fractionNode = NodeConstructor.fromIdentifiers(nodeIdsFrac);
14
+ return `Combien valent les $${fractionNode.toTex()}$ de $${b}$ ?`;
15
+ };
16
+ const getAnswerNode = (identifiers) => {
17
+ const { nodeIdsFrac, b } = identifiers;
18
+ const fractionNode = NodeConstructor.fromIdentifiers(nodeIdsFrac);
19
+ return multiply(fractionNode, b).simplify();
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ return getAnswerNode(identifiers).toTex();
23
+ };
24
+ const getHint = (identifiers) => {
25
+ const { b } = identifiers;
26
+ if (b !== 20) {
27
+ return `Voici un exemple : pour calculer les $\\frac{3}{4}$ de $20$, on multiplie $\\frac{3}{4}$ par $20$ :
28
+
29
+ $$
30
+ \\frac{3}{4} \\times 20 = 3 \\times 5 = 15
31
+ $$
32
+
33
+ `;
34
+ }
35
+ else {
36
+ return `Voici un exemple : pour calculer les $\\frac{3}{4}$ de $24$, on multiplie $\\frac{3}{4}$ par $24$ :
37
+
38
+ $$
39
+ \\frac{3}{4} \\times 24 = 3 \\times 6 = 18
40
+ $$
41
+
42
+ `;
43
+ }
44
+ };
45
+ const getCorrection = (identifiers) => {
46
+ const { nodeIdsFrac, b } = identifiers;
47
+ const fractionNode = NodeConstructor.fromIdentifiers(nodeIdsFrac);
48
+ const nodeNum = fractionNode.leftChild;
49
+ const nodeDen = fractionNode.rightChild;
50
+ const node1OverDen = frac(1, nodeDen);
51
+ const nodeBOverDen = frac(b, nodeDen);
52
+ const answerNode = multiply(fractionNode, b).simplify();
53
+ return `Prendre la fraction d'un nombre, c'est multiplier le nombre par cette fraction.
54
+
55
+ ${alignTex([
56
+ [
57
+ `${fractionNode.toTex()} \\times ${b.frenchify()}`,
58
+ "=",
59
+ `${nodeNum.toTex()} \\times ${node1OverDen.toTex()} \\times ${b.frenchify()}`,
60
+ ],
61
+ [``, "=", `${nodeNum.toTex()} \\times ${nodeBOverDen.toTex()}`],
62
+ [``, "=", `${nodeNum.toTex()} \\times ${nodeBOverDen.simplify().toTex()}`],
63
+ [``, "=", `${answerNode.toTex()}`],
64
+ ])}
65
+
66
+ `;
67
+ };
68
+ const getPropositions = (n, { answer, ...identifiers }) => {
69
+ const { nodeIdsFrac, b } = identifiers;
70
+ const propositions = [];
71
+ const fractionNode = NodeConstructor.fromIdentifiers(nodeIdsFrac);
72
+ const nodeNum = fractionNode.leftChild;
73
+ const nodeDen = fractionNode.rightChild;
74
+ const answerNode = multiply(fractionNode, b).simplify();
75
+ addValidProp(propositions, answer);
76
+ //num * b
77
+ tryToAddWrongProp(propositions, multiply(nodeNum, b).simplify().toTex());
78
+ //b / den
79
+ tryToAddWrongProp(propositions, frac(b, nodeDen).simplify().toTex());
80
+ //around answer
81
+ const valueAnswer = answerNode.evaluate();
82
+ //in tables
83
+ const numbersOneToTen = [...Array(10).keys()].map((i) => i + 1);
84
+ const tableNumbersSortedAsc = [
85
+ ...new Set(numbersOneToTen.flatMap((n1) => numbersOneToTen.map((n2) => n1 * n2))),
86
+ ].toSorted((n1, n2) => n1 - n2);
87
+ const tableNumbersCloseToAnswer = tableNumbersSortedAsc.filter((n) => Math.abs(valueAnswer - n) <= 10);
88
+ randomMany(tableNumbersCloseToAnswer, Math.min(5, tableNumbersCloseToAnswer.length)).forEach((n) => {
89
+ tryToAddWrongProp(propositions, n.frenchify());
90
+ });
91
+ //fuzzy
92
+ propWhile(propositions, n, () => {
93
+ tryToAddWrongProp(propositions, Math.max(2, valueAnswer + randint(-5, 5, [0])).frenchify());
94
+ });
95
+ return shuffleProps(propositions, n);
96
+ };
97
+ const isAnswerValid = (studentAns, { answer }) => {
98
+ return rationalVEA(studentAns, answer, {
99
+ allowNonIrreductible: true,
100
+ allowDecimal: true,
101
+ });
102
+ };
103
+ const getMentalFractionageOfInteger = () => {
104
+ const bDefault = 21;
105
+ const fractionNodeDefault = frac(4, 7);
106
+ let b = bDefault;
107
+ let fractionNode = fractionNodeDefault;
108
+ let counter = -1;
109
+ let isValid = false;
110
+ while (!isValid && counter < 100) {
111
+ counter++;
112
+ const bCandidate = randint(2, 11) * randint(2, 11);
113
+ const den = random(dividersOf(bCandidate).filter((n) => n !== 1 && n !== bCandidate));
114
+ const num = randint(2, Math.max(Math.sqrt(120 - bCandidate), 3), [den]);
115
+ const fractionNodeCandidate = frac(num, den).simplify();
116
+ isValid =
117
+ isFractionNode(fractionNodeCandidate) &&
118
+ fractionNodeCandidate.leftChild.evaluate() !== 1;
119
+ if (isValid) {
120
+ b = bCandidate;
121
+ fractionNode = fractionNodeCandidate;
122
+ }
123
+ }
124
+ const identifiers = { b, nodeIdsFrac: fractionNode.toIdentifiers() };
125
+ return getQuestionFromIdentifiers(identifiers);
126
+ };
127
+ const getQuestionFromIdentifiers = (identifiers) => {
128
+ const question = {
129
+ instruction: getInstruction(identifiers),
130
+ hint: getHint(identifiers),
131
+ correction: getCorrection(identifiers),
132
+ answer: getAnswer(identifiers),
133
+ keys: [],
134
+ answerFormat: "tex",
135
+ identifiers,
136
+ };
137
+ return question;
138
+ };
139
+ export const mentalFractionageOfInteger = {
140
+ id: "mentalFractionageOfInteger",
141
+ connector: "=",
142
+ label: "Prendre la fraction d'un nombre entier",
143
+ isSingleStep: true,
144
+ generator: (nb) => getDistinctQuestions(getMentalFractionageOfInteger, nb),
145
+ qcmTimer: 60,
146
+ freeTimer: 60,
147
+ getPropositions,
148
+ isAnswerValid,
149
+ subject: "Mathématiques",
150
+ getQuestionFromIdentifiers,
151
+ hasHintAndCorrection: true,
152
+ };
@@ -0,0 +1,15 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ quantityType: string;
5
+ situationIndex: number;
6
+ nodeIdsFrac: NodeIdentifiers;
7
+ a: number;
8
+ coeff: number;
9
+ };
10
+ type Options = {
11
+ quantityTypes: string[];
12
+ };
13
+ export declare const mentalFractionageOfQuantity: Exercise<Identifiers, Options>;
14
+ export {};
15
+ //# sourceMappingURL=mentalFractionageOfQuantity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentalFractionageOfQuantity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAsgB7C,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,eAAe,CAAC;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA0FF,KAAK,OAAO,GAAG;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAiBF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAetE,CAAC"}