def show_question(topic_name, box): if 'username' not in login_session: return no_login() elif has_access(): # change status for last question if request.method == 'POST': topic = get_one_topic_by_name(topic_name) status = get_status_for_box(topic, box).first() if 'correct' in request.form: f = int(box) + 1 elif 'wrong' in request.form: f = 0 update_status(status.id, f) # get new question topic = get_one_topic_by_name(topic_name) status = get_status_for_box(topic, box).first() if not status: update_status_0_to_1_and_6_to_5() return redirect(url_for('main.boxes', topic_name=topic.name)) else: return render_template('showQuestion.html', topic=topic, question=status.question, box=box) else: return no_access()
def reset_questions(topic_name, box): if 'username' not in login_session: return no_login() elif has_access(): topic = get_one_topic_by_name(topic_name) status = get_status_for_box(topic, box).all() update_status_to_1(status) return redirect(url_for('main.boxes', topic_name=topic_name)) else: return no_access()
def show_question_list(topic_name): if 'username' not in login_session: return no_login() elif has_access(): topic = get_one_topic_by_name(topic_name) status = get_status_for_topic(topic).all() return render_template('showQuestionList.html', status=status, topic_name=topic_name) else: return no_access()
def show_answer(topic_name, box): if 'username' not in login_session: return no_login() elif has_access(): topic = get_one_topic_by_name(topic_name) status = get_status_for_box(topic, box).first() return render_template('showAnswer.html', topic=topic, question=status.question, box=box) else: return no_access()
def boxes(topic_name): if 'username' not in login_session: return no_login() elif has_access(): topic = get_one_topic_by_name(topic_name) if exits_wrong_status(topic): update_status_0_to_1_and_6_to_5() status_of_topic = get_status_for_topic(topic) if status_of_topic.count() == 0: boxes = (create_status(topic_name), 0, 0, 0, 0) else: boxes = create_boxes(status_of_topic) return render_template('showBoxes.html', topic_name=topic_name, boxes=boxes) else: return no_access()