diff options
author | adityacp | 2020-09-21 19:12:45 +0530 |
---|---|---|
committer | adityacp | 2020-09-21 19:12:45 +0530 |
commit | f02cd58ea21e08c9a7e8120fd5ced3263cf904f6 (patch) | |
tree | 2d325950d518ed85a4cf7b291055e8b81050939d /yaksh | |
parent | 45351763f76d75672419b8575f0a1561ee3a8a53 (diff) | |
download | online_test-f02cd58ea21e08c9a7e8120fd5ced3263cf904f6.tar.gz online_test-f02cd58ea21e08c9a7e8120fd5ced3263cf904f6.tar.bz2 online_test-f02cd58ea21e08c9a7e8120fd5ced3263cf904f6.zip |
Add pagination in the lesson statistics
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/templates/yaksh/show_lesson_statistics.html | 18 | ||||
-rw-r--r-- | 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 @@ <br><br> {% if data %} <div class="row"> - <div class="col-md-3"> + <div class="col-md-4"> <ul class="list-group"> {% for toc, count in data.items %} <li class="list-group-item"> @@ -20,10 +20,14 @@ {{ toc.content_object.summary }} </div> <div class="col-md-4"> - {{toc.get_content_display}} + <span class="badge badge-pill badge-info"> + {{toc.get_content_display}} + </span> </div> <div class="col-md-4"> - <a href="{% url 'yaksh:lesson_statistics' toc.course_id toc.lesson_id toc.id %}">Details</a> + <a href="{% url 'yaksh:lesson_statistics' toc.course_id toc.lesson_id toc.id %}" class="btn btn-outline-primary"> + <i class="fa fa-info-circle"></i> Details + </a> </div> </table> </li> @@ -48,7 +52,6 @@ </table> {% else %} <div class="card"> - {% with per_que_data.0 as question %} <div class="card-header"> {{question.summary}} <div> @@ -111,9 +114,9 @@ <br> {% endfor %} </div> - {% endwith %} </div> <br> + {% include "yaksh/paginator.html" %} <table class="table table-responsive"> <tr> <th>Sr No.</th> @@ -122,7 +125,7 @@ <th>Latest Answer</th> <th>Status</th> </tr> - {% for data in per_que_data.1 %} + {% for data in objects.object_list %} <tr> <td>{{forloop.counter}}</td> <td>{{data.student__first_name}} {{data.student__last_name}}</td> @@ -143,11 +146,12 @@ </tr> {% endfor %} </table> + {% include "yaksh/paginator.html" %} {% endif %} </div> </div> {% else %} - <div class="alert alert-info"> + <div class="container alert alert-warning"> No lesson quizzes found </div> {% 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) |