-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasy3.py
More file actions
181 lines (162 loc) · 6.22 KB
/
easy3.py
File metadata and controls
181 lines (162 loc) · 6.22 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
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": "3. Which European country is completely\nsurrounded by Italy?",
"q2": "3. Which country has Budapest as its capital city?",
"q3": "3. Which country is crossed by the Danube river?",
"A1": "A) San Marino", "B1": "B) Italy", "C1": "C) Vatican City", "D1": "D) Monaco",
"A2": "A) Slovakia", "B2": "B) Hungary", "C2": "C) Romania", "D2": "D) Serbia",
"A3": "A) Spain", "B3": "B) Germany", "C3": "C) France", "D3": "D) Portugal"
},
"Greek": {
"q1": "3. Ποια ευρωπαϊκή χώρα περιβάλλεται εξ ολοκλήρου από την Ιταλία;",
"q2": "3. Ποια χώρα έχει πρωτεύουσα τη Βουδαπέστη;",
"q3": "3. Ποια χώρα διασχίζεται από τον ποταμό Δούναβη;",
"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": "3. Quel pays européen est entièrement entouré par l'Italie ?",
"q2": "3. Quel pays a Budapest pour capitale ?",
"q3": "3. Quel pays est traversé par le Danube ?",
"A1": "A) Saint-Marin", "B1": "B) Italie", "C1": "C) Vatican", "D1": "D) Monaco",
"A2": "A) Slovaquie", "B2": "B) Hongrie", "C2": "C) Roumanie", "D2": "D) Serbie",
"A3": "A) Espagne", "B3": "B) Allemagne", "C3": "C) France", "D3": "D) Portugal"
}
}
current_language = "English"
def tr(key):
return translations.get(current_language, translations["English"]).get(key, key)
qu3 = None
ans = 0
# Main function for the third 'Easy' quiz question
# Receives the window, previous score, and correctness of previous questions
# Sets up the third question and answer buttons
def easy(window, ans2, qu2, qu1, current_language):
global qu3, ans
ans += ans2
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 easy4.easy)
def next_question():
import easy4
# Remove all widgets from the window before showing the next question
for widget in window.children():
widget.deleteLater()
print(ans)
print(qu3)
easy4.easy(window, ans, 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 qu3, ans
if instance == 1:
qu3 = True
ans += 2
elif instance == 2:
qu3 = False
elif instance == 3:
qu3 = False
next_question()
def answer_b():
global qu3, ans
if instance == 1:
qu3 = False
elif instance == 2:
qu3 = True
ans += 2
elif instance == 3:
qu3 = True
ans += 2
next_question()
def answer_c():
global qu3, ans
if instance == 1:
qu3 = False
elif instance == 2:
qu3 = False
elif instance == 3:
qu3 = False
next_question()
def answer_d():
global qu3, ans
if instance == 1:
qu3 = False
elif instance == 2:
qu3 = False
elif instance == 3:
qu3 = False
next_question()
# 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)
# Add this line to set the correct button texts
# (otherwise the buttons will have the same text for all languages)
# set_correct_text() is missing, so add it:
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"))
set_correct_text()