Hey everyone,
I would like to decide whether a LaTeX input of a student is correct. I have seen two posts solving this when the input is of the form y = 3x + 14 for example. I tried the exact same method for the following expected input: =800-100, more precisely:
correct = this.latex = `=800-100`
However, this code doesn’t work. I tried again without the additional “=” which then worked. Unfortunately, I really want to have this additional “=” in front of the expression.
Does anybody have an idea why this additional “=” disturbs the above approach and how a workaround could look like?
Thanks for any idea!
In this vein, did you try quotes with your original?
correct = "${this.latex}" = "${`=800-100`}"
Edit: I thought the benefit of this was that the latex inside ${ } would eliminate extra spaces, but it doesn’t. @Susan_Lauer’s below seems simplest, but won’t handle extra spaces.
I think because “=800-100” in the Desmos calculator generates an error is the reason it’s not working, but not sure.
Finally, I found a way to cope with additional spaces. It is a very weird workaround, but here is how I did it in the end:
correct = parseEquation("3${this.latex}").rhs = `whatever LaTeX I expect after the "="`
To use the parseEquation, I need to artificially insert something on the lhs of the equation. Afterwards, it works just as expected. There is no different if I put 3 or something else, it was simply the first thing that came to my mind…
I really hope that pattern recognition will soon be available, or some sort of more powerful scripting like python!
I hadn’t tried that! Thanks in any case See below for my workaround which copes with additional spaces!
Your explanation with the error inside the calculator seems plausible…