Incorrect highlighting because of flaws in ObjectAssignmentParser
filipsch opened this issue · 0 comments
filipsch commented
When checking whether an object is correctly created and the exercise only contains a single =
operator in addition to other 'object-mutating' operations that don't use =
, highlighting trips up.
Reproducible example (in words)
# solution
x = []
for i in range(3):
x.append(i)
# sct
Ex().check_object('x').has_equal_value()
If the student submits:
# student
x = []
for i in range(3):
x.append(2 * i)
The x = []
will be highlighted, even though the mistake is in the x.append()
step. This is extremely confusing for students! You can see it in action here
Reproducible example (in code)
from pythonwhat.local import setup_state
from pythonwhat.Test import TestFail
sol_code = "x = []\nfor i in range(3): x.append(i)"
stu_code = "x = []\nfor i in range(3): x.append(2 * i)"
s = setup_state(sol_code, stu_code)
try:
s.check_object('x').has_equal_value()
except TestFail as e:
line_info = e.feedback.line_info
line_info
This will print out:
{'column_start': 0, 'line_start': 1, 'line_end': 1, 'column_end': 6}
While it should have a line_start
on line_end
equal to 2, or just not highlight anything at all.