avaaren

AAAAAAAAAAAAAAA

Mar 15th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. def quiz_detail(request, pk):
  2.     response_data = {}
  3.     answers = None
  4.     total_score = 0
  5.     current_question_id = 1
  6.  
  7.     quiz_object = get_object_or_404(Quiz, pk=pk)
  8.     current_quiz_object = CurrentQuiz.objects.create(
  9.         quiz=quiz_object,
  10.         user=request.user
  11.     )
  12.     question_queryset = current_quiz_object.quiz.questions.all()
  13.     current_question = question_queryset.get(pk=current_question_id)
  14.     answers = current_question.answers.all()
  15.  
  16.     if request.method == 'POST':
  17.         return HttpResponse('da eb tvoyu')
  18.  
  19.     return render(request, 'game/quiz_detail.html', {'question_queryset': question_queryset,
  20.                                                      'question': current_question,
  21.                                                      'answers': answers,
  22.                                                      })
  23.  
  24.  
  25.  
  26. #Тут сам темплейт
  27. {% extends 'game/base.html' %}
  28. {% load static %}
  29.  
  30. {% block title %}{{ quiz.title }}{% endblock %}
  31.  
  32. {% block content %}
  33. <!-- <style>
  34.   .question {
  35.     display: none;
  36.   }
  37. </style> -->
  38.  
  39. <h1>{{ current_quiz.quiz.title }}</h1>
  40. <div class="question-block">
  41.   {% for question in question_queryset %}
  42.   <div class="question" id='{{ question.pk }}'>
  43.     {{ question }}
  44.     <form action="." method="post">
  45.       {% for answer in answers %}
  46.       <input type="radio" id="{{ answer.pk }}" name="answer" value="{{ answer.answer_text }}">
  47.       <label for="{{ answer.pk }}">{{ answer.answer_text }}</label><br>
  48.       {% endfor %}
  49.       <button type="submit" class='button'>Next question</button>
  50.       {% csrf_token %}
  51.     </form>
  52.   </div>
  53.   {% endfor %}
  54. </div>
  55.  
  56. <!--
  57. <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
  58.   integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=" crossorigin="anonymous"></script>
  59. <script src="{% static 'game/js.js' %}"></script> -->
  60. {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment