From 9b057e3e4762f4b611764bd534201131d617f5a6 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 1 Aug 2021 09:48:01 +0100 Subject: [PATCH] . --- ...name_json_creation_id_exam_exam_json_id.py | 18 +++ anatomy/templates/anatomy/exam_overview.html | 4 + generic/models.py | 2 +- generic/views.py | 8 +- longs/migrations/0040_auto_20210801_0947.py | 23 +++ longs/models.py | 8 +- longs/templates/longs/exam_overview.html | 11 +- longs/templates/longs/long_display_block.html | 2 +- longs/templates/longs/long_series_viewer.html | 6 +- ...name_json_creation_id_exam_exam_json_id.py | 18 +++ ...name_json_creation_id_exam_exam_json_id.py | 18 +++ rapids/templates/rapids/exam_overview.html | 152 ++++++++++-------- ...name_json_creation_id_exam_exam_json_id.py | 18 +++ 13 files changed, 201 insertions(+), 87 deletions(-) create mode 100644 anatomy/migrations/0043_rename_json_creation_id_exam_exam_json_id.py create mode 100644 longs/migrations/0040_auto_20210801_0947.py create mode 100644 physics/migrations/0011_rename_json_creation_id_exam_exam_json_id.py create mode 100644 rapids/migrations/0027_rename_json_creation_id_exam_exam_json_id.py create mode 100644 sbas/migrations/0003_rename_json_creation_id_exam_exam_json_id.py diff --git a/anatomy/migrations/0043_rename_json_creation_id_exam_exam_json_id.py b/anatomy/migrations/0043_rename_json_creation_id_exam_exam_json_id.py new file mode 100644 index 00000000..b634d914 --- /dev/null +++ b/anatomy/migrations/0043_rename_json_creation_id_exam_exam_json_id.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.4 on 2021-08-01 08:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('anatomy', '0042_exam_json_creation_id'), + ] + + operations = [ + migrations.RenameField( + model_name='exam', + old_name='json_creation_id', + new_name='exam_json_id', + ), + ] diff --git a/anatomy/templates/anatomy/exam_overview.html b/anatomy/templates/anatomy/exam_overview.html index 44ac9132..4899985c 100644 --- a/anatomy/templates/anatomy/exam_overview.html +++ b/anatomy/templates/anatomy/exam_overview.html @@ -43,6 +43,10 @@ {% endfor %}

+
+ JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}), + JSON creation id: {{exam.exam_json_id}} +
JSON Refresh JSON cache diff --git a/generic/models.py b/generic/models.py index 78b976a6..251bb702 100644 --- a/generic/models.py +++ b/generic/models.py @@ -73,7 +73,7 @@ class ExamBase(models.Model): ) json_creation_time = models.DateTimeField(blank=True, default=None, null=True) - json_creation_id = models.IntegerField(default=1, help_text="auto incrementing field when json recreated") + exam_json_id = models.IntegerField(default=1, help_text="auto incrementing field when json recreated") #time_limit = models.IntegerField( # help_text="Exam time limit (in seconds). Default is 2100 secondse (35 minutes)", diff --git a/generic/views.py b/generic/views.py index 0f4c482b..5f55c409 100644 --- a/generic/views.py +++ b/generic/views.py @@ -401,7 +401,7 @@ class ExamViews(View, LoginRequiredMixin): "type": self.question_type, "eid": "{}/{}".format(self.question_type, exam.pk), "json_creation_time": creation_time, - "json_creation_id": exam.creation_id + "exam_json_id": exam.exam_json_id } if self.question_type == "long": @@ -410,7 +410,7 @@ class ExamViews(View, LoginRequiredMixin): # Generate json if needed if question.json_creation_time is None: question.get_json(question.pk) - h[question.pk] = question.json_creation_id + h[question.pk] = question.question_json_id obj["multi_question_json"] = h active_exams["exams"].append( obj ) @@ -477,12 +477,12 @@ class ExamViews(View, LoginRequiredMixin): time = datetime.now() - exam.json_creation_id += 1 + exam.exam_json_id += 1 with open(path, "w+") as f: exam_json = exam.get_exam_json() exam_json["generated"] = time.isoformat() - exam_json["creation_id"] = exam.json_creation_id + exam_json["exam_json_id"] = exam.exam_json_id f.write(json.dumps(exam_json)) exam.recreate_json = False diff --git a/longs/migrations/0040_auto_20210801_0947.py b/longs/migrations/0040_auto_20210801_0947.py new file mode 100644 index 00000000..a9d8ed8b --- /dev/null +++ b/longs/migrations/0040_auto_20210801_0947.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.4 on 2021-08-01 08:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0039_auto_20210801_0918'), + ] + + operations = [ + migrations.RenameField( + model_name='exam', + old_name='json_creation_id', + new_name='exam_json_id', + ), + migrations.RenameField( + model_name='long', + old_name='json_creation_id', + new_name='question_json_id', + ), + ] diff --git a/longs/models.py b/longs/models.py index e60921f6..323b03f7 100644 --- a/longs/models.py +++ b/longs/models.py @@ -126,7 +126,7 @@ class Long(models.Model): json_creation_time = models.DateTimeField(blank=True, default=None, null=True) - json_creation_id = models.IntegerField(default=1, help_text="Auto incrementing json creation number") + question_json_id = models.IntegerField(default=1, help_text="Auto incrementing json creation number") #question_file = models.FileField(upload_to=question_file_directory_path, blank=True, null=True) @@ -214,7 +214,7 @@ class Long(models.Model): url= "{0}longs/questions/{1}.json".format(settings.MEDIA_URL, question_id) timestamp = datetime.datetime.now() - q.json_creation_id += 1 + q.question_json_id += 1 with open(path, "w+") as f: @@ -224,7 +224,7 @@ class Long(models.Model): "type": "long", "generated": "{}", "creation_id": "{}", - """.format(q.history, timestamp.isoformat(), q.json_creation_id) + """.format(q.history, timestamp.isoformat(), q.question_json_id) ) @@ -589,7 +589,7 @@ class Exam(ExamBase): # If it is a new question we need to for a question json refresh if q.json_creation_time is None: q.get_json(q.pk) - exam_questions[q.id] = q.json_creation_id + exam_questions[q.id] = q.question_json_id else: # TODO: combine with question_json diff --git a/longs/templates/longs/exam_overview.html b/longs/templates/longs/exam_overview.html index 6944ecba..6671b7cd 100644 --- a/longs/templates/longs/exam_overview.html +++ b/longs/templates/longs/exam_overview.html @@ -45,11 +45,20 @@ {% endfor %} +
+ Author: {% for author in exam.author.all %} + {{ author }}, + {% endfor %} +
+

+
+ JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}), + JSON creation id: {{exam.exam_json_id}} +
JSON Refresh JSON cache -