This commit is contained in:
Ross
2021-08-01 09:17:44 +01:00
parent b6b00a46da
commit 3067e41ff9
5 changed files with 35 additions and 17 deletions
+9 -4
View File
@@ -126,6 +126,8 @@ 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_file = models.FileField(upload_to=question_file_directory_path, blank=True, null=True)
def get_absolute_url(self):
@@ -212,6 +214,8 @@ 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
with open(path, "w+") as f:
# We manually create the json for long questions to reducem memroy usade
@@ -219,7 +223,8 @@ class Long(models.Model):
"title": "{}",
"type": "long",
"generated": "{}",
""".format(q.history, timestamp.isoformat())
"creation_id": "{}",
""".format(q.history, timestamp.isoformat(), q.json_creation_id)
)
@@ -248,8 +253,8 @@ class Long(models.Model):
f.write('"image_titles" : {} }}'.format(json.dumps(image_titles)))
self.json_creation_time = timestamp
self.save()
q.json_creation_time = timestamp
q.save()
#exam_question = {
# "title": q.history,
@@ -584,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_time.isoformat()
exam_questions[q.id] = q.json_creation_id
else:
# TODO: combine with question_json