From 7493d55bc22c770e365228b211b4269b3aee052f Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 30 Dec 2024 11:12:36 +0000 Subject: [PATCH] allow completion of sbas / physics exams --- generic/models.py | 11 +- .../generic/examcollection_detail.html | 97 +++++---- physics/templates/physics/exam_start.html | 6 +- physics/templates/physics/exam_take.html | 203 +++++++++--------- physics/templates/physics/exam_take_help.html | 14 ++ .../templates/physics/exam_take_overview.html | 32 ++- physics/urls.py | 10 + physics/views.py | 13 +- rad/static/css/anatomy.css | 19 +- sbas/templates/sbas/exam_start.html | 7 +- sbas/templates/sbas/exam_take.html | 26 +-- sbas/templates/sbas/exam_take_help.html | 15 ++ sbas/templates/sbas/exam_take_overview.html | 33 ++- sbas/urls.py | 10 + sbas/views.py | 13 +- templates/exam_list.html | 27 ++- templates/index.html | 66 +++--- 17 files changed, 362 insertions(+), 240 deletions(-) create mode 100644 physics/templates/physics/exam_take_help.html create mode 100644 sbas/templates/sbas/exam_take_help.html diff --git a/generic/models.py b/generic/models.py index d21dfb8c..81fd7546 100644 --- a/generic/models.py +++ b/generic/models.py @@ -1518,6 +1518,12 @@ class CidUserExam(models.Model): else: return "CID" + str(self.cid_user.cid) + def complete_exam(self): + # TODO add examuserstatus? + self.end_time = timezone.now() + self.completed = True + self.save() + CID_GROUP_EXAMS = ( ("SBAs", "sba_cid_user_groups"), @@ -1729,7 +1735,10 @@ class ExamCollection(models.Model, AuthorMixin): ) def __str__(self): - return f"{self.name} [{self.date}]" + if self.date is not None and self.date is not "": + return f"{self.name} [{self.date}]" + else: + return f"{self.name}" def get_absolute_url(self): return reverse("generic:examcollection_detail", kwargs={"pk": self.pk}) diff --git a/generic/templates/generic/examcollection_detail.html b/generic/templates/generic/examcollection_detail.html index da86a567..282ac82b 100755 --- a/generic/templates/generic/examcollection_detail.html +++ b/generic/templates/generic/examcollection_detail.html @@ -2,7 +2,12 @@ {% block content %} -

{{ object.name }} [{{object.date}}]

+

+ {{ object.name }} + {% if object.date %} + [{{object.date}}] + {% endif %} +

Edit @@ -17,55 +22,55 @@ - {% if object.anatomy_exams.all %} -

Anatomy Exams:

- - View exam list - {% endif %} + {% if object.anatomy_exams.all %} +

Anatomy Exams:

+ + View exam list + {% endif %} - {% if object.longs_exams.all %} -

Longs Exams:

- - View exam list - {% endif %} + {% if object.longs_exams.all %} +

Longs Exams:

+ + View exam list + {% endif %} - {% if object.rapids_exams.all %} -

Rapids Exams:

- - View exam list - {% endif %} + {% if object.rapids_exams.all %} +

Rapids Exams:

+ + View exam list + {% endif %} - {% if object.physics_exams.all %} -

Physics Exams:

- - View exam list - {% endif %} + {% if object.physics_exams.all %} +

Physics Exams:

+ + View exam list + {% endif %} - {% if object.sbas_exams.all %} -

SBAs Exams:

- - View exam list - {% endif %} + {% if object.sbas_exams.all %} +

SBAs Exams:

+ + View exam list + {% endif %} diff --git a/physics/templates/physics/exam_start.html b/physics/templates/physics/exam_start.html index ed5d6df2..f3da912e 100755 --- a/physics/templates/physics/exam_start.html +++ b/physics/templates/physics/exam_start.html @@ -9,13 +9,14 @@ {% endif %} {% if request.user.is_authenticated and valid_user %} - Start Exam + {% else %} Enter your CID and passcode in the below boxes.

- + + {% endif %} + {% include "physics/exam_take_help.html" %} {% endblock %} diff --git a/physics/templates/physics/exam_take.html b/physics/templates/physics/exam_take.html index e9e9454b..15b962f0 100755 --- a/physics/templates/physics/exam_take.html +++ b/physics/templates/physics/exam_take.html @@ -15,6 +15,10 @@ + {% elif cid_user_exam.completed %} + {% endif %}
@@ -92,135 +96,126 @@ -
Help -

Each question contains a list of 5 different statements. These are either True or False

-

Click on each statement to toggle between True and False. The current state can be seen to the right of the statement.

-

Your answers are saved when navigating between questions (or if the save button is clicked on the final question). An overview of all the questions can be seen by clicking on the overview button (or by clicking here).

-
-{% endblock %} + {% include "physics/exam_take_help.html" %} -{% block js %} - -{% endblock %} -{% block css %} - -{% endblock %} + + {% endblock %} diff --git a/physics/templates/physics/exam_take_help.html b/physics/templates/physics/exam_take_help.html new file mode 100644 index 00000000..008c94f7 --- /dev/null +++ b/physics/templates/physics/exam_take_help.html @@ -0,0 +1,14 @@ +
+ Help +

Each question contains a list of 5 different statements. These are either True or False

+

Click on each statement to toggle between True and False. The current state can be seen to the right of the statement.

+

Your answers are saved when navigating between questions (or if the save button is clicked on the final question). An overview of all the questions can be seen by clicking on the overview button.

+

Results are also available on the results page + here.

+
\ No newline at end of file diff --git a/physics/templates/physics/exam_take_overview.html b/physics/templates/physics/exam_take_overview.html index a5c6a6ba..d0d8fa63 100644 --- a/physics/templates/physics/exam_take_overview.html +++ b/physics/templates/physics/exam_take_overview.html @@ -2,7 +2,7 @@ {% block content %} - {% if request.user.is_authenticated %} + {% if not cid %} User: {{request.user}} {% else %} CID: {{cid}} @@ -22,9 +22,16 @@ here {% endif %}
- {% endif %} - - {% if not exam.publish_results and answer_count != exam_length %} + {% elif cid_user_exam.completed %} +