]> git.parisson.com Git - django_quiz.git/commitdiff
starting to update the views + making some simple templates to display them
authorTom Walker <tomwalker0472@gmail.com>
Wed, 11 Jun 2014 15:49:12 +0000 (16:49 +0100)
committerTom Walker <tomwalker0472@gmail.com>
Wed, 11 Jun 2014 15:49:12 +0000 (16:49 +0100)
quiz/views.py
templates/quiz/quiz_index.html

index 8002fb6582d502fa39f1cdb862da92e88bea483c..f61c19d9cd41a6542d60d9bc686c9e25ac32f91e 100644 (file)
@@ -9,10 +9,9 @@ from django.shortcuts import render_to_response
 from django.template import RequestContext
 from django.shortcuts import render, get_object_or_404
 
-
-from quiz.models import Quiz, Category, Progress, Sitting
-from multichoice.models import Question, Answer
-
+from quiz.models import Quiz, Category, Progress, Sitting, Question
+from multichoice.models import MCQuestion, Answer
+from true_false.models import TF_Question
 
 """
 
@@ -41,23 +40,21 @@ To do:
 """
 
 def index(request):
-    return render(request, 'quiz_index.html', {
-                'categories': Category.objects.all(),
-    })
+    all_quizzes = Quiz.objects.all()
+    return render(request, 'quiz_index.html',
+                  {'quiz_list': all_quizzes,})
 
 def list_categories(request):
-    return render(request, 'quiz_index.html', {
-                'categories': Category.objects.all(),
-    })
+    return render(request, 'quiz_index.html',
+                  {'categories': Category.objects.all(),})
 
 
 def view_category(request, slug):
     category = get_object_or_404(Category, category = slug.replace(' ', '-').lower())
     quizzes = Quiz.objects.filter(category=category)
-    return render(request, 'view_quiz_category.html', {
-                'category': category,
-                'quizzes': quizzes
-        })
+    return render(request, 'view_quiz_category.html',
+                  {'category': category,
+                   'quizzes': quizzes,})
 
 def quiz_take(request, quiz_name):
     """
index 0a802d0fe49a81f76f64e5ddda8f6cb464513964..a5466eaec11b3745344c766499e4a7dcf1aba491 100644 (file)
@@ -1,16 +1,16 @@
 {% extends 'base.html' %}
-{% block title %}All Quiz{% endblock %}
+{% block title %}All Quizzes{% endblock %}
 
 {% block content %}
-<h2>Categories</h2>
-    {% if categories %}
+<h2>Quiz list</h2>
+    {% if quiz_list %}
         <ul>
-        {% for category in categories %}
-            <li><a href="{{ category.get_absolute_url }}">{{ category.category }}</a></li>
+        {% for quiz in quiz_list %}
+            <li><a href="{% url 'quiz.views.quiz_take' quiz_name=quiz.url %}">{{ quiz.title }}</a></li>
         {% endfor %}
         </ul>
     {% else %}
-        <p>There are no categories.</p>
+        <p>There are no available quizzes.</p>
     {% endif %}
 {% endblock %}