コード例 #1
0
ファイル: host.py プロジェクト: AananthV/Quizwin
    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)
コード例 #2
0
 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)
コード例 #3
0
ファイル: quiz.py プロジェクト: Pavi114/Quizwin
    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')
コード例 #4
0
    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)
コード例 #5
0
ファイル: quiz.py プロジェクト: Pavi114/Quizwin
    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)
コード例 #6
0
 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)
コード例 #7
0
    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)
コード例 #8
0
ファイル: quiz.py プロジェクト: Pavi114/Quizwin
    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)