Hi Guys,
I will shortly be working on a survey module, and would like to ask for some advise on the design.
A survey will have question and a question will have options.
How would you then go about creating a per user survey object which holds the questions with their answers?
ie, i want to define one survey, but have different answers for each user, but would like to pull it back in a way that i can just work with one object that contains the questions and answers.
hopefully you get the idea of what i mean, but if you need clarifiction please let me know.
any help appreciated
Matt
Matt
For this sort of thing, I'd have a set of Questions associated with a Section, and probably a Survey since it is likely a module would serve more than one Survey over time. Depending upon the Question type, you could have a number of AnswerOptions for each Question or free text (or a number range, if you want to get really flexible).
Actual Answers would be associated with a Question and a User (or sessionID if you want to allow anonymous surveys). How you store the Answers depends on whether you just have predefined AnswerOptions (easiest), or allow free text and number ranges (in which case you may also have to consider answer validation).
A survey would have a QuestionList property (or something), and a Question have an AnswerOptionList property. These define a template. As far as answers go, you will need to consider what you want to do with them. You will have a *lot* of data for each Survey (assuming the surveys are reasonably popular) so individual answers might not be that useful to you. You would probably deal with some sort of report, or a class representing aggregated data. I spent many months writing a complex survey web application and had to solve all manner of problems such as these.
Many thanks
Simon
Hi Simon,
Thanks for that, very usefull.
My surveys will be of the more complex nature with free text answers, and numbers for putting options in order of importance, as well as coordinates for a graph type question where a user will say where they see themselves in relation to other options.
One of the things i'm still trying to figure out is how a survey object works on a per user basis? Would the survey hold all answers for all users? or would you have something like a survey class which you setup all the questions with and then a usersurvey object which extends the survey?
any help appreciated
Matt
Matt
I would recommend the Survey being responsible for Questions only. Having a property of UserAnswerList, for example, isn't very helpful because:
* There are a huge number of results and you would run out of memory accessing them all in one go
* You are more concerned with the response to a particular Question. Even so, there will still be a huge number of results for each question
Assuming that each survey happens only once, you would have the supplied Answer with a reference to the Question, which, in turn, would have a reference to the Survey. You might also have a reference to the AnswerOption, depending upon the type of question.
You could have a SurveyReporter class, or something, that tells you how many people responded, the number of answers with a particular value etc. It is unlikely a class extending Survey would be useful, or that dealing with individual responses would be helpful. At the end of the survey, you might even delete all of the answers and store a summary of them in another table.
Many thanks
Simon
Cheers Simon,
Thats pretty much how i thought to do it, i just wasn't sure if there was a better way to do it using some sort of inheritance.
Matt