Talabalar bilimini baholash uchun test tizimi



Download 1.37 Mb.
Date29.02.2024
Size1.37 Mb.
#63704
kurs ishi taqtimod
Livestock-CDE-Test-Bank-Answer-Key, kurs ishi kodi

Talabalar bilimini baholash uchun test tizimi

Habibova Muxlisa

Yaratilgan test tizimi va uni bajarilish ketma - ketligi.


Test tizimini yaratish uchun birinchi bo’lib PYTHONda 2 ta fayl yaratamiz:
  • Savollar yoziladigan fayl
  • Kod qismi yoziladigan fayl

quiz_data qismida yozilgan kod:
Savollarni mavzuga moslab o’zgartirish yoki sonini oshirish mumkin.

Matn qismida yozilgan kod va uning tasnifi:

  • #Tkinterni import qilish
  •  
  • import tkinter as tk
  • from tkinter import messagebox, ttk
  • from quiz_data import quiz_data
  •  
  • # 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)

# Variantlar tugmasini yaratish

  • # Variantlar tugmasini yaratish
  • choice_btns = []
  • for i in range(4):
  • button = ttk.Button(
  • root,
  • command=lambda i=i: check_answer(i)
  • )
  • button.pack(pady=5)
  • choice_btns.append(button)

# Ball labelini yaratish

  • # Ball labelini yaratish
  • score_label = ttk.Label(
  • root,
  • text="Ball: 0/{}".format(len(quiz_data)),
  • anchor="center",
  • padding=10
  • )
  • score_label.pack(pady=10)
  • # Keyingi tugmasini yaratish
  • next_btn = ttk.Button(
  • root,
  • text="Keyingi",
  • command=next_question,
  • state="disabled"
  • )
  • next_btn.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:
Download 1.37 Mb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page