I want this activity to mark any expression equivalent to 2x + 3 correct.
I’ve read some information about evaluation, but I cannot find a good example of code.
Please support.
Thanks,
Devlin
I want this activity to mark any expression equivalent to 2x + 3 correct.
I’ve read some information about evaluation, but I cannot find a good example of code.
Please support.
Thanks,
Devlin
On the first line of input1, use the LaTeX quote symbol (on the upper left key on keyboard) instead of quotes " ":
correct = input1.submitted and input1.latex = `2x+3`
LaTeX ignores spaces. The quotes make a string, and strings require an exact match.
Awesome. Thanks for that. I never realized it was that simple.
Now for the advanced task:
I need to do the same thing, but with (1/2)x + 3 for a line of slope 1/2 and y-intercept of 3.
You might want to add the disableEvaluation line when using fractions if you don’t want them to see an approximation.
correct = input1.submitted and input1.latex = `\frac{1}{2}x+3`
correct: correct
disableEvaluation: true
You might consider having them enter the entire equation with y=\frac{1}{2}x+3
or use a prompt so that it automatically appears for them:
initialLatex: `y=`