fixes
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
|
||||
@@ -34,38 +34,4 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#annotation-json-toggle").click(() => { $("#annotation-json-content").toggle() });
|
||||
|
||||
// send request to change the is_private state on customSwitches toggle
|
||||
$("#save-annotations").click(function () {
|
||||
json = getJsonToolStateNoId();
|
||||
$.ajax({
|
||||
url: "{% url 'anatomy:question_save_annotation' pk=question.pk %}",
|
||||
data: {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
annotation: json,
|
||||
},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
})
|
||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||
.done(function (data) {
|
||||
console.log(data);
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
if (data.status == "success") {
|
||||
toastr.info('Annotations saved')
|
||||
} else {
|
||||
toastr.warning('Error saving annotations')
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
+4
-4
@@ -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)
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<script src="{% static 'tagulous/adaptor/select2-3.js' %}"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dexie/3.0.3/dexie.min.js" integrity="sha512-aEtNzq8X5E0ambgeM68H174SOXaANJ6wDqJ0TuVIx4R2J4fRdUA0nLzx0faA1mmViqb+r0VX7cOXkskxyJENUA==" crossorigin="anonymous"></script>
|
||||
<script src="{% static 'js/toastr.min.js' %}"></script>
|
||||
<script src="{% static 'js/cornerstone/hammer.js' %}"></script>
|
||||
<script src="{% static 'js/cornerstone/cornerstone.min.js' %}"></script>
|
||||
<script src="{% static 'js/cornerstone/dicomParser.min.js' %}"></script>
|
||||
|
||||
Reference in New Issue
Block a user