def delete_row(table_name, row_id, *args): """Deletes the passed row in the passed table. *args is used only in the button widget to delete input inside the entry widget. *args: only needed to delete the gui entry_field after passing of data """ sql_m = SqlManager() sql_m.sql_delete_row(table_name, row_id)
def next_question(self, row_id, question, right_answers, user_answers, start_time, firsts): """Sets the score variable to 1 if right_answers and user_answers are equally. Creates the time_track_variable to save how long user took to answer a question. Adds or subtracts firsts variable accordingly to the score(add if score=0 add subtract if score=1). Checks if any firsts variable is lower than one and deletes that row if true. Passes all variables to the selected_results table. Then call the start_testing function again. """ try: if right_answers == user_answers: score = 1 else: score = 0 end_time = time.time() time_track = round(((end_time - start_time) / 60), 2) results = Results(row_id, question, right_answers, user_answers, score, time_track, firsts) results_list = [results] sql_m = SqlManager() sql_m.sql_insert_new_results( results_list, SettingVariables().selected_results_table) if score == 1: sql_m.sql_subtract_firsts( row_id, SettingVariables().selected_database_copy) elif score == 0: sql_m.sql_add_firsts(row_id, SettingVariables().selected_database_copy) if score == 1: firsts = sql_m.sql_get_row( SettingVariables().selected_database_copy, row_id)[0].firsts if firsts < 1: sql_m.sql_delete_row(SettingVariables().selected_database_copy, row_id) except IndexError as ie: print(str(ie) + " in next_question") print( "Possible reason might be that the database itself is empty or you choose an empty database_copy" ) try: self.testing_top.destroy() self.start_testing(SettingVariables().selected_database_copy) except Exception: print("Another exception in next_question occurred")
def tearDownInsertRow(table_name, row_id): """Deletes a row from the passed table with the passed row_id.""" sql_m = SqlManager() sql_m.sql_delete_row(table_name, row_id)