From 5cf7441da1f785ccb04dafab48ef6d5e20df95a4 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 12 Feb 2013 15:31:30 -0500 Subject: [PATCH] Fix error message passing to JS and student --- .../open_ended_grading_classes/open_ended_module.py | 6 +++--- .../xmodule/open_ended_grading_classes/openendedchild.py | 9 ++++++--- .../open_ended_grading_classes/self_assessment_module.py | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) 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 57d53c41c6..2472244950 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 @@ -613,13 +613,13 @@ class OpenEndedModule(openendedchild.OpenEndedChild): self.send_to_grader(get['student_answer'], system) self.change_state(self.ASSESSING) else: - #Error message already defined, so we can just pass it down the chain - pass + #Error message already defined + success = False else: error_message = "There was a problem saving the image in your submission. Please try a different image, or try pasting a link to an image into the answer box." return { - 'success': True, + 'success': success, 'error': error_message, 'student_response': get['student_answer'] } diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py index 4f4159c612..58939e175f 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py @@ -418,18 +418,21 @@ class OpenEndedChild(object): success = False allowed_to_submit = True response = {} + error_string = ("You need to peer grade more in order to make another submission. " + "You have graded {0}, and {1} are required. You have made {2} successful peer grading submissions.") try: response = self.peer_gs.get_data_for_location(location, student_id) count_graded = response['count_graded'] count_required = response['count_required'] + student_sub_count = response['student_sub_count'] success = True except: - error_message = ("Need to peer grade more in order to make another submission. " - "You have graded {0}, {1} are required.").format(count_graded, count_required) + error_message = "Could not contact the grading controller." return success, allowed_to_submit, error_message if count_graded>=count_required: return success, allowed_to_submit, "" else: allowed_to_submit = False - return success, allowed_to_submit, "" + error_message = error_string.format(count_graded, count_required, student_sub_count) + return success, allowed_to_submit, error_message diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py index 27ef58ac98..f9fd3e301d 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py @@ -183,11 +183,12 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): self.new_history_entry(get['student_answer']) self.change_state(self.ASSESSING) else: - #Error message already defined, so we can just pass - pass + #Error message already defined + success = False else: error_message = "There was a problem saving the image in your submission. Please try a different image, or try pasting a link to an image into the answer box." + log.debug(error_message) return { 'success': success, 'rubric_html': self.get_rubric_html(system),