diff options
author | adityacp | 2018-03-21 12:00:27 +0530 |
---|---|---|
committer | adityacp | 2018-03-21 12:08:32 +0530 |
commit | e244cd285669d3de80a764d75eecbb46b6d3fd63 (patch) | |
tree | 5370c89ef73fccac5ed575ecb287316ab390a7c2 /yaksh/models.py | |
parent | 06abd01fd28eb10aafd18dd60b790549e0233edc (diff) | |
download | online_test-e244cd285669d3de80a764d75eecbb46b6d3fd63.tar.gz online_test-e244cd285669d3de80a764d75eecbb46b6d3fd63.tar.bz2 online_test-e244cd285669d3de80a764d75eecbb46b6d3fd63.zip |
Add condition to get quiz status if answerpaper is created
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index f065190..ea4efce 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -366,6 +366,20 @@ class Quiz(models.Model): course=course, passed=False ).values_list("user", flat=True).distinct().count() + def get_answerpaper_status(self, user, course): + try: + qp = self.questionpaper_set.get().id + except QuestionPaper.DoesNotExist: + qp = None + ans_ppr = AnswerPaper.objects.filter( + user=user, course=course, question_paper=qp + ) + if ans_ppr.exists(): + status = "completed" + else: + status = "not attempted" + return status + def __str__(self): desc = self.description or 'Quiz' return '%s: on %s for %d minutes' % (desc, self.start_date_time, @@ -393,6 +407,8 @@ class LearningUnit(models.Model): if course_status.exists(): if self in course_status.first().completed_units.all(): state = "completed" + elif self.type == "quiz": + state = self.quiz.get_answerpaper_status(user, course) elif course_status.first().current_unit == self: state = "inprogress" return state |