math-exercises 3.0.119 → 3.0.120
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/calculLitteral/formulas/useFormula.d.ts +1 -10
- package/lib/exercises/math/calculLitteral/formulas/useFormula.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/formulas/useFormula.js +21 -6
- package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.js +1 -1
- package/lib/index.d.ts +1 -7
- package/lib/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
-
import { KeyId } from "../../../../types/keyIds.js";
|
|
4
|
-
import { KeyProps } from "../../../../types/keyProps.js";
|
|
5
|
-
type Formula = {
|
|
6
|
-
title: string;
|
|
7
|
-
func: (variables: NodeIdentifiers[]) => NodeIdentifiers;
|
|
8
|
-
variables: NodeIdentifiers[];
|
|
9
|
-
variableNames: string[];
|
|
10
|
-
keys: (KeyId | KeyProps)[];
|
|
11
|
-
};
|
|
12
3
|
type Identifiers = {
|
|
13
|
-
|
|
4
|
+
formulaId: string;
|
|
14
5
|
values: NodeIdentifiers[];
|
|
15
6
|
};
|
|
16
7
|
export declare const useFormula: Exercise<Identifiers>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/formulas/useFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"useFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/formulas/useFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAsI7C,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B,CAAC;AAoKF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAkB5C,CAAC"}
|
|
@@ -13,6 +13,7 @@ import { random } from "../../../../utils/alea/random.js";
|
|
|
13
13
|
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
14
14
|
const FORMULAS = [
|
|
15
15
|
{
|
|
16
|
+
id: "sphere",
|
|
16
17
|
title: "Le volume d'une sphère",
|
|
17
18
|
func: (vars) => multiply(frac(4, 3), multiply(PiNode, power(reifyAlgebraic(vars[0]), 3))).toIdentifiers(),
|
|
18
19
|
variables: [new VariableNode("r").toIdentifiers()],
|
|
@@ -20,6 +21,7 @@ const FORMULAS = [
|
|
|
20
21
|
keys: ["pi"],
|
|
21
22
|
},
|
|
22
23
|
{
|
|
24
|
+
id: "cone",
|
|
23
25
|
title: "Le volume d'un cône",
|
|
24
26
|
func: (vars) => frac(multiply(PiNode, multiply(square(reifyAlgebraic(vars[0])), reifyAlgebraic(vars[1]))), 3).toIdentifiers(),
|
|
25
27
|
variables: [
|
|
@@ -30,6 +32,7 @@ const FORMULAS = [
|
|
|
30
32
|
keys: ["pi"],
|
|
31
33
|
},
|
|
32
34
|
{
|
|
35
|
+
id: "pyramide",
|
|
33
36
|
title: "Le volume d'une pyramide",
|
|
34
37
|
func: (vars) => multiply(frac(1, 3), multiply(reifyAlgebraic(vars[0]), reifyAlgebraic(vars[1]))).toIdentifiers(),
|
|
35
38
|
variables: [
|
|
@@ -91,8 +94,15 @@ const FORMULAS = [
|
|
|
91
94
|
// keys: [],
|
|
92
95
|
// },
|
|
93
96
|
];
|
|
94
|
-
const
|
|
97
|
+
const rebuildIdentifiers = (oldIds) => {
|
|
98
|
+
return {
|
|
99
|
+
formulaId: FORMULAS.find((f) => f.title === oldIds.formula.title)?.id ?? "sphere",
|
|
100
|
+
values: oldIds.values,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const getPropositions = (n, { answer, formulaId, values }) => {
|
|
95
104
|
const propositions = [];
|
|
105
|
+
const formula = FORMULAS.find((f) => f.id === formulaId);
|
|
96
106
|
addValidProp(propositions, answer);
|
|
97
107
|
tryToAddWrongProp(propositions, reifyAlgebraic(formula.func(values.map((x) => multiply(reifyAlgebraic(x), -1)
|
|
98
108
|
.simplify(SIMPLIFY_OPTIONS)
|
|
@@ -115,13 +125,15 @@ const SIMPLIFY_OPTIONS = {
|
|
|
115
125
|
distributePowersOnFrac: true,
|
|
116
126
|
};
|
|
117
127
|
const getAnswer = (identifiers) => {
|
|
118
|
-
const {
|
|
128
|
+
const { formulaId, values } = identifiers;
|
|
129
|
+
const formula = FORMULAS.find((f) => f.id === formulaId);
|
|
119
130
|
return reifyAlgebraic(formula.func(values))
|
|
120
131
|
.simplify(SIMPLIFY_OPTIONS)
|
|
121
132
|
.toTex();
|
|
122
133
|
};
|
|
123
134
|
const getInstruction = (identifiers) => {
|
|
124
|
-
const {
|
|
135
|
+
const { formulaId, values } = identifiers;
|
|
136
|
+
const formula = FORMULAS.find((f) => f.id === formulaId);
|
|
125
137
|
const valuesString = [];
|
|
126
138
|
for (let i = 0; i < formula.variables.length; i++) {
|
|
127
139
|
valuesString.push(`${formula.variableNames[i]} vaut $${reifyAlgebraic(values[i]).toTex()}$`);
|
|
@@ -144,7 +156,8 @@ const getHint = () => {
|
|
|
144
156
|
return `Dans la formule, remplace les variables par les valeurs données dans l'énoncé.`;
|
|
145
157
|
};
|
|
146
158
|
const getCorrection = (identifiers) => {
|
|
147
|
-
const {
|
|
159
|
+
const { formulaId, values } = identifiers;
|
|
160
|
+
const formula = FORMULAS.find((f) => f.id === formulaId);
|
|
148
161
|
const substitutions = [];
|
|
149
162
|
for (let i = 0; i < formula.variables.length; i++) {
|
|
150
163
|
substitutions.push(`- $${reifyAlgebraic(formula.variables[i]).toTex()} = ${reifyAlgebraic(values[i]).toTex()}$`);
|
|
@@ -160,7 +173,8 @@ ${reifyAlgebraic(formula.func(values)).toTex()} = ${getAnswer(identifiers)}
|
|
|
160
173
|
$$`;
|
|
161
174
|
};
|
|
162
175
|
const getKeys = (identifiers) => {
|
|
163
|
-
|
|
176
|
+
const formula = FORMULAS.find((f) => f.id === identifiers.formulaId);
|
|
177
|
+
return formula.keys;
|
|
164
178
|
};
|
|
165
179
|
const isAnswerValid = (ans, { answer }) => {
|
|
166
180
|
try {
|
|
@@ -175,7 +189,7 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
175
189
|
const getUseFormulaQuestion = () => {
|
|
176
190
|
const formula = random(FORMULAS);
|
|
177
191
|
const values = formula.variables.map(() => new NumberNode(randint(1, 10)).toIdentifiers());
|
|
178
|
-
const identifiers = { formula, values };
|
|
192
|
+
const identifiers = { formulaId: formula.id, values };
|
|
179
193
|
return getQuestionFromIdentifiers(identifiers);
|
|
180
194
|
};
|
|
181
195
|
const getQuestionFromIdentifiers = (identifiers) => {
|
|
@@ -205,4 +219,5 @@ export const useFormula = {
|
|
|
205
219
|
getAnswer,
|
|
206
220
|
getQuestionFromIdentifiers,
|
|
207
221
|
hasHintAndCorrection: true,
|
|
222
|
+
rebuildIdentifiers: rebuildIdentifiers,
|
|
208
223
|
};
|
|
@@ -201,7 +201,7 @@ const isAnswerValid = (ans, { answer, reactionProduct, vA, vB, cB }) => {
|
|
|
201
201
|
};
|
|
202
202
|
export const titrationEquivalenceRelation = {
|
|
203
203
|
id: "titrationEquivalenceRelation",
|
|
204
|
-
label: "Calculer la concentration d'un element titré à l'aide d'une équation de réaction d'un mélange stœchiométrique
|
|
204
|
+
label: "Calculer la concentration d'un element titré à l'aide d'une équation de réaction d'un mélange stœchiométrique",
|
|
205
205
|
isSingleStep: true,
|
|
206
206
|
generator: (nb) => getDistinctQuestions(getTitrationEquivalenceRelationQuestion, nb, 10),
|
|
207
207
|
qcmTimer: 60,
|
package/lib/index.d.ts
CHANGED
|
@@ -529,13 +529,7 @@ declare const mathExercises: (Exercise<{
|
|
|
529
529
|
x: number;
|
|
530
530
|
y: number;
|
|
531
531
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
532
|
-
|
|
533
|
-
title: string;
|
|
534
|
-
func: (variables: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[]) => import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
535
|
-
variables: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
536
|
-
variableNames: string[];
|
|
537
|
-
keys: (import("./types/keyIds.js").KeyId | import("./types/keyProps.js").KeyProps)[];
|
|
538
|
-
};
|
|
532
|
+
formulaId: string;
|
|
539
533
|
values: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
540
534
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
541
535
|
word: string;
|
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,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa
|
|
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,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0EAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "math-exercises",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.120",
|
|
5
5
|
"description": "Math exercises generator for middle school and high school",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"testexo": "npm run build && node lib/tests/singleExo.test.js",
|
|
14
14
|
"test": "npm run build && node lib/tests/global.test.js",
|
|
15
15
|
"testmega": "npm run build && node lib/tests/mega.test.js",
|
|
16
|
-
"testml": "npm run build && node lib/tests/ml.test.js",
|
|
16
|
+
"testml": "npx eslint && npm run build && node lib/tests/ml.test.js",
|
|
17
17
|
"testmegaml": "npm run build && node lib/tests/megaml.test.js",
|
|
18
18
|
"testxl": "npm run build && node lib/tests/xl.test.js",
|
|
19
19
|
"testmegaxl": "npm run build && node lib/tests/megaxl.test.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"testsimplify": "npx jest simplify.test.js",
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
24
24
|
"build": "tsc && tsc-alias",
|
|
25
|
-
"patch": "npm run testml && npm version patch && npm publish"
|
|
25
|
+
"patch": "npx eslint && npm run testml && npm version patch && npm publish"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [],
|
|
28
28
|
"author": "Heureux Hasard",
|