math-exercises 3.0.150 → 3.0.152
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/exercise.d.ts +5 -0
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.js +1 -1
- package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts +5 -1
- package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.js +92 -38
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +5 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportional.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportional.js +7 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +5 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTable.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTable.js +5 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.js +8 -2
- package/lib/exercises/math/calculLitteral/equation/equa1.d.ts +4 -1
- package/lib/exercises/math/calculLitteral/equation/equa1.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equa1.js +27 -7
- package/lib/exercises/math/calculLitteral/equation/equa2.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/equation/equa2.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equa2.js +18 -1
- package/lib/exercises/math/calculLitteral/equation/equa3.d.ts +4 -1
- package/lib/exercises/math/calculLitteral/equation/equa3.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equa3.js +26 -6
- package/lib/exercises/math/calculLitteral/equation/equa4.d.ts +4 -1
- package/lib/exercises/math/calculLitteral/equation/equa4.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equa4.js +27 -7
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa1.d.ts +14 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa1.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa1.js +129 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa2.d.ts +18 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa2.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa2.js +167 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa3.d.ts +15 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa3.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa3.js +129 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa4.d.ts +16 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa4.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/equa4.js +124 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType1.d.ts +9 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType1.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType1.js +107 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType2.d.ts +10 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType2.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType2.js +108 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType3.d.ts +11 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType3.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/firstDegreeEquationIntType3.js +104 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/index.d.ts +8 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/index.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/firstDegree/index.js +7 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -7
- package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.js +1 -7
- package/lib/exercises/math/dataRepresentations/histogram/etendueHistogram.d.ts +8 -0
- package/lib/exercises/math/dataRepresentations/histogram/etendueHistogram.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/histogram/etendueHistogram.js +175 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramCommenting.d.ts +9 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramCommenting.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramCommenting.js +250 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramFillDataTableFromHistogramData.d.ts +9 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramFillDataTableFromHistogramData.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramFillDataTableFromHistogramData.js +173 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.d.ts +14 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.js +239 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramReading.d.ts +9 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramReading.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramReading.js +163 -0
- package/lib/exercises/math/dataRepresentations/histogram/index.d.ts +6 -0
- package/lib/exercises/math/dataRepresentations/histogram/index.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/histogram/index.js +5 -0
- package/lib/exercises/math/dataRepresentations/index.d.ts +1 -1
- package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/index.js +1 -1
- package/lib/exercises/math/dataRepresentations/tableReading.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/tableReading.js +7 -0
- package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustment.js +7 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +7 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +7 -1
- package/lib/exercises/math/functions/affines/leadingCoeffAndOriginOrdinate.d.ts +4 -1
- package/lib/exercises/math/functions/affines/leadingCoeffAndOriginOrdinate.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/leadingCoeffAndOriginOrdinate.js +19 -4
- package/lib/exercises/math/functions/affines/leadingCoefficient.d.ts +1 -0
- package/lib/exercises/math/functions/affines/leadingCoefficient.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/leadingCoefficient.js +13 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts +4 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.js +19 -4
- package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +7 -1
- package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/placePointsFromValueTable.js +7 -0
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts +4 -1
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +18 -3
- package/lib/exercises/math/geometry/triangles/index.d.ts +1 -0
- package/lib/exercises/math/geometry/triangles/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/triangles/index.js +1 -0
- package/lib/exercises/math/geometry/triangles/similar/index.d.ts +4 -0
- package/lib/exercises/math/geometry/triangles/similar/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/triangles/similar/index.js +3 -0
- package/lib/exercises/math/geometry/triangles/similar/isSimilarTrianglesWithAngles.d.ts +10 -0
- package/lib/exercises/math/geometry/triangles/similar/isSimilarTrianglesWithAngles.d.ts.map +1 -0
- package/lib/exercises/math/geometry/triangles/similar/isSimilarTrianglesWithAngles.js +122 -0
- package/lib/exercises/math/geometry/triangles/similar/isSimilarTrianglesWrtSideLengths.d.ts +15 -0
- package/lib/exercises/math/geometry/triangles/similar/isSimilarTrianglesWrtSideLengths.d.ts.map +1 -0
- package/lib/exercises/math/geometry/triangles/similar/isSimilarTrianglesWrtSideLengths.js +351 -0
- package/lib/exercises/math/geometry/triangles/similar/placeSegmentsOfSimilarTriangle.d.ts +11 -0
- package/lib/exercises/math/geometry/triangles/similar/placeSegmentsOfSimilarTriangle.d.ts.map +1 -0
- package/lib/exercises/math/geometry/triangles/similar/placeSegmentsOfSimilarTriangle.js +311 -0
- package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.d.ts +10 -0
- package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.js +135 -0
- package/lib/exercises/math/probaStat/basicProbas/findEffectifFromProba.d.ts +9 -0
- package/lib/exercises/math/probaStat/basicProbas/findEffectifFromProba.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/findEffectifFromProba.js +109 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.js +7 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts +9 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.js +120 -0
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts +4 -0
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/index.js +4 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts +12 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.js +374 -0
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +7 -0
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/averageWithTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/averageWithTable.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/etendueTable.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +5 -1
- package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts +2 -0
- package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianWithList.js +67 -14
- package/lib/exercises/math/probaStat/stats1var/medianWithTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianWithTable.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/quartiles.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/quartiles.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +5 -1
- package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/varianceTable.js +5 -1
- package/lib/exercises/math/probaStat/stats2var/averagePoint.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats2var/averagePoint.js +7 -1
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts +7 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.js +171 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts +7 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.js +155 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts +3 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/twoStepExperiments/index.js +3 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts +7 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.js +189 -0
- package/lib/exercises/math/spaceGeometry/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/index.js +1 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfConeSection.d.ts +14 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfConeSection.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfConeSection.js +439 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfCylinderSection.d.ts +14 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfCylinderSection.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfCylinderSection.js +548 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfRectangularPrismSection.d.ts +11 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfRectangularPrismSection.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfRectangularPrismSection.js +360 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfSphereSection.d.ts +9 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfSphereSection.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfSphereSection.js +272 -0
- package/lib/exercises/math/spaceGeometry/sections/index.d.ts +9 -0
- package/lib/exercises/math/spaceGeometry/sections/index.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/index.js +8 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfCone.d.ts +11 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfCone.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfCone.js +266 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfCylinder.d.ts +11 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfCylinder.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfCylinder.js +236 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfRectangularPrism.d.ts +7 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfRectangularPrism.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfRectangularPrism.js +92 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfSphereOrBall.d.ts +9 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfSphereOrBall.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sections/recognizeSectionsOfSphereOrBall.js +236 -0
- package/lib/exercises/pc/mathExosInPC.d.ts +4 -4
- package/lib/exercises/pc/mathExosInPC.d.ts.map +1 -1
- package/lib/exercises/pc/mathExosInPC.js +4 -4
- package/lib/index.d.ts +173 -45
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/spacePoint.d.ts +10 -0
- package/lib/math/geometry/spacePoint.d.ts.map +1 -1
- package/lib/math/geometry/spacePoint.js +13 -0
- package/lib/tree/nodes/operators/substractNode.d.ts +1 -0
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { round } from "../../../../math/utils/round.js";
|
|
7
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
8
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
10
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
11
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
12
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
const { data, bounds } = identifiers;
|
|
15
|
+
addValidProp(propositions, answer);
|
|
16
|
+
//maxHeight - minHeight
|
|
17
|
+
const nodeWidths = [...Array(bounds.length - 1).keys()].map((i) => substract(bounds[i + 1], bounds[i]));
|
|
18
|
+
const nodeHeights = nodeWidths.map((nodeWidth, i) => frac(data[i], nodeWidth).simplify());
|
|
19
|
+
const nodeHeightsSortedAsc = nodeHeights.toSorted((node1, node2) => node1.evaluate() - node2.evaluate());
|
|
20
|
+
const [nodeMaxHeight, nodeMinHeight] = [
|
|
21
|
+
nodeHeightsSortedAsc[nodeHeightsSortedAsc.length - 1],
|
|
22
|
+
nodeHeightsSortedAsc[0],
|
|
23
|
+
];
|
|
24
|
+
tryToAddWrongProp(propositions, substract(nodeMaxHeight, nodeMinHeight).simplify().toTex());
|
|
25
|
+
//filler
|
|
26
|
+
const arrFiller = shuffle([
|
|
27
|
+
//max bound
|
|
28
|
+
(() => {
|
|
29
|
+
const maxBound = bounds[bounds.length - 1];
|
|
30
|
+
return maxBound.frenchify();
|
|
31
|
+
})(),
|
|
32
|
+
//maxHeight
|
|
33
|
+
nodeMaxHeight.toTex(),
|
|
34
|
+
//(maxBound + minBound) / 2
|
|
35
|
+
(() => {
|
|
36
|
+
const maxBound = bounds[bounds.length - 1];
|
|
37
|
+
const minBound = bounds[0];
|
|
38
|
+
return ((maxBound + minBound) / 2).frenchify();
|
|
39
|
+
})(),
|
|
40
|
+
]);
|
|
41
|
+
const genFiller = (function* () {
|
|
42
|
+
yield* arrFiller;
|
|
43
|
+
return "done";
|
|
44
|
+
})();
|
|
45
|
+
propWhile(propositions, n, () => {
|
|
46
|
+
tryToAddWrongProp(propositions, genFiller.next().value);
|
|
47
|
+
});
|
|
48
|
+
return shuffleProps(propositions, n);
|
|
49
|
+
};
|
|
50
|
+
const getAnswer = (identifiers) => {
|
|
51
|
+
const { bounds } = identifiers;
|
|
52
|
+
const maxBound = bounds[bounds.length - 1];
|
|
53
|
+
const minBound = bounds[0];
|
|
54
|
+
const span = maxBound - minBound;
|
|
55
|
+
return `${span.frenchify()}`;
|
|
56
|
+
};
|
|
57
|
+
const getInstruction = () => {
|
|
58
|
+
return `Quelle est l'étendue dans cet histogramme ?`;
|
|
59
|
+
};
|
|
60
|
+
const getHint = () => {
|
|
61
|
+
return `L'étendue concerne le critère qui nous sert à classer les éléments.`;
|
|
62
|
+
};
|
|
63
|
+
const getCorrection = (identifiers) => {
|
|
64
|
+
const { bounds } = identifiers;
|
|
65
|
+
const maxBound = bounds[bounds.length - 1];
|
|
66
|
+
const minBound = bounds[0];
|
|
67
|
+
const span = maxBound - minBound;
|
|
68
|
+
return `Ici le critère pour classer est le diamètre.
|
|
69
|
+
On s'intéresse aux bornes de ce critère.
|
|
70
|
+
L'étendue est la différence entre la borne la plus élévée et la plus petite.
|
|
71
|
+
|
|
72
|
+
$$
|
|
73
|
+
${maxBound.frenchify()} - ${minBound.frenchify()} = ${span.frenchify()}
|
|
74
|
+
$$
|
|
75
|
+
|
|
76
|
+
L'étendue est de $${span.frenchify()} \\ \\textrm{cm}$.`;
|
|
77
|
+
};
|
|
78
|
+
const getGGBOptions = (identifiers) => {
|
|
79
|
+
const { bounds, data } = identifiers;
|
|
80
|
+
const heights = [];
|
|
81
|
+
for (let i = 0; i < data.length; i++) {
|
|
82
|
+
const width = bounds[i + 1] - bounds[i];
|
|
83
|
+
const height = data[i] / width;
|
|
84
|
+
heights.push(height);
|
|
85
|
+
}
|
|
86
|
+
const offsetX = -bounds[0] + 1;
|
|
87
|
+
const offsettedBounds = bounds.map((bound) => bound + offsetX);
|
|
88
|
+
// const xMin = offsettedBounds[0];
|
|
89
|
+
const xMax = offsettedBounds[offsettedBounds.length - 1];
|
|
90
|
+
// const heightMin = 0;
|
|
91
|
+
const heightMax = Math.max(...heights);
|
|
92
|
+
const commands = [
|
|
93
|
+
`B = Histogram({${offsettedBounds}}, {${heights.join(",")}})`,
|
|
94
|
+
...bounds.map((bound, i) => `XBound_{${i}} = Text("\\footnotesize ${bound.frenchify()}", (${offsettedBounds[i]}, 0), true, true, 0, -1)`),
|
|
95
|
+
`ShowLabel(B,false)`,
|
|
96
|
+
...heights.map((height, i) => `YBound_{${i}} = Text("\\footnotesize ${round(height, 0).frenchify()}", (0, ${height}), true, true, 0, 0)`),
|
|
97
|
+
];
|
|
98
|
+
const ggb = new GeogebraConstructor({
|
|
99
|
+
commands,
|
|
100
|
+
hideGrid: true,
|
|
101
|
+
fontSize: 16,
|
|
102
|
+
lockedAxesRatio: false,
|
|
103
|
+
xAxis: {
|
|
104
|
+
hideNumbers: true,
|
|
105
|
+
showPositive: true,
|
|
106
|
+
label: "$\\footnotesize Diamètre (cm)$",
|
|
107
|
+
},
|
|
108
|
+
yAxis: {
|
|
109
|
+
showPositive: true,
|
|
110
|
+
label: "$\\footnotesize Pommes/cm$",
|
|
111
|
+
hideNumbers: true,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
return ggb.getOptions({
|
|
115
|
+
coords: ggb.getAdaptedCoords({
|
|
116
|
+
xMin: -xMax * 0.1,
|
|
117
|
+
xMax: xMax * 1.5,
|
|
118
|
+
yMin: -heightMax * 0.25,
|
|
119
|
+
yMax: heightMax * 1.5,
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
const getKeys = () => {
|
|
124
|
+
return [];
|
|
125
|
+
};
|
|
126
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
127
|
+
return numberVEA(ans, answer);
|
|
128
|
+
};
|
|
129
|
+
const getEtendueHistogramQuestion = () => {
|
|
130
|
+
const boundsRaw = [11.5, 12, 13.5, 15, 15.5, 16, 16.2];
|
|
131
|
+
const nbBounds = randint(3, 5);
|
|
132
|
+
const bounds = random([...Array(boundsRaw.length - nbBounds).keys()].map((i) => boundsRaw.slice(i, i + nbBounds)));
|
|
133
|
+
const heightPool = shuffle([...Array(10).keys()].map((i) => i * 100 + 300));
|
|
134
|
+
const data = [...Array(bounds.length - 1).keys()].map((i) => {
|
|
135
|
+
const nodeWidth = substract(bounds[i + 1], bounds[i]);
|
|
136
|
+
const nodeHeight = heightPool[i].toTree();
|
|
137
|
+
return multiply(nodeWidth, nodeHeight).simplify().evaluate();
|
|
138
|
+
});
|
|
139
|
+
const identifiers = {
|
|
140
|
+
bounds,
|
|
141
|
+
data,
|
|
142
|
+
};
|
|
143
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
144
|
+
};
|
|
145
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
146
|
+
return {
|
|
147
|
+
answer: getAnswer(identifiers),
|
|
148
|
+
instruction: getInstruction(identifiers),
|
|
149
|
+
keys: getKeys(identifiers),
|
|
150
|
+
answerFormat: "tex",
|
|
151
|
+
identifiers,
|
|
152
|
+
hint: getHint(identifiers),
|
|
153
|
+
correction: getCorrection(identifiers),
|
|
154
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
export const etendueHistogram = {
|
|
158
|
+
id: "etendueHistogram",
|
|
159
|
+
label: "Calcul de l'étendue d'un histogramme",
|
|
160
|
+
isSingleStep: true,
|
|
161
|
+
generator: (nb, opts) => getDistinctQuestions(() => getEtendueHistogramQuestion(opts), nb),
|
|
162
|
+
qcmTimer: 60,
|
|
163
|
+
freeTimer: 60,
|
|
164
|
+
getPropositions,
|
|
165
|
+
isAnswerValid,
|
|
166
|
+
subject: "Mathématiques",
|
|
167
|
+
getHint,
|
|
168
|
+
getCorrection,
|
|
169
|
+
getInstruction,
|
|
170
|
+
getAnswer,
|
|
171
|
+
getGGBOptions,
|
|
172
|
+
hasGeogebra: true,
|
|
173
|
+
getQuestionFromIdentifiers,
|
|
174
|
+
hasHintAndCorrection: true,
|
|
175
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
isMax: boolean;
|
|
4
|
+
bounds: number[];
|
|
5
|
+
data: number[];
|
|
6
|
+
};
|
|
7
|
+
export declare const histogramCommenting: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=histogramCommenting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogramCommenting.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/histogram/histogramCommenting.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AA6BrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAiRF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAmBrD,CAAC"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
4
|
+
import { frenchify } from "../../../../math/utils/latex/frenchify.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { round } from "../../../../math/utils/round.js";
|
|
7
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
8
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
10
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
11
|
+
import { probaFlip } from "../../../../utils/alea/probaFlip.js";
|
|
12
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
13
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
14
|
+
import { mdTable } from "../../../../utils/markdown/mdTable.js";
|
|
15
|
+
const getStrStatClassForIndexCateg = (indexCateg, data, bounds) => {
|
|
16
|
+
const labels = bounds.map(frenchify);
|
|
17
|
+
const isLastCateg = indexCateg == data.length;
|
|
18
|
+
return `[${labels[indexCateg]};${labels[indexCateg + 1]}${isLastCateg ? "]" : "["}`;
|
|
19
|
+
};
|
|
20
|
+
const getPropositions = (_, { answer, ...identifiers }) => {
|
|
21
|
+
const propositions = [];
|
|
22
|
+
const { data } = identifiers;
|
|
23
|
+
const arrStr = [...data.map((_, i) => i), -1].map((i) => getStrForAnswerIndex(i, identifiers));
|
|
24
|
+
arrStr.forEach((str) => {
|
|
25
|
+
if (str === answer) {
|
|
26
|
+
addValidProp(propositions, str, "raw");
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
tryToAddWrongProp(propositions, str, "raw");
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return propositions;
|
|
33
|
+
};
|
|
34
|
+
const getAnswerIndex = (identifiers) => {
|
|
35
|
+
const { data, isMax } = identifiers;
|
|
36
|
+
return data.slice(1).reduce((acc, x, i) => {
|
|
37
|
+
if (acc.value === x) {
|
|
38
|
+
return {
|
|
39
|
+
index: -1,
|
|
40
|
+
value: acc.value,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const isLess = acc.value < x;
|
|
45
|
+
if (isMax ? isLess : !isLess) {
|
|
46
|
+
return {
|
|
47
|
+
index: i + 1,
|
|
48
|
+
value: x,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return acc;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
index: 0,
|
|
57
|
+
value: data[0],
|
|
58
|
+
}).index;
|
|
59
|
+
};
|
|
60
|
+
const getStrForAnswerIndex = (indexAnswer, identifiers) => {
|
|
61
|
+
switch (indexAnswer) {
|
|
62
|
+
case -1: {
|
|
63
|
+
return "Les classes ont le même effectif.";
|
|
64
|
+
}
|
|
65
|
+
default: {
|
|
66
|
+
const { data, bounds } = identifiers;
|
|
67
|
+
return getStrStatClassForIndexCateg(indexAnswer, data, bounds);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const getAnswer = (identifiers) => {
|
|
72
|
+
return getStrForAnswerIndex(getAnswerIndex(identifiers), identifiers);
|
|
73
|
+
};
|
|
74
|
+
const getInstruction = (identifiers) => {
|
|
75
|
+
const { isMax } = identifiers;
|
|
76
|
+
return `Un producteur trie sa récolte de pommes selon leur diamètre. L'histogramme ci-dessous représente ses résultats.
|
|
77
|
+
|
|
78
|
+
Quelle est la classe statistique avec l'effectif ${isMax ? "le plus grand" : "le plus petit"} ?
|
|
79
|
+
`;
|
|
80
|
+
};
|
|
81
|
+
const getHint = () => {
|
|
82
|
+
return `Dans un histogramme, l'effectif d'une classe est donné par l'aire du rectangle
|
|
83
|
+
compris entre les deux bornes de la classe.`;
|
|
84
|
+
};
|
|
85
|
+
const getCorrection = (identifiers) => {
|
|
86
|
+
const { bounds, data, isMax } = identifiers;
|
|
87
|
+
const arrDict = data.map((_, i) => {
|
|
88
|
+
const upperBound = bounds[i + 1];
|
|
89
|
+
const lowerBound = bounds[i];
|
|
90
|
+
const nodeWidth = substract(upperBound, lowerBound).simplify();
|
|
91
|
+
const nodeHeight = frac(data[i], nodeWidth).simplify();
|
|
92
|
+
return {
|
|
93
|
+
width: nodeWidth.evaluate(),
|
|
94
|
+
height: nodeHeight.evaluate(),
|
|
95
|
+
area: data[i],
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
return `Voici un tableau représentant les données de l'histogramme :
|
|
99
|
+
|
|
100
|
+
${mdTable([
|
|
101
|
+
[
|
|
102
|
+
"\\text{}",
|
|
103
|
+
...data.map((_, i) => getStrStatClassForIndexCateg(i, data, bounds)),
|
|
104
|
+
],
|
|
105
|
+
["\\text{largeur}", ...arrDict.map((dict) => dict["width"].frenchify())],
|
|
106
|
+
["\\text{hauteur}", ...arrDict.map((dict) => dict["height"].frenchify())],
|
|
107
|
+
["\\text{effectif}", ...arrDict.map((dict) => dict["area"].frenchify())],
|
|
108
|
+
], true)}
|
|
109
|
+
|
|
110
|
+
On peut conclure que ${(() => {
|
|
111
|
+
const indexAnswer = getAnswerIndex(identifiers);
|
|
112
|
+
switch (indexAnswer) {
|
|
113
|
+
case -1:
|
|
114
|
+
return "les classes ont le même effectif";
|
|
115
|
+
default:
|
|
116
|
+
return `la classe statistique avec l'effectif ${isMax ? "le plus grand" : "le plus petit"} est $${getStrForAnswerIndex(indexAnswer, identifiers)}$`;
|
|
117
|
+
}
|
|
118
|
+
})()}.`;
|
|
119
|
+
};
|
|
120
|
+
const getGGBOptions = (identifiers) => {
|
|
121
|
+
const { bounds, data } = identifiers;
|
|
122
|
+
const heights = [];
|
|
123
|
+
for (let i = 0; i < data.length; i++) {
|
|
124
|
+
const width = bounds[i + 1] - bounds[i];
|
|
125
|
+
const height = data[i] / width;
|
|
126
|
+
heights.push(height);
|
|
127
|
+
}
|
|
128
|
+
const offsetX = -bounds[0] + 1;
|
|
129
|
+
const offsettedBounds = bounds.map((bound) => bound + offsetX);
|
|
130
|
+
// const xMin = offsettedBounds[0];
|
|
131
|
+
const xMax = offsettedBounds[offsettedBounds.length - 1];
|
|
132
|
+
// const heightMin = 0;
|
|
133
|
+
const heightMax = Math.max(...heights);
|
|
134
|
+
const commands = [
|
|
135
|
+
`B = Histogram({${offsettedBounds}}, {${heights.join(",")}})`,
|
|
136
|
+
...bounds.map((bound, i) => `XBound_{${i}} = Text("\\footnotesize ${bound.frenchify()}", (${offsettedBounds[i]}, 0), true, true, 0, -1)`),
|
|
137
|
+
`ShowLabel(B,false)`,
|
|
138
|
+
...heights.map((height, i) => `YBound_{${i}} = Text("\\footnotesize ${round(height, 0).frenchify()}", (0, ${height}), true, true, 0, 0)`),
|
|
139
|
+
];
|
|
140
|
+
const ggb = new GeogebraConstructor({
|
|
141
|
+
commands,
|
|
142
|
+
hideGrid: true,
|
|
143
|
+
fontSize: 16,
|
|
144
|
+
lockedAxesRatio: false,
|
|
145
|
+
xAxis: {
|
|
146
|
+
hideNumbers: true,
|
|
147
|
+
showPositive: true,
|
|
148
|
+
label: "$\\footnotesize Diamètre (cm)$",
|
|
149
|
+
},
|
|
150
|
+
yAxis: {
|
|
151
|
+
showPositive: true,
|
|
152
|
+
label: "$\\footnotesize Pommes/cm$",
|
|
153
|
+
hideNumbers: true,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
return ggb.getOptions({
|
|
157
|
+
coords: ggb.getAdaptedCoords({
|
|
158
|
+
xMin: -xMax * 0.1,
|
|
159
|
+
xMax: xMax * 1.5,
|
|
160
|
+
yMin: -heightMax * 0.25,
|
|
161
|
+
yMax: heightMax * 1.5,
|
|
162
|
+
}),
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
const getHistogramCommentingQuestion = () => {
|
|
166
|
+
// const boundsRaw: number[] = [11.5, 12, 13.5, 15, 15.5, 16, 16.2];
|
|
167
|
+
// const nbBounds = 3;
|
|
168
|
+
const bounds = random([
|
|
169
|
+
[11.5, 12, 13.5],
|
|
170
|
+
[12, 13.5, 15],
|
|
171
|
+
[13.5, 15, 15.5],
|
|
172
|
+
[15.5, 16, 16.2],
|
|
173
|
+
]);
|
|
174
|
+
const offsetY = randint(2, 6) * 100;
|
|
175
|
+
const heightPool = shuffle([...Array(20).keys()].map((i) => i * 100 + offsetY));
|
|
176
|
+
let data;
|
|
177
|
+
if (probaFlip(0.36) && bounds[1] !== 13.5) {
|
|
178
|
+
//same height
|
|
179
|
+
const nodeHeightSame = heightPool[0];
|
|
180
|
+
data = [...Array(bounds.length - 1).keys()].map((i) => {
|
|
181
|
+
const nodeWidth = substract(bounds[i + 1], bounds[i]);
|
|
182
|
+
const nodeHeight = nodeHeightSame;
|
|
183
|
+
return multiply(nodeWidth, nodeHeight).simplify().evaluate();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
//different heights
|
|
188
|
+
if (probaFlip(0.48) && bounds[1] !== 13.5) {
|
|
189
|
+
//same data
|
|
190
|
+
const dictDataSame = heightPool.reduce((acc, _, i) => {
|
|
191
|
+
const nodeHeight = heightPool[i].toTree();
|
|
192
|
+
[...Array(bounds.length - 1).keys()].forEach((i) => {
|
|
193
|
+
const nodeWidth = substract(bounds[i + 1], bounds[i]);
|
|
194
|
+
const data = multiply(nodeWidth, nodeHeight).simplify().evaluate();
|
|
195
|
+
if (!acc[data]) {
|
|
196
|
+
acc[data] = {};
|
|
197
|
+
}
|
|
198
|
+
acc[data][nodeWidth.evaluate()] = true;
|
|
199
|
+
});
|
|
200
|
+
return acc;
|
|
201
|
+
}, {});
|
|
202
|
+
const [dataSame, _] = random(Object.entries(dictDataSame).filter(([_, dictWidth]) => Object.keys(dictWidth).length >= 2));
|
|
203
|
+
data = [...Array(bounds.length - 1).keys()].map(() => +dataSame);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
data = [...Array(bounds.length - 1).keys()].map((i) => {
|
|
207
|
+
const nodeWidth = substract(bounds[i + 1], bounds[i]);
|
|
208
|
+
const nodeHeight = heightPool[i].toTree();
|
|
209
|
+
return multiply(nodeWidth, nodeHeight).simplify().evaluate();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const identifiers = {
|
|
214
|
+
isMax: coinFlip(),
|
|
215
|
+
bounds,
|
|
216
|
+
data,
|
|
217
|
+
};
|
|
218
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
219
|
+
};
|
|
220
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
221
|
+
return {
|
|
222
|
+
answer: getAnswer(identifiers),
|
|
223
|
+
instruction: getInstruction(identifiers),
|
|
224
|
+
keys: [],
|
|
225
|
+
answerFormat: "tex",
|
|
226
|
+
identifiers,
|
|
227
|
+
hint: getHint(identifiers),
|
|
228
|
+
correction: getCorrection(identifiers),
|
|
229
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
export const histogramCommenting = {
|
|
233
|
+
id: "histogramCommenting",
|
|
234
|
+
label: "Commenter un histogramme",
|
|
235
|
+
isSingleStep: true,
|
|
236
|
+
generator: (nb, opts) => getDistinctQuestions(() => getHistogramCommentingQuestion(opts), nb),
|
|
237
|
+
qcmTimer: 60,
|
|
238
|
+
freeTimer: 60,
|
|
239
|
+
getPropositions,
|
|
240
|
+
subject: "Mathématiques",
|
|
241
|
+
getHint,
|
|
242
|
+
getCorrection,
|
|
243
|
+
getInstruction,
|
|
244
|
+
getAnswer,
|
|
245
|
+
getGGBOptions,
|
|
246
|
+
hasGeogebra: true,
|
|
247
|
+
getQuestionFromIdentifiers,
|
|
248
|
+
hasHintAndCorrection: true,
|
|
249
|
+
answerType: "QCU",
|
|
250
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
bounds: number[];
|
|
4
|
+
data: number[];
|
|
5
|
+
initTable: string[][];
|
|
6
|
+
};
|
|
7
|
+
export declare const histogramFillDataTableFromHistogramData: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=histogramFillDataTableFromHistogramData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogramFillDataTableFromHistogramData.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/histogram/histogramFillDataTableFromHistogramData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAwDrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAyJF,eAAO,MAAM,uCAAuC,EAAE,QAAQ,CAAC,WAAW,CAsBzE,CAAC"}
|
package/lib/exercises/math/dataRepresentations/histogram/histogramFillDataTableFromHistogramData.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
2
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
3
|
+
import { frenchify } from "../../../../math/utils/latex/frenchify.js";
|
|
4
|
+
import { round } from "../../../../math/utils/round.js";
|
|
5
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
6
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
7
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
8
|
+
import { numberParser } from "../../../../tree/parsers/numberParser.js";
|
|
9
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
10
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
import { mdTable } from "../../../../utils/markdown/mdTable.js";
|
|
13
|
+
const getStrStatClassForIndexCateg = (indexCateg, data, bounds) => {
|
|
14
|
+
const labels = bounds.map(frenchify);
|
|
15
|
+
const isLastCateg = indexCateg == data.length;
|
|
16
|
+
return `[${labels[indexCateg]};${labels[indexCateg + 1]}${isLastCateg ? "]" : "["}`;
|
|
17
|
+
};
|
|
18
|
+
const getTableForHistogramData = (data, bounds) => {
|
|
19
|
+
const arrDict = data.map((_, i) => {
|
|
20
|
+
const upperBound = bounds[i + 1];
|
|
21
|
+
const lowerBound = bounds[i];
|
|
22
|
+
const nodeWidth = substract(upperBound, lowerBound).simplify();
|
|
23
|
+
const nodeHeight = frac(data[i], nodeWidth).simplify();
|
|
24
|
+
return {
|
|
25
|
+
width: nodeWidth.evaluate(),
|
|
26
|
+
height: nodeHeight.evaluate(),
|
|
27
|
+
area: data[i],
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return [
|
|
31
|
+
[
|
|
32
|
+
"\\text{Diamètre(cm)}",
|
|
33
|
+
...data.map((_, i) => getStrStatClassForIndexCateg(i, data, bounds)),
|
|
34
|
+
],
|
|
35
|
+
["\\text{largeur}", ...arrDict.map((dict) => dict["width"].frenchify())],
|
|
36
|
+
["\\text{hauteur}", ...arrDict.map((dict) => dict["height"].frenchify())],
|
|
37
|
+
["\\text{effectif}", ...arrDict.map((dict) => dict["area"].frenchify())],
|
|
38
|
+
];
|
|
39
|
+
};
|
|
40
|
+
const getAnswerTable = (identifiers) => {
|
|
41
|
+
const { data, bounds } = identifiers;
|
|
42
|
+
return getTableForHistogramData(data, bounds);
|
|
43
|
+
};
|
|
44
|
+
const getInstruction = () => {
|
|
45
|
+
return `Remplir le tableau avec les données issues de l'histogramme ci-dessous.`;
|
|
46
|
+
};
|
|
47
|
+
const getHint = () => {
|
|
48
|
+
return `Dans un histogramme, l'effectif d'une classe est donné par l'aire du rectangle
|
|
49
|
+
compris entre les deux bornes de la classe.`;
|
|
50
|
+
};
|
|
51
|
+
const getCorrection = (identifiers) => {
|
|
52
|
+
const { data, bounds } = identifiers;
|
|
53
|
+
return `On peut représenter l'histogramme par le tableau suivant :
|
|
54
|
+
|
|
55
|
+
${mdTable(getTableForHistogramData(data, bounds), true)}
|
|
56
|
+
|
|
57
|
+
`;
|
|
58
|
+
};
|
|
59
|
+
const getGGBOptions = (identifiers) => {
|
|
60
|
+
const { data, bounds } = identifiers;
|
|
61
|
+
const heights = [];
|
|
62
|
+
for (let i = 0; i < data.length; i++) {
|
|
63
|
+
const width = bounds[i + 1] - bounds[i];
|
|
64
|
+
const height = data[i] / width;
|
|
65
|
+
heights.push(height);
|
|
66
|
+
}
|
|
67
|
+
const offsetX = -bounds[0] + 1;
|
|
68
|
+
const offsettedBounds = bounds.map((bound) => bound + offsetX);
|
|
69
|
+
// const xMin = offsettedBounds[0];
|
|
70
|
+
const xMax = offsettedBounds[offsettedBounds.length - 1];
|
|
71
|
+
// const heightMin = 0;
|
|
72
|
+
const heightMax = Math.max(...heights);
|
|
73
|
+
const commands = [
|
|
74
|
+
`B = Histogram({${offsettedBounds}}, {${heights.join(",")}})`,
|
|
75
|
+
...bounds.map((bound, i) => `XBound_{${i}} = Text("\\footnotesize ${bound.frenchify()}", (${offsettedBounds[i]}, 0), true, true, 0, -1)`),
|
|
76
|
+
`ShowLabel(B,false)`,
|
|
77
|
+
...heights.map((height, i) => `YBound_{${i}} = Text("\\footnotesize ${round(height, 0).frenchify()}", (0, ${height}), true, true, 0, 0)`),
|
|
78
|
+
];
|
|
79
|
+
const ggb = new GeogebraConstructor({
|
|
80
|
+
commands,
|
|
81
|
+
hideGrid: true,
|
|
82
|
+
fontSize: 16,
|
|
83
|
+
lockedAxesRatio: false,
|
|
84
|
+
xAxis: {
|
|
85
|
+
hideNumbers: true,
|
|
86
|
+
showPositive: true,
|
|
87
|
+
label: "$\\footnotesize Diamètre (cm)$",
|
|
88
|
+
},
|
|
89
|
+
yAxis: {
|
|
90
|
+
showPositive: true,
|
|
91
|
+
label: "$\\footnotesize Pommes/cm$",
|
|
92
|
+
hideNumbers: true,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
return ggb.getOptions({
|
|
96
|
+
coords: ggb.getAdaptedCoords({
|
|
97
|
+
xMin: -xMax * 0.1,
|
|
98
|
+
xMax: xMax * 1.5,
|
|
99
|
+
yMin: -heightMax * 0.25,
|
|
100
|
+
yMax: heightMax * 1.5,
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const getKeys = () => {
|
|
105
|
+
return ["lbracket", "rbracket", "semicolon"];
|
|
106
|
+
};
|
|
107
|
+
const isAnswerTableValid = (ans, { answerTable }) => {
|
|
108
|
+
try {
|
|
109
|
+
for (let i = 0; i < 2; i++) {
|
|
110
|
+
for (let j = 1; j < ans[i].length; j++) {
|
|
111
|
+
const ansParsed = numberParser(ans[i][j]);
|
|
112
|
+
const answerParsed = numberParser(answerTable[i][j]);
|
|
113
|
+
const valid = ansParsed === answerParsed;
|
|
114
|
+
if (!valid)
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
return handleVEAError(err);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const getHistogramFillDataTableFromHistogramDataQuestion = () => {
|
|
125
|
+
const boundsRaw = [11.5, 12, 13.5, 15, 15.5, 16, 16.2];
|
|
126
|
+
const nbBounds = 3;
|
|
127
|
+
const bounds = random([...Array(boundsRaw.length - nbBounds).keys()].map((i) => boundsRaw.slice(i, i + nbBounds)));
|
|
128
|
+
const heightPool = shuffle([...Array(10).keys()].map((i) => i * 100 + 300));
|
|
129
|
+
const data = [...Array(bounds.length - 1).keys()].map((i) => {
|
|
130
|
+
const nodeWidth = substract(bounds[i + 1], bounds[i]);
|
|
131
|
+
const nodeHeight = heightPool[i].toTree();
|
|
132
|
+
return multiply(nodeWidth, nodeHeight).simplify().evaluate();
|
|
133
|
+
});
|
|
134
|
+
const initTable = getTableForHistogramData(data, bounds).map((arr) => arr.map((str, i) => (i !== 0 ? "" : str)));
|
|
135
|
+
const identifiers = {
|
|
136
|
+
bounds,
|
|
137
|
+
data,
|
|
138
|
+
initTable,
|
|
139
|
+
};
|
|
140
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
141
|
+
};
|
|
142
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
143
|
+
return {
|
|
144
|
+
answerTable: getAnswerTable(identifiers),
|
|
145
|
+
instruction: getInstruction(identifiers),
|
|
146
|
+
answerFormat: "tex",
|
|
147
|
+
initTable: identifiers.initTable,
|
|
148
|
+
keys: getKeys(identifiers),
|
|
149
|
+
identifiers,
|
|
150
|
+
hint: getHint(identifiers),
|
|
151
|
+
correction: getCorrection(identifiers),
|
|
152
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
export const histogramFillDataTableFromHistogramData = {
|
|
156
|
+
id: "histogramFillDataTableFromHistogramData",
|
|
157
|
+
label: "Remplir un tableau avec les données issues d'un histogramme",
|
|
158
|
+
isSingleStep: true,
|
|
159
|
+
generator: (nb, opts) => getDistinctQuestions(() => getHistogramFillDataTableFromHistogramDataQuestion(opts), nb),
|
|
160
|
+
qcmTimer: 60,
|
|
161
|
+
freeTimer: 60,
|
|
162
|
+
subject: "Mathématiques",
|
|
163
|
+
isAnswerTableValid,
|
|
164
|
+
getAnswerTable,
|
|
165
|
+
getInstruction,
|
|
166
|
+
getGGBOptions,
|
|
167
|
+
hasGeogebra: true,
|
|
168
|
+
getQuestionFromIdentifiers,
|
|
169
|
+
getHint,
|
|
170
|
+
getCorrection,
|
|
171
|
+
hasHintAndCorrection: true,
|
|
172
|
+
answerType: "valueTable",
|
|
173
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
histogram: {
|
|
4
|
+
bounds: number[];
|
|
5
|
+
data: number[];
|
|
6
|
+
};
|
|
7
|
+
table: {
|
|
8
|
+
bounds: number[];
|
|
9
|
+
data: number[];
|
|
10
|
+
} | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare const histogramIsSameData: Exercise<Identifiers>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=histogramIsSameData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogramIsSameData.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/histogram/histogramIsSameData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAyErC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE;QACT,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,CAAC;IACF,KAAK,EACD;QACE,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,GACD,SAAS,CAAC;CACf,CAAC;AAmNF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAmBrD,CAAC"}
|