$\textsf{1st numerator = %v}$

$\textsf{2nd numerator = %v}$

$\textsf{denominator = 4}$

$\text{Show Solution}$

$\textsf{2nd numerator = 1}$

$\text{PROBAR OTRO}$

$\text{SHOW SOLUTION}$

+

\textsf{denominador}

\text{Arrastra para colocar}

num2Min: 1
num2Val = 0.6666666666666666 (slider from 0 to 1, step num2Div)
denVal = 0.625 (slider from 0 to 1, step 1 / denRange)
denMax = 20 (slider from -5 to 20)
denMin = 4 (slider from -5 to 5)
countQuestion = 0
choicesQuestion = Flatten({1, Sequence[Shuffle[Sequence[1, 3]], n, 1, 33]})
testmode: false
testChoice: 3
choiceQuestion = If(testmode, testChoice, Element[choicesQuestion, Mod[countQuestion, 100] + 1])
den: floor(If[choiceQuestion < 3, denMax + ((denVal - 1) * (denMax - denMin)), Element[{4, 8, 16}, 3 + ((denVal - 1) * (3 - 1))]])
num1Min: 1
num1Val = 0.35714285714285715 (slider from 0 to 1, step 1 / num1Range)
initialize = true
numRandoms: 6
allRandoms = Sequence(Random[1, 99] / 100, A, 1, 200)
randIndex: (Mod[countQuestion, floor(Length[allRandoms] / numRandoms)] * numRandoms) + 1
currentRandomSeeds = Take(allRandoms, randIndex, randIndex + numRandoms - 1)
dens: {4 + floor((currentRandomSeeds(3) * 17)), 4 + floor((currentRandomSeeds(3) * 17)), 2^(2 + floor((currentRandomSeeds(3) * 3)))}
denStart: dens(choiceQuestion)
denShow = If(initialize, denStart, den)
num1Max: denShow - 1
num1Sli: floor(num1Max + ((num1Val - 1) * (num1Max - num1Min)))
num1Start: 1 + floor((currentRandomSeeds(2) * (denShow - 1)))
num1Show = If(initialize, num1Start, num1Sli)
num2Max = If(Defined[denShow - num1Show], denShow - num1Show, 1)
num2Start: num2Min + floor((currentRandomSeeds(3) * num2Max))
num2Sli: floor(num2Max + ((num2Val - 1) * (num2Max - num2Min)))
num2Show = If(initialize, num2Start, num2Sli)
onboarding = true
den3 = 4
segWidth = PixelsToDistance(200, Corner[1], Corner[3], Corner[5])
den3Sli = 1 (slider from 1 to 3, step 1)
PointInput2: (1, 5.3)
PointInput1: (-1, 5.3)
DragPoint1 = (-4.601803172090624, 8.492933839557427)
textFraction2: "\dfrac{\textcolor{#5145A8}{" + (LaTeX[num2Show]) + "}}{\textcolor{C75000}{" + (LaTeX[denShow]) + "}}"
textFraction1: "\dfrac{\textcolor{#0F8538}{" + (LaTeX[num1Show]) + "}}{\textcolor{C75000}{" + (LaTeX[denShow]) + "}}"
PointStart: (0, 0)
textFracDims2: {abs(x(Corner[textFraction2, 1]) - x(Corner[textFraction2, 3])), abs(y(Corner[textFraction2, 1]) - y(Corner[textFraction2, 3])), Corner[textFraction2, 4] - PointStart}
textFracDims1: {abs(x(Corner[textFraction1, 1]) - x(Corner[textFraction1, 3])), abs(y(Corner[textFraction1, 1]) - y(Corner[textFraction1, 3])), Corner[textFraction1, 4] - PointStart}
maxWidth: 0.95
maxHeight = 1.3120272000000008
boxInput2 = centerBox(maxWidth, maxHeight, PointInput2)
boxInput1 = centerBox(maxWidth, maxHeight, PointInput1)
boxFrac1 = centerBox(maxWidth, maxHeight, DragPoint1)
box1Corners = Sequence(Vertex[boxFrac1, n], n, 1, 4)
DragPoint2 = (6.1482128680096295, 8.492933839557427)
box2Filled: DragPoint1 ≟ PointInput2 ∨ DragPoint2 ≟ PointInput2
box1Filled: DragPoint1 ≟ PointInput1 ∨ DragPoint2 ≟ PointInput1
maxHeightPix = DistanceToPixels(Corner[1], Corner[3], Corner[5], maxHeight)
maxWidthPix = DistanceToPixels(Corner[1], Corner[3], Corner[5], maxWidth)
allItems1: {"pizza", "torta", "tarta", "barra de chocolate"}
item1 = RandomElement(allItems1)
textFrac1Pix: {DistanceToPixels[Corner[1], Corner[3], Corner[5], textFracDims1(1)], DistanceToPixels[Corner[1], Corner[3], Corner[5], textFracDims1(2)]}
allItems3: {"manzanas", "peras", "uvas", "zanahorias", "naranjas", "cebollas"}
tot: (num1Show + num2Show) / denShow
item31 = RandomElement(allItems3)
item32 = RandomElement(allItems3 \ {item31})
showSolution = false
textQuestion2: "\text{\vspace{" + (LaTeX[maxHeightPix / 2]) + "}\phantom{\;\hspace{" + (LaTeX[maxWidthPix]) + "}\;} de la clase hicieron su tarea a tiempo y \phantom{\;\hspace{" + (LaTeX[maxWidthPix]) + "}\;} de la clase debieron llevarla\\
\vspace{" + (LaTeX[maxHeightPix / 2]) + "}\\
y la terminaron en su casa. ¿Qué fracción de la clase finalizó su tarea?}"
AFake = PixelsToPoint(Corner[1], Corner[3], Corner[5], (500, 255))
BFake: AFake + (segWidth, 0)
fakeSli = Segment(AFake, BFake)
textQuestion3: "\text{\vspace{" + (LaTeX[maxHeightPix / 2]) + "}La balanza de la tienda muestra que las " + (LaTeX[item31]) + " pesan \phantom{\;\hspace{" + (LaTeX[maxWidthPix]) + "}\;} de una libra y\\
\vspace{" + (LaTeX[maxHeightPix / 2]) + "}\\
las " + (LaTeX[item32]) + " pesan \phantom{\;\hspace{" + (LaTeX[maxWidthPix]) + "}\;} de una libra. ¿Cuánto pesan ambas en total?"
textQuestion1: "\text{\vspace{" + (LaTeX[maxHeightPix / 2]) + "}Si una persona toma \phantom{\;\hspace{" + (LaTeX[maxWidthPix]) + "}\;} de una " + (LaTeX[item1]) + " 
y otra persona toma \phantom{\;\hspace{" + (LaTeX[maxWidthPix]) + "}\;} de la\\
\vspace{" + (LaTeX[maxHeightPix / 2]) + "}" + (LaTeX[item1]) + ", ¿qué parte de la " + (LaTeX[item1]) + " tomaron entre ambos?}"
Dims = Corner(5)
choiceItem3: 1 + floor((currentRandomSeeds(1) * 6))
l1: {"Si una persona toma", "", "La balanza del mercado muestra que las " + item31 + " pesan"}
l2: {"Si una persona toma \phantom{\;\hspace{" + maxWidthPix + "}\;} de una " + item1 + " y otra persona toma ", "\phantom{\;\hspace{" + maxWidthPix + "}\;} de la clase hicieron la tarea a tiempo y", "las " + item32 + " pesan"}
text1ForDims: "\text{" + (l1(choiceQuestion)) + "}"
text2ForDims: "\text{" + (l2(choiceQuestion)) + "}"
textDims1: {abs(x(Corner[text1ForDims, 1]) - x(Corner[text1ForDims, 3])), abs(y(Corner[text1ForDims, 1]) - y(Corner[text1ForDims, 3])), Corner[text1ForDims, 4] - PointStart}
textDims2: {abs(x(Corner[text2ForDims, 1]) - x(Corner[text2ForDims, 3])), abs(y(Corner[text2ForDims, 1]) - y(Corner[text2ForDims, 3])), Corner[text2ForDims, 4] - PointStart}
StartPixels = PixelsToPoint(Corner[1], Corner[3], Corner[5], (11, 20))
x1: x(StartPixels) + textDims1(1) + maxWidth / 2
y1: y(StartPixels) - maxHeight / 2
PointFrac1: (x1, y1)
textFrac2Pix: {DistanceToPixels[Corner[1], Corner[3], Corner[5], textFracDims2(1)], DistanceToPixels[Corner[1], Corner[3], Corner[5], textFracDims2(2)]}
x2: x(StartPixels) + textDims2(1) + maxWidth / 2
y2 = If(choiceQuestion < 3, y(StartPixels) - maxHeight / 2, y(StartPixels) - (3 * maxHeight / 2))
PointFrac2: (x2, y2)
boxFrac2 = centerBox(maxWidth, maxHeight, DragPoint2)
box2Corners = Sequence(Vertex[boxFrac2, n], n, 1, 4)
bools1: {true ∈ Zip[IsInRegion[n, boxInput1], n, box1Corners] ∧ (¬box1Filled), true ∈ Zip[IsInRegion[n, boxInput2] ∧ (¬box2Filled), n, box1Corners]}
bools2: {true ∈ Zip[IsInRegion[n, boxInput1], n, box2Corners] ∧ (¬box1Filled), true ∈ Zip[IsInRegion[n, boxInput2] ∧ (¬box2Filled), n, box2Corners]}
SnapPoint1 = If(bools1(1), PointInput1, bools1(2), PointInput2, PointFrac1)
SnapPoint2 = If(bools2(1), PointInput1, bools2(2), PointInput2, PointFrac2)
box1Moving: DragPoint1 ≠ PointFrac1 ∧ DragPoint1 ≠ PointInput1 ∧ DragPoint1 ≠ PointInput2
box2Moving: DragPoint2 ≠ PointFrac2 ∧ DragPoint2 ≠ PointInput1 ∧ DragPoint2 ≠ PointInput2
dimensions: {-9.674199999999995, -2.5340000000000082, 9.734200000000008, 9.6144}
inBox1: bools1(1) ∨ bools2(1)
inBox2: bools1(2) ∨ bools2(2)
PointHighlight = If(inBox1, PointInput1, inBox2, PointInput2, (-100, -100))
boxHighlight = centerBox(maxWidth, maxHeight, PointHighlight)
textFraction1DisplayDrag: "" + (LaTeX[textFraction1]) + ""
textFraction2DisplayDrag: "" + (LaTeX[textFraction2]) + ""
PointFrac1Drag: DragPoint1 - (textFracDims1(1) / 2, ((-textFracDims1(2))) / 2) - textFracDims1(3)
PointFrac2Drag: DragPoint2 - (textFracDims2(1) / 2, ((-textFracDims2(2))) / 2) - textFracDims2(3)
textFraction1Display: "" + (LaTeX[textFraction1]) + ""
textFraction2Display: "" + (LaTeX[textFraction2]) + ""
PointFrac1Display: PointFrac1 - (textFracDims1(1) / 2, ((-textFracDims1(2))) / 2) - textFracDims1(3)
PointFrac2Display: PointFrac2 - (textFracDims2(1) / 2, ((-textFracDims2(2))) / 2) - textFracDims2(3)
textAnswer: "\dfrac{" + (LaTeX[num1Show + num2Show]) + "}{\textcolor{C75000}{" + (LaTeX[denShow]) + "}}"
boxesFilled: box1Filled ∧ box2Filled
correctFound = false
showNew = true
pulsingSpeed: 8
pulsing = 0.7 (slider from 0 to 1, step 0.1)
pulsing2 = 1 (slider from 0 to 1, step 0.1)
OnboardingPointD: Midpoint[box1Corners(1), box1Corners(2)] - (0, y2 - y(StartPixels) + maxHeight + 1)
OnboardingPoint: PointToPixels[Corner[1], Corner[3], Corner[5], OnboardingPointD] - (12, 0)
onboardingCase: 3
onboardingX: x(OnboardingPoint)
onboardingY: y(OnboardingPoint)
OnboardingTextOffset = onboardingTextOffset(Corner[onboardingText, 1], Corner[onboardingText, 3], onboardingCase, Corner[1], Corner[3], Corner[5])
onboardingDisplayText: "" + (LaTeX[onboardingText]) + ""
onboardingTextX: onboardingX + x(OnboardingTextOffset)
onboardingTextY: onboardingY + y(OnboardingTextOffset)
input1Corners = Sequence(Vertex[boxInput1, n], n, 1, 4)
pulsingObject = expandQuad(box1Corners(1), box1Corners(2), box1Corners(3), box1Corners(4), (7 * pulsing), Corner[1], Corner[3], Corner[5])
pulsingObject1 = expandQuad(input1Corners(1), input1Corners(2), input1Corners(3), input1Corners(4), pulsing2, Corner[1], Corner[3], Corner[5])
textEquals: "=" + (LaTeX[textAnswer]) + ""
denRange = If(choiceQuestion < 3, denMax - denMin, 2)
denIndStart = If(choiceQuestion < 3, (denStart - denMin) / denRange, (IndexOf[denStart, {4, 8, 16}] - 1) / 2)
num1Range: num1Max - num1Min
num1IndStart: (num1Start - num1Min) / num1Range
num2Range: num2Max - num2Min
num2Div = If(num2Range > 0, 1 / num2Range, 0.5)
num2IndStart = If(num2Range > 0, (num2Start - num2Min) / num2Range, 1)
textSolution2: "\text{\bold{Solución:}\\\\
\[\frac{\bold\textcolor{#0F8538}{ " + (LaTeX[num1Show]) + "}}{\bold\textcolor{#C75000}{" + (LaTeX[denShow]) + "} }+\frac{\bold\textcolor{#5145A8}{" + (LaTeX[num2Show]) + " }}{\bold\textcolor{#C75000}{ " + (LaTeX[denShow]) + "}}=\frac{\bold{" + (LaTeX[num1Show + num2Show]) + "} }{\bold\textcolor{#C75000}{ " + (LaTeX[denShow]) + "}}\] \longrightarrow 
\[\frac{\bold{" + (LaTeX[num1Show + num2Show]) + "} }{\bold\textcolor{#C75000}{" + (LaTeX[denShow]) + "} }\] de la clase " + (LaTeX[If[IsInteger[tot], "(toda la clase) ", ""]]) + "finalizó su tarea.}"
textSolution3: "\text{\bold{Solución:}\\\\
\[\frac{\bold\textcolor{#0F8538}{" + (LaTeX[num1Show]) + "}}{\bold\textcolor{#C75000}{" + (LaTeX[denShow]) + " }}+\frac{\bold\textcolor{#5145A8}{" + (LaTeX[num2Show]) + "}}{\bold\textcolor{#C75000}{ " + (LaTeX[denShow]) + "}}=\frac{\bold{" + (LaTeX[num1Show + num2Show]) + "}}{\bold\textcolor{#C75000}{ " + (LaTeX[denShow]) + "}}\] \longrightarrow
En total pesan \[\frac{\bold{ " + (LaTeX[num1Show + num2Show]) + "}}{\bold\textcolor{#C75000}{ " + (LaTeX[denShow]) + "}}\] de una libra" + (LaTeX[If[IsInteger[tot], " (1 libra).", "."]]) + "}"
num2SetVal = 5
num2SetInd = If(num2Range > 0 ∧ num2SetVal ≤ num2Max, (num2SetVal - num2Min) / num2Range, 1)
textSolution1: "\text{\bold{Solución:}\\\\
\[\frac{\bold\textcolor{#0F8538}{" + (LaTeX[num1Show]) + "}}{\bold\textcolor{#C75000}{" + (LaTeX[denShow]) + "}}+\frac{\bold\textcolor{#5145A8}{" + (LaTeX[num2Show]) + "}}{\bold\textcolor{#C75000}{" + (LaTeX[denShow]) + "}}=\frac{\bold{" + (LaTeX[num1Show + num2Show]) + "}}{\bold\textcolor{#C75000}{" + (LaTeX[denShow]) + "}}\] \longrightarrow
Tomaron \[\frac{\bold{" + (LaTeX[num1Show + num2Show]) + "}}{\bold\textcolor{#C75000}{" + (LaTeX[denShow]) + "}}\] de la " + (LaTeX[item1]) + "" + (LaTeX[If[IsInteger[tot], ((" (toda la " * item1) * ")"), ""]]) + ".}"
correctFrac: (num1Show + num2Show) / denShow
num1SetVal = 6
num1SetInd = If(num1Range > 0 ∧ num1SetVal ≤ num1Max, (num1SetVal - num1Min) / num1Range, 1)
textValDen3: "" + denShow + ""
tabOrder: {textQuestion1, textQuestion2, textQuestion3, boxFrac1, boxFrac1, num1Val, num2Val, denVal, textSolution1, textSolution2, textSolution3, btnNew}
textNumerator1: "\textsf{" + (LaTeX[If[choiceQuestion ≟ 1, "numerador de 1.^{a} " + item1, choiceQuestion ≟ 2, "primer numerador", "numerador de las " + item31]]) + "}"
textNumerator2: "\textsf{" + (LaTeX[If[choiceQuestion ≟ 1, "numerador de 2.^{a} " + item1, choiceQuestion ≟ 2, "segundo numerador", "numerador de las " + item32]]) + "}"

Tool: centerBox
(width,height,CenterPoint)
Input: width, length, StartPoint
Output: myBox

StartPoint: (0, 0)
A: StartPoint + (((-width)) / 2, ((-length)) / 2)
D: A + (0, length)
B: A + (width, 0)
C: A + (width, length)
myBox = Polygon({A, B, C, D})

Tool: DistanceToPixels
DistanceToPixels[ <Number>, <Point>, <Point>, <Point> ]
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputDistance

xLeft: x(Corner1)
xRight: x(Corner3)
OutputDistance: (InputPixels * x(Corner5) / (xRight - xLeft))

Tool: PixelsToPoint
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: PixelsToDistance
PixelsToDistance[ <Number>, <Point>, <Point>, <Point> ]
Input: InputPixels, Corner1, Corner3, Corner5
Output: OutputDistance

InputPixels: 5
xLeft: x(Corner1)
xRight: x(Corner3)
OutputDistance: (InputPixels / x(Corner5) * (xRight - xLeft))

Tool: PointToPixels
PointToPixels(Corner1,Corner3,Corner5,InputPoint)
Input: Corner1, Corner3, Corner5, InputPoint
Output: OutputPixels

Corner1: (-5, -5)
Corner3: (16, 6)
Corner5: (300, 200)
xLeft: x(Corner1)
xRight: x(Corner3)
yTop: y(Corner3)
yBottom: y(Corner1)
yPixels: (y(Corner5) * (yTop - y(InputPoint)) / (yTop - yBottom))
xPixels: (x(Corner5) * (x(InputPoint) - xLeft) / (xRight - xLeft))
OutputPixels: (xPixels, yPixels)

Tool: onboardingTextOffset
onboardingTextOffset(textCorner1,textCorner3,case,corner1,corner3,corner5)
Input: CornerText1, CornerText3, case, Corner1, Corner3, Corner5
Output: TextOffset

xPixels: ((x(CornerText3) - x(CornerText1)) * x(Corner5) / (x(Corner3) - x(Corner1)))
yPixels: ((y(CornerText3) - y(CornerText1)) * y(Corner5) / (y(Corner3) - y(Corner1)))
xOffset = Element({27, (-xPixels) + 2, 16 - xPixels / 2, 16 - xPixels / 2}, case)
yOffset = Element({-23, -23, yPixels - 27, -49}, case)
TextOffset: (xOffset, yOffset)

Tool: expandQuad
expandQuad(A,B,C,D,pixelGap,Corner1,Corner3,Corner5)
Input: A, B, C, D, pixelGap, Corner1, Corner3, Corner5
Output: newPolygon

Corner5: (800, 500)
Corner3: (7, 6)
Corner1: (-4, -2)
distanceY: (pixelGap / y(Corner5) * (y(Corner3) - y(Corner1)))
distanceX: (pixelGap / x(Corner5) * (x(Corner3) - x(Corner1)))
pointGap: distanceX
allVerts: {A, B, C, D}
concaveAngles = Zip(Angle[I, J, K] > 180°, I, Append[allVerts(-1), allVerts], J, allVerts, K, Append[Take[allVerts, 2], allVerts(1)])
allVecs = Zip(Vector[J, K], J, allVerts, K, Append[Take[allVerts, 2], allVerts(1)])
pVecs = Zip(Vector[UnitOrthogonalVector[A]], Vector[A], allVecs)
xyScale: (distanceY) / (distanceX)
circTemplate = CurveCartesian((pointGap * cos(t)), ((xyScale * pointGap) * sin(t)), t, 0, (2 * pi))
scaledVecs = Zip(Vector[(x(K), (xyScale * y(K)))], Vector[K], pVecs)
vPointsPre = Zip(A - (pointGap * B), A, allVerts, B, Append[scaledVecs(-1), scaledVecs])
vPointsPost = Zip(A - (pointGap * B), A, allVerts, Vector[B], scaledVecs)
endAngles = Zip(Angle[M + (1, 0), M, K], K, vPointsPost, M, allVerts)
startAngles = Zip(Angle[M + (1, 0), M, K], K, vPointsPre, J, vPointsPost, M, allVerts)
roundedCornersConvex = Zip(Sequence[circTemplate(K) + A, K, B, C + If[B > C, (2 * pi), 0], (C + If[B > C, (2 * pi), 0] - B) / 4], A, allVerts, B, endAngles, C, startAngles)
roundedCornersConcave = Zip(Sequence[circTemplate(K) + A, K, B, C + If[B > C, (2 * pi), 0], (C + If[B > C, (2 * pi), 0] - B) / 4], A, allVerts, B, startAngles, C, endAngles)
cornerAngles = Zip(Angle[A, B, C], A, vPointsPre, B, allVerts, C, vPointsPost)
cornerPoints = Flatten(Zip[If[¬Concave, {Element[D, 3]}, If[A < pi / 3 ∨ (¬Concave), {Element[C, 3]}, C]], A, cornerAngles, C, roundedCornersConcave, D, roundedCornersConvex, Concave, concaveAngles])
newPolygon = Polygon(cornerPoints)