def create_question(self, request): """ Allows players to create questions. This function allows players to create questions. Returns: QuestionForm -- QuestionForm representation of the created question """ # Construct a question from the request question = Question(question=request.question, incorrect_answers=request.incorrect_answers, correct_answer=request.correct_answer) key = question.put() logger.debug("Question successfully created.") # If a game key has been provided, add the question to the game if request.urlsafe_game_key is not None: game = get_by_urlsafe(request.urlsafe_game_key, Game) game.questions.append(key) game.put() logger.debug("Question added to game.") # Return confirmation of question creation and/or added to a game return question.to_form()