start allowing user candidates in longs
This commit is contained in:
+27
-23
@@ -625,7 +625,7 @@ def mark_answer_override(request, exam_id, question_number, cid):
|
||||
|
||||
@user_is_long_marker
|
||||
@reversion.create_revision()
|
||||
def mark_answer(request, exam_id, question_number, cid, override=False):
|
||||
def mark_answer(request, exam_id, question_number, answer_id, override=False):
|
||||
exam = get_object_or_404(Exam, pk=exam_id)
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
@@ -643,25 +643,29 @@ def mark_answer(request, exam_id, question_number, cid, override=False):
|
||||
raise Http404("Exam question does not exist")
|
||||
|
||||
try:
|
||||
answer = question.cid_user_answers.get(cid=cid, exam__id=exam_id)
|
||||
answer = question.cid_user_answers.get(pk=answer_id)
|
||||
except ObjectDoesNotExist:
|
||||
raise Http404("User answer does not exist")
|
||||
|
||||
cid_list = list(
|
||||
question.cid_user_answers.filter(exam__id=exam_id).values_list("cid", flat=True)
|
||||
answer_list = list(
|
||||
question.cid_user_answers.filter(exam__id=exam_id).values_list("id", flat=True)
|
||||
)
|
||||
|
||||
previous_cid = False
|
||||
next_cid = False
|
||||
answer_list.sort()
|
||||
print(answer_list)
|
||||
|
||||
if len(cid_list) > 1:
|
||||
if cid_list[0] == cid:
|
||||
next_cid = cid_list[1]
|
||||
elif cid_list[-1] == cid:
|
||||
previous_cid = cid_list[-2]
|
||||
previous_answer_id = False
|
||||
next_answer_id = False
|
||||
|
||||
if len(answer_list) > 1:
|
||||
if answer_list[0] == answer_id:
|
||||
next_answer_id = answer_list[1]
|
||||
elif answer_list[-1] == answer_id:
|
||||
previous_answer_id = answer_list[-2]
|
||||
else:
|
||||
next_cid = cid_list[cid_list.index(cid) + 1]
|
||||
previous_cid = cid_list[cid_list.index(cid) - 1]
|
||||
print(answer_list.index(answer_id))
|
||||
next_answer_id = answer_list[answer_list.index(answer_id) + 1]
|
||||
previous_answer_id = answer_list[answer_list.index(answer_id) - 1]
|
||||
|
||||
try:
|
||||
if exam.double_mark:
|
||||
@@ -670,9 +674,9 @@ def mark_answer(request, exam_id, question_number, cid, override=False):
|
||||
)
|
||||
else:
|
||||
unmarked = question.get_unmarked_user_answers(exam_pk=exam.id)
|
||||
next_unmarked_id = unmarked[0].cid
|
||||
if next_unmarked_id == cid:
|
||||
next_unmarked_id = unmarked[1].cid
|
||||
next_unmarked_id = unmarked[0].id
|
||||
if next_unmarked_id == answer_id:
|
||||
next_unmarked_id = unmarked[1].id
|
||||
except IndexError:
|
||||
next_unmarked_id = False
|
||||
|
||||
@@ -699,14 +703,14 @@ def mark_answer(request, exam_id, question_number, cid, override=False):
|
||||
"longs:mark_answer",
|
||||
exam_id=exam_id,
|
||||
question_number=question_number,
|
||||
cid=next_unmarked_id,
|
||||
answer_id=next_unmarked_id,
|
||||
)
|
||||
if "save" in request.POST:
|
||||
return redirect(
|
||||
"longs:mark_answer",
|
||||
exam_id=exam_id,
|
||||
question_number=question_number,
|
||||
cid=cid,
|
||||
answer_id=answer_id,
|
||||
)
|
||||
# elif "previous" in request.POST:
|
||||
# return redirect("longs:mark_question_overview", pk=exam_id, sk=n - 1)
|
||||
@@ -749,14 +753,14 @@ def mark_answer(request, exam_id, question_number, cid, override=False):
|
||||
"longs:mark_answer",
|
||||
exam_id=exam_id,
|
||||
question_number=question_number,
|
||||
cid=next_unmarked_id,
|
||||
answer_id=next_unmarked_id,
|
||||
)
|
||||
if "save" in request.POST:
|
||||
return redirect(
|
||||
"longs:mark_answer",
|
||||
exam_id=exam_id,
|
||||
question_number=question_number,
|
||||
cid=cid,
|
||||
answer_id=answer_id,
|
||||
)
|
||||
# elif "previous" in request.POST:
|
||||
# return redirect("longs:mark_question_overview", pk=exam_id, sk=n - 1)
|
||||
@@ -797,9 +801,9 @@ def mark_answer(request, exam_id, question_number, cid, override=False):
|
||||
"question_details": question_details,
|
||||
"next_unmarked_id": next_unmarked_id,
|
||||
"unmarked": unmarked,
|
||||
"previous_cid": previous_cid,
|
||||
"next_cid": next_cid,
|
||||
"cid": cid,
|
||||
"previous_answer_id": previous_answer_id,
|
||||
"next_answer_id": next_answer_id,
|
||||
"answer_id": answer_id,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user