diff --git a/lms/djangoapps/open_ended_grading/grading_service.py b/lms/djangoapps/open_ended_grading/grading_service.py index 3c92c5bddd..96bd931448 100644 --- a/lms/djangoapps/open_ended_grading/grading_service.py +++ b/lms/djangoapps/open_ended_grading/grading_service.py @@ -44,7 +44,7 @@ class GradingService(object): return response.json - def post(self, url, allow_redirects, data): + def post(self, url, data, allow_redirects=False): """ Make a post request to the grading controller """ @@ -58,7 +58,7 @@ class GradingService(object): return r.text - def get(self, url, allow_redirects, params): + def get(self, url, params, allow_redirects=False): """ Make a get request to the grading controller """ diff --git a/lms/djangoapps/open_ended_grading/peer_grading_service.py b/lms/djangoapps/open_ended_grading/peer_grading_service.py index b8d8d2dbe6..14065d54e4 100644 --- a/lms/djangoapps/open_ended_grading/peer_grading_service.py +++ b/lms/djangoapps/open_ended_grading/peer_grading_service.py @@ -16,6 +16,10 @@ from student.models import unique_id_for_user log = logging.getLogger(__name__) +""" +This is a mock peer grading service that can be used for unit tests +without making actual service calls to the grading controller +""" class MockPeerGradingService(object): def get_next_submission(self, problem_location, grader_id): return json.dumps({'success': True, @@ -26,7 +30,8 @@ class MockPeerGradingService(object): 'rubric': 'fake rubric', 'max_score': 4}) - def save_grade(self, location, grader_id, submission_id, score, feedback, submission_key): + def save_grade(self, location, grader_id, submission_id, + score, feedback, submission_key): return json.dumps({'success': True}) def is_student_calibrated(self, problem_location, grader_id): @@ -41,15 +46,16 @@ class MockPeerGradingService(object): 'rubric': 'fake rubric', 'max_score': 4}) - def save_calibration_essay(self, problem_location, grader_id, calibration_essay_id, submission_key, score, feedback): + def save_calibration_essay(self, problem_location, grader_id, + calibration_essay_id, submission_key, score, feedback): return {'success': True, 'actual_score': 2} def get_problem_list(self, course_id, grader_id): return json.dumps({'success': True, 'problem_list': [ - json.dumps({'location': 'i4x://MITx/3.091x/problem/open_ended_demo1', \ + json.dumps({'location': 'i4x://MITx/3.091x/problem/open_ended_demo1', 'problem_name': "Problem 1", 'num_graded': 3, 'num_pending': 5}), - json.dumps({'location': 'i4x://MITx/3.091x/problem/open_ended_demo2', \ + json.dumps({'location': 'i4x://MITx/3.091x/problem/open_ended_demo2', 'problem_name': "Problem 2", 'num_graded': 1, 'num_pending': 5}) ]}) @@ -78,15 +84,15 @@ class PeerGradingService(GradingService): 'feedback' : feedback, 'submission_key': submission_key, 'location': location} - return self.post(self.save_grade_url, False, data) + return self.post(self.save_grade_url, data) def is_student_calibrated(self, problem_location, grader_id): params = {'problem_id' : problem_location, 'student_id': grader_id} - return self.get(self.is_student_calibrated_url, False, params) + return self.get(self.is_student_calibrated_url, params) def show_calibration_essay(self, problem_location, grader_id): params = {'problem_id' : problem_location, 'student_id': grader_id} - return self.get(self.show_calibration_essay_url, False, params) + return self.get(self.show_calibration_essay_url, params) def save_calibration_essay(self, problem_location, grader_id, calibration_essay_id, submission_key, score, feedback): data = {'location': problem_location, @@ -95,11 +101,11 @@ class PeerGradingService(GradingService): 'submission_key': submission_key, 'score': score, 'feedback': feedback} - return self.post(self.save_calibration_essay_url, False, data) + return self.post(self.save_calibration_essay_url, data) def get_problem_list(self, course_id, grader_id): params = {'course_id': course_id, 'student_id': grader_id} - response = self.get(self.get_problem_list_url, False, params) + response = self.get(self.get_problem_list_url, params) return response diff --git a/lms/djangoapps/open_ended_grading/staff_grading_service.py b/lms/djangoapps/open_ended_grading/staff_grading_service.py index 521983eeee..5c6cec17eb 100644 --- a/lms/djangoapps/open_ended_grading/staff_grading_service.py +++ b/lms/djangoapps/open_ended_grading/staff_grading_service.py @@ -85,7 +85,7 @@ class StaffGradingService(GradingService): GradingServiceError: something went wrong with the connection. """ params = {'course_id': course_id,'grader_id': grader_id} - return self.get(self.get_problem_list_url, False, params) + return self.get(self.get_problem_list_url, params) def get_next(self, course_id, location, grader_id): @@ -107,7 +107,6 @@ class StaffGradingService(GradingService): GradingServiceError: something went wrong with the connection. """ return self.get(self.get_next_url, - allow_redirects=False, params={'location': location, 'grader_id': grader_id}) @@ -131,8 +130,7 @@ class StaffGradingService(GradingService): 'grader_id': grader_id, 'skipped': skipped} - return self.post(self.save_grade_url, data=data, - allow_redirects=False) + return self.post(self.save_grade_url, data=data) # don't initialize until staff_grading_service() is called--means that just # importing this file doesn't create objects that may not have the right config