From 28c99bb1448e6e935ff48a55d38573fb9d3c1e4b Mon Sep 17 00:00:00 2001 From: Zacharis278 Date: Thu, 11 Jul 2024 11:46:21 -0400 Subject: [PATCH] feat: add exam allowance model --- .../core/migrations/0026_studentallowance.py | 33 +++++++++++++++++++ edx_exams/apps/core/models.py | 20 +++++++++++ 2 files changed, 53 insertions(+) create mode 100644 edx_exams/apps/core/migrations/0026_studentallowance.py diff --git a/edx_exams/apps/core/migrations/0026_studentallowance.py b/edx_exams/apps/core/migrations/0026_studentallowance.py new file mode 100644 index 00000000..ca19e834 --- /dev/null +++ b/edx_exams/apps/core/migrations/0026_studentallowance.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.13 on 2024-07-11 15:45 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone +import model_utils.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0025_proctoringprovider_org_key'), + ] + + operations = [ + migrations.CreateModel( + name='StudentAllowance', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')), + ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')), + ('extra_time_mins', models.PositiveIntegerField()), + ('exam', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.exam')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'student allowance', + 'db_table': 'exams_studentallowance', + 'unique_together': {('user', 'exam')}, + }, + ), + ] diff --git a/edx_exams/apps/core/models.py b/edx_exams/apps/core/models.py index 91d2db15..3343498c 100644 --- a/edx_exams/apps/core/models.py +++ b/edx_exams/apps/core/models.py @@ -428,3 +428,23 @@ def _sync_exams_with_new_provider(cls, course_id, new_provider): exam.save() return len(exams) + + +class StudentAllowance(TimeStampedModel): # pragma: no cover + """ + Allowance for extra time in an exam + + TODO: We should remove the no cover pragma once we have code that + uses this model. + """ + user = models.ForeignKey(User, db_index=True, on_delete=models.CASCADE) + + exam = models.ForeignKey(Exam, on_delete=models.CASCADE) + + extra_time_mins = models.PositiveIntegerField() + + class Meta: + """ Meta class for this Django model """ + db_table = 'exams_studentallowance' + verbose_name = 'student allowance' + unique_together = ('user', 'exam')