From b3b0c8cca7cceab61df06291d0f34047d6f5dacf Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 22:59:57 +0000 Subject: [PATCH] . --- anatomy/templates/anatomy/exam_cids.html | 20 ++++++++++++++++++++ anatomy/templates/anatomy/exams.html | 1 + anatomy/urls.py | 17 ++++++++++++----- generic/views.py | 22 ++++++++++++++++++++++ physics/templates/physics/exam_start.html | 2 -- sbas/templates/sbas/exam_start.html | 12 ++++++++++++ 6 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 anatomy/templates/anatomy/exam_cids.html diff --git a/anatomy/templates/anatomy/exam_cids.html b/anatomy/templates/anatomy/exam_cids.html new file mode 100644 index 00000000..49207c49 --- /dev/null +++ b/anatomy/templates/anatomy/exam_cids.html @@ -0,0 +1,20 @@ +{% extends 'anatomy/exams.html' %} + +{% block content %} + + {% load thumbnail %} +
+

Exam: {{ exam.name }}

+ + {{cid_user_count}} users. + +
    + {% for cid in cid_users %} +
  1. {{cid}}
  2. + + {% endfor %} +
+ + +
+{% endblock %} diff --git a/anatomy/templates/anatomy/exams.html b/anatomy/templates/anatomy/exams.html index 23de930f..b19fd9bd 100644 --- a/anatomy/templates/anatomy/exams.html +++ b/anatomy/templates/anatomy/exams.html @@ -8,6 +8,7 @@ {% if exam.exam_mode %} Mark / Scores / + CIDs / {% endif %} Add New Question {% endblock %} diff --git a/anatomy/urls.py b/anatomy/urls.py index 1e6a69d2..a8c083c7 100644 --- a/anatomy/urls.py +++ b/anatomy/urls.py @@ -22,7 +22,11 @@ urlpatterns = [ views.AnatomyQuestionCreate.as_view(), name="anatomy_question_create", ), - path("create/exam/", views.AnatomyQuestionCreate.as_view(), name="anatomy_create_exam"), + path( + "create/exam/", + views.AnatomyQuestionCreate.as_view(), + name="anatomy_create_exam", + ), path( "question//update", views.AnatomyQuestionUpdate.as_view(), @@ -54,11 +58,13 @@ urlpatterns = [ ), path("exam///mark", views.mark, name="mark"), path("exam///mark/all", views.mark_all, name="mark_all"), - path("exam///mark/review", views.mark_review, name="mark_review"), + path( + "exam///mark/review", views.mark_review, name="mark_review" + ), path( "exam//mark", views.AnatomyExamViews.mark_overview, name="mark_overview" ), - #path("exam///", views.exam_take, name="exam_take"), + # path("exam///", views.exam_take, name="exam_take"), path( "exam//question//", views.AnatomyExamViews.exam_question_detail, @@ -99,6 +105,7 @@ urlpatterns = [ path("exam/all", views.AnatomyExamViews.exam_list_all, name="exam_list_all"), path("exam/create", views.ExamCreate.as_view(), name="exam_create"), path("exam//clone", views.ExamClone.as_view(), name="exam_clone"), + path("exam//cids", views.AnatomyExamViews.exam_cids, name="exam_cids"), path("exam//update", views.ExamUpdate.as_view(), name="exam_update"), path("exam//delete", views.ExamDelete.as_view(), name="exam_delete"), path("exam/json/", views.AnatomyExamViews.active_exams, name="active_exams"), @@ -119,7 +126,7 @@ urlpatterns = [ name="exam_json_recreate", ), # path("cid/", views.cid_selector, name="cid_selector"), - #path("ajax/exam/flag/", views.flag_question, name="flag_question"), + # path("ajax/exam/flag/", views.flag_question, name="flag_question"), path("body_part/create/", views.create_body_part, name="create_body_part"), path( "body_part/ajax/get_body_part_id", @@ -158,7 +165,7 @@ urlpatterns = [ ), path( "structure-autocomplete", - views.StructureAutocomplete.as_view(model=Structure, create_field='structure'), + views.StructureAutocomplete.as_view(model=Structure, create_field="structure"), name="structure-autocomplete", ), ] diff --git a/generic/views.py b/generic/views.py index 2886b65f..94d56ccd 100644 --- a/generic/views.py +++ b/generic/views.py @@ -417,6 +417,28 @@ class ExamViews(View, LoginRequiredMixin): }, ) + @method_decorator(login_required) + def exam_cids(self, request, exam_id): + exam = get_object_or_404(self.Exam, pk=exam_id) + + if request.user not in exam.author.all(): + if not self.check_user_access(request.user, exam_id): + raise PermissionDenied + + cid_users = exam.valid_users.all() + + cid_user_count = cid_users.count() + + return render( + request, + "{}/exam_cids.html".format(self.app_name), + { + "exam": exam, + "cid_users": cid_users, + "cid_user_cound": cid_user_count + }, + ) + # @method_decorator(login_required) def exam_notes(self, request, pk): exam = get_object_or_404(self.Exam, pk=pk) diff --git a/physics/templates/physics/exam_start.html b/physics/templates/physics/exam_start.html index 3c32bb4b..1a190f74 100755 --- a/physics/templates/physics/exam_start.html +++ b/physics/templates/physics/exam_start.html @@ -12,10 +12,8 @@