Commit f396fd6e by kimth

CodeResponse uses 'is_file' helper function

parent 21a8ecf5
...@@ -800,6 +800,12 @@ class CodeResponse(LoncapaResponse): ...@@ -800,6 +800,12 @@ class CodeResponse(LoncapaResponse):
''' '''
Grade student code using an external queueing server, called 'xqueue' Grade student code using an external queueing server, called 'xqueue'
Expects 'xqueue' dict in ModuleSystem with the following keys:
system.xqueue = { 'interface': XqueueInterface object,
'callback_url': Per-StudentModule callback URL where results are posted (string),
'default_queuename': Default queuename to submit request (string)
}
External requests are only submitted for student submission grading External requests are only submitted for student submission grading
(i.e. and not for getting reference answers) (i.e. and not for getting reference answers)
''' '''
...@@ -873,15 +879,16 @@ class CodeResponse(LoncapaResponse): ...@@ -873,15 +879,16 @@ class CodeResponse(LoncapaResponse):
'edX_cmd': 'get_score', 'edX_cmd': 'get_score',
'edX_tests': self.tests, 'edX_tests': self.tests,
'processor': self.code, 'processor': self.code,
'edX_student_response': unicode(submission), # unicode on File object returns its filename
} }
# Submit request # Submit request
if hasattr(submission, 'read'): # Test for whether submission is a file if is_file(submission):
contents.update({'edX_student_response': submission.name})
(error, msg) = qinterface.send_to_queue(header=xheader, (error, msg) = qinterface.send_to_queue(header=xheader,
body=json.dumps(contents), body=json.dumps(contents),
file_to_upload=submission) file_to_upload=submission)
else: else:
contents.update({'edX_student_response': submission})
(error, msg) = qinterface.send_to_queue(header=xheader, (error, msg) = qinterface.send_to_queue(header=xheader,
body=json.dumps(contents)) body=json.dumps(contents))
......
...@@ -39,13 +39,13 @@ def convert_files_to_filenames(answers): ...@@ -39,13 +39,13 @@ def convert_files_to_filenames(answers):
''' '''
new_answers = dict() new_answers = dict()
for answer_id in answers.keys(): for answer_id in answers.keys():
if is_uploaded_file(answers[answer_id]): if is_file(answers[answer_id]):
new_answers[answer_id] = answers[answer_id].name new_answers[answer_id] = answers[answer_id].name
else: else:
new_answers[answer_id] = answers[answer_id] new_answers[answer_id] = answers[answer_id]
return new_answers return new_answers
def is_uploaded_file(file_to_test): def is_file(file_to_test):
''' '''
Duck typing to check if 'file_to_test' is a File object Duck typing to check if 'file_to_test' is a File object
''' '''
......
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