From 3a4d9cbb5a81032261b7437ece10f062bb363a4e Mon Sep 17 00:00:00 2001 From: Ross Date: Fri, 31 Dec 2021 10:45:09 +0000 Subject: [PATCH] . --- anatomy/migrations/0058_exam_user_scores.py | 18 +++++++++++++++ generic/migrations/0024_auto_20211231_1044.py | 23 +++++++++++++++++++ generic/models.py | 14 +++++++++++ generic/views.py | 3 +++ longs/migrations/0057_exam_user_scores.py | 18 +++++++++++++++ physics/migrations/0017_exam_user_scores.py | 18 +++++++++++++++ rapids/migrations/0043_exam_user_scores.py | 18 +++++++++++++++ sbas/migrations/0009_exam_user_scores.py | 18 +++++++++++++++ 8 files changed, 130 insertions(+) create mode 100644 anatomy/migrations/0058_exam_user_scores.py create mode 100644 generic/migrations/0024_auto_20211231_1044.py create mode 100644 longs/migrations/0057_exam_user_scores.py create mode 100644 physics/migrations/0017_exam_user_scores.py create mode 100644 rapids/migrations/0043_exam_user_scores.py create mode 100644 sbas/migrations/0009_exam_user_scores.py diff --git a/anatomy/migrations/0058_exam_user_scores.py b/anatomy/migrations/0058_exam_user_scores.py new file mode 100644 index 00000000..670fde36 --- /dev/null +++ b/anatomy/migrations/0058_exam_user_scores.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.10 on 2021-12-31 10:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('anatomy', '0057_auto_20211215_2036'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='user_scores', + field=models.JSONField(default=dict), + ), + ] diff --git a/generic/migrations/0024_auto_20211231_1044.py b/generic/migrations/0024_auto_20211231_1044.py new file mode 100644 index 00000000..2b78cbd7 --- /dev/null +++ b/generic/migrations/0024_auto_20211231_1044.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.10 on 2021-12-31 10:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('generic', '0023_alter_examination_examination'), + ] + + operations = [ + migrations.AlterField( + model_name='contrast', + name='contrast', + field=models.CharField(max_length=200, unique=True), + ), + migrations.AlterField( + model_name='plane', + name='plane', + field=models.CharField(max_length=200, unique=True), + ), + ] diff --git a/generic/models.py b/generic/models.py index 07147ce9..5a532397 100644 --- a/generic/models.py +++ b/generic/models.py @@ -115,6 +115,8 @@ class ExamBase(models.Model): stats_graph = models.TextField(default=0) + user_scores = models.JSONField(default=dict) + notes = GenericRelation("generic.CidUserExam") # time_limit = models.IntegerField( @@ -125,6 +127,15 @@ class ExamBase(models.Model): class Meta: abstract = True + def get_exam_stats(self): + text = f"""{self.name} + ----- + Candidate number: {self.stats_candidates} + Max (possible) score: {self.stats_max_possible} + Mean: {self.stats_mean} Median: {self.stats_median} Mode: {self.stats_mode} [Min: {self.stats_min} / Max: {self.stats_max}] + """ + return text + def __str__(self): return self.name @@ -303,6 +314,9 @@ class CidUser(models.Model): if self.results_email_sent and not resend: return False, "Already sent." + # Get a list of taken exams + exams = self.get_cid_exams() + msg = f""" """ diff --git a/generic/views.py b/generic/views.py index 2f61c54a..8a4790d9 100644 --- a/generic/views.py +++ b/generic/views.py @@ -1085,6 +1085,9 @@ class ExamViews(View, LoginRequiredMixin): exam.stats_max = max(user_scores_list) exam.stats_graph = fig_html + + exam.user_scores = user_scores + exam.save() return render( diff --git a/longs/migrations/0057_exam_user_scores.py b/longs/migrations/0057_exam_user_scores.py new file mode 100644 index 00000000..e7083991 --- /dev/null +++ b/longs/migrations/0057_exam_user_scores.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.10 on 2021-12-31 10:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0056_auto_20211215_2036'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='user_scores', + field=models.JSONField(default=dict), + ), + ] diff --git a/physics/migrations/0017_exam_user_scores.py b/physics/migrations/0017_exam_user_scores.py new file mode 100644 index 00000000..92f0c0b8 --- /dev/null +++ b/physics/migrations/0017_exam_user_scores.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.10 on 2021-12-31 10:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('physics', '0016_auto_20211215_2036'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='user_scores', + field=models.JSONField(default=dict), + ), + ] diff --git a/rapids/migrations/0043_exam_user_scores.py b/rapids/migrations/0043_exam_user_scores.py new file mode 100644 index 00000000..2093395d --- /dev/null +++ b/rapids/migrations/0043_exam_user_scores.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.10 on 2021-12-31 10:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('rapids', '0042_auto_20211215_2036'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='user_scores', + field=models.JSONField(default=dict), + ), + ] diff --git a/sbas/migrations/0009_exam_user_scores.py b/sbas/migrations/0009_exam_user_scores.py new file mode 100644 index 00000000..6bea5c66 --- /dev/null +++ b/sbas/migrations/0009_exam_user_scores.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.10 on 2021-12-31 10:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sbas', '0008_auto_20211215_2036'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='user_scores', + field=models.JSONField(default=dict), + ), + ]