Exemplo n.º 1
0
    def create_listbox(self, eventObject):
        self.all_grades = 0
        self.num_users = 0
        self.drop_down_selection = self.dropdown.get()
        #split the selection strng to get the 'aid'
        result = self.drop_down_selection.split()
        aid = int(result[1])
        user_ids = db.get_users_ids_assignment(aid, conn)
        new_frame = ttk.Frame(self)
        # create a new scrollbar
        scrollbar = ttk.Scrollbar(new_frame, orient='vertical')
        # create a listbox widget
        self.list_box = tk.Listbox(new_frame,
                                   yscrollcommand=scrollbar.set,
                                   width=40,
                                   height=8)
        #configure the scrollbar
        scrollbar.config(command=self.list_box.yview)
        scrollbar.pack(side="right", fill="y")
        # adds the listbox to a listbox dictionary with given key
        self.list_box.pack(side="left", fill="both")
        new_frame.grid(row=4, column=1, padx=15)
        for uid in user_ids:
            # get all the attempts for the user id
            attempts = db.get_user_attempts(aid, uid, conn)
            # get the last attempt
            last_a = attempts[-1]
            user_result = self.update_grades_table(self, *last_a)
            # return it
            self.list_box.insert(END, user_result)

        self.show_average()
Exemplo n.º 2
0
    def create_listbox(self, eventObject):
        ''' Create a listbox for the last 
		attempt of each user for selected assignment
		@param eventObject, dropdown menu item selected		
		'''
        my_frame = ttk.Frame(self.lb_frame)
        drop_results = self.dropdown.get()
        #split the selection strng to get the 'aid'
        aid = drop_results.split()[1]
        self.aid = int(aid)
        user_ids = db.get_users_ids_assignment(self.aid, conn)
        lb_frame = self.create_list_box_loc(my_frame, "results")
        lb_frame.grid(row=1, column=0)
        max_len = self.get_longest_username(user_ids)
        #label_string = "Uid   Name   Grade  Attempts"
        label_string = "{:>4}   {:<7}   {:>7}  {:>4}"
        label_string = label_string.format("Uid", "Name", "Grade", "Attempts")
        lb = self.list_box["results"]
        lb.insert(END, label_string)
        for user in user_ids:
            # get all the attempts for the user id
            attempts = db.get_user_attempts(self.aid, user, conn)
            user_result = self.update_grades_table(self.uids[user], user,
                                                   attempts, max_len)
            # place it in the lists_box
            lb.insert(END, user_result)

        self.average_labels(my_frame, user_ids).grid(row=0,
                                                     column=0,
                                                     columnspan=3)
        self.contents = lb.get(1, lb.size())
        my_frame.grid(row=0, column=0, rowspan=2)
Exemplo n.º 3
0
	def create_listbox(self, eventObject):
		''' Create a listbox for the last 
		attempt of each user for selected assignment
		@param eventObject, dropdown menu item selected		
		'''
		my_frame = ttk.Frame(self.lb_frame)
		drop_results = self.dropdown.get()
		#split the selection strng to get the 'aid' 
		aid = drop_results.split()[1] 
		self.aid = int(aid)
		user_ids = db.get_users_ids_assignment(self.aid,conn)
		lb_frame = self.create_list_box_loc(my_frame, "results")
		lb_frame.grid(row=1, column=0)
		max_len = self.get_longest_username(user_ids)