From cb20d21d5c1dcea35be64bb00c77fcdc830ab060 Mon Sep 17 00:00:00 2001 From: Ross Date: Sat, 16 Oct 2021 11:41:48 +0100 Subject: [PATCH] . --- rapids/models.py | 5 ++- rapids/templates/rapids/mark.html | 64 ++++++++++++++++++------------- rapids/views.py | 53 ++++++++++++++++--------- 3 files changed, 76 insertions(+), 46 deletions(-) diff --git a/rapids/models.py b/rapids/models.py index 61b403c9..26bd7ef9 100644 --- a/rapids/models.py +++ b/rapids/models.py @@ -258,8 +258,9 @@ class Rapid(models.Model): [i for i in user_answer_queryset if i.normal == False and i.answer_compare not in marked_answers] ) - #unmarked_answers = user_answers - self.get_marked_answers() - + return [i.answer_compare for i in unmarked_answers] + + # Marker code below is not used if marker is None: return [i.answer_compare for i in unmarked_answers] diff --git a/rapids/templates/rapids/mark.html b/rapids/templates/rapids/mark.html index b2e7696a..247a4a30 100644 --- a/rapids/templates/rapids/mark.html +++ b/rapids/templates/rapids/mark.html @@ -43,32 +43,44 @@ {% endif %}
- Unmarked: - - Marked: - + {% if not review %} + Unmarked: + + + Marked: + + {% else %} + To review: + + {% endif %}
Key: 2 Marks, 1 Mark, 0 Marks
diff --git a/rapids/views.py b/rapids/views.py index 139ed639..564ffe7b 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -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,