summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py12
-rw-r--r--yaksh/templates/yaksh/course_detail.html6
-rw-r--r--yaksh/templatetags/custom_filters.py5
-rw-r--r--yaksh/test_models.py3
4 files changed, 25 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)
diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html
index a5d10a7..9fcae68 100644
--- a/yaksh/templates/yaksh/course_detail.html
+++ b/yaksh/templates/yaksh/course_detail.html
@@ -136,12 +136,14 @@
<th>Sr No.</th>
<th>Students</th>
<th>Total</th>
+ <th>Grade</th>
<th colspan="{{modules|length}}">Modules</th>
</tr>
<tr>
<th scope="row"></th>
<th></th>
<th></th>
+ <th></th>
{% if modules %}
{% for module in modules %}
<th>
@@ -171,6 +173,10 @@
{% course_completion_percent course student as c_percent %}
{{c_percent}} %
</td>
+ <td>
+ {% course_grade course student as grade %}
+ {{grade}}
+ </td>
{% if modules %}
{% for module in modules %}
<td>
diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py
index 3c2c6fd..717c9bb 100644
--- a/yaksh/templatetags/custom_filters.py
+++ b/yaksh/templatetags/custom_filters.py
@@ -62,3 +62,8 @@ def module_completion_percent(course, module, user):
@register.simple_tag
def course_completion_percent(course, user):
return course.percent_completed(user)
+
+
+@register.simple_tag
+def course_grade(course, user):
+ return course.get_grade(user)
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 50d1843..4e2047e 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -1896,3 +1896,6 @@ class CourseStatusTestCases(unittest.TestCase):
self.course_status.set_grade()
# Then
self.assertEqual(self.course_status.get_grade(), 'B')
+
+ # Test get course grade after completion
+ self.assertEqual(self.course.get_grade(self.answerpaper1.user), 'B')