• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to best keep track of answer count?

Engaged ,
Sep 17, 2010 Sep 17, 2010

Copy link to clipboard

Copied

I have a quiz created in Flex using Spark forms, with a series of questions which are a group of radio buttons.  When the user clicks "next", I get the value of the selected radio button in the group.

What I need to do is keep track of these values; at the end of the quiz I will need to see which value was chosen the most. So if the user mostly picked the questions with a "3" value, I can display a summary based on that, e.g. "You mostly chose type 3 answers".

I was thinking about having an int variable for every choice (there are 5), and incrementing the appropriate variable when the user clicks "next", as in

private function enterScore(i:int):void {

switch (i){

     case 1:

     num1++;

     break;

But this seems unwieldy.  Can anyone suggest a better way?

I also will need to compare the 5 tallies for which one was chosen the most...  Any ideas on that?

Thanks.

TOPICS
ActionScript

Views

381

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 17, 2010 Sep 17, 2010

Copy link to clipboard

Copied

LATEST

an associative array would be pretty straight-forward:

var answerObj:Object={};

.

.

.

.

if(answerObj[radiogroupvalue]){

answerObj[radiogroupvalue]++;

} else {

answerObj[radiogroupvalue]=1;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines