This commit is contained in:
Ross
2021-10-17 11:45:24 +01:00
parent 85e5a34cd6
commit 1b94bf6a9b
4 changed files with 28 additions and 15 deletions
+1 -1
View File
@@ -59,7 +59,7 @@
{% endfor %}
</div>
{% if can_edit %}
<p><button id='button-edit-order'>Edit exam order</button></p>
<p><button id='button-edit-order'>Edit question order / Delete questions</button></p>
{% endif %}
<div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
+14 -2
View File
@@ -36,9 +36,9 @@ from longs.models import Exam as LongExam
from anatomy.models import AnatomyQuestion as AnatomyQuestion
from anatomy.models import Exam as AnatomyExam
from sbas.models import Question as SbasQuestion
#from sbas.models import Exam as SbasExam
from sbas.models import Exam as SbasExam
from physics.models import Question as PhysicsQuestion
#from physics.models import Exam as PhysicsExam
from physics.models import Exam as PhysicsExam
from django.db.models import Case, When
from django.conf import settings
@@ -109,6 +109,12 @@ def generic_exam_json_edit(request):
elif question_type == "anatomy":
Exam = AnatomyExam
Question = AnatomyQuestion
elif question_type == "physics":
Exam = PhysicsExam
Question = PhysicsQuestion
elif question_type == "sbas":
Exam = SbasExam
Question = SbasQuestion
else:
data = {"status": "error"}
return JsonResponse(data, status=400)
@@ -116,6 +122,12 @@ def generic_exam_json_edit(request):
exam = get_object_or_404(Exam, pk=request.POST.get("exam_id"))
#if "exam_toggle_active" in request.POST:
# active = json.loads(request.POST.get("active"))
# data = {"status": "success"}
# return JsonResponse(data, status=200)
if "add_exam_questions" in request.POST:
question_ids = json.loads(request.POST.get("add_exam_questions"))
#question_objects = Question.objects.filter(pk__in=question_ids)
+9 -1
View File
@@ -74,7 +74,7 @@
{% if can_edit %}
<p><button id='button-edit-order'>Edit exam order</button></p>
<p><button id='button-edit-order'>Edit question order / Delete questions</button></p>
<div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
JSON creation id: {{exam.exam_json_id}}
@@ -189,6 +189,14 @@
$(this).remove();
sortable('.sortable');
$("#full-question-list li").each((n, el) => {
$(el).append($(
"<span class='exam-question-delete flex-col'><button>DELETE</button></span>"
).click(() => {
el.remove();
}));
})
$("#full-question-list").append($("<button>Save exam order</button>").click(() => {
new_order = [];
$("#full-question-list li").each((n, el) => {
+4 -11
View File
@@ -28,7 +28,7 @@
</div>
<div class="parent-help" title="Click to enable / disable the exam">
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}> <span
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %} data-posturl="{% url 'rapids:exam_toggle_active' pk=exam.pk %}"> <span
class="help-text">[When checked the exam will be available to take in the test system]</span>
</div>
{% if exam.exam_mode %}
@@ -72,7 +72,7 @@
{{ author }},
{% endfor %}
</div>
<p><button id='button-edit-order' title='click and drag questions to change order'>Edit exam order</button></p>
<p><button id='button-edit-order' title='click and drag questions to change order'>Edit question order / Delete questions</button></p>
<div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
JSON creation id: {{exam.exam_json_id}}
@@ -87,7 +87,8 @@
<script type="text/javascript">
$(document).ready(function () {
// send request to change the is_private state on customSwitches toggle
$("#exam-active-switch").on("change", function () {
$("#exam-active-switch").on("change", function (el) {
console.log(el)
$.ajax({
url: "{% url 'rapids:exam_toggle_active' pk=exam.pk %}",
data: {
@@ -195,14 +196,6 @@
$(this).remove();
sortable('.sortable');
$("#full-question-list li").each((n, el) => {
$(el).append($(
"<span class='exam-question-delete flex-col'><button>DELETE</button></span>"
).click(() => {
el.remove();
}));
})
$("#full-question-list").append($(
"<button title='click and drag questions to change order'>Save exam order</button>"
).click(() => {