Example #1
0
    def __init__(self, question):
        super().__init__(question)

        self.choices = Choice.objects.filter(question=self.question)
        self.choice_slides = [
            get_slide(choice.slide) for choice in self.choices
        ]
Example #2
0
    def __init__(self, question):
        self.question = question

        self.slides = [
            get_slide(qs.slide)
            for qs in QuestionSlide.objects.filter(question=self.question)
        ]
Example #3
0
    def __init__(self, question):
        assert question.type == QuestionType.NORMAL

        super().__init__(question)

        self.answer = NormalAnswer.objects.get(question=self.question)
        self.answer_slide = get_slide(self.answer.slide)
Example #4
0
    def __init__(self, question):
        assert question.type == QuestionType.NORMAL

        super().__init__(question)

        self.answer = NormalAnswer.objects.filter(question=self.question)
        if self.answer.exists():
            self.answer_slide = get_slide(self.answer[0].slide)
Example #5
0
    def __init__(self, question):
        assert question.type == QuestionType.ORDERING

        super.__init__(question)

        self.choices = Choice.objects.filter(question=self.question)
        self.choice_slides = [
            get_slide(choice.slide) for choice in self.choices
        ]

        self.answer = OrderAnswer.objects.get(question=self.question).order
Example #6
0
    def __init__(self, question):
        assert question.type == QuestionType.MCQ

        super().__init__(question)

        self.choices = Choice.objects.filter(question=self.question)
        self.choice_slides = [
            get_slide(choice.slide) for choice in self.choices
        ]

        self.answer = ChoiceAnswer.objects.get(
            question=self.question).choice.choice_number
Example #7
0
 def delete_slide(self, slide_id):
     slide = self.get_slide_or_404(slide_id)
     self.slide_qs.filter(slide_number__gt=slide.slide_number).update(
         slide_number=F('slide_number') - 1)
     get_slide(slide.slide).delete()
Example #8
0
 def edit_slide(self, slide_id, slide_info):
     slide = self.get_slide_or_404(slide_id).slide
     get_slide(slide).edit(slide_info)
Example #9
0
 def delete_choice(self, choice_id):
     choice = self.get_choice_or_404(choice_id)
     self.choices.filter(choice_number__gt=choice.choice_number).update(
         choice_number=F('choice_number') - 1)
     get_slide(choice.slide).delete()
Example #10
0
 def edit_choice(self, choice_id, choice_info):
     info = choice_info.get('info', '')
     get_slide(self.get_choice_or_404(choice_id).slide).edit(info)