Commit 0958485b by kimth

update_score: edit existing CorrectMap rather than starting with empty CorrectMap

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