def classwork(c_id, cw_id, page=0): return InlineKeyboardButton(Course.Classwork(c_id, cw_id).name, callback_data=dumps( dict(G='cw', c_id=c_id, cw_id=cw_id, page=page)))
def get_date(message): if message.text == '/exit': return_to_menu() elif re.fullmatch(r'\d{1,2}\s\d{1,2}\s\d{1,2}', message.text): in_date = message.text.split() cw_ = Course.Classwork(call.data['c_id'], call.data['cw_id']) try: date = datetime.date(2000 + int(in_date[0]), int(in_date[1]), int(in_date[2])).strftime('%d %b %Y') except ValueError: botHelper.send_mes( msgs[get_lang(call.message.chat.id)]['teacher'] ['management']['wrong_input'], message.messasge_id) bot.register_next_step_handler(message, get_date) else: cw_.date = date cw_.name = date return_to_menu() else: botHelper.send_mes( msgs[get_lang(call.message.chat.id)]['teacher']['management'] ['wrong_input'], message.messasge_id) bot.register_next_step_handler(message, get_date)
def new_class(call, lang): d = UI.to_dtime(time.time()) cw_id = Course.Classwork(call.data['c_id'], name=d, date=d).number for user in Course.Course(call.data['c_id']).participants: Course.Attendance(call.data['c_id'], cw_id, user.id).value = 0 back(call, True)
def user_attendance_list(users_list, c_id, cw_id): cw = Course.Classwork(c_id, cw_id) arr = [] for usr in users_list: arr.append( InlineKeyboardButton( usr.name + ' #' if cw.attendance(usr.id).value else usr.name, callback_data=dumps( dict(G='attend', u_id=usr.id, c_id=c_id, cw_id=cw_id)))) return arr
def del_class(call, lang): if call.message.chat.id == Course.Course(call.data['c_id']).owner.id: Course.Classwork(call.data['c_id'], call.data['cw_id']).delete() bot.answer_callback_query(call.id, msgs[lang]['callback']['class_deleted']) else: bot.answer_callback_query(call.id, msgs[lang]['callback']['class_not_exists'], show_alert=True) back(call, True, 2)
def user_attendance(users, course_id, class_id): arr = [] cw = Course.Classwork(course_id, class_id) for user in users: button = InlineKeyboardButton(User.User(user.id).name if cw.attendance( user.id).value else User.User(user.id).name + '*', callback_data=dumps( dict(type='sw_attend', id=course_id, id_u=user.id, id_cl=class_id))) arr.append(button) return arr