.
This commit is contained in:
@@ -57,6 +57,8 @@ class AnatomyQuestionTable(tables.Table):
|
||||
)
|
||||
exams = tables.ManyToManyColumn(verbose_name="Exams")
|
||||
|
||||
selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
|
||||
|
||||
class Meta:
|
||||
model = AnatomyQuestion
|
||||
template_name = "django_tables2/bootstrap4.html"
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
</div>
|
||||
<p><a href="{% url 'anatomy: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}}>
|
||||
<img src="{{ question.image|thumbnail_url:'exam-list' }}" alt="thumbail" />
|
||||
{{ question.description }}
|
||||
<br />
|
||||
@@ -33,6 +33,7 @@
|
||||
<a href="{% url 'anatomy: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">
|
||||
@@ -130,6 +131,37 @@
|
||||
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 'anatomy: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 %}
|
||||
+1
-1
@@ -953,7 +953,7 @@ def question_save_annotation(request, pk):
|
||||
return JsonResponse(data, status=400)
|
||||
|
||||
|
||||
AnatomyExamViews = ExamViews(Exam, "anatomy", "anatomy", loadJsonAnswer)
|
||||
AnatomyExamViews = ExamViews(Exam, AnatomyQuestion, "anatomy", "anatomy", loadJsonAnswer)
|
||||
|
||||
class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
|
||||
model = CidUserAnswer
|
||||
|
||||
Reference in New Issue
Block a user