Basic anatomy user integration testing
This commit is contained in:
+7
-4
@@ -58,7 +58,7 @@ from .forms import (
|
||||
UserUserGroupForm,
|
||||
)
|
||||
|
||||
from .models import CidUser, CidUserGroup, Examination, QuestionNote, Supervisor, UserGrades, UserProfile, UserUserGroup, get_next_cid
|
||||
from .models import CidUser, CidUserGroup, ExamBase, Examination, QuestionNote, Supervisor, UserGrades, UserProfile, UserUserGroup, get_next_cid
|
||||
|
||||
from rapids.models import Rapid as RapidQuestion
|
||||
from rapids.models import Exam as RapidExam
|
||||
@@ -1319,9 +1319,11 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
eid = int(answer["eid"].split("/")[1])
|
||||
uid = False
|
||||
passcode = None
|
||||
|
||||
try:
|
||||
cid = int(answer["cid"])
|
||||
passcode = answer["passcode"]
|
||||
except ValueError:
|
||||
if answer["cid"].startswith("u-"):
|
||||
cid = False
|
||||
@@ -1352,9 +1354,9 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
}
|
||||
)
|
||||
|
||||
exam = get_object_or_404(self.Exam, pk=eid)
|
||||
exam: ExamBase = get_object_or_404(self.Exam, pk=eid)
|
||||
|
||||
if not exam.check_cid_user(cid, answer["passcode"], user_id=uid):
|
||||
if not exam.check_cid_user(cid, passcode, user_id=uid):
|
||||
return JsonResponse(
|
||||
{"success": False, "error": "invalid cid / passcode"}
|
||||
)
|
||||
@@ -1597,7 +1599,8 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
if not exam.exam_mode:
|
||||
raise Http404("Packet not in exam mode")
|
||||
|
||||
# TODO:Need some kind of test for cid
|
||||
if cid is not None and not exam.check_cid_user(cid, passcode, request):
|
||||
raise Http404("Error accessing exam")
|
||||
|
||||
questions = (
|
||||
exam.exam_questions.all()
|
||||
|
||||
Reference in New Issue
Block a user