diff options
author | Prabhu Ramachandran | 2018-02-15 19:10:48 +0530 |
---|---|---|
committer | GitHub | 2018-02-15 19:10:48 +0530 |
commit | 0757a779f5acb41ed52263e3c8406c24918a1e88 (patch) | |
tree | a5656ff7548b17ca170c01b8fa4f799d8798c10c /yaksh/models.py | |
parent | b78b5d0b46114caefca35e82c502d1f7598e8e59 (diff) | |
parent | c1ae8cbf2b85b343aa0d147cc874692e1f3e1a0d (diff) | |
download | online_test-0757a779f5acb41ed52263e3c8406c24918a1e88.tar.gz online_test-0757a779f5acb41ed52263e3c8406c24918a1e88.tar.bz2 online_test-0757a779f5acb41ed52263e3c8406c24918a1e88.zip |
Merge pull request #417 from ankitjavalkar/time-between-attempts
Change time_between_attempts field unit Hours
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 1e45851..9a406c3 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -78,7 +78,6 @@ string_check_type = ( attempts = [(i, i) for i in range(1, 6)] attempts.append((-1, 'Infinite')) -days_between_attempts = [(j, j) for j in range(401)] test_status = ( ('inprogress', 'Inprogress'), @@ -294,8 +293,8 @@ class Quiz(models.Model): # Number of attempts for the quiz attempts_allowed = models.IntegerField(default=1, choices=attempts) - time_between_attempts = models.IntegerField( - "Number of Days", choices=days_between_attempts + time_between_attempts = models.FloatField( + "Time Between Quiz Attempts in hours" ) is_trial = models.BooleanField(default=False) @@ -335,20 +334,32 @@ class Quiz(models.Model): return demo_quiz def get_total_students(self, course): + try: + qp = self.questionpaper_set.get().id + except QuestionPaper.DoesNotExist: + qp = None return AnswerPaper.objects.filter( - question_paper=self.questionpaper_set.get().id, + question_paper=qp, course=course ).values_list("user", flat=True).distinct().count() def get_passed_students(self, course): + try: + qp = self.questionpaper_set.get().id + except QuestionPaper.DoesNotExist: + qp = None return AnswerPaper.objects.filter( - question_paper=self.questionpaper_set.get().id, + question_paper=qp, course=course, passed=True ).values_list("user", flat=True).distinct().count() def get_failed_students(self, course): + try: + qp = self.questionpaper_set.get().id + except QuestionPaper.DoesNotExist: + qp = None return AnswerPaper.objects.filter( - question_paper=self.questionpaper_set.get().id, + question_paper=qp, course=course, passed=False ).values_list("user", flat=True).distinct().count() @@ -1208,7 +1219,7 @@ class QuestionPaper(models.Model): user=user, questionpaper=self, course_id=course_id ) if last_attempt: - time_lag = (timezone.now() - last_attempt.start_time).days + time_lag = (timezone.now() - last_attempt.start_time).total_seconds() / 3600 return time_lag >= self.quiz.time_between_attempts else: return True |