From 80b62bf026bce707a0488e6e648785a9fe6fc0ca Mon Sep 17 00:00:00 2001 From: kimth Date: Mon, 30 Jul 2012 12:30:08 -0400 Subject: [PATCH 1/7] Serialize xqueue payload --- common/lib/capa/capa/inputtypes.py | 1 + common/lib/capa/capa/responsetypes.py | 20 +++++++++++++------- common/lib/capa/capa/templates/textbox.html | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 093595963c..59ca03bf53 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -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 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 linenumbers is None: linenumbers = 'true' context = {'id': eid, 'value': value, 'state': status, 'count': count, 'size': size, 'msg': msg, 'mode': mode, 'linenumbers': linenumbers, 'rows': rows, 'cols': cols, diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 08a4521bbb..24cde4da00 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -810,7 +810,7 @@ class CodeResponse(LoncapaResponse): def setup_response(self): 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') if answer is not None: @@ -904,7 +904,9 @@ class CodeResponse(LoncapaResponse): def _send_to_queue(self, extra_payload): # Prepare payload 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 h = hashlib.md5() @@ -913,11 +915,15 @@ class CodeResponse(LoncapaResponse): queuekey = int(h.hexdigest(), 16) header.update({'queuekey': queuekey}) - 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, - 'processor': self.code, + body = {'xml': xmlstr, + 'edX_cmd': 'get_score', + 'edX_tests': self.tests, + 'processor': self.code, + } + body.update(extra_payload) + + payload = {'xqueue_header': json.dumps(header), + 'xqueue_body' : json.dumps(body), } payload.update(extra_payload) diff --git a/common/lib/capa/capa/templates/textbox.html b/common/lib/capa/capa/templates/textbox.html index aa87682e59..d553ba16e5 100644 --- a/common/lib/capa/capa/templates/textbox.html +++ b/common/lib/capa/capa/templates/textbox.html @@ -34,7 +34,8 @@ % if linenumbers == 'true': lineNumbers: true, % endif - mode: "${mode}" + mode: "${mode}", + tabsize: 4, }); }); From 4e43b662fad1b51edeccd41be66317a9d0e03946 Mon Sep 17 00:00:00 2001 From: kimth Date: Mon, 30 Jul 2012 13:10:24 -0400 Subject: [PATCH 2/7] CodeResponse admits only one student response --- common/lib/capa/capa/responsetypes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 24cde4da00..bb511e588f 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -848,13 +848,13 @@ class CodeResponse(LoncapaResponse): def get_score(self, student_answers): try: - submission = [student_answers[self.answer_id]] + submission = student_answers[self.answer_id] except Exception as err: log.error('Error in CodeResponse %s: cannot get student answer for %s; student_answers=%s' % (err, self.answer_id, student_answers)) raise Exception(err) self.context.update({'submission': submission}) - extra_payload = {'edX_student_response': json.dumps(submission)} + extra_payload = {'edX_student_response': submission} r, queuekey = self._send_to_queue(extra_payload) # TODO: Perform checks on the xqueue response @@ -925,7 +925,6 @@ class CodeResponse(LoncapaResponse): payload = {'xqueue_header': json.dumps(header), 'xqueue_body' : json.dumps(body), } - payload.update(extra_payload) # Contact queue server try: From bd0b20bb60911791fe08873d5dc296a1a61071bc Mon Sep 17 00:00:00 2001 From: kimth Date: Mon, 30 Jul 2012 13:35:13 -0400 Subject: [PATCH 3/7] xqueue_callback uses 'xqueue_body' tag rather than 'response' tag for main message --- common/lib/xmodule/xmodule/capa_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 263e062887..1aa1b4c823 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -339,7 +339,7 @@ class CapaModule(XModule): No ajax return is needed. Return empty dict. """ queuekey = get['queuekey'] - score_msg = get['response'] + score_msg = get['xqueue_body'] self.lcp.update_score(score_msg, queuekey) return dict() # No AJAX return is needed From bd66a28d32f27c9e868b1919b44859381f3aa127 Mon Sep 17 00:00:00 2001 From: kimth Date: Mon, 30 Jul 2012 15:23:14 -0400 Subject: [PATCH 4/7] Add TODO note --- common/lib/capa/capa/responsetypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index bb511e588f..2a50b85cf7 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -905,7 +905,7 @@ class CodeResponse(LoncapaResponse): # Prepare payload xmlstr = etree.tostring(self.xml, pretty_print=True) header = {'return_url': self.system.xqueue_callback_url, - 'queue_name': 'mitx-600x', + 'queue_name': 'mitx-600x', # TODO: Queue name should derive from courseware or XML } # Queuekey generation From 6244412c28e65cc8cd1d812f05edcec7d8c4ff73 Mon Sep 17 00:00:00 2001 From: kimth Date: Mon, 30 Jul 2012 18:59:11 -0400 Subject: [PATCH 5/7] Simplify default linenumbers behavior --- common/lib/capa/capa/inputtypes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 59ca03bf53..31482214b3 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -315,9 +315,8 @@ def textbox(element, value, status, render_template, msg=''): cols = element.get('cols') or '80' mode = element.get('mode') or 'python' # mode for CodeMirror, eg "python" or "xml" 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','true') # for CodeMirror 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, 'mode': mode, 'linenumbers': linenumbers, 'rows': rows, 'cols': cols, From b9e5e9f0ee61ba5635a4c352be66eab05a66918e Mon Sep 17 00:00:00 2001 From: kimth Date: Mon, 30 Jul 2012 20:18:25 -0400 Subject: [PATCH 6/7] Read XML for queuename --- common/lib/capa/capa/responsetypes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 2a50b85cf7..944b84bf61 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -811,6 +811,7 @@ class CodeResponse(LoncapaResponse): def setup_response(self): xml = self.xml self.url = xml.get('url', "http://107.20.215.194/xqueue/submit/") # FIXME -- hardcoded url + self.queue_name = xml.get('queuename', 'python') # TODO: Default queue_name should be course-specific answer = xml.find('answer') if answer is not None: @@ -905,7 +906,7 @@ class CodeResponse(LoncapaResponse): # Prepare payload xmlstr = etree.tostring(self.xml, pretty_print=True) header = {'return_url': self.system.xqueue_callback_url, - 'queue_name': 'mitx-600x', # TODO: Queue name should derive from courseware or XML + 'queue_name': self.queue_name, } # Queuekey generation From 2f95a8e1d04b226c602b49256c8fee3e8163c2ef Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 31 Jul 2012 09:29:14 -0400 Subject: [PATCH 7/7] Re-add __init__.py for contentstore that was accidentally deleted in 05add5818ba15fd4aa3c558ac2647ac0642c1c2f --- cms/djangoapps/contentstore/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 cms/djangoapps/contentstore/__init__.py diff --git a/cms/djangoapps/contentstore/__init__.py b/cms/djangoapps/contentstore/__init__.py new file mode 100644 index 0000000000..e69de29bb2