From 9dc9cb4bf090513cfc6436cb42aa5879827c73d4 Mon Sep 17 00:00:00 2001 From: Ross Date: Sat, 12 Dec 2020 13:55:59 +0000 Subject: [PATCH] more improvements --- anatomy/models.py | 8 +++++++- anatomy/static/css/anatomy.css | 5 +++++ anatomy/static/js/anatomy.js | 13 +++++++++---- anatomy/templates/anatomy/mark.html | 9 +++++---- anatomy/views.py | 15 +++++++-------- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/anatomy/models.py b/anatomy/models.py index b035aff3..e7d805a8 100644 --- a/anatomy/models.py +++ b/anatomy/models.py @@ -363,6 +363,12 @@ class CidUserAnswer(models.Model): is not None ): mark = 1 - else: + elif ( + q.answers.filter( + answer__iexact=ans, status=Answer.MarkOptions.INCORRECT + ).first() + ): mark = 0 + else: + mark = "unmarked" return mark \ No newline at end of file diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index 98890134..851ff809 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -318,3 +318,8 @@ img.uploading:hover { .parent-help .help-text { opacity: 0%; } + +.google-link { + padding-left: 10px; + font-size: smaller; +} \ No newline at end of file diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index de6e2ca1..52cb161c 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -8,10 +8,15 @@ var marked_answers = { $(document).ready(function () { $(".answer-list li").each(function (index, element) { + $(element).append($("G")); + }); + + $(".answer-list span.answer").each(function (index, element) { console.log(element); + $(element).click(function (e) { - var classes = ['correct', 'half-correct', 'incorrect']; + var classes = ['answer correct', 'answer half-correct', 'answer incorrect']; $(element).each(function () { this.className = classes[($.inArray(this.className, classes) + 1) % classes.length]; }); @@ -146,15 +151,15 @@ function prepAnswerData() { window.marked_answers["correct"] = []; window.marked_answers["half-correct"] = []; window.marked_answers["incorrect"] = []; - $("li.correct").map(function () { + $("li span.correct").map(function () { ans = $(this).text(); window.marked_answers["correct"].push(ans); }) - $("li.half-correct").map(function () { + $("li span.half-correct").map(function () { ans = $(this).text(); window.marked_answers["half-correct"].push(ans); }) - $("li.incorrect").map(function () { + $("li span.incorrect").map(function () { ans = $(this).text(); window.marked_answers["incorrect"].push(ans); }) diff --git a/anatomy/templates/anatomy/mark.html b/anatomy/templates/anatomy/mark.html index 57e5f4eb..7844aed5 100644 --- a/anatomy/templates/anatomy/mark.html +++ b/anatomy/templates/anatomy/mark.html @@ -9,22 +9,23 @@
{% csrf_token %} + Click each answer to toggle through marks awarded (as per colour)
Marked:
    {% for answer in correct_answers %} -
  • {{ answer }}
  • +
  • {{ answer }}
  • {% endfor %} {% for answer in half_mark_answers %} -
  • {{ answer }}
  • +
  • {{ answer }}
  • {% endfor %} {% for answer in incorrect_answers %} -
  • {{ answer }}
  • +
  • {{ answer }}
  • {% endfor %}
Unmarked:
    {% for answer in user_answers %} -
  • {{ answer }}
  • +
  • {{ answer }}
  • {% endfor %}
Key: 2 Marks, 1 diff --git a/anatomy/views.py b/anatomy/views.py index 331201f4..fb2b0a6d 100644 --- a/anatomy/views.py +++ b/anatomy/views.py @@ -350,13 +350,7 @@ def mark(request, pk, sk): # i.answer.lower() for i in question.incorrect_answers.all() #] - # It's probably better to do some processing/checking in the model - unmarked_user_answers = (set([ - i.answer.lower() - for i in question.cid_user_answers.all() if i.answer.strip() != "" - ]) - marked_answers_set) # .filter(user=User) - - + unmarked_user_answers = question.GetUnmarkedAnswers() if request.method == "POST": @@ -686,7 +680,12 @@ def exam_scores_cid_user(request, pk, sk): answers_marks.append(answer_score) answers_and_marks.append((ans, answer_score, correct_answer)) - total_score = sum(answers_marks) + if "unmarked" in answers_marks: + total_score = sum(i for i in answers_marks if type(i) == int) + unmarked_number = len(answers_marks) - len(total_score) + total_score = "{} ({} unmarked)".format(total_score, unmarked_number) + else: + total_score = sum(answers_marks) max_score = len(questions) * 2