texximan Posted June 18, 2010 Share Posted June 18, 2010 Hey all! I am new to these forums, but this seems like a really good place for information. I am a beginner in PHP coding, so I don't have that much experience with how to do quite simple tasks. I have a job to fulfill and I have to create a personality quiz, which basically means a user answers about eight questions with three choices and then he will be dubbed as one of six different personalities. I've tired doing this, believe me, but I just don't get it to work. Are there any websites, downloads, or words of advice you guys could give me? And no, I will not be using one of those quiz generators online; it should be made from raw code. Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/ Share on other sites More sharing options...
mentalist Posted June 18, 2010 Share Posted June 18, 2010 You should start by posting some code then we can go from there... Basically you'll need your quiz form (in html), and then a php form handler. To start with for you i'd say stick to one page. Are you using a database or flatfile to store results, or just want to display them. <html><body> <?php if(isset($_POST['submit'])){ if($_POST['q1']=="blue"){print "correct<br />";} else{print "wrong<br />";} } ?> <form method='POST' action=''> What colour is my hair?<br /> <input type='text' name='q1' size='32' value='red'><br /> <input type='submit' name='submit' value='Submit'> </form> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073855 Share on other sites More sharing options...
Adam Posted June 18, 2010 Share Posted June 18, 2010 We really need to know more about the logic behind the quiz, how do the 8 questions relate to the 6 personalities? What decides which you fall under? Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073856 Share on other sites More sharing options...
mentalist Posted June 18, 2010 Share Posted June 18, 2010 this is what I base my personality quizzes on... http://en.wikipedia.org/wiki/Myers-Briggs_Type_Indicator Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073858 Share on other sites More sharing options...
Adam Posted June 18, 2010 Share Posted June 18, 2010 this is what I base my personality quizzes on... http://en.wikipedia.org/wiki/Myers-Briggs_Type_Indicator Deep. How often do you make personality quizzes? I don't think he's after the logic though, sounds like that's already prepared he just needs to put it to code. Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073861 Share on other sites More sharing options...
texximan Posted June 18, 2010 Author Share Posted June 18, 2010 Yeah what he said. I already know the questions and all that, I just need to know how to make the quiz itself. And yeah, just to be clear: there are to be eight different questions in my quiz, and three different possible answers for each question (of which the user answers only one), and depending on all the different answers for the questions the user gave, he will be dubbed as one type of personality. I hope it makes sense. I know the logic behind I just need to know how to do it in pracitce. this is what I base my personality quizzes on... http://en.wikipedia.org/wiki/Myers-Briggs_Type_Indicator Deep. How often do you make personality quizzes? I don't think he's after the logic though, sounds like that's already prepared he just needs to put it to code. Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073870 Share on other sites More sharing options...
texximan Posted June 18, 2010 Author Share Posted June 18, 2010 The most important factor is that the user sees the result, his 'personality', after clicking ''submit''. Having this user's answers stored somewhere isn't that important. Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073871 Share on other sites More sharing options...
Adam Posted June 18, 2010 Share Posted June 18, 2010 Sorry by logic I mean, how do the answers to the 8 questions map against the 6 personalities? Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073877 Share on other sites More sharing options...
texximan Posted June 18, 2010 Author Share Posted June 18, 2010 Ohh... Unfortunately, I don't have anything mapped out. Because I don't know how the code will work, I don't know how the different questions and answers will determine what personality the person will result to be. I am hoping that if I understand the code somewhat and know how it works, then I can figure out how it will logically work. Sorry for my n00bness. Sorry by logic I mean, how do the answers to the 8 questions map against the 6 personalities? Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073885 Share on other sites More sharing options...
Adam Posted June 18, 2010 Share Posted June 18, 2010 So.. you don't have the logic all planned out? That's probably going to be the most crucial part of your application. By logic I don't mean PHP logic, I just mean general logic of the quiz; e.g. if the user answers 'a' to every question he's x personality. Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073886 Share on other sites More sharing options...
mentalist Posted June 18, 2010 Share Posted June 18, 2010 <html><body> <?php if(isset($_POST['submit'])){ if($_POST['q1']=="blue"){ print "correct<br />"; } else{ print "wrong<br />"; } } ?> <form method='POST' action=''> What colour is my hair?<br /> <input type='text' name='q1' size='32' value='red'><br /> <input type='submit' name='submit' value='Submit'> </form> </body></html> There's an example. A html form and php handling for it. I did wonder if you'd be wanting to use radio style selection instead of text, but... Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073887 Share on other sites More sharing options...
Adam Posted June 18, 2010 Share Posted June 18, 2010 <html><body> <?php if(isset($_POST['submit'])){ if($_POST['q1']=="blue"){ print "correct<br />"; } else{ print "wrong<br />"; } } ?> <form method='POST' action=''> What colour is my hair?<br /> <input type='text' name='q1' size='32' value='red'><br /> <input type='submit' name='submit' value='Submit'> </form> </body></html> There's an example. A html form and php handling for it. I did wonder if you'd be wanting to use radio style selection instead of text, but... No offence, but that's a bad way to do it. For that actual quiz storage, you'll want to set up a table within the database to store the questions, with a unique question ID for each. Another table to store the answers (with a foreign key linking to the question ID), again with a unique ID for each. Then depending upon whether you want to store the users' answers, you'll need a third table for the results (with 2 foreign keys linking to the question ID and answer ID). If not then you could temporarily store their answers within a session variable. As I was getting at before though, the exact fields for the tables could vary depending upon the logic of the quiz. Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1073890 Share on other sites More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 Not been about for a while, so... @MrAdam, I purposefully didn't use a database, and kept the whole thing simple and clear, because texximan states in a couple of places his current / then level of competency of coding. But yes, in the real world, my code would be very different too... Quote Link to comment https://forums.phpfreaks.com/topic/205156-personality-quiz/#findComment-1126148 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.