diff options
author | Prabhu Ramachandran | 2011-11-19 17:45:19 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2011-11-19 17:45:19 +0530 |
commit | 637db68dca2a909657c151566ad36897a4353999 (patch) | |
tree | e94c666397d8f82557169a419ebbd0c0062df4e1 /exam | |
parent | e263244c70e8c5db0bc89bfee84ce37fe8e40d16 (diff) | |
download | online_test-637db68dca2a909657c151566ad36897a4353999.tar.gz online_test-637db68dca2a909657c151566ad36897a4353999.tar.bz2 online_test-637db68dca2a909657c151566ad36897a4353999.zip |
BUG: Misc. bug fixes.
- Timeout for signal.alarm is an integer.
- The total_seconds method on timedelta is new to 2.7 and doesn't work
on older versions.
Diffstat (limited to 'exam')
-rw-r--r-- | exam/models.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/exam/models.py b/exam/models.py index 8fe803d..8be87e4 100644 --- a/exam/models.py +++ b/exam/models.py @@ -148,7 +148,11 @@ class QuestionPaper(models.Model): def time_left(self): """Return the time remaining for the user in seconds.""" dt = datetime.datetime.now() - self.start_time - secs = dt.total_seconds() + try: + secs = dt.total_seconds() + except AttributeError: + # total_seconds is new in Python 2.7. :( + secs = dt.seconds + dt.days*24*3600 total = self.quiz.duration*60.0 remain = max(total - secs, 0) return int(remain) |