This commit is contained in:
Ross
2021-10-16 11:41:48 +01:00
parent fe5bfd4e11
commit cb20d21d5c
3 changed files with 76 additions and 46 deletions
+35 -18
View File
@@ -605,16 +605,6 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
except IndexError:
raise Http404("Exam question does not exist")
answers_dict = {}
for ans in question.answers.all():
answers_dict[ans.answer_compare] = ans
if unmarked_exam_answers_only:
unmarked_user_answers = question.get_unmarked_user_answers(exam_pk=exam_pk)
else:
unmarked_user_answers = question.get_unmarked_user_answers()
if request.method == "POST":
@@ -667,15 +657,16 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
else:
form = MarkRapidQuestionForm()
if unmarked_exam_answers_only:
correct_answers = []
half_mark_answers = []
incorrect_answers = []
else:
correct_answers = question.answers.filter(status=Answer.MarkOptions.CORRECT)
half_mark_answers = question.answers.filter(status=Answer.MarkOptions.HALF_MARK)
incorrect_answers = question.answers.filter(status=Answer.MarkOptions.INCORRECT)
#answers_dict = {}
#for ans in question.answers.all():
# answers_dict[ans.answer_compare] = ans
correct_answers = []
half_mark_answers = []
incorrect_answers = []
review_user_answers = []
# this could be improved
if question.normal:
incorrect_answers = question.get_user_answers()
@@ -683,6 +674,31 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
incorrect_answers.remove("")
if "normal" in incorrect_answers:
incorrect_answers.remove("normal")
else:
if review:
unmarked_user_answers = question.get_user_answers(exam_pk=exam_pk)
elif unmarked_exam_answers_only:
unmarked_user_answers = question.get_unmarked_user_answers(exam_pk=exam_pk)
else:
unmarked_user_answers = question.get_unmarked_user_answers()
if not unmarked_exam_answers_only or review:
correct_answers = question.answers.filter(status=Answer.MarkOptions.CORRECT)
half_mark_answers = question.answers.filter(status=Answer.MarkOptions.HALF_MARK)
incorrect_answers = question.answers.filter(status=Answer.MarkOptions.INCORRECT)
if review:
for ans in unmarked_user_answers:
mark = "unmarked"
if ans in correct_answers:
mark = "correct"
elif ans in half_mark_answers:
mark = "half-mark"
elif ans in incorrect_answers:
mark = "incorrect"
review_user_answers.append(ans, mark)
return render(
request,
@@ -695,6 +711,7 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
"question_number": n,
"question_details": question_details,
"user_answers": unmarked_user_answers,
"review_user_answers": review_user_answers,
"correct_answers": correct_answers,
"half_mark_answers": half_mark_answers,
"incorrect_answers": incorrect_answers,