Exemple #1
0
 def set_answer(self, answer_info):
     if self.answer.exists():
         # TODO: Return exception
         pass
     answer_slide = create_slide(answer_info)
     answer = NormalAnswer.objects.create(question=self.question,
                                          slide=answer_slide)
Exemple #2
0
    def edit(self, question_info):
        super().edit(question_info)

        self.answer_slide.delete()

        answer_slide = create_slide(question_info.answer)
        NormalAnswer.objects.create(question=self.question, slide=answer_slide)
Exemple #3
0
    def create(question_info):
        question = BaseQuestion.create(question_info)

        answer_slide = create_slide(question_info.answer)
        answer = NormalAnswer.objects.create(question=question,
                                             slide=answer_slide)

        return question
Exemple #4
0
    def create(question_info):
        question = Question.objects.create(**question_info.question)

        slides = [create_slide(slide) for slide in question_info.slides]
        for i, slide in enumerate(slides):
            QuestionSlide.objects.create(question=question,
                                         slide=slide,
                                         slide_number=i)

        return question
Exemple #5
0
    def edit(self, question_info):
        self.question.__dict__.update(question_info.question)
        self.question.save()

        QuestionSlide.objects.filter(question=self.question).delete()
        for slide in self.slides:
            slide.delete()

        slides = [create_slide(slide) for slide in question_info.slides]
        for i, slide in enumerate(slides):
            QuestionSlide.objects.create(question=self.question,
                                         slide=slide,
                                         slide_number=i)
Exemple #6
0
    def create(question_info):
        question = BaseQuestion.create(question_info)

        choice_slides = [
            create_slide(slide) for slide in question_info.choices
        ]
        for i, slide in enumerate(choice_slides):
            choice = Choice.objects.create(question=question,
                                           slide=slide,
                                           choice_number=i)
            if i == question_info.answer:
                ChoiceAnswer.objects.create(question=question, choice=choice)

        return question
Exemple #7
0
    def edit(self, question_info):
        super().edit(question_info)

        for slide in self.choice_slides:
            slide.delete()

        choice_slides = [
            create_slide(slide) for slide in question_info.choices
        ]
        for i, slide in enumerate(choice_slides):
            choice = Choice.objects.create(question=question,
                                           slide=slide,
                                           choice_number=i)
            if i == question_info.answer:
                ChoiceAnswer.objects.create(question=question, choice=choice)
Exemple #8
0
    def edit(self, question_info):
        super().edit(question_info)

        OrderAnswer.objects.get(question=self.question).delete()
        for slide in self.choice_slides:
            slide.delete()

        choice_slides = [
            create_slide(slide) for slide in question_info.choices
        ]
        for i, slide in enumerate(choice_slides):
            choice = Choice.objects.create(question=question,
                                           slide=slide,
                                           choice_number=i)

        OrderAnswer.objects.create(question=question,
                                   order=question_info.order)
Exemple #9
0
 def create_slide(self, slide_info):
     slide = create_slide(slide_info)
     slide_number = self.slide_qs.count() + 1
     QuestionSlide.objects.create(question=self.question,
                                  slide=slide,
                                  slide_number=slide_number)
Exemple #10
0
 def add_choice(self, choice_info):
     choice_slide = create_slide(choice_info)
     choice_number = self.choices.count() + 1
     Choice.objects.create(question=self.question,
                           slide=choice_slide,
                           choice_number=choice_number)