Completed client side time adjustment handling

Corrected error display bug
Removed redundant auth and models in quiz client app
This commit is contained in:
2021-12-04 17:14:28 +00:00
parent cfdb4db0c3
commit d8e7bf6ae8
12 changed files with 64 additions and 54 deletions

View File

@ -163,6 +163,18 @@ $("#btn-start-quiz").click(function(event){
time_remaining = get_time_remaining();
clock = setInterval(timer, 1000);
}
if (response.time_adjustment > 0) {
const $alert = $("#alert-box");
$alert.html(
`<div class="alert alert-primary alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle-fill" title="Alert"></i>
User code validated. Extra time of ${response.time_adjustment} minutes added to the exam time limit.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`
);
$alert.focus();
}
},
error: function(response) {
error_response(response);
@ -507,7 +519,7 @@ function timer() {
if (time_remaining > 0) {
var timer_display = '';
if (hours > 0) {
timer_display = `${hours.toString()}: `;
timer_display = `${hours.toString()}:`;
}
if (minutes > 0 || hours > 0) {
if (minutes < 10) {

View File

@ -37,11 +37,11 @@ $('form[name=form-quiz-start]').submit(function(event) {
function error_response(response) {
var alert = $("#alert-box");
alert.html('');
const $alert = $("#alert-box");
$alert.html('');
if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
alert.html(`
$alert.html(`
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
${response.responseJSON.error}
@ -49,14 +49,16 @@ function error_response(response) {
</div>
`);
} else if (response.responseJSON.error instanceof Array) {
var output = ''
for (var i = 0; i < response.responseJSON.error.length; i ++) {
alert.html(`
output += `
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
${response.responseJSON.error[i]}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`);
`;
$alert.html(output);
}
}
}