diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 62f537b1e9..f7960b13b1 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -213,7 +213,7 @@ class CombinedOpenEndedFields(object): help="The number of times the student can try to answer this problem.", default=1, scope=Scope.settings, - values={"min" : 1 } + values={"min": 1 } ) accept_file_upload = Boolean( display_name="Allow File Uploads", @@ -242,7 +242,7 @@ class CombinedOpenEndedFields(object): display_name="Problem Weight", help="Defines the number of points each problem is worth. If the value is not set, each problem is worth one point.", scope=Scope.settings, - values={"min" : 0 , "step": ".1"}, + values={"min": 0, "step": ".1"}, default=1 ) min_to_calibrate = Integer( @@ -250,28 +250,28 @@ class CombinedOpenEndedFields(object): help="The minimum number of calibration essays each student will need to complete for peer grading.", default=3, scope=Scope.settings, - values={"min" : 1, "max" : 20, "step" : "1"} + values={"min": 1, "max": 20, "step": "1"} ) max_to_calibrate = Integer( display_name="Maximum Peer Grading Calibrations", help="The maximum number of calibration essays each student will need to complete for peer grading.", default=6, scope=Scope.settings, - values={"min" : 1, "max" : 20, "step" : "1"} + values={"min": 1, "max": 20, "step": "1"} ) peer_grader_count = Integer( display_name="Peer Graders per Response", help="The number of peers who will grade each submission.", default=3, scope=Scope.settings, - values={"min" : 1, "step" : "1", "max" : 5} + values={"min": 1, "step": "1", "max": 5} ) required_peer_grading = Integer( display_name="Required Peer Grading", help="The number of other students each student making a submission will have to grade.", default=3, scope=Scope.settings, - values={"min" : 1, "step" : "1", "max" : 5} + values={"min": 1, "step": "1", "max": 5} ) markdown = String( help="Markdown source of this module", diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py index 8c90983d3c..c215df2d66 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py @@ -351,7 +351,12 @@ class CombinedOpenEndedV1Module(): return self.current_task.get_html(self.system) def get_html_ajax(self, data): - return {'html' : self.get_html()} + """ + Get HTML in AJAX callback + data - Needed to preserve AJAX structure + Output: Dictionary with html attribute + """ + return {'html': self.get_html()} def get_current_attributes(self, task_number): """ @@ -643,7 +648,12 @@ class CombinedOpenEndedV1Module(): def get_current_state(self, data): return self.get_context() - def get_last_response_ajax(self,data): + def get_last_response_ajax(self, data): + """ + Get the last response via ajax callback + data - Needed to preserve ajax callback structure + Output: Last response dictionary + """ return self.get_last_response(self.current_task_number) def next_problem(self, _data): @@ -666,10 +676,10 @@ class CombinedOpenEndedV1Module(): return self.out_of_sync_error(data) success, can_reset, error = self.check_if_student_has_done_needed_grading() if not can_reset: - return {'error' : error, 'success' : False} - if self.student_attempts >= self.max_attempts-1: - if self.student_attempts==self.max_attempts-1: - self.student_attempts +=1 + return {'error': error, 'success': False} + if self.student_attempts >= self.max_attempts - 1: + if self.student_attempts == self.max_attempts - 1: + self.student_attempts += 1 return { 'success': False, # This is a student_facing_error diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py index a72fd07438..1b8d84754a 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py @@ -214,7 +214,7 @@ class CombinedOpenEndedRubric(object): #Get the highest possible score across all categories max_score = max(max_scores) #Loop through each category - for i,category in enumerate(rubric_categories): + for i, category in enumerate(rubric_categories): #Loop through each option in the category for j in xrange(len(category['options'])): #Intialize empty grader types list @@ -234,10 +234,10 @@ class CombinedOpenEndedRubric(object): #If a list in the list of lists for this position exists, append to it actual_scores[i] += [j] - actual_scores = [sum(i)/len(i) for i in actual_scores] + actual_scores = [sum(i) / len(i) for i in actual_scores] correct = [] #Define if the student is "correct" (1) "incorrect" (0) or "partially correct" (.5) - for (i,a) in enumerate(actual_scores): + for (i, a) in enumerate(actual_scores): if int(a) == max_scores[i]: correct.append(1) elif int(a)==0: diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/grading_service_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/grading_service_module.py index fcbe9e5ad1..4c6a79a5f1 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/grading_service_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/grading_service_module.py @@ -11,6 +11,9 @@ log = logging.getLogger(__name__) class GradingServiceError(Exception): + """ + Exception for grading service. Shown when Open Response Assessment servers cannot be reached. + """ pass 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 d99e466886..2f8d4fa866 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py @@ -333,7 +333,7 @@ class OpenEndedChild(object): try: image_data.seek(0) image_ok = open_ended_image_submission.run_image_tests(image_data) - except: + except Exception: log.exception("Could not create image and check it.") if image_ok: @@ -346,7 +346,7 @@ class OpenEndedChild(object): success, s3_public_url = open_ended_image_submission.upload_to_s3( image_data, image_key, self.s3_interface ) - except: + except Exception: log.exception("Could not upload image to S3.") return success, image_ok, s3_public_url