CL Help for Point Slope From

I am asking students to write an equation of a line in point-slope form and I would like this to be self-graded (it’s the end of our trimester, so I have grades due and not a lot of time). How do I write the CL code to grade an answer like “y-2=1/5(x+5)”? THANK YOU!

Here is a snippet of a slide I have for standard form. I use a parseEquation and have it check both sides

mint = numericValue("(-1)^${r.int(0,1)}*${r.int(2,15)}")
mneg =numericValue("(-1)*${mint}")

q = numericValue("(-1)^${r.int(0,1)}*${r.int(2,15)}")

qsign=when q<0 "" otherwise "+"

eq="y=${mint}x${qsign}${q}"

#########

lhs1=parseEquation("${mneg}x+y=${q}").lhs
rhs1=parseEquation("${mneg}x+y=${q}").rhs

inputlhs=parseEquation(fn1).lhs
inputrhs=parseEquation(fn1).rhs

correct=  when ((((numericValue("${mint}")>0) and (inputlhs=lhs2 and inputrhs=rhs2)))
                         or (((numericValue("${mint}")<0) and (inputlhs=lhs1 and inputrhs=rhs1))))  1 
             otherwise 0

co = when correct=1 "Correct, good work!" otherwise "Not there yet, keep working "





##################################################
#Displayed Content 

content:  "Given the following equation: 

`${eq}`

write the standard  form



Your answer: ${co}


"

This will check the slope and y-intercepts are as they should be. This would accept any form of line, so countNumberUsage here also check the number 1 and 2 are each used once, and 5 twice to verify the desired form. It can’t tell the difference between positive and negative, so you could use parseEquation to check each side of the equation instead. You could also evaluateAt on both sides.

check= xyLine(this.latex).slope=0.2 and xyLine(this.latex).yIntercept=7
and countNumberUsage(this.latex,2)=1 and countNumberUsage(this.latex,5)=2
and countNumberUsage(this.latex,1)=1
1 Like

If it is only correct if given in the point-slope form, you can put this into the Math Input CL:

correct: input1.latex=y-2=\frac{1}{5}\left(x+5\right)