def show_student_analytics_window(self):
     group = Group()
     ls_name = group.show_name(self.session)
     self.choice_group_ui.comboBox.clear()
     self.choice_group_ui.comboBox.addItems(ls_name)
     self.choice_analytics_window.hide()
     self.choice_group_ui.update(self.dark_theme)
     self.choice_group_window.show()
    def show_analytics_window(self):
        group = Group()
        ls_name = group.show_name(self.session)

        discipline = Discipline
        d_name = discipline.show_name(self.session)
        self.choice_discipline_ui.comboBox.clear()
        self.choice_discipline_ui.comboBox.addItems(d_name)

        self.choice_discipline_window.show()
        self.choice_discipline_ui.update(self.dark_theme)
        self.choice_analytics_window.hide()
Пример #3
0
    def show_grade_window(self):
        group = Group()
        ls_name = group.show_name(self.session)
        self.grade_ui.comboBox_2.clear()
        self.grade_ui.comboBox_2.addItems(ls_name)

        discipline = Discipline
        d_name = discipline.show_name(self.session)
        self.grade_ui.comboBox.clear()
        self.grade_ui.comboBox.addItems(d_name)

        self.grade_ui.update(self.dark_theme)
        self.grade_window.show()
Пример #4
0
    def delete(self):
        items = self.tableWidget.selectedItems()
        for i in items:
            row = self.tableWidget.row(i)
            number = self.tableWidget.item(row, 1).text()

            group = Group()
            group.delete(self.session, number)

            self.tableWidget.removeRow(row)
            self.combo.clear()
            ls_name = group.show_name(self.session)
            self.combo.addItems(ls_name)
    def next_page(self):
        choice = self.comboBox.currentText()

        if choice == 'По группам':
            self.choice_discipline_group_ui.discipline = self.discipline
            self.choice_discipline_group_ui.update(self.dark_theme)
            self.choice_discipline_group_window.show()
        else:
            group = Group()
            ls_name = group.show_name(self.session)
            self.choice_discipline_student_group_ui.comboBox.clear()
            self.choice_discipline_student_group_ui.comboBox.addItems(ls_name)
            self.choice_discipline_student_group_ui.discipline = self.discipline
            self.choice_discipline_student_group_ui.update(self.dark_theme)
            self.choice_discipline_student_group_window.show()

        self.choice_discipline_group_or_student_window.hide()
Пример #6
0
def parser_moodle(address, login, password, session) -> int:
    # address = 'https://cp29191-wordpress-8.tw1.ru'
    # login = "******"
    # password = "******"

    login_address = address + "/login/index.php"

    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--ignore-certificate-errors")

    driver = webdriver.Chrome(ChromeDriverManager().install(),
                              chrome_options=chrome_options)

    try:
        driver.get(login_address)
        username = driver.find_element_by_id('username')
        username.click()
        username.send_keys(login)
        password_ = driver.find_element_by_id("password")
        password_.click()
        password_.send_keys(password)
        submit = driver.find_element_by_id("loginbtn")
        submit.click()
        time.sleep(1)

        number_course = 0

        while number_course != -1:
            courses = driver.find_elements_by_class_name(
                'list-group-item-action')
            flag = 0
            this_number_course = 0
            flag_number_course = 0
            for course in courses:
                if flag == 1 and this_number_course == number_course:

                    # Синхронизация дисциплин
                    c = course
                    c.click()
                    title = driver.title
                    name_course = title.split('Курс: ')[1]
                    d = Discipline()
                    discipline = d.all(session)

                    flag_d = 0
                    for d in discipline:
                        if d.name == name_course:
                            flag_d = 1
                            break
                    if not flag_d:
                        d.add(session, discipline)
                    driver.find_element_by_partial_link_text(
                        "Участники").click()
                    time.sleep(5)

                    # Синхронизация групп и студентов
                    i = 0
                    flag_e = 0
                    id_template = "user-index-participants-4_r"
                    while flag_e == 0:
                        try:
                            id = id_template + str(i)
                            tr = driver.find_element_by_id(id)
                            i += 1
                            name = tr.find_elements_by_class_name('c1')
                            name = name[0].text
                            role = tr.find_elements_by_class_name('c3')
                            role = role[0].text
                            group = tr.find_elements_by_class_name('c4')
                            group = group[0].text
                            if role == 'Студент':
                                g = Group()
                                g_names = g.show_name(session)
                                g_flag = 0
                                for g_name in g_names:
                                    if g_name == group:
                                        g_flag = 1
                                        break
                                if g_flag == 0:
                                    g.add(session, group,
                                          'Информационная безопасность')

                                s = Student()
                                s_names = s.all(session, group)
                                s_flag = 0
                                for s_name in s_names:
                                    if s_name == name:
                                        s_flag = 1
                                        break
                                if s_flag == 0:
                                    record_book = randint(100000, 999999)
                                    s.add(session, name, record_book, group)
                        except:
                            flag_e = 1
                    driver.back()
                    time.sleep(3)
                    driver.back()
                    time.sleep(3)
                    number_course += 1
                    flag_number_course = 1
                    break

                elif flag == 1:
                    this_number_course += 1
                if course.text == "Личные файлы":
                    flag = 1
            if flag_number_course == 0:
                number_course = -1

        driver.close()
        return 0

    except:
        driver.close()
        return 1
Пример #7
0
 def show_group_choice_window(self):
     group = Group()
     ls_name = group.show_name(self.session)
     self.group_choice_ui.comboBox.addItems(ls_name)
     self.group_choice_ui.update(self.dark_theme)
     self.group_choice_window.show()