def gen_rows(self): # get a list of all the user ids in the database ids = db.get_user_by_grade(conn) # Setup graph x_ax = [] y_ax = [] # set iterator for grid rows i = 0 # for each id create a row for uid in ids: # create new entries user = db.get_user_details(conn, uid) rank_label = self.create_label(self, text=i+1, font=REGULAR_FONT) name_label = self.create_label(self, text=user[0][0], font=REGULAR_FONT) grade_label = self.create_label(self, text=str(user[0][5]) + "%", font=REGULAR_FONT) time_label = self.create_label(self, text=self.datetimeFormat(user[0][6]), font=REGULAR_FONT) # add to corresponding dictonaries with user ids as keys self.names[uid] = name_label self.grades[uid] = grade_label self.times[uid] = time_label # set everything nicely on the grid using an iterator i rank_label.grid(row=i+3, column=0) name_label.grid(row=i+3, column=1) grade_label.grid(row=i+3, column=2) time_label.grid(row=i+3, column=3)
def gen_rows(self): # get a list of all the user ids in the database ids = db.get_user_by_grade(conn) # Setup graph x_ax = [] y_ax = [] # set iterator for grid rows i = 0 # for each id create a row for uid in ids: # create new entries user = db.get_user_details(conn, uid) rank_label = self.create_label(self, text=i + 1, font=REGULAR_FONT) name_label = self.create_label(self, text=user[0][0], font=REGULAR_FONT) grade_label = self.create_label(self, text=str(user[0][5]) + "%", font=REGULAR_FONT) time_label = self.create_label(self, text=self.datetimeFormat( user[0][6]), font=REGULAR_FONT) # add to corresponding dictonaries with user ids as keys self.names[uid] = name_label self.grades[uid] = grade_label self.times[uid] = time_label # set everything nicely on the grid using an iterator i rank_label.grid(row=i + 3, column=0) name_label.grid(row=i + 3, column=1) grade_label.grid(row=i + 3, column=2) time_label.grid(row=i + 3, column=3) # Append for graph x_ax.append(str(i) + "\n" + str(user[0][0])) y_ax.append(user[0][5]) i += 1 fig = Figure(figsize=(5, 6), dpi=60) graph = fig.add_subplot(111) graph.set_title("Leaderboard Graph") graph.set_xlabel("Rank with UID") graph.set_ylabel("Grade in %") graph.plot(x_ax, y_ax) canvas = FigureCanvasTkAgg(fig, self) canvas.get_tk_widget().grid(row=i + 4, column=0, columnspan=4) canvas._tkcanvas.grid(row=0, column=5, columnspan=4, rowspan=45, padx=15, pady=20)
def __init__(self, uid): ''' uid is the user id of the student we want to create ''' # get user details from database user = db.get_user_details(conn, uid)[0] # assign corresponding values to variables self.uid = user[0] self.role = user[1] self.name = user[2] self.email = user[3] self.password = user[4]
def create_student_box(self, location): '''creates a student listbox in the given location''' list_box = self.create_list_box_loc(location, "students", 10, 5, mode="multiple") users = db.get_user_ids(conn) for user in users: info = db.get_user_details(conn, user) # check that a user is a student if (info[0][1] == "student"): result = "{:>3} {:<12}" result = result.format(info[0][0], info[0][2]) self.list_box["students"].insert(END, result) list_box.grid(row=0, column=2, rowspan=8, padx=5)
def get_longest_username(self, uids): ''' a function that gets the longest user name for the formatting of the list box @param uids -> a list containing the uids that are going to be checked ''' max_len = 0 for uid in uids: # get the user_info user_info = db.get_user_details(conn, uid) if (len(user_info) != 0): name = user_info[0][2] # want to call this later without accessing the db self.uids[uid] = name if (len(name) > max_len): max_len = len(name) return max_len
def update_grades_table(self, row, uid, questions, progress, grade): ''' insert a new row to the grades table with the details ''' user_row = [] student_details = db.get_user_details(conn, uid) name = student_details[0][2] user_row.append(name) user_row.append(uid) if (grade == ''): user_row.append("Grade Not Available") else: self.num_users = self.num_users + 1 self.all_grades = self.all_grades + int(grade) user_row.append(grade) return user_row
def substitue_values(self): ''' This method substitutes values such as course, assign #, deadline, and name into the latex expression and ends it. Then it proceeds to create the '.tex' file. ''' # Substitues values into latex expression parser = argparse.ArgumentParser() parser.add_argument('-c', '--course', default='STAB22') parser.add_argument('-t', '--title', default='Assignment: ' + str(self.aid)) parser.add_argument('-n', '--name', default = db.get_user_details(conn, self.uid)[0][2]) parser.add_argument('-d', '--deadline', default=db.get_assignment_details(self.aid, conn)[3]) args = parser.parse_args() # End the document self.content += r'\end{document}' self.createTexFile(args)
def update_attempts_table(self, row, uid, questions, progress, grade, attempt_num): ''' Insert a new row to the student attempts table with the details ''' student_details = db.get_user_details(conn, uid) self.stu_name = student_details[0][2] user_row = [] user_row.append(attempt_num) user_row.append(questions) user_row.append(progress) user_row.append(grade) i = 0 #check for empty content for item in user_row: if (item == ""): user_row[i] = "Not Available" i += 1 return user_row
def gen_rows(self): # get a list of all the user ids in the database ids = db.get_user_by_grade(conn) # set iterator for grid rows i = 0 # for each id create a row for uid in ids: # create new entries user = db.get_user_details(conn, uid) rank_label = Label(self, font=REGULAR_FONT, text=i+1) name_label = Label(self, font=REGULAR_FONT, text=user[0][2]) email_label = Label(self, font=REGULAR_FONT, text=user[0][3]) grade_label = Label(self, font=REGULAR_FONT, text=user[0][5]) time_label = Label(self, font=REGULAR_FONT, text=user[0][6]) # add to corresponding dictonaries with user ids as keys self.names[uid] = name_label self.emails[uid] = email_label self.grades[uid] = grade_label self.times[uid] = time_label ## create new buttons ##update_button = self.create_button(self, "Update") ##delete_button = self.create_button(self, "Delete") ## add to corresponding dictonaries with user ids as keys ##self.deletes[uid] = delete_button ##self.updates[uid] = update_button # set everything nicely on the grid using an iterator i rank_label.grid(row=i+3, column=0) name_label.grid(row=i+3, column=1) email_label.grid(row=i+3, column=2) grade_label.grid(row=i+3, column=3) time_label.grid(row=i+3, column=4) ##update_button.grid(row=i+3, column=3) ##delete_button.grid(row=i+3, column=4) i += 1 """# create new user object to contain user info
completion_label = self.create_label(frame, completion_string) average_label = self.create_label(frame, average_string) completion_label.grid(row=0, column=0) average_label.grid(row=1, column=0) self.widgets["average"] = frame return frame def get_longest_username(self, uids): ''' a function that gets the longest user name for the formatting of the list box @param uids -> a list containing the uids that are going to be checked ''' max_len = 0 for uid in uids: # get the user_info user_info = db.get_user_details(conn, uid) if (len(user_info) != 0): name = user_info[0][2] # want to call this later without accessing the db self.uids[uid] = name if (len(name) > max_len): max_len = len(name) return max_len def update_grades_table(self, username, uid, attempts, max_len): ''' Insert a new row to the grades table with the user details @parame username ->username of the uid @param uid -> user uid from database @param attempts -> Attempts tuple