From 02d7e772c6e14fb9dfc504aa0f48cfdb54e05a1c Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 27 Jan 2021 10:41:19 +0000 Subject: [PATCH 1/4] . --- js/viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/viewer.js b/js/viewer.js index a277f63..19d59a7 100644 --- a/js/viewer.js +++ b/js/viewer.js @@ -511,7 +511,7 @@ export function openMainImage(current_question, t, source) { function loadAnnotation(imageId, annotation) { const toolStateManager = cornerstoneTools.globalImageIdSpecificToolStateManager; - if (annotation.length < 1) { return } + if (annotation == undefined || annotation.length < 1) { return } let tool_state_no_id = JSON.parse(annotation); From f7fc1d91347b276c7cc8a8c2fd575078b4962945 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 28 Jan 2021 09:48:38 +0000 Subject: [PATCH 2/4] Categorise packet lists --- css/main.css | 5 +++++ js/main.js | 29 +++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/css/main.css b/css/main.css index b493dd1..bb64b41 100644 --- a/css/main.css +++ b/css/main.css @@ -1007,4 +1007,9 @@ display: block #options-link { padding-top: 40px; +} + +.packet-list-title { + text-transform: capitalize; + font-weight: bolder; } \ No newline at end of file diff --git a/js/main.js b/js/main.js index 9990670..4753842 100644 --- a/js/main.js +++ b/js/main.js @@ -127,7 +127,19 @@ async function loadExamList(data) { if (exams_completed.indexOf(name) > -1) { c = " session-completed"; } - $("#packet-list").append( + + let list; + if (exam.type != undefined) { + if ($(`#packet-list .${exam.type}`).length) { + list = $(`#packet-list .${exam.type}`); + } else { + list = $("#packet-list").append(`
${exam.type}
`); + } + } else { + list = $("#packet-list"); + } + + list.append( $(`
`) .text(name) .click(function () { @@ -186,6 +198,19 @@ async function loadPacketList(data) { $("#packet-list").empty(); window.packet_list.forEach(function (packet) { + // Seperate packet types + let list; + if (packet.type != undefined) { + if ($(`#packet-list .${packet.type}`)) { + list = $(`#packet-list .${packet.type}`); + } else { + list = $(`
${packet.type}
`); + $("#packet-list").append(list); + } + } else { + list = $("#packet-list"); + } + let c = ""; if (packets_started.indexOf(packet) > -1) { c = " session-started"; @@ -193,7 +218,7 @@ async function loadPacketList(data) { if (packets_completed.indexOf(packet) > -1) { c = " session-completed"; } - $("#packet-list").append( + list.append( $(`
`) .text(packet) .click(function () { From 9ede50983959fa68e2f3e636910b0d339c517459 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 28 Jan 2021 10:58:03 +0000 Subject: [PATCH 3/4] update posting answers to server --- js/interact.js | 51 ++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/js/interact.js b/js/interact.js index cefee76..085142a 100644 --- a/js/interact.js +++ b/js/interact.js @@ -4,7 +4,11 @@ export function submitAnswers(window, db) { console.log( getJsonAnswers(window, db).then((a) => { - postAnswers(a); + let json = { + "eid": window.eid, + "answers": JSON.stringify(a), + }; + postAnswers(json); }) ); } @@ -28,9 +32,10 @@ export function getJsonAnswers(window, db) { * @param {*} ans - json representation of answers */ export function postAnswers(ans) { - $("#progress").html(`Submitting answers...`); + $("#progress").html("Submitting answers..."); // ans = {"test" : 1} - $.post(window.config.exam_submit_url, JSON.stringify(ans)).done((data) => { + console.log(ans) + $.post(window.config.exam_submit_url, ans, null, "json").done((data) => { console.log(data); if (data.success) { if (data.question_count == window.number_of_questions) { @@ -61,25 +66,27 @@ export function postAnswers(ans) { } } else { alert(`Error submitting answers: ${data.error}`); - var docHeight = $(document).height(); + var docHeight = $(document).height(); - $("body").append(`

An error has occured when submit your answers. A copy of your answers are displayed below, you may wish to save a copy. Please refresh this page to continue.

${JSON.stringify(ans)}
`); + $("body").append( + `

An error has occured when submit your answers. A copy of your answers are displayed below, you may wish to save a copy. Please refresh this page to continue.

${JSON.stringify( + ans + )}
` + ); - $("#overlay") - .height(docHeight) - .css({ - 'opacity' : 0.9, - 'position': 'absolute', - 'top': 0, - 'left': 0, - 'background-color': 'black', - 'width': '100%', - 'user-select': 'text', - '-moz-user-select': 'text', - '-webkit-user-select': 'text', - 'z-index': 5000 - }); - } - }); - // $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans)); + $("#overlay").height(docHeight).css({ + opacity: 0.9, + position: "absolute", + top: 0, + left: 0, + "background-color": "black", + width: "100%", + "user-select": "text", + "-moz-user-select": "text", + "-webkit-user-select": "text", + "z-index": 5000, + }); + } + }); + // $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans)); } From d066d283a45c245bbae7d0bdf96258ff014cdeb3 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 1 Feb 2021 12:09:46 +0000 Subject: [PATCH 4/4] few fixes --- index.html | 2 +- js/interact.js | 116 ++++++++++++++++++++++++++++--------------------- 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/index.html b/index.html index 05248b1..fad2ee8 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@