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 ]
def __init__(self, question): self.question = question self.slides = [ get_slide(qs.slide) for qs in QuestionSlide.objects.filter(question=self.question) ]
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)
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)
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
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
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()
def edit_slide(self, slide_id, slide_info): slide = self.get_slide_or_404(slide_id).slide get_slide(slide).edit(slide_info)
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()
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)