Best way to code a survey/quiz for website?

nedfunnell

Senior member
Nov 14, 2009
372
0
76
Hello,
I'm pretty old-school with web development. Years ago I maintained a website, but it was all hand-coded HTML. I'm been called on to make a website for the non-profit I work for. We need to have a survey/quiz on it. What we need is to present the user with a 'quiz' of 10 questions, which are all multiple choice. Then when the user is done, they (ideally) are taken to a page which is dynamic based on their responses- there are right/wrong answers for each question, and we'd like for the page to show them the answers but with their right/wrong next to the answer. Also, we'd like to have their "You got X/10 right" score presented. I don't want to call it a survey, because we don't really care about their responses/data. If it's easily available, then cool, but we don't need it.

Does anyone know of a good way to add this functionality to a website?
(Alternately, does anyone want a tax break for their time coding for a non-profit?)
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
It depends on how advanced you want this quiz to be. If you want to have static questions, answers that don't really change anything, and results pages that, while they do show real results, they don't store any information. Then you could do this all with javascript and cookies fairly simply.

If you want to store results, then it becomes much more complex. You'll need a backend language, some sort of database, and proper handling of input (attack resistant).
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
For fixed questions, a static HTML page POSTing to a PHP / Pearl / ASP / whatever script page to score and show results would be pretty simple. With PHP and ASP it's easy to mix script and raw HTML.

Or, like Cogman says, it could be done using Javascript to re-write parts of either the quiz page or a separate results page. For example, put a [ Score ] button on the page, with an onclick="scoreFunction()" that uses IDs you've pre-placed to add green checks and red Xs and change one area from empty to the "score is 5/15" text).
 

nedfunnell

Senior member
Nov 14, 2009
372
0
76
That all sounds good- do you think that it is something that a coding novice like myself could handle, or perhaps is there code somewhere I could tailor to my needs?
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
That all sounds good- do you think that it is something that a coding novice like myself could handle, or perhaps is there code somewhere I could tailor to my needs?

What you are doing will determine the answer to that question. I can't tell you if something will be too hard until you give me a bit more details about what that thing is.

Doing simple static pages and javascript (even a little php/perl/ASP/etc..) isn't going to be to bad. Interacting with Databases is about the point where things get hairy.

In other words, Do you plan on storing any sort of information about the quiz on the server and are you planning on using that information in any meaningful way? If the answer is yes, this can be quite difficult (depending on what you are doing with the data). If the answer is no, this shouldn't be too bad.
 

nedfunnell

Senior member
Nov 14, 2009
372
0
76
No database, no information collection required.

Where should I start on trying to do this?

Edit: Some more info.

The ideal site is this. The quiz page just has the questions on it, radio buttons, etc. When the user clicks "Submit" it takes them to a second page that has the answers to each of the questions on it, and a status marker (red X/green check, etc) on it. A button to print on the second page would be good but I'm thinking that's probably dead simple.
 
Last edited:

Cogman

Lifer
Sep 19, 2000
10,283
134
106
No database, no information collection required.

Where should I start on trying to do this?

Edit: Some more info.

The ideal site is this. The quiz page just has the questions on it, radio buttons, etc. When the user clicks "Submit" it takes them to a second page that has the answers to each of the questions on it, and a status marker (red X/green check, etc) on it. A button to print on the second page would be good but I'm thinking that's probably dead simple.

How often do you plan on adding new quizzes and how many quizzes do you plan on having?

If it is a lot, then I would look at doing a database where each quiz is stored on the database and rendered on the fly. If it is a little, then I would just whack out the html and either submit to a simple perl/php/asp script or even process stuff on the same page using javascript.

I would start by learning javascript, then a backside language such as Php, perl, or ASP (C#, not vb, don't ever do vb :p), followed up by looking up some database stuff. Doing it in that order should cover everything you need as your requirements expand/shrink.

You can test this stuff by either installing IIS or apache server on your personal PC.
 

nedfunnell

Senior member
Nov 14, 2009
372
0
76
How often do you plan on adding new quizzes and how many quizzes do you plan on having?

If it is a lot, then I would look at doing a database where each quiz is stored on the database and rendered on the fly. If it is a little, then I would just whack out the html and either submit to a simple perl/php/asp script or even process stuff on the same page using javascript.

I would start by learning javascript, then a backside language such as Php, perl, or ASP (C#, not vb, don't ever do vb :p), followed up by looking up some database stuff. Doing it in that order should cover everything you need as your requirements expand/shrink.

You can test this stuff by either installing IIS or apache server on your personal PC.

Thanks for the info- it's just two quizzes that will never change significantly.

I just found out I need to have this done by Thursday, so... yeah, not really enough time to learn Javascript or any other language. So it looks like it will be going up in plaintext unless somebody wants to claim a tax break for their time. (Anyone?)
 

AyashiKaibutsu

Diamond Member
Jan 24, 2004
9,306
3
81
I'd setup a database especially if there's more than one quiz. 0, 1, many rule : p The code for it wouldn't be hard at all at least not with aspx/c#/MS sql server. Not sure if it's significantly harder with other languages.
 

nedfunnell

Senior member
Nov 14, 2009
372
0
76
I've been looking for some free software that will let me make a quiz- I tried KompoZer but it doesn't look like it has that ability. I just realized that I could put this together in flash, which we have an old version of. Does anyone here anticipate problems with doing this in flash?
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
I've been looking for some free software that will let me make a quiz- I tried KompoZer but it doesn't look like it has that ability. I just realized that I could put this together in flash, which we have an old version of. Does anyone here anticipate problems with doing this in flash?

The biggest problem with using flash is that you are using flash :p.

Really, for something simple like this flash is just a bit much, plus it makes it so everything that is taking your quiz must support flash. While most things do, not everything does (think apple stuff, iPhone, iPad, etc).

Other than being a bit much for a quiz, if you already have it available to you then I really don't see too big of an issue using it.
 

nedfunnell

Senior member
Nov 14, 2009
372
0
76
Yeah, it turns out that I can't use flash anyway- the mac we got donated is an old Mac Mini and when we put Snow Leopard on it, all the macromedia applications fail to launch. There's a workaround online but it didn't work. :(

I'm PMing with Ka0t1x now about his code. Thanks!

The biggest problem with using flash is that you are using flash :p.

Really, for something simple like this flash is just a bit much, plus it makes it so everything that is taking your quiz must support flash. While most things do, not everything does (think apple stuff, iPhone, iPad, etc).

Other than being a bit much for a quiz, if you already have it available to you then I really don't see too big of an issue using it.