Commit 0958485b by kimth

update_score: edit existing CorrectMap rather than starting with empty CorrectMap

parent 093ac9d1
......@@ -22,6 +22,7 @@ import random
import re
import scipy
import struct
import json
from lxml import etree
from xml.sax.saxutils import unescape
......@@ -186,14 +187,13 @@ class LoncapaProblem(object):
Returns an updated CorrectMap
'''
oldcmap = self.correct_map
newcmap = CorrectMap()
cmap = self.correct_map
for responder in self.responders.values():
if hasattr(responder,'update_score'): # TODO: Is this the best way to target 'update_score' of CodeResponse?
results = responder.update_score(score_msg, oldcmap, queuekey)
newcmap.update(results)
self.correct_map = newcmap
return newcmap
# Each LoncapaResponse will update the specific entries of 'cmap' that it's responsible for
cmap = responder.update_score(score_msg, cmap, queuekey)
self.correct_map = cmap
return cmap
def is_queued(self):
'''
......
......@@ -695,8 +695,9 @@ class SymbolicResponse(CustomResponse):
class CodeResponse(LoncapaResponse):
'''
Grade student code using an external server. Unlike ExternalResponse, CodeResponse:
1) Goes through a queueing system (xqueue)
Grade student code using an external server, called 'xqueue'
In contrast to ExternalResponse, CodeResponse has following behavior:
1) Goes through a queueing system
2) Does not do external request for 'get_answers'
'''
......@@ -740,7 +741,7 @@ class CodeResponse(LoncapaResponse):
# Non-null CorrectMap['queuekey'] indicates that the problem has been submitted
cmap = CorrectMap()
for answer_id in idset:
cmap.set(answer_id, queuekey=queuekey)
cmap.set(answer_id, queuekey=queuekey, msg='Submitted to queue')
return cmap
......@@ -804,7 +805,7 @@ class CodeResponse(LoncapaResponse):
queuekey = random.randint(0,2**32-1)
header.update({'queuekey': queuekey})
payload = {'xqueue_header': json.dumps(header), # TODO: 'xqueue_header' should eventually be derived from config file
payload = {'xqueue_header': json.dumps(header), # TODO: 'xqueue_header' should eventually be derived from a config file
'xml': xmlstr,
'edX_cmd': 'get_score',
'edX_tests': self.tests,
......
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