.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.8 on 2021-12-11 13:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('generic', '0015_ciduser_ciduserexam'),
|
||||
('physics', '0014_alter_exam_open_access'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='exam',
|
||||
name='valid_users',
|
||||
field=models.ManyToManyField(blank=True, related_name='physics_exams', to='generic.CidUser'),
|
||||
),
|
||||
]
|
||||
+2
-1
@@ -12,7 +12,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from sortedm2m.fields import SortedManyToManyField
|
||||
|
||||
from generic.models import ExamBase, QuestionNote
|
||||
from generic.models import CidUser, ExamBase, QuestionNote
|
||||
|
||||
import reversion
|
||||
|
||||
@@ -154,6 +154,7 @@ class Exam(ExamBase):
|
||||
help_text='Author of exam',
|
||||
related_name="physics_exam_author")
|
||||
|
||||
valid_users = models.ManyToManyField(CidUser, blank=True, related_name="physics_exams")
|
||||
|
||||
|
||||
@reversion.register
|
||||
|
||||
+7
-1
@@ -315,13 +315,19 @@ def exam_finish(request, pk, cid):
|
||||
)
|
||||
|
||||
|
||||
def exam_take(request, pk, sk, cid):
|
||||
def exam_take(request, pk, sk, cid, passcode=None):
|
||||
|
||||
exam = get_object_or_404(Exam, pk=pk)
|
||||
|
||||
if not exam.active:
|
||||
raise Http404("Exam not found")
|
||||
|
||||
if exam.valid_users is not None:
|
||||
user = exam.valid_users.filter(cid=cid)
|
||||
|
||||
if not user or user.passcode != passcode:
|
||||
raise Http404("Exam not found")
|
||||
|
||||
question = exam.exam_questions.all()[sk]
|
||||
|
||||
exam_length = len(exam.exam_questions.all())
|
||||
|
||||
Reference in New Issue
Block a user