0 Replies Latest reply on May 15, 2009 5:37 AM by wgb14

    Combination question

    wgb14 Level 1

      Hi all

       

      I wonder if someone can help me with this.

       

      I have an XML database in the following format:

       

      -- Main Questions (Level0)

       

      Q1

      Q2

      Q3

      Q4

       

       

      Each of these questions load another set of questions as follows: (Level1)

       

      <subQ>SubQ1

                    SubQ2

                     SubQ3

                     SubQ4</SubQ>

       

       

       

      Once the user clicks on any of the subquestions, the question is gone and the others rewritten. For example, if the user clicks on SubQ1 the output is as follows: (level2)

       

      SubQ2 (re-written)

      SubQ3(re-written)

      SubQ4(re-written)

       

       

       

      Or of the user clicks on SubQ2 the output should be as follows:

       

      SubQ1(re-written)

      SubQ3(re-written)

      SubQ4(re-written)

       

       

       

      The re-written questions will be specified in the XML databases as follows:

       

      <q1> SubQ1(re-written)</q2>

      <q2>SubQ2(re-written)</q2>

      <q3>SubQ3(re-written)</q3>

      <q4>SubQ4(re-written)</q4>

       

       

       

       

      So far my code is as follows:

       

       

       


      global

       

      level1,gmain

      on

       

      mouseDown (me)

      pointClicked =

      _mouse.mouseLoc

      thisSprite =

      sprite(me.spriteNum)

      currentMember = thisSprite.

      member

      lineNum = thisSprite.

      pointToLine(pointClicked)

      lineText = currentMember.

      line[lineNum]

       

      -- level 0 (Main Questions)

      If

       

      level1 = VOID and lineN)um = 1 then

       

      member

       

      ("container").text = gmain[1].Architecture.MainQuestions["!CHARDATA"]

      level1=

      "a"

       

         else

       

       

       

      -- level1 (Sub Questions of main questions)

       

      if

       

      level1 = "a" AND lineNum = 1 then

       

       

      member

       

      ("container").text = gmain[1].Architecture.SubQuestions1["!CHARDATA"] --the subquestions of question1

       

      level1=

      "two"

       

      else

       

       

       

       

      if

       

      level1 = "b" AND lineNum = 1 then

       

       

      member

       

      ("container").text = gmain[1].Architecture.Q2["!CHARDATA"] & gmain[1].Architecture.Q3["!CHARDATA"] & & gmain[1].Architecture.Q4["!CHARDATA"]

       

       

      level1= "three"

      end if

       

       

      end if

       

       

       

       

       

      end if

       

       

       

       

      end

       

       

       

      Going from the main questions to the subquestions (level1=VOID -> Level1="a") is easy. However, When the user clicks on any of the subquestions (and given that he can click only one question/time) its extremely tedious to write all the combinations by hand. For example, if the subquestions are 4 the last part of the above code should read as follows. Since we want the clicked question eliminated, we end up with 4 combinations of three numbers/questions.

      if level1 = "b" AND lineNum = 1 then

      member ("container").text = gmain[1].Architecture.Q2["!CHARDATA"] & gmain[1].Architecture.Q3["!CHARDATA"] & gmain[1].Architecture.Q4["!CHARDATA"]

       

       

      if level1 = "b" AND lineNum = 2 then

      member ("container").text = gmain[1].Architecture.Q1["!CHARDATA"] & gmain[1].Architecture.Q3["!CHARDATA"] &gmain[1].Architecture.Q4["!CHARDATA"]

      combination = "two"

       

      if level1 = "b" AND lineNum = 3 then

      member ("container").text = gmain[1].Architecture.Q1["!CHARDATA"] & gmain[1].Architecture.Q2["!CHARDATA"] & gmain[1].Architecture.Q4["!CHARDATA"]

      combination = "three"

       

      if level1 = "b" AND lineNum = 4 then

      member ("container").text = gmain[1].Architecture.Q1["!CHARDATA"] & gmain[1].Architecture.Q2["!CHARDATA"] & & gmain[1].Architecture.Q3["!CHARDATA"]

       

       

       

      If you want to go one level down you will end up with 6 combinations (2 x 2 x 2) of numbers/questions as follows

       

       

      if level1 = "c" AND lineNum = 1 then

      member ("container").text = gmain[1].Architecture.Q3_1["!CHARDATA"] & gmain[1].Architecture.Q4_1["!CHARDATA"]

       

       

      if level1 = "c" AND lineNum = 2 then

      member ("container").text = gmain[1].Architecture.Q2_1["!CHARDATA"] & gmain[1].Architecture.Q4_1["!CHARDATA"]

       

       

      if level1 = "c" AND lineNum = 3 then

      member ("container").text = gmain[1].Architecture.Q2_1["!CHARDATA"] & gmain[1].Architecture.Q3_1["!CHARDATA"]

       

       

      if level1 = "c" AND lineNum = 2 AND combination = "two" then

      member ("container").text = gmain[1].Architecture.Q1_1["!CHARDATA"] &gmain[1].Architecture.Q4_1["!CHARDATA"]

       

       

       

      if level1 = "c" AND lineNum = 3 AND combination = "two" then

      member ("container").text = gmain[1].Architecture.Q1_1["!CHARDATA"] &gmain[1].Architecture.Q3_1["!CHARDATA"]

       

       

       

      if level1 = "c" AND lineNum = 3 AND combination = "three" then

      member ("container").text = gmain[1].Architecture.Q1["!CHARDATA"] & gmain[1].Architecture.Q2["!CHARDATA"]

       

       

       

       

      As this is a rather sloppy way of writing code is there any other way to do it?

       

      Many thanks for any help!!!