math-exercises 3.0.161 → 3.0.162
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/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +101 -15
- package/lib/exercises/math/functions/cube/isPointOnCubicFunction.d.ts.map +1 -1
- package/lib/exercises/math/functions/cube/isPointOnCubicFunction.js +7 -1
- package/lib/math/geometry/point.d.ts +1 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +3 -0
- package/lib/math/polynomials/generalAffine.d.ts +3 -0
- package/lib/math/polynomials/generalAffine.d.ts.map +1 -1
- package/lib/math/polynomials/generalAffine.js +12 -2
- package/lib/math/polynomials/trinom.d.ts +1 -0
- package/lib/math/polynomials/trinom.d.ts.map +1 -1
- package/lib/math/polynomials/trinom.js +13 -0
- package/lib/server.js +21 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IAEjB,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB,CAAC;AA8WF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAoB9D,CAAC"}
|
|
@@ -3,7 +3,9 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
|
|
|
3
3
|
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
4
4
|
import { Line } from "../../../../math/geometry/line.js";
|
|
5
5
|
import { Parabola } from "../../../../math/geometry/parabola.js";
|
|
6
|
-
import { Point } from "../../../../math/geometry/point.js";
|
|
6
|
+
import { Point, PointConstructor } from "../../../../math/geometry/point.js";
|
|
7
|
+
import { GeneralAffineConstructor } from "../../../../math/polynomials/generalAffine.js";
|
|
8
|
+
import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
|
|
7
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";
|
|
@@ -209,38 +211,122 @@ const isAnswerValid = (ans, { answer, points, yValue }) => {
|
|
|
209
211
|
}
|
|
210
212
|
return true;
|
|
211
213
|
};
|
|
212
|
-
const getFeedback = (ans, { answer
|
|
213
|
-
const { points } = identifiers;
|
|
214
|
-
|
|
215
|
-
//A3-2. Intersection axe abscisse
|
|
216
|
-
//A3-3. Intersection ordonnée
|
|
217
|
-
//A3-4. Abscisse maximum
|
|
218
|
-
//A3-5. Abscisse minimum
|
|
219
|
-
//C3-1. Une seule solution au lieu de deux
|
|
220
|
-
//D. Lecture graphique peu précise (réponse proche mais pas correcte)
|
|
221
|
-
if (points.length === 1) {
|
|
214
|
+
const getFeedback = (ans, { answer, ...identifiers }) => {
|
|
215
|
+
const { points, yValue } = identifiers;
|
|
216
|
+
if (points.length === 2) {
|
|
222
217
|
const studentAns = valueParser(ans);
|
|
223
218
|
if (studentAns === false)
|
|
224
219
|
return {
|
|
225
220
|
errorType: "X",
|
|
226
221
|
feedback: "Réponse mal écrite",
|
|
227
222
|
};
|
|
228
|
-
|
|
223
|
+
const pointA = new Point("A", points[0][0], points[0][1]);
|
|
224
|
+
const pointB = new Point("B", points[1][0], points[1][1]);
|
|
225
|
+
const affine = GeneralAffineConstructor.fromPoints(pointA, pointB);
|
|
226
|
+
const image = affine.image(yValue);
|
|
227
|
+
if (Math.abs(studentAns - image.evaluate()) < 0.3) {
|
|
229
228
|
return {
|
|
230
229
|
errorType: "A3-1",
|
|
231
230
|
feedback: "Tu as donné l'image au lieu de l'antécédent",
|
|
232
231
|
};
|
|
233
232
|
}
|
|
233
|
+
if (affine.a.evaluate() !== 0) {
|
|
234
|
+
const root = affine.getRoot();
|
|
235
|
+
if (Math.abs(studentAns - root.evaluate()) < 0.3) {
|
|
236
|
+
return {
|
|
237
|
+
errorType: "A3-2",
|
|
238
|
+
feedback: "Tu lis l'intersection avec axe abscisse",
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const ordOrigine = affine.b.evaluate();
|
|
243
|
+
if (Math.abs(studentAns - ordOrigine) < 0.3) {
|
|
244
|
+
return {
|
|
245
|
+
errorType: "A3-3",
|
|
246
|
+
feedback: "Tu lis l'intersection avec ordonnée",
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
const ansNb = answer.unfrenchify();
|
|
250
|
+
if (Math.abs(studentAns - ansNb) < 1) {
|
|
251
|
+
return {
|
|
252
|
+
errorType: "D",
|
|
253
|
+
feedback: "Lecture graphique peu précise",
|
|
254
|
+
};
|
|
255
|
+
}
|
|
234
256
|
return {
|
|
235
257
|
errorType: "X",
|
|
236
258
|
feedback: "Non corrélable",
|
|
237
259
|
};
|
|
238
260
|
}
|
|
239
261
|
else {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
262
|
+
const trinom = TrinomConstructor.fromPoints(points.map((p) => PointConstructor.fromCoords(p)));
|
|
263
|
+
const studentAns = ans.split("\\text{ et }");
|
|
264
|
+
if (studentAns.length === 1) {
|
|
265
|
+
const v = valueParser(studentAns[0]);
|
|
266
|
+
if (v === false)
|
|
267
|
+
return { errorType: "X", feedback: "Réponse mal écrite" };
|
|
268
|
+
const validPoints = points.filter((p) => p[1] === yValue);
|
|
269
|
+
if (validPoints.length === 2 &&
|
|
270
|
+
validPoints.some((p) => Math.abs(p[0] - v) < 0.2)) {
|
|
271
|
+
return {
|
|
272
|
+
errorType: "C3-1",
|
|
273
|
+
feedback: "Tu as donné une seule solution au lieu de deux",
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const values = studentAns.map((e) => valueParser(e));
|
|
278
|
+
const extrema = round(trinom.getBeta(), 5);
|
|
279
|
+
const image = round(trinom.calculate(yValue), 5);
|
|
280
|
+
const roots = trinom.getRoots();
|
|
281
|
+
const c = trinom.c;
|
|
282
|
+
const checkValue = (v) => {
|
|
283
|
+
if (Math.abs(v - image) < 0.2) {
|
|
284
|
+
return {
|
|
285
|
+
errorType: "A3-1",
|
|
286
|
+
feedback: "Tu as donné l'image au lieu de l'antécédent",
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
if (Math.abs(v - c) < 0.2)
|
|
290
|
+
return {
|
|
291
|
+
errorType: "A3-3",
|
|
292
|
+
feedback: "Tu lis l'intersection avec ordonnée",
|
|
293
|
+
};
|
|
294
|
+
if (Math.abs(v - extrema) < 0.2)
|
|
295
|
+
if (trinom.a < 0)
|
|
296
|
+
return {
|
|
297
|
+
errorType: "A3-4",
|
|
298
|
+
feedback: "Tu lis le maximum",
|
|
299
|
+
};
|
|
300
|
+
else {
|
|
301
|
+
return {
|
|
302
|
+
errorType: "A3-5",
|
|
303
|
+
feedback: "Tu lis le minimum",
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
if (roots.length) {
|
|
307
|
+
if (Math.abs(v - roots[0]) < 0.2 || Math.abs(v - roots[1]) < 0.2) {
|
|
308
|
+
return {
|
|
309
|
+
errorType: "A3-2",
|
|
310
|
+
feedback: "Tu lis l'intersection avec axe abscisse",
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
errorType: "X",
|
|
316
|
+
feedback: "Non corrélable",
|
|
317
|
+
};
|
|
243
318
|
};
|
|
319
|
+
const types = values.map((v) => checkValue(v));
|
|
320
|
+
if (values.length === 1)
|
|
321
|
+
return types[0];
|
|
322
|
+
if (types[0].errorType === types[1].errorType) {
|
|
323
|
+
return types[0];
|
|
324
|
+
}
|
|
325
|
+
if (types[0].errorType === "X" && types[1].errorType !== "X") {
|
|
326
|
+
return types[1];
|
|
327
|
+
}
|
|
328
|
+
else
|
|
329
|
+
return types[0];
|
|
244
330
|
}
|
|
245
331
|
};
|
|
246
332
|
const getMethodology = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPointOnCubicFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/cube/isPointOnCubicFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"isPointOnCubicFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/cube/isPointOnCubicFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAgGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
|
|
@@ -34,7 +34,13 @@ const getInstruction = (identifiers) => {
|
|
|
34
34
|
return `Le point $${point.toTexWithCoords()}$ appartient-il à la courbe de la fonction cube ?`;
|
|
35
35
|
};
|
|
36
36
|
const getHint = () => {
|
|
37
|
-
return `Un point de coordonnées $(x;y)$ appartient à la courbe d'une fonction $f$ si et seulement $y = f(x)
|
|
37
|
+
return `Un point de coordonnées $(x;y)$ appartient à la courbe d'une fonction $f$ si et seulement $y = f(x)$.
|
|
38
|
+
|
|
39
|
+
On rappelle de plus que la fonction cube est la fonction $f$ définie sur $\\mathbb{R}$ par :
|
|
40
|
+
|
|
41
|
+
$$
|
|
42
|
+
f(x) = x^3
|
|
43
|
+
$$`;
|
|
38
44
|
};
|
|
39
45
|
const getCorrection = (identifiers) => {
|
|
40
46
|
const { x, y } = identifiers;
|
|
@@ -15,6 +15,7 @@ export declare abstract class PointConstructor {
|
|
|
15
15
|
static origin(name?: string): Point;
|
|
16
16
|
static random(name: string, min?: number, max?: number): Point;
|
|
17
17
|
static fromIdentifiers(identifiers: PointIdentifiers): Point;
|
|
18
|
+
static fromCoords(coords: number[], name?: string): Point;
|
|
18
19
|
static onSegment(segment: Segment, name: string, { spacing, coefficient, }?: {
|
|
19
20
|
spacing?: number;
|
|
20
21
|
coefficient?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,eAAe,EAChB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC1F,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AACF,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE;IAGrC,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MAAM;IAK5B,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,aAAa;IAMvC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;IAK5B,YAAY;IAGZ,YAAY,CAAC,EACX,OAAc,EACd,gBAAwB,EACxB,SAAgB,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,KAAK,GACN,GAAE,kBAAuB;IAsB1B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK;IAiBpC,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAkBhE,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,SAAkB;IAIrD,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,SAAkB;IAI1C,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,SAAkB;IAKhD,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAG/B,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAAC,EAAE,aAAa,GAAG,MAAM;CAO/D"}
|
|
@@ -35,6 +35,9 @@ export class PointConstructor {
|
|
|
35
35
|
static fromIdentifiers(identifiers) {
|
|
36
36
|
return new Point(identifiers.name, NodeConstructor.fromIdentifiers(identifiers.x), NodeConstructor.fromIdentifiers(identifiers.y));
|
|
37
37
|
}
|
|
38
|
+
static fromCoords(coords, name = "A") {
|
|
39
|
+
return new Point(name, new NumberNode(coords[0]), new NumberNode(coords[1]));
|
|
40
|
+
}
|
|
38
41
|
static onSegment(segment, name, { spacing = 0.1, coefficient, } = {}) {
|
|
39
42
|
const coeff = coefficient ?? randfloat(spacing, 1 - spacing);
|
|
40
43
|
const vector = VectorConstructor.fromSegment(segment).times(coeff.toTree());
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
|
|
2
2
|
import { NodeIdentifiers } from "../../tree/nodes/nodeConstructor.js";
|
|
3
3
|
import { IntervalNode } from "../../tree/nodes/sets/intervalNode.js";
|
|
4
|
+
import { Point } from "../geometry/point.js";
|
|
4
5
|
export declare abstract class GeneralAffineConstructor {
|
|
5
6
|
static fromIdentifiers(identifiers: GeneralAffineIdentifiers): GeneralAffine;
|
|
6
7
|
static randomInts({ allowBNull }: {
|
|
7
8
|
allowBNull?: boolean | undefined;
|
|
8
9
|
}, variable?: string): GeneralAffine;
|
|
10
|
+
static fromPoints(pointA: Point, pointB: Point): GeneralAffine;
|
|
9
11
|
}
|
|
10
12
|
export type GeneralAffineIdentifiers = {
|
|
11
13
|
id: "affine";
|
|
@@ -25,5 +27,6 @@ export declare class GeneralAffine {
|
|
|
25
27
|
toTree(): import("../../tree/nodes/operators/addNode.js").AddNode | import("../../tree/nodes/operators/multiplyNode.js").MultiplyNode;
|
|
26
28
|
xIntersect(aff: GeneralAffine): AlgebraicNode | undefined;
|
|
27
29
|
opposite(): GeneralAffine;
|
|
30
|
+
image(x: AlgebraicNode | number): AlgebraicNode;
|
|
28
31
|
}
|
|
29
32
|
//# sourceMappingURL=generalAffine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generalAffine.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/generalAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"generalAffine.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/generalAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,8BAAsB,wBAAwB;IAC5C,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,wBAAwB;IAM5D,MAAM,CAAC,UAAU,CAAC,EAAE,UAAiB,EAAE;;KAAA,EAAE,QAAQ,SAAM;IAOvD,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;CAU/C;AACD,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,QAAQ,CAAC;IACb,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,qBAAa,aAAa;IACxB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;gBAGf,CAAC,EAAE,MAAM,GAAG,aAAa,EACzB,CAAC,EAAE,MAAM,GAAG,aAAa,EACzB,QAAQ,GAAE,MAAY;IAUxB,aAAa,IAAI,wBAAwB;IAQzC,OAAO,IAAI,aAAa;IAKxB,mBAAmB,IAAI,YAAY;IAQnC,mBAAmB,IAAI,YAAY;IASnC,MAAM;IAMN,UAAU,CAAC,GAAG,EAAE,aAAa;IAI7B,QAAQ;IAMR,KAAK,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM;CAGhC"}
|
|
@@ -15,6 +15,13 @@ export class GeneralAffineConstructor {
|
|
|
15
15
|
static randomInts({ allowBNull = true }, variable = "x") {
|
|
16
16
|
return new GeneralAffine(randint(-10, 11, [0]), randint(-10, 11, allowBNull ? [] : [0]), variable);
|
|
17
17
|
}
|
|
18
|
+
static fromPoints(pointA, pointB) {
|
|
19
|
+
if (pointA.x.equals(pointB.x))
|
|
20
|
+
throw new Error("Not an affine function");
|
|
21
|
+
const a = frac(substract(pointB.y, pointA.y), substract(pointB.x, pointA.x)).simplify();
|
|
22
|
+
const b = substract(pointA.y, multiply(a, pointA.x)).simplify();
|
|
23
|
+
return new GeneralAffine(a, b);
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
export class GeneralAffine {
|
|
20
27
|
a;
|
|
@@ -25,8 +32,6 @@ export class GeneralAffine {
|
|
|
25
32
|
this.a = a.toTree();
|
|
26
33
|
else
|
|
27
34
|
this.a = a;
|
|
28
|
-
if (this.a.evaluate() === 0)
|
|
29
|
-
throw new Error("Forbidden division by zero");
|
|
30
35
|
if (typeof b === "number")
|
|
31
36
|
this.b = b.toTree();
|
|
32
37
|
else
|
|
@@ -42,6 +47,8 @@ export class GeneralAffine {
|
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
49
|
getRoot() {
|
|
50
|
+
if (this.a.evaluate() === 0)
|
|
51
|
+
throw new Error("No root for constant function");
|
|
45
52
|
return frac(opposite(this.b), this.a).simplify();
|
|
46
53
|
}
|
|
47
54
|
getPositiveInterval() {
|
|
@@ -76,4 +83,7 @@ export class GeneralAffine {
|
|
|
76
83
|
opposite() {
|
|
77
84
|
return new GeneralAffine(opposite(this.a).simplify(), opposite(this.b).simplify());
|
|
78
85
|
}
|
|
86
|
+
image(x) {
|
|
87
|
+
return add(multiply(this.a, x), this.b).simplify();
|
|
88
|
+
}
|
|
79
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trinom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/trinom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAO,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAEL,YAAY,EACb,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA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AQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1C,qBAAa,MAAO,SAAQ,UAAU;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;gBAEL,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa;IAQjE,QAAQ;IAGR,YAAY,IAAI,UAAU;IAI1B,QAAQ;IAUR,YAAY,IAAI,aAAa,EAAE;IAyD/B,2BAA2B,CAAC,eAAe,CAAC,EAAE,OAAO;IAarD,QAAQ;IAGR,YAAY;IAIZ,OAAO;IAIP,WAAW;IAIX,YAAY;IAeZ,gBAAgB;IAsBhB,SAAS;IAIT,SAAS;IAYT,QAAQ;IAkCR,aAAa,CACX,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;;;;KAA4C;CAYrE"}
|
|
@@ -14,6 +14,7 @@ import { gcd } from "../utils/arithmetic/gcd.js";
|
|
|
14
14
|
import { randint } from "../utils/random/randint.js";
|
|
15
15
|
import { random } from "../../utils/alea/random.js";
|
|
16
16
|
import { blueMain } from "../../geogebra/colors.js";
|
|
17
|
+
import { round } from "../utils/round.js";
|
|
17
18
|
export class TrinomConstructor {
|
|
18
19
|
static random(aOpts, bOpts, cOpts) {
|
|
19
20
|
const a = randint(aOpts?.min ?? -9, aOpts?.max ?? 10, aOpts?.excludes ?? [0]);
|
|
@@ -86,6 +87,18 @@ export class TrinomConstructor {
|
|
|
86
87
|
const a = ySummit / ((x2 - x1) / 2) ** 2;
|
|
87
88
|
return this.fromRoots(roots, a);
|
|
88
89
|
}
|
|
90
|
+
static fromPoints(points) {
|
|
91
|
+
const sorted = [...points.sort((a, b) => a.x.evaluate() - b.x.evaluate())];
|
|
92
|
+
const [x1, y1] = [sorted[0].x.evaluate(), sorted[0].y.evaluate()];
|
|
93
|
+
const [x2, y2] = [sorted[1].x.evaluate(), sorted[1].y.evaluate()];
|
|
94
|
+
const [x3, y3] = [sorted[2].x.evaluate(), sorted[2].y.evaluate()];
|
|
95
|
+
const delta1 = round((y2 - y1) / (x2 - x1), 5);
|
|
96
|
+
const delta2 = round((y3 - y2) / (x3 - x2), 5);
|
|
97
|
+
const a = round((delta2 - delta1) / (x3 - x1), 5);
|
|
98
|
+
const b = round(delta1 - a * (x1 + x2), 5);
|
|
99
|
+
const c = round(y1 - a * x1 * x1 - b * x1, 5);
|
|
100
|
+
return new Trinom(a, b, c);
|
|
101
|
+
}
|
|
89
102
|
}
|
|
90
103
|
export class Trinom extends Polynomial {
|
|
91
104
|
a;
|
package/lib/server.js
CHANGED
|
@@ -226,6 +226,27 @@ const runServer = () => {
|
|
|
226
226
|
.id,
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
|
+
app.post("/feedback", jsonParser, (req, res) => {
|
|
230
|
+
const exoId = req.query.exoId;
|
|
231
|
+
const options = req.query.options
|
|
232
|
+
? JSON.parse(decodeURIComponent(req.query.options))
|
|
233
|
+
: undefined;
|
|
234
|
+
const { ans, feedbackProps } = req.body;
|
|
235
|
+
const exoIndex = allExercises.findIndex((exo) => exo.id == exoId);
|
|
236
|
+
const exo = allExercises[exoIndex];
|
|
237
|
+
if (!exo) {
|
|
238
|
+
res.send("Exo not found");
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!exo.getFeedback) {
|
|
242
|
+
res.send("No Feedback implemented");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const result = exo.getFeedback(ans, feedbackProps, options) ?? false;
|
|
246
|
+
res.json({
|
|
247
|
+
result,
|
|
248
|
+
});
|
|
249
|
+
});
|
|
229
250
|
app.post("/vea", jsonParser, (req, res) => {
|
|
230
251
|
const exoId = req.query.exoId;
|
|
231
252
|
const options = req.query.options
|