From c648db7f3da212db24e520eec24114a79d019ad3 Mon Sep 17 00:00:00 2001 From: Jason Bau Date: Fri, 1 Nov 2013 15:51:20 -0700 Subject: [PATCH] add comment explaining child_history condition --- .../xmodule/open_ended_grading_classes/open_ended_module.py | 4 ++++ 1 file changed, 4 insertions(+) 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 dcaff7685e..d020987fdf 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)