Commit 3724d1e1 by Muhammad Shoaib

Merge pull request #119 from edx/muhhshoaib/PHX-120-updated-the-dialog-box-for-open-exams-options

PHX-120
parents 86961f26 efe87a21
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<i class="fa fa-arrow-circle-right"></i> <i class="fa fa-arrow-circle-right"></i>
</button> </button>
<button class="gated-sequence start-timed-exam" data-ajax-url="{{enter_exam_endpoint}}" data-exam-id="{{exam_id}}" data-attempt-proctored=false data-start-immediately=true> <button class="gated-sequence start-timed-exam" data-attempt-proctored=false>
<span><i class="fa fa-unlock"></i></span> <span><i class="fa fa-unlock"></i></span>
<a> <a>
{% trans "No, I want to take this exam without proctoring (and not be eligible for credit)" %} {% trans "No, I want to take this exam without proctoring (and not be eligible for credit)" %}
...@@ -41,72 +41,122 @@ ...@@ -41,72 +41,122 @@
<i class="fa fa-arrow-circle-right"></i> <i class="fa fa-arrow-circle-right"></i>
</button> </button>
</div> </div>
<div class="proctored-exam-skip-confirm-wrapper hidden">
<div class="proctored-exam-skip-confirm">
<div class="msg-title">
{% blocktrans %}
Are you sure you want to take this exam without proctoring?
{% endblocktrans %}
</div>
<div class="msg-content">
{% blocktrans %}
You will no longer be eligible to use this course for academic credit.
{% endblocktrans %}
</div>
<div class="proctored-exam-skip-actions">
<button class="proctored-exam-skip-cancel-button btn btn-default btn-base">
{% trans "Cancel" %}
</button>
<button class="proctored-exam-skip-confirm-button btn btn-primary btn-base" data-ajax-url="{{enter_exam_endpoint}}" data-exam-id="{{exam_id}}">
{% trans "Yes, Take this as an open exam" %}
</button>
</div>
<div class="clearfix"></div>
</div>
</div>
{% include 'proctoring/seq_proctored_exam_footer.html' %} {% include 'proctoring/seq_proctored_exam_footer.html' %}
<script type="text/javascript"> <script type="text/javascript">
var startProctoredExam = function(selector, exam_id, action_url, start_immediately, attempt_proctored) {
$.post(
action_url,
{
"exam_id": exam_id,
"attempt_proctored": attempt_proctored,
"start_clock": start_immediately
},
function(data) {
// reload the page, because we've unlocked it
location.reload();
}
).fail(function(){
enableClickEvent(selector);
var msg = gettext(
"There has been a problem starting your exam.\n\n" +
"Possible reasons are that your account has not been fully activated,\n" +
"you have are experiencing a network connection problem, or there has been\n" +
"a service disruption. Please check these and try again."
);
alert(msg);
});
};
var inProcess = false; var inProcess = false;
var disableClickEvent = function () { var disableClickEvent = function (selector) {
inProcess = true; inProcess = true;
$('body').css('cursor', 'wait'); $('body').css('cursor', 'wait');
$('.start-timed-exam').css('cursor', 'wait');
selector.each(function() {
$( this ).css('cursor', 'wait');
});
}; };
var enableClickEvent = function () { var enableClickEvent = function (selector) {
inProcess = false; inProcess = false;
$('body').css('cursor', 'auto'); $('body').css('cursor', 'auto');
$('.start-timed-exam').css('cursor', 'auto'); selector.each(function() {
$( this ).css('cursor', 'pointer');
});
}; };
$('.start-timed-exam').click(function () { $('.start-timed-exam').click(
function() {
if (!inProcess) { if (!inProcess) {
disableClickEvent(); disableClickEvent($(this));
var action_url = $(this).data('ajax-url');
var exam_id = $(this).data('exam-id');
var attempt_proctored = $(this).data('attempt-proctored'); var attempt_proctored = $(this).data('attempt-proctored');
var start_immediately = $(this).data('start-immediately');
if (!attempt_proctored) { if (!attempt_proctored) {
var msg = gettext( enableClickEvent($(this));
"Are you sure you want to take this exam without proctoring? " + $(".proctored-exam.entrance").addClass('hidden');
"You will no longer be eligible to use this course for academic credit." $(".proctored-exam-skip-confirm-wrapper").removeClass('hidden');
); } else {
if (!confirm(msg)) { var action_url = $(this).data('ajax-url');
enableClickEvent(); var exam_id = $(this).data('exam-id');
return; var start_immediately = $(this).data('start-immediately');
} startProctoredExam($(this), exam_id, action_url, start_immediately, attempt_proctored);
}
if (typeof action_url === "undefined") {
enableClickEvent();
return false;
} }
var self = $(this);
$.post(
action_url,
{
"exam_id": exam_id,
"attempt_proctored": attempt_proctored,
"start_clock": start_immediately
},
function (data) {
// reload the page, because we've unlocked it
location.reload();
}
).fail(function(){
enableClickEvent();
var msg = gettext(
"There has been a problem starting your exam.\n\n" +
"Possible reasons are that your account has not been fully activated,\n" +
"you have are experiencing a network connection problem, or there has been\n" +
"a service disruption. Please check these and try again."
);
alert(msg);
});
} else { } else {
return false; return false;
} }
} }
); );
$('.proctored-exam-skip-confirm-button').click(
function(event){
if (!inProcess) {
// find the all the buttons and call disableClickEvent
// on the events
var events = $(this).parent().find('button');
disableClickEvent(events);
var action_url = $(this).data('ajax-url');
var exam_id = $(this).data('exam-id');
startProctoredExam(events, exam_id, action_url, true, false);
} else {
return false
}
}
);
$('.proctored-exam-skip-cancel-button').click(
function(event){
if (!inProcess) {
enableClickEvent($(this));
$(".proctored-exam.entrance").removeClass('hidden');
$(".proctored-exam-skip-confirm-wrapper").addClass('hidden');
} else {
return false;
}
}
)
</script> </script>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# pylint: disable=too-many-lines, invalid-name # pylint: disable=too-many-lines, invalid-name
""" """
All tests for the models.py All tests for the api.py
""" """
import ddt import ddt
from datetime import datetime, timedelta from datetime import datetime, timedelta
......
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