summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exam/models.py6
-rw-r--r--settings.py4
2 files changed, 7 insertions, 3 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)
diff --git a/settings.py b/settings.py
index 11a44a2..4e9b390 100644
--- a/settings.py
+++ b/settings.py
@@ -8,8 +8,8 @@ TEMPLATE_DEBUG = DEBUG
# The port the Python server should run on.
SERVER_PORT = 8001
-# Timeout for the code to run in seconds.
-SERVER_TIMEOUT = 2.0
+# Timeout for the code to run in seconds. This is an integer!
+SERVER_TIMEOUT = 2
ADMINS = (
# ('Your Name', 'your_email@example.com'),