View submitted answers locally

This commit is contained in:
Ross
2023-05-15 09:16:46 +01:00
parent c8515b51c7
commit 57e76c10fa
5 changed files with 126 additions and 97 deletions
+28
View File
@@ -2492,6 +2492,9 @@ $("#login-button").click(function(evt) {
$(".start-packet-button").click(function(evt) {
// TODO: send packet to server to indicated that we have started the exam
// if in exam mode
exam_details.start_time = new Date().getTime() / 1000;
if (timer != null) {
@@ -2627,6 +2630,31 @@ function delete_user_db() {
});
}
$("#btn-view-local-answers").click(async function(evt) {
var docHeight = $(document).height();
let answer_json = await db.answers.toArray();
if ($("#view-answers-overlay").length < 1) {
$("body").append(
`<div id='view-answers-overlay'><span style='color: white'><p>${JSON.stringify(
answer_json
)}</p></span></div>`
);
$("#view-answers-overlay").height(docHeight);
$("#view-answers-overlay").append("<a id='save-failed-answers'>Save</a>")
let file = new Blob([JSON.stringify(answer_json)], {type: "application/json"})
let link = document.getElementById("save-failed-answers");
link.href = URL.createObjectURL(file);
link.download = "answers.json";
}
});
$("#btn-delete-answer-databases").click(function(evt) {
var r = confirm(
"This will delete ALL saved answers (including saved correct answers)!"