diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index cd60e2572c..c2df24dfff 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -66,7 +66,7 @@ class PeerGradingModule(XModule): #We need to set the location here so the child modules can use it system.set('location', location) self.system = system - self.peer_gs = peer_grading_service() + self.peer_gs = peer_grading_service(self.system) self.use_for_single_location = self.metadata.get('use_for_single_location', USE_FOR_SINGLE_LOCATION) if isinstance(self.use_for_single_location, basestring): @@ -106,6 +106,7 @@ class PeerGradingModule(XModule): @return: """ + log.debug(get) handlers = { 'get_next_submission': self.get_next_submission, 'show_calibration_essay': self.show_calibration_essay, @@ -120,8 +121,6 @@ class PeerGradingModule(XModule): d = handlers[dispatch](get) - log.debug(d) - return json.dumps(d, cls=ComplexEncoder) def get_progress(self): @@ -191,8 +190,10 @@ class PeerGradingModule(XModule): score = get['score'] feedback = get['feedback'] submission_key = get['submission_key'] - rubric_scores = get['rubric_scores'] + rubric_scores = get['rubric_scores[]'] submission_flagged = get['submission_flagged'] + log.debug(get) + log.debug(rubric_scores) try: response = self.peer_gs.save_grade(location, grader_id, submission_id, score, feedback, submission_key, rubric_scores, submission_flagged) @@ -322,7 +323,7 @@ class PeerGradingModule(XModule): submission_key = get['submission_key'] score = get['score'] feedback = get['feedback'] - rubric_scores = get['rubric_scores'] + rubric_scores = get['rubric_scores[]'] try: response = self.peer_gs.save_calibration_essay(location, grader_id, calibration_essay_id, @@ -343,7 +344,7 @@ class PeerGradingModule(XModule): problem_list = [] try: problem_list_json = self.peer_gs.get_problem_list(self.system.course_id, self.system.anonymous_student_id) - problem_list_dict = json.loads(problem_list_json) + problem_list_dict = problem_list_json success = problem_list_dict['success'] if 'error' in problem_list_dict: error_text = problem_list_dict['error'] diff --git a/common/lib/xmodule/xmodule/peer_grading_service.py b/common/lib/xmodule/xmodule/peer_grading_service.py index 3328a2c3cc..06fa7351cd 100644 --- a/common/lib/xmodule/xmodule/peer_grading_service.py +++ b/common/lib/xmodule/xmodule/peer_grading_service.py @@ -19,7 +19,7 @@ class PeerGradingService(): """ Interface with the grading controller for peer grading """ - def __init__(self, config): + def __init__(self, config, system): self.username = config['username'] self.password = config['password'] self.url = config['url'] @@ -32,6 +32,7 @@ class PeerGradingService(): self.save_calibration_essay_url = self.url + '/save_calibration_essay/' self.get_problem_list_url = self.url + '/get_problem_list/' self.get_notifications_url = self.url + '/get_notifications/' + self.system = system def get_next_submission(self, problem_location, grader_id): response = self.get(self.get_next_submission_url, @@ -48,7 +49,6 @@ class PeerGradingService(): 'rubric_scores': rubric_scores, 'rubric_scores_complete': True, 'submission_flagged' : submission_flagged} - log.debug(data) return self.post(self.save_grade_url, data) def is_student_calibrated(self, problem_location, grader_id): @@ -70,7 +70,6 @@ class PeerGradingService(): 'feedback': feedback, 'rubric_scores[]': rubric_scores, 'rubric_scores_complete': True} - log.debug(data) return self.post(self.save_calibration_essay_url, data) def get_problem_list(self, course_id, grader_id): @@ -123,7 +122,6 @@ class PeerGradingService(): """ Make a get request to the grading controller """ - log.debug(params) op = lambda: self.session.get(url, allow_redirects=allow_redirects, params=params) @@ -240,7 +238,7 @@ class MockPeerGradingService(object): ]}) _service = None -def peer_grading_service(): +def peer_grading_service(system): """ Return a peer grading service instance--if settings.MOCK_PEER_GRADING is True, returns a mock one, otherwise a real one. @@ -255,6 +253,6 @@ def peer_grading_service(): if settings.MOCK_PEER_GRADING: _service = MockPeerGradingService() else: - _service = PeerGradingService(settings.PEER_GRADING_INTERFACE) + _service = PeerGradingService(settings.PEER_GRADING_INTERFACE, system) return _service