--- a/event/models.py Tue Apr 20 23:31:57 2010 +0530
+++ b/event/models.py Tue Apr 20 23:55:04 2010 +0530
@@ -14,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', choices=QUIZ_CHOICES)
+ quiz_status = models.CharField(max_length=2, default='00', verbose_name="Quiz Name", choices=QUIZ_CHOICES)
--- a/event/views.py Tue Apr 20 23:31:57 2010 +0530
+++ b/event/views.py Tue Apr 20 23:55:04 2010 +0530
@@ -63,5 +63,28 @@
return render_to_response('create_event.html',{'form':form})
def open_quiz(request, admin_key):
- pass
+ """ check for admin and then for quiz status.
+ """
+
+ if not admin_key == ADMIN_KEY:
+ raise Http404
+
+ try:
+ event = Event.objects.all()[0]
+ except IndexError:
+ return redirect('/event/create/%s'%ADMIN_KEY)
+ if event.quiz_status != "00":
+ return redirect('/event/create/%s'%ADMIN_KEY)
+
+ if request.method=="POST":
+ try:
+ quiz_num = request.POST['quiz_num']
+ event.quiz_status = quiz_num
+ event.save()
+ return render_to_response("open_quiz.html",{'success':True})
+ except MultiValueDictKeyError:
+ raise Http404
+ else:
+ return render_to_response("open_quiz.html")
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/open_quiz.html Tue Apr 20 23:55:04 2010 +0530
@@ -0,0 +1,16 @@
+{% extends 'base.html' %}
+{% block content %}
+ {% if success %}
+ The quiz has been successfully opened.
+ {% else %}
+ Select the quiz to open.
+ <form action="" method="post">
+ <select name="quiz_num">
+ <option value="11">Day 1 Quiz 1</option>
+ <option value="12">Day 1 Quiz 2</option>
+ <option value="21">Day 2 Quiz 1</option>
+ </select>
+ <input type="submit" value="Open">
+ </form>
+ {% endif %}
+{% endblock %}