Commit 31e3cff6 by Justin Riley

move proctor server settings to inheritable fields

This completely removes the direct dependency on django and allows these
settings to be configured in the advanced settings pane in Studio and/or
in the course policy.json.
parent 1f4e2f8a
......@@ -86,7 +86,18 @@ class InheritanceMixin(XBlockMixin):
"If the value is not set, infinite attempts are allowed."),
values={"min": 0}, scope=Scope.settings
)
proctor_url = String(
help="URL of proctor server",
scope=Scope.settings
)
proctor_user = String(
help="proctor server username",
scope=Scope.settings
)
proctor_password = String(
help="proctor server password",
scope=Scope.settings
)
def compute_inherited_metadata(descriptor):
......
......@@ -5,8 +5,6 @@ import requests
from lxml import etree
from pkg_resources import resource_string
from django.conf import settings
from xmodule.x_module import XModule
from xmodule.seq_module import SequenceDescriptor
......@@ -30,22 +28,20 @@ class ProctorPanel(object):
}
'''
def __init__(self, user, procset_name):
self.ProctorPanelInterface = getattr(settings, 'PROCTOR_PANEL_INTERFACE', {})
self.ProctorPanelServer = self.ProctorPanelInterface.get('url', "")
def __init__(self, user, proc_url, proc_user, proc_pass, procset_name):
self.proc_url = proc_url
self.proc_user = proc_user
self.proc_pass = proc_pass
self.procset_name = procset_name
self.ses = requests.session()
self.user = user
self.user_id = user.id
def is_released(self):
#url = '{2}/cmd/status/{0}/{1}'.format(self.user_id, self.procset_name, self.ProctorPanelServer)
url = '{1}/cmd/status/{0}'.format(self.user_id, self.ProctorPanelServer)
#url = '{2}/cmd/status/{0}/{1}'.format(self.user.id, self.procset_name, self.proc_url)
url = '{1}/cmd/status/{0}'.format(self.user.id, self.proc_url)
log.info('ProctorPanel url={0}'.format(url))
#ret = self.ses.post(url, data={'userid' : self.user_id, 'urlname': self.procset_name}, verify=False)
auth = (self.ProctorPanelInterface.get('username'), self.ProctorPanelInterface.get('password'))
#ret = self.ses.post(url, data={'userid' : self.user.id, 'urlname': self.procset_name}, verify=False)
auth = (self.proc_user, self.proc_pass)
ret = self.ses.get(url, verify=False, auth=auth, params={'problem': self.procset_name})
try:
retdat = json.loads(ret.content)
......@@ -68,6 +64,9 @@ class ProctorFields(object):
procset_name = String(help="Name of this proctored set", scope=Scope.settings)
staff_release = Boolean(help="True if staff forced release independent of proctor panel",
default=False, scope=Scope.user_state)
proctor_url = String(help="URL of proctor server", scope=Scope.settings)
proctor_user = String(help="proctor server username", scope=Scope.settings)
proctor_password = String(help="proctor server password", scope=Scope.settings)
class ProctorModule(ProctorFields, XModule):
......@@ -106,7 +105,8 @@ class ProctorModule(ProctorFields, XModule):
super(ProctorModule, self).__init__(*args, **kwargs)
# check proctor panel to see if this should be released
user = self.runtime.get_real_user(self.runtime.anonymous_student_id)
self.pp = ProctorPanel(user, self.procset_name)
self.pp = ProctorPanel(user, self.proctor_url, self.proctor_user,
self.proctor_password, self.procset_name)
self.child_descriptor = self.descriptor.get_children()[0]
log.debug("children of proctor module (should be only 1): %s", self.get_children())
......
......@@ -39,7 +39,7 @@ procrel = (function(){
var mkurl = function(cmd) {
ps = encodeURIComponent("${pp.procset_name}");
return "${pp.ProctorPanelServer}/cmd/" + cmd + "/${pp.user_id}/" + ps;
return "${pp.proc_url}/cmd/" + cmd + "/${pp.user.id}/" + ps;
}
var statel = $('#proctor_stat_${element_id}');
......@@ -57,8 +57,8 @@ procrel = (function(){
xhrFields: {
withCredentials: true
},
username: "${pp.ProctorPanelInterface.get('username')}",
password: "${pp.ProctorPanelInterface.get('password')}",
username: "${pp.proc_user}",
password: "${pp.proc_pass}",
success: gfun,
dataType: "json",
error: function(xhr, status, error) {
......
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