Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def quiz_detail(request, pk):
- response_data = {}
- answers = None
- total_score = 0
- current_question_id = 1
- quiz_object = get_object_or_404(Quiz, pk=pk)
- current_quiz_object = CurrentQuiz.objects.create(
- quiz=quiz_object,
- user=request.user
- )
- question_queryset = current_quiz_object.quiz.questions.all()
- current_question = question_queryset.get(pk=current_question_id)
- answers = current_question.answers.all()
- if request.method == 'POST':
- return HttpResponse('da eb tvoyu')
- return render(request, 'game/quiz_detail.html', {'question_queryset': question_queryset,
- 'question': current_question,
- 'answers': answers,
- })
- #Тут сам темплейт
- {% extends 'game/base.html' %}
- {% load static %}
- {% block title %}{{ quiz.title }}{% endblock %}
- {% block content %}
- <!-- <style>
- .question {
- display: none;
- }
- </style> -->
- <h1>{{ current_quiz.quiz.title }}</h1>
- <div class="question-block">
- {% for question in question_queryset %}
- <div class="question" id='{{ question.pk }}'>
- {{ question }}
- <form action="." method="post">
- {% for answer in answers %}
- <input type="radio" id="{{ answer.pk }}" name="answer" value="{{ answer.answer_text }}">
- <label for="{{ answer.pk }}">{{ answer.answer_text }}</label><br>
- {% endfor %}
- <button type="submit" class='button'>Next question</button>
- {% csrf_token %}
- </form>
- </div>
- {% endfor %}
- </div>
- <!--
- <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
- integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=" crossorigin="anonymous"></script>
- <script src="{% static 'game/js.js' %}"></script> -->
- {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment