This commit is contained in:
Ross
2021-10-02 15:48:00 +01:00
parent 57cbf601aa
commit fc09097958
+37 -31
View File
@@ -10,21 +10,23 @@
<a href="{% url 'anatomy:question_clone' question.id %}" title="Clone the Question">Clone</a> <a href="{% url 'anatomy:question_clone' question.id %}" title="Clone the Question">Clone</a>
<a href="{% url 'anatomy:question_delete' pk=question.pk %}" title="Delete the Question">Delete</a> <a href="{% url 'anatomy:question_delete' pk=question.pk %}" title="Delete the Question">Delete</a>
<a href="{% url 'anatomy:question_delete' pk=question.pk %}" title="Delete the Question">Delete</a> <a href="{% url 'anatomy:question_delete' pk=question.pk %}" title="Delete the Question">Delete</a>
<a href="#" onclick="return window.create_popup_window('{% url 'feedback_create' question_type='anatomy' pk=question.pk %}')"> Add Note</a> <a href="#"
onclick="return window.create_popup_window('{% url 'feedback_create' question_type='anatomy' pk=question.pk %}')">
Add Note</a>
<a href="{% url 'admin:anatomy_anatomyquestion_change' question.id %}" <a href="{% url 'admin:anatomy_anatomyquestion_change' question.id %}"
title="Edit the Question using the admin interface">Admin Edit</a> title="Edit the Question using the admin interface">Admin Edit</a>
{% if exam %} {% if exam %}
<div> <div>
{% if previous > -1 %} {% if previous > -1 %}
<a href="{% url 'anatomy:exam_question_detail' exam.id previous %}">Previous question</a> <a href="{% url 'anatomy:exam_question_detail' exam.id previous %}">Previous question</a>
{% endif %}
Viewing question as 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 %} {% endif %}
Viewing question as 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 %}
</div> </div>
<button id="save-annotations">Save Annotations</button> <button id="save-annotations">Save Annotations</button>
<div id="dicom-image" class="dicom-image" data-url="https://www.penracourses.org.uk{{ question.image.url}}" <div id="dicom-image" class="dicom-image" data-url="https://www.penracourses.org.uk{{ question.image.url}}"
@@ -68,38 +70,44 @@
</div> </div>
{% include 'question_notes.html' %} {% include 'question_notes.html' %}
<div> <div>
<span id="annotation-json-toggle">Annotation JSON (+/-):</span> <span id="annotation-json-content"> <details>
<summary>
{% if question.image_annotations %} <span id="annotation-json-toggle">Annotation JSON (+/-):</span> <span id="annotation-json-content">
</summary>
{% if question.image_annotations %}
<pre>{{ question.image_annotations }}</pre> <pre>{{ question.image_annotations }}</pre>
{% else %} {% else %}
No saved annotations. No saved annotations.
{% endif %} {% endif %}
</span> </span>
</details>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$("#annotation-json-toggle").click(() => { $("#annotation-json-content").toggle() }); //$("#annotation-json-toggle").click(() => {
// $("#annotation-json-content").toggle()
//});
// send request to change the is_private state on customSwitches toggle // send request to change the is_private state on customSwitches toggle
$("#save-annotations").click(function () { $("#save-annotations").click(function () {
json = getJsonToolStateNoId(); json = getJsonToolStateNoId();
$.ajax({ $.ajax({
url: "{% url 'anatomy:question_save_annotation' pk=question.pk %}", url: "{% url 'anatomy:question_save_annotation' pk=question.pk %}",
data: { data: {
csrfmiddlewaretoken: "{{ csrf_token }}", csrfmiddlewaretoken: "{{ csrf_token }}",
annotation: json, annotation: json,
}, },
type: "POST", type: "POST",
dataType: "json", dataType: "json",
error: function(e) { error: function (e) {
toastr.warning(`Error saving annotations`) toastr.warning(`Error saving annotations`)
console.log(e); console.log(e);
}, },
}) })
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) { .done(function (data) {
console.log(data); console.log(data);
@@ -134,7 +142,5 @@
return json_tool_state; return json_tool_state;
} }
</script> </script>
{% endblock %} {% endblock %}