I feel like I’m reaching my question quota limit over these last two days so my apologies…
Is there a way to take an expression like “x>5” that was given by a student through an input and test variables from the graph within the expression? [It almost feels like I’d need some kind of “find and replace” function to use on the student input.]
Like student moves points (a,0), (b,0) and (c,0) on the number line to 4, 5, and 6 and I check to see that all values work within the student expression. Right now I have the student expression graphing with the points showing so visually a student could see it isn’t working but that’s it.
My goal is to have some response text if the values on the number line don’t mesh with the inequality a student is entering. Essentially I’m wanting a way to compare the student entered inequality with the correct inequality.
We’d like to have better support for inequalities, but one thing you can do now is something like this:
studentInput = input.latex
a = graph.number("a")
f = simpleFunction("\\{${studentInput}:1,0\\}")
testResult = f.evaluateAt(a)
content:
when isUndefined(f) "Please enter an inequality, like x>0"
when testResult = 1 "Your test point, ${a} satisfies your inequality"
otherwise "Your test point, ${a} does not satisfy your inequality"
What am I doing wrong with this code? I get an error on my second “when” statement that says --syntax error: expected token ‘=’
studentInput = exp1.latex
a = graph1.number("a")
b = graph1.number("b")
c = graph1.number("c")
d = graph1.number("d")
f = simpleFunction("\\{${studentInput}:1,0\\}")
testResult1 = f.evaluateAt(a)
testResult2 = f.evaluateAt(b)
testResult3 = f.evaluateAt(c)
testResult4 = f.evaluateAt(d)
content:
"1. Move the four points to represent represent four different numbers that are more than 5."
when isUndefined(f) "2. Write an inequality that works for all points that are more than 5, like x>0"
when testResult1 = 1 and testResult2 = 1 and testResult3 = 1 and testResult4 = 1 "Your test points all satisfy your inequality."
otherwise "Not all your test points satisfy your inequality."
That’s just our conditional syntax. So if the studentInput evaluates to a true statement, the result of that expression is 1, otherwise it’s 0. That lets you check truthiness of some calculation simply by looking at a numeric value.
I am making an activity guiding students through domain and range, and I need to be able to check inequalities using “y” rather than “x” in order to do the range.
Here is an example of the kind of thing I want to do. I am able to use
f = simpleFunction("\\{${studentInput}:1,0\\}")
to check correctness of the domain questions, but cannot use the same script to check correctness of the range questions, because the range uses the variable y.
Is there a way to compute correctness using y, or to replace all instances of “y” in the latex to an “x” and then compute correctness?