Code clean up: redundant semicolons
Made variable declaration style in for loops consistent
This commit is contained in:
		@@ -1,25 +1,25 @@
 | 
				
			|||||||
// Menu Highlight Scripts
 | 
					// Menu Highlight Scripts
 | 
				
			||||||
const menuItems = document.getElementsByClassName('nav-link');
 | 
					const menuItems = document.getElementsByClassName('nav-link')
 | 
				
			||||||
for(let i = 0; i < menuItems.length; i++) {
 | 
					for(let i = 0; i < menuItems.length; i++) {
 | 
				
			||||||
    if(menuItems[i].pathname == window.location.pathname) {
 | 
					    if(menuItems[i].pathname == window.location.pathname) {
 | 
				
			||||||
        menuItems[i].classList.add('active');
 | 
					        menuItems[i].classList.add('active')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
const dropdownItems = document.getElementsByClassName('dropdown-item');
 | 
					const dropdownItems = document.getElementsByClassName('dropdown-item')
 | 
				
			||||||
for(let i = 0; i< dropdownItems.length; i++) {
 | 
					for(let i = 0; i< dropdownItems.length; i++) {
 | 
				
			||||||
    if(dropdownItems[i].pathname == window.location.pathname) {
 | 
					    if(dropdownItems[i].pathname == window.location.pathname) {
 | 
				
			||||||
        dropdownItems[i].classList.add('active');
 | 
					        dropdownItems[i].classList.add('active')
 | 
				
			||||||
        $( "#" + dropdownItems[i].id ).closest( '.dropdown' ).find('.dropdown-toggle').addClass('active');
 | 
					        $( "#" + dropdownItems[i].id ).closest( '.dropdown' ).find('.dropdown-toggle').addClass('active')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// General Post Method Form Processing Script
 | 
					// General Post Method Form Processing Script
 | 
				
			||||||
$('form.form-post').submit(function(event) {
 | 
					$('form.form-post').submit(function(event) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var $form = $(this);
 | 
					    var $form = $(this)
 | 
				
			||||||
    var data = $form.serialize();
 | 
					    var data = $form.serialize()
 | 
				
			||||||
    var url = $(this).prop('action');
 | 
					    var url = $(this).prop('action')
 | 
				
			||||||
    var rel_success = $(this).data('rel-success');
 | 
					    var rel_success = $(this).data('rel-success')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $.ajax({
 | 
					    $.ajax({
 | 
				
			||||||
        url: url,
 | 
					        url: url,
 | 
				
			||||||
@@ -28,25 +28,25 @@ $('form.form-post').submit(function(event) {
 | 
				
			|||||||
        dataType: 'json',
 | 
					        dataType: 'json',
 | 
				
			||||||
        success: function(response) {
 | 
					        success: function(response) {
 | 
				
			||||||
            if (response.redirect_to) {
 | 
					            if (response.redirect_to) {
 | 
				
			||||||
                window.location.href = response.redirect_to;
 | 
					                window.location.href = response.redirect_to
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                window.location.href = rel_success;
 | 
					                window.location.href = rel_success
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response) {
 | 
					        error: function(response) {
 | 
				
			||||||
            error_response(response);
 | 
					            error_response(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Form Upload Questions - Special case, needs to handle files.
 | 
					// Form Upload Questions - Special case, needs to handle files.
 | 
				
			||||||
$('form[name=form-upload-questions]').submit(function(event) {
 | 
					$('form[name=form-upload-questions]').submit(function(event) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var $form = $(this);
 | 
					    var $form = $(this)
 | 
				
			||||||
    var data = new FormData($form[0]);
 | 
					    var data = new FormData($form[0])
 | 
				
			||||||
    var file = $('input[name=data_file]')[0].files[0]
 | 
					    var file = $('input[name=data_file]')[0].files[0]
 | 
				
			||||||
    data.append('file', file)
 | 
					    data.append('file', file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -57,21 +57,21 @@ $('form[name=form-upload-questions]').submit(function(event) {
 | 
				
			|||||||
        processData: false,
 | 
					        processData: false,
 | 
				
			||||||
        contentType: false,
 | 
					        contentType: false,
 | 
				
			||||||
        success: function(response) {
 | 
					        success: function(response) {
 | 
				
			||||||
            window.location.reload();
 | 
					            window.location.reload()
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response) {
 | 
					        error: function(response) {
 | 
				
			||||||
            error_response(response);
 | 
					            error_response(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Edit and Delete Test Button Handlers
 | 
					// Edit and Delete Test Button Handlers
 | 
				
			||||||
$('.test-action').click(function(event) {
 | 
					$('.test-action').click(function(event) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    let id = $(this).data('id');
 | 
					    let id = $(this).data('id')
 | 
				
			||||||
    let action = $(this).data('action');
 | 
					    let action = $(this).data('action')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (action == 'delete' || action == 'start' || action == 'end') {
 | 
					    if (action == 'delete' || action == 'start' || action == 'end') {
 | 
				
			||||||
        $.ajax({
 | 
					        $.ajax({
 | 
				
			||||||
@@ -80,25 +80,25 @@ $('.test-action').click(function(event) {
 | 
				
			|||||||
            data: JSON.stringify({'id': id, 'action': action}),
 | 
					            data: JSON.stringify({'id': id, 'action': action}),
 | 
				
			||||||
            contentType: 'application/json',
 | 
					            contentType: 'application/json',
 | 
				
			||||||
            success: function(response) {
 | 
					            success: function(response) {
 | 
				
			||||||
                window.location.href = '/admin/tests/';
 | 
					                window.location.href = '/admin/tests/'
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            error: function(response){
 | 
					            error: function(response){
 | 
				
			||||||
                error_response(response);
 | 
					                error_response(response)
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        });
 | 
					        })
 | 
				
			||||||
    } else if (action == 'edit') {
 | 
					    } else if (action == 'edit') {
 | 
				
			||||||
        window.location.href = `/admin/test/${id}/`
 | 
					        window.location.href = `/admin/test/${id}/`
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Edit Dataset Button Handlers
 | 
					// Edit Dataset Button Handlers
 | 
				
			||||||
$('.edit-question-dataset').click(function(event) {
 | 
					$('.edit-question-dataset').click(function(event) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var id = $(this).data('id');
 | 
					    var id = $(this).data('id')
 | 
				
			||||||
    var action = $(this).data('action');
 | 
					    var action = $(this).data('action')
 | 
				
			||||||
    var disabled = $(this).hasClass('disabled');
 | 
					    var disabled = $(this).hasClass('disabled')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ( !disabled ) {
 | 
					    if ( !disabled ) {
 | 
				
			||||||
        if (action == 'delete') {
 | 
					        if (action == 'delete') {
 | 
				
			||||||
@@ -111,25 +111,27 @@ $('.edit-question-dataset').click(function(event) {
 | 
				
			|||||||
                }),
 | 
					                }),
 | 
				
			||||||
                contentType: 'application/json',
 | 
					                contentType: 'application/json',
 | 
				
			||||||
                success: function(response) {
 | 
					                success: function(response) {
 | 
				
			||||||
                    window.location.reload();
 | 
					                    window.location.reload()
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                error: function(response){
 | 
					                error: function(response){
 | 
				
			||||||
                    error_response(response);
 | 
					                    error_response(response)
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            });
 | 
					            })
 | 
				
			||||||
        } else if (action == 'edit') {
 | 
					        } else if (action == 'edit') {
 | 
				
			||||||
            window.location.href = `/admin/editor/${id}/`
 | 
					            window.location.href = `/admin/editor/${id}/`
 | 
				
			||||||
 | 
					        } else if (action == 'view') {
 | 
				
			||||||
 | 
					            window.location.href = `/admin/view/${id}`
 | 
				
			||||||
        } else if (action == 'download') {
 | 
					        } else if (action == 'download') {
 | 
				
			||||||
            window.location.href = `/admin/settings/questions/download/${id}/`
 | 
					            window.location.href = `/admin/settings/questions/download/${id}/`
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function error_response(response) {
 | 
					function error_response(response) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const $alert = $("#alert-box");
 | 
					    const $alert = $("#alert-box")
 | 
				
			||||||
    $alert.html('');
 | 
					    $alert.html('')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
					    if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
				
			||||||
        $alert.html(`
 | 
					        $alert.html(`
 | 
				
			||||||
@@ -138,18 +140,18 @@ function error_response(response) {
 | 
				
			|||||||
            ${response.responseJSON.error}
 | 
					            ${response.responseJSON.error}
 | 
				
			||||||
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
					            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        `);
 | 
					        `)
 | 
				
			||||||
    } else if (response.responseJSON.error instanceof Array) {
 | 
					    } else if (response.responseJSON.error instanceof Array) {
 | 
				
			||||||
        var output = ''
 | 
					        var output = ''
 | 
				
			||||||
        for (var i = 0; i < response.responseJSON.error.length; i ++) {
 | 
					        for (let i = 0; i < response.responseJSON.error.length; i ++) {
 | 
				
			||||||
            output += `
 | 
					            output += `
 | 
				
			||||||
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
					            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
				
			||||||
                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
					                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
				
			||||||
                ${response.responseJSON.error[i]}
 | 
					                ${response.responseJSON.error[i]}
 | 
				
			||||||
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
					                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            `;
 | 
					            `
 | 
				
			||||||
            $alert.html(output);
 | 
					            $alert.html(output)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -167,20 +169,20 @@ $('#dismiss-cookie-alert').click(function(event){
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        dataType: 'json',
 | 
					        dataType: 'json',
 | 
				
			||||||
        success: function(response){
 | 
					        success: function(response){
 | 
				
			||||||
            console.log(response);
 | 
					            console.log(response)
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response){
 | 
					        error: function(response){
 | 
				
			||||||
            console.log(response);
 | 
					            console.log(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Script for Result Actions
 | 
					// Script for Result Actions
 | 
				
			||||||
$('.result-action-buttons').click(function(event){
 | 
					$('.result-action-buttons').click(function(event){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var id = $(this).data('id');
 | 
					    var id = $(this).data('id')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ($(this).data('result-action') == 'generate') {
 | 
					    if ($(this).data('result-action') == 'generate') {
 | 
				
			||||||
        $.ajax({
 | 
					        $.ajax({
 | 
				
			||||||
@@ -190,13 +192,13 @@ $('.result-action-buttons').click(function(event){
 | 
				
			|||||||
            contentType: 'application/json',
 | 
					            contentType: 'application/json',
 | 
				
			||||||
            dataType: 'html',
 | 
					            dataType: 'html',
 | 
				
			||||||
            success: function(response) {
 | 
					            success: function(response) {
 | 
				
			||||||
                var display_window = window.open();
 | 
					                var display_window = window.open()
 | 
				
			||||||
                display_window.document.write(response);
 | 
					                display_window.document.write(response)
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            error: function(response){
 | 
					            error: function(response){
 | 
				
			||||||
                error_response(response);
 | 
					                error_response(response)
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        });
 | 
					        })
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        var action = $(this).data('result-action')
 | 
					        var action = $(this).data('result-action')
 | 
				
			||||||
        $.ajax({
 | 
					        $.ajax({
 | 
				
			||||||
@@ -206,23 +208,23 @@ $('.result-action-buttons').click(function(event){
 | 
				
			|||||||
            contentType: 'application/json',
 | 
					            contentType: 'application/json',
 | 
				
			||||||
            success: function(response) {
 | 
					            success: function(response) {
 | 
				
			||||||
                if (action == 'delete') {
 | 
					                if (action == 'delete') {
 | 
				
			||||||
                    window.location.href = '/admin/results/';
 | 
					                    window.location.href = '/admin/results/'
 | 
				
			||||||
                } else window.location.reload();
 | 
					                } else window.location.reload()
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            error: function(response){
 | 
					            error: function(response){
 | 
				
			||||||
                error_response(response);
 | 
					                error_response(response)
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        });
 | 
					        })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Script for Deleting Time Adjustment
 | 
					// Script for Deleting Time Adjustment
 | 
				
			||||||
$('.adjustment-delete').click(function(event){
 | 
					$('.adjustment-delete').click(function(event){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var user_code = $(this).data('user_code');
 | 
					    var user_code = $(this).data('user_code')
 | 
				
			||||||
    var location = window.location.href;
 | 
					    var location = window.location.href
 | 
				
			||||||
    location = location.replace('#', '')
 | 
					    location = location.replace('#', '')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $.ajax({
 | 
					    $.ajax({
 | 
				
			||||||
@@ -231,12 +233,15 @@ $('.adjustment-delete').click(function(event){
 | 
				
			|||||||
        data: JSON.stringify({'user_code': user_code}),
 | 
					        data: JSON.stringify({'user_code': user_code}),
 | 
				
			||||||
        contentType: 'application/json',
 | 
					        contentType: 'application/json',
 | 
				
			||||||
        success: function(response) {
 | 
					        success: function(response) {
 | 
				
			||||||
            window.location.reload();
 | 
					            window.location.reload()
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response){
 | 
					        error: function(response){
 | 
				
			||||||
            error_response(response);
 | 
					            error_response(response)
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    event.preventDefault()
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
@@ -57,7 +57,7 @@ function error_response(response) {
 | 
				
			|||||||
        `);
 | 
					        `);
 | 
				
			||||||
    } else if (response.responseJSON.error instanceof Array) {
 | 
					    } else if (response.responseJSON.error instanceof Array) {
 | 
				
			||||||
        var output = ''
 | 
					        var output = ''
 | 
				
			||||||
        for (var i = 0; i < response.responseJSON.error.length; i ++) {
 | 
					        for (let i = 0; i < response.responseJSON.error.length; i ++) {
 | 
				
			||||||
            output += `
 | 
					            output += `
 | 
				
			||||||
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
					            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
				
			||||||
                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
					                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,142 +1,142 @@
 | 
				
			|||||||
// Bind Listeners
 | 
					// Bind Listeners
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("input[name='font-select']").change(function(){
 | 
					$("input[name='font-select']").change(function(){
 | 
				
			||||||
    let $choice = $(this).val();
 | 
					    let $choice = $(this).val()
 | 
				
			||||||
    set_font($choice);
 | 
					    set_font($choice)
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("input[name='font-size']").change(function(){
 | 
					$("input[name='font-size']").change(function(){
 | 
				
			||||||
    let $choice = $(this).val();
 | 
					    let $choice = $(this).val()
 | 
				
			||||||
    set_font_size($choice);
 | 
					    set_font_size($choice)
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("input[name='bg-select']").change(function(){
 | 
					$("input[name='bg-select']").change(function(){
 | 
				
			||||||
    let $choice = $(this).val();
 | 
					    let $choice = $(this).val()
 | 
				
			||||||
    set_bg_colour($choice);
 | 
					    set_bg_colour($choice)
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(".bg-select-area").click(function(event){
 | 
					$(".bg-select-area").click(function(event){
 | 
				
			||||||
    $(this).find("input[name='bg-select']").prop("checked", true).change();
 | 
					    $(this).find("input[name='bg-select']").prop("checked", true).change()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#btn-toggle-navigator").click(function(event){
 | 
					$("#btn-toggle-navigator").click(function(event){
 | 
				
			||||||
    check_answered();
 | 
					    check_answered()
 | 
				
			||||||
    update_navigator();
 | 
					    update_navigator()
 | 
				
			||||||
    if ($quiz_navigator.is(":hidden")) {
 | 
					    if ($quiz_navigator.is(":hidden")) {
 | 
				
			||||||
        if ($quiz_settings.is(":visible")) {
 | 
					        if ($quiz_settings.is(":visible")) {
 | 
				
			||||||
            toggle_settings = true;
 | 
					            toggle_settings = true
 | 
				
			||||||
            $quiz_settings.fadeOut();
 | 
					            $quiz_settings.fadeOut()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $quiz_render.fadeOut();
 | 
					        $quiz_render.fadeOut()
 | 
				
			||||||
        $quiz_navigator.fadeIn();
 | 
					        $quiz_navigator.fadeIn()
 | 
				
			||||||
        $(".navigator-text").fadeIn();
 | 
					        $(".navigator-text").fadeIn()
 | 
				
			||||||
        $(".review-text").fadeOut();
 | 
					        $(".review-text").fadeOut()
 | 
				
			||||||
        toggle_navigator = false;
 | 
					        toggle_navigator = false
 | 
				
			||||||
        $(window).scrollTop(0);
 | 
					        $(window).scrollTop(0)
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $quiz_navigator.fadeOut();
 | 
					        $quiz_navigator.fadeOut()
 | 
				
			||||||
        if (toggle_settings) {
 | 
					        if (toggle_settings) {
 | 
				
			||||||
            $quiz_settings.fadeIn();
 | 
					            $quiz_settings.fadeIn()
 | 
				
			||||||
            $(window).scrollTop(0);
 | 
					            $(window).scrollTop(0)
 | 
				
			||||||
            toggle_settings = false;
 | 
					            toggle_settings = false
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $quiz_render.fadeIn();
 | 
					            $quiz_render.fadeIn()
 | 
				
			||||||
            $(window).scrollTop(0);
 | 
					            $(window).scrollTop(0)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#btn-toggle-settings").click(function(event){
 | 
					$("#btn-toggle-settings").click(function(event){
 | 
				
			||||||
    if (($quiz_settings).is(":hidden")) {
 | 
					    if (($quiz_settings).is(":hidden")) {
 | 
				
			||||||
        if ($quiz_navigator.is(":visible")) {
 | 
					        if ($quiz_navigator.is(":visible")) {
 | 
				
			||||||
            toggle_navigator = true;
 | 
					            toggle_navigator = true
 | 
				
			||||||
            $quiz_navigator.fadeOut();
 | 
					            $quiz_navigator.fadeOut()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $quiz_render.fadeOut();
 | 
					        $quiz_render.fadeOut()
 | 
				
			||||||
        $quiz_settings.fadeIn();
 | 
					        $quiz_settings.fadeIn()
 | 
				
			||||||
        $(window).scrollTop(0);
 | 
					        $(window).scrollTop(0)
 | 
				
			||||||
        toggle_settings = false;
 | 
					        toggle_settings = false
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $quiz_settings.fadeOut();
 | 
					        $quiz_settings.fadeOut()
 | 
				
			||||||
        if (toggle_navigator) {
 | 
					        if (toggle_navigator) {
 | 
				
			||||||
            $quiz_navigator.fadeIn();
 | 
					            $quiz_navigator.fadeIn()
 | 
				
			||||||
            toggle_navigator = false;
 | 
					            toggle_navigator = false
 | 
				
			||||||
            $(window).scrollTop(0);
 | 
					            $(window).scrollTop(0)
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $quiz_render.fadeIn();
 | 
					            $quiz_render.fadeIn()
 | 
				
			||||||
            $(window).scrollTop(0);
 | 
					            $(window).scrollTop(0)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(".btn-quiz-return").click(function(event){
 | 
					$(".btn-quiz-return").click(function(event){
 | 
				
			||||||
    $quiz_navigator.fadeOut();
 | 
					    $quiz_navigator.fadeOut()
 | 
				
			||||||
    $quiz_settings.fadeOut();
 | 
					    $quiz_settings.fadeOut()
 | 
				
			||||||
    $quiz_render.fadeIn();
 | 
					    $quiz_render.fadeIn()
 | 
				
			||||||
    $(window).scrollTop(0);
 | 
					    $(window).scrollTop(0)
 | 
				
			||||||
    toggle_settings = false;
 | 
					    toggle_settings = false
 | 
				
			||||||
    toggle_navigator = false;
 | 
					    toggle_navigator = false
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(".btn-dummy").click(function(event){
 | 
					$(".btn-dummy").click(function(event){
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#navigator-container").on("click", ".q-navigator-button", function(event){
 | 
					$("#navigator-container").on("click", ".q-navigator-button", function(event){
 | 
				
			||||||
    check_answered();
 | 
					    check_answered()
 | 
				
			||||||
    update_navigator();
 | 
					    update_navigator()
 | 
				
			||||||
    current_question = parseInt($(this).prop("name"));
 | 
					    current_question = parseInt($(this).prop("name"))
 | 
				
			||||||
    $quiz_navigator.fadeOut();
 | 
					    $quiz_navigator.fadeOut()
 | 
				
			||||||
    $quiz_render.fadeIn();
 | 
					    $quiz_render.fadeIn()
 | 
				
			||||||
    $question_title.focus();
 | 
					    $question_title.focus()
 | 
				
			||||||
    $(window).scrollTop(0);
 | 
					    $(window).scrollTop(0)
 | 
				
			||||||
    toggle_navigator = false;
 | 
					    toggle_navigator = false
 | 
				
			||||||
    toggle_settings = false;
 | 
					    toggle_settings = false
 | 
				
			||||||
    render_question();
 | 
					    render_question()
 | 
				
			||||||
    check_flag();
 | 
					    check_flag()
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(".q-question-nav").click(function(event){
 | 
					$(".q-question-nav").click(function(event){
 | 
				
			||||||
    check_answered();
 | 
					    check_answered()
 | 
				
			||||||
    update_navigator();
 | 
					    update_navigator()
 | 
				
			||||||
    if ($(this).prop("id") == "q-nav-next") {
 | 
					    if ($(this).prop("id") == "q-nav-next") {
 | 
				
			||||||
        if (current_question < questions.length) {
 | 
					        if (current_question < questions.length) {
 | 
				
			||||||
            current_question ++;
 | 
					            current_question ++
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else if ($(this).prop("id") == "q-nav-prev") {
 | 
					    } else if ($(this).prop("id") == "q-nav-prev") {
 | 
				
			||||||
        if (current_question > 0) {
 | 
					        if (current_question > 0) {
 | 
				
			||||||
            current_question --;
 | 
					            current_question --
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else if ($(this).hasClass("q-navigator-button")) {
 | 
					    } else if ($(this).hasClass("q-navigator-button")) {
 | 
				
			||||||
        current_question = $(this).prop("name");
 | 
					        current_question = $(this).prop("name")
 | 
				
			||||||
        $quiz_render.fadeIn();
 | 
					        $quiz_render.fadeIn()
 | 
				
			||||||
        $quiz_navigator.fadeOut();
 | 
					        $quiz_navigator.fadeOut()
 | 
				
			||||||
        toggle_navigator = false;
 | 
					        toggle_navigator = false
 | 
				
			||||||
        toggle_settings = false;
 | 
					        toggle_settings = false
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    render_question();
 | 
					    render_question()
 | 
				
			||||||
    check_flag();
 | 
					    check_flag()
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#q-nav-flag").click(function(event){
 | 
					$("#q-nav-flag").click(function(event){
 | 
				
			||||||
    if (question_status[current_question] != 1) {
 | 
					    if (question_status[current_question] != 1) {
 | 
				
			||||||
        question_status[current_question] = 1;
 | 
					        question_status[current_question] = 1
 | 
				
			||||||
        $(this).removeClass().addClass("btn btn-warning");
 | 
					        $(this).removeClass().addClass("btn btn-warning")
 | 
				
			||||||
        $(this).prop("title", "Question Flagged for revision. Click to un-flag.");
 | 
					        $(this).prop("title", "Question Flagged for revision. Click to un-flag.")
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        question_status[current_question] = 0;
 | 
					        question_status[current_question] = 0
 | 
				
			||||||
        $(this).removeClass().addClass("btn btn-secondary");
 | 
					        $(this).removeClass().addClass("btn btn-secondary")
 | 
				
			||||||
        $(this).prop("title", "Question Un-Flagged. Click to flag for revision.");
 | 
					        $(this).prop("title", "Question Un-Flagged. Click to flag for revision.")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    window.localStorage.setItem('question_status', JSON.stringify(question_status));
 | 
					    window.localStorage.setItem('question_status', JSON.stringify(question_status))
 | 
				
			||||||
    update_navigator();
 | 
					    update_navigator()
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#btn-start-quiz").click(function(event){
 | 
					$("#btn-start-quiz").click(function(event){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -146,29 +146,29 @@ $("#btn-start-quiz").click(function(event){
 | 
				
			|||||||
        data: JSON.stringify({'id': id}),
 | 
					        data: JSON.stringify({'id': id}),
 | 
				
			||||||
        contentType: "application/json",
 | 
					        contentType: "application/json",
 | 
				
			||||||
        success: function(response) {
 | 
					        success: function(response) {
 | 
				
			||||||
            $("#btn-start-quiz").fadeOut();
 | 
					            $("#btn-start-quiz").fadeOut()
 | 
				
			||||||
            $(".btn-quiz-return").fadeIn();
 | 
					            $(".btn-quiz-return").fadeIn()
 | 
				
			||||||
            $(".quiz-console").fadeIn();
 | 
					            $(".quiz-console").fadeIn()
 | 
				
			||||||
            $("#quiz-settings").fadeOut();
 | 
					            $("#quiz-settings").fadeOut()
 | 
				
			||||||
            $("#quiz-navigator").fadeOut();
 | 
					            $("#quiz-navigator").fadeOut()
 | 
				
			||||||
            $(".quiz-start-text").fadeOut();
 | 
					            $(".quiz-start-text").fadeOut()
 | 
				
			||||||
            time_limit = response.time_limit;
 | 
					            time_limit = response.time_limit
 | 
				
			||||||
            start_time = response.start_time;
 | 
					            start_time = response.start_time
 | 
				
			||||||
            questions = response.questions;
 | 
					            questions = response.questions
 | 
				
			||||||
            total_questions = questions.length;
 | 
					            total_questions = questions.length
 | 
				
			||||||
            window.localStorage.setItem('questions', JSON.stringify(questions));
 | 
					            window.localStorage.setItem('questions', JSON.stringify(questions))
 | 
				
			||||||
            window.localStorage.setItem('start_time', JSON.stringify(start_time));
 | 
					            window.localStorage.setItem('start_time', JSON.stringify(start_time))
 | 
				
			||||||
            window.localStorage.setItem('time_limit', JSON.stringify(time_limit));
 | 
					            window.localStorage.setItem('time_limit', JSON.stringify(time_limit))
 | 
				
			||||||
            render_question();
 | 
					            render_question()
 | 
				
			||||||
            build_navigator();
 | 
					            build_navigator()
 | 
				
			||||||
            check_flag();
 | 
					            check_flag()
 | 
				
			||||||
            if (time_limit != 'null' && time_limit != null) {
 | 
					            if (time_limit != 'null' && time_limit != null) {
 | 
				
			||||||
                $("#q-timer-widget").fadeIn();
 | 
					                $("#q-timer-widget").fadeIn()
 | 
				
			||||||
                time_remaining = get_time_remaining();
 | 
					                time_remaining = get_time_remaining()
 | 
				
			||||||
                clock = setInterval(timer, 1000);
 | 
					                clock = setInterval(timer, 1000)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (response.time_adjustment > 0) {
 | 
					            if (response.time_adjustment > 0) {
 | 
				
			||||||
                const $alert = $("#alert-box");
 | 
					                const $alert = $("#alert-box")
 | 
				
			||||||
                $alert.html(
 | 
					                $alert.html(
 | 
				
			||||||
                    `<div class="alert alert-primary alert-dismissible fade show" role="alert">
 | 
					                    `<div class="alert alert-primary alert-dismissible fade show" role="alert">
 | 
				
			||||||
                    <i class="bi bi-exclamation-triangle-fill" title="Alert"></i>
 | 
					                    <i class="bi bi-exclamation-triangle-fill" title="Alert"></i>
 | 
				
			||||||
@@ -176,50 +176,50 @@ $("#btn-start-quiz").click(function(event){
 | 
				
			|||||||
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
					                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                `
 | 
					                `
 | 
				
			||||||
                );
 | 
					                )
 | 
				
			||||||
                $alert.focus();
 | 
					                $alert.focus()
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response) {
 | 
					        error: function(response) {
 | 
				
			||||||
            error_response(response);
 | 
					            error_response(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#quiz-question-options").on("change", ".quiz-option", function(event){
 | 
					$("#quiz-question-options").on("change", ".quiz-option", function(event){
 | 
				
			||||||
    $name = parseInt($(this).prop("name"));
 | 
					    $name = parseInt($(this).prop("name"))
 | 
				
			||||||
    $value = $(this).prop("value");
 | 
					    $value = $(this).prop("value")
 | 
				
			||||||
    answers[$name] = $value;
 | 
					    answers[$name] = $value
 | 
				
			||||||
    window.localStorage.setItem('answers', JSON.stringify(answers));
 | 
					    window.localStorage.setItem('answers', JSON.stringify(answers))
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#q-review-answers").click(function(event){
 | 
					$("#q-review-answers").click(function(event){
 | 
				
			||||||
    check_answered();
 | 
					    check_answered()
 | 
				
			||||||
    update_navigator();
 | 
					    update_navigator()
 | 
				
			||||||
    if ($quiz_navigator.is(":hidden")) {
 | 
					    if ($quiz_navigator.is(":hidden")) {
 | 
				
			||||||
        if ($quiz_settings.is(":visible")) {
 | 
					        if ($quiz_settings.is(":visible")) {
 | 
				
			||||||
            toggle_settings = true;
 | 
					            toggle_settings = true
 | 
				
			||||||
            $quiz_settings.fadeOut();
 | 
					            $quiz_settings.fadeOut()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $quiz_render.fadeOut();
 | 
					        $quiz_render.fadeOut()
 | 
				
			||||||
        $quiz_navigator.fadeIn();
 | 
					        $quiz_navigator.fadeIn()
 | 
				
			||||||
        $(".navigator-text").fadeOut();
 | 
					        $(".navigator-text").fadeOut()
 | 
				
			||||||
        $(".review-text").fadeIn();
 | 
					        $(".review-text").fadeIn()
 | 
				
			||||||
        toggle_navigator = false;
 | 
					        toggle_navigator = false
 | 
				
			||||||
        $(window).scrollTop(0);
 | 
					        $(window).scrollTop(0)
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $quiz_navigator.fadeOut();
 | 
					        $quiz_navigator.fadeOut()
 | 
				
			||||||
        if (toggle_settings) {
 | 
					        if (toggle_settings) {
 | 
				
			||||||
            $quiz_settings.fadeIn();
 | 
					            $quiz_settings.fadeIn()
 | 
				
			||||||
            toggle_settings = false;
 | 
					            toggle_settings = false
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $quiz_render.fadeIn();
 | 
					            $quiz_render.fadeIn()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(".quiz-button-submit").click(function(event){
 | 
					$(".quiz-button-submit").click(function(event){
 | 
				
			||||||
    let submission = {
 | 
					    let submission = {
 | 
				
			||||||
@@ -233,16 +233,16 @@ $(".quiz-button-submit").click(function(event){
 | 
				
			|||||||
        data: JSON.stringify(submission),
 | 
					        data: JSON.stringify(submission),
 | 
				
			||||||
        contentType: "application/json",
 | 
					        contentType: "application/json",
 | 
				
			||||||
        success: function(response) {
 | 
					        success: function(response) {
 | 
				
			||||||
            window.localStorage.clear();
 | 
					            window.localStorage.clear()
 | 
				
			||||||
            window.location.href = `/result/`;
 | 
					            window.location.href = `/result/`
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response) {
 | 
					        error: function(response) {
 | 
				
			||||||
            error_response(response);
 | 
					            error_response(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Functions
 | 
					// Functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -251,17 +251,17 @@ function set_font(value = 'osdefault') {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    for (let i = 0; i < font_styles.length; i ++) {
 | 
					    for (let i = 0; i < font_styles.length; i ++) {
 | 
				
			||||||
        if (font_styles[i] != value) {
 | 
					        if (font_styles[i] != value) {
 | 
				
			||||||
            $("body").removeClass( `q-f-${font_styles[i]}` );
 | 
					            $("body").removeClass( `q-f-${font_styles[i]}` )
 | 
				
			||||||
        };
 | 
					        }
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (value != 'osdefault') {
 | 
					    if (value != 'osdefault') {
 | 
				
			||||||
        $("body").addClass(`q-f-${value}`);
 | 
					        $("body").addClass(`q-f-${value}`)
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    display_settings['font-select'] = value;
 | 
					    display_settings['font-select'] = value
 | 
				
			||||||
    window.localStorage.setItem('display_settings', JSON.stringify(display_settings));
 | 
					    window.localStorage.setItem('display_settings', JSON.stringify(display_settings))
 | 
				
			||||||
    $('input[name="font-select"][value="' + value + '"]').prop('checked', true);
 | 
					    $('input[name="font-select"][value="' + value + '"]').prop('checked', true)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function set_font_size(value = '14pt') {
 | 
					function set_font_size(value = '14pt') {
 | 
				
			||||||
@@ -269,17 +269,17 @@ function set_font_size(value = '14pt') {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    for (let i = 0; i < font_sizes.length; i ++) {
 | 
					    for (let i = 0; i < font_sizes.length; i ++) {
 | 
				
			||||||
        if (font_sizes[i] != value) {
 | 
					        if (font_sizes[i] != value) {
 | 
				
			||||||
            $("body").removeClass( `q-f-${font_sizes[i]}` );
 | 
					            $("body").removeClass( `q-f-${font_sizes[i]}` )
 | 
				
			||||||
        };
 | 
					        }
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (value != '14pt') {
 | 
					    if (value != '14pt') {
 | 
				
			||||||
        $("body").addClass(`q-f-${value}`);
 | 
					        $("body").addClass(`q-f-${value}`)
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    display_settings['font-size'] = value;
 | 
					    display_settings['font-size'] = value
 | 
				
			||||||
    window.localStorage.setItem('display_settings', JSON.stringify(display_settings));
 | 
					    window.localStorage.setItem('display_settings', JSON.stringify(display_settings))
 | 
				
			||||||
    $('input[name="font-size"][value="' + value + '"]').prop('checked', true);
 | 
					    $('input[name="font-size"][value="' + value + '"]').prop('checked', true)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function set_bg_colour(value = 'bg-light') {
 | 
					function set_bg_colour(value = 'bg-light') {
 | 
				
			||||||
@@ -287,34 +287,34 @@ function set_bg_colour(value = 'bg-light') {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    for (let i = 0; i < backgrounds.length; i ++) {
 | 
					    for (let i = 0; i < backgrounds.length; i ++) {
 | 
				
			||||||
        if (backgrounds[i] != value) {
 | 
					        if (backgrounds[i] != value) {
 | 
				
			||||||
            $("body").removeClass(backgrounds[i]);
 | 
					            $("body").removeClass(backgrounds[i])
 | 
				
			||||||
            if (backgrounds[i] == 'bg-dark') {
 | 
					            if (backgrounds[i] == 'bg-dark') {
 | 
				
			||||||
                $("body").removeClass('text-light');
 | 
					                $("body").removeClass('text-light')
 | 
				
			||||||
            };
 | 
					            }
 | 
				
			||||||
            if (backgrounds[i] == 'alert-primary' || backgrounds[i] == 'alert-secondary' || backgrounds[i] == 'alert-dark') {
 | 
					            if (backgrounds[i] == 'alert-primary' || backgrounds[i] == 'alert-secondary' || backgrounds[i] == 'alert-dark') {
 | 
				
			||||||
                $("body").removeClass('text-dark');
 | 
					                $("body").removeClass('text-dark')
 | 
				
			||||||
            };
 | 
					            }
 | 
				
			||||||
        };
 | 
					        }
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $("body").addClass(value);
 | 
					    $("body").addClass(value)
 | 
				
			||||||
    if (value == 'bg-dark') {
 | 
					    if (value == 'bg-dark') {
 | 
				
			||||||
        $("body").addClass('text-light');
 | 
					        $("body").addClass('text-light')
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
    if (value == 'alert-primary' || value == 'alert-secondary' || value == 'alert-dark') {
 | 
					    if (value == 'alert-primary' || value == 'alert-secondary' || value == 'alert-dark') {
 | 
				
			||||||
        $("body").addClass('text-dark');
 | 
					        $("body").addClass('text-dark')
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    display_settings['bg-select'] = value;
 | 
					    display_settings['bg-select'] = value
 | 
				
			||||||
    window.localStorage.setItem('display_settings', JSON.stringify(display_settings));
 | 
					    window.localStorage.setItem('display_settings', JSON.stringify(display_settings))
 | 
				
			||||||
    $('input[name="bg-select"][value="' + value + '"]').prop('checked', true);
 | 
					    $('input[name="bg-select"][value="' + value + '"]').prop('checked', true)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function get_settings_from_storage() {
 | 
					function get_settings_from_storage() {
 | 
				
			||||||
    let display_settings = window.localStorage.getItem('display_settings')
 | 
					    let display_settings = window.localStorage.getItem('display_settings')
 | 
				
			||||||
    if (display_settings != null) {
 | 
					    if (display_settings != null) {
 | 
				
			||||||
        return JSON.parse(display_settings);
 | 
					        return JSON.parse(display_settings)
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        'font-select': 'osdefault',
 | 
					        'font-select': 'osdefault',
 | 
				
			||||||
        'font-size': '14pt',
 | 
					        'font-size': '14pt',
 | 
				
			||||||
@@ -323,133 +323,133 @@ function get_settings_from_storage() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function apply_settings(settings) {
 | 
					function apply_settings(settings) {
 | 
				
			||||||
    set_font(settings['font-select']);
 | 
					    set_font(settings['font-select'])
 | 
				
			||||||
    set_font_size(settings['font-size']);
 | 
					    set_font_size(settings['font-size'])
 | 
				
			||||||
    set_bg_colour(settings['bg-select']);
 | 
					    set_bg_colour(settings['bg-select'])
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function render_question() {
 | 
					function render_question() {
 | 
				
			||||||
    if (current_question == 0) {
 | 
					    if (current_question == 0) {
 | 
				
			||||||
        $nav_prev.addClass('disabled');
 | 
					        $nav_prev.addClass('disabled')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (current_question == questions.length - 1) {
 | 
					    if (current_question == questions.length - 1) {
 | 
				
			||||||
        $nav_next.addClass('disabled');
 | 
					        $nav_next.addClass('disabled')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if ($nav_prev.hasClass('disabled') && current_question > 0) {
 | 
					    if ($nav_prev.hasClass('disabled') && current_question > 0) {
 | 
				
			||||||
        $nav_prev.removeClass('disabled');
 | 
					        $nav_prev.removeClass('disabled')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if ($nav_next.hasClass('disabled') && current_question < questions.length - 1) {
 | 
					    if ($nav_next.hasClass('disabled') && current_question < questions.length - 1) {
 | 
				
			||||||
        $nav_next.removeClass('disabled');
 | 
					        $nav_next.removeClass('disabled')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    var question = questions[current_question];
 | 
					    var question = questions[current_question]
 | 
				
			||||||
    let header_text = question.question_header;
 | 
					    let header_text = question.question_header
 | 
				
			||||||
    var block_length = 0;
 | 
					    var block_length = 0
 | 
				
			||||||
    if ('block_length' in question) {
 | 
					    if ('block_length' in question) {
 | 
				
			||||||
        block_length = question['block_length'];
 | 
					        block_length = question['block_length']
 | 
				
			||||||
    };
 | 
					    }
 | 
				
			||||||
    var block_q_no = 0;
 | 
					    var block_q_no = 0
 | 
				
			||||||
    if ('block_q_no' in question) {
 | 
					    if ('block_q_no' in question) {
 | 
				
			||||||
        block_q_no = question['block_q_no'];
 | 
					        block_q_no = question['block_q_no']
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let remaining_qs = (block_length - block_q_no).toString();
 | 
					    let remaining_qs = (block_length - block_q_no).toString()
 | 
				
			||||||
    if (block_length - block_q_no > 1) {
 | 
					    if (block_length - block_q_no > 1) {
 | 
				
			||||||
        remaining_qs += ' questions';
 | 
					        remaining_qs += ' questions'
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        remaining_qs += ' question';
 | 
					        remaining_qs += ' question'
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    header_text = header_text.replace('<block_remaining_questions>', remaining_qs);
 | 
					    header_text = header_text.replace('<block_remaining_questions>', remaining_qs)
 | 
				
			||||||
    $question_header.html(header_text);
 | 
					    $question_header.html(header_text)
 | 
				
			||||||
    $question_text.html(question.text);
 | 
					    $question_text.html(question.text)
 | 
				
			||||||
    $question_title.html(`Question ${current_question + 1} of ${ questions.length }.`);
 | 
					    $question_title.html(`Question ${current_question + 1} of ${ questions.length }.`)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var q_no = question['q_no'];
 | 
					    var q_no = question['q_no']
 | 
				
			||||||
    var options = question.options;
 | 
					    var options = question.options
 | 
				
			||||||
    var options_output = '';
 | 
					    var options_output = ''
 | 
				
			||||||
    for (let i = 0; i < options.length; i ++) {
 | 
					    for (let i = 0; i < options.length; i ++) {
 | 
				
			||||||
        var add_checked = ''
 | 
					        var add_checked = ''
 | 
				
			||||||
        if (q_no in answers) {
 | 
					        if (q_no in answers) {
 | 
				
			||||||
            if (answers[q_no] == options[i][0]) {
 | 
					            if (answers[q_no] == options[i][0]) {
 | 
				
			||||||
                add_checked = 'checked';
 | 
					                add_checked = 'checked'
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        options_output += `<div class="form-check">
 | 
					        options_output += `<div class="form-check">
 | 
				
			||||||
            <input type="radio" class="form-check-input quiz-option" id="q${current_question}-${i}" name="${q_no}" value="${options[i][0]}" ${add_checked}>
 | 
					            <input type="radio" class="form-check-input quiz-option" id="q${current_question}-${i}" name="${q_no}" value="${options[i][0]}" ${add_checked}>
 | 
				
			||||||
            <label for="q${current_question}-${i}" class="form-check-label">${options[i][1]}</label>
 | 
					            <label for="q${current_question}-${i}" class="form-check-label">${options[i][1]}</label>
 | 
				
			||||||
        </div>`;
 | 
					        </div>`
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    $question_options.html(options_output);
 | 
					    $question_options.html(options_output)
 | 
				
			||||||
    let skipped = count_questions(-1);
 | 
					    let skipped = count_questions(-1)
 | 
				
			||||||
    let answered = count_questions(2);
 | 
					    let answered = count_questions(2)
 | 
				
			||||||
    let flagged = count_questions(1);
 | 
					    let flagged = count_questions(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $progress_skipped.prop('title', `Skipped: ${skipped}`);
 | 
					    $progress_skipped.prop('title', `Skipped: ${skipped}`)
 | 
				
			||||||
    $progress_skipped.prop('aria-valuenow', skipped);
 | 
					    $progress_skipped.prop('aria-valuenow', skipped)
 | 
				
			||||||
    $progress_skipped.css('width', `${skipped}%`);
 | 
					    $progress_skipped.css('width', `${skipped}%`)
 | 
				
			||||||
    $skipped_count.text(`Skipped: ${skipped}`);
 | 
					    $skipped_count.text(`Skipped: ${skipped}`)
 | 
				
			||||||
    if (skipped < 1) {
 | 
					    if (skipped < 1) {
 | 
				
			||||||
        $skipped_count.fadeOut()
 | 
					        $skipped_count.fadeOut()
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $skipped_count.fadeIn()
 | 
					        $skipped_count.fadeIn()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $progress_flagged.prop('title', `Flagged: ${flagged}`);
 | 
					    $progress_flagged.prop('title', `Flagged: ${flagged}`)
 | 
				
			||||||
    $progress_flagged.prop('aria-valuenow', flagged);
 | 
					    $progress_flagged.prop('aria-valuenow', flagged)
 | 
				
			||||||
    $progress_flagged.css('width', `${flagged}%`);
 | 
					    $progress_flagged.css('width', `${flagged}%`)
 | 
				
			||||||
    $flagged_count.text(`Flagged: ${flagged}`);
 | 
					    $flagged_count.text(`Flagged: ${flagged}`)
 | 
				
			||||||
    if (flagged < 1) {
 | 
					    if (flagged < 1) {
 | 
				
			||||||
        $flagged_count.fadeOut()
 | 
					        $flagged_count.fadeOut()
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $flagged_count.fadeIn()
 | 
					        $flagged_count.fadeIn()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $progress_answered.prop('title', `Answered: ${answered}`);
 | 
					    $progress_answered.prop('title', `Answered: ${answered}`)
 | 
				
			||||||
    $progress_answered.prop('aria-valuenow', answered);
 | 
					    $progress_answered.prop('aria-valuenow', answered)
 | 
				
			||||||
    $progress_answered.css('width', `${answered}%`);
 | 
					    $progress_answered.css('width', `${answered}%`)
 | 
				
			||||||
    $answered_count.text(`Answered: ${answered}`);
 | 
					    $answered_count.text(`Answered: ${answered}`)
 | 
				
			||||||
    if (answered < 1) {
 | 
					    if (answered < 1) {
 | 
				
			||||||
        $answered_count.fadeOut()
 | 
					        $answered_count.fadeOut()
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $answered_count.fadeIn()
 | 
					        $answered_count.fadeIn()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $question_title.focus();
 | 
					    $question_title.focus()
 | 
				
			||||||
    $(window).scrollTop(0);
 | 
					    $(window).scrollTop(0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function check_answered() {
 | 
					function check_answered() {
 | 
				
			||||||
    var question = questions[current_question];
 | 
					    var question = questions[current_question]
 | 
				
			||||||
    var name = question.q_no;
 | 
					    var name = question.q_no
 | 
				
			||||||
    if (question_status[current_question] == 0 || question_status[current_question] == -1) {
 | 
					    if (question_status[current_question] == 0 || question_status[current_question] == -1) {
 | 
				
			||||||
        if (!$(`input[name='${name}']:checked`).val()) {
 | 
					        if (!$(`input[name='${name}']:checked`).val()) {
 | 
				
			||||||
            question_status[current_question] = -1;
 | 
					            question_status[current_question] = -1
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            question_status[current_question] = 2;
 | 
					            question_status[current_question] = 2
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        window.localStorage.setItem('question_status', JSON.stringify(question_status));
 | 
					        window.localStorage.setItem('question_status', JSON.stringify(question_status))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function check_flag() {
 | 
					function check_flag() {
 | 
				
			||||||
    if (!(current_question in question_status)) {
 | 
					    if (!(current_question in question_status)) {
 | 
				
			||||||
        question_status[current_question] = 0;
 | 
					        question_status[current_question] = 0
 | 
				
			||||||
        window.localStorage.setItem('question_status', JSON.stringify(question_status));
 | 
					        window.localStorage.setItem('question_status', JSON.stringify(question_status))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    switch (question_status[current_question]) {
 | 
					    switch (question_status[current_question]) {
 | 
				
			||||||
        case -1:
 | 
					        case -1:
 | 
				
			||||||
            $nav_flag.removeClass().addClass('btn btn-danger progress-bar-striped');
 | 
					            $nav_flag.removeClass().addClass('btn btn-danger progress-bar-striped')
 | 
				
			||||||
            $nav_flag.prop("title", "Question Incomplete. Click to flag for revision.");
 | 
					            $nav_flag.prop("title", "Question Incomplete. Click to flag for revision.")
 | 
				
			||||||
            break;
 | 
					            break
 | 
				
			||||||
        case 1:
 | 
					        case 1:
 | 
				
			||||||
            $nav_flag.removeClass().addClass('btn btn-warning');
 | 
					            $nav_flag.removeClass().addClass('btn btn-warning')
 | 
				
			||||||
            $nav_flag.prop("title", "Question Flagged for revision. Click to un-flag.");
 | 
					            $nav_flag.prop("title", "Question Flagged for revision. Click to un-flag.")
 | 
				
			||||||
            break;
 | 
					            break
 | 
				
			||||||
        case 2:
 | 
					        case 2:
 | 
				
			||||||
            $nav_flag.removeClass().addClass('btn btn-success');
 | 
					            $nav_flag.removeClass().addClass('btn btn-success')
 | 
				
			||||||
            $nav_flag.prop("title", "Question Answered. Click to flag for revision.");
 | 
					            $nav_flag.prop("title", "Question Answered. Click to flag for revision.")
 | 
				
			||||||
            break;
 | 
					            break
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            $nav_flag.removeClass().addClass('btn btn-secondary');
 | 
					            $nav_flag.removeClass().addClass('btn btn-secondary')
 | 
				
			||||||
            $nav_flag.prop("title", "Question Un-Flagged. Click to flag for revision.");
 | 
					            $nav_flag.prop("title", "Question Un-Flagged. Click to flag for revision.")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -457,31 +457,31 @@ function build_navigator() {
 | 
				
			|||||||
    $nav_container.html('')
 | 
					    $nav_container.html('')
 | 
				
			||||||
    var output = ''
 | 
					    var output = ''
 | 
				
			||||||
    for (let i = 0; i < questions.length; i ++) {
 | 
					    for (let i = 0; i < questions.length; i ++) {
 | 
				
			||||||
        let add_class, add_href, add_status = '';
 | 
					        let add_class, add_href, add_status = ''
 | 
				
			||||||
        switch (question_status[i]) {
 | 
					        switch (question_status[i]) {
 | 
				
			||||||
            case -1:
 | 
					            case -1:
 | 
				
			||||||
                add_class = 'btn-danger progress-bar-striped';
 | 
					                add_class = 'btn-danger progress-bar-striped'
 | 
				
			||||||
                add_href = 'href="#"';
 | 
					                add_href = 'href="#"'
 | 
				
			||||||
                add_status = 'Incomplete';
 | 
					                add_status = 'Incomplete'
 | 
				
			||||||
                break;
 | 
					                break
 | 
				
			||||||
            case 1:
 | 
					            case 1:
 | 
				
			||||||
                add_class = 'btn-warning';
 | 
					                add_class = 'btn-warning'
 | 
				
			||||||
                add_href = 'href="#"';
 | 
					                add_href = 'href="#"'
 | 
				
			||||||
                add_status = 'Flagged';
 | 
					                add_status = 'Flagged'
 | 
				
			||||||
                break;
 | 
					                break
 | 
				
			||||||
            case 2:
 | 
					            case 2:
 | 
				
			||||||
                add_class = 'btn-success';
 | 
					                add_class = 'btn-success'
 | 
				
			||||||
                add_href = 'href="#"';
 | 
					                add_href = 'href="#"'
 | 
				
			||||||
                add_status = 'Answered';
 | 
					                add_status = 'Answered'
 | 
				
			||||||
                break;
 | 
					                break
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                add_class = 'btn-secondary disabled';
 | 
					                add_class = 'btn-secondary disabled'
 | 
				
			||||||
                add_href = '';
 | 
					                add_href = ''
 | 
				
			||||||
                add_status = 'Unseen';
 | 
					                add_status = 'Unseen'
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        output += `<a ${add_href} class="q-navigator-button btn ${add_class}" name=${i} title="Question ${i+1}: ${add_status}">Q${i + 1}</a>`;
 | 
					        output += `<a ${add_href} class="q-navigator-button btn ${add_class}" name=${i} title="Question ${i+1}: ${add_status}">Q${i + 1}</a>`
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    $nav_container.html(output);
 | 
					    $nav_container.html(output)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function update_navigator() {
 | 
					function update_navigator() {
 | 
				
			||||||
@@ -489,162 +489,162 @@ function update_navigator() {
 | 
				
			|||||||
    if (current_question in question_status) {
 | 
					    if (current_question in question_status) {
 | 
				
			||||||
        switch (question_status[current_question]) {
 | 
					        switch (question_status[current_question]) {
 | 
				
			||||||
            case -1:
 | 
					            case -1:
 | 
				
			||||||
                button.removeClass().addClass("q-navigator-button btn btn-danger progress-bar-striped");
 | 
					                button.removeClass().addClass("q-navigator-button btn btn-danger progress-bar-striped")
 | 
				
			||||||
                button.prop("title", `Question ${current_question + 1}: Incomplete`);
 | 
					                button.prop("title", `Question ${current_question + 1}: Incomplete`)
 | 
				
			||||||
                break;
 | 
					                break
 | 
				
			||||||
            case 1:
 | 
					            case 1:
 | 
				
			||||||
                button.removeClass().addClass("q-navigator-button btn btn-warning");
 | 
					                button.removeClass().addClass("q-navigator-button btn btn-warning")
 | 
				
			||||||
                button.prop("title", `Question ${current_question + 1}: Flagged`);
 | 
					                button.prop("title", `Question ${current_question + 1}: Flagged`)
 | 
				
			||||||
                break;
 | 
					                break
 | 
				
			||||||
            case 2:
 | 
					            case 2:
 | 
				
			||||||
                button.removeClass().addClass("q-navigator-button btn btn-success");
 | 
					                button.removeClass().addClass("q-navigator-button btn btn-success")
 | 
				
			||||||
                button.prop("title", `Question ${current_question + 1}: Answered`);
 | 
					                button.prop("title", `Question ${current_question + 1}: Answered`)
 | 
				
			||||||
                break;
 | 
					                break
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                button.removeClass().addClass("q-navigator-button btn btn-secondary disabled");
 | 
					                button.removeClass().addClass("q-navigator-button btn btn-secondary disabled")
 | 
				
			||||||
                button.prop("title", `Question ${current_question + 1}: Unseen`);
 | 
					                button.prop("title", `Question ${current_question + 1}: Unseen`)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function start() {
 | 
					function start() {
 | 
				
			||||||
    $("#btn-start-quiz").fadeOut();
 | 
					    $("#btn-start-quiz").fadeOut()
 | 
				
			||||||
    $(".btn-quiz-return").fadeIn();
 | 
					    $(".btn-quiz-return").fadeIn()
 | 
				
			||||||
    $(".quiz-console").fadeIn();
 | 
					    $(".quiz-console").fadeIn()
 | 
				
			||||||
    $("#quiz-settings").fadeOut();
 | 
					    $("#quiz-settings").fadeOut()
 | 
				
			||||||
    $("#quiz-navigator").fadeOut();
 | 
					    $("#quiz-navigator").fadeOut()
 | 
				
			||||||
    $(".quiz-start-text").fadeOut();
 | 
					    $(".quiz-start-text").fadeOut()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    questions = JSON.parse(window.localStorage.getItem('questions'));
 | 
					    questions = JSON.parse(window.localStorage.getItem('questions'))
 | 
				
			||||||
    total_questions = questions.length;
 | 
					    total_questions = questions.length
 | 
				
			||||||
    start_time = window.localStorage.getItem('start_time');
 | 
					    start_time = window.localStorage.getItem('start_time')
 | 
				
			||||||
    time_limit = window.localStorage.getItem('time_limit');
 | 
					    time_limit = window.localStorage.getItem('time_limit')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let get_answers = window.localStorage.getItem('answers');
 | 
					    let get_answers = window.localStorage.getItem('answers')
 | 
				
			||||||
    if (get_answers != null) {
 | 
					    if (get_answers != null) {
 | 
				
			||||||
        answers = JSON.parse(get_answers);
 | 
					        answers = JSON.parse(get_answers)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let get_status = window.localStorage.getItem('question_status');
 | 
					    let get_status = window.localStorage.getItem('question_status')
 | 
				
			||||||
    if (get_status != null) {
 | 
					    if (get_status != null) {
 | 
				
			||||||
        question_status = JSON.parse(get_status);
 | 
					        question_status = JSON.parse(get_status)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    render_question();
 | 
					    render_question()
 | 
				
			||||||
    build_navigator();
 | 
					    build_navigator()
 | 
				
			||||||
    check_flag();
 | 
					    check_flag()
 | 
				
			||||||
    if (time_limit != 'null' && time_limit != null) {
 | 
					    if (time_limit != 'null' && time_limit != null) {
 | 
				
			||||||
        $("#q-timer-widget").fadeIn();
 | 
					        $("#q-timer-widget").fadeIn()
 | 
				
			||||||
        time_remaining = get_time_remaining();
 | 
					        time_remaining = get_time_remaining()
 | 
				
			||||||
        clock = setInterval(timer, 1000);
 | 
					        clock = setInterval(timer, 1000)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function check_started() {
 | 
					function check_started() {
 | 
				
			||||||
    let questions = window.localStorage.getItem('questions');
 | 
					    let questions = window.localStorage.getItem('questions')
 | 
				
			||||||
    let time_limit = window.localStorage.getItem('time_limit');
 | 
					    let time_limit = window.localStorage.getItem('time_limit')
 | 
				
			||||||
    let start_time = window.localStorage.getItem('start_time')
 | 
					    let start_time = window.localStorage.getItem('start_time')
 | 
				
			||||||
    if (questions != null && start_time != null && time_limit != null) {
 | 
					    if (questions != null && start_time != null && time_limit != null) {
 | 
				
			||||||
        start();
 | 
					        start()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function get_time_remaining() {
 | 
					function get_time_remaining() {
 | 
				
			||||||
    var end_time = new Date(time_limit).getTime();
 | 
					    var end_time = new Date(time_limit).getTime()
 | 
				
			||||||
    var _start_time = new Date().getTime();
 | 
					    var _start_time = new Date().getTime()
 | 
				
			||||||
    return end_time - _start_time;
 | 
					    return end_time - _start_time
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function timer() {
 | 
					function timer() {
 | 
				
			||||||
    var hours = Math.floor((time_remaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
 | 
					    var hours = Math.floor((time_remaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
 | 
				
			||||||
    var minutes = Math.floor((time_remaining % (1000 * 60 * 60)) / (1000 * 60));
 | 
					    var minutes = Math.floor((time_remaining % (1000 * 60 * 60)) / (1000 * 60))
 | 
				
			||||||
    var seconds = Math.floor((time_remaining % (1000 * 60)) / 1000);
 | 
					    var seconds = Math.floor((time_remaining % (1000 * 60)) / 1000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (time_remaining > 0) {
 | 
					    if (time_remaining > 0) {
 | 
				
			||||||
        var timer_display = '';
 | 
					        var timer_display = ''
 | 
				
			||||||
        if (hours > 0) {
 | 
					        if (hours > 0) {
 | 
				
			||||||
            timer_display = `${hours.toString()}:`;
 | 
					            timer_display = `${hours.toString()}:`
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (minutes > 0 || hours > 0) {
 | 
					        if (minutes > 0 || hours > 0) {
 | 
				
			||||||
            if (minutes < 10) {
 | 
					            if (minutes < 10) {
 | 
				
			||||||
                timer_display += `0${minutes.toString()}:`;
 | 
					                timer_display += `0${minutes.toString()}:`
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                timer_display += `${minutes.toString()}:`;
 | 
					                timer_display += `${minutes.toString()}:`
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (seconds < 10) {
 | 
					        if (seconds < 10) {
 | 
				
			||||||
            timer_display += `0${seconds.toString()}`;
 | 
					            timer_display += `0${seconds.toString()}`
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            timer_display += seconds.toString();
 | 
					            timer_display += seconds.toString()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $timer.html(timer_display);
 | 
					        $timer.html(timer_display)
 | 
				
			||||||
        time_remaining -= 1000
 | 
					        time_remaining -= 1000
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $timer.html('Expired');
 | 
					        $timer.html('Expired')
 | 
				
			||||||
        clearInterval(clock);
 | 
					        clearInterval(clock)
 | 
				
			||||||
        stop()
 | 
					        stop()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function stop() {
 | 
					function stop() {
 | 
				
			||||||
    $quiz_render.fadeOut();
 | 
					    $quiz_render.fadeOut()
 | 
				
			||||||
    $quiz_navigator.fadeOut();
 | 
					    $quiz_navigator.fadeOut()
 | 
				
			||||||
    $quiz_timeout.fadeIn();
 | 
					    $quiz_timeout.fadeIn()
 | 
				
			||||||
    $("#btn-toggle-navigator").addClass('disabled');
 | 
					    $("#btn-toggle-navigator").addClass('disabled')
 | 
				
			||||||
    $("#btn-toggle-settings").addClass('disabled')
 | 
					    $("#btn-toggle-settings").addClass('disabled')
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function count_questions(status) {
 | 
					function count_questions(status) {
 | 
				
			||||||
    output = 0;
 | 
					    output = 0
 | 
				
			||||||
    for (let i = 0; i < Object.keys(question_status).length; i++) {
 | 
					    for (let i = 0; i < Object.keys(question_status).length; i++) {
 | 
				
			||||||
        key = Object.keys(question_status)[i];
 | 
					        key = Object.keys(question_status)[i]
 | 
				
			||||||
        if (question_status[key] == status){
 | 
					        if (question_status[key] == status){
 | 
				
			||||||
            output ++;
 | 
					            output ++
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return output;
 | 
					    return output
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Variable Definitions
 | 
					// Variable Definitions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const id = window.localStorage.getItem('id');
 | 
					const id = window.localStorage.getItem('id')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var current_question = 0;
 | 
					var current_question = 0
 | 
				
			||||||
var total_questions = 0;
 | 
					var total_questions = 0
 | 
				
			||||||
var question_status = {};
 | 
					var question_status = {}
 | 
				
			||||||
var answers = {};
 | 
					var answers = {}
 | 
				
			||||||
var questions = [];
 | 
					var questions = []
 | 
				
			||||||
var time_limit, start_time, time_remaining;
 | 
					var time_limit, start_time, time_remaining
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var display_settings = get_settings_from_storage();
 | 
					var display_settings = get_settings_from_storage()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const $quiz_settings = $("#quiz-settings");
 | 
					const $quiz_settings = $("#quiz-settings")
 | 
				
			||||||
const $quiz_navigator = $("#quiz-navigator");
 | 
					const $quiz_navigator = $("#quiz-navigator")
 | 
				
			||||||
const $quiz_render = $("#quiz-render");
 | 
					const $quiz_render = $("#quiz-render")
 | 
				
			||||||
const $quiz_timeout = $("#quiz-timeout");
 | 
					const $quiz_timeout = $("#quiz-timeout")
 | 
				
			||||||
const $nav_flag = $("#q-nav-flag");
 | 
					const $nav_flag = $("#q-nav-flag")
 | 
				
			||||||
const $nav_next = $("#q-nav-next");
 | 
					const $nav_next = $("#q-nav-next")
 | 
				
			||||||
const $nav_prev = $("#q-nav-prev");
 | 
					const $nav_prev = $("#q-nav-prev")
 | 
				
			||||||
const $nav_container = $("#navigator-container");
 | 
					const $nav_container = $("#navigator-container")
 | 
				
			||||||
const $timer = $("#q-timer-display");
 | 
					const $timer = $("#q-timer-display")
 | 
				
			||||||
var clock
 | 
					var clock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var toggle_settings = false;
 | 
					var toggle_settings = false
 | 
				
			||||||
var toggle_navigator = false;
 | 
					var toggle_navigator = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const $question_title = $("#quiz-question-title");
 | 
					const $question_title = $("#quiz-question-title")
 | 
				
			||||||
const $question_header = $("#quiz-question-header");
 | 
					const $question_header = $("#quiz-question-header")
 | 
				
			||||||
const $question_text = $("#quiz-question-text");
 | 
					const $question_text = $("#quiz-question-text")
 | 
				
			||||||
const $question_options = $("#quiz-question-options");
 | 
					const $question_options = $("#quiz-question-options")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const $progress_skipped = $("#skipped-bar");
 | 
					const $progress_skipped = $("#skipped-bar")
 | 
				
			||||||
const $progress_answered = $("#answered-bar");
 | 
					const $progress_answered = $("#answered-bar")
 | 
				
			||||||
const $progress_flagged = $("#flagged-bar");
 | 
					const $progress_flagged = $("#flagged-bar")
 | 
				
			||||||
const $skipped_count = $("#skipped-count");
 | 
					const $skipped_count = $("#skipped-count")
 | 
				
			||||||
const $answered_count = $("#answered-count");
 | 
					const $answered_count = $("#answered-count")
 | 
				
			||||||
const $flagged_count = $("#flagged-count");
 | 
					const $flagged_count = $("#flagged-count")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Execution on Load
 | 
					// Execution on Load
 | 
				
			||||||
 | 
					
 | 
				
			||||||
apply_settings(display_settings);
 | 
					apply_settings(display_settings)
 | 
				
			||||||
check_started();
 | 
					check_started()
 | 
				
			||||||
@@ -1,21 +1,21 @@
 | 
				
			|||||||
$(document).ready(function() {
 | 
					$(document).ready(function() {
 | 
				
			||||||
    $("#od-font-test").click(function(){
 | 
					    $("#od-font-test").click(function(){
 | 
				
			||||||
        $("body").css("font-family", "opendyslexic3regular")
 | 
					        $("body").css("font-family", "opendyslexic3regular")
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $('.test-code-input').keyup(function() {
 | 
					    $('.test-code-input').keyup(function() {
 | 
				
			||||||
        var input = $(this).val().split("-").join("").split("—").join("");
 | 
					        var input = $(this).val().split("-").join("").split("—").join("")
 | 
				
			||||||
        if (input.length > 0) {
 | 
					        if (input.length > 0) {
 | 
				
			||||||
          input = input.match(new RegExp('.{1,4}', 'g')).join("—");
 | 
					          input = input.match(new RegExp('.{1,4}', 'g')).join("—")
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $(this).val(input);
 | 
					        $(this).val(input)
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$('form[name=form-quiz-start]').submit(function(event) {
 | 
					$('form[name=form-quiz-start]').submit(function(event) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var $form = $(this);
 | 
					    var $form = $(this)
 | 
				
			||||||
    var data = $form.serialize();
 | 
					    var data = $form.serialize()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $.ajax({
 | 
					    $.ajax({
 | 
				
			||||||
        url: window.location.pathname,
 | 
					        url: window.location.pathname,
 | 
				
			||||||
@@ -24,21 +24,21 @@ $('form[name=form-quiz-start]').submit(function(event) {
 | 
				
			|||||||
        dataType: 'json',
 | 
					        dataType: 'json',
 | 
				
			||||||
        success: function(response) {
 | 
					        success: function(response) {
 | 
				
			||||||
            var id = response.id
 | 
					            var id = response.id
 | 
				
			||||||
            window.localStorage.setItem('id', id);
 | 
					            window.localStorage.setItem('id', id)
 | 
				
			||||||
            window.location.href = `/quiz/`;
 | 
					            window.location.href = `/quiz/`
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response) {
 | 
					        error: function(response) {
 | 
				
			||||||
            error_response(response);
 | 
					            error_response(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function error_response(response) {
 | 
					function error_response(response) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const $alert = $("#alert-box");
 | 
					    const $alert = $("#alert-box")
 | 
				
			||||||
    $alert.html('');
 | 
					    $alert.html('')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
					    if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
				
			||||||
        $alert.html(`
 | 
					        $alert.html(`
 | 
				
			||||||
@@ -47,18 +47,18 @@ function error_response(response) {
 | 
				
			|||||||
            ${response.responseJSON.error}
 | 
					            ${response.responseJSON.error}
 | 
				
			||||||
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
					            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        `);
 | 
					        `)
 | 
				
			||||||
    } else if (response.responseJSON.error instanceof Array) {
 | 
					    } else if (response.responseJSON.error instanceof Array) {
 | 
				
			||||||
        var output = ''
 | 
					        var output = ''
 | 
				
			||||||
        for (var i = 0; i < response.responseJSON.error.length; i ++) {
 | 
					        for (let i = 0; i < response.responseJSON.error.length; i ++) {
 | 
				
			||||||
            output += `
 | 
					            output += `
 | 
				
			||||||
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
					            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
				
			||||||
                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
					                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
				
			||||||
                ${response.responseJSON.error[i]}
 | 
					                ${response.responseJSON.error[i]}
 | 
				
			||||||
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
					                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            `;
 | 
					            `
 | 
				
			||||||
            $alert.html(output);
 | 
					            $alert.html(output)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -74,13 +74,13 @@ $('#dismiss-cookie-alert').click(function(event){
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        dataType: 'json',
 | 
					        dataType: 'json',
 | 
				
			||||||
        success: function(response){
 | 
					        success: function(response){
 | 
				
			||||||
            console.log(response);
 | 
					            console.log(response)
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response){
 | 
					        error: function(response){
 | 
				
			||||||
            console.log(response);
 | 
					            console.log(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@@ -1,21 +1,21 @@
 | 
				
			|||||||
$(document).ready(function() {
 | 
					$(document).ready(function() {
 | 
				
			||||||
    $("#od-font-test").click(function(){
 | 
					    $("#od-font-test").click(function(){
 | 
				
			||||||
        $("body").css("font-family", "opendyslexic3regular")
 | 
					        $("body").css("font-family", "opendyslexic3regular")
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $('.test-code-input').keyup(function() {
 | 
					    $('.test-code-input').keyup(function() {
 | 
				
			||||||
        var input = $(this).val().split("-").join("").split("—").join("");
 | 
					        var input = $(this).val().split("-").join("").split("—").join("")
 | 
				
			||||||
        if (input.length > 0) {
 | 
					        if (input.length > 0) {
 | 
				
			||||||
          input = input.match(new RegExp('.{1,4}', 'g')).join("—");
 | 
					          input = input.match(new RegExp('.{1,4}', 'g')).join("—")
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $(this).val(input);
 | 
					        $(this).val(input)
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$('form[name=form-quiz-start]').submit(function(event) {
 | 
					$('form[name=form-quiz-start]').submit(function(event) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var $form = $(this);
 | 
					    var $form = $(this)
 | 
				
			||||||
    var data = $form.serialize();
 | 
					    var data = $form.serialize()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $.ajax({
 | 
					    $.ajax({
 | 
				
			||||||
        url: window.location.pathname,
 | 
					        url: window.location.pathname,
 | 
				
			||||||
@@ -24,21 +24,21 @@ $('form[name=form-quiz-start]').submit(function(event) {
 | 
				
			|||||||
        dataType: 'json',
 | 
					        dataType: 'json',
 | 
				
			||||||
        success: function(response) {
 | 
					        success: function(response) {
 | 
				
			||||||
            var id = response.id
 | 
					            var id = response.id
 | 
				
			||||||
            window.localStorage.setItem('id', id);
 | 
					            window.localStorage.setItem('id', id)
 | 
				
			||||||
            window.location.href = `/quiz/`;
 | 
					            window.location.href = `/quiz/`
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response) {
 | 
					        error: function(response) {
 | 
				
			||||||
            error_response(response);
 | 
					            error_response(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
});
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function error_response(response) {
 | 
					function error_response(response) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const $alert = $("#alert-box");
 | 
					    const $alert = $("#alert-box")
 | 
				
			||||||
    $alert.html('');
 | 
					    $alert.html('')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
					    if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
				
			||||||
        $alert.html(`
 | 
					        $alert.html(`
 | 
				
			||||||
@@ -47,18 +47,18 @@ function error_response(response) {
 | 
				
			|||||||
            ${response.responseJSON.error}
 | 
					            ${response.responseJSON.error}
 | 
				
			||||||
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
					            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        `);
 | 
					        `)
 | 
				
			||||||
    } else if (response.responseJSON.error instanceof Array) {
 | 
					    } else if (response.responseJSON.error instanceof Array) {
 | 
				
			||||||
        var output = ''
 | 
					        var output = ''
 | 
				
			||||||
        for (var i = 0; i < response.responseJSON.error.length; i ++) {
 | 
					        for (let i = 0; i < response.responseJSON.error.length; i ++) {
 | 
				
			||||||
            output += `
 | 
					            output += `
 | 
				
			||||||
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
					            <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
				
			||||||
                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
					                <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
				
			||||||
                ${response.responseJSON.error[i]}
 | 
					                ${response.responseJSON.error[i]}
 | 
				
			||||||
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
					                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            `;
 | 
					            `
 | 
				
			||||||
            $alert.html(output);
 | 
					            $alert.html(output)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -74,13 +74,13 @@ $('#dismiss-cookie-alert').click(function(event){
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        dataType: 'json',
 | 
					        dataType: 'json',
 | 
				
			||||||
        success: function(response){
 | 
					        success: function(response){
 | 
				
			||||||
            console.log(response);
 | 
					            console.log(response)
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        error: function(response){
 | 
					        error: function(response){
 | 
				
			||||||
            console.log(response);
 | 
					            console.log(response)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event.preventDefault();
 | 
					    event.preventDefault()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
		Reference in New Issue
	
	Block a user