This commit is contained in:
Ross
2021-02-01 12:20:48 +00:00
parent 7d3abd0680
commit 1fbc3b4bb8
8 changed files with 62 additions and 76 deletions
+4
View File
@@ -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(
+11 -20
View File
@@ -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");
+1 -1
View File
@@ -5,7 +5,7 @@
<a href="{% url 'anatomy:anatomy_question_update' question.id %}" title="Edit the Question">Edit</a> <a href="{% url 'admin:anatomy_anatomyquestion_change' question.id %}" title="Edit the Question using the admin interface">Admin Edit</a>
<h3>{{ question.question_type }}</h3>
<div id="dicom-image" class="marking-dicom dicom-image" data-url="http://penracourses.org.uk{{ question.image.url}}" data-annotations='{{question.image_annotations}}'>
<div id="single-dicom-viewer" class="marking-dicom" data-images="http://penracourses.org.uk{{ question.image.url}}" data-annotations='{{question.get_annotations}}'>
</div>
<div class="marking">
<form method="POST" class="post-form">{% csrf_token %}
+39 -15
View File
@@ -5,24 +5,26 @@
{% if exam %}
<div>
{% if previous > -1 %}
<a href="{% url 'anatomy:exam_question_detail' exam.id previous %}">Previous question</a>
{% endif %}
This question is part of exam: {{exam.name}} [{{pos}}/{{exam_length}}]
{% if next %}
<a href="{% url 'anatomy:exam_question_detail' exam.id next %}">Next question</a>
{% endif %}
{% if previous > -1 %}
<a href="{% url 'anatomy:exam_question_detail' exam.id previous %}">Previous question</a>
{% endif %}
This question is part of exam: {{exam.name}} [{{pos}}/{{exam_length}}]
{% if next %}
<a href="{% url 'anatomy:exam_question_detail' exam.id next %}">Next question</a>
{% endif %}
</div>
{% endif %}
<button id="save-annotations">Save Annotations</button>
<div id="dicom-image" class="dicom-image" data-url="http://penracourses.org.uk{{ question.image.url}}" data-annotations='{{question.image_annotations}}' data-edit_annotation=true></div>
<!-- testing -->
<div id="dicom-image" class="dicom-image" data-url="http://penracourses.org.uk{{ question.image.url}}"
data-annotations='{{question.image_annotations}}' data-edit_annotation=true></div>
<!-- testing -->
<!--<div id="dicom-image" data-url="http://localhost:8000/static/abdoct.jpg"
data-annotations='{{question.image_annotations}}' data-edit_annotation=true></div>-->
<div class="question">
<a href="{% url 'anatomy:anatomy_question_update' question.id %}" title="Edit the Question">Edit</a>
<a href="{% url 'anatomy:question_clone' question.id %}" title="Clone the Question">Clone</a>
<a href="{% url 'admin:anatomy_anatomyquestion_change' question.id %}" title="Edit the Question using the admin interface">Admin Edit</a>
<a href="{% url 'anatomy:anatomy_question_update' question.id %}" title="Edit the Question">Edit</a>
<a href="{% url 'anatomy:question_clone' question.id %}" title="Clone the Question">Clone</a>
<a href="{% url 'admin:anatomy_anatomyquestion_change' question.id %}"
title="Edit the Question using the admin interface">Admin Edit</a>
<div class="date">
Created: {{ question.created_date }}
</div>
@@ -53,14 +55,16 @@
</div>
<div>
Author: {% for user in question.author.all %}
{{ author }},
{% endfor %}
{{ author }},
{% endfor %}
</div>
<div>
Open access: {{ question.open_access }}
</div>
<div>
<span id="annotation-json-toggle">Annotation JSON (+/-):</span> <span id="annotation-json-content"><pre>{{ question.image_annotations }}</pre></span>
<span id="annotation-json-toggle">Annotation JSON (+/-):</span> <span id="annotation-json-content">
<pre>{{ question.image_annotations }}</pre>
</span>
</div>
</div>
<script type="text/javascript">
@@ -96,5 +100,25 @@
})
})
});
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;
}
</script>
{% endblock %}
+2 -2
View File
@@ -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)