On Sat, Mar 13, 2010 at 11:10 AM, tedd <tedd.sperl...@gmail.com> wrote:
> Hi gang:
>
> I just completed writing a survey that has approximately 180 questions in it
> and I need a fresh look at how to store the results so I can use them later.
>
> The survey requires the responder to identify themselves via an
> authorization script. After which, the responder is permitted to take the
> survey. Everything works as the client wants so there are no problems there.
>
> My question is how to store the results?
>
> I have the answers stored in a session variable, like:
>
> $_SESSION['answer']['e1']
> $_SESSION['answer']['e2']
> $_SESSION['answer']['e2a']
> $_SESSION['answer']['e2ai']
> $_SESSION['answer']['p1']
> $_SESSION['answer']['p1a']
> $_SESSION['answer']['p1ai']
>
> and so on. As I said, there are around 180 questions/answers.
>
> Most of the answers are integers (less than 100), some are text, and some
> will be null.
>
> Each "vote" will have a unique number (i.e., time) assigned to it as well as
> a common survey id.
>
> My first thought was to simply record the "vote" as a single record with the
> answers as a long string (maybe MEDIUMTEXT), such as:
>
> 1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,
>
> Then I thought I might make the data xml, such as:
>
> <survey_id>1</survey_id><vote_id>1268501271</vote_id><e1>1</e1><e2>16</e2><e2a>Four
> score and ...</e2a><e2ai></e2ai>
>
> That way I can strip text entries for <> and have absolute control over
> question separation.
>
> Then I thought I could make each question/answer combination have it's own
> record while using the vote_id to tie the "vote" together. That way I can
> use MySQL to do the heavy lifting during the analysis. While each "vote"
> creates 180 records, I like this way best.
>
> Then I thought, what would you guys do? So, what would you guys do?
>
> Keep in mind that this survey must evaluated in terms of answers, such as
> "Of the ones who answered e1 as 1 how did they answer e2?"
>
> If there is something wrong with my preference, please let me know.
>
> Thanks,
>
> tedd
>
> --
> -------

Tedd,

Sorry to be jumping in late, trying to migrate from yahoo mail to
gmail since I'm experiencing more problems with yahoo mail then I'd
like.  Any way, I'd go with db storage for storing of the results
since it will give better and more flexible analysis and reporting
later.  Below is how I'd do the db structure:

tbl_survey_questions:
questionId = int / uid << your call
languageId = int / uid / char << your call if you intend to I18n it ;)
question = varchar << length is your requirement
PK > questionId + languageId

tbl_participants:
userId = int / uid
userName = varchar
PK > userId

tbl_answers:
userId = int / uid
questionId = int / uid
languageId = int / uid
answer = varchar / mediumtext / or another type of text field
PK > userId + questionId + languageId

The reason why I'd structure it like this is:

Let's say you have question 1 with 5 (a-e) multiple choices, you
aggregrate your query (GROUP BY) to db for question 1 and see how many
responses are for a to e (each).  If your survey is I18n and your DB
reflects it, you can even analyze how/why certain cultural background
would choose each of those answer. (don't flame me... I know the
environment comes in to growing up too :p and that's way beyond the
scope of this list )

For question 2 with could be user entry (non multiple choice
selection), again, you see what their opinions are for that question.
You get the idea as how the rest may go.

I used to do lots of reporting with the real tool, Crystal Report ;)

Regards,
Tommy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to