Commit 91b6bb64 by Calen Pennington

Move queue interface url and auth into configuration, rather than hardcoding it

parent cfe712cb
...@@ -90,6 +90,15 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -90,6 +90,15 @@ TEMPLATE_CONTEXT_PROCESSORS = (
################################# Jasmine ################################### ################################# Jasmine ###################################
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee' JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
#################### CAPA External Code Evaluation #############################
XQUEUE_INTERFACE = {
'url': 'http://localhost:8888',
'auth': {'username': 'local',
'password': 'local'}
}
################################# Middleware ################################### ################################# Middleware ###################################
# List of finder classes that know how to find static files in # List of finder classes that know how to find static files in
# various locations. # various locations.
......
...@@ -7,13 +7,10 @@ import logging ...@@ -7,13 +7,10 @@ import logging
import requests import requests
import time import time
# TODO: Collection of parameters to be hooked into rest of edX system
XQUEUE_LMS_AUTH = { 'username': 'LMS',
'password': 'PaloAltoCA' }
XQUEUE_URL = 'http://xqueue.edx.org'
log = logging.getLogger('mitx.' + __name__) log = logging.getLogger('mitx.' + __name__)
def make_hashkey(seed=None): def make_hashkey(seed=None):
''' '''
Generate a string key by hashing Generate a string key by hashing
...@@ -63,7 +60,7 @@ class XqueueInterface: ...@@ -63,7 +60,7 @@ class XqueueInterface:
Interface to the external grading system Interface to the external grading system
''' '''
def __init__(self, url=XQUEUE_URL, auth=XQUEUE_LMS_AUTH): def __init__(self, url, auth):
self.url = url self.url = url
self.auth = auth self.auth = auth
self.session = requests.session() self.session = requests.session()
...@@ -117,5 +114,3 @@ class XqueueInterface: ...@@ -117,5 +114,3 @@ class XqueueInterface:
return (1, 'unexpected HTTP status code [%d]' % r.status_code) return (1, 'unexpected HTTP status code [%d]' % r.status_code)
return parse_xreply(r.text) return parse_xreply(r.text)
qinterface = XqueueInterface()
...@@ -7,9 +7,9 @@ from django.http import Http404 ...@@ -7,9 +7,9 @@ from django.http import Http404
from django.http import HttpResponse from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from capa.xqueue_interface import XQueueInterface
from django.contrib.auth.models import User from django.contrib.auth.models import User
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from capa.xqueue_interface import qinterface
from mitxmako.shortcuts import render_to_string from mitxmako.shortcuts import render_to_string
from models import StudentModule, StudentModuleCache from models import StudentModule, StudentModuleCache
from static_replace import replace_urls from static_replace import replace_urls
...@@ -23,6 +23,12 @@ from courseware.courses import (has_staff_access_to_course, ...@@ -23,6 +23,12 @@ from courseware.courses import (has_staff_access_to_course,
log = logging.getLogger("mitx.courseware") log = logging.getLogger("mitx.courseware")
xqueue_interface = XQueueInterface(
settings.XQUEUE_INTERFACE['url'],
settings.XQUEUE_INTERFACE['auth']
)
def make_track_function(request): def make_track_function(request):
''' '''
Make a tracking function that logs what happened. Make a tracking function that logs what happened.
...@@ -172,9 +178,9 @@ def get_module(user, request, location, student_module_cache, position=None): ...@@ -172,9 +178,9 @@ def get_module(user, request, location, student_module_cache, position=None):
# TODO: Queuename should be derived from 'course_settings.json' of each course # TODO: Queuename should be derived from 'course_settings.json' of each course
xqueue_default_queuename = descriptor.location.org + '-' + descriptor.location.course xqueue_default_queuename = descriptor.location.org + '-' + descriptor.location.course
xqueue = { 'interface': qinterface, xqueue = {'interface': xqueue_interface,
'callback_url': xqueue_callback_url, 'callback_url': xqueue_callback_url,
'default_queuename': xqueue_default_queuename.replace(' ','_') } 'default_queuename': xqueue_default_queuename.replace(' ', '_')}
def _get_module(location): def _get_module(location):
return get_module(user, request, location, return get_module(user, request, location,
......
...@@ -54,3 +54,5 @@ AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"] ...@@ -54,3 +54,5 @@ AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"] AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]
DATABASES = AUTH_TOKENS['DATABASES'] DATABASES = AUTH_TOKENS['DATABASES']
XQUEUE_INTERFACE = AUTH_TOKENS['XQUEUE_INTERFACE']
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