Basic anatomy user integration testing
This commit is contained in:
+2
-1
@@ -2,6 +2,7 @@ from django.urls import path, include
|
||||
|
||||
from generic.models import Examination
|
||||
from . import views
|
||||
from generic.views import ExamViews as GenericExamViews
|
||||
|
||||
|
||||
app_name = "generic"
|
||||
@@ -131,7 +132,7 @@ def generic_view_urls(generic_views):
|
||||
return urlpatterns
|
||||
|
||||
|
||||
def generic_exam_urls(generic_exam_view):
|
||||
def generic_exam_urls(generic_exam_view: GenericExamViews):
|
||||
urlpatterns = [
|
||||
path("", generic_exam_view.index, name="index"),
|
||||
path("exam/<int:pk>/", generic_exam_view.exam_overview, name="exam_overview"),
|
||||
|
||||
+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