{% extends "manage.html" %} {% load static %} {% block title %} Lesson Views {% endblock %} {% block script %} <script type="text/javascript" src="{% static 'yaksh/js/jquery.tablesorter.min.js' %}"> </script> <script type="text/javascript"> function get_time_in_seconds(time) { var time = time.split(":"); var hh = parseInt(time[0]); var mm = parseInt(time[1]); var ss = parseInt(time[2]); return hh * 3600 + mm * 60 + ss; } $(document).ready(function() { $("#stats-table").tablesorter({}); $('#stats-table tr').each(function() { var td = $(this).find("td"); var elapsed = td.eq(4).html(); var duration = td.eq(5).html(); if (elapsed != undefined || duration != undefined) { percent = (get_time_in_seconds(elapsed) / get_time_in_seconds(duration)) * 100; td.eq(6).html(Math.round(percent)); } }); }); </script> {% endblock %} {% block content %} <div class="container"> {% with objects.object_list as trackings %} <center> <h3>Statistics for {% with trackings|first as entry %} {{entry.lesson}} {% endwith %}</h3> </center> <a class="btn btn-primary" href="{% url 'yaksh:lesson_statistics' course_id lesson_id %}"> <i class="fa fa-arrow-left"></i> Back </a> <br><br> {% include "yaksh/paginator.html" %} <br> <h4><strong>{{total}} student(s) viewed this lesson</strong></h4> <table class="table table-responsive" id="stats-table"> <thead> <tr> <th>Sr No.</th> <th>Student Name <i class="fa fa-sort"></i></th> <th>Last access on <i class="fa fa-sort"></i></th> <th>Started on <i class="fa fa-sort"></i></th> <th>Current Duration <i class="fa fa-sort"></i></th> <th>Video Duration <i class="fa fa-sort"></i></th> <th>Percentage watched <i class="fa fa-sort"></i></th> <th>Total visits <i class="fa fa-sort"></i></th> </tr> </thead> {% for track in trackings %} <tr> <td>{{ forloop.counter0|add:objects.start_index }}</td> <td>{{track.user.get_full_name}}</td> {% with track.get_last_access_time_and_vists as time_and_visits %} <td>{{time_and_visits.0}}</td> <td>{{track.creation_time}}</td> <td>{{track.current_time}}</td> <td>{{track.video_duration}}</td> <td></td> <td>{{time_and_visits.1}}</td> {% endwith %} </tr> {% endfor %} </table> {% endwith %} <br> {% include "yaksh/paginator.html" %} </div> {% endblock %}