Commit d20fc439 by Vik Paruchuri

Fix peer grading boolean parsing

parent 3329af07
...@@ -138,7 +138,7 @@ class CombinedOpenEndedV1Module(): ...@@ -138,7 +138,7 @@ class CombinedOpenEndedV1Module():
self.attempts = self.instance_state.get('attempts', MAX_ATTEMPTS) self.attempts = self.instance_state.get('attempts', MAX_ATTEMPTS)
self.is_scored = self.instance_state.get('is_graded', IS_SCORED) in TRUE_DICT self.is_scored = self.instance_state.get('is_graded', IS_SCORED) in TRUE_DICT
self.accept_file_upload = self.instance_state.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT self.accept_file_upload = self.instance_state.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT
self.skip_basic_checks = self.instance_state.get('skip_spelling_checks', SKIP_BASIC_CHECKS) self.skip_basic_checks = self.instance_state.get('skip_spelling_checks', SKIP_BASIC_CHECKS) in TRUE_DICT
display_due_date_string = self.instance_state.get('due', None) display_due_date_string = self.instance_state.get('due', None)
......
...@@ -58,16 +58,19 @@ class PeerGradingModule(XModule): ...@@ -58,16 +58,19 @@ class PeerGradingModule(XModule):
else: else:
self.peer_gs = MockPeerGradingService() self.peer_gs = MockPeerGradingService()
if self.use_for_single_location == True: log.debug(self.use_for_single_location)
log.debug(type(self.use_for_single_location))
log.debug(self.use_for_single_location==True)
if self.use_for_single_location in TRUE_DICT:
try: try:
self.linked_problem = modulestore().get_instance(self.system.course_id, self.link_to_location) self.linked_problem = modulestore().get_instance(self.system.course_id, self.link_to_location)
except: except:
log.error("Linked location {0} for peer grading module {1} does not exist".format( log.error("Linked location {0} for peer grading module {1} does not exist".format(
self.link_to_location, self.location)) self.link_to_location, self.location))
raise raise
due_date = self.linked_problem.metadata.get('peer_grading_due', None) due_date = self.linked_problem._model_data.get('peer_grading_due', None)
if due_date: if due_date:
self.metadata['due'] = due_date self._model_data['due'] = due_date
try: try:
self.timeinfo = TimeInfo(self.display_due_date_string, self.grace_period_string) self.timeinfo = TimeInfo(self.display_due_date_string, self.grace_period_string)
...@@ -120,7 +123,7 @@ class PeerGradingModule(XModule): ...@@ -120,7 +123,7 @@ class PeerGradingModule(XModule):
""" """
if self.closed(): if self.closed():
return self.peer_grading_closed() return self.peer_grading_closed()
if not self.use_for_single_location: if self.use_for_single_location not in TRUE_DICT:
return self.peer_grading() return self.peer_grading()
else: else:
return self.peer_grading_problem({'location': self.link_to_location})['html'] return self.peer_grading_problem({'location': self.link_to_location})['html']
...@@ -171,7 +174,7 @@ class PeerGradingModule(XModule): ...@@ -171,7 +174,7 @@ class PeerGradingModule(XModule):
pass pass
def get_score(self): def get_score(self):
if not self.use_for_single_location or not self.is_graded: if self.use_for_single_location not in TRUE_DICT or self.is_graded not in TRUE_DICT:
return None return None
try: try:
...@@ -204,7 +207,7 @@ class PeerGradingModule(XModule): ...@@ -204,7 +207,7 @@ class PeerGradingModule(XModule):
randomization, and 5/7 on another randomization, and 5/7 on another
''' '''
max_grade = None max_grade = None
if self.use_for_single_location and self.is_graded: if self.use_for_single_location in TRUE_DICT and self.is_graded in TRUE_DICT:
max_grade = self.max_grade max_grade = self.max_grade
return max_grade return max_grade
...@@ -450,7 +453,6 @@ class PeerGradingModule(XModule): ...@@ -450,7 +453,6 @@ class PeerGradingModule(XModule):
error_text = problem_list_dict['error'] error_text = problem_list_dict['error']
problem_list = problem_list_dict['problem_list'] problem_list = problem_list_dict['problem_list']
except GradingServiceError: except GradingServiceError:
#This is a student_facing_error #This is a student_facing_error
error_text = EXTERNAL_GRADER_NO_CONTACT_ERROR error_text = EXTERNAL_GRADER_NO_CONTACT_ERROR
...@@ -480,8 +482,9 @@ class PeerGradingModule(XModule): ...@@ -480,8 +482,9 @@ class PeerGradingModule(XModule):
problem_location = problem['location'] problem_location = problem['location']
descriptor = _find_corresponding_module_for_location(problem_location) descriptor = _find_corresponding_module_for_location(problem_location)
if descriptor: if descriptor:
problem['due'] = descriptor.metadata.get('peer_grading_due', None) log.debug(descriptor.__dict__)
grace_period_string = descriptor.metadata.get('graceperiod', None) problem['due'] = descriptor._model_data.get('peer_grading_due', None)
grace_period_string = descriptor._model_data.get('graceperiod', None)
try: try:
problem_timeinfo = TimeInfo(problem['due'], grace_period_string) problem_timeinfo = TimeInfo(problem['due'], grace_period_string)
except: except:
...@@ -516,7 +519,7 @@ class PeerGradingModule(XModule): ...@@ -516,7 +519,7 @@ class PeerGradingModule(XModule):
Show individual problem interface Show individual problem interface
''' '''
if get is None or get.get('location') is None: if get is None or get.get('location') is None:
if not self.use_for_single_location: if self.use_for_single_location not in TRUE_DICT:
#This is an error case, because it must be set to use a single location to be called without get parameters #This is an error case, because it must be set to use a single location to be called without get parameters
#This is a dev_facing_error #This is a dev_facing_error
log.error("Peer grading problem in peer_grading_module called with no get parameters, but use_for_single_location is False.") log.error("Peer grading problem in peer_grading_module called with no get parameters, but use_for_single_location is False.")
......
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