From 9bca4ebf210bde7ed8c96760cdcb1d7e6439c652 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Mon, 11 Feb 2013 17:32:11 -0500 Subject: [PATCH] Start to refactor grading settings --- .../xmodule/xmodule/peer_grading_module.py | 8 ------ .../xmodule/xmodule/peer_grading_service.py | 3 ++- common/lib/xmodule/xmodule/x_module.py | 8 +++++- .../controller_query_service.py | 1 + .../open_ended_notifications.py | 7 +++--- .../open_ended_grading/open_ended_util.py | 13 ---------- .../staff_grading_service.py | 2 +- lms/djangoapps/open_ended_grading/views.py | 3 +-- lms/envs/aws.py | 6 ++--- lms/envs/common.py | 25 +++++++------------ 10 files changed, 26 insertions(+), 50 deletions(-) delete mode 100644 lms/djangoapps/open_ended_grading/open_ended_util.py diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index 20f71f3b3c..3eab1aa0a1 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -1,11 +1,3 @@ -""" -This module provides an interface on the grading-service backend -for peer grading - -Use peer_grading_service() to get the version specified -in settings.PEER_GRADING_INTERFACE - -""" import json import logging import requests diff --git a/common/lib/xmodule/xmodule/peer_grading_service.py b/common/lib/xmodule/xmodule/peer_grading_service.py index 8c50b6ff0a..5efb9eb77f 100644 --- a/common/lib/xmodule/xmodule/peer_grading_service.py +++ b/common/lib/xmodule/xmodule/peer_grading_service.py @@ -28,6 +28,7 @@ class PeerGradingService(GradingService): def __init__(self, config, system): config['system'] = system super(PeerGradingService, self).__init__(config) + self.url = config['url'] + config['peer_grading'] self.get_next_submission_url = self.url + '/get_next_submission/' self.save_grade_url = self.url + '/save_grade/' self.is_student_calibrated_url = self.url + '/is_student_calibrated/' @@ -161,6 +162,6 @@ def peer_grading_service(system): if settings.MOCK_PEER_GRADING: _service = MockPeerGradingService() else: - _service = PeerGradingService(settings.PEER_GRADING_INTERFACE, system) + _service = PeerGradingService(settings.OPEN_ENDED_GRADING_INTERFACE, system) return _service diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 87c085b19a..fd4467372b 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -869,7 +869,10 @@ class ModuleSystem(object): xqueue=None, node_path="", anonymous_student_id='', - course_id=None): + course_id=None, + peer_grading_interface=None, + staff_grading_interface=None, + s3_interface=None): ''' Create a closure around the system environment. @@ -920,6 +923,9 @@ class ModuleSystem(object): self.anonymous_student_id = anonymous_student_id self.course_id = course_id self.user_is_staff = user is not None and user.is_staff + self.peer_grading_interface = peer_grading_interface + self.staff_grading_interface = staff_grading_interface + self.s3_interface = s3_interface def get(self, attr): ''' provide uniform access to attributes (like etree).''' diff --git a/lms/djangoapps/open_ended_grading/controller_query_service.py b/lms/djangoapps/open_ended_grading/controller_query_service.py index 83d5617bd2..03a318b6dc 100644 --- a/lms/djangoapps/open_ended_grading/controller_query_service.py +++ b/lms/djangoapps/open_ended_grading/controller_query_service.py @@ -20,6 +20,7 @@ class ControllerQueryService(GradingService): def __init__(self, config): config['system'] = ModuleSystem(None, None, None, render_to_string, None) super(ControllerQueryService, self).__init__(config) + self.url = config['url'] + config['grading_controller'] self.check_eta_url = self.url + '/get_submission_eta/' self.is_unique_url = self.url + '/is_name_unique/' self.combined_notifications_url = self.url + '/combined_notifications/' diff --git a/lms/djangoapps/open_ended_grading/open_ended_notifications.py b/lms/djangoapps/open_ended_grading/open_ended_notifications.py index 4055aab347..a9151b6f38 100644 --- a/lms/djangoapps/open_ended_grading/open_ended_notifications.py +++ b/lms/djangoapps/open_ended_grading/open_ended_notifications.py @@ -28,7 +28,7 @@ NOTIFICATION_TYPES = ( def staff_grading_notifications(course, user): - staff_gs = StaffGradingService(settings.STAFF_GRADING_INTERFACE) + staff_gs = StaffGradingService(settings.OPEN_ENDED_GRADING_INTERFACE) pending_grading = False img_path = "" course_id = course.id @@ -61,7 +61,7 @@ def staff_grading_notifications(course, user): def peer_grading_notifications(course, user): system = ModuleSystem(None, None, None, render_to_string, None) - peer_gs = peer_grading_service.PeerGradingService(settings.PEER_GRADING_INTERFACE, system) + peer_gs = peer_grading_service.PeerGradingService(settings.OPEN_ENDED_GRADING_INTERFACE, system) pending_grading = False img_path = "" course_id = course.id @@ -93,8 +93,7 @@ def peer_grading_notifications(course, user): def combined_notifications(course, user): - controller_url = open_ended_util.get_controller_url() - controller_qs = ControllerQueryService(controller_url) + controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE) student_id = unique_id_for_user(user) user_is_staff = has_access(user, course, 'staff') course_id = course.id diff --git a/lms/djangoapps/open_ended_grading/open_ended_util.py b/lms/djangoapps/open_ended_grading/open_ended_util.py deleted file mode 100644 index 1aa0f1ba70..0000000000 --- a/lms/djangoapps/open_ended_grading/open_ended_util.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.conf import settings -import logging - -log = logging.getLogger(__name__) - - -def get_controller_url(): - peer_grading_url = settings.PEER_GRADING_INTERFACE['url'] - split_url = peer_grading_url.split("/") - controller_url = "http://" + split_url[2] + "/grading_controller" - controller_settings = settings.PEER_GRADING_INTERFACE.copy() - controller_settings['url'] = controller_url - return controller_settings diff --git a/lms/djangoapps/open_ended_grading/staff_grading_service.py b/lms/djangoapps/open_ended_grading/staff_grading_service.py index dfadacb724..0a760c09f1 100644 --- a/lms/djangoapps/open_ended_grading/staff_grading_service.py +++ b/lms/djangoapps/open_ended_grading/staff_grading_service.py @@ -163,7 +163,7 @@ def staff_grading_service(): if settings.MOCK_STAFF_GRADING: _service = MockStaffGradingService() else: - _service = StaffGradingService(settings.STAFF_GRADING_INTERFACE) + _service = StaffGradingService(settings.OPEN_ENDED_GRADING_INTERFACE) return _service diff --git a/lms/djangoapps/open_ended_grading/views.py b/lms/djangoapps/open_ended_grading/views.py index f2e2a4513e..e1766335ab 100644 --- a/lms/djangoapps/open_ended_grading/views.py +++ b/lms/djangoapps/open_ended_grading/views.py @@ -30,8 +30,7 @@ log = logging.getLogger(__name__) template_imports = {'urllib': urllib} -controller_url = open_ended_util.get_controller_url() -controller_qs = ControllerQueryService(controller_url) +controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE) """ Reverses the URL from the name and the course id, and then adds a trailing slash if diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 0779f1f684..3bf244eaca 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -101,10 +101,7 @@ XQUEUE_INTERFACE = AUTH_TOKENS['XQUEUE_INTERFACE'] MODULESTORE = AUTH_TOKENS.get('MODULESTORE', MODULESTORE) CONTENTSTORE = AUTH_TOKENS.get('CONTENTSTORE', CONTENTSTORE) -STAFF_GRADING_INTERFACE = AUTH_TOKENS.get('STAFF_GRADING_INTERFACE', - STAFF_GRADING_INTERFACE) -PEER_GRADING_INTERFACE = AUTH_TOKENS.get('PEER_GRADING_INTERFACE', - PEER_GRADING_INTERFACE) +OPEN_ENDED_GRADING_INTERFACE = AUTH_TOKENS.get('OPEN_ENDED_GRADING_INTERFACE', OPEN_ENDED_GRADING_INTERFACE) PEARSON_TEST_USER = "pearsontest" PEARSON_TEST_PASSWORD = AUTH_TOKENS.get("PEARSON_TEST_PASSWORD") @@ -114,3 +111,4 @@ PEARSON = AUTH_TOKENS.get("PEARSON") # Datadog for events! DATADOG_API = AUTH_TOKENS.get("DATADOG_API") +OPEN_ENDED \ No newline at end of file diff --git a/lms/envs/common.py b/lms/envs/common.py index f3bf223451..4d2533ca3c 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -311,37 +311,30 @@ WIKI_USE_BOOTSTRAP_SELECT_WIDGET = False WIKI_LINK_LIVE_LOOKUPS = False WIKI_LINK_DEFAULT_LEVEL = 2 -################################# Staff grading config ##################### - -#By setting up the default settings with an incorrect user name and password, -# will get an error when attempting to connect -STAFF_GRADING_INTERFACE = { - 'url': 'http://sandbox-grader-001.m.edx.org/staff_grading', - 'username': 'incorrect_user', - 'password': 'incorrect_pass', - } - -# Used for testing, debugging -MOCK_STAFF_GRADING = False - ################################# Pearson TestCenter config ################ PEARSONVUE_SIGNINPAGE_URL = "https://www1.pearsonvue.com/testtaker/signin/SignInPage/EDX" # TESTCENTER_ACCOMMODATION_REQUEST_EMAIL = "exam-help@edx.org" -################################# Peer grading config ##################### +################################# open ended grading config ##################### #By setting up the default settings with an incorrect user name and password, # will get an error when attempting to connect -PEER_GRADING_INTERFACE = { +OPEN_ENDED_GRADING_INTERFACE = { 'url': 'http://sandbox-grader-001.m.edx.org/peer_grading', 'username': 'incorrect_user', 'password': 'incorrect_pass', + 'staff_grading' : 'staff_grading', + 'peer_grading' : 'peer_grading', + 'grading_controller' : 'grading_controller' } -# Used for testing, debugging +# Used for testing, debugging peer grading MOCK_PEER_GRADING = False +# Used for testing, debugging staff grading +MOCK_STAFF_GRADING = False + ################################# Jasmine ################################### JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'