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 Exams:
+
+
+
+
+
+
Available Packets:
@@ -75,28 +85,28 @@
- Options
-
-
-
-
-
@@ -138,7 +148,7 @@
Check your below candidate number is correct.
-
+
@@ -153,12 +163,13 @@
-
-
Select exam
+
@@ -180,7 +191,10 @@
diff --git a/js/main.js b/js/main.js
index be4d2d5..8fc907d 100644
--- a/js/main.js
+++ b/js/main.js
@@ -9,6 +9,7 @@ let exam_details = {
aid: null,
cid: "",
eid: 5678,
+ passcode: "",
exam_mode: false,
number_of_questions: null,
question_order: [],
@@ -27,6 +28,9 @@ let date_started = null;
let score = 0;
let packet_json_id = null;
+let global_cid = null;
+let global_passcode = null;
+
let allow_self_marking = true;
let timer = null;
@@ -62,8 +66,7 @@ db.version(1).stores({
answers: "[aid+cid+eid+qid+qidn], [aid+cid+eid], qid, ans, eid",
flags: "[aid+cid+eid+qid+qidn], [aid+cid+eid], qid",
user_answers: "[qid+type+ans], [qid+type]",
- session:
- "[eid+aid], eid, packet, aid, status, date, score, max_score, exam_time, time_left, question_order, questions_answered, total_questions",
+ session: "[eid+aid], eid, packet, aid, status, date, score, max_score, exam_time, time_left, question_order, questions_answered, total_questions",
});
const question_db = new Dexie("question_database");
@@ -72,6 +75,11 @@ question_db.version(1).stores({
saved_exams: "&eid, type, exam_mode, name, order, time, exam_json_id",
});
+const user_db = new Dexie("user_database");
+user_db.version(1).stores({
+ user: "cid, passcode",
+});
+
retrievePacketList();
refreshDatabaseSettings();
@@ -83,45 +91,69 @@ refreshDatabaseSettings();
*
* if exam_query_url is defined in config.js this will be used in preference
*/
-function retrievePacketList() {
+async function retrievePacketList() {
let url = "packets/packets.json";
//console.log(config.exam_query_url);
+ let users = await user_db.user.toArray();
+ console.log(users)
+
+ if (users.length > 0) {
+ global_cid = users[0].cid;
+ global_passcode = users[0].passcode;
+
+ $(".exam-wrapper").toggle();
+
+ let logout = $("
[x]")
+ logout.click(() => {
+ user_db.user.clear().then(() => {
+ location.reload();
+ return;
+ });
+ })
+
+ $("#candidate-details").append(`Current: CID ${global_cid} / Passcode ${global_passcode} `).append(logout);
+ }
try {
if (config.exam_query_url != undefined) {
- url = config.exam_query_url;
+
+ if (global_cid == null) {
+ url = config.exam_query_url;
+ } else {
+ url = `${config.exam_query_url}${global_cid}/${global_passcode}`;
+ }
}
} catch (e) {
//
}
$.ajax({
- dataType: "json",
- cache: false,
- url: url,
- success: function (data) {
- if (data.hasOwnProperty("exams")) {
- loadExamList(data);
- } else {
- loadPacketList(data);
- }
- },
- })
- .done(function () {})
- .fail(function () {
- $.getJSON("packets", function (data) {
+ dataType: "json",
+ cache: false,
+ url: url,
+ success: function(data) {
if (data.hasOwnProperty("exams")) {
loadExamList(data);
} else {
loadPacketList(data);
}
- }).fail(function (jqXHR, textStatus, errorThrown) {
+ },
+ })
+ .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();
});
})
- .always(function () {});
+ .always(function() {});
}
/**
@@ -131,7 +163,7 @@ function retrievePacketList() {
* @param {JSON} data - json containing available exams
*/
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);
$("#database-error").text(
"Error loading the database, schema has probably changed and needs updating. You will probably need to delete the local database."
@@ -170,7 +202,9 @@ async function loadExamList(data) {
let exam_generated_map = {};
$("#packet-list").empty();
//exam_list.sort((a, b) => (a.name > b.name) ? 1 : -1).forEach(function (exam) {
- exam_list.forEach(function (exam) {
+ for (let index = 0; index < exam_list.length; index++) {
+ const exam = exam_list[index];
+ console.log(exam)
let name = exam["name"];
let url = exam["url"];
let eid = exam["eid"];
@@ -195,31 +229,37 @@ async function loadExamList(data) {
c = c + " inactive";
}
+ let target_list = "packet-list";
+ if (exam.exam_mode) {
+ target_list = "exam-list";
+ }
+
let list;
if (exam.type != undefined) {
- if ($(`#packet-list .${exam.type}`).length) {
- list = $(`#packet-list .${exam.type}`);
+ if ($(`.${target_list}.${exam.type}`).length) {
+ list = $(`.${target_list}.${exam.type}`);
} else {
- list = $("#packet-list").append(
- `
${exam.type}
`
- );
+ list = $(`
${exam.type}
`);
+ $(`#${target_list}`).append(list);
+
}
} else {
list = $("#packet-list");
}
- list.append(
+ $(list).append(
$(
`
`
)
- .text(name)
- .click(function () {
- loadPacketFromAjax(url, eid, exam_json_id);
- })
+ .text(name)
+ .click(function() {
+ loadPacketFromAjax(url, eid, exam_json_id);
+ })
);
- });
+ }
+
if (config.exam_results_url != "" && config.exam_results_url != undefined) {
- let url = config.exam_results_url;
+ let url = `${config.exam_results_url}${global_cid}/${global_passcode}`;
$("#options-link")
.empty()
@@ -270,60 +310,63 @@ async function loadExamList(data) {
`
Question (${saved_exam.exam_type}): ${q}`
);
// If a single question is out of date we invalidate the lot...
- const q_object = { qid: String(q), type: saved_exam.exam_type };
+ const q_object = {
+ qid: String(q),
+ type: saved_exam.exam_type
+ };
console.log(q_object);
let save_question_data = await question_db.question_data.get(q_object);
- try {
- console.log("saved question data", save_question_data, new_question_json_id)
- // saved_question_data is undefined if the question is not saved
- // 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) {
- console.log(`INVALIDATE eid: ${saved_exam.eid}, q ${q}`);
- $(`li.cache-item[data-eid="${saved_exam.eid}"]`).addClass(
- "cache-out-of-date"
- );
- $(`li.cache-item[data-qid="${q}"]`).addClass(
- "cache-out-of-date"
- );
- $(`.packet-button[data-eid="${saved_exam.eid}"]`).addClass(
- "out-of-date"
- );
-
- // Invalidate associated exam
- question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
-
- // Invalidate and any associated answers
- db.answers.where("eid").equals(saved_exam.eid).delete();
-
- //question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
- question_db.question_data
- .where(["qid", "type"])
- .equals([String(q), saved_exam.exam_type])
- .delete();
- }
- } catch(e) {
- console.log("Error loading qusetion data", q_object);
- console.log(e);
- console.log("1234", saved_exam.eid);
- // If the question isn't found in the cache...
+ try {
+ console.log("saved question data", save_question_data, new_question_json_id)
+ // saved_question_data is undefined if the question is not saved
+ // 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) {
+ console.log(`INVALIDATE eid: ${saved_exam.eid}, q ${q}`);
$(`li.cache-item[data-eid="${saved_exam.eid}"]`).addClass(
"cache-out-of-date"
);
- $(`li.cache-item[data-qid="${q}"]`)
- .addClass("cache-out-of-date")
- .append("[Not found]");
+ $(`li.cache-item[data-qid="${q}"]`).addClass(
+ "cache-out-of-date"
+ );
$(`.packet-button[data-eid="${saved_exam.eid}"]`).addClass(
"out-of-date"
);
+ // Invalidate associated exam
+ question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
+
+ // Invalidate and any associated answers
+ db.answers.where("eid").equals(saved_exam.eid).delete();
+
//question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
question_db.question_data
.where(["qid", "type"])
.equals([String(q), saved_exam.exam_type])
.delete();
}
+ } catch (e) {
+ console.log("Error loading qusetion data", q_object);
+ console.log(e);
+ console.log("1234", saved_exam.eid);
+ // If the question isn't found in the cache...
+ $(`li.cache-item[data-eid="${saved_exam.eid}"]`).addClass(
+ "cache-out-of-date"
+ );
+ $(`li.cache-item[data-qid="${q}"]`)
+ .addClass("cache-out-of-date")
+ .append("[Not found]");
+ $(`.packet-button[data-eid="${saved_exam.eid}"]`).addClass(
+ "out-of-date"
+ );
+
+ //question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
+ question_db.question_data
+ .where(["qid", "type"])
+ .equals([String(q), saved_exam.exam_type])
+ .delete();
+ }
}
}
});
@@ -331,30 +374,30 @@ async function loadExamList(data) {
// Sort different lists
$(".packet-list.rapid div")
- .sort(function (a, b) {
- return a.dataset.eid > b.dataset.eid
- ? 1
- : a.dataset.eid < b.dataset.eid
- ? -1
- : 0;
+ .sort(function(a, b) {
+ return a.dataset.eid > b.dataset.eid ?
+ 1 :
+ a.dataset.eid < b.dataset.eid ?
+ -1 :
+ 0;
})
.appendTo(".packet-list.rapid");
$(".packet-list.anatomy div")
- .sort(function (a, b) {
- return a.dataset.eid > b.dataset.eid
- ? 1
- : a.dataset.eid < b.dataset.eid
- ? -1
- : 0;
+ .sort(function(a, b) {
+ return a.dataset.eid > b.dataset.eid ?
+ 1 :
+ a.dataset.eid < b.dataset.eid ?
+ -1 :
+ 0;
})
.appendTo(".packet-list.anatomy");
$(".packet-list.long div")
- .sort(function (a, b) {
- return a.dataset.eid > b.dataset.eid
- ? 1
- : a.dataset.eid < b.dataset.eid
- ? -1
- : 0;
+ .sort(function(a, b) {
+ return a.dataset.eid > b.dataset.eid ?
+ 1 :
+ a.dataset.eid < b.dataset.eid ?
+ -1 :
+ 0;
})
.appendTo(".packet-list.long");
@@ -368,7 +411,7 @@ async function loadExamList(data) {
*/
// TODO: remove (data formats should be switched to the exam format)
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);
$("#database-error").text(
"Error loading the database, schema has probably changed and needs updating. You will probably need to delete the local database."
@@ -400,7 +443,13 @@ async function loadPacketList(data) {
}
$("#packet-list").empty();
- packet_list.forEach(function (packet) {
+
+ if (packet_json_id == undefined) {
+ $("#options-panel").toggle();
+ return
+ }
+ //console.log(packet_list)
+ packet_list.forEach(function(packet) {
// Seperate packet types
let list;
if (packet.type != undefined) {
@@ -425,18 +474,18 @@ async function loadPacketList(data) {
}
list.append(
$(``)
- .text(packet)
- .click(function () {
- loadPacketFromAjax("packets/" + packet, packet);
+ .text(packet)
+ .click(function() {
+ loadPacketFromAjax("packets/" + packet, packet);
+ })
+ .append(
+ $(
+ ``
+ ).click(function(evt) {
+ //console.log("packets/" + packet);
+ evt.stopPropagation();
})
- .append(
- $(
- ``
- ).click(function (evt) {
- //console.log("packets/" + packet);
- evt.stopPropagation();
- })
- )
+ )
);
});
$("#options-panel").show();
@@ -452,8 +501,7 @@ function loadPacketFromAjax(path, eid, exam_json_id) {
question_db.saved_exams
.get(eid)
.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);
ajaxRequestionPacket(true);
} else {
@@ -465,7 +513,7 @@ function loadPacketFromAjax(path, eid, exam_json_id) {
$("#options-panel").hide();
}
})
- .catch(function (error) {
+ .catch(function(error) {
// Will be triggered if eid does not exist in database
console.log("Unable to load exam:", eid);
console.log("error-", error);
@@ -486,24 +534,24 @@ function loadPacketFromAjax(path, eid, exam_json_id) {
}
$.ajax({
- dataType: "json",
- url: path,
- cache: browser_cache,
- progress: function (e) {
- if (e.lengthComputable) {
- var completedPercentage = Math.round((e.loaded * 100) / e.total);
+ dataType: "json",
+ url: path,
+ cache: browser_cache,
+ progress: function(e) {
+ if (e.lengthComputable) {
+ var completedPercentage = Math.round((e.loaded * 100) / e.total);
- $("#progress").html(
- `${completedPercentage}%
${helper.formatBytes(e.total)}`
- );
- }
- },
- })
- .done(function (data) {
+ $("#progress").html(
+ `${completedPercentage}%
${helper.formatBytes(e.total)}`
+ );
+ }
+ },
+ })
+ .done(function(data) {
setUpPacket(data, path);
$("#options-panel").hide();
})
- .fail(function () {
+ .fail(function() {
console.log("Unable to load packet at: " + path);
});
}
@@ -550,7 +598,7 @@ function setUpPacket(data, path) {
exam_details.question_order = data.exam_order;
} else {
exam_details.question_order = [];
- Object.keys(questions).forEach(function (e) {
+ Object.keys(questions).forEach(function(e) {
exam_details.question_order.push(e);
// Make sure answers are arrays
@@ -587,7 +635,9 @@ function setUpPacket(data, path) {
if (!use_local_question_cache) {
// Save the details to the question database
- var clone_data = Object.assign({}, data, { questions: "cached" });
+ var clone_data = Object.assign({}, data, {
+ questions: "cached"
+ });
console.log(clone_data)
//clone_data["cached_questions"] = Object.keys(data["questions"]);
question_db.saved_exams.put(clone_data);
@@ -621,7 +671,10 @@ function setUpPacket(data, path) {
question_number++;
n = String(n);
- let obj = { qid: n, type: question_type };
+ let obj = {
+ qid: n,
+ type: question_type
+ };
let question_in_db = await question_db.question_data.get(obj);
// If the question is in the db we can load
@@ -650,8 +703,7 @@ function setUpPacket(data, path) {
if (
question_json.hasOwnProperty("images_json") &&
question_json["images_json"]
- ) {
- }
+ ) {}
//requests.push(request)
//request_numbers.push(n)
@@ -733,9 +785,15 @@ function loadSession() {
if (sessions[i].status == "active") {
text = text + `\r${i}: ${formatted_date} [In progress]`;
} else {
- text =
- text +
- `\r${i}: ${formatted_date} [Complete - score ${sessions[i].score}/${sessions[i].max_score}]`;
+ if (!exam_details.exam_mode) {
+ text =
+ text +
+ `\r${i}: ${formatted_date} [Complete - score ${sessions[i].score}/${sessions[i].max_score}]`;
+ } else {
+ text =
+ text +
+ `\r${i}: ${formatted_date} [Complete]`;
+ }
}
}
@@ -784,7 +842,7 @@ function setUpQuestions(load_previous) {
//return;
} else {
if (!use_local_question_cache) {
- Object.keys(questions).forEach(function (e) {
+ Object.keys(questions).forEach(function(e) {
// Store question data into dexie
let d = {
//eid: exam_details.eid,
@@ -799,8 +857,7 @@ function setUpQuestions(load_previous) {
}
// Set an order for the questions
- if (!load_previous) {
- }
+ if (!load_previous) {}
}
exam_details.number_of_questions = exam_details.question_order.length;
review_mode = false;
@@ -836,11 +893,14 @@ function setUpQuestions(load_previous) {
if (exam_details.exam_mode) {
// NOTE: changing the CID when restoring a session will not affect the time left
- $("#candidate-number2")
- .val(exam_details.cid)
- .change(() => {
- exam_details.cid = parseInt($("#candidate-number2").val());
- });
+ //$("#candidate-number2")
+ // .val(exam_details.cid)
+ // .change(() => {
+ // exam_details.cid = parseInt($("#candidate-number2").val());
+ // });
+ exam_details.cid = global_cid;
+ $("#candidate-number2").val(global_cid)
+ exam_details.passcode = global_passcode;
$("#start-dialog").addClass("no-close");
$("#start-dialog .exam-time").prop("disabled", "true");
@@ -871,6 +931,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
const aid = exam_details.aid;
const cid = exam_details.cid;
const eid = exam_details.eid;
+ const passcode = exam_details.passcode;
n = parseInt(n);
//console.log("loading question (n)", n);
@@ -886,7 +947,10 @@ async function loadQuestion(n, section = 1, force_reload = false) {
const qid = exam_details.question_order[n];
console.log("qid", qid)
- let q = { qid: String(qid), type: question_type };
+ let q = {
+ qid: String(qid),
+ type: question_type
+ };
console.log(q)
console.log(question_db.question_data)
@@ -904,7 +968,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
} else {
$(".navigation[value='previous']")
.removeAttr("disabled")
- .click(function () {
+ .click(function() {
loadQuestion(n - 1);
});
}
@@ -914,7 +978,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
} else {
$(".navigation[value='next']")
.removeAttr("disabled")
- .click(function () {
+ .click(function() {
loadQuestion(n + 1);
});
}
@@ -990,7 +1054,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
// convert the data url to a file
viewer
.urltoFile(based_img, "dicom", "application/dicom")
- .then(function (dfile) {
+ .then(function(dfile) {
// load the file using cornerstoneWADO file loader
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
dfile
@@ -1005,7 +1069,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
const element = document.getElementById("thumb-" + id);
cornerstone.enable(element);
//cornerstone.loadImage(imageId).then(function (image) {
- cornerstone.loadAndCacheImage(imageId).then(function (image) {
+ cornerstone.loadAndCacheImage(imageId).then(function(image) {
cornerstone.displayImage(element, image);
cornerstone.resize(element);
}); // .catch( function(error) {
@@ -1040,7 +1104,7 @@ async function loadQuestion(n, section = 1, force_reload = false) {
});
function handleThumbnailClicks(id, thumbnail) {
- $(thumbnail).click(function (event) {
+ $(thumbnail).click(function(event) {
viewer.openMainImage(question_data, event, this);
});
}
@@ -1057,20 +1121,20 @@ async function loadQuestion(n, section = 1, force_reload = false) {
case "rapid": {
ap.append(
'' +
- display_n +
- '.1Case normal/abnormal
'
+ display_n +
+ '.1Case normal/abnormal '
);
ap.append(
'
' +
- display_n +
- '.2Reason
'
+ display_n +
+ '.2
Reason '
);
// 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);