Checking correctness of an equation

I want students to be marked correct when they type in math input the equation y = 30x-6 as well as equivalent forms of slope such as y = 60/2 x -6. How do I do this in CL?

1 Like
myLine=xyLine(this.latex)    #makes a line object

#I'm rounding below in case you want to apply to slopes that would be 
#longer or non-terminating decimals

check= slope=30 and yInt=-6
correct: check

The above will accept in any form. If you want to limit to slope-intercept form, add:

slopeIntForm=f.evaluateAt(0)=0 and f.evaluateAt(2)=2

Then, add “and slopeIntForm” to check

1 Like

This is awesome and will no doubt save me so much time! Is there a way to limit to standard form as well?

Also I’m trying to have student students enter slope as 2/3 and I’m not able to get it to show as correct. Am I missing anything?

You need your slope= in check to be a terminating decimal.

If you want specific forms, you can additionally use countNumberUsage. For example, 2x+3y=-3 you could use:
...and countNumberUsage(this.latex,2)=1 and countNumberUsage(this.latex,3)=2

Note that checking for the number 3 needs to occur twice, even though one of them is negative. You can’t use negative numbers in countNumberUsage, but the evaluations generally take care of any ambiguity.

You can use similar methods for slope intercept form.

I am trying to adapt your coding here for my activity. I want the correct answer to be in slope intercept form and y=-x+2. This is what I have but it is not showing as correct when I test it.



check= slope=-1 and yInt=2 and slopeIntForm
correct: check

slopeIntForm=f.evaluateAt(0)=2 and f.evaluateAt(2)=0

disableEvaluation: true

showSubmitButton: true

submitLabel: “Check my Answers”

resetLabel: when this.submitted (when check “:white_check_mark:” otherwise “:x:”) otherwise “”

If this isn’t a typo here then this is the bit that’s wrong, I think - it should be

slopeIntForm=f.evaluateAt(0)=0 and f.evaluateAt(2)=2

All this is doing (as far as I can tell) is checking that the LHS contains y and y only, not y+5=… or similar.

You could also force y only by using pattern matching, as we were looking at in the other thread.