.
This commit is contained in:
@@ -128,6 +128,15 @@ class ExamBase(models.Model):
|
||||
authors = [i for i in self.author.all()]
|
||||
return authors
|
||||
|
||||
def check_cid_user(self, cid, passcode):
|
||||
if self.valid_users.exists():
|
||||
user = self.valid_users.filter(cid=cid).first()
|
||||
|
||||
if not user or user.passcode != passcode:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class NoteType(models.Model):
|
||||
note_type = models.CharField(max_length=200)
|
||||
|
||||
+2
-7
@@ -323,13 +323,8 @@ def exam_take(request, pk, sk, cid, passcode=None):
|
||||
if not exam.active:
|
||||
raise Http404("Exam not found")
|
||||
|
||||
if exam.valid_users.exists():
|
||||
user = exam.valid_users.filter(cid=cid).first()
|
||||
|
||||
if not user:
|
||||
raise Http404("Exam not found")
|
||||
if user.passcode != passcode:
|
||||
raise Http404("Invalid passcode")
|
||||
if not exam.check_cid_user(cid, passcode):
|
||||
raise Http404("Error accessing exam")
|
||||
|
||||
question = exam.exam_questions.all()[sk]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user