math-exercises 3.0.7 → 3.0.8

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 (28) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionsOperations.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/fractions/fractionsOperations.js +6 -1
  3. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +4 -4
  5. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
  6. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +4 -0
  7. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
  8. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +9 -5
  9. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +4 -0
  11. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
  12. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +18 -14
  13. package/lib/exercises/math/dataRepresentations/barChartReading.js +67 -0
  14. package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.d.ts.map +1 -1
  15. package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +3 -0
  16. package/lib/exercises/math/functions/basics/imageFunctionGeogebra.d.ts.map +1 -1
  17. package/lib/exercises/math/functions/basics/imageFunctionGeogebra.js +14 -20
  18. package/lib/exercises/math/percent/globalPercent.d.ts.map +1 -1
  19. package/lib/exercises/math/percent/globalPercent.js +4 -0
  20. package/lib/playground.d.ts.map +1 -1
  21. package/lib/playground.js +2 -7
  22. package/lib/server.d.ts +1 -0
  23. package/lib/server.d.ts.map +1 -1
  24. package/lib/server.js +16 -0
  25. package/lib/tree/nodes/nodeConstructor.d.ts +2 -2
  26. package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
  27. package/lib/tree/nodes/nodeConstructor.js +3 -2
  28. 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,EAcT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAM7C,KAAK,WAAW,GAAG;IACjB,oBAAoB,EAAE,eAAe,CAAC;CACvC,CAAC;AAqFF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAgBrD,CAAC"}
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
- const statement = NodeConstructor.fromIdentifiers(identifiers.statementIdentifiers);
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,EAcT,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;AAqJF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAqB/D,CAAC"}
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,EAaT,MAAM,6BAA6B,CAAC;AAcrC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAoBvD,CAAC"}
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,EAiBT,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;AAmJF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAaF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBhE,CAAC"}
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
  };
@@ -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,EAaT,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;AAgGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAqBvD,CAAC"}
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,EAWT,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;AA+FF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAgBvD,CAAC"}
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,CAgB/D,CAAC"}
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"}
@@ -124,4 +124,7 @@ export const affineExpressionFromTwoImages = {
124
124
  subject: "Mathématiques",
125
125
  hasHintAndCorrection: true,
126
126
  getCorrection,
127
+ getInstruction,
128
+ getAnswer,
129
+ getHint,
127
130
  };
@@ -1 +1 @@
1
- {"version":3,"file":"imageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,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,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;CACzB,CAAC;AAyOF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBhE,CAAC"}
1
+ {"version":3,"file":"imageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/imageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,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,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;CACzB,CAAC;AAoOF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmBhE,CAAC"}
@@ -122,6 +122,18 @@ const getStartStatement = (identifiers) => {
122
122
  const { x } = identifiers;
123
123
  return `f(${x})`;
124
124
  };
125
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
126
+ const question = {
127
+ instruction: getInstruction(identifiers, opts),
128
+ startStatement: getStartStatement(identifiers, opts),
129
+ answer: getAnswer(identifiers, opts),
130
+ keys: [],
131
+ ggbOptions: getGGBOptions(identifiers, opts),
132
+ answerFormat: "tex",
133
+ identifiers,
134
+ };
135
+ return question;
136
+ };
125
137
  const getImageFunctionGeogebra = (opts) => {
126
138
  const x = randint(-8, 9);
127
139
  const y = randint(-8, 9);
@@ -154,33 +166,14 @@ const getImageFunctionGeogebra = (opts) => {
154
166
  default:
155
167
  break;
156
168
  }
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
169
  const identifiers = {
166
- // isSpline,
167
- // splinePoints: spline.points,
168
170
  x,
169
171
  y,
170
172
  functionType,
171
173
  wrongY,
172
174
  otherPoints,
173
175
  };
174
- const question = {
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;
176
+ return getQuestionFromIdentifiers(identifiers, opts);
184
177
  };
185
178
  const getPropositions = (n, { answer, x, y, wrongY }, opts) => {
186
179
  const propositions = [];
@@ -223,4 +216,5 @@ export const imageFunctionGeogebra = {
223
216
  getInstruction,
224
217
  getGGBOptions,
225
218
  rebuildIdentifiers,
219
+ getQuestionFromIdentifiers,
226
220
  };
@@ -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,CAe/C,CAAC"}
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"}
@@ -99,4 +99,8 @@ export const globalPercent = {
99
99
  isAnswerValid,
100
100
  subject: "Mathématiques",
101
101
  hasHintAndCorrection: true,
102
+ getInstruction,
103
+ getAnswer,
104
+ getCorrection,
105
+ getHint,
102
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU,YAAW,CAAC"}
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
- import { NodeConstructor } from "./tree/nodes/nodeConstructor.js";
2
- export const playground = () => { };
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
@@ -1,2 +1,3 @@
1
1
  import "./prototypesEnhancement.js";
2
+ export declare const logIdentifiers: () => void;
2
3
  //# sourceMappingURL=server.d.ts.map
@@ -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,KACT,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,GAAG,IAAI;CAoS3D"}
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);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.7",
4
+ "version": "3.0.8",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [