diff options
author | adityacp | 2018-03-01 19:00:55 +0530 |
---|---|---|
committer | adityacp | 2018-03-21 17:32:41 +0530 |
commit | 65c368a1360a83c2b10458ec61a4b74d9ac8e9f5 (patch) | |
tree | 970a031b18d4fe87eadee2c488ead5f6a6292d45 /yaksh/models.py | |
parent | 95f5f27c18380e2fb2f33526c467e822dd10c4d8 (diff) | |
download | online_test-65c368a1360a83c2b10458ec61a4b74d9ac8e9f5.tar.gz online_test-65c368a1360a83c2b10458ec61a4b74d9ac8e9f5.tar.bz2 online_test-65c368a1360a83c2b10458ec61a4b74d9ac8e9f5.zip |
Show student grade in course status page
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 1ecb1f8..32d7b3d 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -725,6 +725,14 @@ class Course(models.Model): percent = round((count / len(modules))) return percent + def get_grade(self, user): + course_status = CourseStatus.objects.filter(course=self, user=user) + if course_status.exists(): + grade = course_status.first().get_grade() + else: + grade = "NA" + return grade + def __str__(self): return self.name @@ -752,6 +760,7 @@ class CourseStatus(models.Model): grading_system = self.course.grading_system grade = grading_system.get_grade(self.percentage) self.grade = grade + self.save() def calculate_percentage(self): if self.is_course_complete(): @@ -765,7 +774,7 @@ class CourseStatus(models.Model): out_of = quiz.questionpaper_set.first().total_marks sum += (marks/out_of)*quiz.weightage self.percentage = (sum/total_weightage)*100 - + self.save() def is_course_complete(self): modules = self.course.get_learning_modules() @@ -776,6 +785,7 @@ class CourseStatus(models.Model): break return complete + ############################################################################### class ConcurrentUser(models.Model): concurrent_user = models.OneToOneField(User) |