def add_question(): if not current_user.is_admin(): # permission deny return redirect(url_for("permission_deny")) error = "" # else: the admin has logged_in if request.method == "POST": quest = Question() # get the question set # grap the user input question = request.form["question"] answers = request.form["answers"].split("/") pool_id = request.form["pool_id"] q_type = request.form["type"] try: quest.add_q(question, pool_id, q_type, answers=answers) except TypeError as e: error = format(e) else: return render_template("success_add_q.html") # invalid input, push back what user has been input, and push the error message return render_template("add_q.html",\ msg_err = error,question = question, \ answers = request.form["answers"]) return render_template("add_q.html")