Answer check with random line

I have an unsolved problem with this simple activity: generating a random line and CL verifies if the equation is good. Problem with checking is when we get an equation like y = -8/13x + 102/13 and we give the answer exactly like this I don’t get a good answer even if it is. What am I doing wrong here ?

In your graph, you appear to be rounding m and b to the nearest ten-millionth:


However, no such rounding is being applied to a and z:


Because of this, when you compare them, they may not be exactly equal, even if the student entered the correct answer.

The easiest way to fix this is probably to not round any of the numbers. Instead, you can check if the difference between the students’ answer and the correct answer is below a threshold – something along the lines of |m-a| < 0.0001. I’ve modified your activity to do this, and it seems to work correctly:

1 Like