This commit is contained in:
Ross
2021-02-23 21:12:50 +00:00
parent 38a2165893
commit 7f4dbfec51
12 changed files with 153 additions and 24 deletions
+2
View File
@@ -44,6 +44,8 @@ class RapidTable(tables.Table):
orderable=False)
images = ImageColumn("images", orderable=False)
selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
class Meta:
model = Rapid
template_name = "django_tables2/bootstrap4.html"
+36 -2
View File
@@ -16,10 +16,10 @@
</div>
<p><a href="{% url 'rapids:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
<ol id="full-question-list">
<ol id="full-question-list" class="sortable">
{% for question in questions.all %}
<li>
<li data-question_pk={{question.pk}}>
{% for image in question.GetImages %}
<img src="{{ image|thumbnail_url:'exam-list' }}" alt="thumbail" />
{% endfor %}
@@ -39,6 +39,7 @@
<a href="{% url 'rapids:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a>
<button id='button-open-access'>Make questions open access</button>
<button id='button-closed-access'>Make questions closed access</button>
<button id='button-edit-order'>Edit exam order</button>
</div>
<script type="text/javascript">
@@ -136,6 +137,39 @@
console.log('[Done]');
})
})
$("#button-edit-order").click(function () {
$(this).remove();
sortable('.sortable');
$("#full-question-list").append($("<button>Save exam order</button>").click(() => {
new_order = [];
$("#full-question-list li").each((n, el) => {
new_order.push(el.dataset.question_pk)
})
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_exam_order: JSON.stringify(new_order),
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Exam order changed.')
}
})
.always(function () {
console.log('[Done]');
})
}));
});
});
</script>
{% endblock %}
+2 -2
View File
@@ -7,10 +7,10 @@
Edit</a>
{% if question.normal %}
<h3>This question is normal</h3>
Answers will be automatically marked.<br/>
Answers will be automatically marked.
{% else %}
<h3>This question is abnormal</h3>
Answers marked as normal will be automatically marked.
Answers marked as normal will be automatically marked.<br/>
Region: {{ question.get_regions }}, Abnormalities: {{ question.get_abnormalities }}
{% endif %}
<div id="single-dicom-viewer" class="marking-dicom" data-images="{{question.GetImageUrls}}"
+1 -1
View File
@@ -875,4 +875,4 @@ class QuestionDelete(AuthorOrCheckerRequiredMixin, DeleteView):
model = Rapid
success_url = reverse_lazy("rapids:rapid_view")
RapidExamViews = ExamViews(Exam, "rapids", "rapid", loadJsonAnswer)
RapidExamViews = ExamViews(Exam, Rapid, "rapids", "rapid", loadJsonAnswer)