def task(c_id, t_id, page=0): return InlineKeyboardButton(Course.Task(c_id, t_id).name, callback_data=dumps( dict(G='task', c_id=c_id, t_id=t_id, page=page)))
def st_tsk(call, lang): task_ = Course.Task(call.data['c_id'], call.data['t_id']) text = msgs[lang]['student']['student_task'].format( name=task_.name, desc=task_.description, mark=task_.mark(call.message.chat.id).value, hmark=int(task_.highest_mark)) botHelper.edit_mes(text, call, markup=mkp.create(lang))
def del_task(call, lang): if call.message.chat.id == Course.Course(call.data['c_id']).owner.id: Course.Task(call.data['c_id'], call.data['t_id']).delete() bot.answer_callback_query(call.id, msgs[lang]['callback']['task_deleted']) else: bot.answer_callback_query(call.id, msgs[lang]['callback']['task_not_exists'], show_alert=True) back(call, True, 2)
def task(id_tasks, id_course, back_page=0): arr = [] students = Course.Course(id_course).participants for i in id_tasks: star = '' for student in students: if Course.Task(id_course, i).mark(student.id).value is None: star = '*' break button = InlineKeyboardButton(Course.Task(id_course, i).name + star, callback_data=dumps( dict(type='task', id=id_course, id_t=i, page=back_page))) arr.append(button) return arr
def create(): name = task_info['name'] if not name: name = msgs[lang]['teacher']['task_create']['name'] + str( len(Course.Course(call.data['c_id']).tasks) + 1) Course.Task(course_id=call.data['c_id'], name=name, description=task_info['desc'].format(task_info['hmark']), highest_mark=task_info['hmark']) botHelper.send_mes(msgs[lang]['teacher']['task_create']['created'], call.message.chat.id) return_to_menu()
def user_mark(id_u, id_c, id_t): task = Course.Task(id_c, id_t) arr = [] for i in id_u: name = User.User(i).name if task.mark( i).value is not None else User.User(i).name + '*' button = InlineKeyboardButton(name, callback_data=dumps( dict(type='mark_u_o', id=id_c, id_u=i, id_t=id_t))) arr.append(button) return arr
def task(id_tasks, id_course, id_user, back_page=0): arr = [] for i in id_tasks: task = Course.Task(id_course, i) button = InlineKeyboardButton('{} {}/{}'.format( task.name, task.mark(id_user).value, task.highest_mark), callback_data=dumps( dict(type='task_u', id=id_course, id_t=i, page=back_page))) arr.append(button) return arr
def do_tsk(call): def return_to_menu(): new_mes = botHelper.send_mes('empty', call.message.chat.id) botHelper.renew_menu(call, new_mes) back(call, True) def get_mark(message): if message.text == '/exit': return_to_menu() elif message.text == '-1': mark.value = None elif re.fullmatch(r'\d+', message.text): if int(message.text) <= task_.highest_mark: mark.value = int(message.text) return_to_menu() else: botHelper.send_mes(msgs[get_lang(call.message.chat.id)] ['teacher']['management']['error_mark']) bot.register_next_step_handler(message, get_mark) else: botHelper.send_mes(msgs[get_lang( call.message.chat.id)]['teacher']['management']['wrong_input']) bot.register_next_step_handler(message, get_mark) call.data = json.loads(call.data) task_ = Course.Task(call.data['c_id'], call.data['t_id']) mark = Course.Mark(call.data['c_id'], call.data['t_id'], call.data['u_id']) text = msgs['mark_one'].format(task=task_.name, user=User.User(call.data['u_id']).name, mark=mark.value, max=task_.highest_mark) botHelper.edit_mes(text, call) bot.register_next_step_handler(call.message, get_mark)