math-exercises 3.0.166 → 3.0.167
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/_debug/debugVarSignTableReading.d.ts.map +1 -1
- package/lib/exercises/math/_debug/debugVarSignTableReading.js +1 -10
- package/lib/exercises/math/_debug/index.d.ts +1 -2
- package/lib/exercises/math/_debug/index.d.ts.map +1 -1
- package/lib/exercises/math/_debug/index.js +1 -2
- package/lib/exercises/math/derivation/variations/index.d.ts +2 -0
- package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/index.js +2 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.d.ts +9 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.js +163 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromGraph.d.ts +9 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromGraph.js +189 -0
- package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/sign/equationFromSignTable.js +3 -0
- package/lib/exercises/math/index.d.ts +0 -1
- package/lib/exercises/math/index.d.ts.map +1 -1
- package/lib/exercises/math/index.js +1 -1
- package/lib/index.d.ts +8 -12
- package/lib/index.d.ts.map +1 -1
- package/lib/tests/exoTest.d.ts.map +1 -1
- package/lib/tests/exoTest.js +6 -3
- package/lib/tests/pdfExo.test.js +2 -2
- package/lib/tests/pdfs/buildPDFForExercise.d.ts.map +1 -1
- package/lib/tests/pdfs/buildPDFForExercise.js +17 -1
- package/lib/tests/pdfs/dollarizeString.d.ts +2 -0
- package/lib/tests/pdfs/dollarizeString.d.ts.map +1 -0
- package/lib/tests/pdfs/dollarizeString.js +7 -0
- package/lib/tests/pdfs/signTableToLatex.js +1 -1
- package/lib/tests/pdfs/signVarTableToLatex.d.ts +2 -0
- package/lib/tests/pdfs/signVarTableToLatex.d.ts.map +1 -0
- package/lib/tests/pdfs/signVarTableToLatex.js +58 -0
- package/lib/tests/pdfs/varTableToLatex.d.ts.map +1 -1
- package/lib/tests/pdfs/varTableToLatex.js +2 -2
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +8 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugVarSignTableReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/_debug/debugVarSignTableReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;
|
|
1
|
+
{"version":3,"file":"debugVarSignTableReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/_debug/debugVarSignTableReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAwPF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAWF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAenE,CAAC"}
|
|
@@ -35,16 +35,7 @@ const getTable = (identifiers) => {
|
|
|
35
35
|
"\\ ",
|
|
36
36
|
xValues[3].frenchify(),
|
|
37
37
|
],
|
|
38
|
-
[
|
|
39
|
-
"£f'(x)£",
|
|
40
|
-
xValues[0].frenchify(),
|
|
41
|
-
"+",
|
|
42
|
-
xValues[1].frenchify(),
|
|
43
|
-
"-",
|
|
44
|
-
xValues[2].frenchify(),
|
|
45
|
-
"+",
|
|
46
|
-
xValues[3].frenchify(),
|
|
47
|
-
],
|
|
38
|
+
["£f'(x)£", "\\ ", "+", "z", "-", "z", "+", ""],
|
|
48
39
|
[
|
|
49
40
|
" ",
|
|
50
41
|
isFirstAscending ? "\\ " : yValues[0].frenchify(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/_debug/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/_debug/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./debugVarSignTableFromGraph.js";
|
|
1
|
+
export {};
|
|
@@ -2,4 +2,6 @@ export * from "./thirdDegreeFunctionVariation.js";
|
|
|
2
2
|
export * from "./thirdDegreeDerivativeVariation.js";
|
|
3
3
|
export * from "./variationArrowAmount.js";
|
|
4
4
|
export * from "./readExtremaAbscissFromDerivativeCurve.js";
|
|
5
|
+
export * from "./signVarTableFromGraph.js";
|
|
6
|
+
export * from "./signVarTableFromDerivativeGraph.js";
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4CAA4C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC"}
|
|
@@ -2,3 +2,5 @@ export * from "./thirdDegreeFunctionVariation.js";
|
|
|
2
2
|
export * from "./thirdDegreeDerivativeVariation.js";
|
|
3
3
|
export * from "./variationArrowAmount.js";
|
|
4
4
|
export * from "./readExtremaAbscissFromDerivativeCurve.js";
|
|
5
|
+
export * from "./signVarTableFromGraph.js";
|
|
6
|
+
export * from "./signVarTableFromDerivativeGraph.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
type: number;
|
|
4
|
+
coeffs: number[];
|
|
5
|
+
initTable: string[][];
|
|
6
|
+
};
|
|
7
|
+
export declare const signVarTableFromDerivativeGraph: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=signVarTableFromDerivativeGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signVarTableFromDerivativeGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AA4JF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAmBjE,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
2
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
3
|
+
import { Polynomial } from "../../../../math/polynomials/polynomial.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
6
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
7
|
+
const getRoots = (identifiers) => {
|
|
8
|
+
const { coeffs } = identifiers;
|
|
9
|
+
const [_d, c, b, a] = coeffs;
|
|
10
|
+
const sqrtDelta = 2 * Math.sqrt(b ** 2 - 3 * a * c);
|
|
11
|
+
const x1 = (-2 * b - sqrtDelta) / (6 * a);
|
|
12
|
+
const x2 = (-2 * b + sqrtDelta) / (6 * a);
|
|
13
|
+
return [x1, x2].sort((a, b) => a - b);
|
|
14
|
+
};
|
|
15
|
+
const getGGBOptions = (identifiers) => {
|
|
16
|
+
const { coeffs } = identifiers;
|
|
17
|
+
const poly = new Polynomial(coeffs);
|
|
18
|
+
const deriv = poly.derivate();
|
|
19
|
+
const commands = [`f(x) =${deriv.toMathString()}`];
|
|
20
|
+
const ggb = new GeogebraConstructor({
|
|
21
|
+
commands,
|
|
22
|
+
lockedAxesRatio: false,
|
|
23
|
+
});
|
|
24
|
+
const [x1, x2] = getRoots(identifiers);
|
|
25
|
+
const alpha = (x1 + x2) / 2;
|
|
26
|
+
const beta = deriv.calculate(alpha);
|
|
27
|
+
return ggb.getOptions({
|
|
28
|
+
coords: ggb.getAdaptedCoords({
|
|
29
|
+
xMin: x1 - 2,
|
|
30
|
+
xMax: x2 + 2,
|
|
31
|
+
yMin: Math.min(-1, beta) - 2,
|
|
32
|
+
yMax: Math.max(1, beta) + 2,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const getAnswerTable = (identifiers) => {
|
|
37
|
+
const { coeffs } = identifiers;
|
|
38
|
+
const [x1, x2] = getRoots(identifiers);
|
|
39
|
+
const vars = coeffs[3] > 0
|
|
40
|
+
? ["\\nearrow", "\\searrow", "\\nearrow"]
|
|
41
|
+
: ["\\searrow", "\\nearrow", "\\searrow"];
|
|
42
|
+
const signs = coeffs[3] < 0 ? ["-", "+", "-"] : ["+", "-", "+"];
|
|
43
|
+
return [
|
|
44
|
+
[
|
|
45
|
+
"$x$",
|
|
46
|
+
"-\\infty",
|
|
47
|
+
"\\ ",
|
|
48
|
+
x1.toTree().toTex(),
|
|
49
|
+
"\\ ",
|
|
50
|
+
x2.toTree().toTex(),
|
|
51
|
+
"\\ ",
|
|
52
|
+
"+\\infty",
|
|
53
|
+
],
|
|
54
|
+
["$f'(x)$", "\\ ", signs[0], "0", signs[1], "0", signs[2], "\\ "],
|
|
55
|
+
["$\\ $", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ "],
|
|
56
|
+
["$f(x)$", "\\ ", vars[0], "\\ ", vars[1], "\\ ", vars[2], "\\ "],
|
|
57
|
+
["$\\ $", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ "],
|
|
58
|
+
];
|
|
59
|
+
};
|
|
60
|
+
const getInstruction = () => {
|
|
61
|
+
return `On considère une fonction $f$, définie et dérivable sur $\\mathbb{R}$, dont la fonction dérivée $f'$ est représentée ci-dessous.
|
|
62
|
+
|
|
63
|
+
Dresser le tableau de signes de $f'$ et de variations de $f$.`;
|
|
64
|
+
};
|
|
65
|
+
const getHint = () => {
|
|
66
|
+
return `La fonction $f$ est définie sur $\\mathbb{R}$, donc les valeurs de $x$ vont de $-\\infty$ à $+\\infty$.
|
|
67
|
+
|
|
68
|
+
Repère ensuite les abscisses des points de la courbe de $f'$ tels que $f'(x) = 0$.
|
|
69
|
+
|
|
70
|
+
Sur les intervalles où $f'$ est positive, la fonction $f$ est croissante. Sur les intervalles où $f'$ est négative, la fonction $f$ est décroissante.`;
|
|
71
|
+
};
|
|
72
|
+
const getCorrection = (identifiers) => {
|
|
73
|
+
const { coeffs } = identifiers;
|
|
74
|
+
const [_d, _c, _b, a] = coeffs;
|
|
75
|
+
const [x1, x2] = getRoots(identifiers);
|
|
76
|
+
const words = a > 0
|
|
77
|
+
? ["croissante", "décroissante", "croissante"]
|
|
78
|
+
: ["décroissante", "croissante", "décroissante"];
|
|
79
|
+
const signWords = words.map((e) => e === "croissante" ? "positive" : "négative");
|
|
80
|
+
return `D'après le graphique, la fonction dérivée $f'$ est ${signWords[0]} sur $]-\\infty; ${x1}]$, puis ${signWords[1]} sur $[${x1}; ${x2}]$, puis ${signWords[2]} sur $[${x2}; +\\infty[$.
|
|
81
|
+
|
|
82
|
+
On en déduit que la fonction $f$ est ${words[0]} sur $]-\\infty; ${x1}]$, puis ${words[1]} sur $[${x1}; ${x2}]$, puis ${words[2]} sur $[${x2}; +\\infty[$.
|
|
83
|
+
`;
|
|
84
|
+
};
|
|
85
|
+
const getKeys = () => {
|
|
86
|
+
return ["infty"];
|
|
87
|
+
};
|
|
88
|
+
const isAnswerTableValid = (ans, { answerTable }) => {
|
|
89
|
+
try {
|
|
90
|
+
return ans.every((row, i) => row.every((cell, j) => {
|
|
91
|
+
return cell === answerTable[i][j];
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
return handleVEAError(err);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
// const lists = [
|
|
99
|
+
// "x^3 - 3x",
|
|
100
|
+
// "x^3 -6x^2 + 9x",
|
|
101
|
+
// "-x^3 + 3x^2 + 9x",
|
|
102
|
+
// "2x^3 - 9x^2 + 12x",
|
|
103
|
+
// "-x^3+6x^2-9x",
|
|
104
|
+
// "4x^3 -24x^2 + 36x",
|
|
105
|
+
// ];
|
|
106
|
+
const poly3Coeffs = [
|
|
107
|
+
[0, -3, 0, 1],
|
|
108
|
+
[0, 9, -6, 1],
|
|
109
|
+
// [0, 9, 3, -1],
|
|
110
|
+
[0, 12, -9, 2],
|
|
111
|
+
[0, -9, 6, -1],
|
|
112
|
+
// [0, 36, -24, 4],
|
|
113
|
+
];
|
|
114
|
+
const getVarSignTableFromGraphQuestion = () => {
|
|
115
|
+
const index = randint(0, 4);
|
|
116
|
+
const coeffs = coinFlip()
|
|
117
|
+
? poly3Coeffs[index]
|
|
118
|
+
: poly3Coeffs[index].map((x) => -x);
|
|
119
|
+
const initTable = [
|
|
120
|
+
["$x$", "-\\infty", "\\ ", "", "\\ ", "", "\\ ", "+\\infty"],
|
|
121
|
+
["$f'(x)$", "\\ ", "", "", "", "", "", "\\ "],
|
|
122
|
+
["$\\ $", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ "],
|
|
123
|
+
["$f(x)$", "\\ ", "", "", "", "", "", "\\ "],
|
|
124
|
+
["$\\ $", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ "],
|
|
125
|
+
];
|
|
126
|
+
const identifiers = {
|
|
127
|
+
type: 0,
|
|
128
|
+
coeffs: [coeffs[0] + randint(-10, 10), ...coeffs.slice(1)],
|
|
129
|
+
initTable,
|
|
130
|
+
};
|
|
131
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
132
|
+
};
|
|
133
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
134
|
+
return {
|
|
135
|
+
answerTable: getAnswerTable(identifiers),
|
|
136
|
+
instruction: getInstruction(identifiers),
|
|
137
|
+
keys: getKeys(identifiers),
|
|
138
|
+
answerFormat: "tex",
|
|
139
|
+
identifiers,
|
|
140
|
+
hint: getHint(identifiers),
|
|
141
|
+
correction: getCorrection(identifiers),
|
|
142
|
+
initTable: identifiers.initTable,
|
|
143
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
export const signVarTableFromDerivativeGraph = {
|
|
147
|
+
id: "signVarTableFromDerivativeGraph",
|
|
148
|
+
label: "Dresser le tableau de signes de $f'$ et de variations de $f$ à partir d'une représentation graphique",
|
|
149
|
+
isSingleStep: true,
|
|
150
|
+
generator: (nb, opts) => getDistinctQuestions(() => getVarSignTableFromGraphQuestion(opts), nb),
|
|
151
|
+
qcmTimer: 60,
|
|
152
|
+
freeTimer: 60,
|
|
153
|
+
isAnswerTableValid,
|
|
154
|
+
subject: "Mathématiques",
|
|
155
|
+
getInstruction,
|
|
156
|
+
getHint,
|
|
157
|
+
getCorrection,
|
|
158
|
+
getAnswerTable,
|
|
159
|
+
getQuestionFromIdentifiers,
|
|
160
|
+
hasHintAndCorrection: true,
|
|
161
|
+
answerType: "signVarTable",
|
|
162
|
+
hasGeogebra: true,
|
|
163
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
type: number;
|
|
4
|
+
coeffs: number[];
|
|
5
|
+
initTable: string[][];
|
|
6
|
+
};
|
|
7
|
+
export declare const signVarTableFromGraph: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=signVarTableFromGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signVarTableFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAsLF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAmBvD,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
2
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
3
|
+
import { Polynomial } from "../../../../math/polynomials/polynomial.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
6
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
7
|
+
const getRoots = (identifiers) => {
|
|
8
|
+
const { coeffs } = identifiers;
|
|
9
|
+
const [_d, c, b, a] = coeffs;
|
|
10
|
+
const sqrtDelta = 2 * Math.sqrt(b ** 2 - 3 * a * c);
|
|
11
|
+
const x1 = (-2 * b - sqrtDelta) / (6 * a);
|
|
12
|
+
const x2 = (-2 * b + sqrtDelta) / (6 * a);
|
|
13
|
+
return [x1, x2].sort((a, b) => a - b);
|
|
14
|
+
};
|
|
15
|
+
const getGGBOptions = (identifiers) => {
|
|
16
|
+
const { coeffs } = identifiers;
|
|
17
|
+
const poly = new Polynomial(coeffs);
|
|
18
|
+
const commands = [`f(x) =${poly.toMathString()}`];
|
|
19
|
+
const ggb = new GeogebraConstructor({
|
|
20
|
+
commands,
|
|
21
|
+
lockedAxesRatio: false,
|
|
22
|
+
});
|
|
23
|
+
const [x1, x2] = getRoots(identifiers);
|
|
24
|
+
const fx1 = poly.calculate(x1);
|
|
25
|
+
const fx2 = poly.calculate(x2);
|
|
26
|
+
return ggb.getOptions({
|
|
27
|
+
coords: ggb.getAdaptedCoords({
|
|
28
|
+
xMin: x1 - 2,
|
|
29
|
+
xMax: x2 + 2,
|
|
30
|
+
yMin: Math.min(fx1, fx2) - 2,
|
|
31
|
+
yMax: Math.max(fx1, fx2) + 2,
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const getAnswerTable = (identifiers) => {
|
|
36
|
+
const { coeffs } = identifiers;
|
|
37
|
+
const [_d, _c, _b, a] = coeffs;
|
|
38
|
+
const poly = new Polynomial(coeffs);
|
|
39
|
+
const [x1, x2] = getRoots(identifiers);
|
|
40
|
+
const fx1 = poly.calculate(x1);
|
|
41
|
+
const fx2 = poly.calculate(x2);
|
|
42
|
+
const vars = coeffs[3] > 0
|
|
43
|
+
? ["\\nearrow", "\\searrow", "\\nearrow"]
|
|
44
|
+
: ["\\searrow", "\\nearrow", "\\searrow"];
|
|
45
|
+
const signs = coeffs[3] < 0 ? ["-", "+", "-"] : ["+", "-", "+"];
|
|
46
|
+
return [
|
|
47
|
+
[
|
|
48
|
+
"$x$",
|
|
49
|
+
"-\\infty",
|
|
50
|
+
"\\ ",
|
|
51
|
+
x1.toTree().toTex(),
|
|
52
|
+
"\\ ",
|
|
53
|
+
x2.toTree().toTex(),
|
|
54
|
+
"\\ ",
|
|
55
|
+
"+\\infty",
|
|
56
|
+
],
|
|
57
|
+
["$f'(x)$", "\\ ", signs[0], "0", signs[1], "0", signs[2], "\\ "],
|
|
58
|
+
[
|
|
59
|
+
"$\\ $",
|
|
60
|
+
"\\ ",
|
|
61
|
+
"\\ ",
|
|
62
|
+
a > 0 ? fx1.toTree().toTex() : "\\ ",
|
|
63
|
+
"\\ ",
|
|
64
|
+
a > 0 ? "\\ " : fx2.toTree().toTex(),
|
|
65
|
+
"\\ ",
|
|
66
|
+
"\\ ",
|
|
67
|
+
],
|
|
68
|
+
["$f(x)$", "\\ ", vars[0], "\\ ", vars[1], "\\ ", vars[2], "\\ "],
|
|
69
|
+
[
|
|
70
|
+
"$\\ $",
|
|
71
|
+
"\\ ",
|
|
72
|
+
"\\ ",
|
|
73
|
+
a > 0 ? "\\ " : fx1.toTree().toTex(),
|
|
74
|
+
"\\ ",
|
|
75
|
+
a > 0 ? fx2.toTree().toTex() : "\\ ",
|
|
76
|
+
"\\ ",
|
|
77
|
+
"\\ ",
|
|
78
|
+
],
|
|
79
|
+
];
|
|
80
|
+
};
|
|
81
|
+
const getInstruction = () => {
|
|
82
|
+
return `On considère une fonction $f$, définie et dérivable sur $\\mathbb{R}$, dont la représentation graphique est donnée ci-dessous.
|
|
83
|
+
|
|
84
|
+
Dresser le tableau de signes de $f'$ et de variations de $f$.`;
|
|
85
|
+
};
|
|
86
|
+
const getHint = () => {
|
|
87
|
+
return `La fonction est définie sur $\\mathbb{R}$, donc les valeurs de $x$ vont de $-\\infty$ à $+\\infty$.
|
|
88
|
+
|
|
89
|
+
Repère ensuite les points de la courbe auxquels le sens de variation change.
|
|
90
|
+
|
|
91
|
+
Sur les intervalles où $f$ est croissante, sa dérivée $f'$ est négative. Sur les intervalles où $f$ est décroissante, sa dérivée $f'$ est positive.`;
|
|
92
|
+
};
|
|
93
|
+
const getCorrection = (identifiers) => {
|
|
94
|
+
const { coeffs } = identifiers;
|
|
95
|
+
const [_d, _c, _b, a] = coeffs;
|
|
96
|
+
const poly = new Polynomial(coeffs);
|
|
97
|
+
const [x1, x2] = getRoots(identifiers);
|
|
98
|
+
const fx1 = poly.calculate(x1);
|
|
99
|
+
const fx2 = poly.calculate(x2);
|
|
100
|
+
const words = a > 0
|
|
101
|
+
? ["croissante", "décroissante", "croissante"]
|
|
102
|
+
: ["décroissante", "croissante", "décroissante"];
|
|
103
|
+
const signWords = words.map((e) => e === "croissante" ? "positive" : "négative");
|
|
104
|
+
return `D'après le graphique, la fonction $f$ est ${words[0]} sur $]-\\infty; ${x1}]$, puis ${words[1]} sur $[${x1}; ${x2}]$, puis ${words[2]} sur $[${x2}; +\\infty[$.
|
|
105
|
+
|
|
106
|
+
On en déduit que la fonction dérivée $f'$ est ${signWords[0]} sur $]-\\infty; ${x1}]$, puis ${signWords[1]} sur $[${x1}; ${x2}]$, puis ${signWords[2]} sur $[${x2}; +\\infty[$.
|
|
107
|
+
|
|
108
|
+
De plus, on lit graphiquement que l'image de $${x1}$ est $${fx1}$, et celle de $${x2}$ est $${fx2}$.
|
|
109
|
+
`;
|
|
110
|
+
};
|
|
111
|
+
const getKeys = () => {
|
|
112
|
+
return ["infty"];
|
|
113
|
+
};
|
|
114
|
+
const isAnswerTableValid = (ans, { answerTable }) => {
|
|
115
|
+
try {
|
|
116
|
+
return ans.every((row, i) => row.every((cell, j) => {
|
|
117
|
+
return cell === answerTable[i][j];
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
return handleVEAError(err);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
// const lists = [
|
|
125
|
+
// "x^3 - 3x",
|
|
126
|
+
// "x^3 -6x^2 + 9x",
|
|
127
|
+
// "-x^3 + 3x^2 + 9x",
|
|
128
|
+
// "2x^3 - 9x^2 + 12x",
|
|
129
|
+
// "-x^3+6x^2-9x",
|
|
130
|
+
// "4x^3 -24x^2 + 36x",
|
|
131
|
+
// ];
|
|
132
|
+
const poly3Coeffs = [
|
|
133
|
+
[0, -3, 0, 1],
|
|
134
|
+
[0, 9, -6, 1],
|
|
135
|
+
// [0, 9, 3, -1],
|
|
136
|
+
[0, 12, -9, 2],
|
|
137
|
+
[0, -9, 6, -1],
|
|
138
|
+
// [0, 36, -24, 4],
|
|
139
|
+
];
|
|
140
|
+
const getVarSignTableFromGraphQuestion = () => {
|
|
141
|
+
const index = randint(0, 4);
|
|
142
|
+
const coeffs = coinFlip()
|
|
143
|
+
? poly3Coeffs[index]
|
|
144
|
+
: poly3Coeffs[index].map((x) => -x);
|
|
145
|
+
const initTable = [
|
|
146
|
+
["$x$", "-\\infty", "\\ ", "", "\\ ", "", "\\ ", "+\\infty"],
|
|
147
|
+
["$f'(x)$", "\\ ", "", "", "", "", "", "\\ "],
|
|
148
|
+
["$\\ $", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ "],
|
|
149
|
+
["$f(x)$", "\\ ", "", "", "", "", "", "\\ "],
|
|
150
|
+
["$\\ $", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ ", "\\ "],
|
|
151
|
+
];
|
|
152
|
+
const identifiers = {
|
|
153
|
+
type: 0,
|
|
154
|
+
coeffs: [coeffs[0] + randint(-10, 10), ...coeffs.slice(1)],
|
|
155
|
+
initTable,
|
|
156
|
+
};
|
|
157
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
158
|
+
};
|
|
159
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
160
|
+
return {
|
|
161
|
+
answerTable: getAnswerTable(identifiers),
|
|
162
|
+
instruction: getInstruction(identifiers),
|
|
163
|
+
keys: getKeys(identifiers),
|
|
164
|
+
answerFormat: "tex",
|
|
165
|
+
identifiers,
|
|
166
|
+
hint: getHint(identifiers),
|
|
167
|
+
correction: getCorrection(identifiers),
|
|
168
|
+
initTable: identifiers.initTable,
|
|
169
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export const signVarTableFromGraph = {
|
|
173
|
+
id: "signVarTableFromGraph",
|
|
174
|
+
label: "Dresser le tableau de signes de $f'$ et de variations de $f$ à partir d'une représentation graphique",
|
|
175
|
+
isSingleStep: true,
|
|
176
|
+
generator: (nb, opts) => getDistinctQuestions(() => getVarSignTableFromGraphQuestion(opts), nb),
|
|
177
|
+
qcmTimer: 60,
|
|
178
|
+
freeTimer: 60,
|
|
179
|
+
isAnswerTableValid,
|
|
180
|
+
subject: "Mathématiques",
|
|
181
|
+
getInstruction,
|
|
182
|
+
getHint,
|
|
183
|
+
getCorrection,
|
|
184
|
+
getAnswerTable,
|
|
185
|
+
getQuestionFromIdentifiers,
|
|
186
|
+
hasHintAndCorrection: true,
|
|
187
|
+
answerType: "signVarTable",
|
|
188
|
+
hasGeogebra: true,
|
|
189
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equationFromSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/equationFromSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAc7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAuQF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"equationFromSignTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/sign/equationFromSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAc7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,eAAe,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAuQF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1039,6 +1039,14 @@ declare const mathExercises: (Exercise<{
|
|
|
1039
1039
|
d: number;
|
|
1040
1040
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1041
1041
|
splinePoints: number[][];
|
|
1042
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1043
|
+
type: number;
|
|
1044
|
+
coeffs: number[];
|
|
1045
|
+
initTable: string[][];
|
|
1046
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1047
|
+
type: number;
|
|
1048
|
+
coeffs: number[];
|
|
1049
|
+
initTable: string[][];
|
|
1042
1050
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1043
1051
|
coeffs: number[];
|
|
1044
1052
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
@@ -4198,18 +4206,6 @@ declare const mathExercises: (Exercise<{
|
|
|
4198
4206
|
isGreaterCond: boolean;
|
|
4199
4207
|
k?: number;
|
|
4200
4208
|
randListAdd: number;
|
|
4201
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
4202
|
-
xValues: number[];
|
|
4203
|
-
yValues: number[];
|
|
4204
|
-
isAskingX: boolean;
|
|
4205
|
-
isAskingMin: boolean;
|
|
4206
|
-
intervalXIndexes: number[];
|
|
4207
|
-
}, {
|
|
4208
|
-
extremumType: string;
|
|
4209
|
-
}> | Exercise<{
|
|
4210
|
-
type: number;
|
|
4211
|
-
coeffs: number[];
|
|
4212
|
-
initTable: string[][];
|
|
4213
4209
|
}, Record<string, string | boolean | string[]>>)[];
|
|
4214
4210
|
declare const pcExercises: (Exercise<{
|
|
4215
4211
|
numbers: 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;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,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.ts","sourceRoot":"","sources":["../../src/tests/exoTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,6BAA6B,CAAC;AAI5E,eAAO,MAAM,OAAO,GAAI,KAAK,QAAQ,CAAC,MAAM,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"exoTest.d.ts","sourceRoot":"","sources":["../../src/tests/exoTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,6BAA6B,CAAC;AAI5E,eAAO,MAAM,OAAO,GAAI,KAAK,QAAQ,CAAC,MAAM,CAAC;;;;CA6H5C,CAAC"}
|
package/lib/tests/exoTest.js
CHANGED
|
@@ -36,7 +36,8 @@ export const exoTest = (exo) => {
|
|
|
36
36
|
exo.answerType !== "GGB" &&
|
|
37
37
|
exo.answerType !== "valueTable" &&
|
|
38
38
|
exo.answerType !== "varTable" &&
|
|
39
|
-
exo.answerType !== "signTable"
|
|
39
|
+
exo.answerType !== "signTable" &&
|
|
40
|
+
exo.answerType !== "signVarTable") {
|
|
40
41
|
if (!exo.getPropositions)
|
|
41
42
|
throw new Error(`exo ${exo.id} has no getPropositions`);
|
|
42
43
|
}
|
|
@@ -45,7 +46,8 @@ export const exoTest = (exo) => {
|
|
|
45
46
|
exo.answerType !== "GGB" &&
|
|
46
47
|
exo.answerType !== "valueTable" &&
|
|
47
48
|
exo.answerType !== "varTable" &&
|
|
48
|
-
exo.answerType !== "signTable"
|
|
49
|
+
exo.answerType !== "signTable" &&
|
|
50
|
+
exo.answerType !== "signVarTable") {
|
|
49
51
|
if (!exo.isAnswerValid)
|
|
50
52
|
throw new Error(`exo ${exo.id} has no isAnswerValid`);
|
|
51
53
|
}
|
|
@@ -55,7 +57,8 @@ export const exoTest = (exo) => {
|
|
|
55
57
|
}
|
|
56
58
|
if (exo.answerType === "valueTable" ||
|
|
57
59
|
exo.answerType === "varTable" ||
|
|
58
|
-
exo.answerType === "signTable"
|
|
60
|
+
exo.answerType === "signTable" ||
|
|
61
|
+
exo.answerType === "signVarTable") {
|
|
59
62
|
if (!exo.isAnswerTableValid)
|
|
60
63
|
throw new Error(`exo ${exo.id} has no isAnswerTableValid`);
|
|
61
64
|
}
|
package/lib/tests/pdfExo.test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { buildPdfForExercise } from "./pdfs/buildPDFForExercise.js";
|
|
2
2
|
import "../prototypesEnhancement.js";
|
|
3
|
-
import {
|
|
3
|
+
import { equationFromSignTable } from "../exercises/math/index.js";
|
|
4
4
|
try {
|
|
5
|
-
buildPdfForExercise(
|
|
5
|
+
buildPdfForExercise(equationFromSignTable);
|
|
6
6
|
}
|
|
7
7
|
catch (err) {
|
|
8
8
|
console.log(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPDFForExercise.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/buildPDFForExercise.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAe,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"buildPDFForExercise.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/buildPDFForExercise.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAe,MAAM,6BAA6B,CAAC;AAQpE,eAAO,MAAM,mBAAmB,GAAI,KAAK,QAAQ,CAAC,MAAM,CAAC,SA8LxD,CAAC"}
|
|
@@ -10,6 +10,7 @@ import path from "path";
|
|
|
10
10
|
import { signTableToLatex } from "./signTableToLatex.js";
|
|
11
11
|
import { varTableToLatex } from "./varTableToLatex.js";
|
|
12
12
|
import { valueTableToLatex } from "./valueTableToLatex.js";
|
|
13
|
+
import { signVarTableToLatex } from "./signVarTableToLatex.js";
|
|
13
14
|
export const buildPdfForExercise = (exo) => {
|
|
14
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
16
|
const __dirname = path.dirname(__filename);
|
|
@@ -39,6 +40,11 @@ export const buildPdfForExercise = (exo) => {
|
|
|
39
40
|
for (const match of varTableMatches) {
|
|
40
41
|
question.instruction = question.instruction.replace(match[0], varTableToLatex(JSON.parse(match[1])));
|
|
41
42
|
}
|
|
43
|
+
const signVarTableRegex = /<svg id=["']signVarTable["']>([\s\S]*?)<\/svg>/g;
|
|
44
|
+
const signVarTableMatches = question.instruction.matchAll(signVarTableRegex);
|
|
45
|
+
for (const match of signVarTableMatches) {
|
|
46
|
+
question.instruction = question.instruction.replace(match[0], signVarTableToLatex(JSON.parse(match[1])));
|
|
47
|
+
}
|
|
42
48
|
const formatted = formatMarkdownToLatex(question.instruction);
|
|
43
49
|
content += `
|
|
44
50
|
${formatted} \n
|
|
@@ -55,11 +61,15 @@ export const buildPdfForExercise = (exo) => {
|
|
|
55
61
|
// content += mdTableToLatexTabular(question.initTable)
|
|
56
62
|
content += valueTableToLatex(question.initTable);
|
|
57
63
|
}
|
|
64
|
+
if (exo.answerType === "signVarTable") {
|
|
65
|
+
content += signVarTableToLatex(question.initTable, true);
|
|
66
|
+
}
|
|
58
67
|
}
|
|
59
68
|
if (exo.answerType !== "GGB" &&
|
|
60
69
|
exo.answerType !== "valueTable" &&
|
|
61
70
|
exo.answerType !== "signTable" &&
|
|
62
|
-
exo.answerType !== "varTable"
|
|
71
|
+
exo.answerType !== "varTable" &&
|
|
72
|
+
exo.answerType !== "signVarTable") {
|
|
63
73
|
propositions = exo.getPropositions(4, {
|
|
64
74
|
answer: question.answer,
|
|
65
75
|
...question.identifiers,
|
|
@@ -102,6 +112,9 @@ export const buildPdfForExercise = (exo) => {
|
|
|
102
112
|
else if (exo.answerType === "varTable") {
|
|
103
113
|
content += varTableToLatex(question.answerTable);
|
|
104
114
|
}
|
|
115
|
+
else if (exo.answerType === "signVarTable") {
|
|
116
|
+
content += signVarTableToLatex(question.answerTable);
|
|
117
|
+
}
|
|
105
118
|
else if (exo.answerType === "valueTable") {
|
|
106
119
|
// à mettre dans la correction direct
|
|
107
120
|
}
|
|
@@ -119,6 +132,9 @@ export const buildPdfForExercise = (exo) => {
|
|
|
119
132
|
else if (exo.answerType === "varTable") {
|
|
120
133
|
content += varTableToLatex(question.answerTable);
|
|
121
134
|
}
|
|
135
|
+
else if (exo.answerType === "signVarTable") {
|
|
136
|
+
content += signVarTableToLatex(question.answerTable);
|
|
137
|
+
}
|
|
122
138
|
else if (exo.answerType === "valueTable") {
|
|
123
139
|
// à mettre dans la correction direct
|
|
124
140
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dollarizeString.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/dollarizeString.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM,WAIxC,CAAC"}
|
|
@@ -6,7 +6,7 @@ export const signTableToLatex = (arr, isInput = false) => {
|
|
|
6
6
|
return `\n \n
|
|
7
7
|
\\begin{tikzpicture}
|
|
8
8
|
\\tkzTabInit${size}{${arr
|
|
9
|
-
.map((row) => `${dollarize(row[0])} /1`)
|
|
9
|
+
.map((row) => `${dollarize(row[0].replaceAll("£", "$"))} /1`)
|
|
10
10
|
.join(",")}}{${arr[0]
|
|
11
11
|
.slice(1)
|
|
12
12
|
.filter((e) => e !== "\\ ")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signVarTableToLatex.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/signVarTableToLatex.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,EAAE,EAAE,EAAE,iBAAe,WAmDnE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { dollarizeString } from "./dollarizeString.js";
|
|
2
|
+
export const signVarTableToLatex = (arr, isInput = false) => {
|
|
3
|
+
if (isInput)
|
|
4
|
+
return getInputVarTable(arr);
|
|
5
|
+
const headers = [
|
|
6
|
+
arr[0][0].replaceAll("£", "$"),
|
|
7
|
+
arr[1][0].replaceAll("£", "$"),
|
|
8
|
+
arr[3][0].replaceAll("£", "$"),
|
|
9
|
+
];
|
|
10
|
+
const formated = [];
|
|
11
|
+
for (let i = 1; i < arr[3].length; i++) {
|
|
12
|
+
const value = arr[2][i] !== "\\ "
|
|
13
|
+
? arr[2][i]
|
|
14
|
+
: arr[3][i] !== "\\ "
|
|
15
|
+
? arr[3][i]
|
|
16
|
+
: arr[4][i];
|
|
17
|
+
formated.push(value);
|
|
18
|
+
}
|
|
19
|
+
const varLine = [];
|
|
20
|
+
for (let i = 0; i < formated.length; i++) {
|
|
21
|
+
const current = formated[i];
|
|
22
|
+
if (current === "\\nearrow" || current === "\\searrow")
|
|
23
|
+
continue;
|
|
24
|
+
if (i === formated.length - 1) {
|
|
25
|
+
const prev = formated[i - 1];
|
|
26
|
+
varLine.push(`${prev === "\\nearrow" ? "+" : "-"}/ ${dollarizeString(current)}`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const next = formated[i + 1];
|
|
30
|
+
varLine.push(`${next === "\\nearrow" ? "-" : "+"}/ ${dollarizeString(current)}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return `\n \n
|
|
34
|
+
\\begin{tikzpicture}
|
|
35
|
+
|
|
36
|
+
\\tkzTab[lgt=1.5,espcl=1.5]{${headers[0]}/1, ${headers[1]}/1, ${headers[2]}/1.5}{${arr[0]
|
|
37
|
+
.slice(1)
|
|
38
|
+
.filter((e) => e !== "\\ ")
|
|
39
|
+
.map((e) => dollarizeString(e))
|
|
40
|
+
.join(",")}}{${arr[1]
|
|
41
|
+
.slice(1)
|
|
42
|
+
.map((e) => (e === "\\" ? "," : e))
|
|
43
|
+
.join(",")}}{${varLine.join(",")}}
|
|
44
|
+
\\end{tikzpicture} \n \n
|
|
45
|
+
`;
|
|
46
|
+
};
|
|
47
|
+
const getInputVarTable = (arr) => {
|
|
48
|
+
const width = arr[0].length;
|
|
49
|
+
const alignement = "|c|" + "c".repeat(width - 1) + "|";
|
|
50
|
+
const res = ` \\begin{center}\\begin{tabular}{${alignement}} \n \\hline ` +
|
|
51
|
+
arr.map((row, i) => formatRow(row, i)).join(" \\tabularnewline ") +
|
|
52
|
+
"\\tabularnewline \\hline \\end{tabular}\\end{center} ";
|
|
53
|
+
return res;
|
|
54
|
+
};
|
|
55
|
+
const formatRow = (row, i) => {
|
|
56
|
+
return ((i === 1 || i === 2 ? "\\hline " : "") +
|
|
57
|
+
row.map((el) => dollarizeString(el)).join(" & "));
|
|
58
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"varTableToLatex.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/varTableToLatex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,EAAE,EAAE,iBAAe,
|
|
1
|
+
{"version":3,"file":"varTableToLatex.d.ts","sourceRoot":"","sources":["../../../src/tests/pdfs/varTableToLatex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,EAAE,EAAE,iBAAe,WA8C/D,CAAC"}
|
|
@@ -28,11 +28,11 @@ export const varTableToLatex = (arr, isInput = false) => {
|
|
|
28
28
|
return `\n \n
|
|
29
29
|
\\begin{tikzpicture}
|
|
30
30
|
\\tkzTabInit[lgt=1.5,espcl=1.5]{${final
|
|
31
|
-
.map((row, i) => `${dollarize(row[0])} /${i === 0 ? "1" : "1.5"}`)
|
|
31
|
+
.map((row, i) => `${dollarize(row[0].replaceAll("£", "$"))} /${i === 0 ? "1" : "1.5"}`)
|
|
32
32
|
.join(",")}}{${final[0]
|
|
33
33
|
.slice(1)
|
|
34
34
|
.filter((e) => e !== " ")
|
|
35
|
-
.map((e) => dollarize(e))
|
|
35
|
+
.map((e) => dollarize(e.replaceAll("£", "$")))
|
|
36
36
|
.join(",")}}
|
|
37
37
|
\\tkzTabVar{${varLine.join(",")}}
|
|
38
38
|
\\end{tikzpicture} \n \n
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questionTest.d.ts","sourceRoot":"","sources":["../../src/tests/questionTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKjE,eAAO,MAAM,YAAY,GACvB,KAAK,QAAQ,CAAC,MAAM,CAAC,EACrB,UAAU,QAAQ,CAAC,MAAM,CAAC;;;
|
|
1
|
+
{"version":3,"file":"questionTest.d.ts","sourceRoot":"","sources":["../../src/tests/questionTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKjE,eAAO,MAAM,YAAY,GACvB,KAAK,QAAQ,CAAC,MAAM,CAAC,EACrB,UAAU,QAAQ,CAAC,MAAM,CAAC;;;CAyQ3B,CAAC"}
|
|
@@ -47,7 +47,8 @@ export const questionTest = (exo, question) => {
|
|
|
47
47
|
if (question.initTable?.length &&
|
|
48
48
|
exo.answerType !== "valueTable" &&
|
|
49
49
|
exo.answerType !== "varTable" &&
|
|
50
|
-
exo.answerType !== "signTable"
|
|
50
|
+
exo.answerType !== "signTable" &&
|
|
51
|
+
exo.answerType !== "signVarTable") {
|
|
51
52
|
throw new Error(`exo ${exo.id} has init table but is not tableExo`);
|
|
52
53
|
}
|
|
53
54
|
if (exo.answerType === "GGB") {
|
|
@@ -58,7 +59,8 @@ export const questionTest = (exo, question) => {
|
|
|
58
59
|
}
|
|
59
60
|
else if (exo.answerType === "valueTable" ||
|
|
60
61
|
exo.answerType === "varTable" ||
|
|
61
|
-
exo.answerType === "signTable"
|
|
62
|
+
exo.answerType === "signTable" ||
|
|
63
|
+
exo.answerType === "signVarTable") {
|
|
62
64
|
if (!question.answerTable?.length)
|
|
63
65
|
throw new Error(`exo ${exo.id} has no answerTable`);
|
|
64
66
|
if (!question.initTable?.length)
|
|
@@ -152,7 +154,8 @@ export const questionTest = (exo, question) => {
|
|
|
152
154
|
exo.answerType !== "GGB" &&
|
|
153
155
|
exo.answerType !== "valueTable" &&
|
|
154
156
|
exo.answerType !== "signTable" &&
|
|
155
|
-
exo.answerType !== "varTable"
|
|
157
|
+
exo.answerType !== "varTable" &&
|
|
158
|
+
exo.answerType !== "signVarTable") {
|
|
156
159
|
if (!question.keys)
|
|
157
160
|
throw new Error(`exo ${exo.id} has no keys`);
|
|
158
161
|
const answer = question.answer;
|
|
@@ -168,7 +171,8 @@ export const questionTest = (exo, question) => {
|
|
|
168
171
|
exo.answerType !== "GGB" &&
|
|
169
172
|
exo.answerType !== "valueTable" &&
|
|
170
173
|
exo.answerType !== "varTable" &&
|
|
171
|
-
exo.answerType !== "signTable"
|
|
174
|
+
exo.answerType !== "signTable" &&
|
|
175
|
+
exo.answerType !== "signVarTable") {
|
|
172
176
|
if (exo.answerType === "QCM" && !exo.isQCM)
|
|
173
177
|
throw new Error("exo " + exo.id + " has answerType QCM but not isQCM");
|
|
174
178
|
const before = Date.now();
|