Commit 954cacf6 by Usman Khalid

Merge pull request #2148 from edx/usman/ora197-error-on-xqueue-down

If unable to send submission/feedback to xqueue return an error instead of silently failing
parents a7d3a23f 1efe74ec
......@@ -71,10 +71,15 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
self._parse(oeparam, self.child_prompt, self.child_rubric, system)
# If there are multiple tasks (like self-assessment followed by ai), once
# the the status of the first task is set to DONE, setup_next_task() will
# create the OpenEndedChild with parameter child_created=True so that the
# submission can be sent to the grader. Keep trying each time this module
# is loaded until it succeeds.
if self.child_created is True and self.child_state == self.ASSESSING:
self.child_created = False
self.send_to_grader(self.latest_answer(), system)
self.child_created = False
success, message = self.send_to_grader(self.latest_answer(), system)
if success:
self.child_created = False
def _parse(self, oeparam, prompt, rubric, system):
'''
......@@ -196,20 +201,25 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
'student_info': json.dumps(student_info),
}
(error, msg) = qinterface.send_to_queue(
error, error_message = qinterface.send_to_queue(
header=xheader,
body=json.dumps(contents)
)
# Convert error to a success value
success = True
message = "Successfully saved your feedback."
if error:
success = False
self.child_state = self.DONE
message = "Unable to save your feedback. Please try again later."
log.error("Unable to send feedback to grader. location: {0}, error_message: {1}".format(
self.location_string, error_message
))
else:
self.child_state = self.DONE
# This is a student_facing_message
return {'success': success, 'msg': "Successfully submitted your feedback."}
return {'success': success, 'msg': message}
def send_to_grader(self, submission, system):
"""
......@@ -257,7 +267,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
})
# Submit request. When successful, 'msg' is the prior length of the queue
qinterface.send_to_queue(
error, error_message = qinterface.send_to_queue(
header=xheader,
body=json.dumps(contents)
)
......@@ -267,7 +277,17 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
'key': queuekey,
'time': qtime,
}
return True
success = True
message = "Successfully saved your submission."
if error:
success = False
message = 'Unable to submit your submission to grader. Please try again later.'
log.error("Unable to submit to grader. location: {0}, error_message: {1}".format(
self.location_string, error_message
))
return (success, message)
def _update_score(self, score_msg, queuekey, system):
"""
......@@ -671,17 +691,26 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
if self.child_state != self.INITIAL:
return self.out_of_sync_error(data)
message = "Successfully saved your submission."
# add new history element with answer and empty score and hint.
success, error_message, data = self.append_file_link_to_student_answer(data)
if success:
if not success:
message = error_message
else:
data['student_answer'] = OpenEndedModule.sanitize_html(data['student_answer'])
self.new_history_entry(data['student_answer'])
self.send_to_grader(data['student_answer'], system)
self.change_state(self.ASSESSING)
success, error_message = self.send_to_grader(data['student_answer'], system)
if not success:
message = error_message
# Store the answer instead
self.store_answer(data, system)
else:
self.new_history_entry(data['student_answer'])
self.change_state(self.ASSESSING)
return {
'success': success,
'error': error_message,
'error': message,
'student_response': data['student_answer'].replace("\n", "<br/>")
}
......
......@@ -283,7 +283,7 @@ class OpenEndedChild(object):
'child_state': self.child_state,
'max_score': self._max_score,
'child_attempts': self.child_attempts,
'child_created': False,
'child_created': self.child_created,
'stored_answer': self.stored_answer,
}
return json.dumps(state)
......
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