diff options
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6ee02e1..6a1dfbe 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -390,7 +390,7 @@ class QuestionPaper(models.Model): user_ip=ip, attempt_number=attempt_num ) - ans_paper.start_time = datetime.now() + ans_paper.start_time = timezone.now() ans_paper.end_time = ans_paper.start_time + \ timedelta(minutes=self.quiz.duration) ans_paper.question_paper = self @@ -414,7 +414,7 @@ class QuestionPaper(models.Model): last_attempt = AnswerPaper.objects.get_user_last_attempt(user=user, questionpaper=self) if last_attempt: - time_lag = (datetime.today() - last_attempt.start_time.replace(tzinfo=None)).days + time_lag = (timezone.now() - last_attempt.start_time).days return time_lag >= self.quiz.time_between_attempts else: return True @@ -660,7 +660,7 @@ class AnswerPaper(models.Model): def time_left(self): """Return the time remaining for the user in seconds.""" - dt = datetime.now() - self.start_time.replace(tzinfo=None) + dt = timezone.now() - self.start_time try: secs = dt.total_seconds() except AttributeError: |