Is there a way to use xyLine that means students must type proper equations?

I have an expression input where I ask students to give the equation of a line with a gradient of 3.

In order to ascertain correctness, I have code like this:

myLine = xyLine(exp.latex)
correct: myLine.slope = 3

The problem is that if a user types in “3x” then this will be marked as correct but really I don’t want to accept this.

Is there a way I could test to see if something was a well formed equation (or at least whether there was an equals sign in the string)?

I know I can also include initialLatex: "y = " but it still irks me that a student could take 3x, and perhaps Ialso want them to be able to enter in a different form like y - 3x = 10

1 Like