math-exercises 3.0.83 → 3.0.84

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 (79) hide show
  1. package/lib/exercises/exercise.d.ts +7 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.d.ts +9 -0
  4. package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.d.ts.map +1 -0
  5. package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.js +113 -0
  6. package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
  7. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
  9. package/lib/exercises/math/calcul/ordering/framing.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/ordering/framing.js +10 -3
  11. package/lib/exercises/math/functions/basics/index.d.ts +1 -0
  12. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  13. package/lib/exercises/math/functions/basics/index.js +1 -1
  14. package/lib/exercises/math/functions/basics/valueTableCompletion.d.ts +2 -1
  15. package/lib/exercises/math/functions/basics/valueTableCompletion.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/basics/valueTableCompletion.js +104 -31
  17. package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.d.ts +8 -0
  18. package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.d.ts.map +1 -0
  19. package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.js +96 -0
  20. package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.d.ts +10 -0
  21. package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.d.ts.map +1 -0
  22. package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.js +153 -0
  23. package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.d.ts +10 -0
  24. package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.d.ts.map +1 -0
  25. package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.js +130 -0
  26. package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.d.ts +7 -0
  27. package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.d.ts.map +1 -0
  28. package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.js +90 -0
  29. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts +9 -0
  30. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts.map +1 -0
  31. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.js +109 -0
  32. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +8 -0
  33. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -0
  34. package/lib/exercises/math/probaStat/basicProbas/index.js +7 -0
  35. package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.d.ts +8 -0
  36. package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.d.ts.map +1 -0
  37. package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.js +114 -0
  38. package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.d.ts +8 -0
  39. package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.d.ts.map +1 -0
  40. package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.js +139 -0
  41. package/lib/exercises/math/probaStat/events/describeEvent.d.ts +15 -0
  42. package/lib/exercises/math/probaStat/events/describeEvent.d.ts.map +1 -0
  43. package/lib/exercises/math/probaStat/events/describeEvent.js +182 -0
  44. package/lib/exercises/math/probaStat/events/eventNotation.d.ts +15 -0
  45. package/lib/exercises/math/probaStat/events/eventNotation.d.ts.map +1 -0
  46. package/lib/exercises/math/probaStat/events/eventNotation.js +156 -0
  47. package/lib/exercises/math/probaStat/events/index.d.ts +3 -0
  48. package/lib/exercises/math/probaStat/events/index.d.ts.map +1 -0
  49. package/lib/exercises/math/probaStat/events/index.js +2 -0
  50. package/lib/exercises/math/probaStat/index.d.ts +2 -10
  51. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  52. package/lib/exercises/math/probaStat/index.js +2 -10
  53. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  54. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +35 -52
  55. package/lib/exercises/math/probaStat/stats1var/averageLinearity.d.ts +16 -0
  56. package/lib/exercises/math/probaStat/stats1var/averageLinearity.d.ts.map +1 -0
  57. package/lib/exercises/math/probaStat/stats1var/averageLinearity.js +217 -0
  58. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts +8 -0
  59. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -0
  60. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +108 -0
  61. package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.d.ts +9 -0
  62. package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.d.ts.map +1 -0
  63. package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.js +139 -0
  64. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts +9 -0
  65. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts.map +1 -0
  66. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +105 -0
  67. package/lib/exercises/math/probaStat/stats1var/index.d.ts +4 -0
  68. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  69. package/lib/exercises/math/probaStat/stats1var/index.js +4 -0
  70. package/lib/index.d.ts +57 -34
  71. package/lib/index.d.ts.map +1 -1
  72. package/lib/tests/exoTest.d.ts.map +1 -1
  73. package/lib/tests/exoTest.js +9 -2
  74. package/lib/tests/questionTest.d.ts.map +1 -1
  75. package/lib/tests/questionTest.js +21 -2
  76. package/lib/utils/markdown/mdTable.d.ts +1 -1
  77. package/lib/utils/markdown/mdTable.d.ts.map +1 -1
  78. package/lib/utils/markdown/mdTable.js +10 -5
  79. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ type: number;
5
+ };
6
+ export declare const rouletteProbas: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=rouletteProbas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rouletteProbas.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicProbas/rouletteProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAoIF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAkBhD,CAAC"}
@@ -0,0 +1,139 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
6
+ import { random } from "../../../../utils/alea/random.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ const getPropositions = (n, { answer }) => {
9
+ const propositions = [];
10
+ addValidProp(propositions, answer);
11
+ while (propositions.length < n) {
12
+ tryToAddWrongProp(propositions, randint(0, 36) + "");
13
+ }
14
+ return shuffleProps(propositions, n);
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const { a, type } = identifiers;
18
+ switch (type) {
19
+ case 1:
20
+ return frac(Math.floor(36 / a) + 1, 37)
21
+ .simplify()
22
+ .toTex();
23
+ case 2:
24
+ default:
25
+ return frac(36 - a + 1, 37).toTex();
26
+ }
27
+ };
28
+ const getInstruction = (identifiers) => {
29
+ const { a, type } = identifiers;
30
+ const event = type === 1 ? `un multiple de $${a}$` : `un numéro supérieur à $${a}$`;
31
+ return `On lance une bille sur une roulette équilibrée qui comporte tous les numéros de $0$ à $36$.
32
+
33
+ Calculer la probabilité de l'évènement "la bille s'arrête sur ${event}".`;
34
+ };
35
+ const getHint = (identifiers) => {
36
+ const { a, type } = identifiers;
37
+ switch (type) {
38
+ case 1:
39
+ return `N'oublie pas que $0$ est un multiple de $${a}$. De plus, n'oublie pas de compter $0$ dans le total des numéros possibles.`;
40
+ case 2:
41
+ default:
42
+ return `Compte les nombres supérieurs à $${a}$ et inférieurs à $36$. De plus, n'oublie pas de compter $0$ dans le total des numéros possibles.`;
43
+ }
44
+ };
45
+ const getCorrection = (identifiers) => {
46
+ const { a, type } = identifiers;
47
+ switch (type) {
48
+ case 1:
49
+ const multiples = [];
50
+ for (let i = 0; i < 36; i++) {
51
+ if (i % a === 0)
52
+ multiples.push(i);
53
+ }
54
+ return `Voici la liste des multiples de $${a}$ de $0$ à $36$ :
55
+
56
+ $$
57
+ ${multiples.join(" ; ")}
58
+ $$
59
+
60
+ Il y en a donc $${multiples.length}$. Puisqu'il y a $37$ numéros possibles, et que la roulette est bien équilibrée, la probabilité recherchée est donc :
61
+
62
+ $$
63
+ ${getAnswer(identifiers)}
64
+ $$
65
+ `;
66
+ case 2:
67
+ default:
68
+ return `Il y a $${36 - a + 1}$ numéros supérieurs à $${a}$ et inférieurs à $36$.
69
+
70
+ Puisqu'il y a $37$ numéros possibles, et que la roulette est bien équilibrée, la probabilité recherchée est donc :
71
+
72
+ $$
73
+ ${getAnswer(identifiers)}
74
+ $$`;
75
+ }
76
+ };
77
+ const getKeys = (identifiers) => {
78
+ return [];
79
+ };
80
+ const isAnswerValid = (ans, { answer }) => {
81
+ try {
82
+ return rationalVEA(ans, answer, {
83
+ allowDecimal: true,
84
+ allowNonIrreductible: true,
85
+ decimalPrecision: 1,
86
+ });
87
+ }
88
+ catch (err) {
89
+ return handleVEAError(err);
90
+ }
91
+ };
92
+ const getRouletteProbasQuestion = (ops) => {
93
+ const type = randint(1, 4);
94
+ let a;
95
+ switch (type) {
96
+ case 1: //multiple
97
+ a = random([3, 5, 10]);
98
+ break;
99
+ case 2: //sup à
100
+ default:
101
+ a = randint(5, 30);
102
+ break;
103
+ break;
104
+ }
105
+ const identifiers = {
106
+ type,
107
+ a,
108
+ };
109
+ return getQuestionFromIdentifiers(identifiers);
110
+ };
111
+ const getQuestionFromIdentifiers = (identifiers) => {
112
+ return {
113
+ answer: getAnswer(identifiers),
114
+ instruction: getInstruction(identifiers),
115
+ keys: getKeys(identifiers),
116
+ answerFormat: "tex",
117
+ identifiers,
118
+ hint: getHint(identifiers),
119
+ correction: getCorrection(identifiers),
120
+ };
121
+ };
122
+ export const rouletteProbas = {
123
+ id: "rouletteProbas",
124
+ connector: "=",
125
+ label: "Calcul de probabilités sur une roulette",
126
+ isSingleStep: true,
127
+ generator: (nb, opts) => getDistinctQuestions(() => getRouletteProbasQuestion(opts), nb),
128
+ qcmTimer: 60,
129
+ freeTimer: 60,
130
+ getPropositions,
131
+ isAnswerValid,
132
+ subject: "Mathématiques",
133
+ getInstruction,
134
+ getHint,
135
+ getCorrection,
136
+ getAnswer,
137
+ getQuestionFromIdentifiers,
138
+ hasHintAndCorrection: true,
139
+ };
@@ -0,0 +1,15 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ eventA: {
4
+ desc: string;
5
+ isComplementary: boolean;
6
+ };
7
+ eventB: {
8
+ desc: string;
9
+ isComplementary: boolean;
10
+ };
11
+ question: "union" | "intersection" | "comp";
12
+ };
13
+ export declare const describeEvent: Exercise<Identifiers>;
14
+ export {};
15
+ //# sourceMappingURL=describeEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describeEvent.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/events/describeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,QAAQ,EAAE,OAAO,GAAG,cAAc,GAAG,MAAM,CAAC;CAC7C,CAAC;AA0LF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAkB/C,CAAC"}
@@ -0,0 +1,182 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
4
+ import { random } from "../../../../utils/alea/random.js";
5
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer, eventA, eventB, question }) => {
7
+ const propositions = [];
8
+ addValidProp(propositions, answer, "raw");
9
+ const flipComplement = (event) => ({
10
+ desc: event.desc,
11
+ isComplementary: !event.isComplementary,
12
+ });
13
+ const generateWrongAnswer = () => {
14
+ const templates = [
15
+ () => {
16
+ const descA = flipComplement(eventA).isComplementary
17
+ ? `ne pas ${eventA.desc}`
18
+ : eventA.desc;
19
+ const descB = eventB.isComplementary
20
+ ? `ne pas ${eventB.desc}`
21
+ : eventB.desc;
22
+ return `${descA} et ${descB}`;
23
+ },
24
+ () => {
25
+ const descA = eventA.isComplementary
26
+ ? `ne pas ${eventA.desc}`
27
+ : eventA.desc;
28
+ const descB = flipComplement(eventB).isComplementary
29
+ ? `ne pas ${eventB.desc}`
30
+ : eventB.desc;
31
+ return `${descA} ou ${descB}`;
32
+ },
33
+ () => {
34
+ const descA = flipComplement(eventA).isComplementary
35
+ ? `ne pas ${eventA.desc}`
36
+ : eventA.desc;
37
+ const descB = flipComplement(eventB).isComplementary
38
+ ? `ne pas ${eventB.desc}`
39
+ : eventB.desc;
40
+ const op = coinFlip() ? "et" : "ou";
41
+ return `${descA} ${op} ${descB}`;
42
+ },
43
+ () => {
44
+ const descA1 = eventA.isComplementary
45
+ ? `ne pas ${eventA.desc}`
46
+ : eventA.desc;
47
+ const descA2 = flipComplement(eventA).isComplementary
48
+ ? `ne pas ${eventA.desc}`
49
+ : eventA.desc;
50
+ const op = coinFlip() ? "et" : "ou";
51
+ return `${descA1} ${op} ${descA2}`;
52
+ },
53
+ () => {
54
+ return `ne pas ne pas ${eventA.desc}`.replace("ne pas ne pas", eventA.desc);
55
+ },
56
+ ];
57
+ return random(templates)();
58
+ };
59
+ while (propositions.length < n) {
60
+ const wrong = generateWrongAnswer();
61
+ tryToAddWrongProp(propositions, wrong, "raw");
62
+ }
63
+ return shuffleProps(propositions, n);
64
+ };
65
+ const getAnswer = ({ eventA, eventB, question }) => {
66
+ const describe = (e) => e.isComplementary ? `ne pas ${e.desc}` : `${e.desc}`;
67
+ if (question === "comp") {
68
+ return `ne pas ${eventA.desc}`;
69
+ }
70
+ else if (question === "union") {
71
+ return `${describe(eventA)} ou ${describe(eventB)}`;
72
+ }
73
+ else {
74
+ return `${describe(eventA)} et ${describe(eventB)}`;
75
+ }
76
+ };
77
+ const getInstruction = (identifiers) => {
78
+ const { eventA, eventB, question } = identifiers;
79
+ let instruction = `$A$ est l'évènement "${eventA.desc}" et $B$ est l'évènement "${eventB.desc}".\n\n`;
80
+ if (question === "comp") {
81
+ return instruction + `Décrire par une phrase l'évènement $\\overline{A}$.`;
82
+ }
83
+ const overlineA = eventA.isComplementary ? "\\overline{A}" : "A";
84
+ const overlineB = eventB.isComplementary ? "\\overline{B}" : "B";
85
+ const operator = question === "union" ? "\\cup" : "\\cap";
86
+ return (instruction +
87
+ `Décrire par une phrase l'évènement $${overlineA} ${operator} ${overlineB}$.`);
88
+ };
89
+ const getHint = ({ question }) => {
90
+ switch (question) {
91
+ case "comp":
92
+ return `Le contraire ($\\overline{A})$ d'un évènement $A$ signifie que l'évènement ne se réalise pas.`;
93
+ case "union":
94
+ return `L'union ($\\cup$) de deux événements signifie que l'un ou l'autre des évènements (ou les deux) se réalisent.`;
95
+ case "intersection":
96
+ return `L'intersection ($\\cap$) de deux événements signifie que les deux évènements se réalisent en même temps.`;
97
+ default:
98
+ return "";
99
+ }
100
+ };
101
+ const getCorrection = (identifiers) => {
102
+ const { eventA, eventB, question } = identifiers;
103
+ const answer = getAnswer(identifiers);
104
+ if (question === "comp") {
105
+ return `Le contraire de l'évènement "${eventA.desc}" est l'évènement "${answer}".`;
106
+ }
107
+ else if (question === "union") {
108
+ return `L'union signifie que l'un ou l'autre (ou les deux) évènement(s) se produit : "${answer}".`;
109
+ }
110
+ else {
111
+ return `L'intersection signifie que les deux évènements se produisent en même temps : "${answer}".`;
112
+ }
113
+ };
114
+ const getKeys = (identifiers) => {
115
+ return [];
116
+ };
117
+ const isAnswerValid = (ans, { answer }) => {
118
+ try {
119
+ throw Error("VEA not implemented");
120
+ }
121
+ catch (err) {
122
+ return handleVEAError(err);
123
+ }
124
+ };
125
+ const getDescribeEventQuestion = (ops) => {
126
+ const allEvents = [
127
+ "trouver des mures",
128
+ "trouver des fraises",
129
+ "trouver des pommes",
130
+ "perdre son parapluie",
131
+ "rater le bus",
132
+ "avoir un bonbon",
133
+ "avoir un bonbon au chocolat",
134
+ "avoir un bonbon à la menthe",
135
+ "avoir un bonbon à la fraise",
136
+ ];
137
+ const eventA = {
138
+ desc: random(allEvents),
139
+ isComplementary: coinFlip(),
140
+ };
141
+ const eventB = {
142
+ desc: random(allEvents.filter((e) => e !== eventA.desc)),
143
+ isComplementary: coinFlip(),
144
+ };
145
+ const questionTypes = [
146
+ "union",
147
+ "intersection",
148
+ "comp",
149
+ ];
150
+ const question = random(questionTypes);
151
+ const identifiers = { eventA, eventB, question };
152
+ return getQuestionFromIdentifiers(identifiers);
153
+ };
154
+ const getQuestionFromIdentifiers = (identifiers) => {
155
+ return {
156
+ answer: getAnswer(identifiers),
157
+ instruction: getInstruction(identifiers),
158
+ keys: getKeys(identifiers),
159
+ answerFormat: "raw",
160
+ identifiers,
161
+ hint: getHint(identifiers),
162
+ correction: getCorrection(identifiers),
163
+ };
164
+ };
165
+ export const describeEvent = {
166
+ id: "describeEvent",
167
+ label: "Décrire un évènement en une phrase à partir de sa notation",
168
+ isSingleStep: true,
169
+ generator: (nb, opts) => getDistinctQuestions(() => getDescribeEventQuestion(opts), nb),
170
+ qcmTimer: 60,
171
+ freeTimer: 60,
172
+ getPropositions,
173
+ isAnswerValid,
174
+ subject: "Mathématiques",
175
+ getInstruction,
176
+ getHint,
177
+ getCorrection,
178
+ getAnswer,
179
+ getQuestionFromIdentifiers,
180
+ hasHintAndCorrection: true,
181
+ answerType: "QCU",
182
+ };
@@ -0,0 +1,15 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ eventA: {
4
+ desc: string;
5
+ isComplementary: boolean;
6
+ };
7
+ eventB: {
8
+ desc: string;
9
+ isComplementary: boolean;
10
+ };
11
+ question: "union" | "intersection" | "comp";
12
+ };
13
+ export declare const eventNotation: Exercise<Identifiers>;
14
+ export {};
15
+ //# sourceMappingURL=eventNotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventNotation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/events/eventNotation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,QAAQ,EAAE,OAAO,GAAG,cAAc,GAAG,MAAM,CAAC;CAC7C,CAAC;AA4JF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAkB/C,CAAC"}
@@ -0,0 +1,156 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
4
+ import { random } from "../../../../utils/alea/random.js";
5
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer, eventA, eventB, question }) => {
7
+ const propositions = [];
8
+ addValidProp(propositions, answer);
9
+ const events = [
10
+ "\\overline{A}",
11
+ "\\overline{B}",
12
+ "A\\cup B",
13
+ "A\\cap B",
14
+ "A\\cap \\overline{B}",
15
+ "A\\cup \\overline{B}",
16
+ "\\overline{A}\\cap B",
17
+ "\\overline{A}\\cup B",
18
+ "\\overline{A}\\cap \\overline{B}",
19
+ "\\overline{A}\\cup \\overline{B}",
20
+ ];
21
+ while (propositions.length < n) {
22
+ tryToAddWrongProp(propositions, random(events));
23
+ }
24
+ return shuffleProps(propositions, n);
25
+ };
26
+ const getAnswer = ({ eventA, eventB, question }) => {
27
+ const describe = (letter, isComplementary) => isComplementary ? `\\overline{${letter}}` : `${letter}`;
28
+ if (question === "comp") {
29
+ return `\\overline{A}`;
30
+ }
31
+ else if (question === "union") {
32
+ return `${describe("A", eventA.isComplementary)}\\cup ${describe("B", eventB.isComplementary)}`;
33
+ }
34
+ else {
35
+ return `${describe("A", eventA.isComplementary)}\\cap ${describe("B", eventB.isComplementary)}`;
36
+ }
37
+ };
38
+ const getInstruction = (identifiers) => {
39
+ const { eventA, eventB, question } = identifiers;
40
+ const describe = (e) => e.isComplementary ? `ne pas ${e.desc}` : `${e.desc}`;
41
+ let sentence = "";
42
+ if (question === "comp") {
43
+ sentence = `ne pas ${eventA.desc}`;
44
+ }
45
+ else if (question === "union") {
46
+ sentence = `${describe(eventA)} ou ${describe(eventB)}`;
47
+ }
48
+ else {
49
+ sentence = `${describe(eventA)} et ${describe(eventB)}`;
50
+ }
51
+ let instruction = `$A$ est l'évènement "${eventA.desc}" et $B$ est l'évènement "${eventB.desc}".\n\n`;
52
+ return instruction + `Comment se note l'événement "${sentence}" ?`;
53
+ };
54
+ const getHint = ({ question }) => {
55
+ switch (question) {
56
+ case "comp":
57
+ return `Le contraire ($\\overline{A})$ d'un évènement $A$ signifie que l'évènement ne se réalise pas.`;
58
+ case "union":
59
+ return `L'union ($\\cup$) de deux événements signifie que l'un ou l'autre des évènements (ou les deux) se réalisent.`;
60
+ case "intersection":
61
+ return `L'intersection ($\\cap$) de deux événements signifie que les deux évènements se réalisent en même temps.`;
62
+ default:
63
+ return "";
64
+ }
65
+ };
66
+ const getCorrection = (identifiers) => {
67
+ const { eventA, eventB, question } = identifiers;
68
+ const answer = getAnswer(identifiers);
69
+ if (question === "comp") {
70
+ return `Le contraire de l'évènement "${eventA.desc}" est l'évènement $${answer}$.`;
71
+ }
72
+ else if (question === "union") {
73
+ return `L'union signifie que l'un ou l'autre (ou les deux) évènement(s) se produit. Ici, l'évènement se note donc :
74
+
75
+ $$
76
+ ${answer}
77
+ $$`;
78
+ }
79
+ else {
80
+ return `L'intersection signifie que les deux évènements se produisent en même temps. Ici, l'évènement se note donc :
81
+
82
+
83
+ $$
84
+ ${answer}
85
+ $$`;
86
+ }
87
+ };
88
+ const getKeys = (identifiers) => {
89
+ return [];
90
+ };
91
+ const isAnswerValid = (ans, { answer }) => {
92
+ try {
93
+ throw Error("VEA not implemented");
94
+ }
95
+ catch (err) {
96
+ return handleVEAError(err);
97
+ }
98
+ };
99
+ const getEventNotationQuestion = (ops) => {
100
+ const allEvents = [
101
+ "trouver des mures",
102
+ "trouver des fraises",
103
+ "trouver des pommes",
104
+ "perdre son parapluie",
105
+ "rater le bus",
106
+ "avoir un bonbon",
107
+ "avoir un bonbon au chocolat",
108
+ "avoir un bonbon à la menthe",
109
+ "avoir un bonbon à la fraise",
110
+ ];
111
+ const eventA = {
112
+ desc: random(allEvents),
113
+ isComplementary: coinFlip(),
114
+ };
115
+ const eventB = {
116
+ desc: random(allEvents.filter((e) => e !== eventA.desc)),
117
+ isComplementary: coinFlip(),
118
+ };
119
+ const questionTypes = [
120
+ "union",
121
+ "intersection",
122
+ "comp",
123
+ ];
124
+ const question = random(questionTypes);
125
+ const identifiers = { eventA, eventB, question };
126
+ return getQuestionFromIdentifiers(identifiers);
127
+ };
128
+ const getQuestionFromIdentifiers = (identifiers) => {
129
+ return {
130
+ answer: getAnswer(identifiers),
131
+ instruction: getInstruction(identifiers),
132
+ keys: getKeys(identifiers),
133
+ answerFormat: "tex",
134
+ identifiers,
135
+ hint: getHint(identifiers),
136
+ correction: getCorrection(identifiers),
137
+ };
138
+ };
139
+ export const eventNotation = {
140
+ id: "eventNotation",
141
+ label: "Donner la notation d'un évènement à partir d'une phrase",
142
+ isSingleStep: true,
143
+ generator: (nb, opts) => getDistinctQuestions(() => getEventNotationQuestion(opts), nb),
144
+ qcmTimer: 60,
145
+ freeTimer: 60,
146
+ getPropositions,
147
+ isAnswerValid,
148
+ subject: "Mathématiques",
149
+ getInstruction,
150
+ getHint,
151
+ getCorrection,
152
+ getAnswer,
153
+ getQuestionFromIdentifiers,
154
+ hasHintAndCorrection: true,
155
+ answerType: "QCU",
156
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./describeEvent.js";
2
+ export * from "./eventNotation.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./describeEvent.js";
2
+ export * from "./eventNotation.js";
@@ -1,8 +1,4 @@
1
- export * from "./averageLinearity.js";
2
- export * from "./ballsBasicProbas.js";
3
- export * from "./cardBasicProbas.js";
4
1
  export * from "./conditionalProbability.js";
5
- export * from "./diceBasicProbas.js";
6
2
  export * from "./probabilityTree.js";
7
3
  export * from "./stats1var/index.js";
8
4
  export * from "./stats2var/index.js";
@@ -13,13 +9,9 @@ export * from "./probaFromTableWithContext.js";
13
9
  export * from "./binomial/index.js";
14
10
  export * from "./basicStats/index.js";
15
11
  export * from "./randomVariable/index.js";
16
- export * from "./getMissingProbabilityValue.js";
17
- export * from "./getComplementaryProbability.js";
18
12
  export * from "./unionIntersectionProba.js";
19
- export * from "./calculateMeanFromFrequencies.js";
20
- export * from "./mostLeastProbable.js";
21
13
  export * from "./checkEquiprobability.js";
22
14
  export * from "./getSampleCountAndSize.js";
23
- export * from "./describeEvent.js";
24
- export * from "./cumulativeSum.js";
15
+ export * from "./events/index.js";
16
+ export * from "./basicProbas/index.js";
25
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
@@ -1,8 +1,4 @@
1
- export * from "./averageLinearity.js";
2
- export * from "./ballsBasicProbas.js";
3
- export * from "./cardBasicProbas.js";
4
1
  export * from "./conditionalProbability.js";
5
- export * from "./diceBasicProbas.js";
6
2
  export * from "./probabilityTree.js";
7
3
  export * from "./stats1var/index.js";
8
4
  export * from "./stats2var/index.js";
@@ -13,12 +9,8 @@ export * from "./probaFromTableWithContext.js";
13
9
  export * from "./binomial/index.js";
14
10
  export * from "./basicStats/index.js";
15
11
  export * from "./randomVariable/index.js";
16
- export * from "./getMissingProbabilityValue.js";
17
- export * from "./getComplementaryProbability.js";
18
12
  export * from "./unionIntersectionProba.js";
19
- export * from "./calculateMeanFromFrequencies.js";
20
- export * from "./mostLeastProbable.js";
21
13
  export * from "./checkEquiprobability.js";
22
14
  export * from "./getSampleCountAndSize.js";
23
- export * from "./describeEvent.js";
24
- export * from "./cumulativeSum.js";
15
+ export * from "./events/index.js";
16
+ export * from "./basicProbas/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA6JF,KAAK,OAAO,GAAG,EAEd,CAAC;AA2JF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBpE,CAAC"}
1
+ {"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA6JF,KAAK,OAAO,GAAG,EAEd,CAAC;AA6HF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBpE,CAAC"}