summaryrefslogtreecommitdiff
path: root/stats/models.py
diff options
context:
space:
mode:
authoradityacp2020-11-06 18:21:48 +0530
committeradityacp2020-11-06 18:21:48 +0530
commitfe5b3c41aa898fa7491a7ec9bce28c5e1c5b542d (patch)
treee831246ddb7cdbff9a11dde0a554cd4a37ced49d /stats/models.py
parent43958e5932d68fce533d60a1abb953680d422ba9 (diff)
downloadonline_test-fe5b3c41aa898fa7491a7ec9bce28c5e1c5b542d.tar.gz
online_test-fe5b3c41aa898fa7491a7ec9bce28c5e1c5b542d.tar.bz2
online_test-fe5b3c41aa898fa7491a7ec9bce28c5e1c5b542d.zip
Statistics app for video tracking
Diffstat (limited to 'stats/models.py')
-rw-r--r--stats/models.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/stats/models.py b/stats/models.py
new file mode 100644
index 0000000..f2f1bce
--- /dev/null
+++ b/stats/models.py
@@ -0,0 +1,24 @@
+# Django Imports
+from django.db import models
+from django.utils import timezone
+from django.contrib.auth.models import User
+
+# Local Imports
+from yaksh.models import Course, Lesson
+
+
+class TrackLesson(models.Model):
+ user = models.ForeignKey(User, on_delete=models.CASCADE)
+ course = models.ForeignKey(Course, on_delete=models.CASCADE)
+ lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE)
+ current_time = models.CharField(max_length=100, default="00:00:00")
+ video_duration = models.CharField(max_length=100, default="00:00:00")
+ last_access_time = models.DateTimeField(default=timezone.now)
+ creation_time = models.DateTimeField(auto_now_add=True)
+
+ class Meta:
+ unique_together = ('user', 'course', 'lesson')
+
+ def __str__(self):
+ return (f"Track {self.lesson} in {self.course} "
+ f"for {self.user.get_full_name()}")