diff options
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 6c7a12e..4c1b7f7 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -156,6 +156,7 @@ def user_logout(request): def quizlist_user(request, enrolled=None, msg=None): """Show All Quizzes that is available to logged-in user.""" user = request.user + courses_data = [] if request.method == "POST": course_code = request.POST.get('course_code') @@ -164,18 +165,27 @@ def quizlist_user(request, enrolled=None, msg=None): title = 'Search' elif enrolled is not None: - courses = user.students.all() + courses = user.students.all().order_by('-id') title = 'Enrolled Courses' else: courses = Course.objects.filter( active=True, is_trial=False ).exclude( ~Q(requests=user), ~Q(rejected=user), hidden=True - ) + ).order_by('-id') title = 'All Courses' + for c in courses: + _percent = c.get_completion_percent(user) if user in c.students.all() else None + courses_data.append( + { + 'data': c, + 'completion_percentage': _percent, + } + ) + context = { - 'user': user, 'courses': courses, + 'user': user, 'courses': courses_data, 'title': title, 'msg': msg } |