From f02cd58ea21e08c9a7e8120fd5ced3263cf904f6 Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 21 Sep 2020 19:12:45 +0530 Subject: Add pagination in the lesson statistics --- yaksh/templates/yaksh/show_lesson_statistics.html | 18 +++++++++++------- yaksh/views.py | 9 +++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/yaksh/templates/yaksh/show_lesson_statistics.html b/yaksh/templates/yaksh/show_lesson_statistics.html index e7c99d8..2bcdd2d 100644 --- a/yaksh/templates/yaksh/show_lesson_statistics.html +++ b/yaksh/templates/yaksh/show_lesson_statistics.html @@ -11,7 +11,7 @@

{% if data %}
-
+
    {% for toc, count in data.items %}
  • @@ -20,10 +20,14 @@ {{ toc.content_object.summary }}
- {{toc.get_content_display}} + + {{toc.get_content_display}} +
@@ -48,7 +52,6 @@ {% else %}
- {% with per_que_data.0 as question %}
{{question.summary}}
@@ -111,9 +114,9 @@
{% endfor %}
- {% endwith %}

+ {% include "yaksh/paginator.html" %} @@ -122,7 +125,7 @@ - {% for data in per_que_data.1 %} + {% for data in objects.object_list %} @@ -143,11 +146,12 @@ {% endfor %}
Sr No.Latest Answer Status
{{forloop.counter}} {{data.student__first_name}} {{data.student__last_name}}
+ {% include "yaksh/paginator.html" %} {% endif %}
{% else %} -
+
No lesson quizzes found
{% endif %} diff --git a/yaksh/views.py b/yaksh/views.py index 2be8734..d909627 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -3906,12 +3906,17 @@ def lesson_statistics(request, course_id, lesson_id, toc_id=None): not course.is_creator(user) or not course.is_creator(user)): raise Http404("You are not allowed to view this page") context = {} + lesson = get_object_or_404(Lesson, id=lesson_id) data = TableOfContents.objects.get_data(course_id, lesson_id) context['data'] = data - context['lesson'] = next(iter(data)).lesson + context['lesson'] = lesson context['course_id'] = course_id if toc_id: per_que_data = TableOfContents.objects.get_question_stats(toc_id) - context['per_que_data'] = per_que_data + paginator = Paginator(per_que_data[1], 50) + context['question'] = per_que_data[0] + page = request.GET.get('page') + per_que_data = paginator.get_page(page) context['is_que_data'] = True + context['objects'] = per_que_data return render(request, 'yaksh/show_lesson_statistics.html', context) -- cgit