summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPalaparthy Adityachandra2020-07-22 17:30:20 +0530
committerGitHub2020-07-22 17:30:20 +0530
commit3999e744fe1a3a4c4fcb7d2763b36def9d7bb213 (patch)
treea01a1a7a19d3ae16a8471a30afa87dc6c5aa931a
parent3554ade38b0cea025d322e6e303b166a86bc1c6e (diff)
parentcea09519959e8c8c4a0e5250f13b895fc081d324 (diff)
downloadonline_test-3999e744fe1a3a4c4fcb7d2763b36def9d7bb213.tar.gz
online_test-3999e744fe1a3a4c4fcb7d2763b36def9d7bb213.tar.bz2
online_test-3999e744fe1a3a4c4fcb7d2763b36def9d7bb213.zip
Merge pull request #732 from ankitjavalkar/fix_zerodiv_error
Fix division by zero error when quizzes do not exist
-rw-r--r--yaksh/models.py4
1 files changed, 2 insertions, 2 deletions
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: