This commit is contained in:
Ross
2021-09-08 17:13:29 +01:00
parent 0d3bebed9a
commit 48d8e177c4
3 changed files with 11 additions and 8 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
title="View question answers">{{question_details.current}}</a> of {{question_details.total}}</h2>
{% if not next_unmarked_id and not unmarked %}
<div class="alert alert-info" role="alert">Success! Marking question complete. Return to <a href="{% url 'longs:mark' exam.id question_details.current|add:'-1' %}">question
<div class="alert alert-info" role="alert">Success! Marking question complete. <br/>Return to <a href="{% url 'longs:mark' exam.id question_details.current|add:'-1' %}">question
overview</a>, <a href="{% url 'longs:mark_overview' pk=exam.pk %}">marking
overview</a></div>
{% endif %}
+1 -1
View File
@@ -61,7 +61,7 @@ urlpatterns = [
# path("all_questions/", views.all_questions, name="all_questions"),
path("question/<int:pk>/scrap", views.long_scrap, name="long_scrap"),
path("question/<int:pk>/delete", views.LongDelete.as_view(), name="long_delete"),
path("exam/<int:pk>/<int:sk>/<int:tk>/mark", views.mark_answer, name="mark_answer"),
path("exam/<int:pk>/<int:sk>/<int:cid>/mark", views.mark_answer, name="mark_answer"),
path("exam/<int:pk>/<int:sk>/mark", views.mark, name="mark"),
path("exam/<int:pk>/mark", views.LongExamViews.mark_overview, name="mark_overview"),
# path("exam/<int:pk>/<int:sk>/", views.exam_take, name="exam_take"),
+9 -6
View File
@@ -651,7 +651,7 @@ def loadJsonAnswer(answer):
@login_required
@user_is_long_marker
@reversion.create_revision()
def mark_answer(request, pk, sk, tk):
def mark_answer(request, pk, sk, cid):
exam = get_object_or_404(Exam, pk=pk)
questions = exam.exam_questions.all()
@@ -668,15 +668,18 @@ def mark_answer(request, pk, sk, tk):
except IndexError:
raise Http404("Exam question does not exist")
question.cid_user_answers.filter(exam__id=pk).values_list("cid", flat=True)
try:
answer = question.cid_user_answers.get(cid=tk, exam__id=pk)
answer = question.cid_user_answers.get(cid=cid, exam__id=pk)
except ObjectDoesNotExist:
raise Http404("User answer does not exist")
try:
unmarked = question.get_unmarked_answers()
next_unmarked_id = unmarked[0].cid
if next_unmarked_id == tk:
if next_unmarked_id == cid:
next_unmarked_id = unmarked[1].cid
except IndexError:
next_unmarked_id = False
@@ -689,16 +692,16 @@ def mark_answer(request, pk, sk, tk):
# If skip button is pressed skip the question without marking
# Skip is problematic if we skip to the next unmarked answer
#if "skip" in request.POST:
# return redirect("longs:mark_answer", pk=pk, sk=sk, tk=next_unmarked_id)
# return redirect("longs:mark_answer", pk=pk, sk=sk, cid=next_unmarked_id)
# Extract score from form and save it to the object
answer.score = form.cleaned_data["score"]
answer.save()
if "next" in request.POST:
return redirect("longs:mark_answer", pk=pk, sk=sk, tk=next_unmarked_id)
return redirect("longs:mark_answer", pk=pk, sk=sk, cid=next_unmarked_id)
if "save" in request.POST:
return redirect("longs:mark_answer", pk=pk, sk=sk, tk=tk)
return redirect("longs:mark_answer", pk=pk, sk=sk, cid=cid)
#elif "previous" in request.POST:
# return redirect("longs:mark", pk=pk, sk=n - 1)