start with ESlint
This commit is contained in:
+134
-130
@@ -8,7 +8,7 @@ window.exam_mode = false;
|
||||
|
||||
window.packet_list = [];
|
||||
|
||||
// var questions = null
|
||||
window.questions = null;
|
||||
window.question_order = [];
|
||||
window.number_of_questions = null;
|
||||
window.question_type = null;
|
||||
@@ -19,7 +19,6 @@ window.allow_self_marking = true;
|
||||
|
||||
window.dfile = null;
|
||||
|
||||
|
||||
retrievePacketList();
|
||||
|
||||
/**
|
||||
@@ -31,20 +30,16 @@ function retrievePacketList() {
|
||||
$.getJSON("packets/", function (data) {
|
||||
loadPacketList(data);
|
||||
})
|
||||
.done(function() {
|
||||
})
|
||||
.done(function () {})
|
||||
.fail(function () {
|
||||
$.getJSON("packets/packets.json", function (data) {
|
||||
loadPacketList(data);
|
||||
})
|
||||
.fail(function() {
|
||||
}).fail(function () {
|
||||
console.log("No packet list available");
|
||||
showLoginDialog();
|
||||
});
|
||||
})
|
||||
.always(function() {
|
||||
});
|
||||
|
||||
.always(function () {});
|
||||
|
||||
// setUpPacket(questions);
|
||||
}
|
||||
@@ -60,7 +55,8 @@ function loadPacketList(data) {
|
||||
$("#packet-list").append(
|
||||
$("<div class='packet-button'>" + packet + "</div>").click(function () {
|
||||
loadPacketFromAjax("packets/" + packet);
|
||||
}));
|
||||
})
|
||||
);
|
||||
});
|
||||
$("#options-panel").show();
|
||||
}
|
||||
@@ -75,8 +71,7 @@ function loadPacketFromAjax(path) {
|
||||
setUpPacket(data);
|
||||
$("#options-panel").hide();
|
||||
})
|
||||
.done(function() {
|
||||
})
|
||||
.done(function () {})
|
||||
.fail(function () {
|
||||
console.log("Unable to load packet at: " + path);
|
||||
});
|
||||
@@ -86,31 +81,31 @@ function loadPacketFromAjax(path) {
|
||||
* Build the currently loaded quiz
|
||||
*/
|
||||
function setUpQuestions() {
|
||||
if (questions == undefined) {
|
||||
if (window.questions == undefined) {
|
||||
return;
|
||||
}
|
||||
// Set an order for the questions
|
||||
window.question_order = [];
|
||||
Object.keys(questions).forEach(function(e) {
|
||||
Object.keys(window.questions).forEach(function (e) {
|
||||
window.question_order.push(e);
|
||||
|
||||
// Make sure answers are arrays
|
||||
if (!Array.isArray(questions[e]["answers"])) {
|
||||
questions[e]["answers"] = [questions[e]["answers"]];
|
||||
if (!Array.isArray(window.questions[e]["answers"])) {
|
||||
window.questions[e]["answers"] = [window.questions[e]["answers"]];
|
||||
}
|
||||
});
|
||||
|
||||
console.log("pre", window.question_order);
|
||||
window.question_order = helper.shuffleArray(window.question_order);
|
||||
console.log("post", window.question_order);
|
||||
window.number_of_questions = Object.keys(questions).length;
|
||||
window.number_of_questions = Object.keys(window.questions).length;
|
||||
window.review = false;
|
||||
console.log(window.question_order);
|
||||
|
||||
// Horrible way to get type of questions
|
||||
// We assume they are all of the same type....
|
||||
if (window.question_type == null) {
|
||||
window.question_type = questions[Object.keys(questions)[0]].type;
|
||||
window.question_type = window.questions[Object.keys(window.questions)[0]].type;
|
||||
}
|
||||
|
||||
if (window.exam_mode) {
|
||||
@@ -183,7 +178,6 @@ function setUpPacket(data) {
|
||||
setUpQuestions();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a specific question
|
||||
* @param {number} n - Question number to load
|
||||
@@ -197,7 +191,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
|
||||
const qid = window.question_order[n];
|
||||
console.log("qid", qid);
|
||||
const current_question = questions[qid];
|
||||
const current_question = window.questions[qid];
|
||||
|
||||
console.log("N=", n, section, current_question);
|
||||
|
||||
@@ -236,13 +230,13 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
|
||||
if (current_question.title) {
|
||||
$(".question .title").get(0).innerHTML =
|
||||
"<span style=\"font-weight:700;\">" +
|
||||
'<span style="font-weight:700;">' +
|
||||
display_n +
|
||||
"</span> " +
|
||||
current_question.title;
|
||||
} else {
|
||||
$(".question .title").get(0).innerHTML =
|
||||
"<span style=\"font-weight:700;\">" + display_n + "</span>";
|
||||
'<span style="font-weight:700;">' + display_n + "</span>";
|
||||
}
|
||||
|
||||
// Close any open figures
|
||||
@@ -267,9 +261,9 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
}
|
||||
|
||||
thumbnails.append(
|
||||
"<div class=\"figure\" id=\"figure-" +
|
||||
'<div class="figure" id="figure-' +
|
||||
id +
|
||||
"\"><div class=\"figcaption\">...</div></div>",
|
||||
'"><div class="figcaption">...</div></div>'
|
||||
);
|
||||
|
||||
// const thumbnail = $(".figure .thumbnail").get(id);
|
||||
@@ -294,11 +288,11 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
} else {
|
||||
// convert the data url to a file
|
||||
urltoFile(based_img, "dicom", "application/dicom").then(function (
|
||||
dfile,
|
||||
dfile
|
||||
) {
|
||||
// load the file using cornerstoneWADO file loader
|
||||
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
|
||||
dfile,
|
||||
dfile
|
||||
);
|
||||
cornerstone.loadAndCacheImage(imageId).then(function (image) {
|
||||
const img = $("<div></div>").get(0);
|
||||
@@ -350,16 +344,14 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
}
|
||||
}
|
||||
|
||||
$(".figure-open")
|
||||
.removeClass("figure-open")
|
||||
.addClass("figure");
|
||||
$(".figure-open").removeClass("figure-open").addClass("figure");
|
||||
|
||||
source.className = "figure-open";
|
||||
|
||||
$(".question").append(
|
||||
"<div class= \"canvas-panel\"><div id=\"dicom-image\" data-figure=\"" +
|
||||
'<div class= "canvas-panel"><div id="dicom-image" data-figure="' +
|
||||
figure_to_load +
|
||||
"\"></div></div>",
|
||||
'"></div></div>'
|
||||
);
|
||||
|
||||
let images = current_question.images[figure_to_load.split("-")[1]];
|
||||
@@ -391,7 +383,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
dfile = await urltoFile(data_url, "dicom", "application/dicom");
|
||||
|
||||
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
|
||||
dfile,
|
||||
dfile
|
||||
);
|
||||
imageIds.push(imageId);
|
||||
// cornerstone.loadImage(imageId).then(function(image) {
|
||||
@@ -403,7 +395,6 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
currentImageIdIndex: 0,
|
||||
imageIds,
|
||||
};
|
||||
// cornerstone.loadAndCacheImage(imageIds[0]).then(function(image) {
|
||||
cornerstone.loadAndCacheImage(imageIds[0]).then(function (image) {
|
||||
loadMainImage(image, stack);
|
||||
});
|
||||
@@ -418,18 +409,18 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
switch (current_question.type) {
|
||||
case "rapid": {
|
||||
ap.append(
|
||||
"<div class=\"answer-item\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".1</span><span style=\"flex:1\">Case normal/abnormal</span><button class=\"flag\" data-qid=\"" +
|
||||
'.1</span><span style="flex:1">Case normal/abnormal</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=1 style=\"margin-right:0\">⚐</button></p></div><select class=\"rapid-option-answer\" id=\"rapid-option\" data-answer-section-qidn=1><option selected=\"selected\" disabled=\"disabled\" id=\"rapid-option-not-answered\">--- Not Answered ---</option><option>Abnormal</option><option>Normal</option></select></div>",
|
||||
'" data-qidn=1 style="margin-right:0">⚐</button></p></div><select class="rapid-option-answer" id="rapid-option" data-answer-section-qidn=1><option selected="selected" disabled="disabled" id="rapid-option-not-answered">--- Not Answered ---</option><option>Abnormal</option><option>Normal</option></select></div>'
|
||||
);
|
||||
ap.append(
|
||||
"<div class=\"answer-item\" id=\"rapid-text\" style=\"display: none;\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item" id="rapid-text" style="display: none;"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".2</span><span style=\"flex:1\">Reason</span><button class=\"flag\" data-qid=\"" +
|
||||
'.2</span><span style="flex:1">Reason</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=2 style=\"margin-right:0\">⚐</button></p></div><textarea class=\"long-answer\" name=\"Reason\" data-answer-section-qidn=2 style=\"overflow: hidden scroll; overflow-wrap: break-word;\"></textarea></div>",
|
||||
'" data-qidn=2 style="margin-right:0">⚐</button></p></div><textarea class="long-answer" name="Reason" data-answer-section-qidn=2 style="overflow: hidden scroll; overflow-wrap: break-word;"></textarea></div>'
|
||||
);
|
||||
// Handle changing display of optional answer fields and saving of data
|
||||
$("#rapid-option").change(function (evt) {
|
||||
@@ -454,7 +445,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
if (evt.target.value.length < 1) {
|
||||
db.answers.delete([cid, eid, qid, "2"]);
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-2",
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-2"
|
||||
).removeClass("question-saved-localdb");
|
||||
return;
|
||||
}
|
||||
@@ -467,9 +458,9 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
ans: evt.target.value,
|
||||
});
|
||||
|
||||
$("#question-list-item-" + window.question_order.indexOf(qid) + "-2").addClass(
|
||||
"question-saved-localdb",
|
||||
);
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-2"
|
||||
).addClass("question-saved-localdb");
|
||||
|
||||
updateQuestionListPanel();
|
||||
});
|
||||
@@ -477,13 +468,14 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
// We chain our db requests as we can only check answers once
|
||||
// they have been loaded (should probably use then or after)
|
||||
|
||||
|
||||
db.answers
|
||||
.get({ cid: cid, eid: eid, qid: qid, qidn: "1" })
|
||||
.then(function (answer) {
|
||||
if (answer != undefined) {
|
||||
$("#rapid-option option:contains(" + answer.ans + ")").prop(
|
||||
"selected",
|
||||
true,
|
||||
true
|
||||
);
|
||||
// For some reason a change event is not fired...
|
||||
if (answer.ans == "Abnormal") {
|
||||
@@ -493,6 +485,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log("DB", cid, eid, qid);
|
||||
console.log("error-", error);
|
||||
})
|
||||
.then(
|
||||
@@ -507,7 +500,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log("error-", error);
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
addFlagEvents();
|
||||
@@ -518,13 +511,13 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
}
|
||||
case "anatomy": {
|
||||
ap.append(
|
||||
"<div class=\"answer-item\" id=\"anatomy-text\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item" id="anatomy-text"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".1</span><span style=\"flex:1\">" +
|
||||
'.1</span><span style="flex:1">' +
|
||||
current_question.question +
|
||||
"</span><button class=\"flag\" data-qid=\"" +
|
||||
'</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=1 style=\"margin-right:0\">⚐</button></p></div><textarea class=\"long-answer\" name=\"Reason\" data-answer-section-qidn=1 style=\"overflow: hidden scroll; overflow-wrap: break-word;\"></textarea></div>",
|
||||
'" data-qidn=1 style="margin-right:0">⚐</button></p></div><textarea class="long-answer" name="Reason" data-answer-section-qidn=1 style="overflow: hidden scroll; overflow-wrap: break-word;"></textarea></div>'
|
||||
);
|
||||
|
||||
$(".long-answer").change(function (evt) {
|
||||
@@ -532,7 +525,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
if (evt.target.value.length < 1) {
|
||||
db.answers.delete([cid, eid, qid, "1"]);
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-1",
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-1"
|
||||
).removeClass("question-saved-localdb");
|
||||
return;
|
||||
}
|
||||
@@ -545,9 +538,9 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
ans: evt.target.value,
|
||||
});
|
||||
|
||||
$("#question-list-item-" + window.question_order.indexOf(qid) + "-1").addClass(
|
||||
"question-saved-localdb",
|
||||
);
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-1"
|
||||
).addClass("question-saved-localdb");
|
||||
updateQuestionListPanel();
|
||||
});
|
||||
|
||||
@@ -571,39 +564,39 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
|
||||
case "long": {
|
||||
ap.append(
|
||||
"<div class=\"answer-item\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".1</span><span style=\"flex:1\">Observations</span><button class=\"flag\" data-qid=\"" +
|
||||
'.1</span><span style="flex:1">Observations</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=1 style=\"margin-right:0\">⚐</button></p></div><textarea class=\"long-answer\" data-qidn=1 name=\"Observations\" style=\"overflow-x: hidden; overflow-wrap: break-word; height: 80px;\"></textarea></div>",
|
||||
'" data-qidn=1 style="margin-right:0">⚐</button></p></div><textarea class="long-answer" data-qidn=1 name="Observations" style="overflow-x: hidden; overflow-wrap: break-word; height: 80px;"></textarea></div>'
|
||||
);
|
||||
ap.append(
|
||||
"<div class=\"answer-item\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".2</span><span style=\"flex:1\">Interpretation</span><button class=\"flag\" data-qid=\"" +
|
||||
'.2</span><span style="flex:1">Interpretation</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=2 style=\"margin-right:0\">⚐</button></p></div><textarea class=\"long-answer\" data-qidn=2 name=\"Interpretation\" style=\"overflow-x: hidden; overflow-wrap: break-word; , trueheight: 80px;\"></textarea></div>",
|
||||
'" data-qidn=2 style="margin-right:0">⚐</button></p></div><textarea class="long-answer" data-qidn=2 name="Interpretation" style="overflow-x: hidden; overflow-wrap: break-word; , trueheight: 80px;"></textarea></div>'
|
||||
);
|
||||
ap.append(
|
||||
"<div class=\"answer-item\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".3</span><span style=\"flex:1\">Principle Diagnosis</span><button class=\"flag\" data-qid=\"" +
|
||||
'.3</span><span style="flex:1">Principle Diagnosis</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=3 style=\"margin-right:0\">⚐</button></p></div><textarea class=\"long-answer\" data-qidn=3 name=\"Principle Diagnosis\" style=\"overflow-x: hidden; overflow-wrap: break-word; height: 80px;\"></textarea></div>",
|
||||
'" data-qidn=3 style="margin-right:0">⚐</button></p></div><textarea class="long-answer" data-qidn=3 name="Principle Diagnosis" style="overflow-x: hidden; overflow-wrap: break-word; height: 80px;"></textarea></div>'
|
||||
);
|
||||
ap.append(
|
||||
"<div class=\"answer-item\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".4</span><span style=\"flex:1\">Differential Diagnosis</span><button class=\"flag\" data-qid=\"" +
|
||||
'.4</span><span style="flex:1">Differential Diagnosis</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=4 style=\"margin-right:0\">⚐</button></p></div><textarea class=\"long-answer\" data-qidn=4 name=\"Differential Diagnosis\" style=\"overflow-x: hidden; overflow-wrap: break-word; height: 80px;\"></textarea></div>",
|
||||
'" data-qidn=4 style="margin-right:0">⚐</button></p></div><textarea class="long-answer" data-qidn=4 name="Differential Diagnosis" style="overflow-x: hidden; overflow-wrap: break-word; height: 80px;"></textarea></div>'
|
||||
);
|
||||
ap.append(
|
||||
"<div class=\"answer-item\"><div class=\"answer-label-outer\"><p class=\"answer-label-inner\"><span class=\"answer-label-number\">" +
|
||||
'<div class="answer-item"><div class="answer-label-outer"><p class="answer-label-inner"><span class="answer-label-number">' +
|
||||
display_n +
|
||||
".5</span><span style=\"flex:1\">Management (if appropriate)</span><button class=\"flag\" data-qid=\"" +
|
||||
'.5</span><span style="flex:1">Management (if appropriate)</span><button class="flag" data-qid="' +
|
||||
n +
|
||||
"\" data-qidn=5 style=\"margin-right:0\">⚐</button></p></div><textarea class=\"long-answer\" data-qidn=5 name=\"Management (if appropriate)\" style=\"overflow-x: hidden; overflow-wrap: break-word; height: 80px;\"></textarea></div>",
|
||||
'" data-qidn=5 style="margin-right:0">⚐</button></p></div><textarea class="long-answer" data-qidn=5 name="Management (if appropriate)" style="overflow-x: hidden; overflow-wrap: break-word; height: 80px;"></textarea></div>'
|
||||
);
|
||||
|
||||
// Save long answers on textchange
|
||||
@@ -614,7 +607,10 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
if (evt.target.value.length < 1) {
|
||||
db.answers.delete([cid, eid, qid, qidn]);
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-" + qidn,
|
||||
"#question-list-item-" +
|
||||
window.question_order.indexOf(qid) +
|
||||
"-" +
|
||||
qidn
|
||||
).removeClass("question-saved-localdb");
|
||||
return;
|
||||
}
|
||||
@@ -629,7 +625,10 @@ function loadQuestion(n, section = 1, force_reload = false) {
|
||||
console.log("SAVE", qid, qidn, evt.target.value);
|
||||
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(qid) + "-" + qidn,
|
||||
"#question-list-item-" +
|
||||
window.question_order.indexOf(qid) +
|
||||
"-" +
|
||||
qidn
|
||||
).addClass("question-saved-localdb");
|
||||
|
||||
updateQuestionListPanel();
|
||||
@@ -702,17 +701,21 @@ function updateQuestionListPanel() {
|
||||
"#question-list-item-" +
|
||||
window.question_order.indexOf(answer.qid) +
|
||||
"-" +
|
||||
answer.qidn,
|
||||
answer.qidn
|
||||
).addClass("question-saved-localdb");
|
||||
|
||||
if (window.question_type == "rapid" && answer.qidn == "1") {
|
||||
if (answer.ans == "Abnormal") {
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(answer.qid) + "-2",
|
||||
"#question-list-item-" +
|
||||
window.question_order.indexOf(answer.qid) +
|
||||
"-2"
|
||||
).css("display", "block");
|
||||
} else {
|
||||
$(
|
||||
"#question-list-item-" + window.question_order.indexOf(answer.qid) + "-2",
|
||||
"#question-list-item-" +
|
||||
window.question_order.indexOf(answer.qid) +
|
||||
"-2"
|
||||
).css("display", "none");
|
||||
}
|
||||
}
|
||||
@@ -733,7 +736,7 @@ function updateQuestionListPanel() {
|
||||
window.question_order.indexOf(answer.qid) +
|
||||
"-" +
|
||||
answer.qidn +
|
||||
" span",
|
||||
" span"
|
||||
).css("visibility", "visible");
|
||||
});
|
||||
// $(".long-answer").text(answer.ans);
|
||||
@@ -749,7 +752,7 @@ function updateQuestionListPanel() {
|
||||
function createQuestionListPanel() {
|
||||
$(".question-list-panel").empty();
|
||||
$(".question-list-panel").append(
|
||||
"<div class=\"review-heading\">Questions</div>",
|
||||
'<div class="review-heading">Questions</div>'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -761,19 +764,19 @@ function createQuestionListPanel() {
|
||||
function appendReviewItem(n, qidn) {
|
||||
const qn = n - 1;
|
||||
const el = $(
|
||||
"<div id=\"question-list-item-" +
|
||||
'<div id="question-list-item-' +
|
||||
qn +
|
||||
"-" +
|
||||
qidn +
|
||||
"\" data-qid=" +
|
||||
'" data-qid=' +
|
||||
qn +
|
||||
" data-qidn=\"" +
|
||||
' data-qidn="' +
|
||||
qidn +
|
||||
"\" class=\"question-list-item\">" +
|
||||
'" class="question-list-item">' +
|
||||
n +
|
||||
"." +
|
||||
qidn +
|
||||
"<span class=\"question-list-flag\">⚑</span></div>",
|
||||
'<span class="question-list-flag">⚑</span></div>'
|
||||
);
|
||||
$(".question-list-panel").append(el);
|
||||
// return the new element so it can be hidden if necessary
|
||||
@@ -1059,9 +1062,7 @@ function changeControlSelection() {
|
||||
cornerstone.removeElementData(dicom_element);
|
||||
cornerstone.disable(dicom_element);
|
||||
$(".canvas-panel").remove();
|
||||
$(".figure-open")
|
||||
.removeClass("figure-open")
|
||||
.addClass("figure");
|
||||
$(".figure-open").removeClass("figure-open").addClass("figure");
|
||||
$(dicom_element).remove();
|
||||
}
|
||||
break;
|
||||
@@ -1090,7 +1091,8 @@ function onImageRendered(e) {
|
||||
")";
|
||||
|
||||
// update stack data
|
||||
const stack = eventData.enabledElement.toolStateManager.toolState.stack.data[0];
|
||||
const stack =
|
||||
eventData.enabledElement.toolStateManager.toolState.stack.data[0];
|
||||
if (stack.imageIds.length > 1) {
|
||||
$("option[value=scroll").prop("disabled", false);
|
||||
$("option[value=scroll").prop("hidden", false);
|
||||
@@ -1099,7 +1101,7 @@ function onImageRendered(e) {
|
||||
(stack.currentImageIdIndex + 1) +
|
||||
"/" +
|
||||
stack.imageIds.length +
|
||||
")",
|
||||
")"
|
||||
);
|
||||
|
||||
// Temp way to enable CT window presets
|
||||
@@ -1122,12 +1124,10 @@ function onImageRendered(e) {
|
||||
function disableFullscreen(dicom_element) {
|
||||
// TODO: rescale the image to stop it getting zoomed in
|
||||
$(".canvas-panel-fullscreen").toggleClass(
|
||||
"canvas-panel canvas-panel-fullscreen",
|
||||
"canvas-panel canvas-panel-fullscreen"
|
||||
);
|
||||
$(".question").append($(".canvas-panel"));
|
||||
$(".canvas-panel")
|
||||
.get(0)
|
||||
.scrollIntoView();
|
||||
$(".canvas-panel").get(0).scrollIntoView();
|
||||
|
||||
setDicomCanvasNonFullscreen(dicom_element);
|
||||
}
|
||||
@@ -1195,7 +1195,7 @@ function postAnswers(ans) {
|
||||
$.post("http://localhost:8000/submit_answers", JSON.stringify(ans)).done(
|
||||
(data) => {
|
||||
console.log(data);
|
||||
},
|
||||
}
|
||||
);
|
||||
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
|
||||
}
|
||||
@@ -1205,7 +1205,9 @@ function postAnswers(ans) {
|
||||
* This is defined in index.html
|
||||
*/
|
||||
function loadLocalQuestionSet() {
|
||||
let input; let file; let fr;
|
||||
let input;
|
||||
let file;
|
||||
let fr;
|
||||
|
||||
if (typeof window.FileReader !== "function") {
|
||||
alert("The file API isn't supported on this browser yet.");
|
||||
@@ -1217,7 +1219,7 @@ function loadLocalQuestionSet() {
|
||||
alert("No fileinput element.");
|
||||
} else if (!input.files) {
|
||||
alert(
|
||||
"This browser doesn't seem to support the `files` property of file inputs.",
|
||||
"This browser doesn't seem to support the `files` property of file inputs."
|
||||
);
|
||||
} else if (!input.files[0]) {
|
||||
alert("Please select a file before clicking 'Load'");
|
||||
@@ -1246,7 +1248,7 @@ function submitAnswers() {
|
||||
console.log(
|
||||
getJsonAnswers().then((a) => {
|
||||
postAnswers(a);
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1263,7 +1265,7 @@ function reviewQuestions() {
|
||||
.where({ cid: cid, eid: eid })
|
||||
.toArray()
|
||||
.then(function (answers) {
|
||||
current_answers = {};
|
||||
let current_answers = {};
|
||||
answers.forEach(function (arr, n) {
|
||||
answer = arr["ans"];
|
||||
if (answer == undefined) {
|
||||
@@ -1282,7 +1284,7 @@ function reviewQuestions() {
|
||||
n +
|
||||
">Question " +
|
||||
(n + 1) +
|
||||
":</a> <span>Not answered</span></li>",
|
||||
":</a> <span>Not answered</span></li>"
|
||||
);
|
||||
$("#review-answer-list a").click(function (evt) {
|
||||
loadQuestion(this.dataset.qid);
|
||||
@@ -1291,14 +1293,13 @@ function reviewQuestions() {
|
||||
db.user_answers
|
||||
.get({ qid: qid })
|
||||
.then(function (answers) {
|
||||
question_answers = questions[qid]["answers"];
|
||||
if (answers == undefined) {
|
||||
} else {
|
||||
let question_answers = window.questions[qid]["answers"];
|
||||
if (answers != undefined) {
|
||||
question_answers = question_answers.concat(answers.ans);
|
||||
}
|
||||
|
||||
section_1_answer = current_answers[[qid, "1"]];
|
||||
section_2_answer = current_answers[[qid, "2"]];
|
||||
let section_1_answer = current_answers[[qid, "1"]];
|
||||
let section_2_answer = current_answers[[qid, "2"]];
|
||||
|
||||
if (section_1_answer == undefined) {
|
||||
section_1_answer = "Not Answered";
|
||||
@@ -1327,7 +1328,7 @@ function reviewQuestions() {
|
||||
c,
|
||||
user_answer,
|
||||
normal,
|
||||
question_answers,
|
||||
question_answers
|
||||
) {
|
||||
if (normal) {
|
||||
el.html(
|
||||
@@ -1335,7 +1336,7 @@ function reviewQuestions() {
|
||||
c +
|
||||
"'>Answer: " +
|
||||
user_answer +
|
||||
" (Normal)</span>",
|
||||
" (Normal)</span>"
|
||||
);
|
||||
} else {
|
||||
el.html(
|
||||
@@ -1345,21 +1346,21 @@ function reviewQuestions() {
|
||||
user_answer +
|
||||
" (Abnormal: " +
|
||||
question_answers.join(", ") +
|
||||
")</span>",
|
||||
")</span>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (window.question_type == "rapid") {
|
||||
// First check normal vs abnormal
|
||||
if (questions[qid]["normal"] == true) {
|
||||
if (window.questions[qid]["normal"] == true) {
|
||||
if (section_1_answer == "Normal") {
|
||||
setReviewAnswer(
|
||||
el,
|
||||
"correct",
|
||||
section_1_answer,
|
||||
true,
|
||||
question_answers,
|
||||
question_answers
|
||||
);
|
||||
correct_count++;
|
||||
} else {
|
||||
@@ -1368,7 +1369,7 @@ function reviewQuestions() {
|
||||
"incorrect",
|
||||
section_1_answer,
|
||||
true,
|
||||
question_answers,
|
||||
question_answers
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -1379,7 +1380,7 @@ function reviewQuestions() {
|
||||
"correct",
|
||||
section_2_answer,
|
||||
false,
|
||||
question_answers,
|
||||
question_answers
|
||||
);
|
||||
} else {
|
||||
setReviewAnswer(
|
||||
@@ -1387,7 +1388,7 @@ function reviewQuestions() {
|
||||
"incorrect",
|
||||
section_2_answer,
|
||||
false,
|
||||
question_answers,
|
||||
question_answers
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1400,7 +1401,7 @@ function reviewQuestions() {
|
||||
"correct",
|
||||
section_1_answer,
|
||||
false,
|
||||
question_answers,
|
||||
question_answers
|
||||
);
|
||||
} else {
|
||||
setReviewAnswer(
|
||||
@@ -1408,13 +1409,16 @@ function reviewQuestions() {
|
||||
"incorrect",
|
||||
section_1_answer,
|
||||
false,
|
||||
question_answers,
|
||||
question_answers
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$("#review-score").text(
|
||||
"Score: " + correct_count + " out of " + window.question_order.length,
|
||||
"Score: " +
|
||||
correct_count +
|
||||
" out of " +
|
||||
window.question_order.length
|
||||
);
|
||||
})
|
||||
.catch(function (error) {
|
||||
@@ -1443,7 +1447,7 @@ function markAnswer(qid, type) {
|
||||
option = document.getElementById("rapid-option");
|
||||
if (current_question.normal == true) {
|
||||
$(".answer-panel").append(
|
||||
"<div id='correct-answer-block'>This is normal</div>",
|
||||
"<div id='correct-answer-block'>This is normal</div>"
|
||||
);
|
||||
if (option.value == "Normal") {
|
||||
option.classList.add("correct");
|
||||
@@ -1456,7 +1460,7 @@ function markAnswer(qid, type) {
|
||||
}
|
||||
|
||||
$(".answer-panel").append(
|
||||
"<div id='correct-answer-block'>Correct answer(s):<ul id='answer-list'></ul></div>",
|
||||
"<div id='correct-answer-block'>Correct answer(s):<ul id='answer-list'></ul></div>"
|
||||
);
|
||||
ul = $("#answer-list");
|
||||
|
||||
@@ -1496,8 +1500,8 @@ function markAnswer(qid, type) {
|
||||
$("<button id='mark-correct'>Mark Correct</button>").click(
|
||||
function () {
|
||||
markCorrect(qid, user_answer);
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1519,8 +1523,8 @@ function addFeedback() {
|
||||
$(
|
||||
"<div class='feedback'><h4>Feedback</h4>" +
|
||||
current_question.feedback +
|
||||
"</div>",
|
||||
),
|
||||
"</div>"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1533,9 +1537,8 @@ function markCorrect(qid, user_answer) {
|
||||
db.user_answers
|
||||
.get({ qid: qid })
|
||||
.then(function (answers) {
|
||||
if (answers == undefined) {
|
||||
new_answers = [];
|
||||
} else {
|
||||
let new_answers = [];
|
||||
if (answers != undefined) {
|
||||
new_answers = answers.ans;
|
||||
}
|
||||
|
||||
@@ -1550,7 +1553,7 @@ function markCorrect(qid, user_answer) {
|
||||
$("#mark-correct").remove();
|
||||
}
|
||||
|
||||
textarea = $(".long-answer").attr("class", "correct");
|
||||
let textarea = $(".long-answer").attr("class", "correct");
|
||||
}
|
||||
|
||||
function compareString(a, b) {
|
||||
@@ -1570,23 +1573,23 @@ function answerInArray(arr, ans) {
|
||||
function addFlagEvents() {
|
||||
// Bind flag change events
|
||||
$("button.flag").click(function (event) {
|
||||
el = $(this);
|
||||
nqid = el.attr("data-qid");
|
||||
qid = window.question_order[nqid];
|
||||
qidn = el.attr("data-qidn");
|
||||
const el = $(this);
|
||||
const nqid = el.attr("data-qid");
|
||||
const qid = window.question_order[nqid];
|
||||
const qidn = el.attr("data-qidn");
|
||||
|
||||
el.toggleClass("flag flag-selected");
|
||||
|
||||
if (el.hasClass("flag")) {
|
||||
$("#question-list-item-" + nqid + "-" + qidn + " span").css(
|
||||
"visibility",
|
||||
"hidden",
|
||||
"hidden"
|
||||
);
|
||||
db.flags.delete([cid, eid, qid, qidn]);
|
||||
} else {
|
||||
$("#question-list-item-" + nqid + "-" + qidn + " span").css(
|
||||
"visibility",
|
||||
"visible",
|
||||
"visible"
|
||||
);
|
||||
db.flags.put({ cid: cid, eid: eid, qid: qid, qidn: qidn });
|
||||
}
|
||||
@@ -1669,12 +1672,14 @@ function loadMainImage(image, stack) {
|
||||
|
||||
// Add tool selector
|
||||
$(".canvas-panel").append(
|
||||
"<select class=\"control-overlay\"><option value=\"pan\">pan [p]</option><option value=\"zoom\">zoom [z]</option><option value=\"rotate\">rotate [r]</option><option value=\"scroll\" hidden=\"\" disabled=\"\">scroll (1/1)</option><option value=\"window\">window ()</option><option value=\"abdomen\" hidden=\"\" disabled=\"\">window = abdomen [a]</option><option value=\"pulmonary\" hidden=\"\" disabled=\"\">window = pulmonary [u]</option><option value=\"brain\" hidden=\"\" disabled=\"\">window = brain [b]</option><option value=\"bone\" hidden=\"\" disabled=\"\">window = bone [o]</option><option value=\"reset\">reset [e]</option><option value=\"close\">close [c]</option><option disabled=\"true\" value=\"notes\">[modality = CR][size = 9.8]</option></select>",
|
||||
'<select class="control-overlay"><option value="pan">pan [p]</option><option value="zoom">zoom [z]</option><option value="rotate">rotate [r]</option><option value="scroll" hidden="" disabled="">scroll (1/1)</option><option value="window">window ()</option><option value="abdomen" hidden="" disabled="">window = abdomen [a]</option><option value="pulmonary" hidden="" disabled="">window = pulmonary [u]</option><option value="brain" hidden="" disabled="">window = brain [b]</option><option value="bone" hidden="" disabled="">window = bone [o]</option><option value="reset">reset [e]</option><option value="close">close [c]</option><option disabled="true" value="notes">[modality = CR][size = 9.8]</option></select>'
|
||||
);
|
||||
|
||||
$(".control-overlay")
|
||||
.get(0)
|
||||
.addEventListener("change", function() {changeControlSelection();});
|
||||
.addEventListener("change", function () {
|
||||
changeControlSelection();
|
||||
});
|
||||
}
|
||||
|
||||
function setDicomCanvasNonFullscreen(element) {
|
||||
@@ -1698,7 +1703,6 @@ $("#start-exam-button").click(function(evt) {
|
||||
$.modal.close();
|
||||
});
|
||||
|
||||
|
||||
function manualPanDicom(x, y) {
|
||||
dicom_element = document.getElementById("dicom-image");
|
||||
const viewport = cornerstone.getViewport(dicom_element);
|
||||
|
||||
Reference in New Issue
Block a user