114 lines
3.6 KiB
JavaScript
114 lines
3.6 KiB
JavaScript
|
|
var marked_answers = {
|
|
"correct": [],
|
|
"half-correct": [],
|
|
"incorrect": [],
|
|
}
|
|
|
|
|
|
$(document).ready(function () {
|
|
$(".answer-list li").each(function (index, element) {
|
|
console.log(element);
|
|
$(element).click(function (e) {
|
|
|
|
var classes = ['correct', 'half-correct', 'incorrect'];
|
|
$(element).each(function () {
|
|
this.className = classes[($.inArray(this.className, classes) + 1) % classes.length];
|
|
});
|
|
|
|
prepAnswerData();
|
|
|
|
|
|
|
|
});
|
|
});
|
|
prepAnswerData();
|
|
|
|
if($(".post-form").length > 0) {
|
|
$(".post-form").get(0).addEventListener("submit", function (e) {
|
|
if($(".not-marked").length > 0) {
|
|
e.preventDefault(); // before the code
|
|
alert("Ensure all answers are marked first");
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
if($("#dicom-element").length) {
|
|
|
|
cornerstoneBase64ImageLoader.external.cornerstone = cornerstone;
|
|
cornerstoneWebImageLoader.external.cornerstone = cornerstone;
|
|
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
|
|
|
|
cornerstoneTools.init();
|
|
|
|
const element = document.getElementById('dicom-element');
|
|
const imageId = element.dataset.url;
|
|
|
|
cornerstone.enable(element);
|
|
cornerstone.loadAndCacheImage(imageId).then(function(image) {
|
|
cornerstone.displayImage(element, image);
|
|
|
|
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;
|
|
|
|
cornerstoneTools.addTool(PanTool);
|
|
cornerstoneTools.addTool(ZoomTool);
|
|
cornerstoneTools.addTool(ZoomMouseWheelTool);
|
|
cornerstoneTools.addTool(WwwcTool);
|
|
cornerstoneTools.addTool(WwwcRegionTool);
|
|
cornerstoneTools.addTool(RotateTool);
|
|
cornerstoneTools.addTool(StackScrollTool);
|
|
cornerstoneTools.addTool(MagnifyTool);
|
|
// Enable our tools
|
|
|
|
cornerstoneTools.setToolActive("Pan", { mouseButtonMask: 1 });
|
|
cornerstoneTools.setToolActive("WwwcTool", { mouseButtonMask: 2 });
|
|
cornerstoneTools.setToolActive("ZoomMouseWheel", { mouseButtonMask: 3 });
|
|
cornerstoneTools.setToolActive("Zoom", { mouseButtonMask: 4 });
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
function prepAnswerData() {
|
|
//$("#id_correct").val($("li.correct").map(function() {
|
|
// ans = $(this).text();
|
|
// window.marked_answers["correct"].push(ans);
|
|
// return ans
|
|
//}).get().join('--//--'));
|
|
//$("#id_half_correct").val($("li.half-correct").map(function() {
|
|
// ans = $(this).text();
|
|
// window.marked_answers["half-correct"].push(ans);
|
|
// return ans;
|
|
//}).get().join('--//--'));
|
|
//$("#id_incorrect").val($("li.incorrect").map(function() {
|
|
// ans = $(this).text();
|
|
// window.marked_answers["incorrect"].push(ans);
|
|
// return ans;
|
|
//}).get().join('--//--'));
|
|
|
|
window.marked_answers["correct"] = [];
|
|
window.marked_answers["half-correct"] = [];
|
|
window.marked_answers["incorrect"] = [];
|
|
$("li.correct").map(function () {
|
|
ans = $(this).text();
|
|
window.marked_answers["correct"].push(ans);
|
|
})
|
|
$("li.half-correct").map(function () {
|
|
ans = $(this).text();
|
|
window.marked_answers["half-correct"].push(ans);
|
|
})
|
|
$("li.incorrect").map(function () {
|
|
ans = $(this).text();
|
|
window.marked_answers["incorrect"].push(ans);
|
|
})
|
|
$("#id_marked_answers").val(JSON.stringify(window.marked_answers));
|
|
}
|