some refactoring and atlas improvements

This commit is contained in:
Ross
2023-07-24 11:56:12 +01:00
parent e6469e70f0
commit dd300afd63
26 changed files with 521 additions and 170 deletions
@@ -0,0 +1,43 @@
# Generated by Django 4.1.4 on 2023-07-24 09:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sbas', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='exam',
name='candidates_only',
field=models.BooleanField(default=True, help_text='If the exam/collection is only available to candidates who have been added'),
),
migrations.AlterField(
model_name='exam',
name='active',
field=models.BooleanField(default=False, help_text='If an exam/collection should be available to take'),
),
migrations.AlterField(
model_name='exam',
name='archive',
field=models.BooleanField(default=False, help_text='Archived exams/collections will remain on the test system but will not be displayed by default'),
),
migrations.AlterField(
model_name='exam',
name='name',
field=models.CharField(help_text='Name of the exam/collection', max_length=200),
),
migrations.AlterField(
model_name='exam',
name='open_access',
field=models.BooleanField(default=False, help_text='If the exam/collection is freely accessible (to view and edit on the test system)'),
),
migrations.AlterField(
model_name='exam',
name='publish_results',
field=models.BooleanField(default=False, help_text='If an exam/collections results should be available'),
),
]
+3 -9
View File
@@ -102,8 +102,7 @@ def active_exams(request):
def exam_scores_cid_user(request, pk, cid, passcode):
exam = get_object_or_404(Exam, pk=pk)
if not exam.check_cid_user(cid, passcode, request):
raise Http404("Error accessing exam")
exam.check_user_can_review(cid, passcode, request)
questions = exam.exam_questions.all()
@@ -179,8 +178,7 @@ def exam_take_overview(request, pk, cid=None, passcode=None):
if not exam.active:
return exam_inactive(request, context={"exam": exam})
if not exam.check_cid_user(cid, passcode, request):
raise Http404("Error accessing exam")
exam.check_user_can_take(cid, passcode, request)
questions = exam.exam_questions.all()
@@ -222,11 +220,7 @@ def exam_take_overview(request, pk, cid=None, passcode=None):
def exam_take(request, pk: int, sk: int, cid: int = None, passcode: str = None):
exam = get_object_or_404(Exam, pk=pk)
if not exam.active:
raise Http404("Exam not found")
if not exam.check_cid_user(cid, passcode, request):
raise Http404("Error accessing exam")
exam.check_user_can_take(cid, passcode, request)
cid_user_exam = exam.get_or_create_cid_user_exam(cid = cid, user_user=request.user)