event/views.py
changeset 81 848c009b8a60
parent 78 2264a51fc9cf
child 83 76971eed55c6
equal deleted inserted replaced
80:96da6bf2b632 81:848c009b8a60
     5 from offline.settings import ADMIN_KEY
     5 from offline.settings import ADMIN_KEY
     6 
     6 
     7 from offline.event.models import Event
     7 from offline.event.models import Event
     8 from offline.event.forms import EventCreateForm, OpenQuizForm
     8 from offline.event.forms import EventCreateForm, OpenQuizForm
     9 
     9 
    10 from offline.quiz.models import Quiz, QuestionBank
    10 from offline.quiz.models import Quiz, QuestionBank, TOPIC_CHOICES
    11 from offline.quiz.utils import correct_quiz
    11 from offline.quiz.utils import correct_quiz
    12 
    12 
    13 num2name = {"11" : "Day 1 Quiz 1",
    13 num2name = {"11" : "Day 1 Quiz 1",
    14             "12" : "Day 1 Quiz 2",
    14             "12" : "Day 1 Quiz 2",
    15             "21" : "Day 2 Quiz 1",
    15             "21" : "Day 2 Quiz 1",
   201 def list_questions(request):
   201 def list_questions(request):
   202     """ Display all the questions in a list.
   202     """ Display all the questions in a list.
   203     """
   203     """
   204 
   204 
   205     questions = QuestionBank.objects.all()
   205     questions = QuestionBank.objects.all()
       
   206     topic_num2name = dict(TOPIC_CHOICES)
       
   207 
       
   208     for question in questions:
       
   209         question.topic_name = topic_num2name[question.topic]
   206     return render_to_response("list_questions.html", {"questions":questions})
   210     return render_to_response("list_questions.html", {"questions":questions})
   207 
   211