.
This commit is contained in:
@@ -127,6 +127,15 @@ class ExamBase(models.Model):
|
|||||||
"""Returns a comma seperated text list of authors"""
|
"""Returns a comma seperated text list of authors"""
|
||||||
authors = [i for i in self.author.all()]
|
authors = [i for i in self.author.all()]
|
||||||
return authors
|
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):
|
class NoteType(models.Model):
|
||||||
|
|||||||
+2
-7
@@ -323,13 +323,8 @@ def exam_take(request, pk, sk, cid, passcode=None):
|
|||||||
if not exam.active:
|
if not exam.active:
|
||||||
raise Http404("Exam not found")
|
raise Http404("Exam not found")
|
||||||
|
|
||||||
if exam.valid_users.exists():
|
if not exam.check_cid_user(cid, passcode):
|
||||||
user = exam.valid_users.filter(cid=cid).first()
|
raise Http404("Error accessing exam")
|
||||||
|
|
||||||
if not user:
|
|
||||||
raise Http404("Exam not found")
|
|
||||||
if user.passcode != passcode:
|
|
||||||
raise Http404("Invalid passcode")
|
|
||||||
|
|
||||||
question = exam.exam_questions.all()[sk]
|
question = exam.exam_questions.all()[sk]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user