/    Sign up×
Community /Pin to ProfileBookmark

Advice on a quiz

Hey so I am doing this quiz and the questions will be based on the answers you give before so if it asks are you male and you say yes it question #2 will be do you shave your beard and if you said no question #2 would be do you shave your legs?

I would just like some advice on this maybe what direction to head to and how to make it dynamic as possible.

Thank you in advance!

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 15.2009 — Perhaps a database with a table of questions, and then a second response table which would point to the next question:
question_id
response
next_question_id

So you would retrieve the starting question from the question table, then get the next question via the above relational table. You might add another column to it to point to a "final result" table for responses that finish a chain.
Copy linkTweet thisAlerts:
@Mr_Initial_ManDec 16.2009 — Are the questions based solely on what gender you are?
Copy linkTweet thisAlerts:
@papilindo701authorDec 16.2009 — Are the questions based solely on what gender you are?[/QUOTE]

Well depending on what path you choose the questions start changing so i guess it depends on gender. What i am thinking is to do a series of IFs for each question like if user clicked yes to this do this. I am looking for a way to maybe streamline that more

thank you
Copy linkTweet thisAlerts:
@Mr_Initial_ManDec 16.2009 — What I would do, to be honest, is get a pen and a piece of paper, and actually do a physical map of the paths the questions should take. That may help you create your program.
Copy linkTweet thisAlerts:
@papilindo701authorDec 16.2009 — What I would do, to be honest, is get a pen and a piece of paper, and actually do a physical map of the paths the questions should take. That may help you create your program.[/QUOTE]

I have a map and i wrote all the ifs. Is there a way to specify a path in php like say take teh path of 1 then 2 then 3. Then have an array with questions 1 2 3 in it
Copy linkTweet thisAlerts:
@Mr_Initial_ManDec 16.2009 — What you COULD do, and this is going to sound odd: Take the map, and code it like an array, using the answers as array keys. That way, the answers could select which array of questions is used.
×

Success!

Help @papilindo701 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...