Closed kavigupta closed 5 years ago
IIRC, Ok originally did exact string matching for unlocking questions, which caused issues when students entered responses that were correct, but not in the canonical form (e.g. [1,2,3]
instead of [1, 2, 3]
). At first, we tried to fix this by eval
ing the student response (in #101), but that was too lenient (see #211), so #223 replaced eval
there with ast.literal_eval
, which was the closest thing to expression canonicalization we could find in the standard library.
Perhaps ast.literal_eval
s semantics changed between Python versions?
Ah that must be it since sumukh said "For future reference: ast.literal_eval supports addition/subtraction of integers (but not other operations/other types" on the PR
Yep: https://bugs.python.org/issue31778
Ok I'll change the test
I think I've tracked the error down to https://github.com/okpy/ok-client/commit/b605ed3de5979a3436c4e81b49c6a1c42248456f#diff-c66760f0a6aa193db7eca384468b2da0 by @jathak
@jathak do you remember what you were doing in this PR? I'm pretty sure that
ast.literal_eval
can't handle the string"[1,2,3,2+2]"
since it can't handle binary operations.