1 Reply Latest reply on Mar 14, 2008 12:04 PM by jp77

    Layout of multiple choice question+possible answers

      Good day,

      I want to setup a multiple choice questionnaire. The question title and question possible answers are returned to flex from db in xml data format. I would like to display 2 questions at a time. The amount of questions will vary per test, but always more than 2, so I would need some pagination mechanism. I have successfully rendered the all the questions on top of a canvas using a repeater control with a label (for the question title) and a list (for the question possible answers). The list values are set at run time using the repeater [index] notation to access list children and the label text property is bound to the repeater dataprovider currentindex data. But now I don't want to have all the questions showing at once, only 2 at a time with a next button. I can successfully set this up with the list control in my repeater object, however the label control will not react. Here is my code:

      <mx:Repeater id="quesRepeater">
      <mx:Label id="quesTitle" text="loading..." fontSize="12" fontWeight="bold" color="#400040"></mx:Label>
      <mx:List id="ques_list" labelField="Question" width="599" borderStyle="none" click="ans_ID=event.currentTarget.selectedItem.ID; ans_QuesID=event.currentTarget.selectedItem.QuesID; ans_QuesText=event.currentTarget.selectedItem.Question; addAns_Array(ans_ID, ans_QuesID, ans_QuesText)"></mx:List>

      private function pop_quesList():void{
      for (var i:Number=curr_quesno; i<des_quesno; i++){
      ques_list .dataProvider = course_quesList..record.(QuesLevel==1 && QuesID==i);
      .text=course_quesList..record .(OrdinalPos==0).Question;
      Everything works except ...
      ** this line returns the correct value, but fails to set the text property of the label in the repeater. (the builder error is 'Access of undefined property quesTitle') - yet the lable id is quesTitle.

      Am I missing something here?? or if anyone has an alternative method (completely) to suggest, please can help- this is the last part of bigger project that I really want to complete and move on from.

      Thanks in advance,


      PS: Using flex 3 if that helps.
        • 1. Re: Layout of multiple choice question+possible answers
          jp77 Level 1
          Ok I have it working - hotwired maybe but hey I'm just a beginner. Any suggestions for a better solution are still welcome.

          Basically created a virtual array to be a separate dataprovider for my repeater, label control. The array contained only 2 questions. Updated the array at the same time as my questions for loop, thus keeping the correct question with the correct answer choices. The for loop was excuted with a new starting value after a next button was click and ta da it works with pagination and labels and questions.

          If anyone wants help with this, feel free to contact me.

          cheers, JP