From 1fbc3b4bb8e67edcfac64c83b79e81da9f6f86c6 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 1 Feb 2021 12:20:48 +0000 Subject: [PATCH] fixes --- anatomy/models.py | 4 ++ anatomy/static/js/anatomy.js | 31 ++++------- anatomy/templates/anatomy/mark.html | 2 +- .../templates/anatomy/question_detail.html | 54 +++++++++++++------ anatomy/views.py | 4 +- .../templates/physics/question_detail.html | 34 ------------ rapids/views.py | 8 +-- templates/base.html | 1 + 8 files changed, 62 insertions(+), 76 deletions(-) diff --git a/anatomy/models.py b/anatomy/models.py index c6290a4d..3dd13c60 100644 --- a/anatomy/models.py +++ b/anatomy/models.py @@ -196,6 +196,10 @@ class AnatomyQuestion(models.Model): marked_answers = correct_answers | half_mark_answers | incorrect_answers return marked_answers + def get_annotations(self): + return self.image_annotations + + class Answer(models.Model): question = models.ForeignKey( diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index 043271c6..4337b5f8 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -53,8 +53,17 @@ $(document).ready(function () { let single_dicom = document.getElementById("single-dicom-viewer"); if (single_dicom) { - let images = single_dicom.dataset.images.split(","); - let annotations = single_dicom.dataset.annotations.split(","); + + let images = single_dicom.dataset.images; + if (images.indexOf(",") > 0) { + images = images.split(","); + } + + let annotations = single_dicom.dataset.annotations; + if (annotations != undefined && annotations.indexOf(",") > 0) { + annotations = annotations; + } + dicomViewer.loadCornerstone($(single_dicom), null, images, annotations); } @@ -112,24 +121,6 @@ function prepAnswerData() { $("#id_marked_answers").val(JSON.stringify(window.marked_answers)); } -function getJsonToolStateNoId() { - const el = document.getElementById("dicom-image"); - - const c = cornerstone.getEnabledElement(el); - - const toolStateManager = cornerstoneTools.globalImageIdSpecificToolStateManager; - - const image_id = c.image.imageId; - - const state_with_id = toolStateManager.saveToolState() - - const json_tool_state = JSON.stringify(state_with_id[image_id]); - - return json_tool_state; - -} - - function loadJsonToolStateOnCurrentImage(json) { let el = document.getElementById("dicom-image"); diff --git a/anatomy/templates/anatomy/mark.html b/anatomy/templates/anatomy/mark.html index 6aecbf83..943718ff 100644 --- a/anatomy/templates/anatomy/mark.html +++ b/anatomy/templates/anatomy/mark.html @@ -5,7 +5,7 @@ Edit Admin Edit

{{ question.question_type }}

-
+
{% csrf_token %} diff --git a/anatomy/templates/anatomy/question_detail.html b/anatomy/templates/anatomy/question_detail.html index 3e930cdb..a13bcf67 100644 --- a/anatomy/templates/anatomy/question_detail.html +++ b/anatomy/templates/anatomy/question_detail.html @@ -5,24 +5,26 @@ {% if exam %}
-{% if previous > -1 %} -Previous question -{% endif %} - This question is part of exam: {{exam.name}} [{{pos}}/{{exam_length}}] -{% if next %} -Next question -{% endif %} + {% if previous > -1 %} + Previous question + {% endif %} + This question is part of exam: {{exam.name}} [{{pos}}/{{exam_length}}] + {% if next %} + Next question + {% endif %}
{% endif %} -
- +
+
-Edit -Clone -Admin Edit + Edit + Clone + Admin Edit
Created: {{ question.created_date }}
@@ -53,14 +55,16 @@
Author: {% for user in question.author.all %} - {{ author }}, - {% endfor %} + {{ author }}, + {% endfor %}
Open access: {{ question.open_access }}
- Annotation JSON (+/-):
{{ question.image_annotations }}
+ Annotation JSON (+/-): +
{{ question.image_annotations }}
+
{% endblock %} \ No newline at end of file diff --git a/anatomy/views.py b/anatomy/views.py index 42205f19..b6f9ce9b 100644 --- a/anatomy/views.py +++ b/anatomy/views.py @@ -569,7 +569,7 @@ def exam_json(request, pk): if not exam.active: raise Http404("No available exam") - exam_json_cache = cache.get("exam_json_{}".format(pk)) + exam_json_cache = cache.get("anatomy_exam_json_{}".format(pk)) if exam_json_cache is not None and not exam.recreate_json: exam_json_cache["cached"] = True @@ -608,7 +608,7 @@ def exam_json(request, pk): exam.recreate_json = False exam.save() - cache.set("exam_json_{}".format(pk), exam_json, 3600) + cache.set("anatomy_exam_json_{}".format(pk), exam_json, 3600) return JsonResponse(exam_json) diff --git a/physics/templates/physics/question_detail.html b/physics/templates/physics/question_detail.html index f2ea82d8..a626b5ab 100644 --- a/physics/templates/physics/question_detail.html +++ b/physics/templates/physics/question_detail.html @@ -34,38 +34,4 @@ {% endfor %}
- {% endblock %} \ No newline at end of file diff --git a/rapids/views.py b/rapids/views.py index 88157e2d..978aa5ef 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -19,7 +19,7 @@ from django.http import Http404, JsonResponse from django.http import HttpResponseRedirect, HttpResponse from .forms import ( - MarkRapidQuestionForm, RapidForm, + RapidForm, ImageFormSet, NoteForm, RegionForm, @@ -819,7 +819,7 @@ def exam_json(request, pk): if not exam.active: raise Http404("No available exam") - exam_json_cache = cache.get("exam_json_{}".format(pk)) + exam_json_cache = cache.get("rapids_exam_json_{}".format(pk)) if exam_json_cache is not None and not exam.recreate_json: exam_json_cache["cached"] = True @@ -855,7 +855,7 @@ def exam_json(request, pk): } if feedback_images: - exam_questions["feedback_image"] = feedback_images + exam_questions[q.id]["feedback_image"] = feedback_images exam_json = { @@ -874,7 +874,7 @@ def exam_json(request, pk): exam.recreate_json = False exam.save() - cache.set("exam_json_{}".format(pk), exam_json, 3600) + cache.set("rapids_exam_json_{}".format(pk), exam_json, 3600) return JsonResponse(exam_json) diff --git a/templates/base.html b/templates/base.html index 3c7aad72..34a10aa0 100644 --- a/templates/base.html +++ b/templates/base.html @@ -24,6 +24,7 @@ +