Checking cell content that includes more than one variable

On the screen below, I am hoping to add a column to check the correctness of the equations that students type in. Is there a way to do this in a table, even though there is no latex source? I had thought about using the evaluateAt function, but I don’t think that I can since there are variables on both sides of the equal sign.

By default, each column in a table is set to ‘Format as math’, and this means that when you use something like this.cellContent(1,2) you are automatically getting the Latex value of a student’s input. This opens up a few ways to add correctness checks depending on how thorough and complex you want to get:

  1. You could check the exact Latex string a student enters, but then you run the risk of marking some correct answers as incorrect based on format choices (e.g. a student enters 0.5 instead of 1/2 or they enter y - -4 instead of y + 4).

  2. You can turn each equation into an xyLine and check its slope and y-intercept. This is a great way of checking that a student entered some correct equation, but it doesn’t differentiate between point-slope and slope-intercept formats for writing equations. This would look like
    line12 = xyLine(this.cellContent(1,2))
    correct: (line12.slope = 0.5) and (line12.yIntercept = -4.5)

  3. You could build off #2 and add an additional check on just the left-hand side of the equation to differentiate between point-slope and slope-intercept equations. This gets tedious when you have lots of equations to check on the same screen, but it would look like
    line12 = xyLine(this.cellContent(1,2))
    lhs12 = simpleFunction(parseEquation(this.cellContent(1,2)).lhs, "y")
    correct: (line12.slope = 0.5) and (line12.yIntercept = -4.5) and (lhs12.evaluateAt(0) = 4)

So, the functionality to do what you want is definitely there :slight_smile: Other folks, please chime in if you have alternative, more elegant solutions. Good luck!

Thank you so much! This was very helpful! In case anyone else wants to see the finalized code, here is the check that I wrote for each line:

#Row 1:
line1a=xyLine(Table10.cellContent(1,2))
line1b=xyLine(Table10.cellContent(1,3))
cellContent(1,4): when line1a.slope=0.5 and line1b.slope=0.5 and line1a.yIntercept=-4.5 and line1b.yIntercept=-4.5 “:heavy_check_mark:” otherwise “:x: