switch to console.debug

This commit is contained in:
Ross
2022-06-03 14:55:45 +01:00
parent 1f00b7134e
commit a0b5cdf053
3 changed files with 96 additions and 96 deletions
+14 -14
View File
@@ -15,7 +15,7 @@ export function submitAnswers(exam_details, db, config) {
postAnswers(json, config, exam_details); postAnswers(json, config, exam_details);
}) })
.catch((e) => { .catch((e) => {
console.log(e) console.debug(e)
alert("No answers to submit"); alert("No answers to submit");
}); });
} }
@@ -25,8 +25,8 @@ export function submitAnswers(exam_details, db, config) {
* @return {JSON} - answers * @return {JSON} - answers
*/ */
export function getJsonAnswers(exam_details, db) { export function getJsonAnswers(exam_details, db) {
console.log(exam_details) console.debug(exam_details)
console.log({ console.debug({
aid: exam_details.aid, aid: exam_details.aid,
cid: exam_details.cid, cid: exam_details.cid,
eid: exam_details.eid, eid: exam_details.eid,
@@ -49,7 +49,7 @@ export function postAnswers(ans, config, exam_details) {
$.post(config.exam_submit_url, ans, null, "json") $.post(config.exam_submit_url, ans, null, "json")
.done((data) => { .done((data) => {
console.log("returned data", data); console.debug("returned data", data);
if (data.success) { if (data.success) {
$("#submit-error-overlay").remove(); $("#submit-error-overlay").remove();
if (data.question_count == exam_details.number_of_questions) { if (data.question_count == exam_details.number_of_questions) {
@@ -82,7 +82,7 @@ export function postAnswers(ans, config, exam_details) {
}) })
.fail((e) => { .fail((e) => {
// Will occur with server error such as 500 // Will occur with server error such as 500
console.log("error", e); console.debug("error", e);
submissionError(e, ans, exam_details); submissionError(e, ans, exam_details);
}); });
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans)); // $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
@@ -113,9 +113,9 @@ function submissionError(data, answer_json, exam_details) {
let html = $("<ul></ul>"); let html = $("<ul></ul>");
exam_details.question_order.forEach((i, j) => { exam_details.question_order.forEach((i, j) => {
console.log(i, answer_map) console.debug(i, answer_map)
if (i in answer_map) { if (i in answer_map) {
console.log("YES", i, answer_map) console.debug("YES", i, answer_map)
let ans_array = answer_map[i]; let ans_array = answer_map[i];
ans_array.forEach((x, y) => { ans_array.forEach((x, y) => {
$(html).append(`<li><b>Question ${j+1}.${y}:</b> ${x.ans}</li>`); $(html).append(`<li><b>Question ${j+1}.${y}:</b> ${x.ans}</li>`);
@@ -124,9 +124,9 @@ function submissionError(data, answer_json, exam_details) {
}) })
console.log(exam_details.question_order); console.debug(exam_details.question_order);
console.log(answer_map); console.debug(answer_map);
console.log(html); console.debug(html);
if ($("#submit-error-overlay").length < 1) { if ($("#submit-error-overlay").length < 1) {
$("body").append( $("body").append(
@@ -142,7 +142,7 @@ function submissionError(data, answer_json, exam_details) {
} }
export function getQuestion(url, question_number, question_total) { export function getQuestion(url, question_number, question_total) {
console.log("Downloading question ", url, question_number, question_total); console.debug("Downloading question ", url, question_number, question_total);
return $.ajax({ return $.ajax({
dataType: "json", dataType: "json",
url: url, url: url,
@@ -162,7 +162,7 @@ export function getQuestion(url, question_number, question_total) {
} }
}, },
error: (jqXHR, textStatus, errorThrown) => { error: (jqXHR, textStatus, errorThrown) => {
console.log("error downlading", jqXHR, textStatus, errorThrown); console.debug("error downlading", jqXHR, textStatus, errorThrown);
}, },
//success: function (data) { //success: function (data) {
// strReturn = data; // strReturn = data;
@@ -172,7 +172,7 @@ export function getQuestion(url, question_number, question_total) {
} }
export function postSavedAnswer(type, qid, answer, e, db_object, db) { export function postSavedAnswer(type, qid, answer, e, db_object, db) {
console.log("post", type, qid, answer, e) console.debug("post", type, qid, answer, e)
return $.ajax({ return $.ajax({
type: "POST", type: "POST",
url: config.question_answer_submit_url, url: config.question_answer_submit_url,
@@ -187,7 +187,7 @@ export function postSavedAnswer(type, qid, answer, e, db_object, db) {
db_object.submitted = true; db_object.submitted = true;
db.user_answers.put(db_object); db.user_answers.put(db_object);
e.target.remove() e.target.remove()
console.log(data); console.debug(data);
}, },
error: function(errMsg) { error: function(errMsg) {
+79 -79
View File
@@ -99,9 +99,9 @@ refreshDatabaseSettings();
async function retrievePacketList() { async function retrievePacketList() {
let url = "packets/packets.json"; let url = "packets/packets.json";
//console.log(config.exam_query_url); //console.debug(config.exam_query_url);
let users = await user_db.user.toArray(); let users = await user_db.user.toArray();
console.log(users) console.debug(users)
if (users.length > 0) { if (users.length > 0) {
global_cid = users[0].cid; global_cid = users[0].cid;
@@ -147,7 +147,7 @@ async function retrievePacketList() {
} }
}; };
console.log(cid, passcode) console.debug(cid, passcode)
user_db.user.add({ user_db.user.add({
cid: cid, cid: cid,
@@ -183,7 +183,7 @@ async function retrievePacketList() {
} }
}, },
error: function(httpObj, textStatus) { error: function(httpObj, textStatus) {
console.log(httpObj); console.debug(httpObj);
if (httpObj.status == 401 || httpObj.status == 404) { if (httpObj.status == 401 || httpObj.status == 404) {
$.notify("Unable to login", "error"); $.notify("Unable to login", "error");
$("#options-panel").show(); $("#options-panel").show();
@@ -200,7 +200,7 @@ async function retrievePacketList() {
loadPacketList(data); loadPacketList(data);
} }
}).fail(function(jqXHR, textStatus, errorThrown) { }).fail(function(jqXHR, textStatus, errorThrown) {
console.log("No packet list available"); console.debug("No packet list available");
//showLoginDialog(); //showLoginDialog();
}); });
}) })
@@ -215,7 +215,7 @@ async function retrievePacketList() {
*/ */
async function loadExamList(data) { async function loadExamList(data) {
let sessions = await db.session.toArray().catch(function(error) { let sessions = await db.session.toArray().catch(function(error) {
console.log("Error loading session", error); console.debug("Error loading session", error);
$("#database-error").text( $("#database-error").text(
"Error loading the database, schema has probably changed and needs updating. You will probably need to delete the local database." "Error loading the database, schema has probably changed and needs updating. You will probably need to delete the local database."
); );
@@ -263,7 +263,7 @@ async function loadExamList(data) {
//exam_list.sort((a, b) => (a.name > b.name) ? 1 : -1).forEach(function (exam) { //exam_list.sort((a, b) => (a.name > b.name) ? 1 : -1).forEach(function (exam) {
for (let index = 0; index < exam_list.length; index++) { for (let index = 0; index < exam_list.length; index++) {
const exam = exam_list[index]; const exam = exam_list[index];
console.log(exam) console.debug(exam)
let name = exam["name"]; let name = exam["name"];
let url = exam["url"]; let url = exam["url"];
let eid = exam["eid"]; let eid = exam["eid"];
@@ -325,9 +325,9 @@ async function loadExamList(data) {
} else { } else {
$("#cache-details summary").append("<span>Cached exams / questions:</span>"); $("#cache-details summary").append("<span>Cached exams / questions:</span>");
} }
console.log("Loop through saved exams"); console.debug("Loop through saved exams");
saved_exams.forEach(async (saved_exam, n) => { saved_exams.forEach(async (saved_exam, n) => {
console.log("Check", saved_exam); console.debug("Check", saved_exam);
$("#cache-details ul").append( $("#cache-details ul").append(
`<li class="cache-item" data-eid=${saved_exam.eid}>Exam: ${saved_exam.exam_name} [${saved_exam.eid}]: ${saved_exam.exam_json_id}` `<li class="cache-item" data-eid=${saved_exam.eid}>Exam: ${saved_exam.exam_name} [${saved_exam.eid}]: ${saved_exam.exam_json_id}`
); );
@@ -338,23 +338,23 @@ async function loadExamList(data) {
const question_json_id_hash = exam_generated_map[saved_exam.eid][1]; const question_json_id_hash = exam_generated_map[saved_exam.eid][1];
if (saved_exam.exam_json_id != exam_json_id) { if (saved_exam.exam_json_id != exam_json_id) {
console.log("id mismath", saved_exam.exam_json_id, exam_json_id); console.debug("id mismath", saved_exam.exam_json_id, exam_json_id);
question_db.saved_exams.where("eid").equals(saved_exam.eid).delete(); question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
db.answers.where("eid").equals(saved_exam.eid).delete(); db.answers.where("eid").equals(saved_exam.eid).delete();
console.log("HOL"); console.debug("HOL");
$(`li.cache-item[data-eid="${saved_exam.eid}"]`) $(`li.cache-item[data-eid="${saved_exam.eid}"]`)
.addClass("cache-out-of-date") .addClass("cache-out-of-date")
.append(` [out of date (latest: ${exam_json_id})]`); .append(` [out of date (latest: ${exam_json_id})]`);
} else { } else {
console.log("id match", saved_exam.exam_json_id, exam_json_id); console.debug("id match", saved_exam.exam_json_id, exam_json_id);
$(`.packet-button[data-eid="${saved_exam.eid}"]`).addClass("cached"); $(`.packet-button[data-eid="${saved_exam.eid}"]`).addClass("cached");
} }
console.log("Check question ids") console.debug("Check question ids")
for (let q in question_json_id_hash) { for (let q in question_json_id_hash) {
let new_question_json_id = question_json_id_hash[q]; let new_question_json_id = question_json_id_hash[q];
console.log("new question json id", new_question_json_id) console.debug("new question json id", new_question_json_id)
//q = q.toString(); //q = q.toString();
$("#cache-details ul").append( $("#cache-details ul").append(
`<li class="cache-item" data-qid=${q}>Question (${saved_exam.exam_type}): ${q} [New JSON id: ${new_question_json_id}]` `<li class="cache-item" data-qid=${q}>Question (${saved_exam.exam_type}): ${q} [New JSON id: ${new_question_json_id}]`
@@ -364,16 +364,16 @@ async function loadExamList(data) {
qid: String(q), qid: String(q),
type: saved_exam.exam_type type: saved_exam.exam_type
}; };
console.log(q_object); console.debug(q_object);
let save_question_data = await question_db.question_data.get(q_object); let save_question_data = await question_db.question_data.get(q_object);
try { try {
console.log("saved question data", save_question_data, new_question_json_id) console.debug("saved question data", save_question_data, new_question_json_id)
// saved_question_data is undefined if the question is not saved // saved_question_data is undefined if the question is not saved
// we should really just requeue the required question for dowload... // we should really just requeue the required question for dowload...
if (save_question_data == undefined || save_question_data.data.question_json_id != new_question_json_id) { if (save_question_data == undefined || save_question_data.data.question_json_id != new_question_json_id) {
console.log(`INVALIDATE eid: ${saved_exam.eid}, q ${q}`); console.debug(`INVALIDATE eid: ${saved_exam.eid}, q ${q}`);
$(`li.cache-item[data-eid="${saved_exam.eid}"]`).addClass( $(`li.cache-item[data-eid="${saved_exam.eid}"]`).addClass(
"cache-out-of-date" "cache-out-of-date"
); );
@@ -397,9 +397,9 @@ async function loadExamList(data) {
.delete(); .delete();
} }
} catch (e) { } catch (e) {
console.log("Error loading qusetion data", q_object); console.debug("Error loading qusetion data", q_object);
console.log(e); console.debug(e);
console.log("1234", saved_exam.eid); console.debug("1234", saved_exam.eid);
// If the question isn't found in the cache... // If the question isn't found in the cache...
$(`li.cache-item[data-eid="${saved_exam.eid}"]`).addClass( $(`li.cache-item[data-eid="${saved_exam.eid}"]`).addClass(
"cache-out-of-date" "cache-out-of-date"
@@ -462,7 +462,7 @@ async function loadExamList(data) {
// TODO: remove (data formats should be switched to the exam format) // TODO: remove (data formats should be switched to the exam format)
async function loadPacketList(data) { async function loadPacketList(data) {
let sessions = await db.session.toArray().catch(function(error) { let sessions = await db.session.toArray().catch(function(error) {
console.log("Error loading session", error); console.debug("Error loading session", error);
$("#database-error").text( $("#database-error").text(
"Error loading the database, schema has probably changed and needs updating. You will probably need to delete the local database." "Error loading the database, schema has probably changed and needs updating. You will probably need to delete the local database."
); );
@@ -498,7 +498,7 @@ async function loadPacketList(data) {
$("#options-panel").show(); $("#options-panel").show();
return return
} }
//console.log(packet_list) //console.debug(packet_list)
packet_list.forEach(function(packet) { packet_list.forEach(function(packet) {
// Seperate packet types // Seperate packet types
let list; let list;
@@ -532,7 +532,7 @@ async function loadPacketList(data) {
$( $(
`<div class='save-button' title='Download packet for offline use (or to save bandwidth)'><a href='packets/${packet}' download='${packet}'>💾</a></div>` `<div class='save-button' title='Download packet for offline use (or to save bandwidth)'><a href='packets/${packet}' download='${packet}'>💾</a></div>`
).click(function(evt) { ).click(function(evt) {
//console.log("packets/" + packet); //console.debug("packets/" + packet);
evt.stopPropagation(); evt.stopPropagation();
}) })
) )
@@ -552,12 +552,12 @@ function loadPacketFromAjax(path, eid, exam_json_id) {
.get(eid) .get(eid)
.then((exam) => { .then((exam) => {
if (exam == undefined || (exam["exam_json_id"] != exam_json_id)) { if (exam == undefined || (exam["exam_json_id"] != exam_json_id)) {
console.log("AjaxRequestPacket:", eid); console.debug("AjaxRequestPacket:", eid);
ajaxRequestionPacket(true); ajaxRequestionPacket(true);
} else { } else {
// We have an up to date exam in the database // We have an up to date exam in the database
// TODO: check the questions are valid // TODO: check the questions are valid
console.log("LoadLocalPacket:", eid); console.debug("LoadLocalPacket:", eid);
use_local_question_cache = true; use_local_question_cache = true;
setUpPacket(exam, path); setUpPacket(exam, path);
$("#options-panel").hide(); $("#options-panel").hide();
@@ -565,9 +565,9 @@ function loadPacketFromAjax(path, eid, exam_json_id) {
}) })
.catch(function(error) { .catch(function(error) {
// Will be triggered if eid does not exist in database // Will be triggered if eid does not exist in database
console.log("Unable to load exam:", eid); console.debug("Unable to load exam:", eid);
console.log("error-", error); console.debug("error-", error);
console.log("Exam will be downloaded"); console.debug("Exam will be downloaded");
ajaxRequestionPacket(); ajaxRequestionPacket();
}); });
@@ -575,7 +575,7 @@ function loadPacketFromAjax(path, eid, exam_json_id) {
} }
function ajaxRequestionPacket(force_refresh) { function ajaxRequestionPacket(force_refresh) {
//console.log("loading packet from " + path); //console.debug("loading packet from " + path);
$("#progress").html(`Requesting packet: ${path}`); $("#progress").html(`Requesting packet: ${path}`);
let browser_cache = true; let browser_cache = true;
@@ -602,7 +602,7 @@ function loadPacketFromAjax(path, eid, exam_json_id) {
$("#options-panel").hide(); $("#options-panel").hide();
}) })
.fail(function() { .fail(function() {
console.log("Unable to load packet at: " + path); console.debug("Unable to load packet at: " + path);
}); });
} }
} }
@@ -688,7 +688,7 @@ function setUpPacket(data, path) {
var clone_data = Object.assign({}, data, { var clone_data = Object.assign({}, data, {
questions: "cached" questions: "cached"
}); });
console.log(clone_data) console.debug(clone_data)
//clone_data["cached_questions"] = Object.keys(data["questions"]); //clone_data["cached_questions"] = Object.keys(data["questions"]);
question_db.saved_exams.put(clone_data); question_db.saved_exams.put(clone_data);
} }
@@ -735,19 +735,19 @@ function setUpPacket(data, path) {
const question_url = `${path}/${n}`; const question_url = `${path}/${n}`;
//console.log("Creating ", question_url, question_number, question_total); //console.debug("Creating ", question_url, question_number, question_total);
//$("#progress").html(`Downloading [${question_number}/${question_total}]`); //$("#progress").html(`Downloading [${question_number}/${question_total}]`);
let question_json = {}; let question_json = {};
question_json = await interact question_json = await interact
.getQuestion(question_url, question_number, question_total) .getQuestion(question_url, question_number, question_total)
.fail((jqXHR, textStatus, errorThrown) => { .fail((jqXHR, textStatus, errorThrown) => {
//console.log(jqXHR, textStatus, errorThrown); //console.debug(jqXHR, textStatus, errorThrown);
console.log(`error loading question: ${n}`); console.debug(`error loading question: ${n}`);
//data["questions"][n] = {}; //data["questions"][n] = {};
}); });
if (question_json.hasOwnProperty("cached") && question_json["cached"]) { if (question_json.hasOwnProperty("cached") && question_json["cached"]) {
console.log("loading cached packet"); console.debug("loading cached packet");
} }
if ( if (
@@ -776,7 +776,7 @@ function setUpPacket(data, path) {
loadSession(); loadSession();
})().catch((error) => { })().catch((error) => {
alert("Error downloading, try refreshing"); alert("Error downloading, try refreshing");
console.log(error); console.debug(error);
}); });
} else { } else {
// Just carry on loading // Just carry on loading
@@ -785,7 +785,7 @@ function setUpPacket(data, path) {
} }
function loadSession() { function loadSession() {
console.log("load session", exam_details, db.session); console.debug("load session", exam_details, db.session);
// Either continue session or create a new one // Either continue session or create a new one
db.session db.session
// .where("status") // .where("status")
@@ -794,7 +794,7 @@ function loadSession() {
.between([exam_details.eid, Dexie.minKey], [exam_details.eid, Dexie.maxKey]) .between([exam_details.eid, Dexie.minKey], [exam_details.eid, Dexie.maxKey])
.toArray() .toArray()
.then((sessions) => { .then((sessions) => {
//console.log("sessions", sessions); //console.debug("sessions", sessions);
// let active_sessions = []; // let active_sessions = [];
@@ -815,7 +815,7 @@ function loadSession() {
if (exam_details.exam_mode) { if (exam_details.exam_mode) {
text = "Session will be continued"; text = "Session will be continued";
} }
//console.log(sessions.date); //console.debug(sessions.date);
for (let i = 0; i < sessions.length; i++) { for (let i = 0; i < sessions.length; i++) {
let d = new Date(sessions[i].date); let d = new Date(sessions[i].date);
@@ -876,7 +876,7 @@ function loadSession() {
// If cancel is pressed or input is blank // If cancel is pressed or input is blank
exam_details.aid = uuidv4(); exam_details.aid = uuidv4();
date_started = Date.now(); date_started = Date.now();
//console.log("new date", date_started); //console.debug("new date", date_started);
} }
} }
@@ -948,7 +948,7 @@ function setUpQuestions(load_previous) {
// .change(() => { // .change(() => {
// exam_details.cid = parseInt($("#candidate-number2").val()); // exam_details.cid = parseInt($("#candidate-number2").val());
// }); // });
console.log("OTNUHOTNU", global_cid) console.debug("OTNUHOTNU", global_cid)
exam_details.cid = global_cid; exam_details.cid = global_cid;
$("#candidate-number2").val(global_cid) $("#candidate-number2").val(global_cid)
exam_details.passcode = global_passcode; exam_details.passcode = global_passcode;
@@ -990,7 +990,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
const passcode = exam_details.passcode; const passcode = exam_details.passcode;
n = parseInt(n); n = parseInt(n);
//console.log("loading question (n)", n); //console.debug("loading question (n)", n);
if (n == loaded_question && force_reload == false) { if (n == loaded_question && force_reload == false) {
// Question already loaded // Question already loaded
@@ -999,16 +999,16 @@ async function loadQuestion(n, section = 1, force_reload = false) {
return; return;
} }
console.log(exam_details, n); console.debug(exam_details, n);
const qid = exam_details.question_order[n]; const qid = exam_details.question_order[n];
console.log("qid", qid) console.debug("qid", qid)
let q = { let q = {
qid: String(qid), qid: String(qid),
type: question_type type: question_type
}; };
console.log(q) console.debug(q)
console.log(question_db.question_data) console.debug(question_db.question_data)
let return_data = await question_db.question_data.get(q); let return_data = await question_db.question_data.get(q);
const question_data = return_data.data; const question_data = return_data.data;
@@ -1066,7 +1066,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
// disable any further enabled elements // disable any further enabled elements
let enabled_elements = cornerstone.getEnabledElements(); let enabled_elements = cornerstone.getEnabledElements();
for (var i = enabled_elements.length - 1; i >= 0; i--) { for (var i = enabled_elements.length - 1; i >= 0; i--) {
//console.log("disable, ", enabled_elements[i]); //console.debug("disable, ", enabled_elements[i]);
cornerstone.disable(enabled_elements[i].element); cornerstone.disable(enabled_elements[i].element);
} }
$(".canvas-panel").remove(); $(".canvas-panel").remove();
@@ -1084,7 +1084,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
// TODO: figure captions (need to extend base json) // TODO: figure captions (need to extend base json)
function createThumbnail(image, id, caption, thumbnails) { function createThumbnail(image, id, caption, thumbnails) {
//console.log("create thumb", image); //console.debug("create thumb", image);
// For thumbnails we only want a single image // For thumbnails we only want a single image
thumbnails.append( thumbnails.append(
@@ -1255,7 +1255,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
// We chain our db requests as we can only check answers once // We chain our db requests as we can only check answers once
// they have been loaded (should probably use then or after) // they have been loaded (should probably use then or after)
console.log("Load rapid answers") console.debug("Load rapid answers")
db.answers db.answers
.get({ .get({
aid: aid, aid: aid,
@@ -1279,8 +1279,8 @@ async function loadQuestion(n, section = 1, force_reload = false) {
} }
}) })
.catch(function(error) { .catch(function(error) {
console.log("DB", cid, eid, qid); console.debug("DB", cid, eid, qid);
console.log("error-", error); console.debug("error-", error);
}) })
//.then(function() { //.then(function() {
db.answers db.answers
@@ -1299,7 +1299,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
markAnswer(qid, question_data, n); markAnswer(qid, question_data, n);
}) })
.catch(function(error) { .catch(function(error) {
console.log("error-", error); console.debug("error-", error);
}) })
//}); //});
@@ -1367,7 +1367,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
markAnswer(qid, question_data, n); markAnswer(qid, question_data, n);
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.debug(error);
}); });
addFlagEvents(); addFlagEvents();
@@ -1476,7 +1476,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
} }
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.debug(error);
}); });
} }
@@ -1598,7 +1598,7 @@ function rebuildQuestionListPanel() {
// $(".long-answer").text(answer.ans); // $(".long-answer").text(answer.ans);
}) })
.catch(function(error) { .catch(function(error) {
console.log("error - ", error); console.debug("error - ", error);
}); });
db.flags db.flags
@@ -1615,16 +1615,16 @@ function rebuildQuestionListPanel() {
// $(".long-answer").text(answer.ans); // $(".long-answer").text(answer.ans);
}) })
.catch(function(error) { .catch(function(error) {
console.log("error - ", error); console.debug("error - ", error);
}); });
if (review_mode == true) { if (review_mode == true) {
$(".question-panel-ans").remove(); $(".question-panel-ans").remove();
for (const qid in questions_correct) { for (const qid in questions_correct) {
let q_no = exam_details.question_order.indexOf(qid); let q_no = exam_details.question_order.indexOf(qid);
//console.log("q", q_no, qid, questions_correct[qid]); //console.debug("q", q_no, qid, questions_correct[qid]);
let question_list_elements = $(`.question-list-item[data-qid='${q_no}']`); let question_list_elements = $(`.question-list-item[data-qid='${q_no}']`);
//console.log(question_list_elements, questions_correct[qid]); //console.debug(question_list_elements, questions_correct[qid]);
if (questions_correct[qid]) { if (questions_correct[qid]) {
$(`.question-list-item[data-qid='${q_no}']`).append( $(`.question-list-item[data-qid='${q_no}']`).append(
"<span class='question-panel-ans question-panel-correct'>✓</span>" "<span class='question-panel-ans question-panel-correct'>✓</span>"
@@ -1895,7 +1895,7 @@ function reviewQuestions() {
titles.forEach((title, x) => { titles.forEach((title, x) => {
let user_answer = current_answers[`${qid},${+1}`]; let user_answer = current_answers[`${qid},${+1}`];
//console.log(`${qid},${n}`, user_answer); //console.debug(`${qid},${n}`, user_answer);
if (user_answer == undefined) { if (user_answer == undefined) {
user_answer = "Not answered"; user_answer = "Not answered";
} }
@@ -1943,8 +1943,8 @@ function reviewQuestions() {
$("#review-overlay").hide(); $("#review-overlay").hide();
}); });
console.log(db.user_answers) console.debug(db.user_answers)
console.log({ console.debug({
type: question_type, type: question_type,
qid: qid qid: qid
}) })
@@ -2128,7 +2128,7 @@ function reviewQuestions() {
} }
}) })
.catch(function(error) { .catch(function(error) {
console.log("error-", error); console.debug("error-", error);
}) })
.finally(() => { .finally(() => {
// This will lead to saveSession being called after each question is marked // This will lead to saveSession being called after each question is marked
@@ -2148,7 +2148,7 @@ function reviewQuestions() {
}); });
}) })
.catch(function(error) { .catch(function(error) {
console.log("error - ", error); console.debug("error - ", error);
}); });
} }
@@ -2159,7 +2159,7 @@ function reviewQuestions() {
*/ */
function markAnswer(qid, current_question, n) { function markAnswer(qid, current_question, n) {
const type = current_question.type; const type = current_question.type;
console.log("Mark", current_question); console.debug("Mark", current_question);
let option = null; let option = null;
if (review_mode == true) { if (review_mode == true) {
@@ -2219,13 +2219,13 @@ function markAnswer(qid, current_question, n) {
}) })
.toArray() .toArray()
.then(function(saved_user_answers) { .then(function(saved_user_answers) {
//console.log("saved user answers", saved_user_answers) //console.debug("saved user answers", saved_user_answers)
// check if given answer matches a user saved answer // check if given answer matches a user saved answer
if (saved_user_answers != undefined) { if (saved_user_answers != undefined) {
//console.log(saved_user_answers); //console.debug(saved_user_answers);
saved_user_answers.forEach(function(saved_answer_object, n) { saved_user_answers.forEach(function(saved_answer_object, n) {
let saved_answer = saved_answer_object.ans; let saved_answer = saved_answer_object.ans;
//console.log("ua", user_answer, saved_answer); //console.debug("ua", user_answer, saved_answer);
ul.append("<li>" + saved_answer + "</li>"); ul.append("<li>" + saved_answer + "</li>");
if (compareString(saved_answer, user_answer)) { if (compareString(saved_answer, user_answer)) {
textarea.removeClass("incorrect").addClass("correct"); textarea.removeClass("incorrect").addClass("correct");
@@ -2283,7 +2283,7 @@ function markAnswer(qid, current_question, n) {
} }
}) })
.catch(function(error) { .catch(function(error) {
console.log("error-", error); console.debug("error-", error);
}); });
addFeedback(current_question, qid); addFeedback(current_question, qid);
rebuildQuestionListPanel(); rebuildQuestionListPanel();
@@ -2291,7 +2291,7 @@ function markAnswer(qid, current_question, n) {
} }
function addFeedback(current_question, qid) { function addFeedback(current_question, qid) {
console.log(current_question); console.debug(current_question);
if ( if (
current_question.hasOwnProperty("feedback") && current_question.hasOwnProperty("feedback") &&
current_question.feedback.length > 0 current_question.feedback.length > 0
@@ -2346,7 +2346,7 @@ function markCorrect(qid, user_answer, type) {
// db.user_answers.put({ type: type, qid: qid, ans: new_answers }); // db.user_answers.put({ type: type, qid: qid, ans: new_answers });
// }) // })
// .catch(function (error) { // .catch(function (error) {
// console.log("error-", error); // console.debug("error-", error);
// }); // });
if (allow_self_marking) { if (allow_self_marking) {
@@ -2431,7 +2431,7 @@ function loadFlagsFromDb(qid, n) {
} }
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.debug(error);
}); });
} }
@@ -2554,7 +2554,7 @@ $("#btn-delete-answer-databases").click(function(evt) {
setTimeout(() => { setTimeout(() => {
location.reload(); location.reload();
}, 2000); }, 2000);
console.log("Database successfully deleted"); console.debug("Database successfully deleted");
}) })
.catch((err) => { .catch((err) => {
$.notify("Error deleting databases", "error"); $.notify("Error deleting databases", "error");
@@ -2576,7 +2576,7 @@ $("#btn-delete-cached-questions").click(function(evt) {
setTimeout(() => { setTimeout(() => {
location.reload(); location.reload();
}, 2000); }, 2000);
console.log("Database successfully deleted"); console.debug("Database successfully deleted");
}) })
.catch((err) => { .catch((err) => {
$.notify("Error deleting databases", "error"); $.notify("Error deleting databases", "error");
@@ -2617,12 +2617,12 @@ $("#btn-delete-current").click(function(evt) {
// setTimeout(() => { // setTimeout(() => {
// location.reload(); // location.reload();
// }, 2000); // }, 2000);
console.log("Deleted " + deleteCount + " objects"); console.debug("Deleted " + deleteCount + " objects");
}) })
.catch((err) => { .catch((err) => {
$.notify("Error reseting packet", "error"); $.notify("Error reseting packet", "error");
$.notify("You may have to delete all answers this time", "info"); $.notify("You may have to delete all answers this time", "info");
console.log(err); console.debug(err);
}); });
}); });
@@ -2664,7 +2664,7 @@ function saveSession(start_review) {
status = "complete"; status = "complete";
} }
//console.log("save session", score); //console.debug("save session", score);
let time_values = timer.getTimeValues(); let time_values = timer.getTimeValues();
let time_remaining = let time_remaining =
@@ -2716,8 +2716,8 @@ $(document).contextmenu(() => {
// Helper to compare dates // Helper to compare dates
function compareDates(d1, d2) { function compareDates(d1, d2) {
console.log("compare", d1, d2); console.debug("compare", d1, d2);
console.log("compare striped", Date.parse(d1.split("+")[0]), Date.parse(d2.split("+")[0])); console.debug("compare striped", Date.parse(d1.split("+")[0]), Date.parse(d2.split("+")[0]));
console.log("compare striped", Date.parse(d1.split("+")[0]), Date.parse(d2.split("+")[0])); console.debug("compare striped", Date.parse(d1.split("+")[0]), Date.parse(d2.split("+")[0]));
return Date.parse(d1.split("+")[0]) != Date.parse(d2.split("+")[0]); return Date.parse(d1.split("+")[0]) != Date.parse(d2.split("+")[0]);
} }
+3 -3
View File
@@ -409,7 +409,7 @@ export function changeControlSelection() {
* @param {*} event - KeyEvent * @param {*} event - KeyEvent
*/ */
export function keydown_handler(event) { export function keydown_handler(event) {
//console.log(event); //console.debug(event);
const target_element = event.target.tagName; const target_element = event.target.tagName;
// Cancel if no active element // Cancel if no active element
@@ -588,7 +588,7 @@ export function openMainImage(current_question, t, source) {
toolStateManager.restoreToolState(tool_state); toolStateManager.restoreToolState(tool_state);
} }
async function load(images, annotations) { async function load(images, annotations) {
//console.log("Load function", images) //console.debug("Load function", images)
const imageIds = []; const imageIds = [];
for (let i = 0; i < images.length; i++) { for (let i = 0; i < images.length; i++) {
const data_url = images[i]; const data_url = images[i];
@@ -633,7 +633,7 @@ export function openMainImage(current_question, t, source) {
if (/(?:\/|^)[^.\/]+$/.test(url)) { if (/(?:\/|^)[^.\/]+$/.test(url)) {
url = "wadouri:" + url; url = "wadouri:" + url;
} }
//console.log(url) //console.debug(url)
loadAnnotation(url, annotation); loadAnnotation(url, annotation);