You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code that is triggered by setting the upToConstant flag in an answer checker is hard-coded to add C0 as the parameter, which can cause issues if that variable is already present in the context.
The scenario originally arose when calling $ans->cmp(upToConstant=>1) on the same object more than once. Consider the MWE:
This leads to the (non-fatal) warning "Variable 'C0' already exists". In this case it doesn't break anything since C0 is being redefined for the same purpose.
The more dangerous scenario is when the problem author has already declared C0 as a variable in the problem. e.g.
In this case C0 ends up redefined as a parameter rather than a real-valued variable, which means that answers are not checked correctly. Any answer including C0 gets the message "Variable 'C0' is not defined in this context", where answers like x+C0 or x+C0+3 should be marked correct.
The code that is triggered by setting the
upToConstant
flag in an answer checker is hard-coded to addC0
as the parameter, which can cause issues if that variable is already present in the context.The scenario originally arose when calling
$ans->cmp(upToConstant=>1)
on the same object more than once. Consider the MWE:This leads to the (non-fatal) warning "Variable 'C0' already exists". In this case it doesn't break anything since
C0
is being redefined for the same purpose.The more dangerous scenario is when the problem author has already declared
C0
as a variable in the problem. e.g.In this case
C0
ends up redefined as a parameter rather than a real-valued variable, which means that answers are not checked correctly. Any answer includingC0
gets the message "Variable 'C0' is not defined in this context", where answers likex+C0
orx+C0+3
should be marked correct.It seems like the fix would be to modify
pg/lib/Value/AnswerChecker.pm
Lines 1914 to 1915 in 0440842
C0
exists in the context, and if so find a new variable name to use instead. How hard would this be to do?The text was updated successfully, but these errors were encountered: