diff options
author | adityacp | 2020-12-04 09:56:25 +0530 |
---|---|---|
committer | adityacp | 2020-12-04 09:56:25 +0530 |
commit | c5b26a3b0d7e29f9813aa4fcdcbcaaa66945b86d (patch) | |
tree | 24bcd6fde15cc5843632a400a34c87361b52d9c6 /stats/models.py | |
parent | 882fe5cdaee8bc61e51f6626cc3941356905bb61 (diff) | |
parent | 56883784cdcd2a4f1a60cdaa7ba28525cfd21132 (diff) | |
download | online_test-c5b26a3b0d7e29f9813aa4fcdcbcaaa66945b86d.tar.gz online_test-c5b26a3b0d7e29f9813aa4fcdcbcaaa66945b86d.tar.bz2 online_test-c5b26a3b0d7e29f9813aa4fcdcbcaaa66945b86d.zip |
Resolve conflicts in models
Diffstat (limited to 'stats/models.py')
-rw-r--r-- | stats/models.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/stats/models.py b/stats/models.py index 60bc7bd..84ac7ae 100644 --- a/stats/models.py +++ b/stats/models.py @@ -75,16 +75,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 0 - 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 percentage - def get_last_access_time(self): lesson_logs = self.lessonlog_set last_access_time = self.creation_time @@ -93,9 +94,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=120)).time() self.watched = watch_time >= duration @@ -105,7 +108,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() |