コード例 #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)
        await message.answer("Количество студентов на курсе:\n"+len(list_of_students))
    except:
        await message.answer('Что-то пошло не так...')
コード例 #4
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_marks = []
        for student in list_of_students:
            grades = get_my_grades(student[0], cid, 1)
            if len(grades) == 0:
                list_of_marks.append(0)
            else:
                list_of_marks.append(sum(grades)/len(grades))

        result = sum(list_of_marks)/len(list_of_marks)
        await message.answer("Средняя оценка по курсу: "+result)
    except:
        await message.answer('Что-то пошло не так...')
コード例 #5
0
async def answer_q1(message: types.Message, state: FSMContext):
    try:
        df2 = pd.read_excel(r"Оценки.xlsx")
        grades = []
        for i in df2['Оценка']:
            grades.append(i)
        cid = get_cid_by_tid(message.from_user.id)
        list_of_students = get_list_of_student_from_cours(cid)
        for i in range(0, len(list_of_students)):
            try:
                if math.isnan(grades[i]):
                    assign_grades(list_of_students[i][0], cid, 0)
                else:
                    assign_grades(list_of_students[i][0], cid, grades[i])
            except:
                pass
        await message.answer('Оценки выставлены!')
    except:
        await message.answer('Не удалось найти файл с оценками')
コード例 #6
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('Что-то пошло не так...')