Exemple #1
0
    def post(self, request, quiz_id, round_id, question_id, choice_id):
        '''
        Edit answer
        Attributes:
            PARAMS:
                - quiz_id
                - round_id
                - question_id
                - choice_id
            POST:
                - choice_info
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id,
                                               question_id)

        if not question_wrapper.question_class == QuestionClass.CHOICE_ANSWER:
            # TODO: Return exception
            pass

        question_wrapper.edit_choice(choice_id, request.POST.copy())

        return redirect('quiz:edit-question',
                        quiz_id=quiz_id,
                        round_id=round_id,
                        question_id=question_id)
Exemple #2
0
    def post(self, request, quiz_id, round_id, question_id, answer_id):
        '''
        Edit answer
        Attributes:
            PARAMS:
                - quiz_id
                - round_id
                - question_id
                - answer_id (unused)
            POST:
                - answer_info
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id,
                                               question_id)

        if question_wrapper.question.type == QuestionType.NORMAL:
            question_wrapper.edit_answer(request.POST.copy())
        else:
            # TODO: Return exception
            pass

        return redirect('quiz:edit-question',
                        quiz_id=quiz_id,
                        round_id=round_id,
                        question_id=question_id)
Exemple #3
0
    def post(self, request, quiz_id, round_id, question_id):
        '''
        Delete a question
        Attributes:
            PARAMS:
                - quiz_id, round_id, question_id
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id, question_id)

        question_wrapper.delete()

        return redirect('quiz:edit-round', quiz_id=quiz_id, round_id=round_id)
Exemple #4
0
    def post(self, request, quiz_id, round_id, question_id):
        '''
        Edit the attributes of the question model
        Attributes:
            PARAMS:
                - quiz_id, round_id, question_id
            POST:
                - question_info
        ''' 
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id, question_id)

        question_info = filter_question_info(request.POST.copy())

        question_wrapper.edit(question_info)

        return redirect('quiz:edit-question', quiz_id=quiz_id, round_id=round_id, question_id=question_id)
Exemple #5
0
    def post(self, request, quiz_id, round_id, question_id, slide_id):
        '''
        Edit a slide
        Attributes:
            PARAMS:
                - quiz_id
                - round_id
                - question_id
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id,
                                               question_id)

        question_wrapper.delete_slide(slide_id)

        return redirect('quiz:edit-question',
                        quiz_id=quiz_id,
                        round_id=round_id,
                        question_id=question_id)
Exemple #6
0
    def post(self, request, quiz_id, round_id, question_id):
        '''
        Create a slide
        Attributes:
            PARAMS:
                - quiz_id
                - round_id
                - question_id
            POST:
                - answer_info depending on question type
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id,
                                               question_id)

        question_wrapper.set_answer(request.POST.copy())

        return redirect('quiz:edit-question',
                        quiz_id=quiz_id,
                        round_id=round_id,
                        question_id=question_id)
Exemple #7
0
    def post(self, request, quiz_id, round_id, question_id):
        '''
        Create a slide
        Attributes:
            PARAMS:
                - quiz_id
                - round_id
                - question_id
            POST:
                - type
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id,
                                               question_id)

        question_wrapper.create_slide(request.POST.copy())

        return redirect('quiz:edit-question',
                        quiz_id=quiz_id,
                        round_id=round_id,
                        question_id=question_id)
Exemple #8
0
 def get(self, request, quiz_id, round_id, question_id):
     '''
     Render the form to edit a question
     Attributes:
         None
     '''
     question_wrapper = get_question_or_404(request.user, quiz_id, round_id, question_id)
     context = {
         'quiz_id': quiz_id,
         'round_id': round_id,
         'question_id': question_id,
         'question': question_wrapper.host_info(),
         'question_types': dict(QuestionType.choices),
         'slide_types': dict(SlideType.choices),
         'QuestionClass': QuestionClass,
         'QuestionType': QuestionType,
         'SlideType': SlideType,
     }
     # print(context)
     # return context
     return render(request, 'quiz/create/question.html', context)
Exemple #9
0
    def post(self, request, quiz_id, round_id, question_id, slide_id):
        '''
        Edit a slide
        Attributes:
            PARAMS:
                - quiz_id
                - round_id
                - question_id
            POST:
                - slide_info
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id,
                                               question_id)

        slide_info = request.POST.get('info', '')

        question_wrapper.edit_slide(slide_id, slide_info)

        return redirect('quiz:edit-question',
                        quiz_id=quiz_id,
                        round_id=round_id,
                        question_id=question_id)
Exemple #10
0
    def post(self, request, quiz_id, round_id, question_id, choice_id):
        '''
        Edit a slide
        Attributes:
            PARAMS:
                - quiz_id
                - round_id
                - question_id
                - choice_id
        '''
        question_wrapper = get_question_or_404(request.user, quiz_id, round_id,
                                               question_id)

        if not question_wrapper.question_class == QuestionClass.CHOICE_ANSWER:
            # TODO: Return exception
            pass

        question_wrapper.delete_choice(choice_id)

        return redirect('quiz:edit-question',
                        quiz_id=quiz_id,
                        round_id=round_id,
                        question_id=question_id)