|
|
@@ -0,0 +1,97 @@
|
|
|
+import tkinter as tk
|
|
|
+from tkinter import messagebox
|
|
|
+
|
|
|
+class QuizApp:
|
|
|
+ def __init__(self, root):
|
|
|
+ self.root = root
|
|
|
+ self.root.title("Модели построения информационных систем")
|
|
|
+ self.questions = [
|
|
|
+ {
|
|
|
+ 'question': 'Какая из моделей описывает структуру данных в информационной системе?',
|
|
|
+ 'options': ['Модель процессов', 'Модель данных', 'Модель взаимодействия', 'Модель организационной структуры'],
|
|
|
+ 'correct_option': 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'question': 'Классическая модель, которая отображает процессы и их последовательность — это...',
|
|
|
+ 'options': ['Модель данных', 'Модель процессов', 'Модель взаимодействия', 'Модель организационной структуры'],
|
|
|
+ 'correct_option': 1
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ self.current_q_index = 0
|
|
|
+ self.correct_answers = 0
|
|
|
+
|
|
|
+ self.create_scene1()
|
|
|
+
|
|
|
+ def clear_screen(self):
|
|
|
+ for widget in self.root.winfo_children():
|
|
|
+ widget.destroy()
|
|
|
+
|
|
|
+ def create_scene1(self):
|
|
|
+ self.clear_screen()
|
|
|
+ tk.Label(self.root, text="Добро пожаловать в игру: 'Модели построения информационных систем'!", font=('Arial', 16)).pack(pady=20)
|
|
|
+ start_button = tk.Button(self.root, text="Начать игру", command=self.scene2)
|
|
|
+ start_button.pack(pady=20)
|
|
|
+
|
|
|
+ def scene2(self):
|
|
|
+ self.clear_screen()
|
|
|
+ if self.current_q_index >= len(self.questions):
|
|
|
+ self.show_results()
|
|
|
+ return
|
|
|
+ q = self.questions[self.current_q_index]
|
|
|
+ tk.Label(self.root, text=f"Вопрос {self.current_q_index + 1}:", font=('Arial', 14)).pack(pady=10)
|
|
|
+ tk.Label(self.root, text=q['question'], wraplength=600).pack(pady=10)
|
|
|
+
|
|
|
+ self.var = tk.IntVar()
|
|
|
+ for idx, option in enumerate(q['options']):
|
|
|
+ rb = tk.Radiobutton(self.root, text=option, variable=self.var, value=idx+1, font=('Arial', 12))
|
|
|
+ rb.pack(anchor='w')
|
|
|
+
|
|
|
+ next_button = tk.Button(self.root, text="Ответить", command=self.check_answer)
|
|
|
+ next_button.pack(pady=10)
|
|
|
+
|
|
|
+ def check_answer(self):
|
|
|
+ selected = self.var.get()
|
|
|
+ correct = self.questions[self.current_q_index]['correct_option']
|
|
|
+ is_correct = (selected == correct)
|
|
|
+ if is_correct:
|
|
|
+ self.correct_answers += 1
|
|
|
+ self.show_feedback(is_correct)
|
|
|
+
|
|
|
+ def show_feedback(self, is_correct):
|
|
|
+ self.clear_screen()
|
|
|
+ if is_correct:
|
|
|
+ msg = "Правильно! Молодец."
|
|
|
+ else:
|
|
|
+ correct_option_idx = self.questions[self.current_q_index]['correct_option']
|
|
|
+ correct_answer = self.questions[self.current_q_index]['options'][correct_option_idx - 1]
|
|
|
+ msg = f"Неправильно. Правильный ответ: {correct_answer}."
|
|
|
+ label = tk.Label(self.root, text=msg, font=('Arial', 14))
|
|
|
+ label.pack(pady=20)
|
|
|
+ next_button = tk.Button(self.root, text="Далее", command=self.next_question)
|
|
|
+ next_button.pack(pady=10)
|
|
|
+
|
|
|
+ def next_question(self):
|
|
|
+ self.current_q_index += 1
|
|
|
+ self.scene2()
|
|
|
+
|
|
|
+ def show_results(self):
|
|
|
+ self.clear_screen()
|
|
|
+ result_text = f"Вы ответили правильно на {self.correct_answers} из {len(self.questions)} вопросов."
|
|
|
+ tk.Label(self.root, text="Итоги", font=('Arial', 16, 'bold')).pack(pady=20)
|
|
|
+ tk.Label(self.root, text=result_text, font=('Arial', 14)).pack(pady=10)
|
|
|
+ restart_button = tk.Button(self.root, text="Заново", command=self.restart_game)
|
|
|
+ restart_button.pack(pady=10)
|
|
|
+ exit_button = tk.Button(self.root, text="Завершить", command=self.root.quit)
|
|
|
+ exit_button.pack(pady=5)
|
|
|
+
|
|
|
+ def restart_game(self):
|
|
|
+ self.current_q_index = 0
|
|
|
+ self.correct_answers = 0
|
|
|
+ self.create_scene1()
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ root = tk.Tk()
|
|
|
+ root.geometry("700x500")
|
|
|
+ app = QuizApp(root)
|
|
|
+ root.mainloop()
|