From cea09519959e8c8c4a0e5250f13b895fc081d324 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 22 Jul 2020 12:42:57 +0530 Subject: Fix division by zero error when quizzes do not exist --- yaksh/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh') diff --git a/yaksh/models.py b/yaksh/models.py index 1b076a8..6542daa 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1194,8 +1194,8 @@ class CourseStatus(models.Model): self.save() def calculate_percentage(self): - if self.is_course_complete(): - quizzes = self.course.get_quizzes() + quizzes = self.course.get_quizzes() + if self.is_course_complete() and quizzes: total_weightage = 0 sum = 0 for quiz in quizzes: -- cgit