add open access exams
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-10-14 11:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('anatomy', '0022_alter_exam_markers'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='exam',
|
||||
name='exam_open_access',
|
||||
field=models.BooleanField(default=False, help_text='Set to true if you want any registered user to be able to take the exam.'),
|
||||
),
|
||||
]
|
||||
@@ -128,6 +128,7 @@ class ExamFormMixin:
|
||||
"open_access",
|
||||
"authors_only",
|
||||
"exam_mode",
|
||||
"exam_open_access",
|
||||
"include_history",
|
||||
"active",
|
||||
"publish_results",
|
||||
@@ -192,6 +193,7 @@ class ExamFormMixin:
|
||||
"open_access",
|
||||
"authors_only",
|
||||
"exam_mode",
|
||||
"exam_open_access",
|
||||
"include_history",
|
||||
"restrict_to_dates",
|
||||
"start_date",
|
||||
|
||||
+10
-3
@@ -696,6 +696,7 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
|
||||
user_id: int | None = None,
|
||||
allow_authors: bool = True,
|
||||
):
|
||||
"""Checks if a user (cid or otherwise) is allowed to access (and take) the exam"""
|
||||
print(f"Check cid user: {cid=}, {passcode=}, exam_id={self.pk}")
|
||||
if user is not None and user.is_superuser:
|
||||
return True
|
||||
@@ -705,15 +706,19 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
|
||||
if self.author.filter(pk=user_id).exists():
|
||||
return True
|
||||
|
||||
if not self.valid_cid_users.exists() and not self.valid_user_users.exists():
|
||||
return False
|
||||
|
||||
if cid is None and user_id is None:
|
||||
if user is not None:
|
||||
user_id = user.id
|
||||
else:
|
||||
return False
|
||||
|
||||
if self.exam_open_access and user_id is not None:
|
||||
return True
|
||||
|
||||
if not self.valid_cid_users.exists() and not self.valid_user_users.exists():
|
||||
return False
|
||||
|
||||
|
||||
# Start by checking if the logged in user can access
|
||||
if user_id is not None:
|
||||
if self.valid_user_users.filter(pk=user_id).exists():
|
||||
@@ -852,6 +857,8 @@ class ExamBase(ExamOrCollectionGenericBase):
|
||||
default=False,
|
||||
)
|
||||
|
||||
exam_open_access = models.BooleanField(default=False, help_text="Set to true if you want any registered user to be able to take the exam.")
|
||||
|
||||
# randomise_question_order = models.BooleanField(
|
||||
# help_text="If an exam should randomise the order of questions in RTS.",
|
||||
# )
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-10-14 11:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('longs', '0029_alter_exam_markers'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='exam',
|
||||
name='exam_open_access',
|
||||
field=models.BooleanField(default=False, help_text='Set to true if you want any registered user to be able to take the exam.'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-10-14 11:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('physics', '0015_alter_exam_markers'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='exam',
|
||||
name='exam_open_access',
|
||||
field=models.BooleanField(default=False, help_text='Set to true if you want any registered user to be able to take the exam.'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-10-14 11:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rapids', '0013_alter_exam_markers'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='exam',
|
||||
name='exam_open_access',
|
||||
field=models.BooleanField(default=False, help_text='Set to true if you want any registered user to be able to take the exam.'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-10-14 11:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('sbas', '0015_alter_exam_markers'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='exam',
|
||||
name='exam_open_access',
|
||||
field=models.BooleanField(default=False, help_text='Set to true if you want any registered user to be able to take the exam.'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user