Exemple #1
0
    def __init__(self):
        """
        In this init we are going to display the main serverinfo window
        """
        gladefile="glade/quizz.glade"
        windowname="main_window"
        self.gui=gtk.glade.XML (gladefile, windowname)
        
        self.window = self.gui.get_widget("main_window")
        self.txt_quizz = self.gui.get_widget("txt_quizz")
        self.txt_question = self.gui.get_widget("txt_question")
        self.txt_answer = self.gui.get_widget("txt_answer")
        self.txt_questions_count = self.gui.get_widget("txt_questions_count")
        self.txt_correct_count = self.gui.get_widget("txt_correct_count")
        self.txt_percent  = self.gui.get_widget("txt_percent")
        self.mnu_quizzes = self.gui.get_widget("mnu_quizzes")
        self.txt_result = self.gui.get_widget("txt_result")
        
        
        self.da_prioritylist = self.gui.get_widget("da_prioritylist")
        # self.da_prioritylist.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK)
        self.da_prioritylist.connect("expose_event", self.area_expose_cb)
        self.pangolayout = self.da_prioritylist.create_pango_layout("")
        self.da_exposed = False
        
        # Used to shrink window when options are unexpanded
        self._initial_size = None
        
        # we only have two callbacks to register, but
        # you could register any number, or use a
        # special class that automatically
        # registers all callbacks. If you wanted to pass
        # an argument, you would use a tuple like this:
        # dic = { "on button1_clicked" : (self.button1_clicked, arg1,arg2) , ...

        dic = { 
            "on_check" : self.on_check, 
            "on_skip" : self.on_skip, 
            "on_main_window_delete_event" : gtk.main_quit,
            "on_txt_answer_editing_done" : self.on_check,
            "on_options_expander_activate" : self._on_options_expander_activate
        }
        self.gui.signal_autoconnect (dic)
        
        reader = QuizzReader()
        reader.read("data/quizz_v2.xml")

        self.quizzes_list = reader.quizzes_list
        
        menu = gtk.Menu()
        self.mnu_quizzes.set_submenu(menu)
        #menu = self.mnu_quizzes.get_submenu()
        
        for quizz in self.quizzes_list:
            mit = gtk.MenuItem(quizz.name)
            mit.connect("activate", self.select_quizz, quizz)
            menu.append(mit)
        menu.show_all()
        
        self.select_quizz(None, self.quizzes_list[0])
        
        gtk.main()
Exemple #2
0
from QuizzReader import QuizzReader
from PriorityList.QuadraticList import QuadraticList

reader = QuizzReader()
reader.read("data/quizz1.xml")

list = QuadraticList()

for q in reader.q_list:
    list.insert(5, q)

print len(list)
print list.get_priorities_statistics()

while True:
    pos = list.get_random_index()
    q = list.get_value(pos)
    ans = raw_input("%s > " % q.question)

    if ans == ".": 
        break
    elif ans.lower() == q.answer.lower():
        print "Correct"
        list.raise_index(pos)
    else:
        print "Wrong, answer is %s" % q.answer
        list.lower_index(pos)
        
    print list.get_priorities_statistics()