I was able to borrow enough code and activity slides to make an activity that checks student answers when they enter it in the submit box. However, I can only get it to accept one answer, when I want it to accept multiple formats of the same answer. For example Slide #3 has the correct answer as “-5p-20”, but I want it to also accept “-5p+ -20” as correct. Is there a way to adapt the code to have more equivalent expression answers?
More specifically, the code is here.
correct = this.latex = “-5p-20”
Is there a way to make it like this?
correct = this.latex = “-5p-20” OR “-5p+ -20”
I am piecing all this together without really understanding it, so I don’t know what this means, “use calculations to check expressions instead of matching latex.”
But that other bit totally works, thank you, thank you!!
answer = simpleFunction(this.latex, `p`)
check = answer.evaluateAt(0)=-20 and answer.evaluateAt(1)=-25
answer takes student input and turns it into a function.
check evaluates the function at 0 and 1 to see if they get correct solutions. countNumberUsage checks that 5 and 20 are each used once (it can’t recognize negative numbers) in order to mark incorrect other expressions like p-6p-20 that would still evaluate the same.
It’s a little tricky to learn, but it is more accurate in correcting than trying to match latex which can have problems sometimes. Though it does seem to work most of the time.