PDA

View Full Version : Database Drawing


imported_g0ldman
04-17-2004, 04:26 PM
Hello,

I think it's fairly easy. All I want to do is have a database of questions - about 5,000 (don't worry, I'll put them in, you don't have to lol) and then whenever someone accesses a webpage, it randomly draws 20 questions out of the database and displays them onto the webpage in a multiple choice quiz. I want to be able to put images into some of the questions. Then, once the quetsions are there, the person who accessed the page answers the questions, hits a submit button, and vuala, there's a list of the questions she/he got right, wrong, and what the correct answers are. There's also a mark. Thank You!

-Tyler

Whiteknight
04-22-2004, 02:42 PM
I dont have alot of time to write alot of code for you right now, but i can give you a general idea.

I assume you are going to be storeing your questions and answers in an external file, correct?

if so, lets say you format your data file something like this:

Question1 || answer1a || answer1b|| answer1c ||etc..
%%
question2 || answer2a ||answer 2b || answer 2c || etc...

which is perhaps a little ungainly, but it will make your code in PERL simple enough to write.

then, you could use some split statements

@questions = split(/\n\%\%\n/, $filedatastring);
foreach $question (@questions)
($Q[x], %A[x]) = split(/\|\|/, $question);
...


thats the bare gist of it, and if you need me to elaborate, i'll be back later. good luck!