Commit 80b62bf0 by kimth

Serialize xqueue payload

parent 6631848b
...@@ -317,6 +317,7 @@ def textbox(element, value, status, render_template, msg=''): ...@@ -317,6 +317,7 @@ def textbox(element, value, status, render_template, msg=''):
hidden = element.get('hidden', '') # if specified, then textline is hidden and id is stored in div of name given by hidden hidden = element.get('hidden', '') # if specified, then textline is hidden and id is stored in div of name given by hidden
linenumbers = element.get('linenumbers') # for CodeMirror linenumbers = element.get('linenumbers') # for CodeMirror
if not value: value = element.text # if no student input yet, then use the default input given by the problem if not value: value = element.text # if no student input yet, then use the default input given by the problem
if linenumbers is None: linenumbers = 'true'
context = {'id': eid, 'value': value, 'state': status, 'count': count, 'size': size, 'msg': msg, context = {'id': eid, 'value': value, 'state': status, 'count': count, 'size': size, 'msg': msg,
'mode': mode, 'linenumbers': linenumbers, 'mode': mode, 'linenumbers': linenumbers,
'rows': rows, 'cols': cols, 'rows': rows, 'cols': cols,
......
...@@ -810,7 +810,7 @@ class CodeResponse(LoncapaResponse): ...@@ -810,7 +810,7 @@ class CodeResponse(LoncapaResponse):
def setup_response(self): def setup_response(self):
xml = self.xml xml = self.xml
self.url = xml.get('url', "http://ec2-50-16-59-149.compute-1.amazonaws.com/xqueue/submit/") # FIXME -- hardcoded url self.url = xml.get('url', "http://107.20.215.194/xqueue/submit/") # FIXME -- hardcoded url
answer = xml.find('answer') answer = xml.find('answer')
if answer is not None: if answer is not None:
...@@ -904,7 +904,9 @@ class CodeResponse(LoncapaResponse): ...@@ -904,7 +904,9 @@ class CodeResponse(LoncapaResponse):
def _send_to_queue(self, extra_payload): def _send_to_queue(self, extra_payload):
# Prepare payload # Prepare payload
xmlstr = etree.tostring(self.xml, pretty_print=True) xmlstr = etree.tostring(self.xml, pretty_print=True)
header = {'return_url': self.system.xqueue_callback_url} header = {'return_url': self.system.xqueue_callback_url,
'queue_name': 'mitx-600x',
}
# Queuekey generation # Queuekey generation
h = hashlib.md5() h = hashlib.md5()
...@@ -913,11 +915,15 @@ class CodeResponse(LoncapaResponse): ...@@ -913,11 +915,15 @@ class CodeResponse(LoncapaResponse):
queuekey = int(h.hexdigest(), 16) queuekey = int(h.hexdigest(), 16)
header.update({'queuekey': queuekey}) header.update({'queuekey': queuekey})
payload = {'xqueue_header': json.dumps(header), # TODO: 'xqueue_header' should eventually be derived from a config file body = {'xml': xmlstr,
'xml': xmlstr, 'edX_cmd': 'get_score',
'edX_cmd': 'get_score', 'edX_tests': self.tests,
'edX_tests': self.tests, 'processor': self.code,
'processor': self.code, }
body.update(extra_payload)
payload = {'xqueue_header': json.dumps(header),
'xqueue_body' : json.dumps(body),
} }
payload.update(extra_payload) payload.update(extra_payload)
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
% if linenumbers == 'true': % if linenumbers == 'true':
lineNumbers: true, lineNumbers: true,
% endif % endif
mode: "${mode}" mode: "${mode}",
tabsize: 4,
}); });
}); });
</script> </script>
......
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