Example #1
0
    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)
Example #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)
Example #3
0
    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')
Example #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)
Example #5
0
    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)
Example #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)
Example #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)
Example #8
0
    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)