From 5d37cf4284ab9ea3df0702d5797dc258aad6fa40 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 7 Apr 2025 13:25:46 +0100 Subject: [PATCH] . --- generic/urls.py | 1 + generic/views.py | 3 +++ shorts/models.py | 24 ++++------------------ shorts/tables.py | 5 ++--- shorts/templates/shorts/base.html | 3 +++ shorts/templates/shorts/exam_overview.html | 12 ++++++----- shorts/templates/shorts/help.html | 8 ++++++++ 7 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 shorts/templates/shorts/help.html diff --git a/generic/urls.py b/generic/urls.py index 7fd1572f..37a71cd9 100755 --- a/generic/urls.py +++ b/generic/urls.py @@ -280,6 +280,7 @@ def generic_view_urls(generic_views: GenericViewBase): generic_views.question_review, name="question_review", ), + path("help", generic_views.help, name="help"), ] return urlpatterns diff --git a/generic/views.py b/generic/views.py index 333d3c41..2ca12d98 100644 --- a/generic/views.py +++ b/generic/views.py @@ -2609,6 +2609,9 @@ class GenericViewBase: self.checker_group = g[app_name] + def help(self, request): + return render(request, f"{self.app_name}/help.html", {"app_name": self.app_name}) + def question_review(self, request, pk): """ Return a json representation of the question when the exam is published diff --git a/shorts/models.py b/shorts/models.py index 0893bad4..a2f68996 100644 --- a/shorts/models.py +++ b/shorts/models.py @@ -88,26 +88,6 @@ class Question(QuestionBase): def get_image_url_array(self): return json.dumps([f"{REMOTE_URL}{i.url}" for i in self.get_images()]) - # def GetNonFeedbackQuestionImages(self): - # return self.get_images() - - #def get_image_annotations(self): - # return json.dumps( - # [i.image_annotations for i in self.images.all() if not i.feedback_image] - # ) - - def get_laterality_string(self): - if self.laterality == self.NONE: - s = "" - elif self.laterality == self.BILATERAL: - s = "bilateral " - elif self.laterality == self.RIGHT: - s = "right " - elif self.laterality == self.LEFT: - s = "left " - - return s - def anonymise_images(self): anonymizer = dicognito.anonymizer.Anonymizer() @@ -133,6 +113,10 @@ class Question(QuestionBase): return False + def get_best_sample_answer(self): + return self.sample_answers.filter(score__gt=0).order_by("-score").first() + + class QuestionImage(models.Model): question = models.ForeignKey( diff --git a/shorts/tables.py b/shorts/tables.py index 0f2d8f74..2eb88e7b 100644 --- a/shorts/tables.py +++ b/shorts/tables.py @@ -41,8 +41,7 @@ class QuestionTable(tables.Table): class Meta: model = Question template_name = "django_tables2/bootstrap4.html" - fields = ("normal", "abnormality", "region", "examination", - "laterality", + fields = ("normal", "examination", #"site", "created_date", "open_access", "author") sequence = ("view", "images", "exams") @@ -51,7 +50,7 @@ class QuestionTable(tables.Table): def __init__(self, data=None, *args, **kwargs): super().__init__( data.prefetch_related( - "abnormality", "region", "examination", "images", "exams", "author" + "examination", "images", "exams", "author" ), *args, **kwargs, diff --git a/shorts/templates/shorts/base.html b/shorts/templates/shorts/base.html index 2182f6f9..9feb450b 100644 --- a/shorts/templates/shorts/base.html +++ b/shorts/templates/shorts/base.html @@ -46,6 +46,9 @@ Answers {% endif %} + {% endif %} diff --git a/shorts/templates/shorts/exam_overview.html b/shorts/templates/shorts/exam_overview.html index c2357c3f..ffe482aa 100644 --- a/shorts/templates/shorts/exam_overview.html +++ b/shorts/templates/shorts/exam_overview.html @@ -26,13 +26,15 @@ - {% if not question.normal %} - Abnormality: {{ question.get_abnormalities }} Region: {{ question.get_regions }} -
- {{ question.get_primary_answer }} + + {% if question.get_best_sample_answer %} + {{ question.get_best_sample_answer }} + {% else %} - Normal + No sample answer available. + {% endif %} +
Examination: {{ question.get_examinations }}, {% if exam.exam_mode %} diff --git a/shorts/templates/shorts/help.html b/shorts/templates/shorts/help.html new file mode 100644 index 00000000..7c864b88 --- /dev/null +++ b/shorts/templates/shorts/help.html @@ -0,0 +1,8 @@ +{% extends 'shorts/base.html' %} + + +{% block content %} +

Shorts: Help

+ +{% endblock content %} + \ No newline at end of file