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:

m=\frac{\operatorname{round}\left(10000000\frac{\left(y_2-y_1\right)}{x_2-x_1}\right)}{10000000}

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

myLine=xyLine(exp1.latex)
number("a"):myLine.slope
number("z"):myLine.yIntercept

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