Commit 838a8624 by kimth

Add docstring to 'score_update' path

parent e7c25c99
......@@ -180,9 +180,15 @@ class LoncapaProblem(object):
'total': self.get_max_score()}
def update_score(self, score_msg):
'''
Deliver grading response (e.g. from async code checking) to
the specific ResponseType
Returns an updated CorrectMap
'''
newcmap = CorrectMap()
for responder in self.responders.values():
if hasattr(responder,'update_score'): # Is this the best way to implement 'update_score' for CodeResponse?
if hasattr(responder,'update_score'): # TODO: Is this the best way to target 'update_score' of CodeResponse?
results = responder.update_score(score_msg)
newcmap.update(results)
self.correct_map = newcmap
......
......@@ -696,7 +696,9 @@ class SymbolicResponse(CustomResponse):
class CodeResponse(LoncapaResponse):
'''
Grade student code using an external server
Grade student code using an external server. Unlike ExternalResponse, CodeResponse:
1) Goes through a queueing system (xqueue)
2) Does not do external request for 'get_answers'
'''
response_tag = 'coderesponse'
......@@ -704,9 +706,10 @@ class CodeResponse(LoncapaResponse):
def setup_response(self):
xml = self.xml
self.url = xml.get('url') or "http://ec2-50-16-59-149.compute-1.amazonaws.com/xqueue/submit/" # FIXME -- hardcoded url
self.url = xml.get('url', "http://ec2-50-16-59-149.compute-1.amazonaws.com/xqueue/submit/") # FIXME -- hardcoded url
answer = xml.find('answer')
if answer is not None:
answer_src = answer.get('src')
if answer_src is not None:
......@@ -791,7 +794,9 @@ class CodeResponse(LoncapaResponse):
# Prepare payload
xmlstr = etree.tostring(self.xml, pretty_print=True)
header = { 'return_url': self.system.xqueue_callback_url }
header.update({'timestamp': time.time()})
# header.update({'timestamp': time.time()})
random.seed()
header.update({'key': random.randint(0,2**32-1)})
payload = {'xqueue_header': json.dumps(header), # 'xqueue_header' should eventually be derived from xqueue.queue_common.HEADER_TAG or something similar
'xml': xmlstr,
'edX_cmd': 'get_score',
......
......@@ -323,6 +323,15 @@ class CapaModule(XModule):
raise self.system.exception404
def update_score(self, get):
"""
Delivers grading response (e.g. from asynchronous code checking) to
the capa problem, so its score can be updated
'get' must have a field 'response' which is a string that contains the
grader's response
No ajax return is needed. Return empty dict.
"""
score_msg = get['response']
self.lcp.update_score(score_msg)
......
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