diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index 765530c0..5787bca7 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -8,7 +8,7 @@ var marked_answers = { $(document).ready(function () { $(".answer-list li").each(function (index, element) { - $(element).append($("G")); + $(element).append($("G")); }); $(".answer-list span.answer").each(function (index, element) { @@ -29,9 +29,9 @@ $(document).ready(function () { }); prepAnswerData(); - if($(".post-form").length > 0) { + if ($(".post-form").length > 0) { $(".post-form").get(0).addEventListener("submit", function (e) { - if($(".not-marked").length > 0 && e.submitter.name != "skip") { + if ($(".not-marked").length > 0 && e.submitter.name != "skip") { e.preventDefault(); // before the code alert("Ensure all answers are marked first"); } @@ -39,95 +39,97 @@ $(document).ready(function () { }); } - if($("#dicom-image").length) { + if ($("#dicom-image").length) { console.log("Dicom element found ", $("#dicom-image")); -$('#dicom-image').bind('contextmenu', function(e) { - return false; -}); + $('#dicom-image').bind('contextmenu', function (e) { + return false; + }); -cornerstoneBase64ImageLoader.external.cornerstone = cornerstone; -cornerstoneWebImageLoader.external.cornerstone = cornerstone; -cornerstoneWADOImageLoader.external.cornerstone = cornerstone; + cornerstoneBase64ImageLoader.external.cornerstone = cornerstone; + cornerstoneWebImageLoader.external.cornerstone = cornerstone; + cornerstoneWADOImageLoader.external.cornerstone = cornerstone; -cornerstoneTools.init(); - const PanTool = cornerstoneTools.PanTool; - const ZoomTool = cornerstoneTools.ZoomTool; - const ZoomMouseWheelTool = cornerstoneTools.ZoomMouseWheelTool; - const WwwcTool = cornerstoneTools.WwwcTool; - const WwwcRegionTool = cornerstoneTools.WwwcRegionTool; - const RotateTool = cornerstoneTools.RotateTool; - const StackScrollTool = cornerstoneTools.StackScrollTool; - const MagnifyTool = cornerstoneTools.MagnifyTool; - const ArrowAnnotateTool = cornerstoneTools.ArrowAnnotateTool; + cornerstoneTools.init(); + const PanTool = cornerstoneTools.PanTool; + const ZoomTool = cornerstoneTools.ZoomTool; + const ZoomMouseWheelTool = cornerstoneTools.ZoomMouseWheelTool; + const WwwcTool = cornerstoneTools.WwwcTool; + const WwwcRegionTool = cornerstoneTools.WwwcRegionTool; + const RotateTool = cornerstoneTools.RotateTool; + const StackScrollTool = cornerstoneTools.StackScrollTool; + const MagnifyTool = cornerstoneTools.MagnifyTool; + const ArrowAnnotateTool = cornerstoneTools.ArrowAnnotateTool; -const element = document.getElementById('dicom-image'); -const imageId = element.dataset.url; + const element = document.getElementById('dicom-image'); + const imageId = element.dataset.url; -cornerstone.enable(element); -cornerstone.loadAndCacheImage(imageId).then(function(image) { - cornerstone.displayImage(element, image); + console.log("Dicom - load imageId: ", imageId); - cornerstoneTools.addTool(PanTool); - cornerstoneTools.addTool(ZoomTool); - cornerstoneTools.addTool(ZoomMouseWheelTool); - cornerstoneTools.addTool(WwwcTool); - cornerstoneTools.addTool(WwwcRegionTool); - cornerstoneTools.addTool(RotateTool); - cornerstoneTools.addTool(StackScrollTool); - cornerstoneTools.addTool(MagnifyTool); + cornerstone.enable(element); + cornerstone.loadAndCacheImage(imageId).then(function (image) { + cornerstone.displayImage(element, image); - cornerstoneTools.addTool(ArrowAnnotateTool, { - configuration: { - getTextCallback: () => {}, - changeTextCallback: () => {}, - allowEmptyLabel: true, - renderDashed: false, - drawHandles: false, - drawHandlesOnHover: true, - }, - }); + cornerstoneTools.addTool(PanTool); + cornerstoneTools.addTool(ZoomTool); + cornerstoneTools.addTool(ZoomMouseWheelTool); + cornerstoneTools.addTool(WwwcTool); + cornerstoneTools.addTool(WwwcRegionTool); + cornerstoneTools.addTool(RotateTool); + cornerstoneTools.addTool(StackScrollTool); + cornerstoneTools.addTool(MagnifyTool); + + cornerstoneTools.addTool(ArrowAnnotateTool, { + configuration: { + getTextCallback: () => { }, + changeTextCallback: () => { }, + allowEmptyLabel: true, + renderDashed: false, + drawHandles: false, + drawHandlesOnHover: true, + }, + }); - // Enable our tools - // Avoid incorrect aspect ratio - cornerstoneTools.setToolActive("Pan", { mouseButtonMask: 1 }); - cornerstoneTools.setToolActive("Wwwc", { mouseButtonMask: 2 }); - cornerstoneTools.setToolActive("ZoomMouseWheel", { mouseButtonMask: 3 }); - cornerstoneTools.setToolActive("Zoom", { mouseButtonMask: 4 }); + // Enable our tools + // Avoid incorrect aspect ratio + cornerstoneTools.setToolActive("Pan", { mouseButtonMask: 1 }); + cornerstoneTools.setToolActive("Wwwc", { mouseButtonMask: 2 }); + cornerstoneTools.setToolActive("ZoomMouseWheel", { mouseButtonMask: 3 }); + cornerstoneTools.setToolActive("Zoom", { mouseButtonMask: 4 }); - if (element.dataset.edit_annotation == "true") { - cornerstoneTools.setToolActive("ArrowAnnotate", { mouseButtonMask: 2 }); - } else { - cornerstoneTools.setToolEnabled("ArrowAnnotate"); - } + if (element.dataset.edit_annotation == "true") { + cornerstoneTools.setToolActive("ArrowAnnotate", { mouseButtonMask: 2 }); + } else { + cornerstoneTools.setToolEnabled("ArrowAnnotate"); + } - if (element.dataset.annotations) { - loadJsonToolStateOnCurrentImage(element.dataset.annotations) - } + if (element.dataset.annotations) { + loadJsonToolStateOnCurrentImage(element.dataset.annotations) + } - cornerstone.resize(element); + cornerstone.resize(element); -}); + }); } -if ($("#question-mark-list").length) { -$(".show-all-button").click(() => { - $("#question-mark-list li").show(); -}); -$(".show-unmarked-button").click(() => { + if ($("#question-mark-list").length) { + $(".show-all-button").click(() => { + $("#question-mark-list li").show(); + }); + $(".show-unmarked-button").click(() => { console.log("TESTIG"); - $("#question-mark-list li").each((n, el) => { - console.log(el); - if (el.dataset.markcount < 1) { $(el).hide(); } - }) -}); + $("#question-mark-list li").each((n, el) => { + console.log(el); + if (el.dataset.markcount < 1) { $(el).hide(); } + }) + }); -} + } }); diff --git a/anatomy/views.py b/anatomy/views.py index 6e23bcf6..02353101 100644 --- a/anatomy/views.py +++ b/anatomy/views.py @@ -119,6 +119,8 @@ def exam_question_detail(request, pk, sk): pos = exam.get_question_index(question) + 1 + print(question.exams.through.sort_value) + previous = -1 if sk > 0: previous = sk - 1