some improvements
This commit is contained in:
@@ -1004,3 +1004,7 @@ display: block
|
|||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#options-link {
|
||||||
|
padding-top: 40px;
|
||||||
|
}
|
||||||
+3
-1
@@ -71,6 +71,8 @@
|
|||||||
<span id="packet-list">
|
<span id="packet-list">
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="options-link">
|
||||||
|
</div>
|
||||||
<div id="local-fileloader">
|
<div id="local-fileloader">
|
||||||
<form id="jsonFile" name="jsonFile" enctype="multipart/form-data" method="post">
|
<form id="jsonFile" name="jsonFile" enctype="multipart/form-data" method="post">
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="start-dialog" class="dialog modal">
|
<div id="start-dialog" class="dialog modal">
|
||||||
<h3 class="dialog-title">Start exam</h3>
|
<h3 class="dialog-title">Start <span class="exam-name"></span></h3>
|
||||||
<div class="packet-database-options">
|
<div class="packet-database-options">
|
||||||
<input type='button' id='btn-delete-current' value='Reset current packet answers'><br />
|
<input type='button' id='btn-delete-current' value='Reset current packet answers'><br />
|
||||||
<input type='button' id='btn-delete-current-saved-answers' value='Reset current packet saved answers'>
|
<input type='button' id='btn-delete-current-saved-answers' value='Reset current packet saved answers'>
|
||||||
|
|||||||
+29
-6
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits answers
|
* Submits answers
|
||||||
*/
|
*/
|
||||||
@@ -31,14 +30,38 @@ export function getJsonAnswers(window, db) {
|
|||||||
export function postAnswers(ans) {
|
export function postAnswers(ans) {
|
||||||
$("#progress").html(`Submitting answers...`);
|
$("#progress").html(`Submitting answers...`);
|
||||||
// ans = {"test" : 1}
|
// ans = {"test" : 1}
|
||||||
$.post(window.config.exam_submit_url, JSON.stringify(ans)).done(
|
$.post(window.config.exam_submit_url, JSON.stringify(ans)).done((data) => {
|
||||||
(data) => {
|
console.log(data);
|
||||||
console.log(data)
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
alert(`${data.question_count} answers sucessfully submitted.`);
|
if (data.question_count == window.number_of_questions) {
|
||||||
|
let ret = confirm(
|
||||||
|
`${data.question_count} answers sucessfully submitted. Click OK to finish the exam.`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
window.review = true;
|
||||||
|
window.saveSession();
|
||||||
|
if (config.exam_results_url != "") {
|
||||||
|
let url = config.exam_results_url;
|
||||||
|
|
||||||
|
if (window.cid != "") {
|
||||||
|
url = url + window.cid;
|
||||||
|
}
|
||||||
|
$("#options-link")
|
||||||
|
.empty()
|
||||||
|
.append(
|
||||||
|
`<a href="${url}" target="_blank"><div class="packet-button">Results and answers</div></a>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$("#options-panel").show();
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(`${data.question_count} answers sucessfully submitted.`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(`Error submitting answers: ${data.error}`);
|
alert(`Error submitting answers: ${data.error}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
|
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
|
||||||
}
|
}
|
||||||
+24
-8
@@ -135,6 +135,15 @@ async function loadExamList(data) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
if (config.exam_results_url != "") {
|
||||||
|
let url = config.exam_results_url;
|
||||||
|
|
||||||
|
$("#options-link")
|
||||||
|
.empty()
|
||||||
|
.append(
|
||||||
|
`<a href="${url}" target="_blank"><div class="packet-button">Results and answers</div></a>`
|
||||||
|
);
|
||||||
|
}
|
||||||
$("#options-panel").show();
|
$("#options-panel").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +261,13 @@ function setUpQuestions(load_previous) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.question_order = helper.shuffleArray(window.question_order);
|
let randomise_order = true;
|
||||||
|
if (window.config.randomise_order != undefined) {
|
||||||
|
randomise_order = window.config.randomise_order;
|
||||||
|
}
|
||||||
|
if (randomise_order) {
|
||||||
|
window.question_order = helper.shuffleArray(window.question_order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.number_of_questions = Object.keys(window.questions).length;
|
window.number_of_questions = Object.keys(window.questions).length;
|
||||||
window.review = false;
|
window.review = false;
|
||||||
@@ -299,8 +314,8 @@ function setUpQuestions(load_previous) {
|
|||||||
|
|
||||||
$("#start-dialog").addClass("no-close");
|
$("#start-dialog").addClass("no-close");
|
||||||
$("#start-dialog .exam-time").prop("disabled", "true");
|
$("#start-dialog .exam-time").prop("disabled", "true");
|
||||||
$("#exam-candidate-number").toggle();
|
$("#exam-candidate-number").show();
|
||||||
$(".packet-database-options").toggle();
|
$(".packet-database-options").hide();
|
||||||
$("#start-dialog").modal({
|
$("#start-dialog").modal({
|
||||||
closeExisting: false, // Close existing modals. Set this to false if you need to stack multiple modal instances.
|
closeExisting: false, // Close existing modals. Set this to false if you need to stack multiple modal instances.
|
||||||
escapeClose: false, // Allows the user to close the modal by pressing `ESC`
|
escapeClose: false, // Allows the user to close the modal by pressing `ESC`
|
||||||
@@ -1716,13 +1731,12 @@ $("#start-exam-button").click(function (evt) {
|
|||||||
|
|
||||||
$(".start-packet-button").click(function (evt) {
|
$(".start-packet-button").click(function (evt) {
|
||||||
if (window.exam_mode) {
|
if (window.exam_mode) {
|
||||||
if (!Number.isInteger(parseInt($("#candidate-number2").val()))) {
|
if (!Number.isInteger(parseInt($("#candidate-number2").val()))) {
|
||||||
alert("Please enter a valid candidate number.")
|
alert("Please enter a valid candidate number.");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (window.timer != null) {
|
if (window.timer != null) {
|
||||||
window.timer.stop();
|
window.timer.stop();
|
||||||
}
|
}
|
||||||
@@ -1913,5 +1927,7 @@ function saveSession() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.saveSession = saveSession;
|
||||||
|
|
||||||
// Register Key Event Listener
|
// Register Key Event Listener
|
||||||
window.addEventListener("keydown", viewer.keydown_handler);
|
window.addEventListener("keydown", viewer.keydown_handler);
|
||||||
|
|||||||
Reference in New Issue
Block a user