0 Replies Latest reply on Jul 2, 2011 6:43 PM by kayjs

    Question about Multiple Choice Quiz

    kayjs Level 1

       

      I have multiple choice quiz that I'd like make more complex. The quiz is based on a movie clip with a series of questions on different frames and the same set of answer buttons on each frame (no keyframes on the answer button layer). The user clicks a button to go from one question to the next. There’s a scoring mechanism that displays the number of correct answers (score), the total number of answers clicked (right or wrong), and the percentage of right answers.

       

      For each question, only the first answer counts toward the score. If you click correctly the first time, a point is added to the score and to the total. If you click incorrectly the first time, a point is added to the total only. After you give the first answer, right or wrong, you can still click on all the answers to see which answer was correct; the correct answer button changes in appearance and the correct sound cue plays but no point is added to the score or total. If you click on a wrong answer after you’ve given the first answer, the incorrect sound cue plays but no point is added to the total. In other words, you can’t help or hurt your score after clicking on the first answer, but you can determine which answer was correct.

       

      This all works fine.

       

      But now I want to make a similar exercise that has TWO questions on each frame. The answers both come from the same set of answer buttons. The question is how to preserve the “only the first click counts” mechanism for each of the two answers, since clicking on the answer to the first question will mark the frame as “answer has been given” and prevent any further scoring. There needs to be a point given for each correct answer on the frame.

       

      Here’s the code from an answer button in the existing quiz. How would I modify this to allow for two answers per frame?

       

      on (press) {

       

                      /* This code executes whether this is the first click on the answer button or a subsequent click. If the answer is correct (if this is frame 1 or 3), the correct sound cue plays and the answer button changes its appearance, and if the answer is incorrect (if this is any other frame), the incorrect sound cue plays */

       

                      if (_currentframe == 1){

                              _parent.snd_obj.playsound("correct", "cue1");

                              answer1_mc.gotoAndStop(2);

       

                      }else if (_currentframe == 3){

                              _parent.snd_obj.playsound("correct", "cue1");

                              answer1_mc.gotoAndStop(2);

       

                      }else{

                              _parent.snd_obj.playsound("incorrect", "cue2");

       

                      }

       

                      /* This code executes only if this is the first click on the answer button. It checks to see if an answer has been clicked in this frame, and if not, it marks the answer as given (so this code will be executed only once) and then adds one point to the total, one point to the score for correct answers, and re-calculates the percentage */

       

                      if (!_parent.answerGiven[_currentframe]) {

                              _parent.answerGiven[_currentframe] = true;

                              _parent.total = _parent.total + 1;

                              _parent.percent = Math.round((_parent.score / _parent.total) * 100);

       

                             if (_currentframe == 1){

                                     answer1_mc.gotoAndStop(2);

                                     _parent.score = _parent.score + 1;

                                     _parent.percent = Math.round((_parent.score / _parent.total) * 100);

       

                            }else if (_currentframe == 3){

                                 answer1_mc.gotoAndStop(2);

                                 _parent.score = _parent.score + 1;

                                 _parent.percent = Math.round((_parent.score / _parent.total) * 100);

       

                             }else{

                                 _parent.snd_obj.playsound("incorrect", "cue2");

       

                                }

                     }

           }