Skip to content

Commit

Permalink
use timezone.now for Exam.date_created, move def from AbstractExam ->…
Browse files Browse the repository at this point in the history
… DraftExam
  • Loading branch information
nucleogenesis committed Jul 3, 2024
1 parent 08ae627 commit df83c52
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions kolibri/core/exams/migrations/0009_alter_exam_date_created.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.25 on 2024-07-03 21:46
import django.utils.timezone
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
("exams", "0008_draft_exams"),
]

operations = [
migrations.AlterField(
model_name="exam",
name="date_created",
field=models.DateTimeField(default=django.utils.timezone.now),
),
]
6 changes: 3 additions & 3 deletions kolibri/core/exams/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ class Meta:
"""
data_model_version = models.SmallIntegerField(default=3)

date_created = models.DateTimeField(auto_now_add=True, null=True)

def __str__(self):
return self.title

Expand Down Expand Up @@ -196,6 +194,8 @@ class DraftExam(AbstractExam):
assignments = JSONField(default=list, blank=True)
learner_ids = JSONField(default=list, blank=True)

date_created = models.DateTimeField(auto_now_add=True, null=True)

def to_exam(self):
"""
Convert this draft exam to an exam object.
Expand Down Expand Up @@ -235,7 +235,7 @@ class Exam(AbstractExam, AbstractFacilityDataModel):
# Is this exam currently active and visible to students to whom it is assigned?
active = models.BooleanField(default=False)

date_created = models.DateTimeField(null=True)
date_created = models.DateTimeField(default=timezone.now)

# To be set True when the quiz is first set to active=True
date_activated = models.DateTimeField(default=None, null=True, blank=True)
Expand Down

0 comments on commit df83c52

Please sign in to comment.