From 4f3ec68fb744565af929da3eae5f9dc2c5262bf7 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Fri, 16 Aug 2013 14:12:37 -0400 Subject: [PATCH] Scroll to top in peer and staff grading, preserve line breaks in submissions --- .../js/src/combinedopenended/display.coffee | 30 +++++++++++-------- .../peergrading/peer_grading_problem.coffee | 8 ++++- .../open_ended_module.py | 2 +- .../openendedchild.py | 3 +- .../self_assessment_module.py | 2 +- .../src/staff_grading/staff_grading.coffee | 8 ++++- lms/templates/instructor/staff_grading.html | 6 ++-- lms/templates/peer_grading/peer_grading.html | 2 +- .../peer_grading/peer_grading_problem.html | 4 +-- 9 files changed, 43 insertions(+), 22 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee b/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee index e846717030..b4f72a3e1d 100644 --- a/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee @@ -100,6 +100,7 @@ class @CombinedOpenEnded open_ended_child_sel: 'section.open-ended-child' error_sel: '.error' answer_area_sel: 'textarea.answer' + answer_area_div_sel : 'div.answer' prompt_sel: '.prompt' rubric_wrapper_sel: '.rubric-wrapper' hint_wrapper_sel: '.hint-wrapper' @@ -339,6 +340,21 @@ class @CombinedOpenEnded find_hint_elements: -> @hint_area = @$('textarea.post_assessment') + replace_answer: (response) => + if response.success + @rubric_wrapper.html(response.rubric_html) + @rubric_wrapper.show() + @rub = new Rubric(@coe) + @rub.initialize(@location) + @child_state = 'assessing' + @find_assessment_elements() + @rebind() + answer_area_div = @$(@answer_area_div_sel) + answer_area_div.html(response.student_response) + else + @can_upload_files = pre_can_upload_files + @gentle_alert response.error + save_answer: (event) => @submit_button.attr("disabled",true) event.preventDefault() @@ -367,19 +383,9 @@ class @CombinedOpenEnded data: fd processData: false contentType: false + async: false success: (response) => - if response.success - @rubric_wrapper.html(response.rubric_html) - @rubric_wrapper.show() - @rub = new Rubric(@coe) - @rub.initialize(@location) - @answer_area.html(response.student_response) - @child_state = 'assessing' - @find_assessment_elements() - @rebind() - else - @can_upload_files = pre_can_upload_files - @gentle_alert response.error + @replace_answer(response) $.ajaxWithPrefix("#{@ajax_url}/save_answer",settings) else diff --git a/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading_problem.coffee b/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading_problem.coffee index a026cafd61..f96704037e 100644 --- a/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading_problem.coffee +++ b/common/lib/xmodule/xmodule/js/src/peergrading/peer_grading_problem.coffee @@ -450,7 +450,7 @@ class @PeerGradingProblem @submit_button.unbind('click') @submit_button.click @submit_calibration_essay - + @scroll_to_top() else if response.error @render_error(response.error) else @@ -479,6 +479,7 @@ class @PeerGradingProblem @submit_button.unbind('click') @submit_button.click @submit_grade + @scroll_to_top() else if response.error @render_error(response.error) else @@ -573,3 +574,8 @@ class @PeerGradingProblem Logger.log 'peer_grading_show_question', {location: @location} new_text = "(Hide)" @question_header.text(new_text) + + scroll_to_top: () => + $('html, body').animate({ + scrollTop: $(".peer-grading").offset().top + }, 200) diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py index dc2c3fb01b..800789b56a 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py @@ -663,7 +663,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): return { 'success': success, 'error': error_message, - 'student_response': data['student_answer'] + 'student_response': data['student_answer'].replace("\n","
") } def update_score(self, data, system): diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py index 3e12b4656d..d99e466886 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py @@ -179,9 +179,10 @@ class OpenEndedChild(object): answer = autolink_html(answer) cleaner = Cleaner(style=True, links=True, add_nofollow=False, page_structure=True, safe_attrs_only=True, host_whitelist=open_ended_image_submission.TRUSTED_IMAGE_DOMAINS, - whitelist_tags=set(['embed', 'iframe', 'a', 'img'])) + whitelist_tags=set(['embed', 'iframe', 'a', 'img', 'br'])) clean_html = cleaner.clean_html(answer) clean_html = re.sub(r'

$', '', re.sub(r'^

', '', clean_html)) + clean_html = re.sub("\n","
", clean_html) except Exception: clean_html = answer return clean_html diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py index 5c40aca116..2485fc77ea 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py @@ -196,7 +196,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): 'success': success, 'rubric_html': self.get_rubric_html(system), 'error': error_message, - 'student_response': data['student_answer'], + 'student_response': data['student_answer'].replace("\n","
") } def save_assessment(self, data, _system): diff --git a/lms/static/coffee/src/staff_grading/staff_grading.coffee b/lms/static/coffee/src/staff_grading/staff_grading.coffee index e8cee60001..31c084ffd0 100644 --- a/lms/static/coffee/src/staff_grading/staff_grading.coffee +++ b/lms/static/coffee/src/staff_grading/staff_grading.coffee @@ -253,7 +253,7 @@ class @StaffGrading # always clear out errors and messages on transition. @error_msg = '' @message = '' - + if response.success if response.problem_list @problems = response.problem_list @@ -265,6 +265,7 @@ class @StaffGrading @error(response.error) @render_view() + @scroll_to_top() get_next_submission: (location) -> @location = location @@ -474,6 +475,11 @@ class @StaffGrading new_text = "(Hide)" @question_header.text(new_text) + scroll_to_top: () => + $('html, body').animate({ + scrollTop: $(".staff-grading").offset().top + }, 200) + # for now, just create an instance and load it... diff --git a/lms/templates/instructor/staff_grading.html b/lms/templates/instructor/staff_grading.html index bb60bddeb0..15ea97332a 100644 --- a/lms/templates/instructor/staff_grading.html +++ b/lms/templates/instructor/staff_grading.html @@ -38,6 +38,7 @@

+

@@ -80,8 +81,9 @@
-
- \ No newline at end of file + + + diff --git a/lms/templates/peer_grading/peer_grading.html b/lms/templates/peer_grading/peer_grading.html index 162c9273b0..b0dffe8f9d 100644 --- a/lms/templates/peer_grading/peer_grading.html +++ b/lms/templates/peer_grading/peer_grading.html @@ -9,7 +9,7 @@ % if success: % if len(problem_list) == 0:
- ${_("You currently do not having any peer grading to do. In order to have peer grading to do, you need to have submitted a response to a peer grading problem. The instructor also needs to score the essays that are used in the 'learning to grade' process.")} + ${_("You currently do not having any peer grading to do. In order to have peer grading to do, you need to have submitted a response to a peer grading problem. The instructor also needs to score the essays that are used to help you better understand the grading criteria.")}
%else:
diff --git a/lms/templates/peer_grading/peer_grading_problem.html b/lms/templates/peer_grading/peer_grading_problem.html index a0078b8868..b945e030cb 100644 --- a/lms/templates/peer_grading/peer_grading_problem.html +++ b/lms/templates/peer_grading/peer_grading_problem.html @@ -27,6 +27,8 @@
+
+

${_("Student Response")}

@@ -53,8 +55,6 @@
-
-