summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 6c7a12e..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
}
@@ -2825,8 +2838,6 @@ def preview_questionpaper(request, questionpaper_id):
if not is_moderator(user):
raise Http404('You are not allowed to view this page!')
paper = QuestionPaper.objects.get(id=questionpaper_id)
- if not paper.quiz.creator == user:
- raise Http404('This questionpaper does not belong to you')
context = {
'questions': paper._get_questions_for_answerpaper(),
'paper': paper,