コード例 #1
0
async def enter_test(message: types.Message):
    try:
        cid = get_cid_by_tid(message.from_user.id)
        list_of_students = get_list_of_student_from_cours(cid)
        grades = []
        students_surnames = []
        students_idcards = []
        students_groups = []
        for i in list_of_students:
            g = []
            student = get_info_about_me(i[0])[0]
            students_surnames.append(student[2])
            students_idcards.append(student[3])
            students_groups.append(student[4])
            for j in get_my_grades(i[0], cid, 1):
                g.append(j[3])
            grades.append(g)
        lens = []
        for i in grades:
            lens.append(len(i))
        max_len = max(lens)
        for j in grades:
            if len(j) < max_len:
                while len(j) < max_len:
                    j.insert(0, 0)
        a = np.array(grades)
        df_grades = pd.DataFrame(a)
        df = pd.DataFrame(
            {'Фамилия': students_surnames, 'Номер студенческого': students_idcards, 'Группа': students_groups})
        answer = pd.merge(df, df_grades, left_index=True, right_index=True)
        answer.to_excel(r"Журнал.xlsx")
        await message.answer
    except:
        await message.answer('Что-то пошло не так....')
コード例 #2
0
async def enter_test(message: types.Message):
    try:
        cid = get_cid_by_tid(message.from_user.id)
        list_of_students = get_list_of_student_from_cours(cid)
        list_of_surnames = []
        list_of_idcards = []
        list_of_groupnumbers = []
        list_of_grades = []
        for i in list_of_students:
            a = get_info_about_me(i[0])[0]
            list_of_surnames.append(a[2])
            list_of_idcards.append(a[3])
            list_of_groupnumbers.append(a[4])
            list_of_grades.append('')
        df = pd.DataFrame({
            'Фамилия': list_of_surnames,
            'Номер студенческого': list_of_idcards,
            'Группа': list_of_groupnumbers,
            'Оценка': list_of_grades
        })
        df.to_excel(r"Оценки.xlsx")
        await message.answer(
            "В папку проекта сохранен Excel файл 'Оценки', откройте его и выставите оценки, "
            "после сохраните "
            "изменения и вызовите команду '/assigngrades'")
    except:
        await message.answer('Что-то пошло не так...')
コード例 #3
0
async def enter_test(message: types.Message):
    try:
        cid = get_cid_by_tid(message.from_user.id)
        list_of_students = get_list_of_student_from_cours(cid)
        list_of_student_marks = []
        for student in list_of_students:
            grades = get_my_grades(student[0], cid, 1)
            if len(grades) == 0:
                list_of_student_marks.append((student[0], 0))
            else:
                list_of_student_marks.append((student[0], sum(grades) / len(grades)))

        top5 = sorted(list_of_student_marks, key=lambda res: res[1])
        result = ""
        for res in top5:
            info = get_info_about_me(res[0])[0]
            result = result + f"{info[1]} {info[2]} : {res[1]}\n"
        await message.answer("Топ 5 студентов п ооценкам:\n"+result)
    except:
        await message.answer('Что-то пошло не так...')
コード例 #4
0
async def answer_q1(message: types.Message, state: FSMContext):
    try:
        answer = message.text
        cid = get_cid_by_name(answer)
        list_of_students = get_list_of_student_from_cours(cid)
        list_of_student_marks = []
        for student in list_of_students:
            grades = [i[3] for i in get_my_grades(student[0], cid, 1)]
            if len(grades) == 0:
                list_of_student_marks.append((student[0], 0))
            else:
                list_of_student_marks.append(
                    (student[0], sum(grades) / len(grades)))
        top5 = sorted(list_of_student_marks,
                      key=lambda res: res[1],
                      reverse=True)[:5]
        result = ""
        for res in top5:
            info = get_info_about_me(res[0])[0]
            result = result + f"{info[1]} {info[2]} : {res[1]}\n"
        await message.answer("Топ 5 студентов по оценкам:\n" + result)
    except:
        await message.answer('Что-то пошло не так...')
    await state.finish()
コード例 #5
0
async def enter_test(message: types.Message):
    info = get_info_about_me(message.from_user.id)[0]
    await message.answer("{student[0]!r} {student[1]!r}\nНомер студенческого: {student[2]!r}\n" \
                         "Группа: {student[3]!r}".format(student=[info[1], info[2], info[3], info[4]]).replace("'", ''))