--- a/.hgignore Tue Apr 20 15:44:43 2010 +0530
+++ b/.hgignore Tue Apr 20 19:20:15 2010 +0530
@@ -2,3 +2,4 @@
*.pyc
*.db
*.swp
+*.bak
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/quiz/management/commands/seed_db.py Tue Apr 20 19:20:15 2010 +0530
@@ -0,0 +1,47 @@
+import sys
+from datetime import datetime
+
+from django.core.management.base import NoArgsCommand
+
+from offline.event.models import Event
+from offline.quiz.models import QuestionBank
+
+def seed_db():
+ ev = Event()
+ ev.title = "Some Workshop"
+ ev.start_date = datetime.now()
+ ev.stop_date = datetime.now()
+ ev.quiz_status = '11'
+ ev.save()
+
+ q1 = QuestionBank()
+ q1.quiz_num = "11"
+ q1.description = "How do you combine two lists a and b"
+ q1.type = 'S'
+ q1.time_limit = 15
+ q1.expected_ans = r"a + b"
+ q1.save()
+
+ q2 = QuestionBank()
+ q2.quiz_num = '11'
+ q2.description = "What IPython magic command would you use to obtain the code that you have already typed."
+ q2.type = "S"
+ q2.time_limit = 15
+ q2.expected_ans = r"%hist"
+ q2.save()
+
+ q3 = QuestionBank()
+ q3.quiz_num = "11"
+ q3.description = "a = [1, 2, 5, 9]. How do you add 10 to end of this list."
+ q3.type = "S"
+ q3.time_limit = 30
+ q3.expected_ans = r"a.append(10)"
+ q3.save()
+
+
+class Command(NoArgsCommand):
+
+ def handle_noargs(self, **options):
+ """ Just copied the code from seed_db.py """
+
+ seed_db()
--- a/quiz/models.py Tue Apr 20 15:44:43 2010 +0530
+++ b/quiz/models.py Tue Apr 20 19:20:15 2010 +0530
@@ -6,7 +6,7 @@
class Profile(models.Model):
user = models.ForeignKey(User)
- profession = models.CharField(max_length=20,help_text="(Ex: Faculty,Student etc.)")
+ profession = models.CharField(max_length=20,help_text="(Ex: Faculty, Student etc.)")
affiliated_to = models.CharField(max_length=100, verbose_name="College/Company")
class QuestionBank(models.Model):
@@ -39,3 +39,4 @@
quiz_num = models.CharField(max_length=2)
que_remaining = models.CharField(max_length=100)
que_answered = models.ManyToManyField(Answer)
+
--- a/quiz/views.py Tue Apr 20 15:44:43 2010 +0530
+++ b/quiz/views.py Tue Apr 20 19:20:15 2010 +0530
@@ -32,12 +32,6 @@
if user.is_authenticated():
return redirect("/quiz/start/%s"%user.username)
- try:
- Quiz.objects.get(event=event,user_ip=ip,quiz_num=event.quiz_status)
- return redirect("/quiz/complete")
- except Quiz.DoesNotExist:
- pass
-
if request.method == "POST":
form = UserRegisterForm(request.POST)
if form.is_valid():
@@ -71,4 +65,23 @@
return render_to_response('register.html',{'form':form})
def start_quiz(request, username):
- logout(request)
+ """ get the user by his username.
+ then check for the event quiz status
+ then check if his ip has finished the quiz
+ then make his quiz paper and redirect to the right question.
+ """
+
+ user = repuest.user
+ if not user.username == username:
+ raise Http404
+
+ try:
+ event = Event.objects.all()[0]
+ except IndexError:
+ raise Http404
+
+ if event.quiz_status == "00":
+ raise Http404
+
+
+
Binary file tmp.db.bak has changed