Solved

Drawing from a Database

Posted on 2004-04-17
9
155 Views
Last Modified: 2013-12-25
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  
0
Comment
Question by:legolasgreenleaf
9 Comments
 
LVL 17

Expert Comment

by:dorward
ID: 10851134
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.

0
 

Author Comment

by:legolasgreenleaf
ID: 10851740
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!!!
0
 
LVL 1

Expert Comment

by:bkiahg
ID: 10851832
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.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 17

Expert Comment

by:dorward
ID: 10852394
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.
0
 

Author Comment

by:legolasgreenleaf
ID: 10854416
I'm sorry.  I don't know much about CGI.  I'll try to work it out.  Thanks anyway!
0
 
LVL 6

Accepted Solution

by:
MatthewP earned 50 total points
ID: 10861740
If you want a good beginners guide to CGI, have a look at http://www.cgi101.com. This is based around the Perl language, and there's plenty of people on here who'll more than happily help you out with the little bits if you get stuck.

Matt.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Python Encoding Problem \u2013 4 107
Perl script to find new files and compress those new files 5 81
Disk Ram Peak 1 33
Sums of coloumns in html/java 15 66
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to dynamically set the form action using jQuery.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now