Jump to content

php what kind of .. are you quiz


seenm

Recommended Posts

Hi,

 

I'm trying to build a quiz like you find it in many womens magazines. what kind of blond are you, which desperate housewife are you etc. so its questions to which no answer is wrong or right. a small example http://www.sofeminine.co.uk/mag/psycho/d2114/x13554.html.

 

so far i have created an admin area in which i can make a quiz, here i decide how many questions and conclusions (you are as blond as paris hilton) there will be. after that you enter the conclusions , after that you enter the questions,answers and which conclusion goes with which answer. this is all saved in a database of course.

 

now im trying to build the front end, all the questions are shown and all the answers have become a radio button but i just cant think of a way how to "calculate the conclusion". all answers have the id of the conclusion which they are part of. does anyone have an idea how to do it?

Link to comment
Share on other sites

Base your conclusions on a LINE of sorts such as 0-100. In your example, 0 being not blonde at all and 100 being extremely blond. Have each answer give a numerical value and add it all up along the scale. Allow the creator to give "weight" to each answer.

Link to comment
Share on other sites

thinking this through, it doesn't work out. e.g. i got 15 questions and i would answer 4 times 100 and 11 times 25. now in this case i should get to conclusion A cause thats what i selected most. but with this system i would get to conclusion B cause calculating everything together would get me closer to answer B then to A.

Link to comment
Share on other sites

Give the answer that proves to be most blond a value of N where N is the number of possible answers to the particular question. The next least blond answer N-1 next N-2 and so on until you have the least blond answer having a value of 1. Do this for each question. If the questions have the same number of answers divide the running total by the number of questions and set your classifications based upon the average.

 

Link to comment
Share on other sites

give weighted answers, as stated:

each question is worth a total of 50 points, no matter how many questions you have (you *can* do math in PHP)

if they answer one way, they get 0 points, and it goes up, 1/# of the options (if you have 5 questions, you do 1/5 increase each time, until you get to the last one, which is the question most in line with the ultimate result)

then at the end, you do the math on the total (if you have 5 questions, it's answer1 + answer2 + answer 3 + answer4 + answer5 /5) and that's their score out of the total available.  then you can get a percentage out of that.

Link to comment
Share on other sites

Don't let the snide comments of others get you down. Everybody has to start somewhere and even though some people appear to be born with the ability to write php applications the norm is to learn over time.

 

With that in mind remember that emotions are hard to interpret through text and can be commonly mis-interpreted. If somebody seems to be acting rude through their posts, it may be that that is the way they operate.

 

Good Luck programming.

Link to comment
Share on other sites

if it was me, I have a bad habit of writing in "stream of thought" mode. no emotion can be interpreted from it, unfortunately. I want to get the ideas down as I think of them, and I can't type as fast as I think, which makes it seem like I'm writing to a 3rd grader, when I'm just expressing my idea/opinion. sorry about that.

Link to comment
Share on other sites

i thought it was solved but thinking it through, i still got the same problem. i received a few of the quizes my client wants to do and the answer are not weighted. they are really like if you got most answers which correspond to A then conclusion A is for you.

 

Lets say there are 15 questions and every time there are 4 answers. your first 8 answers are A and the next 7 always D. you will end up at B not at A.

 

so there is no php function that could determine the most occurring answer (string) in an array for example. if i give the answer the value of the conclusion (id).  so conclusion A=30, B=31, C=32, D=33. and after the question i have a list of like this (31,31,33,31,31,32,31,33,33,31) now this function should find the string that most occurs, in this case 31. because 31 is the id of conclusion A it should display that.

 

tell me if im wrong or not.

Link to comment
Share on other sites

If you don't want it weighted and you just want the most of a particular answer, E.G. selected option A more times than any other option. Then one way you can do it is just have an array of 4 values.

$answers = array(0, 0, 0, 0);
echo $answers[0];  // Will output the number of questions answered with option A
echo $answers[1];  // Ditto ^ exception with option B

That could work for $answers 0 to 3 with 3 being option D. Each time they give an answer, run a switch statement and add to the appropriate array index. In the end, compare the indexes of the array and the highest one will be the result. You will run into a problem if two are equal though, so you'll need to plan out an outcome for that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.