In the ip6a box - it is grading as correct when the standard form is written as an expression (no y=) but not when written as an equation (with the y=).
How do I change the pattern to require the equation instead of the expression?
This checks if y= is entered on the left hand side, although Daniel’s suggestion would work too. This wouldn’t work if a student enters f(x) though, which is why it might be better to check if the equation is defined. To alleviate that, you could just put in the errorMessage to enter a standard form equation starting with y=.
submitLabel: "Check my Standard Form equation"
left = parseEquation(this.latex).lhs
right = parseEquation(this.latex).rhs
p=patterns
matchLeft = p.literal("y").matches(left)
standard=p.anyOf(
p.difference(p.expression,p.expression,p.expression),
p.difference(p.expression,p.expression),
p.sum(p.expression,p.expression,p.expression),
p.sum(p.expression,p.expression)
)
matchRight = standard.matches(right)
errorMessage: when not(matchRight) or not(matchLeft) "Did you write your equation in standard form?" otherwise ""
fn1 = simpleFunction(this.latex)
disableEvaluation: true
correct = fn1.evaluateAt(-2) = -10 and fn1.evaluateAt(2) = -6 and fn1.evaluateAt(1) = -10
correct: correct
errorMessage: when isUndefined(parseEquation(this.latex)) or
not(standard.matches(parseEquation(this.latex).lhs)) "Did you write your equation in standard form?"
otherwise ""
I sincerely appreciate all of the help. I tried both of your ideas (on pages 2 and 3, attached). On one I am getting an error in the computation layer, and in the other it still isn’t “grading” correctly when typed in and is still getting a red x instead of a green check.
I was wondering if you could help me finish this up?
The error in ip6a is that since the difference function (which is lhs - rhs) is in terms of x and y you need to put both x and y in evaluateAt. Solutions to the differenceFunction should always equal 0:
checkfunction = fn1.evaluateAt(-2,-10) = 0 and fn1.evaluateAt(2,-6) = 0 and fn1.evaluateAt(1,-10) = 0