quizzes

docmax

New Member
Hi experts,

How do I write a code for creating quizzes? The following format is an example:

Question? Click on your choice below:

a)...
b)...
c)...
d)...

A pop-up will occur indicating whether you are right or wrong (i.e., the choices are linked to a respone to the click).

Thanks for any suggestions and assistance.
 

derez

Expert
Licensed User
Longtime User
I havemore questions then answers, because the code is the last part - first you need a system design, which answers for the way you want this game to work.

- how many questions ?
- are they to be ordered or random ?

A very simple possible solution is like that:
1. keep each question + answers in a text file, named n.txt, where n is the question number.
2. an array will keep the number of correct answer to each question number.
3. A large label will display the question, using:
FileOpen(c1,AppPath & "\" & n & ".txt",cRead)
label1.Text = FileReadToEnd (c1)
Fileclose(c1)
4. four buttons below the label will enable the user to select the answer.
5. the code in each button_click sub will check the answer by comparing it to the array item, add or not the mark to a mark accumulator, and randomize the next question.

This solution will require many files so it is better to arrange the database in other ways which are more complicated.
 
Last edited:

mjcoon

Well-Known Member
Licensed User
... and randomize the next question.

I would think that it is more important to randomise where in the sequence of answers the correct answer appears, but still to be able to verify which one this is!

(As Derez says, it is best to do system design first. But there's nothing wrong with experimenting with coding a simple initial design first, so long as you are prepared to discard much of it as design progresses. Otherwise the resulting program shows too much of its tortuous developmental meanders...)

Mike.
 
Top