def handle_classroom_assessments_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) student = Student.get(call.message.chat.id) classroom = Classroom.get(data['classroom_id']) classroom_assessments_view(student, classroom) classroom_detail_view(student, classroom)
def handle_classroom_link_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) teacher = Teacher.get(call.message.chat.id) classroom = Classroom.get(data['classroom_id']) classroom_link_view(teacher, classroom) classroom_detail_view(teacher, classroom)
def handle_classroom_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) classroom = Classroom.get(data['classroom_id']) teacher = Teacher.get(call.message.chat.id) delete_classroom_scenario.are_you_sure_request(call.message, teacher, classroom)
def handle_submissions_reviewed_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) teacher = Teacher.get(call.message.chat.id) task = Task.get(data['task_id']) task_assessments_view(teacher, task) task_detail_view(teacher, task)
def handle_task_messages_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) user = Teacher.get(call.message.chat.id) or Student.get( call.message.chat.id) task = Task.get(data['task_id']) task_message_list_view(user, task) task_detail_view(user, task)
def cancel_handler(bot_instance, message): # прерывать выполнение задания if message.text == '/cancel': chat_id = message.chat.id if chat_id in sessions: sess = sessions[chat_id] # если такой чат-ид существует bot.clear_step_handler_by_chat_id(chat_id) # отменяет message.chat.id = -1000 # so that it never gets to other handlers - doesnt ex sess.choose_task()
def handle_submission_message_list_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) user = Teacher.get(call.message.chat.id) or Student.get( call.message.chat.id) submission = Submission.get(data['submission_id']) task = Task.get(submission.task_id) submission_message_list_view(user, submission, task) task_detail_view(user, task)
def handle_submission_review_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) user = Teacher.get(call.message.chat.id) or Student.get( call.message.chat.id) submission = Submission.get(data['submission_id']) task = Task.get(submission.task_id) submission_message_list_view(user, submission, task) review_submission_scenario.submission_comment_request( call.message, data['submission_id'])
def handle_new_submission_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) student = Student.get(call.message.chat.id) submission = Submission(data['task_id'], student.id, status=SubmissionStatus.DRAFT.value, created_utc=datetime.now(timezone.utc)).save() ru_text = "Отправьте мне выполненное задание в любом формате: " \ "текст, фото, видео, файлы или аудиосообщения; одним или несколькими сообщениями." en_text = "Send me the submission in any format: " \ "text, photo, video, files or audio messages; one or more messages." text = ru_text if student.language_code == 'ru' else en_text bot.send_message(call.message.chat.id, text, parse_mode='Markdown') bot.register_next_step_handler( call.message, create_submission_scenario.compose_submission, submission)
def handle_new_classroom_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) create_classroom_scenario.classroom_name_request(call.message)
def handle_new_task_query(call): bot.clear_step_handler_by_chat_id(call.message.chat.id) data = get_call_data(call) create_task_scenario.task_name_request(call.message, data['classroom_id'])