I'm creating an online survey tool wherein I have a set of questions with some radio button options in it. Whenever I'm creating a survey, I can set the conditions like for example, I select question 1 which has 5 options for it and based on the options that I select, I will be taken to question 2 and so on. I want to implement this logic using java/jsp/servlets. The jsp/servlet part is later but for now I want to know what packages in java that will help me do this??
[ May 17, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
It is probably best to keep the code that displays the pages and collects the results generic. That means that the server reads the survey description from a file, where the questions to display and the types of answers expected (text, checkbox, radio buttons) is listed for each page. Then you can use the same code later (or even simultaneously) for other survey.
I have a tool wherein the administrator can actually select the questions for today's survey and branch out conditions based on his selection.
So that means that the questions for each survey are stored in a DB? That's even better than a file.
But in that case I don't understand what exactly you are asking or need help with.
If you see some commercial survey tools, the questions that appear on the survey changes according to the user's response. I want to create a system which has a set of say 50 questions with 4 options to select (in the form of radio buttons). Now I'm the administrator, so I log on to the system and I configure the questions. Like I select 10 questions for a survey and I can configure those 10 questions in such a way that based on the answer for the first question, I will be directed to the next question or questions 3 and so on. I want to implement this logic. I have alreday done a sampling of it using a database, but I want to know if I can create a generic class without a database that can handle such a situation??
I have alreday done a sampling of it using a database, but I want to know if I can create a generic class without a database that can handle such a situation?
You can certainly do that, but why would you? If the data isn't stored anywhere, what would the application do if the server went down? All data would be lost.
I want to implement this logic. I have alreday done a sampling of it using a database, but I want to know if I can create a generic class without a database that can handle such a situation??
Of course you can create a class that defines all the possible flows of users through a survey in terms of the question numbers from some master list. Make it serializable so it can be saved and restored if the server restarts. Given that you want to handle branching in the survey this class is not going to be simple.
1. Whats the form of the master list of questions? (I would use XML since you don't want to use a database)
2. How do you maintain the history of a given user's responses?
3. How do you save that history for analysis?
Originally posted by Ulf Dittmer:
.... what would the application do if the server went down? All data would be lost.
What about doing a file open, say in init(), and partially writing the file.
If the server goes down (unexpected condition) there's a mess to clean up anyway - something I am giving deep consideration to in my main() class - and a partially written file may or may not be recoverable due to issues reservered to the underlying OS [correct ?] so it's a productive challenge, but I like the original poster would rather write things in a class where I could see exactly what was going on.
Note: I recognize that this approach tends to incite deep loathing in some Grand Masters.