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
+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)