From a3bf73059c803fad354ab3159bfdfbfdd9898dc1 Mon Sep 17 00:00:00 2001 From: Ross Date: Sat, 5 Dec 2020 18:10:51 +0000 Subject: [PATCH] numerous improvements --- anatomy/models.py | 8 +++--- anatomy/static/css/anatomy.css | 30 +++++++++++++++++++- anatomy/templates/anatomy/exam_overview.html | 4 +-- anatomy/templates/anatomy/mark_overview.html | 2 +- anatomy/views.py | 11 +++++-- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/anatomy/models.py b/anatomy/models.py index 70ce9b0f..b81d0264 100644 --- a/anatomy/models.py +++ b/anatomy/models.py @@ -99,8 +99,8 @@ class AnatomyQuestion(models.Model): def __str__(self): # Get first answer - a = self.answers.all().first() - + return "{} [{}, {}]".format(self.GetPrimaryAnswer(), self.modality, + self.structure) # Get associated exams e = self.exams.all().values_list("name", flat=True) exams = ", ".join(e) @@ -253,7 +253,7 @@ class UserAnswer(models.Model): exam = self.exam except (Exam.DoesNotExist, KeyError) as e: exam = "None" - return "{}/{}/{}: {}".format(exam, self.cid, self.question.id, + return "{}/{}/{}: {}".format(exam, self.cid, self.question.GetPrimaryAnswer(), self.answer) def clean(self): @@ -284,7 +284,7 @@ class CidUserAnswer(models.Model): exam = self.exam except (Exam.DoesNotExist, KeyError) as e: exam = "None" - return "{}/{}/{}: {}".format(exam, self.cid, self.question.id, + return "{}/{}/{}: {}".format(exam, self.cid, self.question.GetPrimaryAnswer(), self.answer) def clean(self): diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index cdd471a0..b16dd961 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -64,9 +64,31 @@ a, a:link { .not-flagged { } +button { +text-decoration: none; +display:inline-block; +padding:0.35em 1.2em; +border:0.1em solid #52057b; +margin:0 0.3em 0.3em 0; +border-radius:0.12em; +box-sizing: border-box; +text-decoration:none; +font-family:'Roboto',sans-serif; +font-weight:300; +color:#a600ff; +text-align:center; +transition: all 0.2s; +background-color: transparent; +} + +button:hover{ +color:white; +background-color:#52057b; +} + button a { text-decoration: none; - color: green; + color: inherit; } #admin-link { @@ -123,4 +145,10 @@ button a { #question-mark-list li { padding-bottom: 5px; +} + +#start-marking-button { + float: right; + position: sticky; + top: 30px; } \ No newline at end of file diff --git a/anatomy/templates/anatomy/exam_overview.html b/anatomy/templates/anatomy/exam_overview.html index 6cf139cb..1954d81f 100644 --- a/anatomy/templates/anatomy/exam_overview.html +++ b/anatomy/templates/anatomy/exam_overview.html @@ -10,7 +10,7 @@
Exam active:
-

+

    @@ -18,7 +18,7 @@ Exam active: {{ question.description }}: {{ question.GetPrimaryAnswer }}thumbail
    -Exams: {{ question.GetExams }} / Modality: {{ question.modality }} +Modality: {{ question.modality }} {% endfor %}
diff --git a/anatomy/templates/anatomy/mark_overview.html b/anatomy/templates/anatomy/mark_overview.html index 977fdd01..c7c97465 100644 --- a/anatomy/templates/anatomy/mark_overview.html +++ b/anatomy/templates/anatomy/mark_overview.html @@ -8,6 +8,7 @@
+
-

{% endblock %} \ No newline at end of file diff --git a/anatomy/views.py b/anatomy/views.py index 591aa300..b480730b 100644 --- a/anatomy/views.py +++ b/anatomy/views.py @@ -261,21 +261,28 @@ def loadJsonAnswer(answer): ans.answer = answer["ans"] ans.save() + return True + @csrf_exempt def postExamAnswers(request): if request.is_ajax and request.method == "POST": + n = 0 # horrible but it works for k in request.POST.dict(): print(k) for answer in json.loads(k): - loadJsonAnswer(answer) + ret = loadJsonAnswer(answer) + + if ret is not True: + return ret + n = n + 1 # print(UserAnswer.objects.filter(exam__id=q["eid"])) # print(request.urlencode()) - return JsonResponse({"success": True}) + return JsonResponse({"success": True, "question-number": n}) return JsonResponse({"success": False, "error": "Invalid data"}) # return render(request, "anatomy/exam.html", {"exam" : exam, "question" : question})