QuizFlask/run.py
def ask_question(id):
    '''get the specific question and put it on the page'''
    cursor = get_db().cursor()
    sql = "SELECT id,question,answer FROM questions WHERE id=?"
    cursor.execute(sql,(id,))
    entry = cursor.fetchone()
    if request.method == "POST":
        '''we posted- check answer and flash message'''
        actual_answer = entry['answer']
        user_answer = request.form.get("answer")
        if user_answer.lower() == actual_answer.lower():
            flash("Correct")
        else:
            flash("Incorrect")

    return render_template("ask_question.html",entry=entry)
get the specific question and put it on the page
get the specific question and put it on the page
get the specific question and put it on the page
def ask_question(id):
    cursor = get_db().cursor()
    sql = "SELECT id,question,answer FROM questions WHERE id=?"
    cursor.execute(sql,(id,))
    entry = cursor.fetchone()
    if request.method == "POST":
        actual_answer = entry['answer']
        user_answer = request.form.get("answer")
        if user_answer.lower() == actual_answer.lower():
            flash("Correct")
        else:
            flash("Incorrect")
    return render_template("ask_question.html",entry=entry)
def ask_question ( id ) : cursor = get_db ( ) . cursor ( ) sql = "SELECT id,question,answer FROM questions WHERE id=?" cursor . execute ( sql , ( id , ) ) entry = cursor . fetchone ( ) if request . method == "POST" : '''we posted- check answer and flash message''' actual_answer = entry [ 'answer' ] user_answer = request . form . get ( "answer" ) if user_answer . lower ( ) == actual_answer . lower ( ) : flash ( "Correct" ) else : flash ( "Incorrect" ) return render_template ( "ask_question.html" , entry = entry )
get the specific question and put it on the page
get the specific question and put it on the page
'''get the specific question and put it on the page''' '''we posted- check answer and flash message'''
id