diff --git a/.gitignore b/.gitignore index ab2b6843..d614eec2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__ rad/settings_local.py venv .venv/ +.env \ No newline at end of file diff --git a/anatomy/migrations/0060_exam_authors_only.py b/anatomy/migrations/0060_exam_authors_only.py new file mode 100644 index 00000000..77f43469 --- /dev/null +++ b/anatomy/migrations/0060_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.13 on 2022-05-03 17:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('anatomy', '0059_exam_include_history'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam authors will be able to view.'), + ), + ] diff --git a/atlas/migrations/0044_userreportanswer.py b/atlas/migrations/0044_userreportanswer.py new file mode 100644 index 00000000..465dbfa8 --- /dev/null +++ b/atlas/migrations/0044_userreportanswer.py @@ -0,0 +1,33 @@ +# Generated by Django 3.2.13 on 2022-05-03 17:48 + +from django.conf import settings +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('atlas', '0043_alter_casecollection_cid_user_groups'), + ] + + operations = [ + migrations.CreateModel( + name='UserReportAnswer', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('answer', models.TextField(blank=True)), + ('feedback', models.TextField(blank=True)), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('score', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(10), django.core.validators.MinValueValidator(0)])), + ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='atlas.casedetail')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/generic/models.py b/generic/models.py index 44f4abe4..dcad3ac4 100644 --- a/generic/models.py +++ b/generic/models.py @@ -66,6 +66,16 @@ class Condition(tagulous.models.TagModel): class Sign(tagulous.models.TagModel): pass +class QuestionBase(models.Model): + + authors_only = models.BooleanField( + help_text="If true only question authors will be able to view.", + default=False, + ) + + class Meta: + abstract = True + class ExamBase(models.Model): name = models.CharField(max_length=200, help_text="Name of the exam") @@ -108,6 +118,11 @@ class ExamBase(models.Model): default=False, ) + authors_only = models.BooleanField( + help_text="If true only exam authors will be able to view.", + default=False, + ) + stats_mean = models.FloatField(default=0) stats_mode = models.CharField(default=0, max_length=25) stats_median = models.FloatField(default=0) diff --git a/generic/views.py b/generic/views.py index 9008630e..4a3330ac 100644 --- a/generic/views.py +++ b/generic/views.py @@ -299,6 +299,9 @@ class ExamViews(View, LoginRequiredMixin): if (exam.open_access and exam.active) or user in exam.get_author_objects(): return True + if exam.authors_only: + return False + if ( self.app_name == "rapids" and not user.groups.filter(name="rapid_checker").exists() @@ -350,6 +353,9 @@ class ExamViews(View, LoginRequiredMixin): if exam.open_access or user in exam.get_author_objects(): return True + if exam.authors_only: + return False + if ( self.app_name == "rapids" and not user.groups.filter(name="rapid_checker").exists() diff --git a/longs/migrations/0059_exam_authors_only.py b/longs/migrations/0059_exam_authors_only.py new file mode 100644 index 00000000..3dc7d732 --- /dev/null +++ b/longs/migrations/0059_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.13 on 2022-05-03 17:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0058_exam_include_history'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam authors will be able to view.'), + ), + ] diff --git a/physics/migrations/0019_exam_authors_only.py b/physics/migrations/0019_exam_authors_only.py new file mode 100644 index 00000000..b2cddb48 --- /dev/null +++ b/physics/migrations/0019_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.13 on 2022-05-03 17:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('physics', '0018_exam_include_history'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam authors will be able to view.'), + ), + ] diff --git a/rapids/migrations/0051_exam_authors_only.py b/rapids/migrations/0051_exam_authors_only.py new file mode 100644 index 00000000..f88eea4b --- /dev/null +++ b/rapids/migrations/0051_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.13 on 2022-05-03 17:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('rapids', '0050_alter_exam_cid_user_groups'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam authors will be able to view.'), + ), + ] diff --git a/sbas/migrations/0011_exam_authors_only.py b/sbas/migrations/0011_exam_authors_only.py new file mode 100644 index 00000000..9c66193c --- /dev/null +++ b/sbas/migrations/0011_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.13 on 2022-05-03 17:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sbas', '0010_exam_include_history'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam authors will be able to view.'), + ), + ]