Then you can use the numericValue function… so slope1.numericValue=numericValue("2/3") should accept any equivalent to 2/3 - including, I just discovered, manually typing 0.6666666666666666 with at least 16 sixes!
Thank you so much, can I also ask you another question that you might be able to help me with. So they are writing equations and they could write y=4x+1 or y=16/4x+1 and technically they are both correct. My last coding just has the latex for one of them. How would I adjust that?
For linear functions like that you can use the xyLine function… so along the lines of
line=xyLine(e1.latex)
correct = e1.submitted and line.slope=4 and line.yIntercept=1
You may want to add additional checks if you want it specifically in y=mx+c form, because the code above will accept any equivalent variation - y-4x=1, x=(y-1)/4, etc. etc.
For non-terminating decimals, numericValue does not always yield equivalent (something to do with how it’s calculated). simpleFunction is more stable in this respect:
correct= when numericValue("\\operatorname{round}\\left(${input.numericValue},2\\right)")=numericValue("\\operatorname{round}\\left(\frac{2}{3},2\\right)")