some improvements
This commit is contained in:
@@ -1003,4 +1003,8 @@ display: block
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#options-link {
|
||||
padding-top: 40px;
|
||||
}
|
||||
+3
-1
@@ -71,6 +71,8 @@
|
||||
<span id="packet-list">
|
||||
</span>
|
||||
</div>
|
||||
<div id="options-link">
|
||||
</div>
|
||||
<div id="local-fileloader">
|
||||
<form id="jsonFile" name="jsonFile" enctype="multipart/form-data" method="post">
|
||||
|
||||
@@ -110,7 +112,7 @@
|
||||
</div>
|
||||
|
||||
<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">
|
||||
<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'>
|
||||
|
||||
+30
-7
@@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* Submits answers
|
||||
*/
|
||||
@@ -31,14 +30,38 @@ export function getJsonAnswers(window, db) {
|
||||
export function postAnswers(ans) {
|
||||
$("#progress").html(`Submitting answers...`);
|
||||
// ans = {"test" : 1}
|
||||
$.post(window.config.exam_submit_url, JSON.stringify(ans)).done(
|
||||
(data) => {
|
||||
console.log(data)
|
||||
$.post(window.config.exam_submit_url, JSON.stringify(ans)).done((data) => {
|
||||
console.log(data);
|
||||
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 {
|
||||
alert(`Error submitting answers: ${data.error}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
// $.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();
|
||||
}
|
||||
|
||||
@@ -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.review = false;
|
||||
@@ -299,8 +314,8 @@ function setUpQuestions(load_previous) {
|
||||
|
||||
$("#start-dialog").addClass("no-close");
|
||||
$("#start-dialog .exam-time").prop("disabled", "true");
|
||||
$("#exam-candidate-number").toggle();
|
||||
$(".packet-database-options").toggle();
|
||||
$("#exam-candidate-number").show();
|
||||
$(".packet-database-options").hide();
|
||||
$("#start-dialog").modal({
|
||||
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`
|
||||
@@ -1716,13 +1731,12 @@ $("#start-exam-button").click(function (evt) {
|
||||
|
||||
$(".start-packet-button").click(function (evt) {
|
||||
if (window.exam_mode) {
|
||||
if (!Number.isInteger(parseInt($("#candidate-number2").val()))) {
|
||||
alert("Please enter a valid candidate number.")
|
||||
return
|
||||
}
|
||||
if (!Number.isInteger(parseInt($("#candidate-number2").val()))) {
|
||||
alert("Please enter a valid candidate number.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (window.timer != null) {
|
||||
window.timer.stop();
|
||||
}
|
||||
@@ -1913,5 +1927,7 @@ function saveSession() {
|
||||
});
|
||||
}
|
||||
|
||||
window.saveSession = saveSession;
|
||||
|
||||
// Register Key Event Listener
|
||||
window.addEventListener("keydown", viewer.keydown_handler);
|
||||
|
||||
Reference in New Issue
Block a user