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 @@
<i class="fa fa-arrow-circle-right"></i>
</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>
<a>
{% trans "No, I want to take this exam without proctoring (and not be eligible for credit)" %}
......@@ -41,72 +41,122 @@
<i class="fa fa-arrow-circle-right"></i>
</button>
</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' %}
<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 disableClickEvent = function () {
var disableClickEvent = function (selector) {
inProcess = true;
$('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;
$('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) {
disableClickEvent();
var action_url = $(this).data('ajax-url');
var exam_id = $(this).data('exam-id');
disableClickEvent($(this));
var attempt_proctored = $(this).data('attempt-proctored');
var start_immediately = $(this).data('start-immediately');
if (!attempt_proctored) {
var msg = gettext(
"Are you sure you want to take this exam without proctoring? " +
"You will no longer be eligible to use this course for academic credit."
);
if (!confirm(msg)) {
enableClickEvent();
return;
}
}
if (typeof action_url === "undefined") {
enableClickEvent();
return false;
enableClickEvent($(this));
$(".proctored-exam.entrance").addClass('hidden');
$(".proctored-exam-skip-confirm-wrapper").removeClass('hidden');
} else {
var action_url = $(this).data('ajax-url');
var exam_id = $(this).data('exam-id');
var start_immediately = $(this).data('start-immediately');
startProctoredExam($(this), exam_id, action_url, start_immediately, attempt_proctored);
}
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 {
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>
......@@ -2,7 +2,7 @@
# pylint: disable=too-many-lines, invalid-name
"""
All tests for the models.py
All tests for the api.py
"""
import ddt
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