Esempio n. 1
0
    def check_answer(
        self, item
    ):  # todo перенести запрос задания на уровень выше для избежания повторений
        self.current_answer = item.text()
        query_get_answer = '''SELECT answer_object FROM answerbasemarktwo WHERE task_name=\'{}\' AND student_id={} 
        AND completion_date=\'{}\' AND mark_del = false'''.format(
            self.task_folder, self.student_folder, self.current_answer)
        answer_tup = sql_stuff.get_answer_as_teacher(query_get_answer)
        packed_answer = answer_tup[0][0]
        answer = pickle.loads(packed_answer)
        self.current_answer_highlighted_text = answer.highlighted_text

        query_get_task = '''SELECT task_object FROM taskbasemarktwo WHERE task_name=\'{}\' AND mark_del = false'''.format(
            self.task_folder)
        task_tup = sql_stuff.get_answer_as_teacher(query_get_task)
        packed_task = task_tup[0][0]
        task = pickle.loads(packed_task)

        correct, not_found, not_right = answer.answer_checker(task)

        self.ui.label_found_correct.setText('Найдено правильно {}'.format(
            len(correct)))
        self.ui.label_found_wrong.setText('Найдено неправильно {}'.format(
            len(not_right)))
        self.ui.label_not_found.setText('Не найдено {}'.format(len(not_found)))
        self.ui.label_total_figs_task.setText(
            'Всего оборотов в задании {}'.format(len(task.figuresList)))
        self.ui.label_total_figs_answer.setText(
            'Всего оборотов в ответе {}'.format(len(
                answer.answer_figures_list)))

        found_correct_text, found_wrong_text, not_found_text = '', '', ''
        for i in correct:
            found_correct_text += i.figure_type + ' || ' + \
                                  i.key_symbols_text + '\n'
        for i in not_right:
            found_wrong_text += i.figure_type + ' || ' + \
                                i.figure_text + '\n'
        for i in not_found:
            not_found_text += i.figure_type + ' || ' + \
                              i.key_symbols_text + '\n'
        self.ui.text_found_correct.setText(found_correct_text)
        self.ui.text_found_wrong.setText(found_wrong_text)
        self.ui.text_not_found.setText(not_found_text)
 def modify_task(self, item):
     task_name = item.text()
     query_get_task_objects = '''SELECT task_object FROM taskbasemarktwo 
     WHERE task_name=\'{}\' AND mark_del = false'''.format(task_name)
     task_tuple = sql_stuff.get_answer_as_teacher(query_get_task_objects)
     packed_task = task_tuple[0][0]
     task = pickle.loads(packed_task)
     edit_window = ModifyTaskForm(task,
                                  creator_id=self.creator_id,
                                  creator_name=self.creator_name)
     edit_window.exec()
Esempio n. 3
0
    def show_task_text(self):
        if not self.current_answer:
            return
        query_get_task = '''SELECT task_object FROM taskbasemarktwo 
        WHERE task_name=\'{}\' AND mark_del = false'''.format(self.task_folder)
        task_tup = sql_stuff.get_answer_as_teacher(query_get_task)
        packed_task = task_tup[0][0]
        task = pickle.loads(packed_task)
        task_text = task.highlighted_text

        self.task_text_windows.append(TextWindow(text=task_text))
        self.task_text_windows[-1].open()
Esempio n. 4
0
    def open_students_folder(self, item):
        self.student_folder = int(item.text().split()[-1])
        self.ui.list_of_answers.clear()

        query_get_answer_times = '''SELECT completion_date FROM answerbasemarktwo
        WHERE task_name=\'{}\' AND student_id={} AND mark_del = false 
        ORDER BY completion_date'''.format(self.task_folder,
                                           self.student_folder)
        times_tup = sql_stuff.get_answer_as_teacher(query_get_answer_times)

        for i in range(len(times_tup)):
            self.ui.list_of_answers.addItem(times_tup[i][0])
 def go_to_task_modification(self):
     self.ui.stackedWidget.setCurrentIndex(4)
     if self.user_rights == TEACHER_RIGHTS:
         query_get_task_names = '''SELECT task_name FROM taskbasemarktwo WHERE mark_del = false'''
     else:
         query_get_task_names = '''SELECT task_name FROM taskbasemarktwo 
         WHERE creator = {} AND mark_del = false'''.format(self.creator_id)
     task_names_tuple = sql_stuff.get_answer_as_teacher(
         query_get_task_names)
     self.ui.list_of_edited_tasks.clear()
     for i in task_names_tuple:
         self.ui.list_of_edited_tasks.addItem(i[0])
 def check_login_password(self):
     login = self.ui.login_input.text()
     password = self.ui.password_input.text()
     query_login_teacher = 'SELECT * FROM users'
     teachers = sql_stuff.get_answer_as_teacher(query_login_teacher)
     for i in range(len(teachers)):
         if teachers[i][1] == login and teachers[i][2] == password:
             self.creator_name = teachers[i][3]
             self.creator_id = teachers[i][0]
             self.user_rights = teachers[i][4]
             self.ui.stackedWidget.setCurrentIndex(1)
             break
         else:
             self.ui.label.setText('Неудача')  # todo более цивильный текст
Esempio n. 7
0
    def open_tasks_folder(self, item):  # здесь важна адресация по именам и id
        self.task_folder = item.text()
        self.ui.list_of_students.clear()

        query_get_student_names = '''SELECT DISTINCT student_id, student_name FROM answerbasemarktwo 
        WHERE task_name=\'{}\' AND mark_del = false
        ORDER BY student_name'''.format(self.task_folder)
        students_tup = sql_stuff.get_answer_as_teacher(query_get_student_names)
        # print(students_tup)
        student_strings = []
        for i in range(len(students_tup)):
            student_strings.append(students_tup[i][1] + ' || ' +
                                   str(students_tup[i][0]))
        for i in student_strings:
            self.ui.list_of_students.addItem(i)
Esempio n. 8
0
    def __init__(self):
        super().__init__()
        self.ui = Ui_check_answers_window()
        self.ui.setupUi(self)
        self.task_text_windows = []

        query_get_task_names = '''SELECT DISTINCT task_name FROM answerbasemarktwo 
        WHERE mark_del = false ORDER BY task_name'''
        tasks_tup = sql_stuff.get_answer_as_teacher(query_get_task_names)
        for i in range(len(tasks_tup)):
            self.ui.list_of_tasks.addItem(tasks_tup[i][0])

        self.task_folder = ''
        self.student_folder = ''
        self.current_answer = None
        self.current_answer_highlighted_text = None

        self.ui.list_of_tasks.itemClicked.connect(self.open_tasks_folder)
        self.ui.list_of_students.itemClicked.connect(self.open_students_folder)
        self.ui.list_of_answers.itemClicked.connect(self.check_answer)
        self.ui.button_show_task_text.clicked.connect(self.show_task_text)
        self.ui.button_show_answer_text.clicked.connect(self.show_answer_text)
        # self.ui.label.setText(task_name)
        self.ui.button_delete.clicked.connect(self.delete_task)
        self.ui.button_cancel.clicked.connect(self.cancel)

    def delete_task(self):
        query_deletion_task = '''UPDATE `taskbasemarktwo` 
        SET mark_del = true
        WHERE task_name=%s'''
        query_deletion_answers = """UPDATE answerbasemarktwo
        SET mark_del = true
        WHERE task_name=%s"""
        insert = (self.task_name, )
        sql_stuff.insert_as_teacher(query_deletion_task, insert)
        sql_stuff.insert_as_teacher(query_deletion_answers, insert)
        self.ui.label.setText('Удалено')

    def cancel(self):
        self.close()


if __name__ == '__main__':
    task_tup = sql_stuff.get_answer_as_teacher(
        '''SELECT task_object FROM taskbase WHERE task_name=\'Тест 1\'''')
    task_packed = task_tup[0][0]
    task1 = pickle.loads(task_packed)
    app = QtWidgets.QApplication([])
    application = ModifyTaskForm(task1)
    application.show()

    sys.exit(app.exec())
Esempio n. 10
0
import sql_stuff


query_get_tasks = """
SELECT task_name, creator_name, creator from taskbasemarktwo"""
tasks = sql_stuff.get_answer_as_teacher(query_get_tasks)
for task_name, student_name, stud_id in tasks:
    stud_split = student_name.split()
    if len(stud_split) == 3 and stud_id > 10 and stud_split[0] not in task_name:
        new_task_name = stud_split[0] + " " + stud_split[1][:1] + "." + stud_split[2][:1] + ". - " + task_name
        query_task = "UPDATE taskbasemarktwo set task_name = %s where task_name = %s"
        sql_stuff.insert_as_teacher(query_task, (new_task_name, task_name))
        query_answer = "UPDATE answerbasemarktwo set task_name = %s where task_name = %s"
        sql_stuff.insert_as_teacher(query_answer, (new_task_name, task_name))
        a = 5
a = 5