diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py index dcaff7685e86bc0c685bde4567802ff7aa342a97..d020987fdf6cae3c7ac2ced6f996172177cc619a 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py @@ -281,6 +281,10 @@ class OpenEndedModule(openendedchild.OpenEndedChild): if not new_score_msg['valid']: new_score_msg['feedback'] = 'Invalid grader reply. Please contact the course staff.' + # self.child_history is initialized as []. record_latest_score() and record_latest_post_assessment() + # operate on self.child_history[-1]. Thus we have to make sure child_history is not []. + # Handle at this level instead of in record_*() because this is a good place to reduce the number of conditions + # and also keep the persistent state from changing. if self.child_history: self.record_latest_score(new_score_msg['score']) self.record_latest_post_assessment(score_msg)