Auto correcting with latex

First question here.
I’ll like to ask student to submitte the equation of a graphic in input box in an activity.

It’s work fine with integer and float, but not when I use fraction.

In my window, I use graphic, text area where «Good answer» and «bad answer» will appear (where the code was) and an input box (call inputc2) set in latex.

There is the code in the text area:

when c2input.submitted and c2input.latex = “y=\frac{1}{3}x-1” “\n\Good job !”
when c2input.submitted “Try again!”
otherwise “”

I cut n past my equation in the preview to put in in my code…

Any idea?

If you’re looking for an exact latex match you’ll need to use a second backslash in the key:


Yes! It’s work.

I use “y=\frac{1}{3}x+1” (Edit I cant put two backslash in this topic…)


Haha yup sorry. Two backslashes

Just a reminder that, for many of the same reasons that you’re hitting, trying to exactly match latex that students have entered will be frustrating and unreliable for them as well. Things like -1+1/3x, 2/6x-1, or even putting a space somewhere in the equation will cause correct responses to be marked as wrong. Checking if the equation passes through the right points using simpleFunction(), or using xyLine() to check the slope and intercept will help make this a much better experience for your students.

thanks for your answer. Do you have an exemple about what you tell me?


Let the correct answer be some function in the graph, say, “f” and the student input is “g”.

Then in the graph component you can create a list of inputs say X=[-5…5] and check if the difference between the desired function (f) and the student input (g) is zero. f(X)-g(X).

If it is zero I make the output 1 and if it is not then 0. Adopting this convention is useful because of the properties of 0 and 1 – especially if you are correctness checking multiple inputs.

Here is an example:

Thanks for your answer.

I test it today!