-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasy9.py
More file actions
186 lines (168 loc) · 6.65 KB
/
easy9.py
File metadata and controls
186 lines (168 loc) · 6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import os
import sys
import random
from PyQt5.QtWidgets import QPushButton, QLabel, QWidget
from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt
translations = {
"English": {
"q1": "9. What is the capital of Hungary?",
"q2": "9. Which of the following country-capital pairs\nis a correct match?",
"q3": "9. What is the longest river in Europe?",
"A1": "A) Budapest", "B1": "B) Belgrade", "C1": "C) Vienna", "D1": "D) Prague",
"A2": "A) Georgia-Yerevan", "B2": "B) Armenia-Tbilisi", "C2": "C) Armenia-Baku", "D2": "D) Georgia-Tbilisi",
"A3": "A) Danube", "B3": "B) Volga", "C3": "C) Rhine", "D3": "D) Seine"
},
"Greek": {
"q1": "9. Ποια είναι η πρωτεύουσα της Ουγγαρίας;",
"q2": "9. Ποιο από τα παρακάτω ζεύγη χώρας-πρωτεύουσας είναι σωστό;",
"q3": "9. Ποιος είναι ο μεγαλύτερος ποταμός της Ευρώπης;",
"A1": "A) Βουδαπέστη", "B1": "B) Βελιγράδι", "C1": "C) Βιέννη", "D1": "D) Πράγα",
"A2": "A) Γεωργία-Γερεβάν", "B2": "B) Αρμενία-Τιφλίδα", "C2": "C) Αρμενία-Μπακού", "D2": "D) Γεωργία-Τιφλίδα",
"A3": "A) Δούναβης", "B3": "B) Βόλγας", "C3": "C) Ρήνος", "D3": "D) Σηκουάνας"
},
"French": {
"q1": "9. Quelle est la capitale de la Hongrie ?",
"q2": "9. Laquelle des paires pays-capitale suivantes\nest correcte ?",
"q3": "9. Quel est le plus long fleuve d'Europe ?",
"A1": "A) Budapest", "B1": "B) Belgrade", "C1": "C) Vienne", "D1": "D) Prague",
"A2": "A) Géorgie-Erevan", "B2": "B) Arménie-Tbilissi", "C2": "C) Arménie-Bakou", "D2": "D) Géorgie-Tbilissi",
"A3": "A) Danube", "B3": "B) Volga", "C3": "C) Rhin", "D3": "D) Seine"
}
}
current_language = "English"
def tr(key):
return translations.get(current_language, translations["English"]).get(key, key)
qu9 = None
ans = 0
# Main function for the ninth 'Easy' quiz question
# Receives the window, previous score, and correctness of previous questions
# Sets up the ninth question and answer buttons
def easy(window, ans8, qu8, qu7, qu6, qu5, qu4, qu3, qu2, qu1, current_language):
global qu9, ans
ans += ans8
font = QFont("Calibri", 13)
instance = random.randint(1, 3)
def tr(key):
return translations.get(current_language, translations["English"]).get(key, key)
# Create the question label, centered horizontally
question = QLabel("", window)
question.setFont(font)
question.setAlignment(Qt.AlignCenter)
# Set the question text based on the random variant (translated)
if instance == 1:
question.setText(tr("q1"))
elif instance == 2:
question.setText(tr("q2"))
elif instance == 3:
question.setText(tr("q3"))
# Calculate position to center the label horizontally and place it near the top
window_width = window.frameGeometry().width()
question_width = 600
question_height = 100
question_x = (window_width - question_width) // 2
question_y = 20
question.setGeometry(question_x, question_y, question_width, question_height)
question.setStyleSheet("font-size: 20px; font-weight: bold;")
question.show()
# Function to proceed to the next question (calls easy10.easy)
def next_question():
import easy10
# Remove all widgets from the window before showing the next question
for widget in window.children():
widget.deleteLater()
print(ans)
print(qu9)
easy10.easy(window, ans, qu9, qu8, qu7, qu6, qu5, qu4, qu3, qu2, qu1, current_language)
# Answer button callbacks for each possible answer
# Each function checks which question is active and updates the score and correctness accordingly
def answer_a():
global qu9, ans
if instance == 1:
qu9 = True
ans += 2
next_question()
elif instance == 2:
qu9 = False
next_question()
elif instance == 3:
qu9 = False
next_question()
def answer_b():
global qu9, ans
if instance == 1:
qu9 = False
next_question()
elif instance == 2:
qu9 = False
next_question()
elif instance == 3:
qu9 = True
ans += 2
next_question()
def answer_c():
global qu9, ans
if instance == 1:
qu9 = False
next_question()
elif instance == 2:
qu9 = False
next_question()
elif instance == 3:
qu9 = False
next_question()
def answer_d():
global qu9, ans
if instance == 1:
qu9 = False
next_question()
elif instance == 2:
qu9 = True
ans += 2
next_question()
elif instance == 3:
qu9 = False
next_question()
# Set the button texts according to the question instance (translated)
def set_correct_text():
if instance == 1:
dania.setText(tr("A1"))
kroatia.setText(tr("B1"))
norway.setText(tr("C1"))
poland.setText(tr("D1"))
if instance == 2:
dania.setText(tr("A2"))
kroatia.setText(tr("B2"))
norway.setText(tr("C2"))
poland.setText(tr("D2"))
if instance == 3:
dania.setText(tr("A3"))
kroatia.setText(tr("B3"))
norway.setText(tr("C3"))
poland.setText(tr("D3"))
# Create answer buttons with translated text and connect them to the correct callback
dania = QPushButton(tr(f"A{instance}"), window)
dania.resize(500, 120)
dania.move(250, 140)
dania.setFont(font)
dania.show()
dania.clicked.connect(answer_a)
kroatia = QPushButton(tr(f"B{instance}"), window)
kroatia.setFont(font)
kroatia.resize(500, 120)
kroatia.move(250, 270)
kroatia.show()
kroatia.clicked.connect(answer_b)
norway = QPushButton(tr(f"C{instance}"), window)
norway.resize(500, 120)
norway.move(250, 400)
norway.setFont(font)
norway.show()
norway.clicked.connect(answer_c)
poland = QPushButton(tr(f"D{instance}"), window)
poland.resize(500, 120)
poland.move(250, 530)
poland.setFont(font)
poland.show()
poland.clicked.connect(answer_d)
set_correct_text()