Hello guys,
I am creating an app to make quizzes and it is already in an advanced stage, but I've noticed this problem a week ago and it's driving me insane because I can't figure out what is wrong. Maybe it's a bug, I think.
So I have a page to edit the quizzes, which are initially read and then saved to a .txt file. Simplifying in the designer I have 5 textboxes (1 for entering the question and 4 for the options), 4 checkboxes (to select the only correct answer), and buttons to go to the next and previous question and to create more questions. Every time I click to go to a different question it updates the list where I have the questions saved and loads the textboxes' text with the next question, so I can change them. In the end, I hit Save and the list is saved again in the .txt file. The questions are saved in the .txt file one question per line, separated with semi-colons (Question;nr_for_the_correct_option;Option_1;Option_2;Option_3;Option_4). While editing they are saved in a list of lists in the same order as the .txt file.
My issue: everything works fine (loading and presenting the questions, changing questions, selecting the correct option, etc), except for saving the file. Most of the times works ok, but once in a while, it changes the order of the options only in some questions (for example: "nr_for_the_correct_option;Question;Option_1;Option_2;Option_3;Option_4", this is the order that happens the most, and happens mostly on the first question). I always try to produce the same error, repeating my steps, but when I do the exact same thing again, the problem doesn't happen. As I said it only happens sometimes even with the same steps and text, so I can't figure out what's wrong... maybe some kind of delay??
Here are my relevant blocks:
"altera_pergunta" is the function to update the list of questions every time I go to the next or previous question, "recebe_correta" if for getting the correct option from the checkboxes, "gravar2" is the function that happens in the end to update the file.
I appreciate it if you can help me.
Thanks and sorry for the extent of the post.