.
This commit is contained in:
@@ -34,7 +34,7 @@ APP_NAME = "anatomy"
|
|||||||
|
|
||||||
def create_exam(db):
|
def create_exam(db):
|
||||||
exam: Exam = AnatomyExamViews.Exam.objects.create(
|
exam: Exam = AnatomyExamViews.Exam.objects.create(
|
||||||
name="Cid Exam", exam_mode=True, active=True
|
name="Cid Exam", exam_mode=True, active=True, open_access=False, exam_open_access=False
|
||||||
)
|
)
|
||||||
|
|
||||||
group1: CidUserGroup = CidUserGroup.objects.get(name="Group1")
|
group1: CidUserGroup = CidUserGroup.objects.get(name="Group1")
|
||||||
@@ -194,6 +194,8 @@ def test_exams(db, client):
|
|||||||
exam.save()
|
exam.save()
|
||||||
|
|
||||||
res = client.get(exam_metadata["url"])
|
res = client.get(exam_metadata["url"])
|
||||||
|
print("PRE ERRER", exam_metadata["url"])
|
||||||
|
print(res.content)
|
||||||
assert res.status_code == 404
|
assert res.status_code == 404
|
||||||
|
|
||||||
exam.active = True
|
exam.active = True
|
||||||
@@ -365,7 +367,7 @@ def test_exams(db, client):
|
|||||||
cid_exam_scores_soup = BeautifulSoup(cid_exam_scores_res.content, "html.parser")
|
cid_exam_scores_soup = BeautifulSoup(cid_exam_scores_res.content, "html.parser")
|
||||||
|
|
||||||
# Check that we have an alert that exams are not published
|
# Check that we have an alert that exams are not published
|
||||||
alert = cid_exam_scores_soup.find("div", {"class": "alert"})
|
alert = cid_exam_scores_soup.find("div", {"class": "no-results"})
|
||||||
assert "Results are not currently published." in str(alert)
|
assert "Results are not currently published." in str(alert)
|
||||||
|
|
||||||
answer_lis = cid_exam_scores_soup.find(
|
answer_lis = cid_exam_scores_soup.find(
|
||||||
|
|||||||
+2
-1
@@ -702,7 +702,7 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
|
|||||||
allow_authors: bool = True,
|
allow_authors: bool = True,
|
||||||
):
|
):
|
||||||
"""Checks if a user (cid or otherwise) is allowed to access (and take) the exam"""
|
"""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:
|
if user is not None and user.is_superuser:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -724,6 +724,7 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Start by checking if the logged in user can access
|
# Start by checking if the logged in user can access
|
||||||
if user_id is not None:
|
if user_id is not None:
|
||||||
if self.valid_user_users.filter(pk=user_id).exists():
|
if self.valid_user_users.filter(pk=user_id).exists():
|
||||||
|
|||||||
@@ -28,6 +28,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% 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.
|
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}}]
|
<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 %}"
|
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>
|
{% 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>
|
</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>
|
<p><a href="{% url exam.get_app_name|add:':mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
+7
-2
@@ -184,6 +184,7 @@ def get_user_exams(user, supervisor_view=False):
|
|||||||
|
|
||||||
if supervisor_view:
|
if supervisor_view:
|
||||||
kwargs["results_supervisor_visible"] = True
|
kwargs["results_supervisor_visible"] = True
|
||||||
|
del kwargs["archive"]
|
||||||
|
|
||||||
exams = []
|
exams = []
|
||||||
for exam_type in EXAM_ANSWER_MAP:
|
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():
|
if (exam.open_access and exam.active) or user in exam.get_author_objects():
|
||||||
return True
|
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
|
return True
|
||||||
|
|
||||||
if marker and user in exam.markers.all():
|
if marker and user in exam.markers.all():
|
||||||
@@ -1914,10 +1915,12 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
user_id = None
|
user_id = None
|
||||||
else:
|
else:
|
||||||
user_id = request.user.pk
|
user_id = request.user.pk
|
||||||
|
print(0)
|
||||||
if exam.exam_mode and not exam.check_cid_user(
|
if exam.exam_mode and not exam.check_cid_user(
|
||||||
cid, passcode, request.user, user_id
|
cid, passcode, request.user, user_id
|
||||||
):
|
):
|
||||||
raise Http404("No available exam")
|
raise Http404("No available exam")
|
||||||
|
print(1)
|
||||||
|
|
||||||
# exam_json_cache = cache.get("{}_exam_json_{}".format(self.app_name, pk))
|
# exam_json_cache = cache.get("{}_exam_json_{}".format(self.app_name, pk))
|
||||||
|
|
||||||
@@ -2116,10 +2119,10 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
|
|
||||||
# check for supervisor access
|
# check for supervisor access
|
||||||
raise Http404("Error accessing exam")
|
raise Http404("Error accessing exam")
|
||||||
view_all_results = True
|
|
||||||
else:
|
else:
|
||||||
if user is None:
|
if user is None:
|
||||||
raise Exception("user must be defined")
|
raise Exception("user must be defined")
|
||||||
|
view_all_results = True
|
||||||
|
|
||||||
if user is not None:
|
if user is not None:
|
||||||
request.user = user
|
request.user = user
|
||||||
@@ -3853,6 +3856,8 @@ def supervisor_trainee(request, pk, trainee_id):
|
|||||||
|
|
||||||
exams = get_user_exams(trainee, supervisor_view=True)
|
exams = get_user_exams(trainee, supervisor_view=True)
|
||||||
|
|
||||||
|
print(exams)
|
||||||
|
|
||||||
print(trainee)
|
print(trainee)
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<div class="rapids">
|
<div class="rapids">
|
||||||
|
|
||||||
{% if exam.exam_mode %}
|
{% if exam.exam_mode %}
|
||||||
|
<a href="{% url exam.get_app_name|add:':mark_overview' pk=exam.pk %}"><button>Mark exam</button></a>
|
||||||
<a href="{% url 'rapids:mark_review' exam_pk=exam.pk sk=0 %}"><button>Review exam</button></a></p>
|
<a href="{% url 'rapids:mark_review' exam_pk=exam.pk sk=0 %}"><button>Review exam</button></a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -20,16 +20,16 @@
|
|||||||
<ul class="score-answer-list">
|
<ul class="score-answer-list">
|
||||||
{% for ans, score, correct_answer in answers_and_marks %}
|
{% for ans, score, correct_answer in answers_and_marks %}
|
||||||
<li class="user-answer-li" data-question-number="{{forloop.counter}}">Question {{forloop.counter}} - Correct answer: {% if exam.publish_results %}<span class="correct-answer">{{correct_answer}}</span>{% endif %}
|
<li class="user-answer-li" data-question-number="{{forloop.counter}}">Question {{forloop.counter}} - Correct answer: {% if exam.publish_results %}<span class="correct-answer">{{correct_answer}}</span>{% endif %}
|
||||||
|
<span class="view-question-link" data-qn={{forloop.counter0}}>View</span>
|
||||||
<br/>
|
<br/>
|
||||||
<span class="user-answer-score user-answer-score-{{score}}">
|
<span class="user-answer-score user-answer-score-{{score}}">
|
||||||
<span class="submitted-user-answer">
|
<span class="submitted-user-answer">
|
||||||
<pre>{{ans}}</pre>
|
<pre>{{ans}}</pre>
|
||||||
</span>
|
</span>
|
||||||
{% if exam.publish_results or view_all_results%}
|
{% if exam.publish_results or view_all_results%}
|
||||||
<span class="answer-score">{{score}}</span>
|
<span class="answer-score">Score: {{score}}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
<span class="view-question-link" data-qn={{forloop.counter0}}>View</span>
|
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -90,3 +90,14 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
<style>
|
||||||
|
.answer-score {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
{% endblock css %}
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ def test_supervisor_management(db, faker, client, create_cid_manager, django_use
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
soup = BeautifulSoup(response.content, "html.parser")
|
soup = BeautifulSoup(response.content, "html.parser")
|
||||||
assert len(soup.find(id="supervisor-list").find_all("li")) == 2
|
assert len(soup.find(id="tbody").find_all("tr")) == 2
|
||||||
|
|
||||||
response = client.get(reverse(f"generic:supervisor_detail", kwargs={"pk": s1.pk}))
|
response = client.get(reverse(f"generic:supervisor_detail", kwargs={"pk": s1.pk}))
|
||||||
soup = BeautifulSoup(response.content, "html.parser")
|
soup = BeautifulSoup(response.content, "html.parser")
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if not exam.publish_results %}
|
{% if not exam.publish_results %}
|
||||||
<div class="alert alert-info" role="alert">Results are not currently published. You can see your own answers below.</a></div>
|
<div class="alert alert-info no-results" role="alert">Results are not currently published. You can see your own answers below.</a></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user