diff options
author | King | 2019-02-26 22:43:10 +0530 |
---|---|---|
committer | GitHub | 2019-02-26 22:43:10 +0530 |
commit | dda5b4626a6df366860b0079447137b709d46d88 (patch) | |
tree | fefe4594ee8837c4eeb52ea853adc69544e0608b /yaksh/views.py | |
parent | 8b5674dbd170307f5acac63fa1c53fd94dbe990e (diff) | |
parent | 055dcaa679d50baab56b7e0c20b8de19a400d11c (diff) | |
download | online_test-dda5b4626a6df366860b0079447137b709d46d88.tar.gz online_test-dda5b4626a6df366860b0079447137b709d46d88.tar.bz2 online_test-dda5b4626a6df366860b0079447137b709d46d88.zip |
Merge pull request #566 from ankitjavalkar/toggle-view-grade
Toggle view grade and other UI improvements
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 1ea7a22..94ef19b 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,30 @@ 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 course in courses: + if user in course.students.all(): + _percent = course.get_completion_percent(user) + else: + _percent = None + courses_data.append( + { + 'data': course, + 'completion_percentage': _percent, + } + ) + context = { - 'user': user, 'courses': courses, + 'user': user, 'courses': courses_data, 'title': title, 'msg': msg } |