Radio Button Help!
Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller
Radio Button Help!
I am new to revolution, but willing to learn and I am making progress. I am developing test review software. Each test will have 200 questions. I don't have a problem getting the questions on the card and have buttons at the bottom to go to the next question, or previous question and so forth. My problem is each question has 4 answers. Only one of them is right of course. How do I record which radio button the student selected so I can test later on, at the end of the test if the student got that particular question on the card wrong? I need to set it up in such a way that if they choose one answer and select that radio button, then go back and change their answer then the container reflects the changed answer. The radio buttons are mutually exclusive of course. I've done that! Having a real problem with this. Any help or direction would be greatly appreciated.
-
- Livecode Opensource Backer
Re: Radio Button Help!
This behavior is given if you group all four radio buttons within a group. Then only one can be active at a time.stuartls wrote:I need to set it up in such a way that if they choose one answer and select that radio button, then go back and change their answer then the container reflects the changed answer. The radio buttons are mutually exclusive of course. I've done that! Having a real problem with this. Any help or direction would be greatly appreciated.
To get the active one in the group, type something like this:
Code: Select all
put the long id of group "answersOfQuestion24" into tGpRef
put -1 into tResult
repeat for x = 1 to the number of buttons in tGpRef
put the long id of button x of tGpRef into tBtnRef
if the hilited of tBtnRef is true then
put x into tResult
-- put the short name of tBtnRef into tResult
-- put the label of tBtnRef into tResult
exit repeat
end if
end repeat
-- do something with tResult
Can I not do this?
On my final card can I not have a button that says "Grade Exam" and will go to each card and retrieve the hilited button and check it in with an if statement. Thinking the get statement would do it.
Stu, hope this makes sense....
Stu, hope this makes sense....
-
- Livecode Opensource Backer
Re: Can I not do this?
A bit more of new vocabulary for you.stuartls wrote:On my final card can I not have a button that says "Grade Exam" and will go to each card and retrieve the hilited button and check it in with an if statement. Thinking the get statement would do it.
Easy approach: Have in you radio button name some prefix or suffix that unambiguously separate out the correct answer to the question
button 1 -> option1
button 2 -> option2
button 3 -> correct
button 4 -> option4
This way, you can use the repeat above and add as a condition:
Code: Select all
if the short name of button x of group "answerToQuestion24" is "correct" then
if the hilited of button x of group "answerToQuestion24" is true then
-- correct and selected as correct
add 1 to score
else
-- correct but not selected as correct
add -0.5 to score
end if
end if
then you can replace the above with
Code: Select all
if the isCorrect of button x of group "answerToQuestion24" is true then
...
end if
Let me see if I can put this in my terms. I have so far 5 cards. So basically 5 questions. Each question has 4 answers. On the final card I have a button that says "grade exam". Under it,s script is the on mouse up and on mouse down ending. I can go to each card and name each individual button and can name the group that contains the radio buttons. In my terms I want to write in the script. "go back to card # 1027 and find out which button is highlighted and if it is the right one add 1 to the score if not substract one from the score. I have no idea what you mean by short name. I also don't know what you mean by "x". Here is the script that i have typed into the button that says "grade exam".
on mouseUp
put the hilitedButtonID of group 1012 of cardIDs 1002 into tGpRef
if tGpref=1005 add 1 to field "right"
else add 1 to field "wrong"
end mouseUp
It doesn't work. I have named the fields as a type of counter that is visible. Don't know why.
on mouseUp
put the hilitedButtonID of group 1012 of cardIDs 1002 into tGpRef
if tGpref=1005 add 1 to field "right"
else add 1 to field "wrong"
end mouseUp
It doesn't work. I have named the fields as a type of counter that is visible. Don't know why.
Hi stuartls,
1. you can check the currently hilited radiobutton in a group much more effective with:
...
the hilitedbutton of grp "radio group"
## Will return the NUMBER of that button IN that group
## NOT the number of the button on the card!
## or use
the hilitedbuttonname of grp "radio group"
## will return the NAME of the button
...
Really NO need to loop through all the buttons
2. What exactly do yopu mean "It doesn't work" with "hilitedbuttonid"?
Does work here for me!?
Regards
Klaus
1. you can check the currently hilited radiobutton in a group much more effective with:
...
the hilitedbutton of grp "radio group"
## Will return the NUMBER of that button IN that group
## NOT the number of the button on the card!
## or use
the hilitedbuttonname of grp "radio group"
## will return the NAME of the button
...
Really NO need to loop through all the buttons

2. What exactly do yopu mean "It doesn't work" with "hilitedbuttonid"?
Does work here for me!?
Regards
Klaus
-
- Livecode Opensource Backer
It's a very bad way to go, to make 200 cards, on for each question...
Suppose you want to change the positions of the radio buttons or the appearance of the interface... you are not going to change each card individually...
Your best solution is to have only 1 card containing 4 radio buttons...
And change their names as the student advances in the exam...
You can store your questions and answers in a field on a second card... the "dataCard" for instance...
To learn the general scripting language, the documentation is your best friend... when you are puzzled by terms like "the short name", just type "name" in the dictionary, and you'll understand everything... check out the pre-made scripts too, called "recipes"; they can give you a feel for string manipulation and repeat loop structure.
Cheers.
Suppose you want to change the positions of the radio buttons or the appearance of the interface... you are not going to change each card individually...
Your best solution is to have only 1 card containing 4 radio buttons...
And change their names as the student advances in the exam...
You can store your questions and answers in a field on a second card... the "dataCard" for instance...
To learn the general scripting language, the documentation is your best friend... when you are puzzled by terms like "the short name", just type "name" in the dictionary, and you'll understand everything... check out the pre-made scripts too, called "recipes"; they can give you a feel for string manipulation and repeat loop structure.
Cheers.
Well it going to be 200 cards for each practice test. I do agree that there should, and probably is an easier way to go. That is why I'm only going to do a practice test with only 5 questions. I want the program to fully work before I add the other 195 questions and answers. I'm hoping that as I just put together the smaller test that different ways will emerge to do it more efficently and easier. I do agree with your suggestion of the online documentation. It does help me. I'm just learning as you well know and picking up pieces of advice from people such as yourself helps people like me greatly. I DO strongly believe at THIS time that the "Software at the speed of thought" book by Dan Shafer was a waste of my money. I find it to not be a good book to teach the software and certainly not for reference. I frankly find it poorly written. BUT I certainly want to thank you for any quidance you can give me!
Thanks again X
Stu
Thanks again X
Stu