I’m trying to use simpleFunction to check whether an expression has been simplified correctly. Heres my code
#b=when ans13.latex=QAtable.cellContent(13,3) 0 otherwise 1
#correct: C=U and b=0
#f=when b=1 and C=U 1 otherwise 0
check13= when C=U 1 otherwise 0
Its not working and I can’t see why. I know I still need to include a check that students are not simply entering an unsimplified expression
It basically evaluates the expression that is input by student and checks it against the an evaluation of the correct expression that is pulled from a table on another slide:
The expression simplifies to 2a-b
Can you share a link to the activity that isn’t working? I can’t see anything wrong with the code specifically, so it might be that the references are wrong (for example you refer to both cell (13,2) and (13,3) here) or similar contextual error.
Duh, Thinks I’ve found it, stupid mistake. Wrong variable name ans3 should have been ans13!! I can now try to get it to return as incorrect if the student just inputs the unsimplified expression.
Glad you found it.
Various ways of checking for fully simplified versions, if you haven’t got that working yet. For example,
countNumberUsage is good - if you’re simplifying to 3a+4b then
countNumberUsage should return 2, but 3a+2b+2b would return 3 and hence be wrong.
Alternatively, you can delve into pattern matching - might be worth posting back on here if you need help with that.
Thanks, I didn’t know countNumberUsage could be used for that. I’ll rtfm to see how to use it. It could come in useful but in this case use I am trying to develop code that I don’t have have to change if the number of variables in the expression increases.
I am able to check that they haven’t just input the unsimplified expression by latex matching their input against the expression but that still leaves weird input cases that will match.
eg: Expression 3a+2b-a+b
Student input: 2a+2a +b would be marked as correct.
I have watched a video on pattern matching so will take another look at it to see if its applicable in this case.
Thanks for you help