def admin_page(): questions = get_all_questions() return render_template( 'admin_page.html', question_form=AddQuestionForm(), questions=get_all_questions(), active_tab='question' if request.args.get('active_tab') is None else request.args.get('active_tab'), last_order_number=len(questions))
def move_up_question(question_id=0): update_in_order_new_order_questions( toggle_postion_in_order(get_all_questions(), get_question_by_id(question_id), False)) return redirect( url_for('admin_page', active_tab='question') + '#question_{}'.format(question_id))
def delete_question(question_id=0): delete_question_by_id(question_id) update_in_order_new_order_questions( sort_question_by_order_number(get_all_questions())) return redirect( url_for('admin_page', active_tab='question') + '#question_{}'.format(question_id - 1))
def question_page(): user_id = uuid.uuid4( ) if request.args.get('id') is None else request.args.get('id') nxt_question, is_last_answer_correct = get_next_question_and_is_last_answer_correct( get_all_questions(), get_answers_by_user(str(user_id))) if nxt_question is not None: return render_template('question_page.html', question=nxt_question, form=AnswerForm(), id=user_id, is_last_answer_correct=is_last_answer_correct) else: return render_template('naming_page.html', form=NamingForm(), id=user_id)
def get_nxt_question_order_number(): return len(get_all_questions()) + 1