answerdb: Timestamp answers
[quizzer.git] / quizzer / answerdb.py
index 7054057797607bb11ec5cc3f995b8eed2917da18..c8c802f9bc3606d012823cd3a7a8d53e469a7f7e 100644 (file)
@@ -1,6 +1,21 @@
-# Copyright
+# Copyright (C) 2013 W. Trevor King <wking@tremily.us>
+#
+# This file is part of quizzer.
+#
+# quizzer is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# quizzer is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# quizzer.  If not, see <http://www.gnu.org/licenses/>.
 
 import codecs as _codecs
+import datetime as _datetime
 import json as _json
 
 from . import __version__
@@ -41,9 +56,12 @@ class AnswerDatabase (dict):
     def add(self, question, answer, correct):
         if question.id not in self:
             self[question.id] = []
+        timezone = _datetime.timezone.utc
+        timestamp = _datetime.datetime.now(tz=timezone).isoformat()
         self[question.id].append({
                 'answer': answer,
                 'correct': correct,
+                'timestamp': timestamp,
                 })
 
     def get_answered(self, questions):