Hello,
I've made an online questionnaire with 70 questions to be answered with 'yes' or 'no'. After every question a new question is loaded in the same window. Because I don't have a database, I used PHP to write the results to a file each time an answer is given. Here's how:
- I made a counter file with only one variable (counter), an integer which indicates the last respondent (so 5, 18 or 67)
- When a new questionnaire is started, the counter is incremented and a new file is made with the counter (so 5.txt, 18.txt etc.)
- I pass this counter number as a parameter every time a question is answered, together with the 'yes' or 'no'
- Each time I write the answer to the file: just 'yes/no' and no other information (for processing reasons)
- I use fopen to open the file, fwrite to write the results and fclose to close the file (only after the last question is answered)
Here's my problem:
While processing the results, some text files only contained 69 (or less) answers and other contained 71 (and even a single 73) answers. What went wrong here? Did some answers get lost (how could this happen?) and how is it possible that there are more answers than questions? Is it the impatience of some people who click twice, or can it be a PHP coding problem?
Also the directory sometimes showed a .txt file, does this indicate that the counter hasn't been sent with the question results and a new file has been made? (The file showed some 'yes/no' answers.)
It's essential for the reliability of the questionnaire for me to know whether I must remove all the results if the total answers are not 70 (because you don't know where it went wrong), or that I can use the results until, say, 69 (because it went wrong at the end).
I realise these are not easy questions to answer, but I hope you can tell me more about it. I'm planning to use this PHP method more often, so it must become reliable.
Thanks in advance.
Alexander