Link to home
Start Free TrialLog in
Avatar of legolasgreenleaf
legolasgreenleaf

asked on

Drawing from a Database

Hello,

You may have noticed this isn't worth barely anything - and that's becuase I don't know if it is possible.  If it is, I will raise the points to a desired level for whoever wants to program my script.  

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 a also a mark.  Please tell me if I can do this, and then I will raise the point value and then you can make me the script.  Thank You!

-Tyler  
Avatar of dorward
dorward

It shouldn't be too difficult.

In the database you can have the following fields:

id - a unique integer to identify the question
question
url to image
answer a
answer b
answer c
answer d
correct answer

You can first issue the query: SELECT count(*) from tablename
Then pick 20 random numbers between 1 and that result (checking to see if you have picked one already)

For each of those numbers: SELECT * from tableneame WHERE id='number of question'

You can then structure your form along the lines of:
<p>Question</p>
<input type="radio" name="question23" value="a"> Answer A
etc

When you submit the form, you check to see the name of the submitted paramerts. From these you can extract the number of the question and SELECT answer from tablename where id='number of the question' to see if it is right or not.

Avatar of legolasgreenleaf

ASKER

Thank You!  Can you please write my a CGI file that can do all this?  Tell me how much you think it's worth for you to make a script like this and tell me.  If it's reasonable, I will increase the point value to that level which you told me.  Then you can write me the script, I'll try it out and make sure it will work, and I'll reward you you're well-deserved points!  Thank you!!!
What type of database are you going to use?  Also I would recommend putting the image tags directly into the question field.  You can format them there to look exactly how you want them to.  And its one less thing to worry about.
No amount of EE points is going to make it worth my while writing this script from scratch. It isn't difficult, but it is somewhat time consuming and I have other projects which will benefit me far more then more EE points.

As for putting the image tags directly in the question field - I wouldn't. I would leave the whole thing as plain text. This gives greater flexibility for handing the data. For example, you could have the script email the results to you with the questions selected, or write a non-browser-based frontend - that is somewhat harder to do if you have to strip out HTML from it.
I'm sorry.  I don't know much about CGI.  I'll try to work it out.  Thanks anyway!
ASKER CERTIFIED SOLUTION
Avatar of MatthewP
MatthewP
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial