summaryrefslogtreecommitdiff
path: root/stats
diff options
context:
space:
mode:
authoradityacp2020-11-16 16:54:07 +0530
committeradityacp2020-11-18 17:52:53 +0530
commit5f02880d022053ed07ed218fd52d9e436f6455ee (patch)
tree4596a627d68accb8ac27805a7ce34b7a1c70addb /stats
parent6aef69d6e5a3eb3dde2d39e0bb9e1dd5b05a8b3c (diff)
downloadonline_test-5f02880d022053ed07ed218fd52d9e436f6455ee.tar.gz
online_test-5f02880d022053ed07ed218fd52d9e436f6455ee.tar.bz2
online_test-5f02880d022053ed07ed218fd52d9e436f6455ee.zip
Change stats and yaksh
- Show total visits per student in lesson statistics - Remove settimeout ajax calls for tracking video positions - Show initial views per lesson in the course modules section
Diffstat (limited to 'stats')
-rw-r--r--stats/models.py16
-rw-r--r--stats/templates/view_lesson_tracking.html39
2 files changed, 42 insertions, 13 deletions
diff --git a/stats/models.py b/stats/models.py
index 0200a80..56c7f0d 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1,7 +1,11 @@
+# Python Imports
+import pandas as pd
+
# Django Imports
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
+from django.db.models import F
# Local Imports
from yaksh.models import Course, Lesson
@@ -93,6 +97,18 @@ class TrackLesson(models.Model):
return str(timezone.timedelta(seconds=total_duration))
return self.get_current_time()
+ def get_no_of_vists(self):
+ lesson_logs = self.lessonlog_set.values("last_access_time").annotate(
+ visits=F('last_access_time')
+ )
+ df = pd.DataFrame(lesson_logs)
+ visits = 1
+ if not df.empty:
+ visits = df.groupby(
+ [df['visits'].dt.date]
+ ).first().count()['visits']
+ return visits
+
def __str__(self):
return (f"Track {self.lesson} in {self.course} "
f"for {self.user.get_full_name()}")
diff --git a/stats/templates/view_lesson_tracking.html b/stats/templates/view_lesson_tracking.html
index ef5c9ae..d8d35c2 100644
--- a/stats/templates/view_lesson_tracking.html
+++ b/stats/templates/view_lesson_tracking.html
@@ -5,26 +5,29 @@
<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({});
+ $.tablesorter.addWidget({
+ id: "numbering",
+ format: function(table) {
+ var c = table.config;
+ $("tr:visible", table.tBodies[0]).each(function(i) {
+ $(this).find('td').eq(0).text(i + 1);
+ });
+ }
+ });
+ $("#stats-table").tablesorter({
+ headers: {0: { sorter: false }}, widgets: ['numbering']
+ });
});
</script>
{% endblock %}
{% block content %}
-<div class="container">
+<div class="container-fluid">
{% 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 %}">
+ <a class="btn btn-primary" href="{% url 'yaksh:get_course_modules' course_id %}">
<i class="fa fa-arrow-left"></i>&nbsp;Back
</a>
<br><br>
@@ -43,19 +46,29 @@
<th>Percentage Watched&nbsp;<i class="fa fa-sort"></i></th>
<th>Watched Once Completely&nbsp;<i class="fa fa-sort"></i></th>
<th>Total Time Spent&nbsp;<i class="fa fa-sort"></i></th>
+ <th>Total Visits&nbsp;<i class="fa fa-sort"></i></th>
</tr>
</thead>
{% for track in trackings %}
<tr>
- <td>{{ forloop.counter0|add:objects.start_index }}</td>
+ <td>{{ forloop.counter0 }}</td>
<td>{{track.user.get_full_name}}</td>
<td>{{track.get_last_access_time}}</td>
<td>{{track.creation_time}}</td>
<td>{{track.get_current_time}}</td>
<td>{{track.get_video_duration}}</td>
<td>{{track.get_percentage_complete}}</td>
- <td>{{track.get_watched}}</td>
+ <td>
+ {% with track.get_watched as watched %}
+ {% if watched %}
+ <span class="badge-pill badge-success">{{watched}}</span>
+ {% else %}
+ <span class="badge-pill badge-success">{{watched}}</span>
+ {% endif %}
+ {% endwith %}
+ </td>
<td>{{track.time_spent}}</td>
+ <td>{{track.get_no_of_vists}}</td>
</tr>
{% endfor %}
</table>