Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do I make a multiple-choice test using buttons?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Yoda




PostPosted: Thu Nov 11, 2004 12:02 pm   Post subject: How do I make a multiple-choice test using buttons?

How do I make a multiple-choice test using buttons? It's going to have 15 questions, and is going to count the number of correct answers, displaying the final score at the end. How do I do this? General tips, or maybe even a full program outline would be really nice. Thanks.
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Thu Nov 11, 2004 6:59 pm   Post subject: (No subject)

Hello and welcome to CompSci.ca...

So, you want to make a multiple choice test. Ok, first thing to understand is that you're not making a multiple choice test...you're making a programme that's going to receive input from the User as a result of various text-based instructions presented to them via the monitor. This input will then be validated, and if it is viable, it will be compared with stored data (the "correct answers"). Subsequent output will inform the User as to the verity of their input.
Got that? Good.

Now, it sounds like you'll be using GUI in this...I feel large amounts of sympathy for you, OOT GUI sucks majorly. But once you get to know how to use it, you can make some pretty nifty masks.

I hope you realise that that little spiel up there was a good programme overview...

What you'll want to do, to elicit more help is to post code that you have already made. You'll get far more help if you're asking for debug suggestions and the like than if you're asking for raw code (rarely provided).

Enjoy your stay.
Neo




PostPosted: Thu Nov 11, 2004 10:18 pm   Post subject: (No subject)

I dont understand what is it with the built in GUI? Why do people use them? Cant you just make your own buttons with drawbox and draw oval or sumthing?
Delos




PostPosted: Fri Nov 12, 2004 8:58 am   Post subject: (No subject)

Yes you could, but would you honestly want to sit down and right all the event handling for that as well? The idea behind OOT's GUI is that you can create a bunch of objects that have useful properties, and in a single loop all of them can be kept under control.
Ever had a look through the GUI modules? Stuff in there is not fun.
So, despite their limited functionality and almost unlimited ability to irk, they have their uses.
Yoda




PostPosted: Fri Nov 12, 2004 12:08 pm   Post subject: (No subject)

This is the flawed program for a single question, using buttons and such. Everything in tags are wrong according to the computer.


import GUI

var count:int :=0

procedure pro
put "Time for The Tech Class quiz of DOOM"
delay (1000)
put "What is two plus two?"
var cb1 : int := GUI.CreateButton (10, 35, 0, "1", pro)
var cb2 : int := GUI.CreateButton (100, 35, 0, "2", pro)
var cb3 : int := GUI.CreateButton (10, 5, 0, "3", pro)
var cb4 : int := GUI.CreateButton (100, 5, 0, "4", pro)
% In case we drew over the buttons, redraw them.
GUI.Refresh
end pro

View.Set ("graphics:300;200,nobuttonbar ")
var draw : int := GUI.CreateButtonFull (50, 10, 0, "answer",
pro, 0, '^D', true)
var quitBtn : int := GUI.CreateButton (200, 10, 0, "Quit", GUI.Quit)
loop
exit when GUI.ProcessEvent
end loop
var cb1Status : boolean := <GUI.CreateButton>
var cb2Status : boolean := <GUI.CreateButton>
var cb3Status : boolean := <GUI.CreateButton>
var cb4Status : boolean := <GUI.CreateButton>
if cb1Status then
put "Wrong"
else
put ""
end if
if cb2Status then
put "Wrong"
else
put ""
end if
if cb3Status then
put "Wrong"
else
put ""
end if
if cb4Status then
put "Right"

else
put ""
end if

-------

As you can see, it's that one place, and they're all the same problems. This is for a computer class, and the teacher (and the help file) can't help me on this problem because they're both incompetent. Do you see the problem in it?
Delos




PostPosted: Fri Nov 12, 2004 3:00 pm   Post subject: (No subject)

First off, pls pls use [code] tags. They will make everyone's lives much easier.

From your code, I see that you have the right idea of what to do, just that you don't know how to translate that into code.
- procedures that are associated with buttons are supposed to characterize the button's job. For example, button labelled "Run WordPad" would link to a procedure that would execute the said programme.
Likewise, a button that gives a possible answer could be linked to a procedure that sets a flag to either true or false depending on the answer (long, hardcoded method), or to a procedure with parameters that could then be used to figure out if the given response is right or wrong. Sound confusing?
Think about this: any given button is either right or wrong (T/F). When the button is created, it can link to a single procedure with a qualification as to its state.

- 'var cb1Status : boolean := <GUI.CreateButton>' cb1Status is a boolean variable. GUI.CreateButton() is a function that returns an integral value. Hence the two cannot go together.

- your 'exit when GUI.ProcessEvent' statement generally goes right at the end of your programme, unless you really need to have stuff going on afterwards.

- I can't stress enough how vital it is for you to learn the multiple and often amazingly useful nature of parameters in procedures. Seriously, they'll do wonders for you. Also, try get out of the habit of hardcoding from now...the earlier you realise that variables and constants are you friends, the better off you'll be down the road.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: