This commit is contained in:
Ross
2021-03-08 14:05:00 +00:00
parent fa00766620
commit 2c74b6e27d
+29 -41
View File
@@ -15,8 +15,7 @@ window.exam_details = {
cid: "",
eid: 5678,
exam_mode: false,
}
};
//window.exam_mode = false;
@@ -278,7 +277,9 @@ function loadPacketFromAjax(path) {
})
.done(function (data) {
//setUpPacket(data, path.split("/").pop());
if (data.hasOwnProperty("cached") && data["cached"]) { console.log("loading cached packet")}
if (data.hasOwnProperty("cached") && data["cached"]) {
console.log("loading cached packet");
}
setUpPacket(data, path);
$("#options-panel").hide();
})
@@ -387,7 +388,7 @@ cornerstoneWebImageLoader.external.cornerstone = cornerstone;
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
cornerstone.imageCache.setMaximumSizeBytes(22428800)
cornerstone.imageCache.setMaximumSizeBytes(22428800);
// cornerstoneWADOImageLoader.configure({
// beforeSend: function(xhr) {
@@ -452,7 +453,6 @@ function setUpPacket(data, path) {
// If the question_requests is set we need to do a request for each question
if (data.hasOwnProperty("question_requests") && data["question_requests"]) {
const question_total = Object.keys(data["questions"]).length;
let question_number = 0;
@@ -467,44 +467,32 @@ function setUpPacket(data, path) {
console.log("Creating ", question_url, question_number, question_total);
//$("#progress").html(`Downloading [${question_number}/${question_total}]`);
let question_json = {}
try {
question_json = await interact.getQuestion(
question_url,
question_number,
question_total
).fail(( jqXHR, textStatus, errorThrown ) => {
let question_json = {};
question_json = await interact
.getQuestion(question_url, question_number, question_total)
.fail((jqXHR, textStatus, errorThrown) => {
console.log(jqXHR, textStatus, errorThrown);
console.log("error loading question");
data["questions"][n] = {};
});
if (question_json.hasOwnProperty("cached") && question_json["cached"]) { console.log("loading cached packet")}
if (question_json.hasOwnProperty("cached") && question_json["cached"]) {
console.log("loading cached packet");
}
if (
question_json.hasOwnProperty("images_json") &&
question_json["images_json"]
) {
}
//requests.push(request)
//request_numbers.push(n)
data["questions"][n] = question_json;
} catch (error) {
console.log(error);
console.log("error loading question ", question_url);
question_json = await interact.getQuestion(
question_url,
question_number,
question_total
)
data["questions"][n] = question_json;
} finally {
}
}
// Once all questions have been downloaded we carry on loading
loadSession();
})()
})();
} else {
// Just carry on loading
loadSession();
@@ -512,7 +500,7 @@ function setUpPacket(data, path) {
}
function loadSession() {
console.log("load session")
console.log("load session");
// Either continue session or create a new one
window.db.session
// .where("status")
@@ -803,7 +791,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
qid: qid,
qidn: "1",
ans: evt.target.value,
}
};
window.db.answers.put(answer);
saveSession();
@@ -828,7 +816,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
qid: qid,
qidn: "2",
ans: evt.target.value,
}
};
// db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value});
window.db.answers.put(answer);
@@ -911,7 +899,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
qid: qid,
qidn: "1",
ans: evt.target.value,
}
};
// db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value});
window.db.answers.put(answer);
@@ -1000,7 +988,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
qid: qid,
qidn: qidn,
ans: evt.target.value,
}
};
window.db.answers.put(answer);
console.log("SAVE", qid, qidn, evt.target.value);
@@ -1056,7 +1044,9 @@ function loadQuestion(n, section = 1, force_reload = false) {
}
//rebuildQuestionListPanel();
setTimeout(() => { setFocus(section); }, 200);
setTimeout(() => {
setFocus(section);
}, 200);
}
/**
@@ -1118,7 +1108,6 @@ function deleteQuestionListPanelFlags(answer) {
answer.qidn +
" span"
).css("visibility", "hidden");
}
function updateQuestionListPanelFlags(answer) {
@@ -1129,7 +1118,6 @@ function updateQuestionListPanelFlags(answer) {
answer.qidn +
" span"
).css("visibility", "visible");
}
/**
* Updates the question list panel
@@ -1982,7 +1970,8 @@ $("#btn-delete-databases").click(function (evt) {
"This will delete ALL saved answers (including saved correct answers)!"
);
if (r == true) {
window.db.delete()
window.db
.delete()
.then(() => {
$.notify("Database successfully deleted", "success");
$.notify("The page will now reload", "warn");
@@ -2097,4 +2086,3 @@ function saveSession() {
}
window.saveSession = saveSession;