diff options
author | ankitjavalkar | 2019-02-01 14:47:20 +0530 |
---|---|---|
committer | ankitjavalkar | 2019-02-01 14:47:20 +0530 |
commit | c70cf2a0fd8e51d4b689e08d78021cac848b0187 (patch) | |
tree | 609a448874df27c2474859da4a965f1293268246 /yaksh/views.py | |
parent | 64298d4afebdece1eaccb363e83dc64db6645c45 (diff) | |
download | online_test-c70cf2a0fd8e51d4b689e08d78021cac848b0187.tar.gz online_test-c70cf2a0fd8e51d4b689e08d78021cac848b0187.tar.bz2 online_test-c70cf2a0fd8e51d4b689e08d78021cac848b0187.zip |
Change Course Listing UI on Student Dashboard
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 } |