Commit cb203a6f by Vik Paruchuri

Better error messages

parent 62e93870
...@@ -224,6 +224,7 @@ class CombinedOpenEndedModule(XModule): ...@@ -224,6 +224,7 @@ class CombinedOpenEndedModule(XModule):
current_task_state=self.overwrite_state(current_task_state) current_task_state=self.overwrite_state(current_task_state)
self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, self.static_data, instance_state=current_task_state) self.current_task=children['modules'][current_task_type](self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, self.static_data, instance_state=current_task_state)
log.debug(current_task_state)
return True return True
def check_allow_reset(self): def check_allow_reset(self):
......
...@@ -405,23 +405,29 @@ class OpenEndedModule(openendedchild.OpenEndedChild): ...@@ -405,23 +405,29 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
correct: Correctness of submission (Boolean) correct: Correctness of submission (Boolean)
score: Points to be assigned (numeric, can be float) score: Points to be assigned (numeric, can be float)
""" """
fail = {'valid' : False, 'correct' : False, 'points' : 0, 'msg' : ''} fail = {'valid' : False, 'score' : 0, 'feedback' : ''}
try: try:
score_result = json.loads(score_msg) score_result = json.loads(score_msg)
except (TypeError, ValueError): except (TypeError, ValueError):
log.error("External grader message should be a JSON-serialized dict." error_message=("External grader message should be a JSON-serialized dict."
" Received score_msg = {0}".format(score_msg)) " Received score_msg = {0}".format(score_msg))
log.error(error_message)
fail['feedback']=error_message
return fail return fail
if not isinstance(score_result, dict): if not isinstance(score_result, dict):
log.error("External grader message should be a JSON-serialized dict." error_message=("External grader message should be a JSON-serialized dict."
" Received score_result = {0}".format(score_result)) " Received score_result = {0}".format(score_result))
log.error(error_message)
fail['feedback']=error_message
return fail return fail
for tag in ['score', 'feedback', 'grader_type', 'success', 'grader_id', 'submission_id']: for tag in ['score', 'feedback', 'grader_type', 'success', 'grader_id', 'submission_id']:
if tag not in score_result: if tag not in score_result:
log.error("External grader message is missing required tag: {0}" error_message=("External grader message is missing required tag: {0}"
.format(tag)) .format(tag))
log.error(error_message)
fail['feedback']=error _message
return fail return fail
#This is to support peer grading #This is to support peer grading
if isinstance(score_result['score'], list): if isinstance(score_result['score'], list):
......
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