From 74d6645d0387cce8af9a08f9fabb51073fadbd04 Mon Sep 17 00:00:00 2001 From: Arsenii Date: Tue, 7 Feb 2023 17:26:30 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D1=81=D0=BA=D1=80=D0=B0=D1=88?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=B5=D0=BC=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/config/Localization.json | 1 + data/config/config.jet | 117 ++++++++++++++++++++++------------ data_manager.py | 3 + ui_exam.py | 38 ++++++++++- 4 files changed, 116 insertions(+), 43 deletions(-) diff --git a/data/config/Localization.json b/data/config/Localization.json index 6f1198a..3528ab5 100644 --- a/data/config/Localization.json +++ b/data/config/Localization.json @@ -73,6 +73,7 @@ "TIMER_TEXT_TIME_EXPIRED": "Время вышло!", "TIMER_TEXT": "Оставшееся время: %s.", + "EXAM_TIMER_NOT_STARTED": "Таймер запустится, когда вы откроете любое задание.", "EXAM_GET_DESTINATION_ERROR": "Недопустимое расположение файла. Попробуйте ещё раз.", "EXAM_GET_FILE_ERROR": "Ошибка получения файла.", "EXAM_SUCCESS": "Файл успешно сохранён. Имя файла: %s", diff --git a/data/config/config.jet b/data/config/config.jet index ad0bc45..2ea6aa3 100644 --- a/data/config/config.jet +++ b/data/config/config.jet @@ -1,44 +1,77 @@ { - "POINTS": { - "0": "0", - "1": "7", - "2": "14", - "3": "20", - "4": "27", - "5": "34", - "6": "40", - "7": "43", - "8": "46", - "9": "48", - "10": "51", - "11": "54", - "12": "56", - "13": "59", - "14": "62", - "15": "64", - "16": "67", - "17": "70", - "18": "72", - "19": "75", - "20": "78", - "21": "80", - "22": "83", - "23": "85", - "24": "88", - "25": "90", - "26": "93", - "27": "95", - "28": "98", - "29": "100" - }, - "TIMER_TIME_IN_SECONDS": 14101, - "TIMER_FORMAT": "%s:%s:%s", - "build": "24", - "SIZE_PARAMETERS": - {"tiny": {"multiplier": 0.7, "font": 14, "font-family": "Semibold"}, - "default": {"multiplier": 1, "font": 18, "font-family": "Semibold"}, - "big": {"multiplier": 1.3, "font": 24, "font-family": "Regular"}, - "large": {"multiplier": 1.7, "font": 28, "font-family": "Regular"}, - "secret": {"multiplier": 2.5, "font": 70, "font-family": "Semibold"}}, - "EASTEREGG_TRIGGERS": "егор крид|кристина парфентьева" + "POINTS": { + "0": "0", + "1": "7", + "2": "14", + "3": "20", + "4": "27", + "5": "34", + "6": "40", + "7": "43", + "8": "46", + "9": "48", + "10": "51", + "11": "54", + "12": "56", + "13": "59", + "14": "62", + "15": "64", + "16": "67", + "17": "70", + "18": "72", + "19": "75", + "20": "78", + "21": "80", + "22": "83", + "23": "85", + "24": "88", + "25": "90", + "26": "93", + "27": "95", + "28": "98", + "29": "100" + }, + "TIMER_TIME_IN_SECONDS": 14101, + "TIMER_FORMAT": "%s:%s:%s", + "build": "27", + "SIZE_PARAMETERS": { + "tiny": { + "multiplier": 0.7, + "font": 14, + "font-family": "Semibold" + }, + "default": { + "multiplier": 1, + "font": 18, + "font-family": "Semibold" + }, + "big": { + "multiplier": 1.3, + "font": 24, + "font-family": "Regular" + }, + "large": { + "multiplier": 1.7, + "font": 28, + "font-family": "Regular" + }, + "secret": { + "multiplier": 2.5, + "font": 70, + "font-family": "Semibold" + } + }, + "EASTEREGG_TRIGGERS": "егор крид|кристина парфентьева", + "button_styles": { + "exam_in_progress": { + "current": "border: 4px solid #474747; border-radius: 7px; background-color: #3265b3; ", + "answered": "background-color: #99c5cf; ", + "skipped": "background-color: #e2f046; " + }, + "exam_finished": { + "current": "border: 4px solid #474747; border-radius: 7px; ", + "correct": "background-color: #3eab48; ", + "wrong": "background-color: #ab3b2c; " + } + } } \ No newline at end of file diff --git a/data_manager.py b/data_manager.py index 8af1e30..dc332b1 100644 --- a/data_manager.py +++ b/data_manager.py @@ -138,6 +138,9 @@ def checkIfNameNeedsToBeTriggered(name: str) -> bool: return True return False + def getButtonStyles() -> dict: + return Config.button_styles + class Email(object): def send_message(receiver_email: str) -> tuple: diff --git a/ui_exam.py b/ui_exam.py index 2477771..ca50131 100644 --- a/ui_exam.py +++ b/ui_exam.py @@ -109,6 +109,7 @@ def setupUi(self, BaseWindow): for button in self.buttons_list[1:]: self.nums_widget_layout.addWidget(button, self.placing_x, 0) self.placing_x = self.placing_x + 1 + self.buttons_style_list = [None] + ["transition-duration: 0.1s; " for _ in range(1, 28)] self.contents_nums.setLayout(self.nums_widget_layout) self.contents_tasks = QStackedWidget() @@ -123,10 +124,11 @@ def setupUi(self, BaseWindow): self.count = 0 self.timer.timeout.connect(self.timerAction) self.timer.start(1000) - self.timer_text_lbl = QLabel('Таймер запустится, когда вы откроете любое задание.') + self.timer_text_lbl = QLabel(Localization.EXAM_TIMER_NOT_STARTED) self.timer_isnt_started = True self.timer_has_ended = False self.var_saved = False + self.user_finished = False # 111111111 @@ -1195,7 +1197,10 @@ def task_27_get_file_b_button_clicked(): for key in self.widgets_list: self.contents_tasks.addWidget(self.widgets_list[key]) + self.opened_nums = [] def btn_clicked(button_num): + styles = Config.getButtonStyles() + self.opened_nums.append(button_num) try: if self.timer_isnt_started and not self.timer_has_ended: self.timerSetup() @@ -1210,11 +1215,33 @@ def btn_clicked(button_num): except: pass self.contents_tasks.setCurrentIndex(button_num) + self.style_key = "exam_in_progress" if not self.user_finished else "exam_finished" + self.buttons_style_list[button_num] += styles[self.style_key]["current"] + for n in range(1, 28): + if n != button_num: + self.buttons_style_list[n] = self.buttons_style_list[n].replace(styles[self.style_key]["current"], "") + if not self.user_finished: + for n in range(1, 28): + if self.user_answers[n] is None and n in self.opened_nums and n != button_num: + if not styles["exam_in_progress"]["skipped"] in self.buttons_style_list[n]: + self.buttons_style_list[n] += styles["exam_in_progress"]["skipped"] + if (not (self.user_answers[n] is None)) and n in self.opened_nums: + if styles["exam_in_progress"]["skipped"] in self.buttons_style_list[n]: + self.buttons_style_list[n] = self.buttons_style_list[n].replace(styles["exam_in_progress"]["skipped"], "") + if not styles["exam_in_progress"]["answered"] in self.buttons_style_list[n]: + self.buttons_style_list[n] += styles["exam_in_progress"]["answered"] + update_button_styles() except KeyError: pass def buttons_set(num): self.buttons_list[num].clicked.connect(lambda: btn_clicked(num)) + self.buttons_list[num].setStyleSheet(self.buttons_style_list[num]) + + def update_button_styles(): + for num in range(1, 28): + self.buttons_list[num].setStyleSheet(self.buttons_style_list[num]) + for num in range(1, 28): buttons_set(num) @@ -1311,6 +1338,15 @@ def finish(self): self.number_of_completed_tasks = self.user_results.count(True) self.result_text = Localization.RESULT % self.number_of_completed_tasks + self.button_styles = Config.getButtonStyles() + for task in range(1, 28): + if self.user_results[task]: + self.buttons_style_list[task] = "transition-duration: 0.1s; " + self.button_styles["exam_finished"]["correct"] + else: + self.buttons_style_list[task] = "transition-duration: 0.1s; " + self.button_styles["exam_finished"]["wrong"] + self.buttons_list[task].setStyleSheet(self.buttons_style_list[task]) + + self.first_points = 0 for ind in range(1, 28): if self.user_results[ind] and ind < 26: