473,473 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Writing a Questionnaire/Survey

Hi,

Here's a worthy challenge for ya'll. I'm trying to build a
questionnaire in php and need help understanding the logic behind the
process. Here's an example that explains everything:

1) What quality is most important to you in a car?
a) Reliability
b) Affordability
c) Large size

2) How important is gas mileage?
a) Very important
b) Not at all important

If a user chooses 1a, 2b, the program writes "you will probably like a
Volvo SUV (reliable, gas-guzzling)".
If a user chooses 1b, 2a, the program writes "you will probably like a
Chevrolet Cavalier (cheap, efficient)".
If a user chooses 1c, 2b, the program writes "you will probably like a
GMC Yukon SUV (large, gas-guzzling)".
If a user chooses 1a, 2a, the program writes "you will probably like a
Honda Civic compact (reliable, efficient)".

.... and so on ...

Basically, a user makes some radio-button choces, and the script
matches the choices to some database records filled with vehicle
information. Because I want to have more than 2 questions, I can't
even begin imagining the difficulty of hard-coding all possible choices
- behold the power of a factorial :)

What would be the logic/algorithm for something like that? What would
be the database structure?

May 5 '06 #1
8 2773

ma*******@gmail.com wrote:
Hi,

Here's a worthy challenge for ya'll. I'm trying to build a
questionnaire in php and need help understanding the logic behind the
process. Here's an example that explains everything:

1) What quality is most important to you in a car?
a) Reliability
b) Affordability
c) Large size

2) How important is gas mileage?
a) Very important
b) Not at all important

If a user chooses 1a, 2b, the program writes "you will probably like a
Volvo SUV (reliable, gas-guzzling)".
If a user chooses 1b, 2a, the program writes "you will probably like a
Chevrolet Cavalier (cheap, efficient)".
If a user chooses 1c, 2b, the program writes "you will probably like a
GMC Yukon SUV (large, gas-guzzling)".
If a user chooses 1a, 2a, the program writes "you will probably like a
Honda Civic compact (reliable, efficient)".

... and so on ...

Basically, a user makes some radio-button choces, and the script
matches the choices to some database records filled with vehicle
information. Because I want to have more than 2 questions, I can't
even begin imagining the difficulty of hard-coding all possible choices
- behold the power of a factorial :)

What would be the logic/algorithm for something like that? What would
be the database structure?


May 5 '06 #2
omg, i wrote out this huge page of how i would implement your
questionaire..... but it somehow go lost because my 'Nickname'........
AHHHH!!!!!

May 5 '06 #3
NC
ma*******@gmail.com wrote:

Basically, a user makes some radio-button choces, and the script
matches the choices to some database records filled with vehicle
information. Because I want to have more than 2 questions, I can't
even begin imagining the difficulty of hard-coding all possible choices
- behold the power of a factorial :)

What would be the logic/algorithm for something like that? What
would be the database structure?


The logic is that of scoring and weighing.

First, you assign attribute scores to each vehicle (let's say, you have
three scores: reliability, fuel economy, and price, all on a scale from
1 to 10, with 1 being "extremely poor" and 10 being "excellent"). So
you have a table in a database with fields like this:

id (int)
make (varchar)
model (varchar)
year (int)
reliability (int)
economy (int)
price (int)

Then, you use user responses to elicit which score is most important to
a particular user (each question can add points to relative importance
of one or more scores). How you weigh the results is entirely up to
you. You can use raw points or simply give a weight of 3 to the most
important score, 2 to the next in order of importance, and 1 to the
least important.

Let's say you decided to store reliability, economy, and price weights
in three variables, $w_reliability, $w_economy, and $w_price. Now you
can form your query, execute it, and display results:

$year = '2007';
$query = <<<EOQ
SELECT make, model,
($w_reliability * reliability +
$w_economy * economy +
$w_price * price) AS composite_score
FROM vehicles
WHERE year = $year
ORDER BY composite_score DESC
LIMIT 5
EOQ;
$result = mysql_query($query);
echo "Your responses indicate that you might be interested in: \r\n";
while ($record = mysql_fetch_array($result)) {
echo $record['make'], ' ', $record['model'], "\r\n";
}

Cheers,
NC

May 5 '06 #4
I feel so-o-o-o-o bad ... Thank you for trying!

May 5 '06 #5
Simply awesome. Many thanks.

May 5 '06 #6
I'm following you.

However, I don't understand how I would tie in the second question
about the importance of gas mileage.

Suppose I have the field 'mileage' in the database. All vehicles are
scored on the 10-point scale depending on how gas-guzzling they are.
So a Cav is 7, Focus is 7, Civic is 8, Prius is 10, VW TDI is 10, Aveo
and Echo are 9, Ford F-150 is 2, Humscalade is 1, etc.

How would I tie that question in with the logic is the question asks
"important" or "not important"? But even before that, what values do I
give to each radio button of each question?

Thanks again.
The logic is that of scoring and weighing.

First, you assign attribute scores to each vehicle (let's say, you have
three scores: reliability, fuel economy, and price, all on a scale from
1 to 10, with 1 being "extremely poor" and 10 being "excellent"). So
you have a table in a database with fields like this:

id (int)
make (varchar)
model (varchar)
year (int)
reliability (int)
economy (int)
price (int)

Then, you use user responses to elicit which score is most important to
a particular user (each question can add points to relative importance
of one or more scores). How you weigh the results is entirely up to
you. You can use raw points or simply give a weight of 3 to the most
important score, 2 to the next in order of importance, and 1 to the
least important.

Let's say you decided to store reliability, economy, and price weights
in three variables, $w_reliability, $w_economy, and $w_price. Now you
can form your query, execute it, and display results:

$year = '2007';
$query = <<<EOQ
SELECT make, model,
($w_reliability * reliability +
$w_economy * economy +
$w_price * price) AS composite_score
FROM vehicles
WHERE year = $year
ORDER BY composite_score DESC
LIMIT 5
EOQ;
$result = mysql_query($query);
echo "Your responses indicate that you might be interested in: \r\n";
while ($record = mysql_fetch_array($result)) {
echo $record['make'], ' ', $record['model'], "\r\n";
}

Cheers,
NC


May 6 '06 #7
>However, I don't understand how I would tie in the second question
about the importance of gas mileage.

Suppose I have the field 'mileage' in the database. All vehicles are
scored on the 10-point scale depending on how gas-guzzling they are.
So a Cav is 7, Focus is 7, Civic is 8, Prius is 10, VW TDI is 10, Aveo
and Echo are 9, Ford F-150 is 2, Humscalade is 1, etc.

How would I tie that question in with the logic is the question asks
"important" or "not important"? But even before that, what values do I
give to each radio button of each question?


If something is VERY IMPORTANT, give it a weight of, say, 10.
If something is IMPORTANT, give it a weight of, say 3.
If something is NOT IMPORTANT, give it a weight of about 0.
If something is UNDESIRABLE, give it a weight of, say, -3.
If something is VERY UNDESIRABLE, give it a weight of, say, -10.

The exact numbers are not critical and depend somewhat on how related
the characteristics are. If you multiply all the weights on all
the questions by X (X a positive number), you really haven't changed
anything in the relative ranking.

If you're only going to give two levels of answer, e.g. price:
important or not important, low price should probably have some
positive weight even for those choosing "not important", since "not
important" is not equivalent to "don't care AT ALL" and there's no
other way to say "don't care AT ALL".

Sometimes people consider a feature normally thought of as desirable
as undesirable. For example, HORSEPOWER is often thought of as
good, but if I'm buying a car for my teenage son, it's a NEGATIVE,
as I don't want him to even try hot-rodding with it. Large size
might generally be considered a positive for a large family, but a
negative for a commuter who wants something easy to park in a small
space. I don't know of anyone who thinks good gas mileage is a
negative for their own car except that good gas mileage might imply
non-sportiness. I don't know of anyone who thinks higher price is
a good thing except that low price might imply unreliability.

Gordon L. Burditt
May 6 '06 #8
NC
TristaSD wrote:

I'm following you.

However, I don't understand how I would tie in the second question
about the importance of gas mileage.

Suppose I have the field 'mileage' in the database. All vehicles are
scored on the 10-point scale depending on how gas-guzzling they are.
So a Cav is 7, Focus is 7, Civic is 8, Prius is 10, VW TDI is 10, Aveo
and Echo are 9, Ford F-150 is 2, Humscalade is 1, etc.

How would I tie that question in with the logic is the question asks
"important" or "not important"?


It's entirely up to you. You could say that "important" would add, say
7 points to the relative importance of fuel economy, while
"unimportant" would not change that weight. Or, you could rewrite the
question to something like, "On a scale from 1 to 10 (1 being
absolutely unimportant and 10 being extremely important), how important
is fuel economy to you?" and put a <SELECT> menu next to it.

Cheers,
NC

May 6 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Steve Wylie | last post by:
At work we use SNAP survey software. The software is capable of outputting a survey as a web page, in HTML, which we can tart up with Javascript for basic form validation if required. When the...
1
by: jmgro | last post by:
I need help in structuring a 200 question survey. Each question has three responses, and I want all 200 questions displayed at the same time with the user using the scrollbar to go down. What is...
3
by: Jason A. Thompson | last post by:
Dear Access Gurus, I have a database which I hoped to use to administer questionnaires, or rather that someone who knows nothing about Access could use to administer them. Each q'aire item is on...
3
by: krygsma | last post by:
So, I need to figure out how to do what I want to do with Access. I have many questions with mutually exclusive options, each option has a value, never=0, few times=1...ect.. (then when questions...
3
by: Tom_F | last post by:
To comp.databases.ms-access -- I have a questionnaire for which I would like to design a MIcrosoft Access form. I understand that the proper Access table structure would be: Respondent_ID ...
1
by: javedna | last post by:
Can PHP help with the following as I have tried in the MYSQL Forums and cant get any help Thanks Nabz ---------------------------------------- Hi I am developing a PHP MYSQL questionnaire...
7
by: javedna | last post by:
Hi guys Ive got a simple problem, im designing an online questionnaire and on submission the coding that I have used to validate whether a user has filled in all the questions is supposed to...
12
by: Gabriel | last post by:
Hi All, (First my apologies for this kind of "spam" message. But for my thesis this will be my once in a lifetime spam moment... ) At the moment I have to graduate for my master in Business...
6
by: Lakesider | last post by:
Dear NG, I want to create a dynamic questionnaire/survey application with .NET / C#. I want to ask questions and have several answer types: Yes/No, 1-10, list of answers, eg. "Dog", "Bird" and...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.