.
This commit is contained in:
+2
-1
@@ -702,7 +702,7 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
|
||||
allow_authors: bool = True,
|
||||
):
|
||||
"""Checks if a user (cid or otherwise) is allowed to access (and take) the exam"""
|
||||
print(f"Check cid user: {cid=}, {passcode=}, exam_id={self.pk}")
|
||||
print(f"Check cid user: {cid=}, {passcode=}, exam_id={self.pk}, {user=}, {user_id=}, {allow_authors=}")
|
||||
if user is not None and user.is_superuser:
|
||||
return True
|
||||
|
||||
@@ -724,6 +724,7 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
|
||||
return False
|
||||
|
||||
|
||||
|
||||
# Start by checking if the logged in user can access
|
||||
if user_id is not None:
|
||||
if self.valid_user_users.filter(pk=user_id).exists():
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if exam.archive %}
|
||||
<div class="alert alert-info" role="alert">
|
||||
This exam is archived. Results and submitted answers will not be available to candidates. They can still be viewed by supervisors.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
This exam has {{question_number}} questions.
|
||||
<span title="Time per question: {% widthratio exam.time_limit question_number 1 %} seconds">Time limit: {{exam.time_limit}} seconds [{{exam.get_time_limit}}]
|
||||
@@ -101,7 +106,7 @@ Open access: {{ exam.open_access }}<br />
|
||||
id="exam-publish-results-switch" data-posturl="{% url exam.get_app_name|add:':exam_toggle_results_published' pk=exam.pk %}"
|
||||
{% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will be available to users on this site]</span>
|
||||
</div>
|
||||
{% if exam.get_app_name == "anatomy" or exam.get_app_name == "rapids" or exam.get_app_name == "longs" %}
|
||||
{% if exam.get_app_name == "anatomy" or exam.get_app_name == "longs" %}
|
||||
<p><a href="{% url exam.get_app_name|add:':mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
+7
-2
@@ -184,6 +184,7 @@ def get_user_exams(user, supervisor_view=False):
|
||||
|
||||
if supervisor_view:
|
||||
kwargs["results_supervisor_visible"] = True
|
||||
del kwargs["archive"]
|
||||
|
||||
exams = []
|
||||
for exam_type in EXAM_ANSWER_MAP:
|
||||
@@ -527,7 +528,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
if (exam.open_access and exam.active) or user in exam.get_author_objects():
|
||||
return True
|
||||
|
||||
if exam.cid_user_exam.filter(user_user=user):
|
||||
if user.is_authenticated and exam.active and exam.cid_user_exam.filter(user_user=user):
|
||||
return True
|
||||
|
||||
if marker and user in exam.markers.all():
|
||||
@@ -1914,10 +1915,12 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
user_id = None
|
||||
else:
|
||||
user_id = request.user.pk
|
||||
print(0)
|
||||
if exam.exam_mode and not exam.check_cid_user(
|
||||
cid, passcode, request.user, user_id
|
||||
):
|
||||
raise Http404("No available exam")
|
||||
print(1)
|
||||
|
||||
# exam_json_cache = cache.get("{}_exam_json_{}".format(self.app_name, pk))
|
||||
|
||||
@@ -2116,10 +2119,10 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
# check for supervisor access
|
||||
raise Http404("Error accessing exam")
|
||||
view_all_results = True
|
||||
else:
|
||||
if user is None:
|
||||
raise Exception("user must be defined")
|
||||
view_all_results = True
|
||||
|
||||
if user is not None:
|
||||
request.user = user
|
||||
@@ -3853,6 +3856,8 @@ def supervisor_trainee(request, pk, trainee_id):
|
||||
|
||||
exams = get_user_exams(trainee, supervisor_view=True)
|
||||
|
||||
print(exams)
|
||||
|
||||
print(trainee)
|
||||
|
||||
return render(
|
||||
|
||||
Reference in New Issue
Block a user