Commit 21e13e44 by Vik Paruchuri

Pep8 and pylint fixes

parent a0680143
...@@ -213,7 +213,7 @@ class CombinedOpenEndedFields(object): ...@@ -213,7 +213,7 @@ class CombinedOpenEndedFields(object):
help="The number of times the student can try to answer this problem.", help="The number of times the student can try to answer this problem.",
default=1, default=1,
scope=Scope.settings, scope=Scope.settings,
values={"min" : 1 } values={"min": 1 }
) )
accept_file_upload = Boolean( accept_file_upload = Boolean(
display_name="Allow File Uploads", display_name="Allow File Uploads",
...@@ -242,7 +242,7 @@ class CombinedOpenEndedFields(object): ...@@ -242,7 +242,7 @@ class CombinedOpenEndedFields(object):
display_name="Problem Weight", 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.", 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, scope=Scope.settings,
values={"min" : 0 , "step": ".1"}, values={"min": 0, "step": ".1"},
default=1 default=1
) )
min_to_calibrate = Integer( min_to_calibrate = Integer(
...@@ -250,28 +250,28 @@ class CombinedOpenEndedFields(object): ...@@ -250,28 +250,28 @@ class CombinedOpenEndedFields(object):
help="The minimum number of calibration essays each student will need to complete for peer grading.", help="The minimum number of calibration essays each student will need to complete for peer grading.",
default=3, default=3,
scope=Scope.settings, scope=Scope.settings,
values={"min" : 1, "max" : 20, "step" : "1"} values={"min": 1, "max": 20, "step": "1"}
) )
max_to_calibrate = Integer( max_to_calibrate = Integer(
display_name="Maximum Peer Grading Calibrations", display_name="Maximum Peer Grading Calibrations",
help="The maximum number of calibration essays each student will need to complete for peer grading.", help="The maximum number of calibration essays each student will need to complete for peer grading.",
default=6, default=6,
scope=Scope.settings, scope=Scope.settings,
values={"min" : 1, "max" : 20, "step" : "1"} values={"min": 1, "max": 20, "step": "1"}
) )
peer_grader_count = Integer( peer_grader_count = Integer(
display_name="Peer Graders per Response", display_name="Peer Graders per Response",
help="The number of peers who will grade each submission.", help="The number of peers who will grade each submission.",
default=3, default=3,
scope=Scope.settings, scope=Scope.settings,
values={"min" : 1, "step" : "1", "max" : 5} values={"min": 1, "step": "1", "max": 5}
) )
required_peer_grading = Integer( required_peer_grading = Integer(
display_name="Required Peer Grading", display_name="Required Peer Grading",
help="The number of other students each student making a submission will have to grade.", help="The number of other students each student making a submission will have to grade.",
default=3, default=3,
scope=Scope.settings, scope=Scope.settings,
values={"min" : 1, "step" : "1", "max" : 5} values={"min": 1, "step": "1", "max": 5}
) )
markdown = String( markdown = String(
help="Markdown source of this module", help="Markdown source of this module",
......
...@@ -351,7 +351,12 @@ class CombinedOpenEndedV1Module(): ...@@ -351,7 +351,12 @@ class CombinedOpenEndedV1Module():
return self.current_task.get_html(self.system) return self.current_task.get_html(self.system)
def get_html_ajax(self, data): 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): def get_current_attributes(self, task_number):
""" """
...@@ -643,7 +648,12 @@ class CombinedOpenEndedV1Module(): ...@@ -643,7 +648,12 @@ class CombinedOpenEndedV1Module():
def get_current_state(self, data): def get_current_state(self, data):
return self.get_context() 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) return self.get_last_response(self.current_task_number)
def next_problem(self, _data): def next_problem(self, _data):
...@@ -666,10 +676,10 @@ class CombinedOpenEndedV1Module(): ...@@ -666,10 +676,10 @@ class CombinedOpenEndedV1Module():
return self.out_of_sync_error(data) return self.out_of_sync_error(data)
success, can_reset, error = self.check_if_student_has_done_needed_grading() success, can_reset, error = self.check_if_student_has_done_needed_grading()
if not can_reset: if not can_reset:
return {'error' : error, 'success' : False} return {'error': error, 'success': False}
if self.student_attempts >= self.max_attempts-1: if self.student_attempts >= self.max_attempts - 1:
if self.student_attempts==self.max_attempts-1: if self.student_attempts == self.max_attempts - 1:
self.student_attempts +=1 self.student_attempts += 1
return { return {
'success': False, 'success': False,
# This is a student_facing_error # This is a student_facing_error
......
...@@ -214,7 +214,7 @@ class CombinedOpenEndedRubric(object): ...@@ -214,7 +214,7 @@ class CombinedOpenEndedRubric(object):
#Get the highest possible score across all categories #Get the highest possible score across all categories
max_score = max(max_scores) max_score = max(max_scores)
#Loop through each category #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 #Loop through each option in the category
for j in xrange(len(category['options'])): for j in xrange(len(category['options'])):
#Intialize empty grader types list #Intialize empty grader types list
...@@ -234,10 +234,10 @@ class CombinedOpenEndedRubric(object): ...@@ -234,10 +234,10 @@ class CombinedOpenEndedRubric(object):
#If a list in the list of lists for this position exists, append to it #If a list in the list of lists for this position exists, append to it
actual_scores[i] += [j] 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 = [] correct = []
#Define if the student is "correct" (1) "incorrect" (0) or "partially correct" (.5) #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]: if int(a) == max_scores[i]:
correct.append(1) correct.append(1)
elif int(a)==0: elif int(a)==0:
......
...@@ -11,6 +11,9 @@ log = logging.getLogger(__name__) ...@@ -11,6 +11,9 @@ log = logging.getLogger(__name__)
class GradingServiceError(Exception): class GradingServiceError(Exception):
"""
Exception for grading service. Shown when Open Response Assessment servers cannot be reached.
"""
pass pass
......
...@@ -333,7 +333,7 @@ class OpenEndedChild(object): ...@@ -333,7 +333,7 @@ class OpenEndedChild(object):
try: try:
image_data.seek(0) image_data.seek(0)
image_ok = open_ended_image_submission.run_image_tests(image_data) image_ok = open_ended_image_submission.run_image_tests(image_data)
except: except Exception:
log.exception("Could not create image and check it.") log.exception("Could not create image and check it.")
if image_ok: if image_ok:
...@@ -346,7 +346,7 @@ class OpenEndedChild(object): ...@@ -346,7 +346,7 @@ class OpenEndedChild(object):
success, s3_public_url = open_ended_image_submission.upload_to_s3( success, s3_public_url = open_ended_image_submission.upload_to_s3(
image_data, image_key, self.s3_interface image_data, image_key, self.s3_interface
) )
except: except Exception:
log.exception("Could not upload image to S3.") log.exception("Could not upload image to S3.")
return success, image_ok, s3_public_url return success, image_ok, s3_public_url
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment