Added functionality for default datasets.
Incorporated dataset selector into test creation.
This commit is contained in:
		@@ -132,16 +132,11 @@ table.dataTable {
 | 
			
		||||
    width: 100%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.user-table-row {
 | 
			
		||||
.table-row {
 | 
			
		||||
    vertical-align: middle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.user-row-actions {
 | 
			
		||||
    text-align: center;
 | 
			
		||||
    white-space: nowrap;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.test-row-actions {
 | 
			
		||||
.row-actions {
 | 
			
		||||
    text-align: center;
 | 
			
		||||
    white-space: nowrap;
 | 
			
		||||
}
 | 
			
		||||
@@ -153,8 +148,8 @@ table.dataTable {
 | 
			
		||||
    text-align:center;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.user-row-actions button {
 | 
			
		||||
    margin: 0px 10px;
 | 
			
		||||
.row-actions button, .row-actions a {
 | 
			
		||||
    margin: 0px 5px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#cookie-alert {
 | 
			
		||||
@@ -214,6 +209,11 @@ table.dataTable {
 | 
			
		||||
    font-size: 20px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.form-upload {
 | 
			
		||||
    margin: 2rem 0;
 | 
			
		||||
    font-size: 14pt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Fallback for Edge
 | 
			
		||||
-------------------------------------------------- */
 | 
			
		||||
@supports (-ms-ime-align: auto) {
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ $('form[name=form-register]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -62,7 +62,7 @@ $('form[name=form-login]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -104,7 +104,7 @@ $('form[name=form-reset]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -146,7 +146,7 @@ $('form[name=form-update-password]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
    console.log(data)
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -188,7 +188,7 @@ $('form[name=form-create-user]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -230,7 +230,7 @@ $('form[name=form-delete-user]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -272,7 +272,7 @@ $('form[name=form-update-user]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -314,7 +314,7 @@ $('form[name=form-update-account]').submit(function(event) {
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -355,7 +355,7 @@ $('form[name=form-create-test]').submit(function(event) {
 | 
			
		||||
    var $form = $(this);
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    var data = $form.serialize();
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -398,7 +398,7 @@ $('form[name=form-upload-questions]').submit(function(event) {
 | 
			
		||||
    var data = new FormData($form[0]);
 | 
			
		||||
    var file = $('input[name=data_file]')[0].files[0]
 | 
			
		||||
    data.append('file', file)
 | 
			
		||||
    alert.innerHTML = ''
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: window.location.pathname,
 | 
			
		||||
@@ -407,25 +407,7 @@ $('form[name=form-upload-questions]').submit(function(event) {
 | 
			
		||||
        processData: false,
 | 
			
		||||
        contentType: false,
 | 
			
		||||
        success: function(response) {
 | 
			
		||||
            if (typeof response.success === 'string' || response.success instanceof String) {
 | 
			
		||||
                alert.innerHTML = alert.innerHTML + `
 | 
			
		||||
                <div class="alert alert-success alert-dismissible fade show" role="alert">
 | 
			
		||||
                    <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
			
		||||
                    ${response.success}
 | 
			
		||||
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
			
		||||
                </div>
 | 
			
		||||
                `;
 | 
			
		||||
            } else if (response.success instanceof Array) {
 | 
			
		||||
                for (var i = 0; i < response.success.length; i ++) {
 | 
			
		||||
                    alert.innerHTML = alert.innerHTML + `
 | 
			
		||||
                    <div class="alert alert-success alert-dismissible fade show" role="alert">
 | 
			
		||||
                        <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
			
		||||
                        ${response.success[i]}
 | 
			
		||||
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    `;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            window.location.reload();
 | 
			
		||||
        },
 | 
			
		||||
        error: function(response) {
 | 
			
		||||
            if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
			
		||||
@@ -455,10 +437,10 @@ $('form[name=form-upload-questions]').submit(function(event) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Edit and Delete Test Button Handlers
 | 
			
		||||
 | 
			
		||||
$('.delete-test').click(function(event) {
 | 
			
		||||
    
 | 
			
		||||
    _id = $(this).data('_id')
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: `/admin/tests/delete/${_id}`,
 | 
			
		||||
@@ -492,6 +474,89 @@ $('.delete-test').click(function(event) {
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// Edit and Delete Dataset Button Handlers
 | 
			
		||||
$('.delete-question-dataset').click(function(event) {
 | 
			
		||||
    
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    var filename = $(this).data('filename');
 | 
			
		||||
    var disabled = $(this).hasClass('disabled');
 | 
			
		||||
 | 
			
		||||
    if ( !disabled ) {        
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: `/admin/settings/questions/delete/${filename}`,
 | 
			
		||||
            type: 'GET',
 | 
			
		||||
            success: function(response) {
 | 
			
		||||
                window.location.reload();
 | 
			
		||||
            },
 | 
			
		||||
            error: function(response) {
 | 
			
		||||
                if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
			
		||||
                    alert.innerHTML = alert.innerHTML + `
 | 
			
		||||
                    <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
			
		||||
                        <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
			
		||||
                        ${response.responseJSON.error}
 | 
			
		||||
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    `;
 | 
			
		||||
                } else if (response.responseJSON.error instanceof Array) {
 | 
			
		||||
                    for (var i = 0; i < response.responseJSON.error.length; i ++) {
 | 
			
		||||
                        alert.innerHTML = alert.innerHTML + `
 | 
			
		||||
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
			
		||||
                            <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
			
		||||
                            ${response.responseJSON.error[i]}
 | 
			
		||||
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        `;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    };
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$('.edit-question-dataset').click(function(event) {
 | 
			
		||||
    
 | 
			
		||||
    var alert = document.getElementById('alert-box');
 | 
			
		||||
    alert.innerHTML = '';
 | 
			
		||||
 | 
			
		||||
    var filename = $(this).data('filename');
 | 
			
		||||
    var disabled = $(this).hasClass('disabled');
 | 
			
		||||
 | 
			
		||||
    if ( !disabled ) {        
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: `/admin/settings/questions/default/${filename}`,
 | 
			
		||||
            type: 'GET',
 | 
			
		||||
            success: function(response) {
 | 
			
		||||
                window.location.reload();
 | 
			
		||||
            },
 | 
			
		||||
            error: function(response) {
 | 
			
		||||
                if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
 | 
			
		||||
                    alert.innerHTML = alert.innerHTML + `
 | 
			
		||||
                    <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
			
		||||
                        <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
			
		||||
                        ${response.responseJSON.error}
 | 
			
		||||
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    `;
 | 
			
		||||
                } else if (response.responseJSON.error instanceof Array) {
 | 
			
		||||
                    for (var i = 0; i < response.responseJSON.error.length; i ++) {
 | 
			
		||||
                        alert.innerHTML = alert.innerHTML + `
 | 
			
		||||
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
			
		||||
                            <i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
 | 
			
		||||
                            ${response.responseJSON.error[i]}
 | 
			
		||||
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        `;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    };
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// Dismiss Cookie Alert
 | 
			
		||||
$('#dismiss-cookie-alert').click(function(event){
 | 
			
		||||
 | 
			
		||||
@@ -503,13 +568,13 @@ $('#dismiss-cookie-alert').click(function(event){
 | 
			
		||||
        },
 | 
			
		||||
        dataType: 'json',
 | 
			
		||||
        success: function(response){
 | 
			
		||||
            console.log(response)
 | 
			
		||||
            console.log(response);
 | 
			
		||||
        },
 | 
			
		||||
        error: function(response){
 | 
			
		||||
            console.log(response)
 | 
			
		||||
            console.log(response);
 | 
			
		||||
        }
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    event.preventDefault()
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
 | 
			
		||||
})
 | 
			
		||||
		Reference in New Issue
	
	Block a user