math-exercises 3.0.7 → 3.0.9
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.
- package/lib/exercises/math/calcul/fractions/fractionsOperations.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsOperations.js +6 -1
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +4 -4
- package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +4 -0
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +10 -6
- package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +4 -0
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +18 -14
- package/lib/exercises/math/dataRepresentations/barChartReading.js +67 -0
- package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +3 -0
- package/lib/exercises/math/functions/basics/imageFunctionGeogebra.d.ts +2 -1
- package/lib/exercises/math/functions/basics/imageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/imageFunctionGeogebra.js +70 -32
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts +1 -4
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +175 -88
- package/lib/exercises/math/percent/globalPercent.d.ts.map +1 -1
- package/lib/exercises/math/percent/globalPercent.js +4 -0
- package/lib/index.d.ts +3 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +2 -7
- package/lib/server.d.ts +1 -0
- package/lib/server.d.ts.map +1 -1
- package/lib/server.js +16 -0
- package/lib/tree/nodes/nodeConstructor.d.ts +2 -2
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +3 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fractionsOperations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"fractionsOperations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAM7C,KAAK,WAAW,GAAG;IACjB,oBAAoB,EAAE,eAAe,CAAC;CACvC,CAAC;AA4FF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAiBrD,CAAC"}
|
|
@@ -17,7 +17,8 @@ const getPropositions = (n, { answer }) => {
|
|
|
17
17
|
return shuffleProps(propositions, n);
|
|
18
18
|
};
|
|
19
19
|
const getAnswer = (identifiers) => {
|
|
20
|
-
|
|
20
|
+
console.log("ans", identifiers);
|
|
21
|
+
const statement = NodeConstructor.fromIdentifiers(identifiers.statementIdentifiers, true);
|
|
21
22
|
return statement.simplify().toTex();
|
|
22
23
|
};
|
|
23
24
|
const getInstruction = (identifiers) => {
|
|
@@ -58,6 +59,9 @@ const getFractionsOperationsQuestion = (ops) => {
|
|
|
58
59
|
const identifiers = {
|
|
59
60
|
statementIdentifiers: ids,
|
|
60
61
|
};
|
|
62
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
63
|
+
};
|
|
64
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
61
65
|
const question = {
|
|
62
66
|
answer: getAnswer(identifiers),
|
|
63
67
|
instruction: getInstruction(identifiers),
|
|
@@ -84,4 +88,5 @@ export const fractionsOperations = {
|
|
|
84
88
|
// getHint,
|
|
85
89
|
// getCorrection,
|
|
86
90
|
getAnswer,
|
|
91
|
+
getQuestionFromIdentifiers,
|
|
87
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choseOperationToSolveEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"choseOperationToSolveEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAuJF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}
|
|
@@ -130,14 +130,15 @@ const getChoseOperationToSolveEquationQuestion = (opts) => {
|
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
132
|
const identifiers = { type, a, b, c };
|
|
133
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
134
|
+
};
|
|
135
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
133
136
|
const question = {
|
|
134
137
|
answer: getAnswer(identifiers),
|
|
135
138
|
instruction: getInstruction(identifiers),
|
|
136
139
|
keys: getKeys(identifiers),
|
|
137
140
|
answerFormat: "tex",
|
|
138
141
|
identifiers,
|
|
139
|
-
// hint: getHint(identifiers),
|
|
140
|
-
// correction: getCorrection(identifiers),
|
|
141
142
|
};
|
|
142
143
|
return question;
|
|
143
144
|
};
|
|
@@ -153,8 +154,7 @@ export const choseOperationToSolveEquation = {
|
|
|
153
154
|
isAnswerValid,
|
|
154
155
|
subject: "Mathématiques",
|
|
155
156
|
getInstruction,
|
|
156
|
-
// getHint,
|
|
157
|
-
// getCorrection,
|
|
158
157
|
getAnswer,
|
|
159
158
|
answerType: "QCU",
|
|
159
|
+
getQuestionFromIdentifiers,
|
|
160
160
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equationType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"equationType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAqBvD,CAAC"}
|
|
@@ -58,6 +58,9 @@ const getEquationType1ExerciseQuestion = () => {
|
|
|
58
58
|
const b = randint(-10, 11);
|
|
59
59
|
const a = randint(-10, 11, [0]);
|
|
60
60
|
const identifiers = { a, b };
|
|
61
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
62
|
+
};
|
|
63
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
61
64
|
const question = {
|
|
62
65
|
instruction: getInstruction(identifiers),
|
|
63
66
|
startStatement: getStartStatement(identifiers),
|
|
@@ -104,4 +107,5 @@ export const equationType1Exercise = {
|
|
|
104
107
|
getInstruction,
|
|
105
108
|
getAnswer,
|
|
106
109
|
getStartStatement,
|
|
110
|
+
getQuestionFromIdentifiers,
|
|
107
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equationType2Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType2Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"equationType2Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType2Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAsBrC,OAAO,EAEL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAM7C;;GAEG;AAGH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA0JF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAaF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAuBhE,CAAC"}
|
|
@@ -94,15 +94,18 @@ const getEquationType2ExerciseQuestion = (opts) => {
|
|
|
94
94
|
isXRight,
|
|
95
95
|
aNumberType: type,
|
|
96
96
|
};
|
|
97
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
98
|
+
};
|
|
99
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
97
100
|
const question = {
|
|
98
|
-
instruction: getInstruction(identifiers),
|
|
99
|
-
startStatement: getStartStatement(identifiers),
|
|
100
|
-
answer: getAnswer(identifiers),
|
|
101
|
+
instruction: getInstruction(identifiers, opts),
|
|
102
|
+
startStatement: getStartStatement(identifiers, opts),
|
|
103
|
+
answer: getAnswer(identifiers, opts),
|
|
101
104
|
keys: equationKeys,
|
|
102
105
|
answerFormat: "tex",
|
|
103
106
|
identifiers,
|
|
104
|
-
hint: getHint(identifiers),
|
|
105
|
-
correction: getCorrection(identifiers),
|
|
107
|
+
hint: getHint(identifiers, opts),
|
|
108
|
+
correction: getCorrection(identifiers, opts),
|
|
106
109
|
};
|
|
107
110
|
return question;
|
|
108
111
|
};
|
|
@@ -129,7 +132,7 @@ const isAnswerValid = (ans, { a, b }) => {
|
|
|
129
132
|
const options = [
|
|
130
133
|
{
|
|
131
134
|
id: "aNumberType",
|
|
132
|
-
label: "
|
|
135
|
+
label: "Type du coefficient $a$",
|
|
133
136
|
target: GeneratorOptionTarget.generation,
|
|
134
137
|
type: GeneratorOptionType.multiselect,
|
|
135
138
|
defaultValue: ["Entier"],
|
|
@@ -157,4 +160,5 @@ export const equationType2Exercise = {
|
|
|
157
160
|
getAnswer,
|
|
158
161
|
getStartStatement,
|
|
159
162
|
rebuildIdentifiers,
|
|
163
|
+
getQuestionFromIdentifiers,
|
|
160
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equationType3Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType3Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"equationType3Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType3Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAerC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAsBvD,CAAC"}
|
|
@@ -60,6 +60,9 @@ const getEquationType3ExerciseQuestion = () => {
|
|
|
60
60
|
const a = randint(-10, 11, [0, 1]);
|
|
61
61
|
const c = randint(-10, 11);
|
|
62
62
|
const identifiers = { a, b, c };
|
|
63
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
64
|
+
};
|
|
65
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
63
66
|
const question = {
|
|
64
67
|
instruction: getInstruction(identifiers),
|
|
65
68
|
hint: getHint(identifiers),
|
|
@@ -106,4 +109,5 @@ export const equationType3Exercise = {
|
|
|
106
109
|
getCorrection,
|
|
107
110
|
getHint,
|
|
108
111
|
getStartStatement,
|
|
112
|
+
getQuestionFromIdentifiers,
|
|
109
113
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equationType4Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType4Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"equationType4Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationType4Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAerC;;GAEG;AAEH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAiBvD,CAAC"}
|
|
@@ -43,6 +43,9 @@ const getEquationType4ExerciseQuestion = () => {
|
|
|
43
43
|
c,
|
|
44
44
|
d,
|
|
45
45
|
};
|
|
46
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
47
|
+
};
|
|
48
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
46
49
|
const question = {
|
|
47
50
|
instruction: getInstruction(identifiers),
|
|
48
51
|
startStatement: getStartStatement(identifiers),
|
|
@@ -50,23 +53,23 @@ const getEquationType4ExerciseQuestion = () => {
|
|
|
50
53
|
keys: equationKeys,
|
|
51
54
|
answerFormat: "tex",
|
|
52
55
|
identifiers,
|
|
53
|
-
// hint: `Commence par regrouper les termes en $x$ d'un même côté de l'équation. Puis, isole $x$ en effectuant les bonnes opérations.`,
|
|
54
|
-
// correction: `On isole $x$ à gauche en soustrayant par $${b}$ puis en divisant par $${a}$ :
|
|
55
|
-
// ${alignTex([
|
|
56
|
-
// [
|
|
57
|
-
// statementTex,
|
|
58
|
-
// "\\iff",
|
|
59
|
-
// new EqualNode(
|
|
60
|
-
// new Affine(a, 0).toTree(),
|
|
61
|
-
// affines[1].add(-b).toTree(),
|
|
62
|
-
// ).toTex(),
|
|
63
|
-
// ],
|
|
64
|
-
// ["", "\\iff", answer],
|
|
65
|
-
// ])}
|
|
66
|
-
// `,
|
|
67
56
|
};
|
|
68
57
|
return question;
|
|
69
58
|
};
|
|
59
|
+
// hint: `Commence par regrouper les termes en $x$ d'un même côté de l'équation. Puis, isole $x$ en effectuant les bonnes opérations.`,
|
|
60
|
+
// correction: `On isole $x$ à gauche en soustrayant par $${b}$ puis en divisant par $${a}$ :
|
|
61
|
+
// ${alignTex([
|
|
62
|
+
// [
|
|
63
|
+
// statementTex,
|
|
64
|
+
// "\\iff",
|
|
65
|
+
// new EqualNode(
|
|
66
|
+
// new Affine(a, 0).toTree(),
|
|
67
|
+
// affines[1].add(-b).toTree(),
|
|
68
|
+
// ).toTex(),
|
|
69
|
+
// ],
|
|
70
|
+
// ["", "\\iff", answer],
|
|
71
|
+
// ])}
|
|
72
|
+
// `,
|
|
70
73
|
const getPropositions = (n, { answer, a, b, c, d }) => {
|
|
71
74
|
const propositions = [];
|
|
72
75
|
addValidProp(propositions, answer);
|
|
@@ -97,4 +100,5 @@ export const equationType4Exercise = {
|
|
|
97
100
|
subject: "Mathématiques",
|
|
98
101
|
getInstruction,
|
|
99
102
|
getAnswer,
|
|
103
|
+
getQuestionFromIdentifiers,
|
|
100
104
|
};
|
|
@@ -130,3 +130,70 @@ export const barChartReading = {
|
|
|
130
130
|
getCorrection,
|
|
131
131
|
getAnswer,
|
|
132
132
|
};
|
|
133
|
+
// !signtable
|
|
134
|
+
// const options = { svg: true };
|
|
135
|
+
// const d3n = new D3Node(options);
|
|
136
|
+
// const d3 = d3n.d3;
|
|
137
|
+
// const width = 600;
|
|
138
|
+
// const height = 250;
|
|
139
|
+
// const svg = d3n.createSVG(width, height);
|
|
140
|
+
// // Define table structure
|
|
141
|
+
// const rows = 3;
|
|
142
|
+
// const cols = 5;
|
|
143
|
+
// const cellWidth = 120;
|
|
144
|
+
// const cellHeight = 50;
|
|
145
|
+
// const startX = 50;
|
|
146
|
+
// const startY = 50;
|
|
147
|
+
// // Define table values
|
|
148
|
+
// const headers = ["x", "-\\infty", "-2", "0", "+\\infty"];
|
|
149
|
+
// const firstRow = ["f'(x)", "+", "0", "-", ""];
|
|
150
|
+
// const secondRow = ["f(x)", "\\nearrow", "max", "\\searrow", ""];
|
|
151
|
+
// // Draw table grid
|
|
152
|
+
// for (let r = 0; r < rows; r++) {
|
|
153
|
+
// for (let c = 0; c < cols; c++) {
|
|
154
|
+
// svg
|
|
155
|
+
// .append("rect")
|
|
156
|
+
// .attr("x", startX + c * cellWidth)
|
|
157
|
+
// .attr("y", startY + r * cellHeight)
|
|
158
|
+
// .attr("width", cellWidth)
|
|
159
|
+
// .attr("height", cellHeight)
|
|
160
|
+
// .attr("stroke", "black")
|
|
161
|
+
// .attr("fill", "black");
|
|
162
|
+
// }
|
|
163
|
+
// }
|
|
164
|
+
// // Function to render LaTeX with KaTeX
|
|
165
|
+
// const renderLatex = (formula: any) =>
|
|
166
|
+
// katex.renderToString(formula, { throwOnError: false });
|
|
167
|
+
// // Add LaTeX text using <foreignObject> for proper positioning
|
|
168
|
+
// const addLatexText = (x: any, y: any, latex: any) => {
|
|
169
|
+
// svg
|
|
170
|
+
// .append("foreignObject")
|
|
171
|
+
// .attr("x", x - cellWidth / 2)
|
|
172
|
+
// .attr("y", y - cellHeight / 2)
|
|
173
|
+
// .attr("width", cellWidth)
|
|
174
|
+
// .attr("height", cellHeight)
|
|
175
|
+
// .html(`<div xmlns="http://www.w3.org/1999/xhtml"
|
|
176
|
+
// style="display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;">
|
|
177
|
+
// ${renderLatex(latex)}
|
|
178
|
+
// </div>`);
|
|
179
|
+
// };
|
|
180
|
+
// // Insert header row
|
|
181
|
+
// headers.forEach((text, i) =>
|
|
182
|
+
// addLatexText(startX + i * cellWidth + cellWidth / 2, startY + 25, text),
|
|
183
|
+
// );
|
|
184
|
+
// // Insert first row (derivative sign changes)
|
|
185
|
+
// firstRow.forEach((text, i) =>
|
|
186
|
+
// addLatexText(
|
|
187
|
+
// startX + i * cellWidth + cellWidth / 2,
|
|
188
|
+
// startY + cellHeight + 25,
|
|
189
|
+
// text,
|
|
190
|
+
// ),
|
|
191
|
+
// );
|
|
192
|
+
// // Insert second row (function increasing/decreasing)
|
|
193
|
+
// secondRow.forEach((text, i) =>
|
|
194
|
+
// addLatexText(
|
|
195
|
+
// startX + i * cellWidth + cellWidth / 2,
|
|
196
|
+
// startY + 2 * cellHeight + 25,
|
|
197
|
+
// text,
|
|
198
|
+
// ),
|
|
199
|
+
// );
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAgIF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAgIF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAmB/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"imageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAsBrC,KAAK,WAAW,GAAG;IACjB,cAAc;IAMd,UAAU;IAMV,UAAU;IACV,YAAY,EAAE,MAAM,CAAC;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAgRF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmBhE,CAAC"}
|
|
@@ -49,19 +49,33 @@ const rebuildIdentifiers = (oldIds) => {
|
|
|
49
49
|
else
|
|
50
50
|
return oldIds;
|
|
51
51
|
};
|
|
52
|
-
const getInstruction = (identifiers) => {
|
|
52
|
+
const getInstruction = (identifiers, opts) => {
|
|
53
53
|
const { x } = identifiers;
|
|
54
|
-
|
|
54
|
+
let instruction = `Quelle est l'image de $${x}$ par la fonction $f$ représentée ci dessous ?`;
|
|
55
|
+
if (opts?.curveTypes?.includes("Avec valeur interdite (pas d'image)")) {
|
|
56
|
+
instruction += `
|
|
57
|
+
|
|
58
|
+
On écrira "aucun" si l'image n'existe pas.`;
|
|
59
|
+
}
|
|
60
|
+
return instruction;
|
|
55
61
|
};
|
|
56
62
|
const getAnswer = (identifiers) => {
|
|
57
63
|
const { y } = identifiers;
|
|
64
|
+
if (y === undefined)
|
|
65
|
+
return "\\text{Aucun}";
|
|
58
66
|
return y.frenchify();
|
|
59
67
|
};
|
|
60
68
|
const getGGBOptions = (identifiers) => {
|
|
61
|
-
const { functionType, otherPoints, wrongY, x, y } = identifiers;
|
|
69
|
+
const { functionType, otherPoints, wrongY, x, y, functionCommand } = identifiers;
|
|
62
70
|
const allPoints = [...otherPoints, [x, y], [wrongY, x]].sort((a, b) => a[0] - b[0]);
|
|
63
71
|
let commands = [];
|
|
64
72
|
switch (functionType) {
|
|
73
|
+
case "Avec valeur interdite (pas d'image)":
|
|
74
|
+
commands = [
|
|
75
|
+
`f(x) = ${functionCommand}`,
|
|
76
|
+
`SetColor(f, "${randomColor()}")`,
|
|
77
|
+
];
|
|
78
|
+
break;
|
|
65
79
|
case "Droites":
|
|
66
80
|
const line = new Line(new Point("A", allPoints[0][0], allPoints[0][1]), new Point("B", allPoints[1][0], allPoints[1][1]));
|
|
67
81
|
commands = line.toGGBCommands(false);
|
|
@@ -104,10 +118,19 @@ const getGGBOptions = (identifiers) => {
|
|
|
104
118
|
// commands: spline.getCommands()
|
|
105
119
|
commands,
|
|
106
120
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
let xMin, xMax, yMin, yMax;
|
|
122
|
+
if (functionType === "Avec valeur interdite (pas d'image)") {
|
|
123
|
+
xMin = x - 3;
|
|
124
|
+
xMax = x + 3;
|
|
125
|
+
yMin = -7;
|
|
126
|
+
yMax = 7;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
xMin = allPoints[0][0];
|
|
130
|
+
xMax = allPoints[allPoints.length - 1][0];
|
|
131
|
+
yMin = Math.min(...allPoints.map((p) => p[1])) - 1;
|
|
132
|
+
yMax = Math.max(...allPoints.map((p) => p[1])) + 1;
|
|
133
|
+
}
|
|
111
134
|
return ggb.getOptions({
|
|
112
135
|
coords: ggb.getAdaptedCoords({
|
|
113
136
|
forceShowAxes: true,
|
|
@@ -122,13 +145,39 @@ const getStartStatement = (identifiers) => {
|
|
|
122
145
|
const { x } = identifiers;
|
|
123
146
|
return `f(${x})`;
|
|
124
147
|
};
|
|
148
|
+
const getKeys = (identifiers, options) => {
|
|
149
|
+
if (options?.curveTypes?.includes("Avec valeur interdite (pas d'image)")) {
|
|
150
|
+
return ["aucun"];
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
157
|
+
const question = {
|
|
158
|
+
instruction: getInstruction(identifiers, opts),
|
|
159
|
+
startStatement: getStartStatement(identifiers, opts),
|
|
160
|
+
answer: getAnswer(identifiers, opts),
|
|
161
|
+
keys: getKeys(identifiers, opts),
|
|
162
|
+
ggbOptions: getGGBOptions(identifiers, opts),
|
|
163
|
+
answerFormat: "tex",
|
|
164
|
+
identifiers,
|
|
165
|
+
};
|
|
166
|
+
return question;
|
|
167
|
+
};
|
|
125
168
|
const getImageFunctionGeogebra = (opts) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
169
|
+
let x = randint(-8, 9);
|
|
170
|
+
let y = randint(-8, 9);
|
|
171
|
+
let wrongY = y + randint(-3, 4, [0, x - y, 10 - y, -10 - y]);
|
|
172
|
+
let functionCommand = undefined;
|
|
129
173
|
const functionType = random(opts?.curveTypes ?? ["Tracés", "Polynômes", "Droites", "Paraboles"]);
|
|
130
174
|
let otherPoints = [];
|
|
131
175
|
switch (functionType) {
|
|
176
|
+
case "Avec valeur interdite (pas d'image)":
|
|
177
|
+
y = undefined;
|
|
178
|
+
const k = randint(2, 6);
|
|
179
|
+
functionCommand = `${k}/(x-${x}) -x`;
|
|
180
|
+
break;
|
|
132
181
|
case "Droites":
|
|
133
182
|
//nothing to add
|
|
134
183
|
break;
|
|
@@ -154,35 +203,17 @@ const getImageFunctionGeogebra = (opts) => {
|
|
|
154
203
|
default:
|
|
155
204
|
break;
|
|
156
205
|
}
|
|
157
|
-
// const spline = new (isSpline ? Spline : Lagrange)(
|
|
158
|
-
// new IntervalNode((-10).toTree(), (10).toTree(), ClosureType.FF),
|
|
159
|
-
// [
|
|
160
|
-
// new Point("A", x.toTree(), y.toTree()),
|
|
161
|
-
// //distractor point with ordonnée = x
|
|
162
|
-
// new Point("B", wrongY.toTree(), x.toTree()),
|
|
163
|
-
// ],
|
|
164
|
-
// );
|
|
165
206
|
const identifiers = {
|
|
166
|
-
// isSpline,
|
|
167
|
-
// splinePoints: spline.points,
|
|
168
207
|
x,
|
|
169
208
|
y,
|
|
170
209
|
functionType,
|
|
171
210
|
wrongY,
|
|
172
211
|
otherPoints,
|
|
212
|
+
functionCommand,
|
|
173
213
|
};
|
|
174
|
-
|
|
175
|
-
instruction: getInstruction(identifiers),
|
|
176
|
-
startStatement: getStartStatement(identifiers),
|
|
177
|
-
answer: getAnswer(identifiers),
|
|
178
|
-
keys: [],
|
|
179
|
-
ggbOptions: getGGBOptions(identifiers),
|
|
180
|
-
answerFormat: "tex",
|
|
181
|
-
identifiers,
|
|
182
|
-
};
|
|
183
|
-
return question;
|
|
214
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
184
215
|
};
|
|
185
|
-
const getPropositions = (n, { answer,
|
|
216
|
+
const getPropositions = (n, { answer, wrongY }, opts) => {
|
|
186
217
|
const propositions = [];
|
|
187
218
|
addValidProp(propositions, answer);
|
|
188
219
|
//old questions have spline POint undefined
|
|
@@ -203,7 +234,13 @@ const options = [
|
|
|
203
234
|
target: GeneratorOptionTarget.generation,
|
|
204
235
|
type: GeneratorOptionType.multiselect,
|
|
205
236
|
defaultValue: ["Tracés", "Polynômes", "Droites", "Paraboles"],
|
|
206
|
-
values: [
|
|
237
|
+
values: [
|
|
238
|
+
"Tracés",
|
|
239
|
+
"Polynômes",
|
|
240
|
+
"Droites",
|
|
241
|
+
"Paraboles",
|
|
242
|
+
"Avec valeur interdite (pas d'image)",
|
|
243
|
+
],
|
|
207
244
|
},
|
|
208
245
|
];
|
|
209
246
|
export const imageFunctionGeogebra = {
|
|
@@ -223,4 +260,5 @@ export const imageFunctionGeogebra = {
|
|
|
223
260
|
getInstruction,
|
|
224
261
|
getGGBOptions,
|
|
225
262
|
rebuildIdentifiers,
|
|
263
|
+
getQuestionFromIdentifiers,
|
|
226
264
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
2
|
type Identifiers = {
|
|
3
|
-
xValue: number;
|
|
4
3
|
yValue: number;
|
|
5
|
-
|
|
6
|
-
trinomCoeffs?: number[];
|
|
7
|
-
isAffine: boolean;
|
|
4
|
+
points: number[][];
|
|
8
5
|
};
|
|
9
6
|
export declare const inverseImageFunctionGeogebra: Exercise<Identifiers>;
|
|
10
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IAEjB,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB,CAAC;AAmNF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAoB9D,CAAC"}
|
|
@@ -1,94 +1,175 @@
|
|
|
1
1
|
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
-
import { randomColor } from "../../../../geogebra/colors.js";
|
|
4
3
|
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { Line } from "../../../../math/geometry/line.js";
|
|
5
|
+
import { Parabola } from "../../../../math/geometry/parabola.js";
|
|
6
|
+
import { Point } from "../../../../math/geometry/point.js";
|
|
7
|
+
import { AffineConstructor } from "../../../../math/polynomials/affine.js";
|
|
8
|
+
import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
|
|
9
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
8
10
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
9
11
|
import { round } from "../../../../math/utils/round.js";
|
|
12
|
+
import { valueParser } from "../../../../tree/parsers/valueParser.js";
|
|
10
13
|
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
14
|
+
import { probaFlip } from "../../../../utils/alea/probaFlip.js";
|
|
11
15
|
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
16
|
+
const rebuildIdentifiers = (oldIds) => {
|
|
17
|
+
if (oldIds.points?.length)
|
|
18
|
+
return oldIds;
|
|
19
|
+
const [x, y] = [oldIds.xValue, oldIds.yValue];
|
|
20
|
+
let points = [[x, y]];
|
|
21
|
+
if (oldIds.isAffine) {
|
|
22
|
+
const affine = AffineConstructor.fromCoeffs(oldIds.affineCoeffs);
|
|
23
|
+
const x2 = x + 1;
|
|
24
|
+
const y2 = affine.calculate(x2);
|
|
25
|
+
points.push([x2, y2]);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const trinom = TrinomConstructor.fromCoeffs(oldIds.trinomCoeffs);
|
|
29
|
+
const x2 = x - 1;
|
|
30
|
+
const x3 = x + 1;
|
|
31
|
+
const y2 = trinom.calculate(x2);
|
|
32
|
+
const y3 = trinom.calculate(x3);
|
|
33
|
+
points.push([x2, y2], [x3, y3]);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
points,
|
|
37
|
+
yValue: oldIds.yValue,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const getInstruction = (identifiers) => {
|
|
41
|
+
const { yValue } = identifiers;
|
|
42
|
+
return `Avec la précision permise par le graphique, déterminer le ou les antécédents de $${yValue}$ par la fonction $f$ représentée ci dessous.
|
|
43
|
+
|
|
44
|
+
S'il n'y en a pas, on écrira "aucun".`;
|
|
45
|
+
};
|
|
46
|
+
const getAnswer = (identifiers) => {
|
|
47
|
+
const { points, yValue } = identifiers;
|
|
48
|
+
const validPoints = points.filter((p) => p[1] === yValue);
|
|
49
|
+
if (!validPoints.length) {
|
|
50
|
+
return "\\text{Aucun}";
|
|
51
|
+
}
|
|
52
|
+
return validPoints
|
|
53
|
+
.map((p) => round(p[0], 2).frenchify())
|
|
54
|
+
.join("\\text{ et }");
|
|
55
|
+
};
|
|
56
|
+
const getGGBOptions = (identifiers) => {
|
|
57
|
+
const { points } = identifiers;
|
|
58
|
+
let commands = [];
|
|
59
|
+
if (points.length === 2) {
|
|
60
|
+
const line = new Line(new Point("A", points[0][0], points[0][1]), new Point("B", points[1][0], points[1][1]));
|
|
61
|
+
commands = line.toGGBCommands(false);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const parabola = new Parabola(points.map((p, i) => new Point(`A_${i}`, p[0], p[1])));
|
|
65
|
+
commands = parabola.toGGBCommands(false);
|
|
66
|
+
}
|
|
67
|
+
const Xs = points.map((p) => p[0]);
|
|
68
|
+
const Ys = points.map((p) => p[1]);
|
|
69
|
+
const xMin = Math.min(...Xs);
|
|
70
|
+
const xMax = Math.max(...Xs);
|
|
71
|
+
const yMin = Math.min(...Ys);
|
|
72
|
+
const yMax = Math.max(...Ys);
|
|
73
|
+
const ggb = new GeogebraConstructor({ commands });
|
|
74
|
+
return ggb.getOptions({
|
|
75
|
+
coords: ggb.getAdaptedCoords({
|
|
76
|
+
xMin,
|
|
77
|
+
xMax,
|
|
78
|
+
yMin,
|
|
79
|
+
yMax,
|
|
80
|
+
forceShowAxes: true,
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
};
|
|
12
84
|
const getInverseImageFunctionGeogebra = () => {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
// const
|
|
85
|
+
const isLine = coinFlip();
|
|
86
|
+
const hasAntecedent = probaFlip(0.8);
|
|
87
|
+
// const isLine = false;
|
|
88
|
+
// const hasAntecedent = true;
|
|
16
89
|
let yValue;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
xMin = xValue;
|
|
34
|
-
xMax = xValue;
|
|
35
|
-
commands = [affine.toString()];
|
|
90
|
+
const points = [];
|
|
91
|
+
if (isLine) {
|
|
92
|
+
if (hasAntecedent) {
|
|
93
|
+
yValue = randint(-6, 7);
|
|
94
|
+
const xIsDecimal = probaFlip(0.3);
|
|
95
|
+
const xValue = xIsDecimal
|
|
96
|
+
? randfloat(-6, 7, 2, [yValue])
|
|
97
|
+
: randint(-6, 7, [yValue]);
|
|
98
|
+
const wrongY = randint(-6, 7);
|
|
99
|
+
points.push([xValue, yValue], [yValue, wrongY]);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
yValue = randint(-6, 7, [0]);
|
|
103
|
+
const constante = randint(-6, 7, [yValue]);
|
|
104
|
+
points.push([0, constante], [1, constante]);
|
|
105
|
+
}
|
|
36
106
|
}
|
|
37
107
|
else {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
108
|
+
if (hasAntecedent) {
|
|
109
|
+
yValue = randint(-6, 7);
|
|
110
|
+
const xIsDecimal = coinFlip();
|
|
111
|
+
const xValue = xIsDecimal
|
|
112
|
+
? randfloat(-6, 7, 2, [yValue])
|
|
113
|
+
: randint(-6, 7, [yValue]);
|
|
114
|
+
const hasTwoAntecedents = probaFlip(0.8);
|
|
115
|
+
if (hasTwoAntecedents) {
|
|
116
|
+
const wrongY = randint(-6, 7, [yValue]);
|
|
117
|
+
const secondAntecedentPoint = [
|
|
118
|
+
randint(-6, 7, [xValue, yValue]),
|
|
119
|
+
yValue,
|
|
120
|
+
];
|
|
121
|
+
points.push([xValue, yValue], [yValue, wrongY], secondAntecedentPoint);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
//(x,y) is summit
|
|
125
|
+
const wrongY = randint(-6, 7, [yValue]);
|
|
126
|
+
points.push([xValue, yValue], [yValue, wrongY], [2 * xValue - yValue, wrongY]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
yValue = randint(-8, 9);
|
|
131
|
+
const wrongY = randint(-3, 4, [yValue, yValue - 1, yValue + 1]);
|
|
132
|
+
const below = wrongY < yValue;
|
|
133
|
+
const summit = [
|
|
134
|
+
randint(-6, 7, [yValue]),
|
|
135
|
+
below
|
|
136
|
+
? randint(wrongY + 1, yValue, [wrongY])
|
|
137
|
+
: randint(yValue + 1, wrongY, [wrongY]),
|
|
138
|
+
];
|
|
139
|
+
const thirdPoint = [2 * summit[0] - yValue, wrongY];
|
|
140
|
+
//construire deux autrs points au pif avec y sous/audssu yValus
|
|
141
|
+
points.push([yValue, wrongY], summit, thirdPoint);
|
|
142
|
+
}
|
|
60
143
|
}
|
|
61
|
-
|
|
62
|
-
const
|
|
144
|
+
points.sort((p1, p2) => p1[0] - p2[0]);
|
|
145
|
+
const identifiers = {
|
|
146
|
+
// xValue,
|
|
147
|
+
// affineCoeffs: isAffine ? affine!.coefficients : undefined,
|
|
148
|
+
// trinomCoeffs: isAffine ? undefined : trinom!.coefficients,
|
|
149
|
+
yValue,
|
|
150
|
+
points,
|
|
151
|
+
// isAffine,
|
|
152
|
+
};
|
|
153
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
154
|
+
};
|
|
155
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
63
156
|
const question = {
|
|
64
|
-
instruction:
|
|
65
|
-
answer,
|
|
157
|
+
instruction: getInstruction(identifiers),
|
|
158
|
+
answer: getAnswer(identifiers),
|
|
66
159
|
keys: ["et", "aucun"],
|
|
67
|
-
ggbOptions:
|
|
68
|
-
coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
|
|
69
|
-
}),
|
|
160
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
70
161
|
answerFormat: "tex",
|
|
71
|
-
identifiers
|
|
72
|
-
xValue,
|
|
73
|
-
affineCoeffs: isAffine ? affine.coefficients : undefined,
|
|
74
|
-
trinomCoeffs: isAffine ? undefined : trinom.coefficients,
|
|
75
|
-
yValue,
|
|
76
|
-
isAffine,
|
|
77
|
-
},
|
|
162
|
+
identifiers,
|
|
78
163
|
};
|
|
79
164
|
return question;
|
|
80
165
|
};
|
|
81
|
-
const getPropositions = (n, { answer,
|
|
166
|
+
const getPropositions = (n, { answer, points, yValue }) => {
|
|
82
167
|
const propositions = [];
|
|
83
168
|
addValidProp(propositions, answer);
|
|
84
169
|
tryToAddWrongProp(propositions, "\\text{Aucun}");
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
tryToAddWrongProp(propositions,
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
const trinom = new Polynomial(trinomCoeffs);
|
|
91
|
-
tryToAddWrongProp(propositions, trinom.calculate(yValue).toString().replace(".", ","));
|
|
170
|
+
const wrongY = points.find((p) => p[0] === yValue)?.[1];
|
|
171
|
+
if (wrongY !== undefined) {
|
|
172
|
+
tryToAddWrongProp(propositions, wrongY.frenchify());
|
|
92
173
|
}
|
|
93
174
|
while (propositions.length < n) {
|
|
94
175
|
const wrongAnswer = coinFlip()
|
|
@@ -98,26 +179,27 @@ const getPropositions = (n, { answer, xValue, affineCoeffs, trinomCoeffs, yValue
|
|
|
98
179
|
}
|
|
99
180
|
return shuffle(propositions);
|
|
100
181
|
};
|
|
101
|
-
const isAnswerValid = (ans, { answer,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
182
|
+
const isAnswerValid = (ans, { answer, points, yValue }) => {
|
|
183
|
+
if (ans === "\\text{Aucun}" || answer === "\\text{Aucun}")
|
|
184
|
+
return ans === answer;
|
|
185
|
+
const validPoints = points.filter((p) => p[1] === yValue);
|
|
186
|
+
const ansElements = ans.split("\\text{ et }");
|
|
187
|
+
if (validPoints.length !== ansElements.length)
|
|
188
|
+
return false;
|
|
189
|
+
let sorted = [];
|
|
190
|
+
for (const el of ansElements) {
|
|
191
|
+
const parsed = valueParser(el);
|
|
192
|
+
if (parsed === false)
|
|
193
|
+
return false;
|
|
194
|
+
sorted.push(parsed);
|
|
105
195
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
196
|
+
sorted.sort((a, b) => a - b);
|
|
197
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
198
|
+
const validPointX = validPoints[i][0];
|
|
199
|
+
if (Math.abs(sorted[i] - validPointX) > 0.3)
|
|
200
|
+
return false;
|
|
110
201
|
}
|
|
111
|
-
|
|
112
|
-
return ans === `\\text{Aucun}`;
|
|
113
|
-
const studentNumbers = ans
|
|
114
|
-
.split("\\text{ et }")
|
|
115
|
-
.map((n) => Number(n.replace(",", ".")))
|
|
116
|
-
.filter((n) => !isNaN(n))
|
|
117
|
-
.sort((a, b) => a - b);
|
|
118
|
-
antecedents.sort((a, b) => a - b);
|
|
119
|
-
return (!!studentNumbers.length &&
|
|
120
|
-
studentNumbers.every((nb, index) => Math.abs(nb - antecedents[index]) < 0.2));
|
|
202
|
+
return true;
|
|
121
203
|
};
|
|
122
204
|
export const inverseImageFunctionGeogebra = {
|
|
123
205
|
id: "inverseImageFunctionGeogebra",
|
|
@@ -133,4 +215,9 @@ export const inverseImageFunctionGeogebra = {
|
|
|
133
215
|
isAnswerValid,
|
|
134
216
|
hasGeogebra: true,
|
|
135
217
|
subject: "Mathématiques",
|
|
218
|
+
getAnswer,
|
|
219
|
+
getInstruction,
|
|
220
|
+
getGGBOptions,
|
|
221
|
+
getQuestionFromIdentifiers,
|
|
222
|
+
rebuildIdentifiers,
|
|
136
223
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalPercent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/globalPercent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAYT,MAAM,mBAAmB,CAAC;AAO3B,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAuGF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"globalPercent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/globalPercent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAYT,MAAM,mBAAmB,CAAC;AAO3B,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAuGF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAmB/C,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -684,20 +684,18 @@ declare const mathExercises: (Exercise<{
|
|
|
684
684
|
}> | Exercise<{
|
|
685
685
|
functionType: string;
|
|
686
686
|
x: number;
|
|
687
|
-
y
|
|
687
|
+
y?: number;
|
|
688
688
|
wrongY: number;
|
|
689
689
|
otherPoints: number[][];
|
|
690
|
+
functionCommand?: string;
|
|
690
691
|
}, {
|
|
691
692
|
curveTypes: string[];
|
|
692
693
|
}> | Exercise<{
|
|
693
694
|
poly1: number[];
|
|
694
695
|
xValue: number;
|
|
695
696
|
}, {}> | Exercise<{
|
|
696
|
-
xValue: number;
|
|
697
697
|
yValue: number;
|
|
698
|
-
|
|
699
|
-
trinomCoeffs?: number[];
|
|
700
|
-
isAffine: boolean;
|
|
698
|
+
points: number[][];
|
|
701
699
|
}, {}> | Exercise<{
|
|
702
700
|
yValue: number;
|
|
703
701
|
splinePoints: [number, number][];
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,UAAU,YAEtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const logIdentifiers = () => {
|
|
4
|
-
const ids = '{"xA":-3,"yA":-2,"yPrimeA":{"id":31,"child":{"id":3,"leftChild":{"id":7,"value":3},"rightChild":{"id":7,"value":2}}},"trinomCoeffs":[0.3888888888888889,0.833333333333333,-3]}';
|
|
5
|
-
const parsed = JSON.parse(ids);
|
|
6
|
-
console.log(parsed);
|
|
7
|
-
console.log(NodeConstructor.fromIdentifiers({ ...parsed.yPrimeA }).toTex());
|
|
1
|
+
export const playground = () => {
|
|
2
|
+
// logIdentifiers();
|
|
8
3
|
};
|
package/lib/server.d.ts
CHANGED
package/lib/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAUA,OAAO,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAUA,OAAO,4BAA4B,CAAC;AAOpC,eAAO,MAAM,cAAc,YAW1B,CAAC"}
|
package/lib/server.js
CHANGED
|
@@ -11,6 +11,18 @@ const jsonParser = bodyParser.json();
|
|
|
11
11
|
const mathExercises = Object.values(MathExercises);
|
|
12
12
|
const pcExercises = Object.values(PCExercises);
|
|
13
13
|
const allExercises = [...mathExercises, ...pcExercises];
|
|
14
|
+
export const logIdentifiers = () => {
|
|
15
|
+
const log = false;
|
|
16
|
+
if (!log)
|
|
17
|
+
return;
|
|
18
|
+
const shortname = "fractionsOperations";
|
|
19
|
+
const gen = mathExercises.find((el) => el.id === shortname);
|
|
20
|
+
const ids = '{"statementIdentifiers":{"id":1,"leftChild":{"id":3,"leftChild":{"id":7,"value":10},"rightChild":{"id":7,"value":3}},"rightChild":{"id":2,"leftChild":{"id":3,"leftChild":{"id":7,"value":1},"rightChild":{"id":7,"value":5}},"rightChild":{"id":3,"leftChild":{"id":7,"value":7},"rightChild":{"id":7,"value":5}}}}}';
|
|
21
|
+
const parsed = JSON.parse(ids);
|
|
22
|
+
console.log(parsed);
|
|
23
|
+
const question = gen.getQuestionFromIdentifiers(parsed);
|
|
24
|
+
console.log(question.instruction);
|
|
25
|
+
};
|
|
14
26
|
const runServer = () => {
|
|
15
27
|
dotenv.config();
|
|
16
28
|
const app = express();
|
|
@@ -19,6 +31,7 @@ const runServer = () => {
|
|
|
19
31
|
console.log("math hints", mathExercises.filter((exo) => exo.hasHintAndCorrection).length);
|
|
20
32
|
console.log("pc exos", `${pcExercises.length}`);
|
|
21
33
|
playground();
|
|
34
|
+
logIdentifiers();
|
|
22
35
|
app.get("/", (req, res) => {
|
|
23
36
|
res.json(allExercises);
|
|
24
37
|
});
|
|
@@ -28,6 +41,9 @@ const runServer = () => {
|
|
|
28
41
|
app.get("/xplive", (req, res) => {
|
|
29
42
|
res.json(pcExercises);
|
|
30
43
|
});
|
|
44
|
+
app.get("/question", (req, res) => {
|
|
45
|
+
const exoId = req.query.exoId;
|
|
46
|
+
});
|
|
31
47
|
app.get("/exo", (req, res) => {
|
|
32
48
|
const exoId = req.query.exoId;
|
|
33
49
|
const options = req.query.options
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AlgebraicNode } from "./algebraicNode.js";
|
|
2
2
|
import { Node, NodeIds } from "./node.js";
|
|
3
|
-
export declare const reifyAlgebraic: (identifiers: NodeIdentifiers) => AlgebraicNode;
|
|
3
|
+
export declare const reifyAlgebraic: (identifiers: NodeIdentifiers, log?: boolean) => AlgebraicNode;
|
|
4
4
|
export declare const reifyNode: (identifiers: NodeIdentifiers) => Node;
|
|
5
5
|
export type NodeIdentifiers = {
|
|
6
6
|
id: NodeIds;
|
|
7
7
|
} & Record<string, any>;
|
|
8
8
|
export declare abstract class NodeConstructor {
|
|
9
|
-
static fromIdentifiers(identifiers: NodeIdentifiers): Node;
|
|
9
|
+
static fromIdentifiers(identifiers: NodeIdentifiers, log?: boolean): Node;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=nodeConstructor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeConstructor.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/nodeConstructor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAwBnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoB1C,eAAO,MAAM,cAAc,gBAAiB,eAAe,
|
|
1
|
+
{"version":3,"file":"nodeConstructor.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/nodeConstructor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAwBnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoB1C,eAAO,MAAM,cAAc,gBAAiB,eAAe,QAAQ,OAAO,KACxB,aAAa,CAAC;AAChE,eAAO,MAAM,SAAS,gBAAiB,eAAe,SACR,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACpE,8BAAsB,eAAe;IACnC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI;CAqS1E"}
|
|
@@ -41,10 +41,11 @@ import { DiscreteSetNode } from "./sets/discreteSetNode.js";
|
|
|
41
41
|
import { IntervalNode } from "./sets/intervalNode.js";
|
|
42
42
|
import { UnionIntervalNode } from "./sets/unionIntervalNode.js";
|
|
43
43
|
import { VariableNode } from "./variables/variableNode.js";
|
|
44
|
-
export const reifyAlgebraic = (identifiers) => NodeConstructor.fromIdentifiers(identifiers);
|
|
44
|
+
export const reifyAlgebraic = (identifiers, log) => NodeConstructor.fromIdentifiers(identifiers);
|
|
45
45
|
export const reifyNode = (identifiers) => NodeConstructor.fromIdentifiers(identifiers);
|
|
46
46
|
export class NodeConstructor {
|
|
47
|
-
static fromIdentifiers(identifiers) {
|
|
47
|
+
static fromIdentifiers(identifiers, log) {
|
|
48
|
+
log && console.log(identifiers.id);
|
|
48
49
|
switch (identifiers.id) {
|
|
49
50
|
case NodeIds.variable: {
|
|
50
51
|
return new VariableNode(identifiers.name);
|