--- a/event/models.py Tue Apr 20 23:12:15 2010 +0530
+++ b/event/models.py Tue Apr 20 23:29:44 2010 +0530
@@ -1,5 +1,11 @@
from django.db import models
+
+QUIZ_CHOICES = (("11", "Day 1 Quiz 1"),
+ ("12", "Day 1 Quiz 2"),
+ ("21", "Day 2 Quiz 1"),
+ )
+
class Event(models.Model):
""" An event.
"""
@@ -8,4 +14,4 @@
start_date = models.DateField()
stop_date = models.DateField()
feedback_status = models.CharField(max_length=1, default='0')
- quiz_status = models.CharField(max_length=2, default='00')
+ quiz_status = models.CharField(max_length=2, default='00', choices=QUIZ_CHOICES)
--- a/event/views.py Tue Apr 20 23:12:15 2010 +0530
+++ b/event/views.py Tue Apr 20 23:29:44 2010 +0530
@@ -18,7 +18,7 @@
can_submit_feedback = True if event.feedback_status != '0' and \
not event.feedback.filter(day=event.feedback_status,user_ip=ip) else False
- can_take_quiz = False
+ can_take_quiz = True if event.quiz_status != "00" else False
return render_to_response('home.html', {'event':event, 'can_submit_feedback':can_submit_feedback, 'can_take_quiz':can_take_quiz})
@@ -61,3 +61,7 @@
else:
form = EventCreateForm()
return render_to_response('create_event.html',{'form':form})
+
+def open_quiz(request, admin_key):
+ pass
+
--- a/quiz/models.py Tue Apr 20 23:12:15 2010 +0530
+++ b/quiz/models.py Tue Apr 20 23:29:44 2010 +0530
@@ -34,7 +34,7 @@
"""
user = models.ForeignKey(User)
- event = models.ForeignKey(Event)
+ event = models.ForeignKey(Event, related_name="%(class)s")
user_ip = models.CharField(max_length=15)
key = models.CharField(max_length=10)
--- a/settings.py Tue Apr 20 23:12:15 2010 +0530
+++ b/settings.py Tue Apr 20 23:29:44 2010 +0530
@@ -10,7 +10,7 @@
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = 'tmp.db' # Or path to database file if using sqlite3.
+DATABASE_NAME = 'offline.db' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
--- a/templates/admin.html Tue Apr 20 23:12:15 2010 +0530
+++ b/templates/admin.html Tue Apr 20 23:29:44 2010 +0530
@@ -7,6 +7,12 @@
<a href="/feedback/close/{{admin_key}}">Close feedback for day{{event.feedback_status}}</a>
{% endifequal %}
<br /><br />
+{% ifequal event.quiz_status "00" %}
+<a href="/quiz/open/{{admin_key}}">Open quiz</a>
+{% else %}
+<a href="/quiz/close/{{admin_key}}">Close quiz</a>
+{% endifequal %}
+<br /><br />
<a href="/feedback/list/{{admin_key}}">View the feedbacks submitted</a><br />
<a href="/feedback/report/{{admin_key}}">View report of feedbacks submitted</a><br />
{% endblock %}
--- a/templates/home.html Tue Apr 20 23:12:15 2010 +0530
+++ b/templates/home.html Tue Apr 20 23:29:44 2010 +0530
@@ -5,6 +5,6 @@
<a href="/feedback/submit">Submit Feedback</a><br />
{% endif %}
{% if can_take_quiz %}
-<a href="/quiz">Attempt {{quiz_name}} </a><br />
+<a href="/quiz">Attempt quiz</a><br />
{% endif %}
{% endblock %}
--- a/urls.py Tue Apr 20 23:12:15 2010 +0530
+++ b/urls.py Tue Apr 20 23:29:44 2010 +0530
@@ -27,6 +27,7 @@
(r'^feedback/close/(\w+)$', feed_views.close_feedback),
(r'^feedback/list/(\w+)$', feed_views.list_feedbacks),
(r'^feedback/report/(\w+)$', feed_views.view_report),
+ (r'^quiz/open/(\w+)$', event_views.open_quiz),
(r'^quiz$', quiz_views.start_page),
(r'^quiz/start/$', quiz_views.start_quiz),
(r'^quiz/answer/(\w+)$', quiz_views.answer),