From 50b3d115c1d5e7b4ca52de0573681a8265664745 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 18:13:17 +0100 Subject: [PATCH 01/19] . --- anatomy/templates/anatomy/exam_overview.html | 2 +- anatomy/templates/anatomy/exam_scores.html | 4 ++-- longs/templates/longs/exam_scores.html | 4 ++-- physics/templates/physics/exam_scores.html | 2 +- rapids/templates/rapids/exam_scores.html | 2 +- sbas/templates/sbas/exam_scores.html | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/anatomy/templates/anatomy/exam_overview.html b/anatomy/templates/anatomy/exam_overview.html index 4899985c..b1ca3117 100644 --- a/anatomy/templates/anatomy/exam_overview.html +++ b/anatomy/templates/anatomy/exam_overview.html @@ -17,7 +17,7 @@ Exam active: [When checked the exam will be available to take in the test system]
- Publish results: [When checked the exam results will be available on this site] + Publish results: [When checked the exam results will be available to users on this site]
{% endif %}

diff --git a/anatomy/templates/anatomy/exam_scores.html b/anatomy/templates/anatomy/exam_scores.html index 8dd68c4a..91f621ba 100644 --- a/anatomy/templates/anatomy/exam_scores.html +++ b/anatomy/templates/anatomy/exam_scores.html @@ -36,8 +36,8 @@
-

Answers as a table

- +

Results as a table

+
{% for cid in cids %} diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html index 6579fcc5..c9f13502 100644 --- a/longs/templates/longs/exam_scores.html +++ b/longs/templates/longs/exam_scores.html @@ -36,8 +36,8 @@
Candidate
-

Answers as a table

- +

Results as a table

+
{% for cid in cids %} diff --git a/physics/templates/physics/exam_scores.html b/physics/templates/physics/exam_scores.html index c1e712c2..2d7bb95e 100644 --- a/physics/templates/physics/exam_scores.html +++ b/physics/templates/physics/exam_scores.html @@ -31,7 +31,7 @@

Answers as a table

-
Candidate
+
{% for cid in cids %} diff --git a/rapids/templates/rapids/exam_scores.html b/rapids/templates/rapids/exam_scores.html index 918eba05..5d4575e8 100644 --- a/rapids/templates/rapids/exam_scores.html +++ b/rapids/templates/rapids/exam_scores.html @@ -37,7 +37,7 @@

Answers as a table

-
Candidate
+
{% for cid in cids %} diff --git a/sbas/templates/sbas/exam_scores.html b/sbas/templates/sbas/exam_scores.html index 99fd57bc..c67417e4 100644 --- a/sbas/templates/sbas/exam_scores.html +++ b/sbas/templates/sbas/exam_scores.html @@ -30,8 +30,8 @@
Candidate
-

Answers as a table

- +

Results as a table

+
{% for cid in cids %} From 179045c3fa5ab07050d14acf2a5c2f8716ca7c51 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 18:16:13 +0100 Subject: [PATCH 02/19] . --- anatomy/templates/anatomy/exam_scores.html | 2 ++ longs/templates/longs/exam_scores.html | 2 ++ physics/templates/physics/exam_scores.html | 3 ++- rapids/templates/rapids/exam_scores.html | 2 ++ sbas/templates/sbas/exam_scores.html | 2 ++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/anatomy/templates/anatomy/exam_scores.html b/anatomy/templates/anatomy/exam_scores.html index 91f621ba..3829cf75 100644 --- a/anatomy/templates/anatomy/exam_scores.html +++ b/anatomy/templates/anatomy/exam_scores.html @@ -38,6 +38,7 @@

Results as a table

Candidate
+ {% for cid in cids %} @@ -45,6 +46,7 @@ {% endfor %} + {% for question in questions %} diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html index c9f13502..06e8d7d2 100644 --- a/longs/templates/longs/exam_scores.html +++ b/longs/templates/longs/exam_scores.html @@ -38,6 +38,7 @@

Results as a table

Candidate
Question {{forloop.counter}}
+ {% for cid in cids %} @@ -45,6 +46,7 @@ {% endfor %} + {% for question in questions %} diff --git a/physics/templates/physics/exam_scores.html b/physics/templates/physics/exam_scores.html index 2d7bb95e..73ab8c4d 100644 --- a/physics/templates/physics/exam_scores.html +++ b/physics/templates/physics/exam_scores.html @@ -32,12 +32,13 @@

Answers as a table

Candidate
Question {{forloop.counter}}
+ {% for cid in cids %} {% endfor %} - + {% for question in questions %} diff --git a/rapids/templates/rapids/exam_scores.html b/rapids/templates/rapids/exam_scores.html index 5d4575e8..60994d74 100644 --- a/rapids/templates/rapids/exam_scores.html +++ b/rapids/templates/rapids/exam_scores.html @@ -23,10 +23,12 @@
Candidate{{cid}}
+ + {% for user, value in user_answers_marks.items %} diff --git a/sbas/templates/sbas/exam_scores.html b/sbas/templates/sbas/exam_scores.html index c67417e4..2f33a748 100644 --- a/sbas/templates/sbas/exam_scores.html +++ b/sbas/templates/sbas/exam_scores.html @@ -32,6 +32,7 @@

Results as a table

Candidate ID Score
{{user}}
+ {% for cid in cids %} @@ -39,6 +40,7 @@ {% endfor %} + {% for question in questions %} From 7acc9081e2b9166c93c953b7cad25b1e21c474a8 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 18:32:24 +0100 Subject: [PATCH 03/19] . --- anatomy/templates/anatomy/exam_scores.html | 2 +- longs/templates/longs/exam_scores.html | 2 +- physics/templates/physics/exam_scores.html | 2 +- rapids/templates/rapids/exam_scores.html | 6 +++--- sbas/templates/sbas/exam_scores.html | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/anatomy/templates/anatomy/exam_scores.html b/anatomy/templates/anatomy/exam_scores.html index 3829cf75..97b7dec8 100644 --- a/anatomy/templates/anatomy/exam_scores.html +++ b/anatomy/templates/anatomy/exam_scores.html @@ -22,7 +22,7 @@
{{plot|safe}}
-
Candidate
Question {{forloop.counter}}
+
diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html index 06e8d7d2..9894341e 100644 --- a/longs/templates/longs/exam_scores.html +++ b/longs/templates/longs/exam_scores.html @@ -22,7 +22,7 @@
{{plot|safe}}
-
Candidate ID Score
+
diff --git a/physics/templates/physics/exam_scores.html b/physics/templates/physics/exam_scores.html index 73ab8c4d..96c987e9 100644 --- a/physics/templates/physics/exam_scores.html +++ b/physics/templates/physics/exam_scores.html @@ -16,7 +16,7 @@
-
Candidate ID Score
+
diff --git a/rapids/templates/rapids/exam_scores.html b/rapids/templates/rapids/exam_scores.html index 60994d74..c92f5c1e 100644 --- a/rapids/templates/rapids/exam_scores.html +++ b/rapids/templates/rapids/exam_scores.html @@ -22,13 +22,11 @@
{{plot|safe}}
-
Candidate ID Score
- +
- {% for user, value in user_answers_marks.items %} @@ -40,6 +38,7 @@

Answers as a table

Candidate ID Score
{{user}}
+ {% for cid in cids %} @@ -47,6 +46,7 @@ {% endfor %} + {% for question in questions %} diff --git a/sbas/templates/sbas/exam_scores.html b/sbas/templates/sbas/exam_scores.html index 2f33a748..15e56721 100644 --- a/sbas/templates/sbas/exam_scores.html +++ b/sbas/templates/sbas/exam_scores.html @@ -16,7 +16,7 @@
-
Candidate
Question {{forloop.counter}}
+
From 9971828fc41e924e3f2ff5b3799cb2be688f1059 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 18:42:36 +0100 Subject: [PATCH 04/19] . --- longs/templates/longs/exam_scores.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html index 9894341e..727ee070 100644 --- a/longs/templates/longs/exam_scores.html +++ b/longs/templates/longs/exam_scores.html @@ -37,7 +37,7 @@

Results as a table

-
Candidate ID Score
+
From be1e3129ab0a9a860fae156911b75ecec4827307 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 18:45:49 +0100 Subject: [PATCH 05/19] . --- longs/templates/longs/exam_scores.html | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html index 727ee070..9745d99f 100644 --- a/longs/templates/longs/exam_scores.html +++ b/longs/templates/longs/exam_scores.html @@ -16,12 +16,12 @@

Stats

Candidates: {{cids|length}}
- Max score: {{max_score}}
+ Max score: {{max_score}}
Mean: {{mean}}, Median {{median}}, Mode {{mode}} - +
{{plot|safe}}
-
+
Candidate
@@ -35,32 +35,32 @@ {% endfor %}
Candidate ID
-
+

Results as a table

- - - {% for cid in cids %} - - {% endfor %} + + + {% for cid in cids %} + + {% endfor %} - + - {% for question in questions %} - - - {% for ans, score in by_question|get_item:question %} - + {% for question in questions %} + + + {% for ans, score in by_question|get_item:question %} + + {% endfor %} + {% endfor %} - - {% endfor %} - - - {% for score in user_scores_list %} - - {% endfor %} - + + + {% for score in user_scores_list %} + + {% endfor %} +
Candidate{{cid}}
Candidate{{cid}}
Question {{forloop.counter}}{{score}}
Question {{forloop.counter}}{{score}}
Score:{{score}}
Score:{{score}}
From f0c962536276ed8e1b9c60649f3eae4903ff3a36 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 18:47:16 +0100 Subject: [PATCH 06/19] . --- longs/templates/longs/exam_scores.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html index 9745d99f..06d0d1dd 100644 --- a/longs/templates/longs/exam_scores.html +++ b/longs/templates/longs/exam_scores.html @@ -35,9 +35,9 @@ {% endfor %}
-
+

Results as a table

- +
From 6b30bfa36435a0b9c48265765fe115b4f8a96562 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 19:50:01 +0100 Subject: [PATCH 07/19] . --- anatomy/static/css/anatomy.css | 16 ++++++++++++++++ longs/templates/longs/exam_scores.html | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index b62659d1..65cb5577 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -485,4 +485,20 @@ td.user-answer-score-2::after { .notes .complete { color: darkslategray; + } + + table.longs .user-answer-score-4, table.longs .user-answer-score-4\.5 { + color: red + } + + table.longs .user-answer-score-5, table.longs .user-answer-score-5\.5 { + color: yellow + } + + table.longs .user-answer-score-6, table.longs .user-answer-score-6\.5 { + color: yellowgreen + } + + table.longs .user-answer-score-7, table.longs .user-answer-score-7\.5 { + color: green } \ No newline at end of file diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html index 06d0d1dd..d7e8f5b8 100644 --- a/longs/templates/longs/exam_scores.html +++ b/longs/templates/longs/exam_scores.html @@ -37,7 +37,7 @@

Results as a table

-
Candidate
+
From cdc1259e56483a48f9dcee78f0e950a1d313cc02 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 19:50:25 +0100 Subject: [PATCH 08/19] . --- static/css/anatomy.css | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/static/css/anatomy.css b/static/css/anatomy.css index b62659d1..65cb5577 100644 --- a/static/css/anatomy.css +++ b/static/css/anatomy.css @@ -485,4 +485,20 @@ td.user-answer-score-2::after { .notes .complete { color: darkslategray; + } + + table.longs .user-answer-score-4, table.longs .user-answer-score-4\.5 { + color: red + } + + table.longs .user-answer-score-5, table.longs .user-answer-score-5\.5 { + color: yellow + } + + table.longs .user-answer-score-6, table.longs .user-answer-score-6\.5 { + color: yellowgreen + } + + table.longs .user-answer-score-7, table.longs .user-answer-score-7\.5 { + color: green } \ No newline at end of file From accef904be04f265be3738905d67e7e9c4d4de3a Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 20:34:35 +0100 Subject: [PATCH 09/19] . --- anatomy/static/css/anatomy.css | 6 ++--- longs/filters.py | 21 +++++++++++++++++- longs/tables.py | 28 ++++++++++++++++++++++-- longs/templates/longs/question_view.html | 18 +++++++++++++++ longs/urls.py | 3 +++ longs/views.py | 25 ++++++++++++++++++--- rapids/urls.py | 4 ++-- rapids/views.py | 4 ++-- 8 files changed, 96 insertions(+), 13 deletions(-) create mode 100644 longs/templates/longs/question_view.html diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index 65cb5577..f47d2658 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -491,14 +491,14 @@ td.user-answer-score-2::after { color: red } - table.longs .user-answer-score-5, table.longs .user-answer-score-5\.5 { + table.longs .user-answer-score-5\.0, table.longs .user-answer-score-5\.5 { color: yellow } - table.longs .user-answer-score-6, table.longs .user-answer-score-6\.5 { + table.longs .user-answer-score-6\.0, table.longs .user-answer-score-6\.5 { color: yellowgreen } - table.longs .user-answer-score-7, table.longs .user-answer-score-7\.5 { + table.longs .user-answer-score-7\.0, table.longs .user-answer-score-7\.5 { color: green } \ No newline at end of file diff --git a/longs/filters.py b/longs/filters.py index 98cdb4d3..84b0bf94 100755 --- a/longs/filters.py +++ b/longs/filters.py @@ -1,6 +1,6 @@ import django_filters -from .models import Long, LongSeries, Exam +from .models import Long, LongSeries, Exam, CidUserAnswer from django.contrib.auth.models import User def get_exams(request): @@ -51,4 +51,23 @@ class LongSeriesFilter(django_filters.FilterSet): #queryset = queryset.filter(open_access=True) | queryset.filter(author__id=request.user.id) queryset = queryset.filter(author__id=request.user.id) super(LongSeriesFilter, self).__init__(data=data, queryset=queryset, prefix=prefix, request=request) + pass + +class UserAnswerFilter(django_filters.FilterSet): + class Meta: + model = CidUserAnswer + fields = ( + "cid", + "normal", + "answer", + #"answer_compare", + "exam", + "created", + "updated", + ) + + def __init__(self, data=None, queryset=None, prefix=None, strict=None, user=None, request=None): + if not request.user.groups.filter(name="long_checker").exists(): + queryset = queryset.filter(open_access=True) | queryset.filter(author__id=request.user.id) + super(UserAnswerFilter, self).__init__(data=data, queryset=queryset, prefix=prefix, request=request) pass \ No newline at end of file diff --git a/longs/tables.py b/longs/tables.py index c1aebc63..6a299515 100755 --- a/longs/tables.py +++ b/longs/tables.py @@ -1,7 +1,7 @@ import django_tables2 as tables from django_tables2.utils import A -from .models import Long, LongSeries +from .models import Long, LongSeries, CidUserAnswer from django.utils.html import format_html @@ -111,4 +111,28 @@ class LongSeriesTable(tables.Table): def render_popup(self, value, record): print(self) - return format_html("""Popup""", record.pk) \ No newline at end of file + return format_html("""Popup""", record.pk) + +class UserAnswerTable(tables.Table): + select = tables.CheckBoxColumn(accessor=("pk")) + delete = tables.LinkColumn( + "longs:user_answer_delete", text="Delete", args=[A("pk")], orderable=False + ) + view = tables.LinkColumn('longs:user_answer_view', + text='View', + args=[A('pk')], + orderable=False) + class Meta: + model = CidUserAnswer + template_name = "django_tables2/bootstrap4.html" + fields = ( + "cid", + "question", + "normal", + "answer", + #"answer_compare", + "exam", + "created", + "updated", + ) + \ No newline at end of file diff --git a/longs/templates/longs/question_view.html b/longs/templates/longs/question_view.html new file mode 100644 index 00000000..0c1da180 --- /dev/null +++ b/longs/templates/longs/question_view.html @@ -0,0 +1,18 @@ +{% extends 'longs/base.html' %} + +{% load render_table from django_tables2 %} +{% block css %} +{% endblock %} + +{% block content %} + +
+

Filter Long

+
+ {{ filter.form }} + + +
+{% render_table table %} + +{% endblock %} \ No newline at end of file diff --git a/longs/urls.py b/longs/urls.py index 7edf2ffa..ca47b8d6 100755 --- a/longs/urls.py +++ b/longs/urls.py @@ -104,4 +104,7 @@ urlpatterns = [ name="long_series_update", ), path("/add_note", views.AddNote.as_view(), name="long_add_note"), + path("user_answers/", views.UserAnswerTableView.as_view(), name="user_answer_table_view"), + path("user_answers/", views.UserAnswerView.as_view(), name="user_answer_view"), + path("user_answers//delete", views.UserAnswerDelete.as_view(), name="user_answer_delete"), ] diff --git a/longs/views.py b/longs/views.py index f02aa1f8..bda049bf 100755 --- a/longs/views.py +++ b/longs/views.py @@ -8,6 +8,8 @@ from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist, PermissionDenied, ViewDoesNotExist from django.contrib.auth.mixins import LoginRequiredMixin +from django.views.generic.detail import DetailView +from generic.mixins import SuperuserRequiredMixin from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic import ListView @@ -33,8 +35,8 @@ from .models import ( Exam, CidUserAnswer, ) -from .tables import LongTable, LongSeriesTable -from .filters import LongFilter, LongSeriesFilter +from .tables import LongTable, LongSeriesTable, UserAnswerTable +from .filters import LongFilter, LongSeriesFilter, UserAnswerFilter from django_tables2 import SingleTableView, SingleTableMixin from django_filters.views import FilterView @@ -998,4 +1000,21 @@ def question_json_recreate(request, pk): #question.get_question_json() - return redirect("longs:question_detail", pk=pk) \ No newline at end of file + return redirect("longs:question_detail", pk=pk) + + +class UserAnswerView(LoginRequiredMixin, DetailView): + model = CidUserAnswer + + +class UserAnswerTableView(LoginRequiredMixin, SingleTableMixin, FilterView): + model = CidUserAnswer + table_class = UserAnswerTable + template_name = "longs/question_view.html" + + filterset_class = UserAnswerFilter + + +class UserAnswerDelete(SuperuserRequiredMixin, DeleteView): + model = CidUserAnswer + success_url = reverse_lazy("longs:user_answer_table_view") diff --git a/rapids/urls.py b/rapids/urls.py index 44ccbcec..6eab01b0 100755 --- a/rapids/urls.py +++ b/rapids/urls.py @@ -66,7 +66,7 @@ urlpatterns = [ name="rapid_update", ), path("/add_note", views.AddNote.as_view(), name="rapid_add_note"), - path("user_answers/", views.RapidUserAnswerTableView.as_view(), name="rapid_user_answer_table_view"), - path("user_answers/", views.RapidUserAnswerView.as_view(), name="rapid_user_answer_view"), + path("user_answers/", views.UserAnswerTableView.as_view(), name="rapid_user_answer_table_view"), + path("user_answers/", views.UserAnswerView.as_view(), name="rapid_user_answer_view"), path("user_answers//delete", views.UserAnswerDelete.as_view(), name="rapid_user_answer_delete"), ] diff --git a/rapids/views.py b/rapids/views.py index b0a470ed..9657ad8f 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -985,11 +985,11 @@ class ExamUpdate( return super().form_valid(form) -class RapidUserAnswerView(LoginRequiredMixin, DetailView): +class UserAnswerView(LoginRequiredMixin, DetailView): model = CidUserAnswer -class RapidUserAnswerTableView(LoginRequiredMixin, SingleTableMixin, FilterView): +class UserAnswerTableView(LoginRequiredMixin, SingleTableMixin, FilterView): model = CidUserAnswer table_class = RapidUserAnswerTable template_name = "rapids/rapid_question_view.html" From dac44e71a0f320cfed7dfc79fe1417205c656d19 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 20:34:46 +0100 Subject: [PATCH 10/19] . --- static/css/anatomy.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/css/anatomy.css b/static/css/anatomy.css index 65cb5577..f47d2658 100644 --- a/static/css/anatomy.css +++ b/static/css/anatomy.css @@ -491,14 +491,14 @@ td.user-answer-score-2::after { color: red } - table.longs .user-answer-score-5, table.longs .user-answer-score-5\.5 { + table.longs .user-answer-score-5\.0, table.longs .user-answer-score-5\.5 { color: yellow } - table.longs .user-answer-score-6, table.longs .user-answer-score-6\.5 { + table.longs .user-answer-score-6\.0, table.longs .user-answer-score-6\.5 { color: yellowgreen } - table.longs .user-answer-score-7, table.longs .user-answer-score-7\.5 { + table.longs .user-answer-score-7\.0, table.longs .user-answer-score-7\.5 { color: green } \ No newline at end of file From e6cd59ad189e78a350528da45b2a09052c96588a Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 20:37:46 +0100 Subject: [PATCH 11/19] . --- longs/filters.py | 4 ++-- longs/tables.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/longs/filters.py b/longs/filters.py index 84b0bf94..fe664067 100755 --- a/longs/filters.py +++ b/longs/filters.py @@ -58,8 +58,8 @@ class UserAnswerFilter(django_filters.FilterSet): model = CidUserAnswer fields = ( "cid", - "normal", - "answer", + #"normal", + #"answer", #"answer_compare", "exam", "created", diff --git a/longs/tables.py b/longs/tables.py index 6a299515..5351ba23 100755 --- a/longs/tables.py +++ b/longs/tables.py @@ -128,8 +128,8 @@ class UserAnswerTable(tables.Table): fields = ( "cid", "question", - "normal", - "answer", + #"normal", + #"answer", #"answer_compare", "exam", "created", From cfec44cdf259d36116b753ced6fa497cb6a067fe Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 20:42:27 +0100 Subject: [PATCH 12/19] . --- longs/templates/longs/ciduseranswer_detail.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 longs/templates/longs/ciduseranswer_detail.html diff --git a/longs/templates/longs/ciduseranswer_detail.html b/longs/templates/longs/ciduseranswer_detail.html new file mode 100644 index 00000000..e6f56665 --- /dev/null +++ b/longs/templates/longs/ciduseranswer_detail.html @@ -0,0 +1,15 @@ + +{% extends 'rapids/base.html' %} + +{% block content %} +{{ciduseranswer.question}} + +{{ciduseranswer.model_observations}} +{{ciduseranswer.model_interpretation}} +{{ciduseranswer.model_principle_diagnosis}} +{{ciduseranswer.model_differential_diagnosis}} +{{ciduseranswer.model_management}} + + +{{ciduseranswer.cid}} +{% endblock content %} \ No newline at end of file From 0927b7e436e98500c495708891e5a15a39176fd7 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 20:44:02 +0100 Subject: [PATCH 13/19] . --- longs/templates/longs/ciduseranswer_detail.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/longs/templates/longs/ciduseranswer_detail.html b/longs/templates/longs/ciduseranswer_detail.html index e6f56665..9c4ca4de 100644 --- a/longs/templates/longs/ciduseranswer_detail.html +++ b/longs/templates/longs/ciduseranswer_detail.html @@ -2,14 +2,18 @@ {% extends 'rapids/base.html' %} {% block content %} +User answer: {{ciduseranswer.cid} + +

Question

{{ciduseranswer.question}} -{{ciduseranswer.model_observations}} -{{ciduseranswer.model_interpretation}} -{{ciduseranswer.model_principle_diagnosis}} -{{ciduseranswer.model_differential_diagnosis}} -{{ciduseranswer.model_management}} +

Answers

+{{ciduseranswer.model_observations}}
+{{ciduseranswer.model_interpretation}}
+{{ciduseranswer.model_principle_diagnosis}}
+{{ciduseranswer.model_differential_diagnosis}}
+{{ciduseranswer.model_management}}
-{{ciduseranswer.cid}} +} {% endblock content %} \ No newline at end of file From 0f502a1ed2614a3d9b9a5d3c34bfb2941a9f9466 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 20:44:32 +0100 Subject: [PATCH 14/19] . --- longs/templates/longs/ciduseranswer_detail.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/longs/templates/longs/ciduseranswer_detail.html b/longs/templates/longs/ciduseranswer_detail.html index 9c4ca4de..c4c44110 100644 --- a/longs/templates/longs/ciduseranswer_detail.html +++ b/longs/templates/longs/ciduseranswer_detail.html @@ -2,7 +2,7 @@ {% extends 'rapids/base.html' %} {% block content %} -User answer: {{ciduseranswer.cid} +User answer: {{ciduseranswer.cid}}

Question

{{ciduseranswer.question}} @@ -15,5 +15,5 @@ User answer: {{ciduseranswer.cid} {{ciduseranswer.model_management}}
-} + {% endblock content %} \ No newline at end of file From 3d96cad503441d4a145dd8601cdfa1437db93a62 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 22:00:56 +0100 Subject: [PATCH 15/19] . --- .../templates/longs/ciduseranswer_detail.html | 2 +- longs/templates/longs/question_view.html | 38 +++++++++++++++++++ longs/urls.py | 1 + longs/views.py | 11 ++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/longs/templates/longs/ciduseranswer_detail.html b/longs/templates/longs/ciduseranswer_detail.html index c4c44110..508aedd9 100644 --- a/longs/templates/longs/ciduseranswer_detail.html +++ b/longs/templates/longs/ciduseranswer_detail.html @@ -2,7 +2,7 @@ {% extends 'rapids/base.html' %} {% block content %} -User answer: {{ciduseranswer.cid}} +CID: {{ciduseranswer.cid}}

Question

{{ciduseranswer.question}} diff --git a/longs/templates/longs/question_view.html b/longs/templates/longs/question_view.html index 0c1da180..c3c511f5 100644 --- a/longs/templates/longs/question_view.html +++ b/longs/templates/longs/question_view.html @@ -13,6 +13,44 @@ + {% render_table table %} +{% endblock %} + +{% block js %} + {% endblock %} \ No newline at end of file diff --git a/longs/urls.py b/longs/urls.py index ca47b8d6..b0459efe 100755 --- a/longs/urls.py +++ b/longs/urls.py @@ -107,4 +107,5 @@ urlpatterns = [ path("user_answers/", views.UserAnswerTableView.as_view(), name="user_answer_table_view"), path("user_answers/", views.UserAnswerView.as_view(), name="user_answer_view"), path("user_answers//delete", views.UserAnswerDelete.as_view(), name="user_answer_delete"), + path("user_answers/delete", views.user_answer_delete_multiple, name="user_answer_delete_multiple"), ] diff --git a/longs/views.py b/longs/views.py index bda049bf..3da8c3e4 100755 --- a/longs/views.py +++ b/longs/views.py @@ -1018,3 +1018,14 @@ class UserAnswerTableView(LoginRequiredMixin, SingleTableMixin, FilterView): class UserAnswerDelete(SuperuserRequiredMixin, DeleteView): model = CidUserAnswer success_url = reverse_lazy("longs:user_answer_table_view") + +@user_passes_test(lambda u: u.is_superuser) +def user_answer_delete_multiple(request): + if request.is_ajax(): + answer_ids = request.GET["answer_ids"] + + # We could probably delete them all at once.... + for id in answer_ids: + CidUserAnswer.objects.get(pk=id).delete() + return HttpResponseRedirect(request.path_info) + return HttpResponse("/") \ No newline at end of file From 931454d9d6b395007879280391d13827151186f2 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 22:03:34 +0100 Subject: [PATCH 16/19] . --- longs/templates/longs/question_view.html | 2 +- longs/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/longs/templates/longs/question_view.html b/longs/templates/longs/question_view.html index c3c511f5..c271bdf0 100644 --- a/longs/templates/longs/question_view.html +++ b/longs/templates/longs/question_view.html @@ -32,7 +32,7 @@ url: "{% url 'longs:user_answer_delete_multiple' %}", data: { csrfmiddlewaretoken: "{{ csrf_token }}", - answer_ids: this.checked // true if checked else false + answer_ids: JSON.stringify(answer_ids) // true if checked else false }, type: "POST", dataType: "json", diff --git a/longs/views.py b/longs/views.py index 3da8c3e4..10faff36 100755 --- a/longs/views.py +++ b/longs/views.py @@ -1022,7 +1022,7 @@ class UserAnswerDelete(SuperuserRequiredMixin, DeleteView): @user_passes_test(lambda u: u.is_superuser) def user_answer_delete_multiple(request): if request.is_ajax(): - answer_ids = request.GET["answer_ids"] + answer_ids = json.load(request.GET["answer_ids"]) # We could probably delete them all at once.... for id in answer_ids: From c387528d29cab0ccd4152adc7e05c87176a4fb0c Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 22:04:14 +0100 Subject: [PATCH 17/19] . --- longs/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/longs/views.py b/longs/views.py index 10faff36..c0c42720 100755 --- a/longs/views.py +++ b/longs/views.py @@ -1022,7 +1022,7 @@ class UserAnswerDelete(SuperuserRequiredMixin, DeleteView): @user_passes_test(lambda u: u.is_superuser) def user_answer_delete_multiple(request): if request.is_ajax(): - answer_ids = json.load(request.GET["answer_ids"]) + answer_ids = json.load(request.POST["answer_ids"]) # We could probably delete them all at once.... for id in answer_ids: From da43ab986365f88a23714b450f43b42a0a0cbf48 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 3 Aug 2021 22:04:45 +0100 Subject: [PATCH 18/19] . --- longs/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/longs/views.py b/longs/views.py index c0c42720..4c304c4c 100755 --- a/longs/views.py +++ b/longs/views.py @@ -1022,7 +1022,7 @@ class UserAnswerDelete(SuperuserRequiredMixin, DeleteView): @user_passes_test(lambda u: u.is_superuser) def user_answer_delete_multiple(request): if request.is_ajax(): - answer_ids = json.load(request.POST["answer_ids"]) + answer_ids = json.loads(request.POST["answer_ids"]) # We could probably delete them all at once.... for id in answer_ids: From e4a09a116345ec824fc8a1d858ca02bccbb071c7 Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 4 Aug 2021 19:47:43 +0100 Subject: [PATCH 19/19] . --- longs/templates/longs/exam_overview.html | 2 ++ longs/urls.py | 1 + longs/views.py | 14 +++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/longs/templates/longs/exam_overview.html b/longs/templates/longs/exam_overview.html index 97239ec9..032586af 100644 --- a/longs/templates/longs/exam_overview.html +++ b/longs/templates/longs/exam_overview.html @@ -62,6 +62,8 @@ JSON Refresh JSON cache + Refresh Question JSON cache + diff --git a/longs/urls.py b/longs/urls.py index b0459efe..367e1db5 100755 --- a/longs/urls.py +++ b/longs/urls.py @@ -39,6 +39,7 @@ urlpatterns = [ ), path("exam//", views.LongExamViews.exam_overview, name="exam_overview"), path("exam//json_edit", views.LongExamViews.exam_json_edit, name="exam_json_edit"), + path("exam//question_json_refresh", views.refresh_exam_question_json, name="refresh_exam_question_json"), path("exam//scores", views.exam_scores_cid, name="exam_scores_cid"), path( "exam//scores//", diff --git a/longs/views.py b/longs/views.py index 4c304c4c..337883a6 100755 --- a/longs/views.py +++ b/longs/views.py @@ -1028,4 +1028,16 @@ def user_answer_delete_multiple(request): for id in answer_ids: CidUserAnswer.objects.get(pk=id).delete() return HttpResponseRedirect(request.path_info) - return HttpResponse("/") \ No newline at end of file + return HttpResponse("/") + + +@user_passes_test(lambda u: u.is_superuser) +def refresh_exam_question_json(request, pk): + exam = Exam.objects.get(pk=pk) + + for question in exam.exam_questions.all(): + question.recreate_json = True + question.save() + + return redirect("longs:exam_overview", pk=pk) +
Candidate