I have some understanding of writing CL for checking if a student is correct on writing an equation in any form: #for y=0.5x+10
f = parseEquation(this.cellContent(1,1)).differenceFunction(“x”,“y”)
correct: (f.evaluateAt(0,10)=0 and f.evaluateAt(-20,0)=0)
Is there a way to check if the student has written a correct equation in a very specific form (ie point slope form). I want to make sure they know how to write the different forms and be able to convert to another specified form like to slope intercept or to standard.
Some of this makes sense but I’m still learning here. I’m assuming “number” is where I am putting an actual number? Let’s try something specific. I want the student to enter y=x+2. How would I program this so that this is the specific form of an answer without writing all the various latex forms? And I would like this to show a check on the teacher dashboard if it is correct.
In all cases (forgot to mention this originally), I would still use simpleFunction to handle the checking that the equation itself is correct - pattern matching is only really to verify the correct form. So p.number doesn’t get replaced with an actual number - it’s just telling the pattern matcher to make sure there’s some number there.
For y=x+2, you’d use simpleFunction to make sure it evaluated correctly, then something like:
errorMessage: when lhsmatch and rhsmatch "" otherwise "Not in correct form"
Instead of p.number on the third line, you could use p.literal("2") or p.number.satisfies(`x=2`) to force it to check for the sum of x and 2… but like I say, I much prefer to use pattern matching to check the form, and simpleFunction to check the values.