math-exercises 3.0.17 → 3.0.19

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.
@@ -5,4 +5,5 @@ export * from "./scaleUsage.js";
5
5
  export * from "./isTableProportionalNonInteger.js";
6
6
  export * from "./findCoeffInProportionalTableNonIntegers.js";
7
7
  export * from "./isTableProportional.js";
8
+ export * from "./rectangleSideAfterReduction.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC"}
@@ -5,3 +5,4 @@ export * from "./scaleUsage.js";
5
5
  export * from "./isTableProportionalNonInteger.js";
6
6
  export * from "./findCoeffInProportionalTableNonIntegers.js";
7
7
  export * from "./isTableProportional.js";
8
+ export * from "./rectangleSideAfterReduction.js";
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lengths: number[];
4
+ };
5
+ export declare const rectangleSideAfterReduction: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=rectangleSideAfterReduction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectangleSideAfterReduction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/rectangleSideAfterReduction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CAGnB,CAAC;AA8OF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAmB7D,CAAC"}
@@ -0,0 +1,198 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ import { D3Node } from "d3-node";
9
+ const getPropositions = (n, { answer, ...identifiers }) => {
10
+ const propositions = [];
11
+ const { lengths } = identifiers;
12
+ const [a, b, c, d] = lengths;
13
+ addValidProp(propositions, answer);
14
+ const askedIndex = lengths.findIndex((e) => !e);
15
+ switch (askedIndex) {
16
+ case 0:
17
+ tryToAddWrongProp(propositions, c + (b - d) + "");
18
+ tryToAddWrongProp(propositions, round((b * d) / c, 1).frenchify());
19
+ tryToAddWrongProp(propositions, round((c * d) / b, 1).frenchify());
20
+ break;
21
+ case 1:
22
+ tryToAddWrongProp(propositions, d + (a - c) + "");
23
+ tryToAddWrongProp(propositions, round((c * d) / a, 1).frenchify());
24
+ tryToAddWrongProp(propositions, round((a * c) / d, 1).frenchify());
25
+ break;
26
+ case 2:
27
+ tryToAddWrongProp(propositions, a - (b - d) + "");
28
+ tryToAddWrongProp(propositions, round((b * d) / a, 1).frenchify());
29
+ tryToAddWrongProp(propositions, round((a * b) / d, 1).frenchify());
30
+ break;
31
+ case 3:
32
+ tryToAddWrongProp(propositions, b - (a - c) + "");
33
+ tryToAddWrongProp(propositions, round((a * c) / b, 1).frenchify());
34
+ tryToAddWrongProp(propositions, round((a * b) / c, 1).frenchify());
35
+ default:
36
+ break;
37
+ }
38
+ while (propositions.length < n) {
39
+ tryToAddWrongProp(propositions, randfloat(2, 10, 1).frenchify());
40
+ }
41
+ return shuffleProps(propositions, n);
42
+ };
43
+ const getAnswer = (identifiers) => {
44
+ const { lengths } = identifiers;
45
+ const [a, b, c, d] = lengths;
46
+ const asked = lengths.findIndex((e) => !e);
47
+ switch (asked) {
48
+ case 0:
49
+ //a = bc/d
50
+ return round((b * c) / d, 1).frenchify();
51
+ case 1:
52
+ //b = da/c
53
+ return round((d * a) / c, 1).frenchify();
54
+ case 2:
55
+ //c = ad/b
56
+ return round((a * d) / b, 1).frenchify();
57
+ case 3:
58
+ default:
59
+ //d = bc/a
60
+ return round((b * c) / a, 1).frenchify();
61
+ }
62
+ };
63
+ const getInstruction = (identifiers) => {
64
+ const { lengths } = identifiers;
65
+ const [a, b, c, d] = lengths;
66
+ const askedIndex = lengths.findIndex((e) => !e);
67
+ // Create d3-node instance
68
+ const d3n = new D3Node();
69
+ // Set SVG dimensions
70
+ const width = 300, height = 150;
71
+ const svg = d3n.createSVG(width, height, { id: "nonLatex" });
72
+ // Function to add rotated rectangles
73
+ function addRectangle(svg, x, y, w, h, angle, color, label1, label2) {
74
+ const group = svg
75
+ .append("g")
76
+ .attr("transform", `translate(${x},${y}) rotate(${angle})`);
77
+ group
78
+ .append("rect")
79
+ .attr("width", w)
80
+ .attr("height", h)
81
+ .attr("fill", color)
82
+ .attr("fill-opacity", 0.3)
83
+ .attr("stroke", color)
84
+ .attr("stroke-width", 2);
85
+ // Add side labels
86
+ group
87
+ .append("text")
88
+ .attr("x", w + 5)
89
+ .attr("y", h / 2)
90
+ .attr("fill", color)
91
+ .attr("font-size", "14px")
92
+ .attr("font-weight", "bold")
93
+ .text(label1);
94
+ group
95
+ .append("text")
96
+ .attr("x", w / 2 - 5)
97
+ .attr("y", h + 18)
98
+ .attr("fill", color)
99
+ .attr("font-size", "14px")
100
+ .attr("font-weight", "bold")
101
+ .text(label2);
102
+ }
103
+ // Add first rectangle (red) - Bigger
104
+ addRectangle(svg, 60, 60, 120, 40, -20, "red", b === 0 ? "?" : b + "", a === 0 ? "?" : a + "");
105
+ // Add second rectangle (blue) - Smaller
106
+ addRectangle(svg, 190, 90, 80, 25, -20, "blue", d === 0 ? "?" : d + "", c === 0 ? "?" : c + "");
107
+ // Output the SVG string
108
+ const sideIsOnFirstRect = askedIndex < 2;
109
+ const sideTypeAsked = askedIndex % 2 === 0 ? "longueur" : "largeur";
110
+ const sidesString = lengths.map((e, i) => e === 0 ? "" : `${i % 2 === 0 ? "longueur" : "largeur"} $${e}$ cm`);
111
+ return `Sur la figure suivante, le premier rectangle a pour ${sideIsOnFirstRect
112
+ ? sidesString[askedIndex === 1 ? 0 : 1]
113
+ : sidesString[0] + " et pour " + sidesString[1]}.
114
+
115
+ Le deuxième rectangle est une réduction du premier rectangle et a pour ${sideIsOnFirstRect
116
+ ? sidesString[2] + " et pour " + sidesString[3]
117
+ : sidesString[askedIndex === 3 ? 2 : 3]}.
118
+
119
+ ${d3n.svgString()}
120
+
121
+ Quelle est la ${sideTypeAsked} (en cm) du ${sideIsOnFirstRect ? "premier" : "deuxième"} rectangle ? Arrondir à $0,1$ cm si nécessaire.`;
122
+ };
123
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
124
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
125
+ const getKeys = (identifiers) => {
126
+ return [];
127
+ };
128
+ const isAnswerValid = (ans, { answer }) => {
129
+ try {
130
+ return numberVEA(ans, answer, 1);
131
+ }
132
+ catch (err) {
133
+ return handleVEAError(err);
134
+ }
135
+ };
136
+ const getRectangleSideAfterReductionQuestion = (ops) => {
137
+ const askedSize = randint(0, 4);
138
+ let a;
139
+ let b;
140
+ let c;
141
+ let d;
142
+ switch (askedSize) {
143
+ case 0:
144
+ a = 0;
145
+ c = randint(3, 10);
146
+ d = randint(1, c);
147
+ b = randint(d + 1, 15);
148
+ break;
149
+ case 1:
150
+ b = 0;
151
+ c = randint(3, 10);
152
+ d = randint(1, c);
153
+ a = randint(c + 1, 15);
154
+ break;
155
+ case 2:
156
+ c = 0;
157
+ a = randint(5, 10);
158
+ b = randint(2, a);
159
+ d = randint(1, b);
160
+ break;
161
+ case 3:
162
+ default:
163
+ d = 0;
164
+ a = randint(5, 10);
165
+ b = randint(2, a);
166
+ c = randint(3, a);
167
+ break;
168
+ }
169
+ const identifiers = {
170
+ lengths: [a, b, c, d],
171
+ };
172
+ const question = {
173
+ answer: getAnswer(identifiers),
174
+ instruction: getInstruction(identifiers),
175
+ keys: getKeys(identifiers),
176
+ answerFormat: "tex",
177
+ identifiers,
178
+ // hint: getHint(identifiers),
179
+ // correction: getCorrection(identifiers),
180
+ };
181
+ return question;
182
+ };
183
+ export const rectangleSideAfterReduction = {
184
+ id: "rectangleSideAfterReduction",
185
+ // connector: "",
186
+ label: "Déterminer les dimensions d'un rectangle après réduction",
187
+ isSingleStep: true,
188
+ generator: (nb, opts) => getDistinctQuestions(() => getRectangleSideAfterReductionQuestion(opts), nb),
189
+ qcmTimer: 60,
190
+ freeTimer: 60,
191
+ getPropositions,
192
+ isAnswerValid,
193
+ subject: "Mathématiques",
194
+ getInstruction,
195
+ // getHint,
196
+ // getCorrection,
197
+ getAnswer,
198
+ };
package/lib/index.d.ts CHANGED
@@ -163,6 +163,8 @@ declare const mathExercises: (Exercise<{
163
163
  }> | Exercise<{
164
164
  xValues: number[];
165
165
  yValues: number[];
166
+ }, {}> | Exercise<{
167
+ lengths: number[];
166
168
  }, {}> | Exercise<{
167
169
  precisionAsked: number;
168
170
  decimal: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":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Q,EAAE,cAAc,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"latexTester.d.ts","sourceRoot":"","sources":["../src/latexTester.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,2CAkJxC,CAAC"}
1
+ {"version":3,"file":"latexTester.d.ts","sourceRoot":"","sources":["../src/latexTester.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,2CAsJxC,CAAC"}
@@ -5,11 +5,12 @@ export const latexTester = (latex, isDefaultInMathMode = false) => {
5
5
  let leftRightCount = 0;
6
6
  let inArray = false;
7
7
  let inPython = false;
8
- for (let i = 0; i < latex.length; i++) {
9
- const prevChar = latex[i - 1];
10
- const char = latex[i];
11
- const nextChar = latex[i + 1];
12
- const nextNextChar = latex[i + 2];
8
+ const formated = latex.replace(/<svg[\s\S]*?<\/svg>/g, "");
9
+ for (let i = 0; i < formated.length; i++) {
10
+ const prevChar = formated[i - 1];
11
+ const char = formated[i];
12
+ const nextChar = formated[i + 1];
13
+ const nextNextChar = formated[i + 2];
13
14
  if (char === "$") {
14
15
  if (isDefaultInMathMode)
15
16
  throw new Error("Dollar in default math mode");
@@ -63,13 +64,13 @@ export const latexTester = (latex, isDefaultInMathMode = false) => {
63
64
  if (char === "}" && prevChar !== "\\" && !inPython) {
64
65
  commandModeCount--;
65
66
  }
66
- const substring = latex.substring(i);
67
+ const substring = formated.substring(i);
67
68
  if ((inDollarMode || inDoubleDollarMode) && char === "\n") {
68
69
  let isEmptyLine = true;
69
- for (let j = i + 1; j < latex.length; j++) {
70
- if (latex[j] === "\n")
70
+ for (let j = i + 1; j < formated.length; j++) {
71
+ if (formated[j] === "\n")
71
72
  break;
72
- if (latex[j] !== " " && latex[j] !== "\t") {
73
+ if (formated[j] !== " " && formated[j] !== "\t") {
73
74
  isEmptyLine = false;
74
75
  break;
75
76
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.17",
4
+ "version": "3.0.19",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [
@@ -18,7 +18,8 @@
18
18
  "testpdf": "npm run build && node lib/tests/pdfExo.test.js",
19
19
  "testsimplify": "npx jest simplify.test.js",
20
20
  "prepublishOnly": "npm run build",
21
- "build": "tsc && tsc-alias"
21
+ "build": "tsc && tsc-alias",
22
+ "patch": "npm version patch && npm publish"
22
23
  },
23
24
  "keywords": [],
24
25
  "author": "Heureux Hasard",