# Joriy savol va variantlarni ko'rsatish funksiyasi
def show_question():
# Joriy savolni quiz_data faylidan olish
question = quiz_data[current_question]
qs_label.config(text=question["question"])
# Tugmalardagi variantlarni ko'rsatish
choices = question["choices"]
for i in range(4):
choice_btns[i].config(text=choices[i], state="normal") # Qayta tiklash tugmasi holati
# Tanlangan variantni tekshirish va feedbackni ko'rsatish
def check_answer(choice):
# Joriy savolni quiz_data faylidan olish
question = quiz_data[current_question]
selected_choice = choice_btns[choice].cget("text")
# Tanlangan variant to'gri javobga mos kelishini tekshirish
if selected_choice == question["answer"]:
# Balni yangilash va uni ko'rsatish
global score
score += 1
score_label.config(text="Ball: {}/{}".format(score, len(quiz_data)))
feedback_label.config(text="To'g'ri!", foreground="green")
else:
feedback_label.config(text="Noto'g'ri!", foreground="red")
# Barcha variant tugmalarini o'chirish va keyingi tugmani yoqish
for button in choice_btns:
button.config(state="disabled")
next_btn.config(state="normal")
# Keyingi savolga o'tish funksiyasi
def next_question():
global current_question
current_question +=1
if current_question < len(quiz_data):
# Agar ko'proq savollar bo'lsa, keyingi savolni ko'rsating
show_question()
else:
# Agar barcha savollarga javob berilgan bo'lsa,yakuniy ballni ko'rsatish va testni tugatish
messagebox.showinfo("Savollar tugadi",
"Savollar tugadi! Yakuniy ball: {}/{}".format(score, len(quiz_data)))
root.destroy()
# Asosiy oynani yaratish
root = tk.Tk()
root.title("Test tizimi")
root.geometry("600x500")
# Savol labelini yaratish
qs_label = ttk.Label(
root,
anchor="center",
wraplength=500,
padding=10
)
qs_label.pack(pady=10)
# Joriy savol indeksini ishga tushirish
current_question = 0
# Birinchi savolni ko'rsatish
show_question()
# Ekranda ko'rsatish
root.mainloop()
Talabalar bilimini baholash uchun test tizimining umumiy ko’rinishi:
Bunda savollar sonini mavzuga qarab ko’paytirishingiz yoki kamaytirishingiz yoki o’zgartirishingiz mumkin.
Agar savolga to’g’ri javob berilsa, ballga yana 1 ball qo’shiladi va
“ To’g’ri “ yozuvi yashil rangda chiqadi.
Noto’g’ri javob berilsa, ball qo’shilmaydi va “ Noto’g’ri” yozuvi chiqadi.
(misolda 2-savolga javob)
“ Keyingi ” tugmasini bossak keying savolga o’tadi.
Oxirida savollar tugaganligini bildirib, umumiy balingizni messageboxda ko’rsatadi: