QuizFlaskAlchemy/run.py
def ask_question(id):
    '''ask the specific question passed by the parameter'''
    question_to_ask = Question.query.filter_by(id=id).first()
    '''check if we posted an answer and display the correct question and a flash to show correct/wrong'''
    if request.method == 'POST':
        #we posted, check answer
        user_answer = request.form.get("answer")
        actual_answer = question_to_ask.answer
        if user_answer.lower() == actual_answer.lower():
            flash("You are correct!")
        else:
            flash("Sorry, you got it wrong :(")
    return render_template("ask_question.html",entry=question_to_ask)
ask the specific question passed by the parameter
ask the specific question passed by the parameter
ask the specific question passed by the parameter
def ask_question(id):
    question_to_ask = Question.query.filter_by(id=id).first()
    if request.method == 'POST':
        user_answer = request.form.get("answer")
        actual_answer = question_to_ask.answer
        if user_answer.lower() == actual_answer.lower():
            flash("You are correct!")
        else:
            flash("Sorry, you got it wrong :(")
    return render_template("ask_question.html",entry=question_to_ask)
def ask_question ( id ) : question_to_ask = Question . query . filter_by ( id = id ) . first ( ) '''check if we posted an answer and display the correct question and a flash to show correct/wrong''' if request . method == 'POST' : user_answer = request . form . get ( "answer" ) actual_answer = question_to_ask . answer if user_answer . lower ( ) == actual_answer . lower ( ) : flash ( "You are correct!" ) else : flash ( "Sorry, you got it wrong :(" ) return render_template ( "ask_question.html" , entry = question_to_ask )
ask the specific question passed by the parameter
ask the specific question passed by the parameter
'''ask the specific question passed by the parameter''' '''check if we posted an answer and display the correct question and a flash to show correct/wrong''' #we posted, check answer
id