示例#1
0
    def up_problem(self):
        '''
        updates a problem details in the database and show a success popup
        '''
        lb = self.list_box["problems"]
        selection = lb.curselection()

        # check to make sure that we have something selected
        if (selection != ()):
            # get new parameters from entry widgets in the dictionaries
            new_subject = self.entry_fields[self.labels[0]].get()
            new_question = self.entry_fields[self.labels[1]].get()
            new_answer = self.entry_fields[self.labels[2]].get()
            new_hint = self.entry_fields[self.labels[3]].get()

            verified = self.verify_problem_input(new_subject, new_question,
                                                 new_answer)
            if (verified):
                qid = lb.get(selection[0]).split()
                # update the database with new entries
                db.update_problem_subject(qid[0], new_subject, conn)
                db.update_problem_question(qid[0], new_question, conn)
                db.update_problem_answer(qid[0], new_answer, conn)
                db.update_problem_hint(qid[0], new_hint, conn)
                # create a string representation to put in the listbox
                problem_string = self.string_qid(qid[0])
                # clear entry boxes
                self.clear_entries()
                # delete from listbox and readd at same index
                lb.delete(selection[0])
                lb.insert(selection[0], problem_string)
                # show popup
                showinfo("Success",
                         "problem #" + str(qid[0]) + " has been updated")
示例#2
0
文件: problem.py 项目: gsteinb/ace
 def up_problem(self, button):
     '''
     delete a problem details in the database and show a success popup
     '''        
     # get new parameters from entry widgets in the dictionaries
     new_subject = self.subjects[button].get()
     new_question = self.questions[button].get()
     new_answer = self.answers[button].get()
     # update the database with new entries
     db.update_problem_subject(button, new_subject, conn)
     db.update_problem_question(button, new_question, conn)
     db.update_problem_answer(button, new_answer, conn)
     
     self.refresh()
     
     # show popup
     showinfo("Success", "problem #" + str(button) + " has been updated")
示例#3
0
    def press2(self):
        '''calls a function that tells the user if update of answer was sucessful
        and displays appropriate message on label'''

        qid = self.problem_entry.get()
        new_answer = self.problem_entry3.get()

        message = database_api.update_problem_answer(qid, new_answer,
                                                     sqlite3.connect('ace.db'))
        print(message)

        self.feedback_label.config(text="Updated Successfully!")
示例#4
0
 def test_empty_answer_update(self):
     db.update_problem_answer(row + 1, "", conn)
示例#5
0
            new_question = self.entry_fields[self.labels[1]].get()
            new_answer = self.entry_fields[self.labels[2]].get()
<<<<<<< HEAD
            new_hint = self.entry_fields[self.label[3]].get()
=======
            new_hint = self.entry_fields[self.labels[3]].get()
>>>>>>> working_final
            
            verified = self.verify_problem_input(new_subject, new_question,
                                                 new_answer)
            if (verified):
                qid = lb.get(selection[0]).split()
                # update the database with new entries
                db.update_problem_subject(qid[0], new_subject, conn)
                db.update_problem_question(qid[0], new_question, conn)
                db.update_problem_answer(qid[0], new_answer, conn)
                db.update_problem_hint(qid[0], new_hint, conn)
                # create a string representation to put in the listbox
                problem_string = self.string_qid(qid[0])
                # clear entry boxes
                self.clear_entries()
                # delete from listbox and readd at same index
                lb.delete(selection[0])
                lb.insert(selection[0], problem_string)
                # show popup
                showinfo("Success", "problem #" + str(qid[0]) + " has been updated")


    def verify_problem_input(self, subject, question, answer):
        '''verifies whether a problem is a valid problem'''
        result = True