Exemplo n.º 1
0
    def press(self):
        #calls a function that tells the user if add was sucessfully,
        #displays appropriate message on label

        subject = self.problem_entry.get()
        question = self.problem_entry1.get()
        answer = self.problem_entry2.get()

        message = database_api.add_problem(subject, question, answer,
                                           sqlite3.connect('ace.db'))
        print(message)

        self.feedback_label.config(text="Added Successfully!")
Exemplo n.º 2
0
 def add_problem(self):
     '''
     delete a problem from the database and show a success popup
     '''
     # get new parameters from entry widgets in the dictionaries
     new_subject = self.entry_fields["Subject"] .get()
     new_question = self.entry_fields["Question"].get()
     new_answer = self.entry_fields["Answer"].get()        
     # add new problem to databse and save his id number
     qid = db.add_problem(new_subject, new_question, new_answer, conn)
     # show popup
     self.refresh()
     # clear entries
     self.entry_fields["Subject"].set('')
     self.entry_fields["Question"].set('')
     self.entry_fields["Answer"].set('')      
     showinfo("Success", "problem #" + str(qid) + " has been added to database")
Exemplo n.º 3
0
 def add_question_to_db(self, subject, question, answer, hint):
     '''takes a question and adds it to the db and list box
     @param subject ->subject of the question
     @param question -> question of the question
     @param answer-> answer of the question
     @returns -> True if successfully added False otherwise
     '''
     lb = self.list_box["problems"]
     # verify the inputs
     verified = self.verify_problem_input(subject, question, answer)
     if (verified):
         # add new problem to databse and save his id number
         qid = db.add_problem(subject, question, str(answer), hint, conn)
         # create a string representation to put in the listbox
         problem_string = self.string_qid(qid)
         # clear entry boxes
         self.clear_entries()
         # add problem to list box
         lb.insert(END, problem_string)
         # show popup
     return verified
Exemplo n.º 4
0
 def test_delete_problem(self):
     db.add_problem("math", "30+60", "42", conn)
     db.remove_problem(row + 1, conn)
Exemplo n.º 5
0
 def test_add_valid_problem(self):
     db.add_problem("math", "30+60", "42", conn)
Exemplo n.º 6
0
 def test_empty_answer_add(self):
     db.add_problem("math", "30+60", "", conn)
Exemplo n.º 7
0
 def test_empty_question_add(self):
     db.add_problem("math", "", "42", conn)
Exemplo n.º 8
0
 def test_empty_subject_add(self):
     db.add_problem("", "30+60", "42", conn)
Exemplo n.º 9
0
 def setUp(self):
     db.add_problem("math", "60+60", "120", conn)
     self.problem = Problem(row + 1)
Exemplo n.º 10
0
 def setUp(self):
     db.add_problem("math", "30+60", "42", conn)