def gen_rows(self): # get a list of all the problem ids for the user for that assignment ids = db.get_user_nth_attempt(self.aid, self.uid, (self.atid - 1), conn)[2] # set iterator for grid rows ids = ast.literal_eval(ids) # for each id create a row i = 0 for qid in ids: # create new entries question_label = self.create_label(self, font=REGULAR_FONT) answer_label = self.create_label(self, font=REGULAR_FONT) self.labels.append(question_label) self.entries.append(answer_label) # add to corresponding dictonaries with problem ids as keys # self.subjects[qid] = subject_entry # self.questions[qid] = question_entry # self.answers[qid] = answer_entry # set everything nicely on the grid using an iterator i question_label.grid(row=i + 3, column=0) answer_label.grid(row=i + 3, column=1) # set each label with the corresponding value from the problem object question_label.config(text=db.get_problem_details(conn, qid)[0][2]) # set each entry with the corresponding value from list of existing progress try: answer_label.config(text=self.existing_progress[i]) except IndexError: print("no progress yet") i += 1
def gen_rows(self): # get a list of all the problem ids for the user for that assignment ids = db.get_user_first_attempt(self.aid, self.uid, conn)[1] # set iterator for grid rows ids = ast.literal_eval(ids) # for each id create a row i = 0 for qid in ids: # create new entries question_label = Label(self, font=REGULAR_FONT) answer_entry = Entry(self, font=REGULAR_FONT) self.labels.append(question_label) self.entries.append(answer_entry) # add to corresponding dictonaries with problem ids as keys # self.subjects[qid] = subject_entry # self.questions[qid] = question_entry # self.answers[qid] = answer_entry # set everything nicely on the grid using an iterator i question_label.grid(row=i + 3, column=0) answer_entry.grid(row=i + 3, column=1) i += 1 # set each entry with the corresponding value from the problem object question_label.config(text=db.get_problem_details(conn, qid)[0][2])
def gen_rows(self, uid=None, aid=None, atid=None): title_hints = self.create_label(self, "You have "+str(self.hints_left)+" hints", APP_HIGHLIGHT_FONT, NICE_BLUE) self.labels.append(title_hints) # get a list of all the problem ids for the user for that assignment ids = db.get_user_nth_attempt(self.aid, self.uid, -1, conn)[2] # set iterator for grid rows ids = ast.literal_eval(ids) # for each id create a row self.i = 0 for qid in ids: # create new entries self.problem_ids.append(qid) hint_button = self.create_button(self, "Hint!") #question_label = self.create_label(self, "", REGULAR_FONT) answer_entry = ttk.Entry(self, font=REGULAR_FONT) hint_label = self.create_label(self, "", REGULAR_FONT, NICE_BLUE) self.labels.append(hint_label) self.entries.append(answer_entry) self.hint_buttons[qid] = hint_button self.hints_labels[qid] = hint_label # set everything nicely on the grid using an iterator i answer_entry.grid(row=self.i+4, column=2) hint_button.grid(row=self.i+4, column=3) hint_label.grid(row=self.i+4, column=4) # set each label with the corresponding value from the problem object #question_label.config(text=db.get_problem_details(conn, qid)[0][2]) # set each entry with the corresponding value from list of existing progress try: answer_entry.insert(0, self.existing_progress[self.i]) except IndexError: print("no progress yet") # NEW (latex feature) create the canvas with the latex problem self.latex_row(db.get_problem_details(conn, qid)[0][2]) self.i += 1 title_hints.grid(row=1, column=2, pady=10) # create submit and save progress buttons self.update_progress_button = self.create_button(self, "Save") self.update_progress_button["command"] = lambda : self.update_progress() self.update_progress_button.grid(row=0, column=4, padx=5) self.submit_button = self.create_button(self,"Submit") self.submit_button["command"] = lambda : self.submit_progress() self.submit_button.grid(row=0, column=5, padx=5) self.pdf_button = self.create_button(self, "Convert to PDF") self.pdf_button["command"]= lambda : self.conv.addOnLatex() self.pdf_button.grid(row=0, column=6, padx=5)
def __init__(self, qid): ''' qid is the problem id of the student we want to create ''' # get problem details from database problem = db.get_problem_details(conn, qid)[0] # assign corresponding values to variables self.qid = problem[0] self.subject = problem[1] self.question = problem[2] self.answer = problem[3]
def addOnLatex(self): '''This method takes problems from the database and attaches them to the latex expression. ''' # Fetch the user attempts for assignment ids = db.get_user_nth_attempt(self.aid, self.uid, -1, conn)[2] ids = ast.literal_eval(ids) # Loop through problems for qid in ids: # For each problem, append it to latex expression problem = db.get_problem_details(conn, qid)[0][2] self.content += problem + r'\newline\newline' + r'\begin{tikzpicture}' + r'\draw (0,0) -- (17,0) -- (17,3) -- (0,3) -- (0,0);' +r'\end{tikzpicture}' + r'\newline\newline\newline\newline' self.substitue_values()
def gen_rows(self): # get a list of all the problem ids for the user for that assignment ids = db.get_user_nth_attempt(self.aid, self.uid, -1, conn)[2] # set iterator for grid rows # print(db.get_user_nth_attempt(self.aid, self.uid, -1, conn)[2]) ids = ast.literal_eval(ids) # for each id create a row i = 0 for qid in ids: # create new entries question_label = Label(self, font=REGULAR_FONT) answer_entry = Entry(self, font=REGULAR_FONT) self.labels.append(question_label) self.entries.append(answer_entry) # add to corresponding dictonaries with problem ids as keys # self.subjects[qid] = subject_entry # self.questions[qid] = question_entry # self.answers[qid] = answer_entry # set everything nicely on the grid using an iterator i question_label.grid(row=i + 3, column=0) answer_entry.grid(row=i + 3, column=1) # set each label with the corresponding value from the problem object question_label.config(text=db.get_problem_details(conn, qid)[0][2]) # set each entry with the corresponding value from list of existing progress try: answer_entry.insert(0, self.existing_progress[i]) except IndexError: print("no progress yet") i += 1 # create submit and save progress buttons self.update_progress_button = ttk.Button( text="Save", command=lambda: self.update_progress()) self.update_progress_button.pack() self.submit_button = ttk.Button(text="Submit", command=lambda: self.submit_progress()) self.submit_button.pack()