From 8d8e9beb56e203a6a01ea227e30e36998361dba0 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Tue, 12 May 2020 21:20:17 +0530 Subject: Add testcases for start view function --- yaksh/models.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 64489b8..b64ac77 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -773,14 +773,20 @@ class LearningModule(models.Model): def get_passing_status(self, user, course): course_status = CourseStatus.objects.filter(user=user, course=course) + ordered_units = [] if course_status.exists(): - learning_units_with_quiz = self.learning_unit.filter(type='quiz') + learning_units_with_quiz = self.learning_unit.filter( + type='quiz' + ).order_by("order") ordered_units = learning_units_with_quiz.order_by("order") - statuses = [ - unit.quiz.get_answerpaper_passing_status(user, course) - for unit in ordered_units - ] + if ordered_units: + statuses = [ + unit.quiz.get_answerpaper_passing_status(user, course) + for unit in ordered_units + ] + else: + statuses = [] if not statuses: status = False -- cgit