Page 1 of 1

radio buttons - Multiple choice question

Posted: Mon Oct 05, 2009 3:51 am
by therock777
Hi All,
I'm completely new to RunRev, so please bear with me. what I'm trying to do is very simple, however I can't get it right.

I'm trying to create a 1 question multiple choice quiz for testing purposes, I'm using radio buttons with 4 possible choices. My question is, how do I refer in the script to the correct answer? here is my script.

on mouseUp
if button "firstone" is selected then
answer "Good"
else
answer "Wrong"
end if

end mouseUp

even when the correct choice is being selected, I still get the wrong answer.

what am I doing wrong?

Please advise, or point me to the right direction on working with radio buttons.

Thanks,

Posted: Mon Oct 05, 2009 6:14 am
by Janschenkel
If you haven't done so already, group the four radio buttons. Then use the inspector palette to turn on the radigroupBehavior property of that group.
Now the engine will automatically handle the hiliting-only-one-option part. Next, lookup the following temrs in the rev dictionary: hilitedButton, hilitedButtonId, hilitedButtonName.

HTH,

Jan Schenkel.

Posted: Mon Oct 05, 2009 8:14 pm
by therock777
Hi Janschenkel,
Thanks for your reply, based on the outcome I got by following your instructions, it looks like this option allows you to set the default value for a radio button. However, what I'm trying to achieve here is, to have the program to make the correct decision based on the user response.

for example:
if button "Radio1" of group "RadioGroup" is selected then
answer "Correct!"
else
answer "Wrong"
end if

Is this correct?
I apologize for my lack of knowledge, I'm coming from the python programing language, and the environment is totally different.

Thanks,

Posted: Mon Oct 05, 2009 9:17 pm
by Paul D
I use the hilitedbuttonname syntax but you can use hilitedbutton for the number of the button if needed.

Edit the script of the group that your buttons are in.

Code: Select all

on mouseup
if the hilitedbuttonname of group "radiogroup" <> "thecorrectanswer" then
answer "Wrong"
else
answer "Right"
end if
end mouseup

Code: Select all

on mouseup
if the hilitedbutton of group "radiogroup" <> 1 then
answer "Wrong"
else
answer "Right"
end if
end mouseup
change the button number to the number of the correct button. you find the button number under size & position in the property inspector... this what you mean?

Posted: Tue Oct 06, 2009 12:50 am
by therock777
Thanks Paul D,

This is exactly what I needed, it works now!

Do you know of any Run Rev books, in addition to the user manual? I have been reading the manual, but I need something more informative and concise.

Thanks Again!

Posted: Tue Oct 06, 2009 1:29 pm
by Paul D
the only book ive read is Software at the Speed of Thought by Dan Shafer. Its maybe a bit outdated but goes over the basics. You can actually download the examples in the book from runrev...

http://www.runrev.com/downloads/all-dow ... -examples/

Posted: Tue Oct 06, 2009 5:22 pm
by therock777
I'll look into it, Thanks.