Commit 6c9c411b by Bridger Maxwell

Errors in certificate request or survey are now scrolled into view.

parent ec0fba04
...@@ -124,6 +124,20 @@ $(function() { ...@@ -124,6 +124,20 @@ $(function() {
}); });
%if settings.END_COURSE_ENABLED: %if settings.END_COURSE_ENABLED:
//This is used to scroll error divs to the user's attention. It can be removed when we switch to the branch with jQuery.ScrollTo
jQuery.fn.scrollMinimal = function(smooth) {
var cTop = this.offset().top;
var cHeight = this.outerHeight(true);
var windowTop = $(window).scrollTop();
var visibleHeight = $(window).height();
if (cTop < windowTop) {
$('body').animate({'scrollTop': cTop}, 'slow', 'swing');
} else if (cTop + cHeight > windowTop + visibleHeight) {
$('body').animate({'scrollTop': cTop - visibleHeight + cHeight}, 'slow', 'swing');
}
};
/* /*
There is a fieldset, #survey_fieldset, which contains an exit survey. This exist survey can be taken by iteself, There is a fieldset, #survey_fieldset, which contains an exit survey. This exist survey can be taken by iteself,
or as part of the certificate request. If they haven't taken the survey yet, it moves to the open modal dialogue. or as part of the certificate request. If they haven't taken the survey yet, it moves to the open modal dialogue.
...@@ -161,7 +175,7 @@ $(function() { ...@@ -161,7 +175,7 @@ $(function() {
$("#cert_request").html("<h1>Certificate Request Received</h1><p>Thank you! A certificate is being generated. You will be notified when it is ready to download.</p>"); $("#cert_request").html("<h1>Certificate Request Received</h1><p>Thank you! A certificate is being generated. You will be notified when it is ready to download.</p>");
$(".cert_request_link").text("Certificate is being generated..."); $(".cert_request_link").text("Certificate is being generated...");
} else { } else {
$("#cert_request_error").html(data.error); $("#cert_request_error").html(data.error).scrollMinimal();
} }
}); });
log_event("certificate_request", values); log_event("certificate_request", values);
...@@ -201,7 +215,7 @@ $(function() { ...@@ -201,7 +215,7 @@ $(function() {
//Remove the links to take the survey //Remove the links to take the survey
$(".survey_offer").hide(); $(".survey_offer").hide();
} else { } else {
$("#survey_error").html(data.error); $("#survey_error").html(data.error).scrollMinimal();
} }
}); });
log_event("exit_survey_submission", values); log_event("exit_survey_submission", values);
...@@ -228,15 +242,9 @@ $(function() { ...@@ -228,15 +242,9 @@ $(function() {
<div id="grade"> <div id="grade">
%if grade_sheet['grade']: %if grade_sheet['grade']:
<p>Final Grade: <strong>${grade_sheet['grade']}</strong></p> <p>Final Grade: <strong>${grade_sheet['grade']}</strong></p>
%if not certificate_requested: %if not certificate_requested:
<a rel="leanModal" class="cert_request_link" href="#cert_request">Request Certificate</a> <a rel="leanModal" class="cert_request_link" href="#cert_request">Request Certificate</a>
%if not took_survey:
<div class="survey_offer">
<a class="survey_link" rel="leanModal" href="#survey">Take the survey</a>.
</div>
%endif
%elif certificate_download_url: %elif certificate_download_url:
<a href="${certificate_download_url}" target="_blank">Download Certificate</a> <a href="${certificate_download_url}" target="_blank">Download Certificate</a>
%else: %else:
...@@ -245,6 +253,12 @@ $(function() { ...@@ -245,6 +253,12 @@ $(function() {
%else: %else:
<p> No letter grade has been earned for this course </p> <p> No letter grade has been earned for this course </p>
%endif %endif
%if not took_survey:
<div class="survey_offer">
<a class="survey_link" rel="leanModal" href="#survey">Take the survey</a>.
</div>
%endif
</div> </div>
%endif %endif
...@@ -461,7 +475,7 @@ $(function() { ...@@ -461,7 +475,7 @@ $(function() {
<form id="survey_form"> <form id="survey_form">
<div id="survey_survey_holder"> <div id="survey_survey_holder">
<fieldset id="survey_fieldset"> <fieldset id="survey_fieldset">
<h1>Please take this short survey about 6.002x.</h1> <h1>Please take this optional survey about 6.002x.</h1>
<p>This survey is collected only for research purposes. It is completely optional and will not affect your grade.</p> <p>This survey is collected only for research purposes. It is completely optional and will not affect your grade.</p>
<div id="survey_error"> </div> <div id="survey_error"> </div>
......
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