Solving literal equation answer checker

If I have the equation

v/r=t 

and I tell them to solve for r their answer would be

v/t

I know I can set up an answer check that something something like:

solution="v/t"

correct= when input.latex = solution "Correct" otherwise "incorrect

but if there is any spaces or just something small it will count it as incorrect. Is there a way to eliminate the error of something like an accidental space hit stopping the answer from being registered as correct?

If you use backticks instead of quote marks, that allows for spaces.

Does that do it?

Was getting an error. Below is an example of one of my questions. How would you change it to allow the spaces? (The ${val} are pulling from a random letter generator)

eq6="`${val}=${val2}${val3}${val4}+${val2}${val3}^{2}`"

content6= "Given: 
${eq6}
    
Solve for ${val4}"

solution6a="\frac{${val}-${val2}${val3}^{2}}{${val2}${val3}}=${val4}"
solution6b="${val4}=\frac{${val}-${val2}${val3}^{2}}{${val2}${val3}}"
solution6c="\frac{\left(${val}-${val2}${val3}^{2}\right)}{${val2}${val3}}=${val4}"
solution6d="${val4}=\frac{\left(${val}-${val2}${val3}^{2}\right)}{${val2}${val3}}"
solution6e="\frac{\left(${val}-${val2}${val3}^{2}\right)}{\left(${val2}${val3}\right)}=${val4}"
solution6f="${val4}=\frac{\left(${val}-${val2}${val3}^{2}\right)}{\left(${val2}${val3}\right)}"

I built out that one. apparently backticks with \frac because of the fraction.

Now maybe apply that to your code overall? I think for more flexible checks you’d have to add in some differenceFunction and evaluateAt statements. Like right now my example doesn’t allow v/t=ras a teacher-facing correct solution

Why not use a simpleFunction in two variables and check a variety of solutions?

Here is my code for 1 of the slides. How would you advise to implement simpleFunction?

r=randomGenerator()
valpick=r.int(1,15)

val= when valpick=1  "a"
     when valpick=2  "b"
     when valpick=3  "c"
     when valpick=4  "d"
     when valpick=5  "e"
     when valpick=6  "f"
     when valpick=7  "g"
     when valpick=8  "h"
     when valpick=9  "i"
     when valpick=10 "j"
     when valpick=11 "k"
     when valpick=12 "L"
     when valpick=13 "m"
     when valpick=14 "n"
     when valpick=15 "o"
     when valpick=16 "p"
     when valpick=17 "q"
     when valpick=18 "r"
     when valpick=19 "s"
     when valpick=20 "t"
     when valpick=21 "u"
     when valpick=22 "v"
     when valpick=23 "w"
     when valpick=24 "z"
     otherwise "x"

valpick2a=r.int(1,15)
valpick2aa= when valpick<21 numericValue("(${valpick})+(2)") otherwise numericValue("(${valpick})-(2)")
valpick2= when not(valpick=valpick2a) valpick2a otherwise valpick2aa

val2=when valpick2=1  "a"
     when valpick2=2  "b"
     when valpick2=3  "c"
     when valpick2=4  "d"
     when valpick2=5  "e"
     when valpick2=6  "f"
     when valpick2=7  "g"
     when valpick2=8  "h"
     when valpick2=9  "i"
     when valpick2=10 "j"
     when valpick2=11 "k"
     when valpick2=12 "y"
     when valpick2=13 "m"
     when valpick2=14 "n"
     when valpick2=15 "o"
     when valpick2=16 "p"
     when valpick2=17 "q"
     when valpick2=18 "r"
     when valpick2=19 "s"
     when valpick2=20 "t"
     when valpick2=21 "u"
     when valpick2=22 "v"
     when valpick2=23 "w"
     when valpick2=24 "z"
     otherwise "x"

valpick3a=r.int(1,15)
valpick3aa= when valpick<21 numericValue("(${valpick})+(2)") otherwise numericValue("(${valpick})-(2)")
valpick3aaa= when not(valpick=valpick3a) and not(valpick2=valpick3a) valpick3a otherwise valpick3aa
valpick3= when not(valpick3aaa=valpick) and not(valpick3aaa=valpick2) valpick3aaa otherwise 25

val3=when valpick3=1  "a"
     when valpick3=2  "b"
     when valpick3=3  "c"
     when valpick3=4  "d"
     when valpick3=5  "e"
     when valpick3=6  "f"
     when valpick3=7  "g"
     when valpick3=8  "h"
     when valpick3=9  "i"
     when valpick3=10 "j"
     when valpick3=11 "k"
     when valpick3=12 "y"
     when valpick3=13 "m"
     when valpick3=14 "n"
     when valpick3=15 "o"
     when valpick3=16 "p"
     when valpick3=17 "q"
     when valpick3=18 "r"
     when valpick3=19 "s"
     when valpick3=20 "t"
     when valpick3=21 "u"
     when valpick3=22 "v"
     when valpick3=23 "w"
     when valpick3=24 "z"
     otherwise "x"

val4a=numericValue("(${valpick})-(1)")
val4b=numericValue("(${valpick2})-(1)")
valpick4= when not(val4a=valpick2) and not(val4a=valpick3) val4a 
          when (val4a=valpick2 or val4a=valpick3) and not(val4b=valpick2) and not(val4b=valpick3) val4b 
          otherwise 25
val4=when valpick4=1  "a"
     when valpick4=2  "b"
     when valpick4=3  "c"
     when valpick4=4  "d"
     when valpick4=5  "e"
     when valpick4=6  "f"
     when valpick4=7  "g"
     when valpick4=8  "h"
     when valpick4=9  "i"
     when valpick4=10 "j"
     when valpick4=11 "k"
     when valpick4=12 "y"
     when valpick4=13 "m"
     when valpick4=14 "n"
     when valpick4=15 "o"
     when valpick4=16 "p"
     when valpick4=17 "q"
     when valpick4=18 "r"
     when valpick4=19 "s"
     when valpick4=20 "t"
     when valpick4=21 "u"
     when valpick4=22 "v"
     when valpick4=23 "w"
     when valpick4=24 "z"
     otherwise "x"     
     

####################################################
eq1="`\frac{${val}}{${val2}}=${val3}`"

content1= "Given: 
${eq1}
    
Solve for ${val2}"

solution1a="${val2}=\frac{${val}}{${val3}}"
solution1b="\frac{${val}}{${val3}}=${val2}"
####################################################
eq2="`${val}+${val2}=${val3}`"

content2= "Given: 
${eq2}
    
Solve for ${val}"

solution2a="${val}=${val3}-${val2}"
solution2b="${val}=-${val2}+${val3}"
solution2c="${val3}-${val2}=${val}"
solution2d="-${val2}+${val3}=${val}"
####################################################
eq3="`${val}-${val2}=${val3}`"

content3= "Given: 
${eq3}
    
Solve for ${val2}"

solution3a="${val2}=-${val3}+${val}"
solution3b="${val2}=${val}-${val3}"
solution3c="-${val3}+${val}=${val2}"
solution3d="${val}-${val3}=${val2}"
####################################################
eq4="`${val}=${val2}${val3}`"

content4= "Given: 
${eq4}
    
Solve for ${val2}"

solution4a="${val2}=\frac{${val}}{${val3}}"
solution4b="\frac{${val}}{${val3}}=${val2}"
####################################################
eq5="`${val}=\frac{${val2}}{${val3}}`"

content5= "Given: 
${eq5}
    
Solve for ${val2}"

solution5a="${val2}=${val}${val3}"
solution5b="${val}${val3}=${val2}"
solution5c="${val2}=(${val})(${val3})"
solution5d="(${val})(${val3})=${val2}"
solution5e="${val2}=${val}(${val3})"
solution5f="${val}(${val3})=${val2}"
solution5g="${val2}=(${val})${val3}"
solution5h="(${val})${val3}=${val2}"
####################################################
eq6="`${val}=${val2}${val3}${val4}+${val2}${val3}^{2}`"

content6= "Given: 
${eq6}
    
Solve for ${val4}"

solution6a="\frac{${val}-${val2}${val3}^{2}}{${val2}${val3}}=${val4}"
solution6b="${val4}=\frac{${val}-${val2}${val3}^{2}}{${val2}${val3}}"
solution6c="\frac{\left(${val}-${val2}${val3}^{2}\right)}{${val2}${val3}}=${val4}"
solution6d="${val4}=\frac{\left(${val}-${val2}${val3}^{2}\right)}{${val2}${val3}}"
solution6e="\frac{\left(${val}-${val2}${val3}^{2}\right)}{\left(${val2}${val3}\right)}=${val4}"
solution6f="${val4}=\frac{\left(${val}-${val2}${val3}^{2}\right)}{\left(${val2}${val3}\right)}"
####################################################
eq7="`${val}-${val2}=${val3}`"

content7= "Given: 
${eq3}
    
Solve for ${val}"

solution7a="${val}=${val3}+${val2}"
solution7b="${val}=${val2}+${val3}"
solution7c="${val3}+${val2}=${val}"
solution7d="+${val2}+${val3}=${val}"
####################################################


correct=when input.latex=solution1a 1 
        when input.latex=solution1b 1 
        when input.latex=solution2a 1
        when input.latex=solution2b 1
        when input.latex=solution2c 1
        when input.latex=solution2d 1
        when input.latex=solution3a 1
        when input.latex=solution3b 1
        when input.latex=solution3c 1
        when input.latex=solution3d 1
        when input.latex=solution4a 1
        when input.latex=solution4b 1
        when input.latex=solution5a 1
        when input.latex=solution5b 1
        when input.latex=solution5c 1
        when input.latex=solution5d 1
        when input.latex=solution5e 1
        when input.latex=solution5f 1
        when input.latex=solution5g 1
        when input.latex=solution5h 1
        when input.latex=solution6a 1
        when input.latex=solution6b 1
        when input.latex=solution6c 1
        when input.latex=solution6d 1
        when input.latex=solution6e 1
        when input.latex=solution6f 1
        when input.latex=solution7a 1
        when input.latex=solution7b 1
        when input.latex=solution7c 1
        when input.latex=solution7d 1 otherwise 0

co = when correct=1 "Correct, good work!" otherwise "Not there yet, keep working "

conpick=r.int(1,7)
con= when conpick =1 content1
     when conpick =2 content2
     when conpick =3 content3
     when conpick =4 content4
     when conpick =5 content5
     when conpick =6 content6
     when conpick =7 content7
     otherwise content1

#eq = when conpick =1 eq1
#     when conpick =2 eq2
#     when conpick =3 eq3
#     when conpick =4 eq4
#     when conpick =5 eq5
#     when conpick =6 eq6
#     when conpick =7 eq7
#     otherwise eq1

content: "${con}

Your Answer: ${co}

"

That works with static variables, but when using ${} in it it causes an error

Don’t use the ${}, just enter the variables. They should already be strings, right?:
simpleFunction(input.latex,val2,val3)

It is either the long school day today, or something else but I am having a hard time right now grasping what you are saying. Sorry man