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