def post(self, request, quiz_id): ''' Start a quiz ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) # TODO: Check if quiz is valid quiz_room, created = QuizRoom.objects.get_or_create(quiz_id=quiz_id) return redirect('quiz:host', room_id=quiz_room.id)
def post(self, request, quiz_id): ''' Create a round Attributes: body containing round_info ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) round_info = {'type': request.POST.get('round_type')} round = create_round(quiz_wrapper, round_info) context = {'quiz_id': quiz_id, 'round_id': round.id} return redirect('quiz:edit-round', quiz_id=quiz_id, round_id=round.id)
def post(self, request, quiz_id): ''' Delete a quiz Attributes: PARAMS: - quiz_id ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) quiz_wrapper.quiz.delete() # TODO: Have some kinda notification in dashboard, "successfully deleted" etc return redirect('quiz:profile')
def post(self, request, quiz_id, round_id): ''' Delete a round Attributes: PARAMS: - quiz_id, round_id ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) round_wrapper = get_round_or_404(quiz_wrapper.quiz, round_id) round_wrapper.round.delete() return redirect('quiz:edit-quiz', quiz_id=quiz_id)
def get(self, request, quiz_id): ''' Render the form to edit a quiz Attributes: None ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) context = { 'quiz': quiz_wrapper.edit_info(), 'round_types': dict(RoundType.choices) } # return context return render(request, 'quiz/create/quiz.html', context)
def post(self, request, quiz_id, round_id): ''' Edit the attributes of the round model Attributes: PARAMS: - quiz_id, round_id POST: - round_info ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) round_wrapper = get_round_or_404(quiz_wrapper.quiz, round_id) round_info = filter_round_info(request.POST) round_wrapper.edit(round_id, round_info) return redirect('quiz:edit-round', quiz_id=quiz_id, round_id=round_id)
def get(self, request, quiz_id, round_id): ''' Render the form to edit a round Attributes: None ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) round_wrapper = get_round_or_404(quiz_wrapper.quiz, round_id) context = { 'quiz': quiz_wrapper.edit_info(), 'round': round_wrapper.edit_info(), 'question_types': dict(QuestionType.choices) } return render(request, 'quiz/create/round.html', context)
def post(self, request, quiz_id): ''' Edit the attributes of the quiz model Attributes: PARAMS: - quiz_id POST: - quiz_info ''' quiz_wrapper = get_quiz_or_404(request.user, quiz_id) quiz_info = filter_quiz_info(request.POST) quiz_wrapper.edit(quiz_info) return redirect('quiz:edit-quiz', quiz_id=quiz_id)