Link to home
Start Free TrialLog in
Avatar of Stephen Forlance
Stephen Forlance

asked on

Survey branching tutorial

Does anyone know of a good tutorial on building a survey system using PHP.

I'm having trouble wrapping my head around how branching on a survey works (where some questions are hidden unless the answer to another equals something), in particular how the concept would work in terms of storing that data in a table and then using it at run time.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

I am sure there are many patterns out there for this. I use the following method

I have a routing table that allows me to specify
a question
an answer
a destination
a value to say equal or not equal

On each question I check that table - I look for the question number, get the answer and check to see if the actual answer for that question matches. If it does I check the equal not equal value. If this is set to NotEqual and the answer given does NOT match the answer value in the table then I jump to the next question. If they are equal I allow the current question to continue - vice versa if they values must be equal.

All questions have a stack to say where they came from so that if you branch and someone hits the back button you go back to the branch point not the previous question in the section.

Best I can do for now - if you want to pursue it more post back and I will see if I can put a sample together.
Avatar of Stephen Forlance
Stephen Forlance

ASKER

Any samples you could give would be great
thanks
Any particular reason you are building your own and not using something like Moodle or similar?
The reason is basically because I want to know the system inside and out, and secondly its something that Ive been thinking about for few years now, and its its at the edge of my understanding, so Id like to conquer it :)
How far have you got? If you are just starting out then you have a journey ahead of you. Our survey engine has been developed over the last 17 years - we keep refining it to cater for new requirements - so the question is how much of a head start do you need - because it could take a while to provide a demo from scratch.
My sense is that reinventing your wheel when a well-known solution already exists is probably an antipractice.  Go Pro on SurveyMonkey!
My sense is that reinventing your wheel when a well-known solution already exists is probably an antipractice.
Might be stuck with the Model 'T' if we always adopted that approach :)
I think SurveyMonkey is one of the tools Experts-Exchnage has used for its surveys.  If SurveyMonkey were stuck in the steady state with respect to time, I would agree about the Model T, but I think they are a going concern with active development.  IIRC, ConstantContact has surveys, too.  And Google.
https://www.experts-exchange.com/questions/28934183/Survey-software.html
https://www.experts-exchange.com/articles/18199/Top-5-Best-Practices-for-Conducting-Surveys-with-Google-Forms.html
Fine, but there is never a good reason to innovate. By continually revisiting products / problems we find other products or improve existing one.
SM is a good tool but it left a gap that Qualtrics was able to fill.
Ive figured out the basics in terms of questions and options etc, but what i was trying to work out is how to store the branching information in  a database and then call it to logically effect the flow of the survey.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial