now topic name is displayed instead of topic number in list_questions page
authornishanth
Thu, 01 Jul 2010 16:20:17 +0530
changeset 81 848c009b8a60
parent 80 96da6bf2b632
child 82 79ae8288b5ff
now topic name is displayed instead of topic number in list_questions page
event/views.py
templates/list_questions.html
--- a/event/views.py	Thu Jul 01 16:13:01 2010 +0530
+++ b/event/views.py	Thu Jul 01 16:20:17 2010 +0530
@@ -7,7 +7,7 @@
 from offline.event.models import Event
 from offline.event.forms import EventCreateForm, OpenQuizForm
 
-from offline.quiz.models import Quiz, QuestionBank
+from offline.quiz.models import Quiz, QuestionBank, TOPIC_CHOICES
 from offline.quiz.utils import correct_quiz
 
 num2name = {"11" : "Day 1 Quiz 1",
@@ -203,5 +203,9 @@
     """
 
     questions = QuestionBank.objects.all()
+    topic_num2name = dict(TOPIC_CHOICES)
+
+    for question in questions:
+        question.topic_name = topic_num2name[question.topic]
     return render_to_response("list_questions.html", {"questions":questions})
 
--- a/templates/list_questions.html	Thu Jul 01 16:13:01 2010 +0530
+++ b/templates/list_questions.html	Thu Jul 01 16:20:17 2010 +0530
@@ -9,7 +9,7 @@
 		{% for question in questions %}
 		<tr>
 <td><a href="/quiz/questions/ditchax/question.id">{{question.description}}</a></td>
-<td>{{question.topic}}</td>
+<td>{{question.topic_name}}</td>
 </tr>
 {% endfor %}
 </table>