diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index ded47b7ea0..6de9ec8523 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -29,7 +29,6 @@ import xqueue_interface log = logging.getLogger('mitx.' + __name__) -qinterface = xqueue_interface.XqueueInterface() #----------------------------------------------------------------------------- # Exceptions @@ -811,7 +810,7 @@ class CodeResponse(LoncapaResponse): def setup_response(self): xml = self.xml - self.queue_name = xml.get('queuename', self.system.xqueue_default_queuename) + self.queue_name = xml.get('queuename', self.system.xqueue['default_queuename']) answer = xml.find('answer') if answer is not None: @@ -859,10 +858,11 @@ class CodeResponse(LoncapaResponse): # Prepare xqueue request #------------------------------------------------------------ + qinterface = self.system.xqueue['interface'] # Generate header - queuekey = xqueue_interface.make_hashkey(self.system.seed) - xheader = xqueue_interface.make_xheader(lms_callback_url=self.system.xqueue_callback_url, + queuekey = xqueue_interface.make_hashkey(str(self.system.seed)+self.answer_id) + xheader = xqueue_interface.make_xheader(lms_callback_url=self.system.xqueue['callback_url'], lms_key=queuekey, queue_name=self.queue_name) diff --git a/common/lib/capa/capa/xqueue_interface.py b/common/lib/capa/capa/xqueue_interface.py index deb068adf6..f965b01723 100644 --- a/common/lib/capa/capa/xqueue_interface.py +++ b/common/lib/capa/capa/xqueue_interface.py @@ -112,3 +112,5 @@ class XqueueInterface: return (1, 'cannot connect to server') return parse_xreply(r.text) + +qinterface = XqueueInterface() diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 7bb98dcdc5..0eaca8c426 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -587,7 +587,7 @@ class ModuleSystem(object): def __init__(self, ajax_url, track_function, get_module, render_template, replace_urls, user=None, filestore=None, debug=False, - xqueue_callback_url=None, xqueue_default_queuename="null"): + xqueue=None): ''' Create a closure around the system environment. @@ -615,8 +615,7 @@ class ModuleSystem(object): ajax results. ''' self.ajax_url = ajax_url - self.xqueue_callback_url = xqueue_callback_url - self.xqueue_default_queuename = xqueue_default_queuename + self.xqueue = xqueue self.track_function = track_function self.filestore = filestore self.get_module = get_module diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 9ce4008597..b54e71df6d 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -8,6 +8,7 @@ from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.models import User from xmodule.modulestore.django import modulestore +from capa.xqueue_interface import qinterface from mitxmako.shortcuts import render_to_string from models import StudentModule, StudentModuleCache from static_replace import replace_urls @@ -151,6 +152,10 @@ def get_module(user, request, location, student_module_cache, position=None): # TODO: Queuename should be derived from 'course_settings.json' of each course xqueue_default_queuename = descriptor.location.org + '-' + descriptor.location.course + xqueue = { 'interface': qinterface, + 'callback_url': xqueue_callback_url, + 'default_queuename': xqueue_default_queuename.replace(' ','_') } + def _get_module(location): (module, _, _, _) = get_module(user, request, location, student_module_cache, position) @@ -162,8 +167,7 @@ def get_module(user, request, location, student_module_cache, position=None): system = ModuleSystem(track_function=make_track_function(request), render_template=render_to_string, ajax_url=ajax_url, - xqueue_callback_url=xqueue_callback_url, - xqueue_default_queuename=xqueue_default_queuename.replace(' ','_'), + xqueue=xqueue, # TODO (cpennington): Figure out how to share info between systems filestore=descriptor.system.resources_fs, get_module=_get_module, @@ -214,6 +218,9 @@ def get_module(user, request, location, student_module_cache, position=None): @csrf_exempt def xqueue_callback(request, userid, id, dispatch): + ''' + Entry point for graded results from the queueing system. + ''' # Parse xqueue response get = request.POST.copy() try: