lost track of changes...
This commit is contained in:
+3
-1
@@ -16,7 +16,7 @@ from sortedm2m.fields import SortedManyToManyField
|
||||
|
||||
import string
|
||||
|
||||
from generic.models import CidUser, CidUserGroup, Examination, ExamBase, QuestionNote, UserUserGroup
|
||||
from generic.models import CidUser, CidUserGroup, ExamUserStatus, Examination, ExamBase, QuestionNote, UserUserGroup
|
||||
|
||||
from collections import defaultdict
|
||||
from helpers.images import image_as_base64
|
||||
@@ -415,6 +415,8 @@ class Exam(ExamBase):
|
||||
related_name="anatomy_user_user_groups"
|
||||
)
|
||||
|
||||
exam_user_status = GenericRelation(ExamUserStatus)
|
||||
|
||||
def get_exam_json(self, based=True):
|
||||
questions = self.exam_questions.all()
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<a href="{% url 'anatomy:exam_overview' pk=exam.pk %}">Overview</a> /
|
||||
{% if exam.exam_mode %}
|
||||
<a href="{% url 'anatomy:mark_overview' pk=exam.pk %}">Mark</a> /
|
||||
<a href="{% url 'anatomy:exam_scores_cid' pk=exam.pk %}">Scores</a> /
|
||||
<a href="{% url 'anatomy:exam_scores_all' pk=exam.pk %}">Scores</a> /
|
||||
<a href="{% url 'anatomy:exam_cids' exam_id=exam.pk %}">Candidates</a> /
|
||||
{% endif %}
|
||||
<a href="{% url 'anatomy:anatomy_create_exam' pk=exam.pk %}">Add New Question</a>
|
||||
|
||||
@@ -116,6 +116,16 @@ def test_exams(db, client):
|
||||
cid_user_2001 = CidUser.objects.get(cid=2001)
|
||||
user1 = User.objects.get(username="user1")
|
||||
|
||||
# Test exam access urls
|
||||
|
||||
# Check that we can't access without logging in
|
||||
assert client.get(exam.get_json_url()).status_code == 404
|
||||
assert client.get(exam.get_json_url(cid=cid_user_2001.cid, passcode=cid_user_2001.passcode)).status_code == 404
|
||||
# Valid user but incorrect passcode
|
||||
assert client.get(exam.get_json_url(cid=cid_user_1001.cid, passcode=cid_user_2001.passcode)).status_code == 404
|
||||
|
||||
|
||||
|
||||
users_tested = 1
|
||||
for cid_user in [cid_user_1001, cid_user_1000, user1]:
|
||||
if isinstance(cid_user, CidUser):
|
||||
@@ -168,6 +178,7 @@ def test_exams(db, client):
|
||||
assert exam_metadata["exam_active"] == True
|
||||
assert exam_metadata["exam_mode"] == True
|
||||
|
||||
# Check that we can access the exam json
|
||||
res = client.get(exam_metadata["url"])
|
||||
assert res.status_code == 200
|
||||
exam_json = json.loads(res.content)
|
||||
|
||||
Reference in New Issue
Block a user