From 2c8cdf5fb56f0f529a4f39b09eddd96075c03449 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 10:50:34 +0100 Subject: [PATCH 01/48] . --- index.html | 1 + js/main.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/index.html b/index.html index 8ee7df7..5ddf58c 100644 --- a/index.html +++ b/index.html @@ -64,6 +64,7 @@

RTS

+

Available Packets (click to load):

diff --git a/js/main.js b/js/main.js index 8f29e68..ce09307 100644 --- a/js/main.js +++ b/js/main.js @@ -146,6 +146,12 @@ async function loadExamList(data) { $("#database-error").show(); }); + //Display user info if it exists + if (data.hasOwnProperty("user") && data.user) { + $("#user").append(data.user); + } + + let exams_started = []; let exams_completed = []; sessions.forEach((s) => { From 794bbe5df8ba3e63a991c9af33a91a02f86e752f Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:01:04 +0100 Subject: [PATCH 02/48] . --- css/main.css | 20 +++++++++++++++++++- index.html | 2 +- js/main.js | 6 +++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/css/main.css b/css/main.css index 3cc6f56..37ca734 100644 --- a/css/main.css +++ b/css/main.css @@ -1095,4 +1095,22 @@ display: block .cache-out-of-date { color: red; - } \ No newline at end of file + } + +.user-text { + color: darkslateblue; +} + +.inactive { + transform: rotate(12deg); + color: #555; + font-size: 3rem; + font-weight: 700; + border: 0.25rem solid #555; + display: inline-block; + padding: 0.25rem 1rem; + text-transform: uppercase; + border-radius: 1rem; + font-family: 'Courier'; + mix-blend-mode: multiply; +} \ No newline at end of file diff --git a/index.html b/index.html index 5ddf58c..cc7017c 100644 --- a/index.html +++ b/index.html @@ -64,7 +64,7 @@

RTS

-
+

Available Packets (click to load):

diff --git a/js/main.js b/js/main.js index ce09307..8ebda26 100644 --- a/js/main.js +++ b/js/main.js @@ -148,7 +148,7 @@ async function loadExamList(data) { //Display user info if it exists if (data.hasOwnProperty("user") && data.user) { - $("#user").append(data.user); + $("#user").append(`User: ${data.user}`); } @@ -191,6 +191,10 @@ async function loadExamList(data) { c = " session-completed"; } + if (!exam.active) { + c = c + " inactive"; + } + let list; if (exam.type != undefined) { if ($(`#packet-list .${exam.type}`).length) { From fcb62776af477741874f7dfda6fd3c7ac523e766 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:04:02 +0100 Subject: [PATCH 03/48] . --- css/main.css | 3 ++- js/main.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/css/main.css b/css/main.css index 37ca734..93da4b3 100644 --- a/css/main.css +++ b/css/main.css @@ -1101,7 +1101,8 @@ display: block color: darkslateblue; } -.inactive { +.inactive::after { + content: "inactive"; transform: rotate(12deg); color: #555; font-size: 3rem; diff --git a/js/main.js b/js/main.js index 8ebda26..fa3597b 100644 --- a/js/main.js +++ b/js/main.js @@ -191,7 +191,7 @@ async function loadExamList(data) { c = " session-completed"; } - if (!exam.active) { + if (!exam.exam_active) { c = c + " inactive"; } From e5cf7805ad568d61df797baf958d98bdbcc6daaf Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:09:46 +0100 Subject: [PATCH 04/48] . --- css/main.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/css/main.css b/css/main.css index 93da4b3..d202af1 100644 --- a/css/main.css +++ b/css/main.css @@ -1103,11 +1103,11 @@ display: block .inactive::after { content: "inactive"; - transform: rotate(12deg); - color: #555; - font-size: 3rem; - font-weight: 700; - border: 0.25rem solid #555; + transform: translateX(-100%) rotate(12deg); + color: red; + font-size: 2rem; + font-weight: 900; + border: 0.25rem solid red; display: inline-block; padding: 0.25rem 1rem; text-transform: uppercase; From 57b88c81b8fa9471e2402dd98cf389d853681809 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:13:41 +0100 Subject: [PATCH 05/48] . --- css/main.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/css/main.css b/css/main.css index d202af1..0603156 100644 --- a/css/main.css +++ b/css/main.css @@ -1105,13 +1105,13 @@ display: block content: "inactive"; transform: translateX(-100%) rotate(12deg); color: red; - font-size: 2rem; + font-size: 1rem; font-weight: 900; border: 0.25rem solid red; display: inline-block; - padding: 0.25rem 1rem; + /* padding: 0.25rem 1rem; */ text-transform: uppercase; border-radius: 1rem; font-family: 'Courier'; - mix-blend-mode: multiply; + /* mix-blend-mode: multiply; */ } \ No newline at end of file From 8f229362dc9f6de0431494cc1b657b08c7ec5862 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:14:21 +0100 Subject: [PATCH 06/48] . --- css/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/main.css b/css/main.css index 0603156..a29eba8 100644 --- a/css/main.css +++ b/css/main.css @@ -1103,7 +1103,7 @@ display: block .inactive::after { content: "inactive"; - transform: translateX(-100%) rotate(12deg); + transform: rotate(19deg); color: red; font-size: 1rem; font-weight: 900; From 2efc892779f57d412727147b19a542b4d6995b68 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:21:43 +0100 Subject: [PATCH 07/48] . --- css/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/main.css b/css/main.css index a29eba8..d57b6c7 100644 --- a/css/main.css +++ b/css/main.css @@ -831,7 +831,7 @@ select option:disabled { transition: all 0.2s; } -.packet-button.cached:after{ +.packet-button.cached:before{ content: "cached"; width: 12px; height: 12px; From 26b3410ad8ea363f9df808ac566a5cb116e46245 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:22:25 +0100 Subject: [PATCH 08/48] . --- css/main.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/css/main.css b/css/main.css index d57b6c7..bff0129 100644 --- a/css/main.css +++ b/css/main.css @@ -831,7 +831,7 @@ select option:disabled { transition: all 0.2s; } -.packet-button.cached:before{ +.packet-button.cached:after{ content: "cached"; width: 12px; height: 12px; @@ -1101,7 +1101,7 @@ display: block color: darkslateblue; } -.inactive::after { +.inactive::before { content: "inactive"; transform: rotate(19deg); color: red; From 054b480d88c7ae8ce5a303dff717d27fd83d6ca8 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Aug 2021 11:40:11 +0100 Subject: [PATCH 09/48] disable option button --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index cc7017c..24c1462 100644 --- a/index.html +++ b/index.html @@ -19,8 +19,8 @@

RTS

+
-

Available Packets (click to load):

+

Click buttons below to load an exam / packet

+ + +

Available Packets:

@@ -75,28 +85,28 @@
-
- -
    -
-
+
+ +
    +
+
- Options -
- - -
-
-
+ Options +
+ + +
+
+ -
-

Load local question set

- - -
- -
+
+

Load local question set

+ + +
+ +
@@ -138,7 +148,7 @@
@@ -153,12 +163,13 @@
-
' ); ap.append( '' + display_n + + '.2Reason

' ); // Handle changing display of optional answer fields and saving of data - $("#rapid-option").change(function (evt) { + $("#rapid-option").change(function(evt) { if (evt.target.value == "Abnormal") { $("#rapid-text").css("display", "block"); } else { @@ -1083,6 +1147,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { eid: eid, qid: qid, qidn: "1", + passcode: passcode, ans: evt.target.value, }; @@ -1092,14 +1157,14 @@ async function loadQuestion(n, section = 1, force_reload = false) { }); // Save long answers on textchange - $(".long-answer").change(function (evt) { + $(".long-answer").change(function(evt) { // ignore blank text and delete any stored value if (evt.target.value.length < 1) { db.answers.delete([aid, cid, eid, qid, "2"]); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-2" + exam_details.question_order.indexOf(qid) + + "-2" ).removeClass("question-saved-localdb"); return; } @@ -1110,6 +1175,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { eid: eid, qid: qid, qidn: "2", + passcode: passcode, ans: evt.target.value, }; // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); @@ -1117,8 +1183,8 @@ async function loadQuestion(n, section = 1, force_reload = false) { $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-2" + exam_details.question_order.indexOf(qid) + + "-2" ).addClass("question-saved-localdb"); saveSession(); @@ -1129,8 +1195,15 @@ async function loadQuestion(n, section = 1, force_reload = false) { // they have been loaded (should probably use then or after) db.answers - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" }) - .then(function (answer) { + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + passcode: passcode, + qidn: "1" + }) + .then(function(answer) { if (answer != undefined) { $("#rapid-option option:contains(" + answer.ans + ")").prop( "selected", @@ -1143,22 +1216,29 @@ async function loadQuestion(n, section = 1, force_reload = false) { $("#rapid-option-not-answered").remove(); } }) - .catch(function (error) { + .catch(function(error) { console.log("DB", cid, eid, qid); console.log("error-", error); }) .then( db.answers - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "2" }) - .then(function (answer) { - if (answer != undefined) { - $(".long-answer").text(answer.ans); - } - markAnswer(qid, question_data, n); - }) - .catch(function (error) { - console.log("error-", error); - }) + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: "2", + passcode: passcode, + }) + .then(function(answer) { + if (answer != undefined) { + $(".long-answer").text(answer.ans); + } + markAnswer(qid, question_data, n); + }) + .catch(function(error) { + console.log("error-", error); + }) ); addFlagEvents(); @@ -1170,22 +1250,22 @@ async function loadQuestion(n, section = 1, force_reload = false) { case "anatomy": { ap.append( '

' + - display_n + - '.1' + - question_data.question + - '

' + display_n + + '.1' + + question_data.question + + '

' ); - $(".long-answer").change(function (evt) { + $(".long-answer").change(function(evt) { // ignore blank text and delete any stored value if (evt.target.value.length < 1) { db.answers.delete([aid, cid, eid, qid, "1"]); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-1" + exam_details.question_order.indexOf(qid) + + "-1" ).removeClass("question-saved-localdb"); return; } @@ -1196,29 +1276,35 @@ async function loadQuestion(n, section = 1, force_reload = false) { eid: eid, qid: qid, qidn: "1", + passcode: passcode, ans: evt.target.value, }; - // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); db.answers.put(answer); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-1" + exam_details.question_order.indexOf(qid) + + "-1" ).addClass("question-saved-localdb"); saveSession(); updateQuestionListPanel(answer); }); db.answers - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" }) - .then(function (answer) { + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: "1" + }) + .then(function(answer) { if (answer != undefined) { $(".long-answer").text(answer.ans); } markAnswer(qid, question_data, n); }) - .catch(function (error) { + .catch(function(error) { console.log(error); }); @@ -1231,42 +1317,42 @@ async function loadQuestion(n, section = 1, force_reload = false) { case "long": { ap.append( '

' + - display_n + - '.1Observations

' + display_n + + '.1Observations

' ); ap.append( '

' + - display_n + - '.2Interpretation

' + display_n + + '.2Interpretation

' ); ap.append( '

' + - display_n + - '.3Principal Diagnosis

' + display_n + + '.3Principal Diagnosis

' ); ap.append( '

' + - display_n + - '.4Differential Diagnosis

' + display_n + + '.4Differential Diagnosis

' ); ap.append( '

' + - display_n + - '.5Management (if appropriate)

' + display_n + + '.5Management (if appropriate)

' ); // Save long answers on textchange - $(".long-answer").change(function (evt) { + $(".long-answer").change(function(evt) { const qidn = evt.target.dataset.qidn.toString(); // ignore blank text and delete any stored value @@ -1274,19 +1360,19 @@ async function loadQuestion(n, section = 1, force_reload = false) { db.answers.delete([aid, cid, eid, qid, qidn]); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-" + - qidn + exam_details.question_order.indexOf(qid) + + "-" + + qidn ).removeClass("question-saved-localdb"); return; } - // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); const answer = { aid: aid, cid: cid, eid: eid, qid: qid, qidn: qidn, + passcode: passcode, ans: evt.target.value, }; @@ -1294,9 +1380,9 @@ async function loadQuestion(n, section = 1, force_reload = false) { $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-" + - qidn + exam_details.question_order.indexOf(qid) + + "-" + + qidn ).addClass("question-saved-localdb"); saveSession(); updateQuestionListPanel(answer); @@ -1316,7 +1402,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { }; db.answers .get(obj) - .then(function (answer) { + .then(function(answer) { if (answer != undefined) { $(".long-answer") .eq(parseInt(answer.qidn) - 1) @@ -1327,7 +1413,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { markAnswer(qid, question_data, n); } }) - .catch(function (error) { + .catch(function(error) { console.log(error); }); } @@ -1379,23 +1465,23 @@ function setFocus(section) { function updateQuestionListPanel(answer) { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-" + - answer.qidn + exam_details.question_order.indexOf(answer.qid) + + "-" + + answer.qidn ).addClass("question-saved-localdb"); if (question_type == "rapid" && answer.qidn == "1") { if (answer.ans == "Abnormal") { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-2" + exam_details.question_order.indexOf(answer.qid) + + "-2" ).css("display", "block"); } else { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-2" + exam_details.question_order.indexOf(answer.qid) + + "-2" ).css("display", "none"); } } @@ -1404,20 +1490,20 @@ function updateQuestionListPanel(answer) { function deleteQuestionListPanelFlags(answer) { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-" + - answer.qidn + - " span" + exam_details.question_order.indexOf(answer.qid) + + "-" + + answer.qidn + + " span" ).css("visibility", "hidden"); } function updateQuestionListPanelFlags(answer) { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-" + - answer.qidn + - " span" + exam_details.question_order.indexOf(answer.qid) + + "-" + + answer.qidn + + " span" ).css("visibility", "visible"); } /** @@ -1431,34 +1517,42 @@ function rebuildQuestionListPanel() { const eid = exam_details.eid; db.answers - .where({ aid: aid, cid: cid, eid: eid }) + .where({ + aid: aid, + cid: cid, + eid: eid + }) .toArray() - .then(function (answers) { + .then(function(answers) { // Reset all classes (of question-list-item s) $(".question-list-panel div") .slice(1) .attr("class", "question-list-item"); // Loop through each saved answer - answers.forEach(function (answer, n) { + answers.forEach(function(answer, n) { updateQuestionListPanel(answer); }); // $(".long-answer").text(answer.ans); }) - .catch(function (error) { + .catch(function(error) { console.log("error - ", error); }); db.flags - .where({ aid: aid, cid: cid, eid: eid }) + .where({ + aid: aid, + cid: cid, + eid: eid + }) .toArray() - .then(function (answers) { - answers.forEach(function (answer, n) { + .then(function(answers) { + answers.forEach(function(answer, n) { updateQuestionListPanelFlags(answer); }); // $(".long-answer").text(answer.ans); }) - .catch(function (error) { + .catch(function(error) { console.log("error - ", error); }); @@ -1501,18 +1595,18 @@ function createQuestionListPanel() { const qn = n - 1; const el = $( '
' + - n + - "." + - qidn + - '
' + qn + + "-" + + qidn + + '" data-qid=' + + qn + + ' data-qidn="' + + qidn + + '" class="question-list-item">' + + n + + "." + + qidn + + '' ); $(".question-list-panel").append(el); // return the new element so it can be hidden if necessary @@ -1539,31 +1633,31 @@ function createQuestionListPanel() { } } - $(".question-list-item").click(function (evt) { + $(".question-list-item").click(function(evt) { loadQuestion($(this).attr("data-qid"), $(this).attr("data-qidn")); }); rebuildQuestionListPanel(); } -$("#btn-local-file-load").click(function (evt) { +$("#btn-local-file-load").click(function(evt) { loadLocalQuestionSet(); }); -$(".submit-button").click(function (evt) { +$(".submit-button").click(function(evt) { interact.submitAnswers(exam_details, db, config); }); -$("#review-button").click(function (evt) { +$("#review-button").click(function(evt) { $(".question-list-panel").toggle(); }); -$("#options-button").click(function (evt) { +$("#options-button").click(function(evt) { loadPacketList(null); $("#options-panel").toggle(); }); -$("#review-overlay-button").click(function (evt) { +$("#review-overlay-button").click(function(evt) { if (review_mode == true) { reviewQuestions(); } else { @@ -1571,7 +1665,7 @@ $("#review-overlay-button").click(function (evt) { } }); -$("#fullscreen-overlay-button").click(function (evt) { +$("#fullscreen-overlay-button").click(function(evt) { if (document.fullscreen == false) { document.documentElement.requestFullscreen(); } else { @@ -1579,25 +1673,25 @@ $("#fullscreen-overlay-button").click(function (evt) { } }); -$("#finish-exam, #time-up-review-button").click(function (evt) { +$("#finish-exam, #time-up-review-button").click(function(evt) { review_mode = true; reviewQuestions(); $.modal.close(); }); -$("#time-up-continue-button").click(function (evt) { +$("#time-up-continue-button").click(function(evt) { $.modal.close(); }); -$("#finish-cancel").click(function (evt) { +$("#finish-cancel").click(function(evt) { $.modal.close(); }); -$("#overlay-close").click(function (evt) { +$("#overlay-close").click(function(evt) { $("#options-panel").hide(); }); -$("#review-overlay-close").click(function (evt) { +$("#review-overlay-close").click(function(evt) { $("#review-overlay").hide(); }); @@ -1664,11 +1758,15 @@ function reviewQuestions() { loadQuestion(0, 0, true); db.answers - .where({ aid: aid, cid: cid, eid: eid }) + .where({ + aid: aid, + cid: cid, + eid: eid + }) .toArray() - .then(function (answers) { + .then(function(answers) { let current_answers = {}; - answers.forEach(function (arr, n) { + answers.forEach(function(arr, n) { let answer = arr["ans"]; if (answer == undefined) { answer = "Not answered"; @@ -1684,8 +1782,11 @@ function reviewQuestions() { let undercall_number = 0; let overcall_number = 0; let incorrectcall_number = 0; - exam_details.question_order.forEach(async function (qid, n) { - const q_object = { qid: String(qid), type: question_type }; + exam_details.question_order.forEach(async function(qid, n) { + const q_object = { + qid: String(qid), + type: question_type + }; let question = await question_db.question_data.get(q_object); question = question.data; if (question_type == "long") { @@ -1753,12 +1854,12 @@ function reviewQuestions() { // TOOD fix $("#review-answer-table tr") - .sort(function (a, b) { - return a.dataset.qid > b.dataset.qid - ? 1 - : a.dataset.qid < b.dataset.qid - ? -1 - : 0; + .sort(function(a, b) { + return a.dataset.qid > b.dataset.qid ? + 1 : + a.dataset.qid < b.dataset.qid ? + -1 : + 0; }) .appendTo("#review-answer-table"); return; @@ -1766,24 +1867,27 @@ function reviewQuestions() { $("#review-answer-list").append( "
  • Question " + - (n + 1) + - ": Not answered
  • " + qid + + "' data-qid=" + + n.toString().padStart(2, "0") + + "'>Question " + + (n + 1) + + ": Not answered" ); - $("#review-answer-list a").click(function (evt) { + $("#review-answer-list a").click(function(evt) { loadQuestion(this.dataset.qid); $("#review-overlay").hide(); }); db.user_answers - .where({ type: question_type, qid: qid }) + .where({ + type: question_type, + qid: qid + }) .toArray() - .then(function (answers) { + .then(function(answers) { // Merge the question answers with the user saved answers let question_answers = question["answers"]; if (answers != undefined) { @@ -1831,20 +1935,20 @@ function reviewQuestions() { if (normal) { el.html( "Answer: " + - user_answer + - " (Normal)" + c + + "'>Answer: " + + user_answer + + " (Normal)" ); } else { el.html( "Answer: " + - user_answer + - " (Abnormal: " + - question_answers.join(", ") + - ")" + c + + "'>Answer: " + + user_answer + + " (Abnormal: " + + question_answers.join(", ") + + ")" ); } } @@ -1896,8 +2000,7 @@ function reviewQuestions() { ); questions_correct[qid] = false; - if (section_1_answer == "Not Answered") { - } else if (section_1_answer == "Normal") { + if (section_1_answer == "Not Answered") {} else if (section_1_answer == "Normal") { undercall_number++; } else { // Incorrect calls could be correct if @@ -1941,9 +2044,9 @@ function reviewQuestions() { $("#review-score").text( "Score: " + - correct_count + - " out of " + - exam_details.question_order.length + correct_count + + " out of " + + exam_details.question_order.length ); if (question_type == "rapid") { @@ -1958,7 +2061,7 @@ function reviewQuestions() { $("#exam-stats").show(); } }) - .catch(function (error) { + .catch(function(error) { console.log("error-", error); }) .finally(() => { @@ -1967,18 +2070,18 @@ function reviewQuestions() { rebuildQuestionListPanel(); $("#review-answer-list li") - .sort(function (a, b) { - return a.dataset.qid > b.dataset.qid - ? 1 - : a.dataset.qid < b.dataset.qid - ? -1 - : 0; + .sort(function(a, b) { + return a.dataset.qid > b.dataset.qid ? + 1 : + a.dataset.qid < b.dataset.qid ? + -1 : + 0; }) .appendTo("#review-answer-list"); }); }); }) - .catch(function (error) { + .catch(function(error) { console.log("error - ", error); }); } @@ -2044,13 +2147,16 @@ function markAnswer(qid, current_question, n) { // Load user saved answers db.user_answers - .where({ type: type, qid: qid }) + .where({ + type: type, + qid: qid + }) .toArray() - .then(function (saved_user_answers) { + .then(function(saved_user_answers) { // check if given answer matches a user saved answer if (saved_user_answers != undefined) { //console.log(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; //console.log("ua", user_answer, saved_answer); ul.append("
  • " + saved_answer + "
  • "); @@ -2078,7 +2184,7 @@ function markAnswer(qid, current_question, n) { } // check if given answer matches an answer from the question - current_question.answers.forEach(function (answer, n) { + current_question.answers.forEach(function(answer, n) { ul.append("
  • " + answer + "
  • "); if (compareString(answer, user_answer)) { textarea.removeClass("incorrect").addClass("correct"); @@ -2099,7 +2205,7 @@ function markAnswer(qid, current_question, n) { if (allow_self_marking) { $(".answer-panel").append( $("").click( - function () { + function() { markCorrect(qid, user_answer, type); loadQuestion(n, 0, true); } @@ -2109,7 +2215,7 @@ function markAnswer(qid, current_question, n) { } } }) - .catch(function (error) { + .catch(function(error) { console.log("error-", error); }); addFeedback(current_question, qid); @@ -2126,8 +2232,8 @@ function addFeedback(current_question, qid) { $(".answer-panel").append( $( "

    Feedback

    " + - current_question.feedback + - "
    " + current_question.feedback + + "" ) ); } @@ -2192,8 +2298,8 @@ function compareString(a, b) { function answerInArray(arr, ans) { return ( arr - .map((v) => v.toLowerCase().replace(/\s/g, "")) - .includes(ans.toLowerCase().replace(/\s/g, "")) == true + .map((v) => v.toLowerCase().replace(/\s/g, "")) + .includes(ans.toLowerCase().replace(/\s/g, "")) == true ); } @@ -2203,7 +2309,7 @@ function addFlagEvents() { const eid = exam_details.eid; // Bind flag change events - $("button.flag").click(function (event) { + $("button.flag").click(function(event) { const el = $(this); const nqid = el.attr("data-qid"); const qid = exam_details.question_order[nqid]; @@ -2211,7 +2317,13 @@ function addFlagEvents() { el.toggleClass("flag flag-selected"); - const flag_db_data = { aid: aid, cid: cid, eid: eid, qid: qid, qidn: qidn }; + const flag_db_data = { + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: qidn + }; if (el.hasClass("flag")) { $("#question-list-item-" + nqid + "-" + qidn + " span").css( @@ -2237,15 +2349,21 @@ function loadFlagsFromDb(qid, n) { const cid = exam_details.cid; const eid = exam_details.eid; db.flags - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: n }) - .then(function (answer) { + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: n + }) + .then(function(answer) { if (answer != undefined) { $("button.flag, button.flag-selected") .eq(parseInt(answer.qidn) - 1) .toggleClass("flag flag-selected"); } }) - .catch(function (error) { + .catch(function(error) { console.log(error); }); } @@ -2254,12 +2372,32 @@ function showLoginDialog() { $("#login-dialog").modal(); } -$("#start-exam-button").click(function (evt) { - exam_details.cid = parseInt($("#candidate-number").val()); +$("#btn-candidate-login").click(function(evt) { + $("#login-dialog").modal({ + escapeClose: false, + clickClose: false, + showClose: false + }); + $("#options-panel").toggle(); + $(".exam-wrapper").toggle(); +}); + + +$("#login-button").click(function(evt) { + global_cid = parseInt($("#candidate-number").val()); + global_passcode = $("#passcode").val(); + + user_db.user.clear().then(() => { + user_db.user.add({ + cid: global_cid, + passcode: global_passcode + }) + location.reload(); + }); $.modal.close(); }); -$(".start-packet-button").click(function (evt) { +$(".start-packet-button").click(function(evt) { if (exam_details.exam_mode) { if (!Number.isInteger(parseInt($("#candidate-number2").val()))) { alert("Please enter a valid candidate number."); @@ -2274,11 +2412,16 @@ $(".start-packet-button").click(function (evt) { timer = new easytimer.Timer(); //exam_time = 2; - timer.start({ countdown: true, startValues: { seconds: exam_time } }); - timer.addEventListener("secondsUpdated", function (e) { + timer.start({ + countdown: true, + startValues: { + seconds: exam_time + } + }); + timer.addEventListener("secondsUpdated", function(e) { $("#timer").html("Time left: " + timer.getTimeValues().toString()); }); - timer.addEventListener("targetAchieved", function (e) { + timer.addEventListener("targetAchieved", function(e) { if (exam_details.exam_mode == true) { $( "#dialog-submit-button, #time-up-review-button, #time-up-continue-button" @@ -2336,7 +2479,7 @@ $(".start-packet-button").click(function (evt) { $.modal.close(); }); -$("#btn-delete-answer-databases").click(function (evt) { +$("#btn-delete-answer-databases").click(function(evt) { var r = confirm( "This will delete ALL saved answers (including saved correct answers)!" ); @@ -2357,10 +2500,9 @@ $("#btn-delete-answer-databases").click(function (evt) { .finally(() => { // Do what should be done next... }); - } else { - } + } else {} }); -$("#btn-delete-cached-questions").click(function (evt) { +$("#btn-delete-cached-questions").click(function(evt) { var r = confirm("Delete cached questions?"); if (r == true) { question_db @@ -2380,11 +2522,10 @@ $("#btn-delete-cached-questions").click(function (evt) { .finally(() => { // Do what should be done next... }); - } else { - } + } else {} }); -$("#btn-delete-current").click(function (evt) { +$("#btn-delete-current").click(function(evt) { if (exam_details.question_order.length < 1) { $.notify("No packet is currently loaded", "warn"); return; @@ -2394,7 +2535,7 @@ $("#btn-delete-current").click(function (evt) { .where("qid") .anyOf(exam_details.question_order) .delete() - .then(function (deleteCount) { + .then(function(deleteCount) { $.notify("Packet flags deleted", "success"); }) .catch((err) => { @@ -2406,7 +2547,7 @@ $("#btn-delete-current").click(function (evt) { .where("qid") .anyOf(exam_details.question_order) .delete() - .then(function (deleteCount) { + .then(function(deleteCount) { $.notify("Packet successfully reset", "success"); loadQuestion(0, 0, true); // $.notify("The page will now reload", "warn"); @@ -2422,7 +2563,7 @@ $("#btn-delete-current").click(function (evt) { }); }); -$("#btn-delete-current-saved-answers").click(function (evt) { +$("#btn-delete-current-saved-answers").click(function(evt) { if (exam_details.question_order.length < 1) { $.notify("No packet is currently loaded", "warn"); return; @@ -2433,7 +2574,7 @@ $("#btn-delete-current-saved-answers").click(function (evt) { .where("qid") .anyOf(exam_details.question_order) .delete() - .then(function (deleteCount) { + .then(function(deleteCount) { $.notify("Packet answers deleted", "success"); }) .catch((err) => { @@ -2442,11 +2583,11 @@ $("#btn-delete-current-saved-answers").click(function (evt) { }); }); -$(document).ajaxStart(function () { +$(document).ajaxStart(function() { $("#loading").show(); }); -$(document).ajaxStop(function () { +$(document).ajaxStop(function() { $("#loading").hide(); }); @@ -2472,6 +2613,7 @@ function saveSession(start_review) { eid: exam_details.eid, aid: exam_details.aid, cid: exam_details.cid, + passcode: exam_details.passcode, status: status, date: date_started, score: score, @@ -2511,4 +2653,4 @@ function compareDates(d1, d2) { console.log("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])); return Date.parse(d1.split("+")[0]) != Date.parse(d2.split("+")[0]); -} +} \ No newline at end of file From dc5f514f7ab7585dec3e0944d4c0834e5976cbbd Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:00:53 +0000 Subject: [PATCH 24/48] . --- js/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/main.js b/js/main.js index 8fc907d..bdb9129 100644 --- a/js/main.js +++ b/js/main.js @@ -139,6 +139,12 @@ async function retrievePacketList() { loadPacketList(data); } }, + error: function(httpObj, textStatus) { + if (httpObj.status==401) { + $.notify("Unable to login", "error"); + + } + }, }) .done(function() {}) .fail(function() { From 4a6487fcef094fd8e2294f995808165abcccd5a6 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:03:12 +0000 Subject: [PATCH 25/48] . --- js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index bdb9129..6651e44 100644 --- a/js/main.js +++ b/js/main.js @@ -140,9 +140,9 @@ async function retrievePacketList() { } }, error: function(httpObj, textStatus) { - if (httpObj.status==401) { + if (httpObj.status == 401 || httpObj.status == 404) { $.notify("Unable to login", "error"); - + } }, }) From 7803c9d0e5142595890bc2efb050eaae9fa37c42 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:06:13 +0000 Subject: [PATCH 26/48] . --- js/main.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/js/main.js b/js/main.js index 6651e44..641863d 100644 --- a/js/main.js +++ b/js/main.js @@ -142,23 +142,22 @@ async function retrievePacketList() { error: function(httpObj, textStatus) { if (httpObj.status == 401 || httpObj.status == 404) { $.notify("Unable to login", "error"); - } }, }) .done(function() {}) - .fail(function() { - $.getJSON("packets", function(data) { - if (data.hasOwnProperty("exams")) { - loadExamList(data); - } else { - loadPacketList(data); - } - }).fail(function(jqXHR, textStatus, errorThrown) { - console.log("No packet list available"); - showLoginDialog(); - }); - }) + //.fail(function() { + // $.getJSON("packets", function(data) { + // if (data.hasOwnProperty("exams")) { + // loadExamList(data); + // } else { + // loadPacketList(data); + // } + // }).fail(function(jqXHR, textStatus, errorThrown) { + // console.log("No packet list available"); + // showLoginDialog(); + // }); + //}) .always(function() {}); } From e5b6d61046f11a0d039ea32085eb8359103a6d34 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:07:57 +0000 Subject: [PATCH 27/48] . --- js/main.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/js/main.js b/js/main.js index 641863d..438d505 100644 --- a/js/main.js +++ b/js/main.js @@ -146,18 +146,21 @@ async function retrievePacketList() { }, }) .done(function() {}) - //.fail(function() { - // $.getJSON("packets", function(data) { - // if (data.hasOwnProperty("exams")) { - // loadExamList(data); - // } else { - // loadPacketList(data); - // } - // }).fail(function(jqXHR, textStatus, errorThrown) { - // console.log("No packet list available"); - // showLoginDialog(); - // }); - //}) + .fail(function() { + $.getJSON("packets", function(data) { + if (data.hasOwnProperty("exams")) { + loadExamList(data); + } else { + loadPacketList(data); + } + }).fail(function(jqXHR, textStatus, errorThrown) { + console.log("No packet list available"); + if (jqXHR.status == 401 || jqXHR.status == 404) { + $.notify("Unable to login", "error"); + } + //showLoginDialog(); + }); + }) .always(function() {}); } From d34caacbaedfbaf18f0265020ea339623e735a14 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:09:26 +0000 Subject: [PATCH 28/48] . --- js/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/main.js b/js/main.js index 438d505..e26ee12 100644 --- a/js/main.js +++ b/js/main.js @@ -140,6 +140,7 @@ async function retrievePacketList() { } }, error: function(httpObj, textStatus) { + console.log(httpObj); if (httpObj.status == 401 || httpObj.status == 404) { $.notify("Unable to login", "error"); } From 2ece556666e46576e2a716c6b6eca5d0210b979a Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:13:05 +0000 Subject: [PATCH 29/48] . --- js/main.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/main.js b/js/main.js index e26ee12..795c243 100644 --- a/js/main.js +++ b/js/main.js @@ -143,6 +143,7 @@ async function retrievePacketList() { console.log(httpObj); if (httpObj.status == 401 || httpObj.status == 404) { $.notify("Unable to login", "error"); + $("options-panel").show() } }, }) @@ -156,9 +157,6 @@ async function retrievePacketList() { } }).fail(function(jqXHR, textStatus, errorThrown) { console.log("No packet list available"); - if (jqXHR.status == 401 || jqXHR.status == 404) { - $.notify("Unable to login", "error"); - } //showLoginDialog(); }); }) From 04603a2a529696157640384a878c9de303b65682 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:13:33 +0000 Subject: [PATCH 30/48] . --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 795c243..ff1a19c 100644 --- a/js/main.js +++ b/js/main.js @@ -143,7 +143,7 @@ async function retrievePacketList() { console.log(httpObj); if (httpObj.status == 401 || httpObj.status == 404) { $.notify("Unable to login", "error"); - $("options-panel").show() + $("#options-panel").show() } }, }) From 0b2ed3159870efc69de73afabb0e6129ef8f622f Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 18:17:10 +0000 Subject: [PATCH 31/48] . --- css/main.css | 4 ++++ js/main.js | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/css/main.css b/css/main.css index 3d76a45..f864045 100644 --- a/css/main.css +++ b/css/main.css @@ -1182,4 +1182,8 @@ select option:disabled { opacity: 30%; margin-left: -2em; position: absolute; +} + +.invalid-login { + color: red; } \ No newline at end of file diff --git a/js/main.js b/js/main.js index ff1a19c..c1928a1 100644 --- a/js/main.js +++ b/js/main.js @@ -143,7 +143,8 @@ async function retrievePacketList() { console.log(httpObj); if (httpObj.status == 401 || httpObj.status == 404) { $.notify("Unable to login", "error"); - $("#options-panel").show() + $("#options-panel").show(); + $("#candidate-details").addClass("invalid-login"); } }, }) @@ -452,7 +453,7 @@ async function loadPacketList(data) { $("#packet-list").empty(); if (packet_json_id == undefined) { - $("#options-panel").toggle(); + $("#options-panel").show(); return } //console.log(packet_list) From 39388dc2a02ba5e61600c9efd1c0236a1c4c8b9c Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 19:13:22 +0000 Subject: [PATCH 32/48] . --- js/main.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/js/main.js b/js/main.js index c1928a1..5e159ad 100644 --- a/js/main.js +++ b/js/main.js @@ -1889,6 +1889,11 @@ function reviewQuestions() { $("#review-overlay").hide(); }); + console.log(db.user_answers) + console.log({ + type: question_type, + qid: qid + }) db.user_answers .where({ type: question_type, @@ -1942,25 +1947,26 @@ function reviewQuestions() { ) { if (normal) { el.html( - "Answer: " + - user_answer + - " (Normal)" + `Answer: ${user_answer} (Normal)` ); } else { el.html( - "Answer: " + - user_answer + - " (Abnormal: " + - question_answers.join(", ") + - ")" + `Answer: ${user_answer} (Abnormal: ${question_answers.join(', ')})` ); } } + function setAnatomyReviewAnswer( + el, + c, + user_answer, + question_answers + ) { + el.html( + `Answer: ${user_answer} (Correct answers: ${question_answers.join(', ')})` + ) + } + if (question_type == "rapid") { // First check normal vs abnormal if (question["normal"] == true) { @@ -2028,20 +2034,18 @@ function reviewQuestions() { // Anatomy answers are either correct or incorrect if (answerInArray(question_answers, section_1_answer)) { correct_count++; - setReviewAnswer( + setAnatomyReviewAnswer( el, "correct", section_1_answer, - false, question_answers ); questions_correct[qid] = true; } else { - setReviewAnswer( + setAnatomyReviewAnswer( el, "incorrect", section_1_answer, - false, question_answers ); questions_correct[qid] = false; From 72397ca334f17aa76c509f5c52b69d645c350ead Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 21:10:07 +0000 Subject: [PATCH 33/48] . --- js/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/main.js b/js/main.js index 5e159ad..5bd68f3 100644 --- a/js/main.js +++ b/js/main.js @@ -189,6 +189,7 @@ async function loadExamList(data) { //Display user info if it exists if (data.hasOwnProperty("user") && data.user) { $("#user").append(`User: ${data.user}`); + $(".exam-wrapper").show(); } From 2916ca8dd8de122f76a762c1bfed0091bccc6d9c Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:23:52 +0000 Subject: [PATCH 34/48] . --- js/main.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/main.js b/js/main.js index 5bd68f3..8f81439 100644 --- a/js/main.js +++ b/js/main.js @@ -37,6 +37,18 @@ let timer = null; let use_local_question_cache = false; +window.location.search.substr(1).split("&").forEach((item) => + { + s = item.split("="); + if (s[0] == "cid") { + $("#cid-box").val(s[1]); + + } + if (s[0] == "passcode") { + $("#passcode-box").val(s[1]); + } + }); + cornerstone.imageCache.setMaximumSizeBytes(5128800); // Set up cornerstone (the dicom viewer) From fa9578cc6aaba0278229299698ad4d80b4f08c20 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:24:39 +0000 Subject: [PATCH 35/48] . --- js/main.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/js/main.js b/js/main.js index 8f81439..9d3e419 100644 --- a/js/main.js +++ b/js/main.js @@ -37,17 +37,16 @@ let timer = null; let use_local_question_cache = false; -window.location.search.substr(1).split("&").forEach((item) => - { - s = item.split("="); - if (s[0] == "cid") { - $("#cid-box").val(s[1]); +window.location.search.substr(1).split("&").forEach((item) => { + let s = item.split("="); + if (s[0] == "cid") { + global_cid = s[1]; - } - if (s[0] == "passcode") { - $("#passcode-box").val(s[1]); - } - }); + } + if (s[0] == "passcode") { + global_passcode = s[1]; + } +}); cornerstone.imageCache.setMaximumSizeBytes(5128800); From 6ae4d0567508c47040a32201d9ce91166707da5d Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:30:04 +0000 Subject: [PATCH 36/48] . --- js/main.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index 9d3e419..5244120 100644 --- a/js/main.js +++ b/js/main.js @@ -37,16 +37,7 @@ let timer = null; let use_local_question_cache = false; -window.location.search.substr(1).split("&").forEach((item) => { - let s = item.split("="); - if (s[0] == "cid") { - global_cid = s[1]; - } - if (s[0] == "passcode") { - global_passcode = s[1]; - } -}); cornerstone.imageCache.setMaximumSizeBytes(5128800); @@ -124,6 +115,25 @@ async function retrievePacketList() { }) $("#candidate-details").append(`Current: CID ${global_cid} / Passcode ${global_passcode} `).append(logout); + } else { + + window.location.search.substr(1).split("&").forEach((item) => { + s = item.split("="); + if (s[0] == "cid") { + let cid = s[1]; + + } + if (s[0] == "passcode") { + let passcode = s[1]; + } + + user_db.user.add({ + cid: cid, + passcode: passcode + }) + location.reload(); + }); + } try { From 5c10e5124a6259b8116920777c1ceb3335bbc16c Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:30:24 +0000 Subject: [PATCH 37/48] . --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 5244120..5e59484 100644 --- a/js/main.js +++ b/js/main.js @@ -118,7 +118,7 @@ async function retrievePacketList() { } else { window.location.search.substr(1).split("&").forEach((item) => { - s = item.split("="); + let s = item.split("="); if (s[0] == "cid") { let cid = s[1]; From 7af32b75d3621456cdf966111a8800a63e3cfceb Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:31:19 +0000 Subject: [PATCH 38/48] . --- js/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 5e59484..1a45ac4 100644 --- a/js/main.js +++ b/js/main.js @@ -119,9 +119,11 @@ async function retrievePacketList() { window.location.search.substr(1).split("&").forEach((item) => { let s = item.split("="); + + let cid = ""; + let passcode = ""; if (s[0] == "cid") { let cid = s[1]; - } if (s[0] == "passcode") { let passcode = s[1]; From 310c55e4ec2d6c18b1b360f4a3aee840bdcb1dde Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:32:15 +0000 Subject: [PATCH 39/48] . --- js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index 1a45ac4..aeb32eb 100644 --- a/js/main.js +++ b/js/main.js @@ -123,10 +123,10 @@ async function retrievePacketList() { let cid = ""; let passcode = ""; if (s[0] == "cid") { - let cid = s[1]; + cid = s[1]; } if (s[0] == "passcode") { - let passcode = s[1]; + passcode = s[1]; } user_db.user.add({ From d12461020a6e5e6e16c1dc9dec7f9f85d006805b Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:35:15 +0000 Subject: [PATCH 40/48] . --- js/main.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index aeb32eb..ae5b057 100644 --- a/js/main.js +++ b/js/main.js @@ -117,24 +117,31 @@ async function retrievePacketList() { $("#candidate-details").append(`Current: CID ${global_cid} / Passcode ${global_passcode} `).append(logout); } else { - window.location.search.substr(1).split("&").forEach((item) => { - let s = item.split("="); + items = window.location.search.substr(1).split("&") + if (items.length == 2) { let cid = ""; let passcode = ""; - if (s[0] == "cid") { - cid = s[1]; - } - if (s[0] == "passcode") { - passcode = s[1]; - } + for (let index = 0; index < array.length; index++) { + const item = items[index]; + let s = item.split("="); + + if (s[0] == "cid") { + cid = s[1]; + } + if (s[0] == "passcode") { + passcode = s[1]; + } + + }; + console.log(cid, passcode) user_db.user.add({ cid: cid, passcode: passcode }) location.reload(); - }); + } } From e32b6c2d9a499c3074ebadd9c6dc41fccbd7763b Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:36:00 +0000 Subject: [PATCH 41/48] . --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index ae5b057..406bf50 100644 --- a/js/main.js +++ b/js/main.js @@ -122,7 +122,7 @@ async function retrievePacketList() { if (items.length == 2) { let cid = ""; let passcode = ""; - for (let index = 0; index < array.length; index++) { + for (let index = 0; index < items.length; index++) { const item = items[index]; let s = item.split("="); From 3695bc04a5877c842f0848bb53e351fff2508fc2 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:37:28 +0000 Subject: [PATCH 42/48] . --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 406bf50..553f028 100644 --- a/js/main.js +++ b/js/main.js @@ -118,7 +118,7 @@ async function retrievePacketList() { } else { - items = window.location.search.substr(1).split("&") + let items = window.location.search.substr(1).split("&"); if (items.length == 2) { let cid = ""; let passcode = ""; From d6eff8ab96d1dc26b24b5e3f3ead59b75a2e9a73 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:38:47 +0000 Subject: [PATCH 43/48] . --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 553f028..d6a20be 100644 --- a/js/main.js +++ b/js/main.js @@ -109,7 +109,7 @@ async function retrievePacketList() { let logout = $("[x]") logout.click(() => { user_db.user.clear().then(() => { - location.reload(); + window.location = window.location.pathname; return; }); }) From 984e698d6e3774b509304a3a3e16af9c39fb4de6 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:47:10 +0000 Subject: [PATCH 44/48] . --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index d6a20be..05f5c6e 100644 --- a/js/main.js +++ b/js/main.js @@ -151,7 +151,7 @@ async function retrievePacketList() { if (global_cid == null) { url = config.exam_query_url; } else { - url = `${config.exam_query_url}${global_cid}/${global_passcode}`; + url = `${config.exam_query_url}/${global_cid}/${global_passcode}`; } } } catch (e) { From a0155c710c854d97e6c1b2dab6ad6c12026f7a25 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 16 Dec 2021 23:11:40 +0000 Subject: [PATCH 45/48] . --- js/main.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index 05f5c6e..2c7db80 100644 --- a/js/main.js +++ b/js/main.js @@ -114,6 +114,16 @@ async function retrievePacketList() { }); }) + if (config.exam_results_url != "" && config.exam_results_url != undefined) { + let url = `${config.exam_results_url}${global_cid}/${global_passcode}`; + + $("#options-link") + .empty() + .append( + `
    Results and answers
    ` + ); + } + $("#candidate-details").append(`Current: CID ${global_cid} / Passcode ${global_passcode} `).append(logout); } else { @@ -297,15 +307,6 @@ async function loadExamList(data) { ); } - if (config.exam_results_url != "" && config.exam_results_url != undefined) { - let url = `${config.exam_results_url}${global_cid}/${global_passcode}`; - - $("#options-link") - .empty() - .append( - `
    Results and answers
    ` - ); - } // Check the database for exams that have been saved question_db.saved_exams.toArray().then((saved_exams) => { From ea708dbc88ae623020f16b9fb26d0933ebf15366 Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 22 Dec 2021 18:05:05 +0000 Subject: [PATCH 46/48] . --- .vscode/settings.json | 2 +- js/interact.js | 45 ++++++++++++++++++++++++------------------- js/main.js | 3 +++ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3cdf6f8..0ec6bc1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,5 @@ "javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": false, "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false, "javascript.format.enable": false, - "liveServer.settings.port": 5501 + "liveServer.settings.port": 5502 } \ No newline at end of file diff --git a/js/interact.js b/js/interact.js index a829979..976b423 100644 --- a/js/interact.js +++ b/js/interact.js @@ -8,6 +8,8 @@ export function submitAnswers(exam_details, db, config) { .then((a) => { let json = { eid: exam_details.eid, + cid: exam_details.cid, + start_time: exam_details.start_time, answers: JSON.stringify(a), }; postAnswers(json, config, exam_details); @@ -25,10 +27,10 @@ export function submitAnswers(exam_details, db, config) { export function getJsonAnswers(exam_details, db) { console.log(exam_details) console.log({ - aid: exam_details.aid, - cid: exam_details.cid, - eid: exam_details.eid, - }) + aid: exam_details.aid, + cid: exam_details.cid, + eid: exam_details.eid, + }) return db.answers .where({ aid: exam_details.aid, @@ -56,7 +58,7 @@ export function postAnswers(ans, config, exam_details) { ); if (ret) { - $( document ).trigger( "saveSessionEvent", [ true ] ); + $(document).trigger("saveSessionEvent", [true]); if (config.exam_results_url != "") { let url = config.exam_results_url; @@ -70,8 +72,7 @@ export function postAnswers(ans, config, exam_details) { ); } $("#options-panel").show(); - } else { - } + } else {} } else { alert(`${data.question_count} answers sucessfully submitted.`); } @@ -100,13 +101,13 @@ function submissionError(data, answer_json, exam_details) { let answer_map = {} - answers.forEach((ans, n) => { + answers.forEach((ans, n) => { if (!answer_map.hasOwnProperty(ans.qid)) { answer_map[ans.qid] = []; } answer_map[ans.qid].push(ans); - + }); let html = $("
      "); @@ -114,13 +115,13 @@ function submissionError(data, answer_json, exam_details) { exam_details.question_order.forEach((i, j) => { console.log(i, answer_map) if (i in answer_map) { - console.log("YES", i, answer_map) + console.log("YES", i, answer_map) let ans_array = answer_map[i]; ans_array.forEach((x, y) => { - $(html).append(`
    • Question ${j+1}.${y}: ${x.ans}
    • `); + $(html).append(`
    • Question ${j+1}.${y}: ${x.ans}
    • `); }); } - + }) console.log(exam_details.question_order); @@ -145,7 +146,7 @@ export function getQuestion(url, question_number, question_total) { return $.ajax({ dataType: "json", url: url, - progress: function (e) { + progress: function(e) { $("#progress").html( `Downloading question [${question_number}/${question_total}]
      This file is compressed (no size available)` ); @@ -170,14 +171,18 @@ export function getQuestion(url, question_number, question_total) { } export function postSavedAnswer(type, qid, answer, e, db_object, db) { -console.log("post", type, qid, answer, e) -return $.ajax({ + console.log("post", type, qid, answer, e) + return $.ajax({ type: "POST", url: config.question_answer_submit_url, - data: JSON.stringify({ qid: `${type}/${qid}`, answer: answer, status: 2 }), + data: JSON.stringify({ + qid: `${type}/${qid}`, + answer: answer, + status: 2 + }), contentType: "application/json; charset=utf-8", dataType: "json", - success: function(data){ + success: function(data) { db_object.submitted = true; db.user_answers.put(db_object); e.target.remove() @@ -185,7 +190,7 @@ return $.ajax({ }, error: function(errMsg) { - alert(errMsg); + alert(errMsg); } -}); -} + }); +} \ No newline at end of file diff --git a/js/main.js b/js/main.js index 2c7db80..a2004f0 100644 --- a/js/main.js +++ b/js/main.js @@ -13,6 +13,7 @@ let exam_details = { exam_mode: false, number_of_questions: null, question_order: [], + start_time: null, }; let packet_list = []; @@ -2449,6 +2450,8 @@ $(".start-packet-button").click(function(evt) { } } + exam_details.start_time = new Date().getTime() / 1000; + if (timer != null) { timer.stop(); } From b5a9df003554c0e990033bfd1679540a403517c3 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 30 Dec 2021 20:46:07 +0000 Subject: [PATCH 47/48] . --- js/main.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/main.js b/js/main.js index a2004f0..be43366 100644 --- a/js/main.js +++ b/js/main.js @@ -2443,12 +2443,13 @@ $("#login-button").click(function(evt) { }); $(".start-packet-button").click(function(evt) { - if (exam_details.exam_mode) { - if (!Number.isInteger(parseInt($("#candidate-number2").val()))) { - alert("Please enter a valid candidate number."); - return; - } - } + // No longer needed as candidates log in... + //if (exam_details.exam_mode) { + // if (!Number.isInteger(parseInt($("#candidate-number2").val()))) { + // alert("Please enter a valid candidate number."); + // return; + // } + //} exam_details.start_time = new Date().getTime() / 1000; From c2d7d2eb0ea51d08c2a0e042453ffdfb9eb73bee Mon Sep 17 00:00:00 2001 From: Ross Date: Sat, 1 Jan 2022 09:57:44 +0000 Subject: [PATCH 48/48] Disable contextmenu and show download progress for compresesd files --- js/interact.js | 7 ++++--- js/main.js | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/interact.js b/js/interact.js index 976b423..9477279 100644 --- a/js/interact.js +++ b/js/interact.js @@ -147,9 +147,6 @@ export function getQuestion(url, question_number, question_total) { dataType: "json", url: url, progress: function(e) { - $("#progress").html( - `Downloading question [${question_number}/${question_total}]
      This file is compressed (no size available)` - ); if (e.lengthComputable) { var completedPercentage = Math.round((e.loaded * 100) / e.total); @@ -158,6 +155,10 @@ export function getQuestion(url, question_number, question_total) { e.total )}` ); + } else { + $("#progress").html( + `Downloading question [${question_number}/${question_total}]
      This file is compressed (downloaded ${helper.humanFileSize(e.loaded)})` + ); } }, error: (jqXHR, textStatus, errorThrown) => { diff --git a/js/main.js b/js/main.js index be43366..33a1121 100644 --- a/js/main.js +++ b/js/main.js @@ -2695,6 +2695,10 @@ $(document).on("saveSessionEvent", {}, (evt, review) => { saveSession(review); }); +$(document).contextmenu(() => { + return false; +}) + // Helper to compare dates function compareDates(d1, d2) { console.log("compare", d1, d2);