summaryrefslogtreecommitdiff
path: root/stats
diff options
context:
space:
mode:
authorprathamesh2020-12-04 01:24:23 +0530
committerprathamesh2020-12-04 01:24:23 +0530
commit70a462d5be92723f34bfd6440f4f56b4af9d2eb3 (patch)
tree3e8d7974e312839fef10565095299024739dac43 /stats
parent4e577ed4db9895d757d1df8632b45fec3e3c2e2a (diff)
downloadonline_test-70a462d5be92723f34bfd6440f4f56b4af9d2eb3.tar.gz
online_test-70a462d5be92723f34bfd6440f4f56b4af9d2eb3.tar.bz2
online_test-70a462d5be92723f34bfd6440f4f56b4af9d2eb3.zip
Fix PEP8
Diffstat (limited to 'stats')
-rw-r--r--stats/models.py18
-rw-r--r--stats/test_models.py28
2 files changed, 26 insertions, 20 deletions
diff --git a/stats/models.py b/stats/models.py
index 56c7f0d..6774721 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -57,16 +57,17 @@ class TrackLesson(models.Model):
self.current_time = ct
def get_percentage_complete(self):
- if self.current_time == '00:00:00' and self.video_duration == '00:00:00':
+ ctime = self.current_time
+ vduration = self.video_duration
+ if ctime == '00:00:00' and vduration == '00:00:00':
return 'less than 25%'
- duration = str_to_time(self.video_duration)
- watch_time = str_to_time(self.current_time)
+ duration = str_to_time(vduration)
+ watch_time = str_to_time(ctime)
duration_seconds = time_to_seconds(duration)
watched_seconds = time_to_seconds(watch_time)
percentage = round((watched_seconds / duration_seconds) * 100)
return 'approx {0} %'.format(percentage)
-
def get_last_access_time(self):
lesson_logs = self.lessonlog_set
last_access_time = self.creation_time
@@ -75,9 +76,11 @@ class TrackLesson(models.Model):
return last_access_time
def set_watched(self):
- if self.current_time != '00:00:00' and self.video_duration != '00:00:00':
- duration = str_to_time(self.video_duration)
- watch_time = (str_to_datetime(self.current_time) + timezone.timedelta(
+ ctime = self.current_time
+ vduration = self.video_duration
+ if ctime != '00:00:00' and vduration != '00:00:00':
+ duration = str_to_time(vduration)
+ watch_time = (str_to_datetime(ctime) + timezone.timedelta(
seconds=10)).time()
self.watched = watch_time >= duration
@@ -87,7 +90,6 @@ class TrackLesson(models.Model):
self.save()
return self.watched
-
def time_spent(self):
if self.video_duration != '00:00:00':
hits = self.get_log_counter()
diff --git a/stats/test_models.py b/stats/test_models.py
index 49c561e..5506a64 100644
--- a/stats/test_models.py
+++ b/stats/test_models.py
@@ -8,28 +8,32 @@ from yaksh.models import Course, Lesson, LearningModule, LearningUnit
class TrackLessonTestCase(TestCase):
def setUp(self):
creator = User.objects.create(username='creator', password='test',
- email='test1@test.com')
+ email='test1@test.com')
self.student = User.objects.create(username='student', password='test',
- email='test2@test.com')
- self.course = Course.objects.create(name="Test Course",
- enrollment="Enroll Request", creator=creator)
- learning_module = LearningModule.objects.create(name='LM',
- description='module', creator=creator)
- self.lesson = Lesson.objects.create(name='Lesson',
- description='Video Lesson', creator=creator)
- learning_unit = LearningUnit.objects.create(order=1,
- lesson=self.lesson, type='lesson')
+ email='test2@test.com')
+ self.course = Course.objects.create(
+ name="Test Course", enrollment="Enroll Request", creator=creator
+ )
+ learning_module = LearningModule.objects.create(
+ name='LM', description='module', creator=creator
+ )
+ self.lesson = Lesson.objects.create(
+ name='Lesson', description='Video Lesson', creator=creator
+ )
+ learning_unit = LearningUnit.objects.create(order=1, type='lesson',
+ lesson=self.lesson)
learning_module.learning_unit.add(learning_unit)
learning_module.save()
self.course.learning_module.add(learning_module)
self.course.students.add(self.student)
self.course.save()
self.tracker = TrackLesson.objects.create(user=self.student,
- course=self.course, lesson=self.lesson)
+ course=self.course,
+ lesson=self.lesson)
LessonLog.objects.create(track=self.tracker)
self.last_access_time = timezone.now()
LessonLog.objects.create(track=self.tracker,
- last_access_time=self.last_access_time)
+ last_access_time=self.last_access_time)
def tearDown(self):
User.objects.all().delete()