Jump to content

Personality Quiz


texximan

Recommended Posts

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!

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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...

Link to comment
Share on other sites

<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.

Link to comment
Share on other sites

  • 4 months later...

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...

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.