Commit 4f3ec68f by Vik Paruchuri

Scroll to top in peer and staff grading, preserve line breaks in submissions

parent be3291ee
......@@ -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
......
......@@ -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)
......@@ -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","<br/>")
}
def update_score(self, data, system):
......
......@@ -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'</p>$', '', re.sub(r'^<p>', '', clean_html))
clean_html = re.sub("\n","<br/>", clean_html)
except Exception:
clean_html = answer
return clean_html
......
......@@ -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","<br/>")
}
def save_assessment(self, data, _system):
......
......@@ -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...
......
......@@ -38,6 +38,7 @@
<!-- Grading View -->
<section class="prompt-wrapper">
<div class="grading-message"></div>
<h2 class="prompt-name">
</h2>
<div class="meta-info-wrapper">
......@@ -80,8 +81,9 @@
<input type="button" value="${_("Submit")}" class="submit-button" name="show"/>
<input type="button" value="${_("Skip")}" class="skip-button" name="skip"/>
</div>
<div class="grading-message"></div>
</div>
</section>
</div>
\ No newline at end of file
</div>
</section>
......@@ -9,7 +9,7 @@
% if success:
% if len(problem_list) == 0:
<div class="message-container">
${_("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.")}
</div>
%else:
<div class="problem-list-container">
......
......@@ -27,6 +27,8 @@
</div>
</div>
<section class="grading-wrapper">
<div class="grading-message">
</div>
<h2>${_("Student Response")}</h2>
<div class="grading-container">
<div class="submission-wrapper">
......@@ -53,8 +55,6 @@
<input type="button" value="${_("Submit")}" class="submit-button" name="show"/>
</div>
</div>
<div class="grading-message">
</div>
</section>
</section>
<!-- Calibration feedback: Shown after a calibration is sent -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment