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)
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)
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)
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)
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)
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)
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)
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)
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)
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)