2 Replies Latest reply on Aug 14, 2010 7:19 AM by webster_1c

    Multiple choice questions with more than one correct answer

    webster_1c

      hi all

       

      Ned kindly helped  with the code below. However i was wondering if i could ask for some help to amend the code below so that a user could select more than one answer. So for example they select two options and recieve one feedback, but  if they select the wrong option they get seperate feedback.

       

       

      var ans1 = 0;
      var checkboxListener:Object = new Object();
      checkboxListener.click = function(evt_obj:Object) {

      if (evt_obj.target.selected) {
        checkBox1a.selected = false;
        checkBox1b.selected = false;
        checkBox1c.selected = false;
        checkBox1d.selected = false;
       
        evt_obj.target.selected = true;
       
        if(evt_obj.target == checkBox1a){
           txtOutput.text="You picked an apple";
           ans1 = 0;
        } else  if(evt_obj.target == checkBox1b){
           txtOutput.text="You picked a pear";
           ans1 = 1;
        } else  if(evt_obj.target == checkBox1c){
           txtOutput.text="You picked bananas";
           ans1 = 0;
        } else  if(evt_obj.target == checkBox1d){
           txtOutput.text="You picked grapes";
           ans1 = 0;
        }

      } else {
        ans1 = 0;

        txtOutput.text = "";
      }
      };
      checkBox1a.addEventListener("click", checkboxListener);
      checkBox1b.addEventListener("click", checkboxListener);
      checkBox1c.addEventListener("click", checkboxListener);
      checkBox1d.addEventListener("click", checkboxListener);

        • 1. Re: Multiple choice questions with more than one correct answer
          Ned Murphy Adobe Community Professional & MVP

          I think the only way to do it with the approach you are taking now is to offer check boxes that have selection such as "both A and B".  You otherwise may have to take an entirely different approach to the interaction, where you don't use listeners for the checkboxes anymore, but instead use a button that gets clicked when a user is ready to have their choice(s) evaluated.  If you use the listeners still, then each time a selection is made, the evaluation is made... and if the user is intent on making one selection only where two are called for, they'll be wondering what they have to do next if the code is somehow waiting for another selection to be made.

           

          Think thru the process of what has to happen with the processing and pursue that.  You don't need to know the code to think thru how you'd have to process things, but in determining that process, the code normally flows directly from that determination.

          1 person found this helpful
          • 2. Re: Multiple choice questions with more than one correct answer
            webster_1c Level 1

            Thanks for the advice Ned, will have a think through.

             

            Cheers