Creating a short question answer with radio buttons

Peter Haworth pete at lcsql.com
Fri Aug 31 20:43:23 EDT 2012


Hi Shawn,
Probably lots of ways to do this, here's one.

First thing to do is put the checkboxes for each question into a group -
that ensures that only one can be selected at a time.  You might call the
groups Q1, Q2, Q3, etc

Then define a custom property of each group that specifies the correct
answer in terms of the name of the checkbox.  In your example, you'd call
your buttons 1,2,3,4 and the custom property (let's call it
"correctAnswer") of group Q1 would have the value 4.

FInally, when your user indicates that they've finished answering
questions, you'd use a repeat loop like this

put the groupIDs of this card into tGroupIDs
put zero into tRight
put zero into tWrong
repeat with each line tGroupID in tGroupIDS
   if the correctAnswer of group ID tGroupID is not empty and the
hilitedbuttonname of group ID tGroupID is the correctAnswer of group ID
tGroupID then
      add 1 to tRight
   else
      add 1 to tWrong
   end if
end repeat
<Do whatever you want to do with tRight and tWrong here>

Only thing to watch out for is that the GroupIDs property includes only the
top level groups on a card so be sure that your Qn groups aren't contained
within any other groups.  The first condition of the if statement above
deals with any toher groups you might have on the card that are not
question groups, since they won't have a correctAnswer cprop.

I haven't tested any of that but it should work.  No doubt you'll get
other, equally as good, solutions.

Hope that helps.

Pete
lcSQL Software <http://www.lcsql.com>



On Fri, Aug 31, 2012 at 5:17 PM, Shawn Blc <shawnlivecode at gmail.com> wrote:

> Disclaimer:  I'm totally new to LiveCode, bought Colin's PDF file, read the
> scripting conference stack on controls, etc.  As of yet, I haven't really
> created anything of value to me or anyone else.  I'm trying to change that.
>  I've had the Gold Bundle for over a month.
>
> I'm trying to create a short question and answer program, the answers will
> be supplied in radio buttons.  Example:   A square has how many sides?   A)
> 1 B) 2 C) 3 D) 4 (these would be radio buttons).
>
> I'll have to keep track of the right and wrong answer and show a score at
> the end.
>
> If anyone can give me a short example or show me where to find it, thank
> you.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list