diff options
author | prathamesh | 2016-03-31 12:54:13 +0530 |
---|---|---|
committer | prathamesh | 2016-04-01 17:04:56 +0530 |
commit | b121d2215b7cd5f4de9d78a0bee015952d3f5d97 (patch) | |
tree | a59e8568eaaffa652abb65e8b9bad439c1cc295f /yaksh/models.py | |
parent | 0b2a7623a7a5e225ee7a29b438872705b2c4ba5b (diff) | |
download | online_test-b121d2215b7cd5f4de9d78a0bee015952d3f5d97.tar.gz online_test-b121d2215b7cd5f4de9d78a0bee015952d3f5d97.tar.bz2 online_test-b121d2215b7cd5f4de9d78a0bee015952d3f5d97.zip |
Added and modoified testcases
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 4d52794..828b0a0 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -339,7 +339,6 @@ class QuestionPaper(models.Model): questions = self._get_questions_for_answerpaper() ans_paper.questions.add(*questions) ans_paper.questions_unanswered.add(*questions) - ans_paper.save() return ans_paper def is_questionpaper_passed(self, user): @@ -352,13 +351,16 @@ class QuestionPaper(models.Model): return attempts != self.quiz.attempts_allowed def can_attempt_now(self, user): - last_attempt = AnswerPaper.objects.get_user_last_attempt(user=user, - questionpaper=self) - if last_attempt: - time_lag = (datetime.today() - last_attempt.start_time).days - return time_lag >= self.quiz.time_between_attempts + if self.is_attempt_allowed(user): + last_attempt = AnswerPaper.objects.get_user_last_attempt(user=user, + questionpaper=self) + if last_attempt: + time_lag = (datetime.today() - last_attempt.start_time).days + return time_lag >= self.quiz.time_between_attempts + else: + return True else: - return True + return False ############################################################################### class QuestionSet(models.Model): |