Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.shortcuts import render
- from .models import Quiz
- from django.views.generic import ListView
- from django.http import JsonResponse
- class QuizListView(ListView):
- model = Quiz
- template_name = 'quizes/main.html'
- # Create your views here.
- def quiz_view(request,pk):
- quiz = Quiz.objects.get(pk=pk)
- return render(request,'quizes/quiz.html',{'quiz':quiz})
- def quiz_data_view(request,pk):
- quiz = Quiz.objects.get(pk=pk)
- questions = []
- for q in quiz.get_questions():
- answers = []
- for a in q.get_answers():
- answers.append(a.text)
- questions.append({str(q): answers})
- return JsonResponse(
- {
- 'data': questions,
- 'time': quiz.time
- }
- )
- def save_quiz_view(request,pk):
- print(request.POST)
- return JsonResponse({
- 'text': 'work'
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement