diff --git a/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading.coffee b/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading.coffee index a82353b7ef..113f5e02a6 100644 --- a/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading.coffee +++ b/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading.coffee @@ -4,12 +4,18 @@ # becomes more sophisticated class PeerGrading constructor: () -> + @peer_grading_container = $('.peer-grading') + @peer_grading_outer_container = $('.peer-grading-container') + @ajax_url = peer_grading_container.data('ajax-url') @error_container = $('.error-container') @error_container.toggle(not @error_container.is(':empty')) @message_container = $('.message-container') @message_container.toggle(not @message_container.is(':empty')) + @problem_button = $('.problem-button') + @problem_button.click show_results + @problem_list = $('.problem-list') @construct_progress_bar() @@ -22,6 +28,14 @@ class PeerGrading bar_max = parseInt(problem.data('required')) + bar_value progress_bar.progressbar({value: bar_value, max: bar_max}) ) - + + show_results: (event) => + location_to_fetch = $(event.target).data('location') + data = {'location' : location_to_fetch} + $.postWithPrefix "#{@ajax_url}problem", data, (response) => + if response.success + @peer_grading_outer_container.after(response.html).remove() + else + @gentle_alert response.error $(document).ready(() -> new PeerGrading()) diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index 87469dba51..c5a08e0812 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -74,6 +74,10 @@ class PeerGradingModule(XModule): if isinstance(self.use_for_single_location, basestring): self.use_for_single_location = (self.use_for_single_location in TRUE_DICT) + self.ajax_url = self.system.ajax_url + if not self.ajax_url.endswith("/"): + self.ajax_url = self.ajax_url + "/" + def _err_response(self, msg): """ Return a HttpResponse with a json dump with success=False, and the given error message. @@ -108,11 +112,10 @@ class PeerGradingModule(XModule): handlers = { 'get_next_submission': self.get_next_submission, 'show_calibration_essay': self.show_calibration_essay, - 'save_post_assessment': self.message_post, 'is_student_calibrated': self.is_student_calibrated, 'save_grade': self.save_grade, 'save_calibration_essay' : self.save_calibration_essay, - 'show_problem' : self.peer_grading_problem, + 'problem' : self.peer_grading_problem, } if dispatch not in handlers: @@ -357,9 +360,8 @@ class PeerGradingModule(XModule): error_text = "Could not get problem list" success = False - ajax_url = self.system.ajax_url - - return self.system.render_template('peer_grading/peer_grading.html', { + ajax_url = self.ajax_url + html = self.system.render_template('peer_grading/peer_grading.html', { 'course_id': self.system.course_id, 'ajax_url': ajax_url, 'success': success, @@ -368,6 +370,7 @@ class PeerGradingModule(XModule): # Checked above 'staff_access': False, }) + return html def peer_grading_problem(self, get = None): ''' @@ -380,9 +383,8 @@ class PeerGradingModule(XModule): else: problem_location = self.system.location - ajax_url = self.system.ajax_url - - return self.system.render_template('peer_grading/peer_grading_problem.html', { + ajax_url = self.ajax_url + html = self.system.render_template('peer_grading/peer_grading_problem.html', { 'view_html': '', 'problem_location': problem_location, 'course_id': self.system.course_id, @@ -390,6 +392,8 @@ class PeerGradingModule(XModule): # Checked above 'staff_access': False, }) + return {'html' : html, 'success' : True} + class PeerGradingDescriptor(XmlDescriptor, EditingDescriptor): """ Module for adding combined open ended questions diff --git a/lms/templates/peer_grading/peer_grading.html b/lms/templates/peer_grading/peer_grading.html index fff753da41..99ef288e5f 100644 --- a/lms/templates/peer_grading/peer_grading.html +++ b/lms/templates/peer_grading/peer_grading.html @@ -1,4 +1,4 @@ -
+
${error_text}

Peer Grading

@@ -22,7 +22,7 @@ %for problem in problem_list: - ${problem['problem_name']} + ${problem['problem_name']} ${problem['num_graded']} diff --git a/lms/templates/peer_grading/peer_grading_problem.html b/lms/templates/peer_grading/peer_grading_problem.html index f314b9733a..9646b861c1 100644 --- a/lms/templates/peer_grading/peer_grading_problem.html +++ b/lms/templates/peer_grading/peer_grading_problem.html @@ -1,4 +1,4 @@ -
+