Beispiel #1
0
def get_question(request):
    if (request.args and request.args.get("q-num")):
        q_num = request.args.get("q-num") or 0
    else:
        q_num = 1

    return model.get_question(q_num)
Beispiel #2
0
def get_next_qid(request):
    if (request.form and request.form["q_num"]):
        q_id = int(request.form["q_num"]) + 1
        next_q = model.get_question(q_id)
        if (next_q["q_num"]):
            print "found the next q"
            return q_id

    return 0
Beispiel #3
0
def check_and_set_next_ques(update: Update, context: CallbackContext, answer):
    chat_id = update.effective_chat.id
    current_ques = get_current_ques(chat_id)
    ques_pic, status = get_question(chat_id, current_ques)
    is_correct = check_answer(ques_pic, answer)
    if is_correct:
        set_ques_status_to_true(chat_id, current_ques)
    send_stick_ans(context, chat_id, is_correct)
    set_current_question(chat_id, current_ques + 1)
    bot_keyboards.continue_task_keyboard(update)
Beispiel #4
0
def question():
    if not is_admin():
        return 'login_fail'
    question_id = request.form['question_id']
    question = model.get_question(question_id)
    topic_id = question['topic_id']
    action = request.form['action']
    if action == 'delete':
        model.delete_question(question_id)
    return redirect('/admin/questions?topic_id=%(id)s' % {'id': topic_id})
Beispiel #5
0
def question():
    if not is_admin():
        return "login_fail"
    question_id = request.form["question_id"]
    question = model.get_question(question_id)
    topic_id = question["topic_id"]
    action = request.form["action"]
    if action == "delete":
        model.delete_question(question_id)
    return redirect("/admin/questions?topic_id=%(id)s" % {"id": topic_id})
Beispiel #6
0
 def GET(self):
     i = web.input()
     question_id = i["question_id"]
     print "question id is", question_id
     question = model.get_question(question_id)
     print "Question is", question
     topic_id = question["topic_id"]
     action = i.action
     if action == "delete":
         model.delete_question(question_id)
     raise web.seeother("questions?topic_id=%(id)s" % {"id": topic_id})
Beispiel #7
0
def start_task_one(update: Update, context: CallbackContext):
    chat_id = update.effective_chat.id
    if not ready_tasks(chat_id):
        context.bot.send_message(chat_id=chat_id, text=f"No task set for you yet!")
    else:
        logger.info(f"> child chat #{chat_id} starting task 1")
        set_task_start_to_true(chat_id)
        level = get_task_level(chat_id)
        context.bot.send_message(chat_id=chat_id, text=f"You are solving Math - level {level}.\n Good luck!!!")
        amount_questions = NUMBER_Q_IN_TASK
        ques_pic, status = get_question(chat_id, 1)
        context.bot.send_photo(chat_id=chat_id, photo=open(ques_pic, 'rb'),
                               caption=f"Question #1/{amount_questions}")
        bot_keyboards.continue_task_keyboard(update)
Beispiel #8
0
def next_task(update: Update, context: CallbackContext):
    chat_id = update.effective_chat.id
    current_ques = get_current_ques(chat_id)
    if current_ques == NUMBER_Q_IN_TASK + 1:
        set_task_status_true(chat_id)
        set_current_question(chat_id, 0)
        send_gif_end_task(context, chat_id)
        bot_keyboards.main_child_keyboard(update, chat_id, context)
    else:
        set_task_start_to_true(chat_id)
        ques_pic, status = get_question(chat_id, current_ques)
        context.bot.send_photo(chat_id=chat_id, photo=open(ques_pic, 'rb'),
                               caption=f"Question #{current_ques}/{NUMBER_Q_IN_TASK}")
        bot_keyboards.continue_task_keyboard(update)