math-exercises 3.0.217 → 3.0.218
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/calcul/arithmetics/commonDivisorsList.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/commonDivisorsList.js +1 -0
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.js +5 -8
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.js +7 -17
- package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.js +5 -6
- package/lib/exercises/math/calcul/fractions/fractionsDivision.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsDivision.js +7 -17
- package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSum.js +7 -22
- package/lib/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.js +7 -19
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +7 -22
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +7 -22
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts +4 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +7 -23
- package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.js +3 -7
- package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/simplifyFraction.js +6 -7
- package/lib/exercises/math/calcul/mentalCaluls/mentalDivisions.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalDivisions.js +3 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.js +2 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.js +2 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.js +2 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +2 -4
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.js +3 -4
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.js +14 -3
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +14 -3
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.js +8 -5
- package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.js +14 -5
- package/lib/exercises/math/calculLitteral/equation/fractionEquation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/fractionEquation.js +10 -10
- package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts +0 -8
- package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoByXK.js +223 -190
- package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.js +22 -9
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +0 -1
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -1
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.js +10 -4
- package/lib/exercises/math/functions/absolute/absoluteValueEquations.js +12 -12
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +10 -18
- package/lib/exercises/math/functions/affines/affineMeanValue.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineMeanValue.js +3 -5
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +0 -1
- package/lib/exercises/math/functions/basics/twoFunctionsEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/twoFunctionsEquation.js +12 -7
- package/lib/exercises/math/functions/integral/integralExpAxPlusB.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralExpAxPlusB.js +19 -3
- package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/log10Simplifying.js +20 -6
- package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/logSimplifiying.js +14 -9
- package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.d.ts.map +1 -1
- package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.js +9 -6
- package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +12 -8
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.js +21 -4
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.js +4 -7
- package/lib/exercises/math/functions/trinoms/trinomialMeanValue.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/trinomialMeanValue.js +3 -5
- package/lib/exercises/math/geometry/areas/circleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/circleArea.js +4 -2
- package/lib/exercises/math/geometry/areas/rectangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/rectangleArea.js +4 -2
- package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/rightTriangleArea.js +14 -11
- package/lib/exercises/math/geometry/areas/squareArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/squareArea.js +4 -2
- package/lib/exercises/math/geometry/areas/squareSideFromArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/squareSideFromArea.js +6 -4
- package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/triangleArea.js +3 -1
- package/lib/exercises/math/geometry/areas/triangleAreaV2.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/triangleAreaV2.js +4 -2
- package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/midpoint.js +6 -11
- package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.js +3 -3
- package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.js +3 -3
- package/lib/exercises/math/geometry/vectors/vectorNormCalculation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/vectorNormCalculation.js +3 -5
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +3 -4
- package/lib/exercises/math/geometry/volumes/sphereVolume.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/sphereVolume.js +3 -4
- package/lib/exercises/math/geometry/volumes/volumeOfCube.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/volumeOfCube.js +3 -4
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.js +3 -6
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.js +3 -6
- package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.js +3 -1
- package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.js +19 -42
- package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts +0 -2
- package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsCheckIsSameGraph.js +4 -14
- package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.js +3 -1
- package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsDegreeOfVertex.js +3 -1
- package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsOrderOfGraph.js +3 -1
- package/lib/exercises/math/limits/rationalFracLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/rationalFracLimit.js +9 -20
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +9 -20
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +11 -28
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.js +12 -27
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +3 -5
- package/lib/exercises/math/squareRoots/simpifySquareRoot.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/simpifySquareRoot.js +5 -4
- package/lib/exercises/math/squareRoots/squareRootEquation.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootEquation.js +9 -8
- package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootIdentities.js +7 -4
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +7 -8
- package/lib/exercises/math/trigonometry/arcLength.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/arcLength.js +3 -8
- package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.d.ts.map +1 -1
- package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.js +0 -6
- package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
- package/lib/exercises/pc/dosage/beerLambertRandomValue.js +3 -4
- package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
- package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +3 -18
- package/lib/exercises/pc/energy/energyTransfer.d.ts.map +1 -1
- package/lib/exercises/pc/energy/energyTransfer.js +3 -8
- package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.d.ts.map +1 -1
- package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.js +3 -24
- package/lib/exercises/pc/math/proportionnalityCoeffFromLine.d.ts.map +1 -1
- package/lib/exercises/pc/math/proportionnalityCoeffFromLine.js +9 -6
- package/lib/exercises/vea/equationVEA.d.ts.map +1 -1
- package/lib/exercises/vea/equationVEA.js +2 -0
- package/lib/exercises/vea/rationalVEA.d.ts +2 -1
- package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
- package/lib/exercises/vea/rationalVEA.js +36 -2
- package/lib/index.d.ts +3 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/math/utils/graphs/graphRenderer.d.ts +7 -9
- package/lib/math/utils/graphs/graphRenderer.d.ts.map +1 -1
- package/lib/math/utils/graphs/graphRenderer.js +25 -117
- package/lib/tree/nodes/algebraicNode.d.ts +2 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/algebraicNode.js +11 -0
- package/lib/tree/nodes/functions/log10Node.d.ts +2 -2
- package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
- package/lib/tree/nodes/functions/log10Node.js +3 -1
- package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/logNode.js +2 -0
- package/lib/tree/nodes/operators/addNode.js +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +1 -1
- package/package.json +1 -7
|
@@ -4,6 +4,7 @@ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuesti
|
|
|
4
4
|
import { randfloat } from "../../../math/utils/random/randfloat.js";
|
|
5
5
|
import { round } from "../../../math/utils/round.js";
|
|
6
6
|
import { requiresApostropheBefore } from "../../../utils/strings/requiresApostropheBefore.js";
|
|
7
|
+
import { numberVEA } from "../../../exercises/vea/numberVEA.js";
|
|
7
8
|
const substances = [
|
|
8
9
|
{ name: "eau", latentHeat: 334 }, // kJ/kg for melting ice
|
|
9
10
|
{ name: "fer", latentHeat: 276 }, // kJ/kg for melting iron
|
|
@@ -56,14 +57,8 @@ const getPropositions = (n, { answer, substance, mass }) => {
|
|
|
56
57
|
});
|
|
57
58
|
return shuffleProps(propositions, n);
|
|
58
59
|
};
|
|
59
|
-
const isAnswerValid = (ans, {
|
|
60
|
-
|
|
61
|
-
const energy = round(mass * subst.latentHeat, 2);
|
|
62
|
-
const validanswer1 = `${energy}\\kJ`;
|
|
63
|
-
const validanswer2 = energy.toTree().toAllValidTexs();
|
|
64
|
-
const latexs = [];
|
|
65
|
-
latexs.push(validanswer1, ...validanswer2);
|
|
66
|
-
return latexs.includes(ans);
|
|
60
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
61
|
+
return numberVEA(ans, answer);
|
|
67
62
|
};
|
|
68
63
|
export const energyTransfer = {
|
|
69
64
|
id: "energyTransfer",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thermalEnergyTransferCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/energy/thermalEnergyTransferCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"thermalEnergyTransferCalculation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/energy/thermalEnergyTransferCalculation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC;CACzC,CAAC;AAuPF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuesti
|
|
|
4
4
|
import { round } from "../../../math/utils/round.js";
|
|
5
5
|
import { randfloat } from "../../../math/utils/random/randfloat.js";
|
|
6
6
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
7
|
+
import { numberVEA } from "../../../exercises/vea/numberVEA.js";
|
|
7
8
|
const getInstruction = (identifiers) => {
|
|
8
9
|
const { mass, specificHeat, initialTemp, finalTemp, variable } = identifiers;
|
|
9
10
|
const deltaT = finalTemp - initialTemp;
|
|
@@ -148,30 +149,8 @@ const getPropositions = (n, { answer, mass, specificHeat, initialTemp, finalTemp
|
|
|
148
149
|
});
|
|
149
150
|
return shuffleProps(propositions, n);
|
|
150
151
|
};
|
|
151
|
-
const isAnswerValid = (ans, {
|
|
152
|
-
|
|
153
|
-
const deltaT = finalTemp - initialTemp;
|
|
154
|
-
switch (variable) {
|
|
155
|
-
case "E_th":
|
|
156
|
-
validanswer = round(mass * specificHeat * deltaT, 2);
|
|
157
|
-
break;
|
|
158
|
-
case "m":
|
|
159
|
-
validanswer = round((mass * specificHeat * deltaT) / (specificHeat * deltaT), 2);
|
|
160
|
-
break;
|
|
161
|
-
case "c":
|
|
162
|
-
validanswer = round((mass * specificHeat * deltaT) / (mass * deltaT), 2);
|
|
163
|
-
break;
|
|
164
|
-
case "deltaT":
|
|
165
|
-
validanswer = round((mass * specificHeat * deltaT) / (mass * specificHeat), 2);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
const latexs = [
|
|
169
|
-
...validanswer.toTree().toAllValidTexs(),
|
|
170
|
-
validanswer.toScientific(2).toTex(),
|
|
171
|
-
validanswer.toScientific(1).toTex(),
|
|
172
|
-
validanswer.toScientific(3).toTex(),
|
|
173
|
-
];
|
|
174
|
-
return latexs.includes(ans);
|
|
152
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
153
|
+
return numberVEA(ans, answer);
|
|
175
154
|
};
|
|
176
155
|
export const thermalEnergyTransferCalculation = {
|
|
177
156
|
id: "thermalEnergyTransferCalculation",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proportionnalityCoeffFromLine.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/math/proportionnalityCoeffFromLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"proportionnalityCoeffFromLine.d.ts","sourceRoot":"","sources":["../../../../src/exercises/pc/math/proportionnalityCoeffFromLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAWrC,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;AA0FF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAc/D,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { rationalVEA } from "../../../exercises/vea/rationalVEA.js";
|
|
3
4
|
import { randomColor } from "../../../geogebra/colors.js";
|
|
4
5
|
import { GeogebraConstructor } from "../../../geogebra/geogebraConstructor.js";
|
|
5
6
|
import { Integer } from "../../../math/numbers/integer/integer.js";
|
|
@@ -7,6 +8,7 @@ import { Rational } from "../../../math/numbers/rationals/rational.js";
|
|
|
7
8
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
8
9
|
import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
|
|
9
10
|
import { shuffle } from "../../../utils/alea/shuffle.js";
|
|
11
|
+
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
10
12
|
const getInstruction = () => {
|
|
11
13
|
return "Déterminer le coefficient de proportionnalité entre $y$ et $x$ : ";
|
|
12
14
|
};
|
|
@@ -71,12 +73,13 @@ const getPropositions = (n, { answer, xA, xB, yA, yB }) => {
|
|
|
71
73
|
});
|
|
72
74
|
return shuffle(propositions);
|
|
73
75
|
};
|
|
74
|
-
const isAnswerValid = (ans, {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
77
|
+
try {
|
|
78
|
+
return rationalVEA(ans, answer);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
return handleVEAError(err);
|
|
82
|
+
}
|
|
80
83
|
};
|
|
81
84
|
export const proportionnalityCoeffFromLine = {
|
|
82
85
|
id: "proportionnalityCoeffFromLine",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equationVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/equationVEA.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"equationVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/equationVEA.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,aAAa,MAAM,YAgB3D,CAAC"}
|
|
@@ -4,6 +4,8 @@ import { handleVEAError } from "../../utils/errors/handleVEAError.js";
|
|
|
4
4
|
import { rationalVEA } from "./rationalVEA.js";
|
|
5
5
|
export const equationVEA = (ans, solutionTex) => {
|
|
6
6
|
try {
|
|
7
|
+
if (solutionTex === "\\varnothing")
|
|
8
|
+
return ans === "\\varnothing" || ans === "S=\\varnothing";
|
|
7
9
|
const parsed = equationSolutionParser(ans);
|
|
8
10
|
if (parsed) {
|
|
9
11
|
return rationalVEA(parsed.toTex(), solutionTex);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
type Opts = {
|
|
2
2
|
allowNonIrreductible?: boolean;
|
|
3
3
|
allowDecimal?: boolean;
|
|
4
|
+
allowDecimalApprox?: boolean;
|
|
4
5
|
decimalPrecision?: number;
|
|
5
6
|
};
|
|
6
|
-
export declare const rationalVEA: (studentAns: string, answer: string, { allowNonIrreductible, decimalPrecision, allowDecimal }?: Opts) => boolean;
|
|
7
|
+
export declare const rationalVEA: (studentAns: string, answer: string, { allowNonIrreductible, decimalPrecision, allowDecimal, allowDecimalApprox, }?: Opts) => boolean;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=rationalVEA.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rationalVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/rationalVEA.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rationalVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/rationalVEA.ts"],"names":[],"mappings":"AAeA,KAAK,IAAI,GAAG;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AACF,eAAO,MAAM,WAAW,GACtB,YAAY,MAAM,EAClB,QAAQ,MAAM,EACd,gFAKG,IAKF,YAsEF,CAAC"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { round } from "../../math/utils/round.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isOppositeNode } from "../../tree/nodes/functions/oppositeNode.js";
|
|
3
|
+
import { isNumberNode, } from "../../tree/nodes/numbers/numberNode.js";
|
|
4
|
+
import { isFractionNode, } from "../../tree/nodes/operators/fractionNode.js";
|
|
3
5
|
import { parseAlgebraic } from "../../tree/parsers/latexParser.js";
|
|
4
6
|
import { rationalParser } from "../../tree/parsers/rationalParser.js";
|
|
5
7
|
import { handleVEAError } from "../../utils/errors/handleVEAError.js";
|
|
6
|
-
export const rationalVEA = (studentAns, answer, { allowNonIrreductible, decimalPrecision, allowDecimal } = {
|
|
8
|
+
export const rationalVEA = (studentAns, answer, { allowNonIrreductible, decimalPrecision, allowDecimal, allowDecimalApprox, } = {
|
|
7
9
|
allowNonIrreductible: true,
|
|
8
10
|
decimalPrecision: 2,
|
|
9
11
|
allowDecimal: true,
|
|
12
|
+
allowDecimalApprox: true,
|
|
10
13
|
}) => {
|
|
11
14
|
allowDecimal = allowDecimal ?? true;
|
|
15
|
+
allowDecimalApprox = allowDecimalApprox ?? true;
|
|
12
16
|
allowNonIrreductible = allowNonIrreductible ?? true;
|
|
13
17
|
decimalPrecision = decimalPrecision ?? undefined;
|
|
14
18
|
const parsed = rationalParser(studentAns);
|
|
@@ -19,6 +23,20 @@ export const rationalVEA = (studentAns, answer, { allowNonIrreductible, decimalP
|
|
|
19
23
|
if (isNumberNode(parsed)) {
|
|
20
24
|
if (!allowDecimal)
|
|
21
25
|
return false;
|
|
26
|
+
if (!allowDecimalApprox) {
|
|
27
|
+
//si l'answer n'est pas décimable et que c'est un nbNode on renvoit faux dans tous les cas
|
|
28
|
+
const answerFraced = isFractionNode(parsedAnswer)
|
|
29
|
+
? parsedAnswer
|
|
30
|
+
: isOppositeNode(parsedAnswer) && isFractionNode(parsedAnswer.child)
|
|
31
|
+
? parsedAnswer.child
|
|
32
|
+
: isNumberNode(parsedAnswer)
|
|
33
|
+
? parsedAnswer.toFrac()
|
|
34
|
+
: null;
|
|
35
|
+
if (!!answerFraced &&
|
|
36
|
+
!isNumberNode(answerFraced) &&
|
|
37
|
+
!answerFraced.isDecimal())
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
22
40
|
if (decimalPrecision === undefined)
|
|
23
41
|
return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001);
|
|
24
42
|
else {
|
|
@@ -32,6 +50,22 @@ export const rationalVEA = (studentAns, answer, { allowNonIrreductible, decimalP
|
|
|
32
50
|
}
|
|
33
51
|
}
|
|
34
52
|
else if (allowNonIrreductible) {
|
|
53
|
+
if (!allowDecimalApprox) {
|
|
54
|
+
if (isNumberNode(parsed)) {
|
|
55
|
+
//si l'answer n'est pas décimable et que c'est un nbNode on renvoit faux dans tous les cas
|
|
56
|
+
const answerFraced = isFractionNode(parsedAnswer)
|
|
57
|
+
? parsedAnswer
|
|
58
|
+
: isOppositeNode(parsedAnswer) && isFractionNode(parsedAnswer.child)
|
|
59
|
+
? parsedAnswer.child
|
|
60
|
+
: isNumberNode(parsedAnswer)
|
|
61
|
+
? parsedAnswer.toFrac()
|
|
62
|
+
: null;
|
|
63
|
+
if (!!answerFraced &&
|
|
64
|
+
!isNumberNode(answerFraced) &&
|
|
65
|
+
!answerFraced.isDecimal())
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
35
69
|
return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001;
|
|
36
70
|
}
|
|
37
71
|
else {
|
package/lib/index.d.ts
CHANGED
|
@@ -119,7 +119,9 @@ declare const mathExercises: (Exercise<{
|
|
|
119
119
|
denom: number;
|
|
120
120
|
num1: number;
|
|
121
121
|
num2: number;
|
|
122
|
-
},
|
|
122
|
+
}, {
|
|
123
|
+
allowNonIrreductible?: boolean;
|
|
124
|
+
}> | Exercise<{
|
|
123
125
|
num1: number;
|
|
124
126
|
num2: number;
|
|
125
127
|
denom1: number;
|
|
@@ -681,11 +683,6 @@ declare const mathExercises: (Exercise<{
|
|
|
681
683
|
d: number;
|
|
682
684
|
k: number;
|
|
683
685
|
isSubstract: boolean;
|
|
684
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
685
|
-
a: number;
|
|
686
|
-
k1: number;
|
|
687
|
-
b: number;
|
|
688
|
-
k2: number;
|
|
689
686
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
690
687
|
b: number;
|
|
691
688
|
c: number;
|
|
@@ -5943,10 +5940,8 @@ declare const mathExercises: (Exercise<{
|
|
|
5943
5940
|
graphIds2: import("./math/graphs/graph.js").GraphIdentifiers;
|
|
5944
5941
|
graphNodes1: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
|
|
5945
5942
|
graphEdges1: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
|
|
5946
|
-
scale1: number;
|
|
5947
5943
|
graphNodes2: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
|
|
5948
5944
|
graphEdges2: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
|
|
5949
|
-
scale2: number;
|
|
5950
5945
|
}, {
|
|
5951
5946
|
graphType: string;
|
|
5952
5947
|
}> | Exercise<{
|
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,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WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Graph } from "../../graphs/graph.js";
|
|
2
|
-
import * as TSGraphViz from "ts-graphviz";
|
|
3
|
-
import { Engine } from "@hpcc-js/wasm-graphviz";
|
|
4
2
|
export interface GraphNode {
|
|
5
3
|
label: string;
|
|
6
4
|
x: number;
|
|
@@ -10,14 +8,14 @@ export interface GraphEdge {
|
|
|
10
8
|
from: string;
|
|
11
9
|
to: string;
|
|
12
10
|
}
|
|
11
|
+
export type RandomLayoutOptions = {
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
minDistance?: number;
|
|
15
|
+
maxAttempts?: number;
|
|
16
|
+
};
|
|
13
17
|
export declare class GraphRenderer {
|
|
14
|
-
static
|
|
15
|
-
static renderToSVG(graph: Graph, layoutEngineIn?: Engine): string;
|
|
16
|
-
static convertSVGToNodesAndEdges(strSVG: string): {
|
|
17
|
-
nodes: GraphNode[];
|
|
18
|
-
edges: GraphEdge[];
|
|
19
|
-
};
|
|
20
|
-
static renderToNodesAndEdges(graph: Graph, layoutEngineIn?: Engine): {
|
|
18
|
+
static renderToNodesAndEdges(graph: Graph, { width, height, minDistance, maxAttempts, }?: RandomLayoutOptions): {
|
|
21
19
|
nodes: GraphNode[];
|
|
22
20
|
edges: GraphEdge[];
|
|
23
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphRenderer.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/graphs/graphRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"graphRenderer.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/graphs/graphRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,qBAAa,aAAa;IACxB,MAAM,CAAC,qBAAqB,CAC1B,KAAK,EAAE,KAAK,EACZ,EACE,KAAU,EACV,MAAW,EACX,WAAiB,EACjB,WAAiB,GAClB,GAAE,mBAAwB,GAC1B;QAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAAC,KAAK,EAAE,SAAS,EAAE,CAAA;KAAE;CAoC9C"}
|
|
@@ -1,123 +1,31 @@
|
|
|
1
|
-
import * as TSGraphViz from "ts-graphviz";
|
|
2
|
-
import { Graphviz } from "@hpcc-js/wasm-graphviz";
|
|
3
|
-
const graphviz = await Graphviz.load();
|
|
4
|
-
import { JSDOM } from "jsdom";
|
|
5
|
-
import { random } from "../../../utils/alea/random.js";
|
|
6
1
|
export class GraphRenderer {
|
|
7
|
-
static
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
static renderToNodesAndEdges(graph, { width = 10, height = 10, minDistance = 1.5, maxAttempts = 100, } = {}) {
|
|
3
|
+
// 1. Placement aléatoire des sommets, en évitant les chevauchements
|
|
4
|
+
const nodes = [];
|
|
5
|
+
for (const label of graph.vertexNames) {
|
|
6
|
+
let best = { x: 0, y: 0 };
|
|
7
|
+
let bestDist = -Infinity;
|
|
8
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
9
|
+
const x = Math.random() * width;
|
|
10
|
+
const y = Math.random() * height;
|
|
11
|
+
const dist = nodes.reduce((min, node) => Math.min(min, Math.hypot(node.x - x, node.y - y)), Infinity);
|
|
12
|
+
// on garde le candidat le plus éloigné des autres (repli si la zone est trop petite)
|
|
13
|
+
if (dist > bestDist) {
|
|
14
|
+
best = { x, y };
|
|
15
|
+
bestDist = dist;
|
|
16
|
+
}
|
|
17
|
+
if (dist >= minDistance)
|
|
18
|
+
break;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
return arrConnection
|
|
26
|
-
.map(([nameVertexStart, nameVertexEnd]) => [nameVertexStart, nameVertexEnd].join("-"))
|
|
27
|
-
.reduce((acc, strEdge) => {
|
|
28
|
-
const strEdgeReversed = strEdge.split("").toReversed().join("");
|
|
29
|
-
if (acc.includes(strEdgeReversed)) {
|
|
30
|
-
//ignore
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
acc = [...acc, strEdge];
|
|
34
|
-
}
|
|
35
|
-
return acc;
|
|
36
|
-
}, [])
|
|
37
|
-
.map((strEdge) => {
|
|
38
|
-
const [nameVertexStart, nameVertexEnd] = strEdge.split("-");
|
|
39
|
-
return [nameVertexStart, nameVertexEnd];
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
})();
|
|
43
|
-
const arrEdge = arrConnectionNoDuplicate.map(([nameVertexStart, nameVertexEnd]) => {
|
|
44
|
-
const [graphvizNodeStart, graphvizNodeEnd] = [
|
|
45
|
-
nameVertexStart,
|
|
46
|
-
nameVertexEnd,
|
|
47
|
-
].map((nameVertex) => dictGraphvizNode[nameVertex]);
|
|
48
|
-
const graphvizEdge = new TSGraphViz.Edge([graphvizNodeStart, graphvizNodeEnd], {});
|
|
49
|
-
return graphvizEdge;
|
|
50
|
-
});
|
|
51
|
-
// Add elements to the graph
|
|
52
|
-
Object.entries(dictGraphvizNode).forEach(([_, graphvizNode]) => digraph.addNode(graphvizNode));
|
|
53
|
-
arrEdge.forEach((graphvizEdge) => digraph.addEdge(graphvizEdge));
|
|
54
|
-
return digraph;
|
|
55
|
-
}
|
|
56
|
-
static renderToSVG(graph, layoutEngineIn) {
|
|
57
|
-
const digraph = GraphRenderer.convertToGraphVizGraph(graph);
|
|
58
|
-
const dot = TSGraphViz.toDot(digraph);
|
|
59
|
-
// Render DOT to SVG
|
|
60
|
-
/*
|
|
61
|
-
const arrLayoutEngine = [
|
|
62
|
-
"circo",
|
|
63
|
-
"dot",
|
|
64
|
-
"fdp",
|
|
65
|
-
"neato",
|
|
66
|
-
"nop",
|
|
67
|
-
"nop2",
|
|
68
|
-
// "osage",
|
|
69
|
-
// "patchwork",
|
|
70
|
-
"sfdp",
|
|
71
|
-
"twopi",
|
|
72
|
-
];
|
|
73
|
-
*/
|
|
74
|
-
const layoutEngine = layoutEngineIn ?? random(["fdp", "circo"]);
|
|
75
|
-
const svg = graphviz.layout(dot, "svg", layoutEngine);
|
|
76
|
-
return svg;
|
|
77
|
-
}
|
|
78
|
-
static convertSVGToNodesAndEdges(strSVG) {
|
|
79
|
-
function parseSvgGraph(svgString) {
|
|
80
|
-
const domParser = new new JSDOM().window.DOMParser();
|
|
81
|
-
const doc = domParser.parseFromString(svgString, "image/svg+xml");
|
|
82
|
-
const svgEl = doc.querySelector("svg");
|
|
83
|
-
const height = parseFloat(svgEl?.getAttribute("height") ?? "0");
|
|
84
|
-
// Translation du groupe racine (pattern classique Graphviz)
|
|
85
|
-
const graphGroup = doc.querySelector("g.graph") ?? doc.querySelector("svg > g");
|
|
86
|
-
const transform = graphGroup?.getAttribute("transform") ?? "";
|
|
87
|
-
const match = transform.match(/translate\(([-\d.]+)[ ,]([-\d.]+)\)/);
|
|
88
|
-
const [tx, ty] = match
|
|
89
|
-
? [parseFloat(match[1]), parseFloat(match[2])]
|
|
90
|
-
: [0, 0];
|
|
91
|
-
// Sommets
|
|
92
|
-
const nodes = Array.from(doc.querySelectorAll("g.node")).map((g) => {
|
|
93
|
-
const ellipse = g.querySelector("ellipse");
|
|
94
|
-
const text = g.querySelector("text");
|
|
95
|
-
const label = text?.textContent?.trim() ??
|
|
96
|
-
g.querySelector("title")?.textContent?.trim() ??
|
|
97
|
-
"";
|
|
98
|
-
const cx = parseFloat(ellipse?.getAttribute("cx") ?? "0");
|
|
99
|
-
const cy = parseFloat(ellipse?.getAttribute("cy") ?? "0");
|
|
100
|
-
return {
|
|
101
|
-
label,
|
|
102
|
-
x: cx + tx,
|
|
103
|
-
y: height - (cy + ty), // flip vertical SVG -> GeoGebra
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
// Arêtes : lues directement depuis le <title> de chaque g.edge (ex: "A->B")
|
|
107
|
-
const edges = Array.from(doc.querySelectorAll("g.edge"))
|
|
108
|
-
.map((g) => g.querySelector("title")?.textContent?.trim() ?? "")
|
|
109
|
-
.map((title) => {
|
|
110
|
-
const [from, to] = title.split(/->|->/).map((s) => s.trim());
|
|
111
|
-
return { from, to };
|
|
112
|
-
})
|
|
113
|
-
.filter((e) => Boolean(e.from && e.to));
|
|
114
|
-
return { nodes, edges };
|
|
20
|
+
nodes.push({ label, ...best });
|
|
115
21
|
}
|
|
116
|
-
|
|
22
|
+
// 2. Arêtes (une seule fois par paire si le graphe n'est pas orienté)
|
|
23
|
+
const indexOf = new Map(graph.vertexNames.map((name, i) => [name, i]));
|
|
24
|
+
const edges = graph
|
|
25
|
+
.arrConnection()
|
|
26
|
+
.filter(([from, to, isConnection]) => isConnection &&
|
|
27
|
+
(graph.isDirected || indexOf.get(from) <= indexOf.get(to)))
|
|
28
|
+
.map(([from, to]) => ({ from, to }));
|
|
117
29
|
return { nodes, edges };
|
|
118
30
|
}
|
|
119
|
-
static renderToNodesAndEdges(graph, layoutEngineIn) {
|
|
120
|
-
const strSVG = this.renderToSVG(graph, layoutEngineIn);
|
|
121
|
-
return this.convertSVGToNodesAndEdges(strSVG);
|
|
122
|
-
}
|
|
123
31
|
}
|
|
@@ -21,6 +21,7 @@ export type SimplifyOptions = {
|
|
|
21
21
|
forbidPowerMultiply?: boolean;
|
|
22
22
|
forbidPowerDivision?: boolean;
|
|
23
23
|
forbidPowerPower?: boolean;
|
|
24
|
+
forbidLogSimplify?: boolean;
|
|
24
25
|
};
|
|
25
26
|
export type EvaluateOptions = {
|
|
26
27
|
degreeMode?: boolean;
|
|
@@ -41,4 +42,5 @@ export declare abstract class CAlgebraicNode {
|
|
|
41
42
|
private static toString;
|
|
42
43
|
}
|
|
43
44
|
export declare const isAlgebraicNode: (node: Node) => node is AlgebraicNode;
|
|
45
|
+
export declare const isFactorizedNode: (node: Node) => node is AlgebraicNode;
|
|
44
46
|
//# sourceMappingURL=algebraicNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src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,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,eAAe,KAAK,MAAM,CAAC;IAC5E,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,aAAa,CAAC;IAC7E,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,aAAa,EAAE,CAAC;IAC3D,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,aAAa,CAAC;IACnE,MAAM,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;IAChD,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,MAAM,CAAC;IACxD,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AACD,8BAAsB,cAAc;;IAElC,OAAO,CAAC,MAAM,CAAC,QAAQ;CAGxB;AACD,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,aACI,CAAC;AAE1D,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,aASrD,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isOppositeNode } from "./functions/oppositeNode.js";
|
|
2
|
+
import { isMultiplyNode } from "./operators/multiplyNode.js";
|
|
3
|
+
import { isPowerNode, isSquareNode } from "./operators/powerNode.js";
|
|
1
4
|
export class CAlgebraicNode {
|
|
2
5
|
constructor() { }
|
|
3
6
|
static toString() {
|
|
@@ -5,3 +8,11 @@ export class CAlgebraicNode {
|
|
|
5
8
|
}
|
|
6
9
|
}
|
|
7
10
|
export const isAlgebraicNode = (node) => Object.prototype.hasOwnProperty.call(node, "isNumeric");
|
|
11
|
+
export const isFactorizedNode = (node) => {
|
|
12
|
+
return (isMultiplyNode(node) ||
|
|
13
|
+
isPowerNode(node) ||
|
|
14
|
+
isSquareNode(node) ||
|
|
15
|
+
(isOppositeNode(node) && isMultiplyNode(node.child)) ||
|
|
16
|
+
(isOppositeNode(node) && isPowerNode(node.child)) ||
|
|
17
|
+
(isOppositeNode(node) && isSquareNode(node.child)));
|
|
18
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node.js";
|
|
2
2
|
import { FunctionNode, FunctionsIds } from "./functionNode.js";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode.js";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
4
|
export declare function isLog10Node(a: Node): a is Log10Node;
|
|
5
5
|
export declare const log10: (a: AlgebraicNode | number | string) => Log10Node;
|
|
6
6
|
export declare class Log10Node implements FunctionNode {
|
|
@@ -22,7 +22,7 @@ export declare class Log10Node implements FunctionNode {
|
|
|
22
22
|
toEquivalentNodes(): AlgebraicNode[];
|
|
23
23
|
toSignInequationTex(): string;
|
|
24
24
|
toAllValidTexs(): string[];
|
|
25
|
-
simplify(): AlgebraicNode;
|
|
25
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
26
26
|
evaluate(vars?: Record<string, number>): number;
|
|
27
27
|
equals(node: AlgebraicNode): boolean;
|
|
28
28
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): Log10Node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log10Node.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/log10Node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"log10Node.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/log10Node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMrE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,eAAO,MAAM,KAAK,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,cAIvD,CAAC;AACF,qBAAa,SAAU,YAAW,YAAY;IAC5C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,mBAAmB;IAQnB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IAQpC,mBAAmB;IAOnB,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAkC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,IAAI,aAAa;CAG5B"}
|
|
@@ -78,9 +78,11 @@ export class Log10Node {
|
|
|
78
78
|
toAllValidTexs() {
|
|
79
79
|
return this.toEquivalentNodes().map((node) => node.toTex());
|
|
80
80
|
}
|
|
81
|
-
simplify() {
|
|
81
|
+
simplify(opts) {
|
|
82
82
|
const simplifiedChild = this.child.simplify();
|
|
83
83
|
const copy = new Log10Node(simplifiedChild, this.opts);
|
|
84
|
+
if (opts?.forbidLogSimplify)
|
|
85
|
+
return copy;
|
|
84
86
|
if (isNumberNode(simplifiedChild)) {
|
|
85
87
|
const value = simplifiedChild.value;
|
|
86
88
|
const log10 = Math.log10(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/logNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAED,eAAO,MAAM,IAAI,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,YAItD,CAAC;AAEF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,mBAAmB;IAQnB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IAQpC,mBAAmB;IAOnB,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CA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ify(opts) {
|
|
82
82
|
const simplifiedChild = this.child.simplify(opts);
|
|
83
83
|
const copy = new LogNode(simplifiedChild, this.opts);
|
|
84
|
+
if (opts?.forbidLogSimplify)
|
|
85
|
+
return copy; //on autorise la simplification du child mais pas les formules de simpliifications du log en elles memes
|
|
84
86
|
if (isNumberNode(simplifiedChild)) {
|
|
85
87
|
const value = simplifiedChild.value;
|
|
86
88
|
if (value <= 0)
|
|
@@ -313,7 +313,7 @@ const addSort = (a, b, opts) => {
|
|
|
313
313
|
parsedA.variable.localeCompare(parsedB.variable));
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
return
|
|
316
|
+
return Number(isNumberNode(b)) - Number(isNumberNode(a));
|
|
317
317
|
};
|
|
318
318
|
const addSimplifyFrac = (a, b, opts) => {
|
|
319
319
|
if (isFractionNode(a) &&
|
|
@@ -102,7 +102,7 @@ export class FractionNode {
|
|
|
102
102
|
const simp = this.simplify();
|
|
103
103
|
if (isNumberNode(simp))
|
|
104
104
|
return true;
|
|
105
|
-
let denum = simp.
|
|
105
|
+
let denum = simp.rightChild.evaluate();
|
|
106
106
|
let counter = 0;
|
|
107
107
|
while (denum % 2 === 0) {
|
|
108
108
|
counter++;
|
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.218",
|
|
5
5
|
"description": "Math exercises generator for middle school and high school",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
@@ -28,22 +28,16 @@
|
|
|
28
28
|
"author": "Heureux Hasard",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@flatten-js/core": "^1.6.14",
|
|
32
|
-
"@hpcc-js/wasm-graphviz": "^1.29.1",
|
|
33
31
|
"d3-node": "^4.0.1",
|
|
34
|
-
"jsdom": "^29.1.1",
|
|
35
32
|
"katex": "^0.16.21",
|
|
36
33
|
"lodash.isequal": "^4.5.0",
|
|
37
|
-
"ts-graphviz": "^3.0.7",
|
|
38
34
|
"uuidv4": "^6.2.13"
|
|
39
35
|
},
|
|
40
36
|
"devDependencies": {
|
|
41
37
|
"@eslint/js": "^9.34.0",
|
|
42
38
|
"@types/cors": "^2.8.13",
|
|
43
|
-
"@types/deasync": "^0.1.5",
|
|
44
39
|
"@types/express": "^4.17.17",
|
|
45
40
|
"@types/jest": "^29.5.6",
|
|
46
|
-
"@types/jsdom": "^30.0.0",
|
|
47
41
|
"@types/lodash.isequal": "^4.5.8",
|
|
48
42
|
"@types/node": "^20.10.6",
|
|
49
43
|
"body-parser": "^1.20.2",
|