diff options
author | adityacp | 2020-11-16 16:54:07 +0530 |
---|---|---|
committer | adityacp | 2020-11-18 17:52:53 +0530 |
commit | 5f02880d022053ed07ed218fd52d9e436f6455ee (patch) | |
tree | 4596a627d68accb8ac27805a7ce34b7a1c70addb /stats/models.py | |
parent | 6aef69d6e5a3eb3dde2d39e0bb9e1dd5b05a8b3c (diff) | |
download | online_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/models.py')
-rw-r--r-- | stats/models.py | 16 |
1 files changed, 16 insertions, 0 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()}") |